From 44755e6e86770324934480d169a2d1e79215b942 Mon Sep 17 00:00:00 2001 From: Brent Westbrook <36778786+ntBre@users.noreply.github.com> Date: Fri, 8 Aug 2025 12:56:23 -0400 Subject: [PATCH] Move full diagnostic rendering to `ruff_db` (#19415) ## Summary This PR switches the `full` output format in Ruff over to use the rendering code in `ruff_db`. As proposed in the design doc, this involves a lot of changes to the snapshot output. I also had to comment out this assertion with a TODO to replace it after https://github.com/astral-sh/ruff/issues/19688 because many of Ruff's "file-level" annotations aren't actually file-level. They just happen to occur at the start of the file, especially in tests with very short snippets. https://github.com/astral-sh/ruff/blob/529d81daca30e0af93a18d7406bd2c419008e8f4/crates/ruff_annotate_snippets/src/renderer/display_list.rs#L1204-L1208 I broke up the snapshot commits at the end into several blocks, but I don't think it's enough to help with review. The first few (notebooks, syntax errors, and test rules) are small enough to look at, but I couldn't really think of other categories beyond that. I'm happy to break those up or pick out specific examples beyond what I have below, if that would help. The minimal code changes are in this [range](https://github.com/astral-sh/ruff/pull/19415/files/abd28f1e776e442379186e9f24c9aa6290f64163), with the snapshot commits following. Moving the `FullRenderer` and updating the `EmitterFlags` aren't strictly necessary either. I even dropped the renderer commit this morning but figured it made sense to keep it since we have the `full` module for tests. I don't feel strongly either way. ## Test Plan I did actually click through all 1700 snapshots individually instead of accepting them all at once, although I moved through them quickly. There are a few main categories: ### Lint diagnostics ```diff -unused.py:8:19: F401 [*] `pathlib` imported but unused +F401 [*] `pathlib` imported but unused + --> unused.py:8:19 | 7 | # Unused, _not_ marked as required (due to the alias). 8 | import pathlib as non_alias - | ^^^^^^^^^ F401 + | ^^^^^^^^^ 9 | 10 | # Unused, marked as required. | - = help: Remove unused import: `pathlib` +help: Remove unused import: `pathlib` ``` - The filename and line numbers are moved to the second line - The second noqa code next to the underline is removed ### Syntax errors These are much like the above. ```diff - -:1:16: invalid-syntax: Expected one or more symbol names after import + invalid-syntax: Expected one or more symbol names after import + --> -:1:16 | 1 | from foo import | ^ ``` One thing I noticed while reviewing some of these, but I don't think is strictly syntax-error-related, is that some of the new diagnostics have a little less context after the error. I don't think this is a problem, but it's one small discrepancy I hadn't noticed before. Here's a minor example: ```diff -syntax_errors.py:1:15: invalid-syntax: Expected one or more symbol names after import +invalid-syntax: Expected one or more symbol names after import + --> syntax_errors.py:1:15 | 1 | from os import | ^ 2 | 3 | if call(foo -4 | def bar(): | ``` And one of the biggest examples: ```diff -E30_syntax_error.py:18:11: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:18:11 | 16 | pass 17 | 18 | foo = Foo( | ^ -19 | -20 | -21 | def top( | ``` Similarly, a few of the lint diagnostics showed that the cut indicator calculation for overly long lines is also slightly different, but I think that's okay too. ### Full-file diagnostics ```diff -comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> comment.py:1:1 +help: Insert required import: `from __future__ import annotations` + ``` As noted above, these will be much more rare after #19688 too. This case isn't a true full-file diagnostic and will render a snippet in the future, but you can see that we're now rendering the help message that would have been discarded before. In contrast, this is a true full-file diagnostic and should still look like this after #19688: ```diff -__init__.py:1:1: A005 Module `logging` shadows a Python standard-library module +A005 Module `logging` shadows a Python standard-library module +--> __init__.py:1:1 ``` ### Jupyter notebooks There's nothing particularly different about these, just showing off the cell index again. ```diff - Jupyter.ipynb:cell 3:1:7: F821 Undefined name `x` + F821 Undefined name `x` + --> Jupyter.ipynb:cell 3:1:7 | 1 | print(x) - | ^ F821 + | ^ | ``` --- crates/ruff/tests/integration_test.rs | 273 ++++++---- .../snapshots/lint__output_format_full.snap | 15 +- .../src/renderer/display_list.rs | 15 +- crates/ruff_db/src/diagnostic/render.rs | 43 +- crates/ruff_db/src/diagnostic/render/full.rs | 56 +++ ...linter__message__text__tests__default.snap | 20 +- ...ter__message__text__tests__fix_status.snap | 20 +- ...ssage__text__tests__fix_status_unsafe.snap | 20 +- ...message__text__tests__notebook_output.snap | 21 +- ...__message__text__tests__syntax_errors.snap | 7 +- crates/ruff_linter/src/message/text.rs | 44 +- ...les__airflow__tests__AIR001_AIR001.py.snap | 15 +- ...les__airflow__tests__AIR002_AIR002.py.snap | 10 +- ...ests__AIR301_AIR301_airflow_plugin.py.snap | 28 +- ...airflow__tests__AIR301_AIR301_args.py.snap | 114 +++-- ...sts__AIR301_AIR301_class_attribute.py.snap | 224 +++++---- ...flow__tests__AIR301_AIR301_context.py.snap | 167 +++--- ...irflow__tests__AIR301_AIR301_names.py.snap | 188 ++++--- ...ow__tests__AIR301_AIR301_names_fix.py.snap | 231 +++++---- ...__AIR301_AIR301_provider_names_fix.py.snap | 70 +-- ...rflow__tests__AIR302_AIR302_amazon.py.snap | 77 +-- ...rflow__tests__AIR302_AIR302_celery.py.snap | 21 +- ...w__tests__AIR302_AIR302_common_sql.py.snap | 217 ++++---- ..._tests__AIR302_AIR302_daskexecutor.py.snap | 7 +- ...irflow__tests__AIR302_AIR302_druid.py.snap | 28 +- ..._airflow__tests__AIR302_AIR302_fab.py.snap | 126 +++-- ...airflow__tests__AIR302_AIR302_hdfs.py.snap | 14 +- ...airflow__tests__AIR302_AIR302_hive.py.snap | 140 +++--- ...airflow__tests__AIR302_AIR302_http.py.snap | 21 +- ...airflow__tests__AIR302_AIR302_jdbc.py.snap | 14 +- ...w__tests__AIR302_AIR302_kubernetes.py.snap | 259 ++++++---- ...irflow__tests__AIR302_AIR302_mysql.py.snap | 21 +- ...rflow__tests__AIR302_AIR302_oracle.py.snap | 7 +- ...ow__tests__AIR302_AIR302_papermill.py.snap | 7 +- ..._airflow__tests__AIR302_AIR302_pig.py.snap | 14 +- ...low__tests__AIR302_AIR302_postgres.py.snap | 12 +- ...rflow__tests__AIR302_AIR302_presto.py.snap | 7 +- ...irflow__tests__AIR302_AIR302_samba.py.snap | 7 +- ...irflow__tests__AIR302_AIR302_slack.py.snap | 21 +- ...airflow__tests__AIR302_AIR302_smtp.py.snap | 14 +- ...rflow__tests__AIR302_AIR302_sqlite.py.snap | 7 +- ...low__tests__AIR302_AIR302_standard.py.snap | 147 +++--- ...flow__tests__AIR302_AIR302_zendesk.py.snap | 7 +- ...airflow__tests__AIR311_AIR311_args.py.snap | 15 +- ...irflow__tests__AIR311_AIR311_names.py.snap | 168 ++++--- ...les__airflow__tests__AIR312_AIR312.py.snap | 196 ++++---- ...s__eradicate__tests__ERA001_ERA001.py.snap | 133 ++--- ...non-annotated-dependency_FAST002_0.py.snap | 92 ++-- ...nnotated-dependency_FAST002_0.py_py38.snap | 92 ++-- ...non-annotated-dependency_FAST002_1.py.snap | 22 +- ...nnotated-dependency_FAST002_1.py_py38.snap | 22 +- ...i-redundant-response-model_FAST001.py.snap | 70 +-- ...-api-unused-path-parameter_FAST003.py.snap | 164 +++--- ..._flake8_2020__tests__YTT101_YTT101.py.snap | 15 +- ..._flake8_2020__tests__YTT102_YTT102.py.snap | 10 +- ..._flake8_2020__tests__YTT103_YTT103.py.snap | 25 +- ..._flake8_2020__tests__YTT201_YTT201.py.snap | 20 +- ..._flake8_2020__tests__YTT202_YTT202.py.snap | 10 +- ..._flake8_2020__tests__YTT203_YTT203.py.snap | 10 +- ..._flake8_2020__tests__YTT204_YTT204.py.snap | 10 +- ..._flake8_2020__tests__YTT301_YTT301.py.snap | 10 +- ..._flake8_2020__tests__YTT302_YTT302.py.snap | 25 +- ..._flake8_2020__tests__YTT303_YTT303.py.snap | 10 +- ...e8_annotations__tests__allow_overload.snap | 8 +- ...nnotations__tests__allow_star_arg_any.snap | 21 +- ..._annotations__tests__auto_return_type.snap | 309 +++++++----- ...tations__tests__auto_return_type_py38.snap | 308 +++++++----- ...__flake8_annotations__tests__defaults.snap | 152 +++--- ...otations__tests__ignore_fully_untyped.snap | 31 +- ..._annotations__tests__mypy_init_return.snap | 29 +- ...otations__tests__simple_magic_methods.snap | 98 ++-- ...tions__tests__suppress_none_returning.snap | 20 +- ...e8_async__tests__ASYNC100_ASYNC100.py.snap | 55 +- ...e8_async__tests__ASYNC105_ASYNC105.py.snap | 175 ++++--- ...s__flake8_async__tests__ASYNC109_0.py.snap | 15 +- ..._async__tests__ASYNC109_ASYNC109_0.py.snap | 15 +- ..._async__tests__ASYNC109_ASYNC109_1.py.snap | 15 +- ...e8_async__tests__ASYNC110_ASYNC110.py.snap | 25 +- ...e8_async__tests__ASYNC115_ASYNC115.py.snap | 91 ++-- ...e8_async__tests__ASYNC116_ASYNC116.py.snap | 126 +++-- ...e8_async__tests__ASYNC210_ASYNC210.py.snap | 125 +++-- ...e8_async__tests__ASYNC220_ASYNC22x.py.snap | 40 +- ...e8_async__tests__ASYNC221_ASYNC22x.py.snap | 120 +++-- ...e8_async__tests__ASYNC222_ASYNC22x.py.snap | 35 +- ...e8_async__tests__ASYNC230_ASYNC230.py.snap | 60 ++- ...e8_async__tests__ASYNC251_ASYNC251.py.snap | 6 +- ...s__flake8_bandit__tests__S101_S101.py.snap | 16 +- ...s__flake8_bandit__tests__S102_S102.py.snap | 15 +- ...s__flake8_bandit__tests__S103_S103.py.snap | 70 +-- ...s__flake8_bandit__tests__S104_S104.py.snap | 40 +- ...s__flake8_bandit__tests__S105_S105.py.snap | 205 +++++--- ...s__flake8_bandit__tests__S106_S106.py.snap | 6 +- ...s__flake8_bandit__tests__S107_S107.py.snap | 26 +- ...s__flake8_bandit__tests__S108_S108.py.snap | 35 +- ...es__flake8_bandit__tests__S108_extend.snap | 40 +- ...s__flake8_bandit__tests__S110_S110.py.snap | 10 +- ...les__flake8_bandit__tests__S110_typed.snap | 15 +- ...s__flake8_bandit__tests__S112_S112.py.snap | 20 +- ...s__flake8_bandit__tests__S113_S113.py.snap | 120 +++-- ...s__flake8_bandit__tests__S201_S201.py.snap | 5 +- ...s__flake8_bandit__tests__S202_S202.py.snap | 26 +- ...s__flake8_bandit__tests__S301_S301.py.snap | 5 +- ...s__flake8_bandit__tests__S307_S307.py.snap | 10 +- ...s__flake8_bandit__tests__S308_S308.py.snap | 60 ++- ...s__flake8_bandit__tests__S310_S310.py.snap | 120 +++-- ...s__flake8_bandit__tests__S311_S311.py.snap | 45 +- ...s__flake8_bandit__tests__S312_S312.py.snap | 10 +- ...s__flake8_bandit__tests__S324_S324.py.snap | 105 ++-- ...s__flake8_bandit__tests__S401_S401.py.snap | 11 +- ...s__flake8_bandit__tests__S402_S402.py.snap | 11 +- ...s__flake8_bandit__tests__S403_S403.py.snap | 41 +- ...s__flake8_bandit__tests__S404_S404.py.snap | 16 +- ...s__flake8_bandit__tests__S405_S405.py.snap | 21 +- ...s__flake8_bandit__tests__S406_S406.py.snap | 16 +- ...s__flake8_bandit__tests__S407_S407.py.snap | 11 +- ...s__flake8_bandit__tests__S408_S408.py.snap | 11 +- ...s__flake8_bandit__tests__S409_S409.py.snap | 11 +- ...s__flake8_bandit__tests__S410_S410.py.snap | 11 +- ...s__flake8_bandit__tests__S411_S411.py.snap | 11 +- ...s__flake8_bandit__tests__S412_S412.py.snap | 6 +- ...s__flake8_bandit__tests__S413_S413.py.snap | 21 +- ...s__flake8_bandit__tests__S415_S415.py.snap | 11 +- ...s__flake8_bandit__tests__S501_S501.py.snap | 90 ++-- ...s__flake8_bandit__tests__S502_S502.py.snap | 35 +- ...s__flake8_bandit__tests__S503_S503.py.snap | 21 +- ...s__flake8_bandit__tests__S504_S504.py.snap | 10 +- ...s__flake8_bandit__tests__S505_S505.py.snap | 70 +-- ...s__flake8_bandit__tests__S506_S506.py.snap | 10 +- ...s__flake8_bandit__tests__S507_S507.py.snap | 40 +- ...s__flake8_bandit__tests__S508_S508.py.snap | 10 +- ...s__flake8_bandit__tests__S509_S509.py.snap | 10 +- ...s__flake8_bandit__tests__S601_S601.py.snap | 5 +- ...s__flake8_bandit__tests__S602_S602.py.snap | 60 ++- ...s__flake8_bandit__tests__S603_S603.py.snap | 65 ++- ...s__flake8_bandit__tests__S604_S604.py.snap | 6 +- ...s__flake8_bandit__tests__S605_S605.py.snap | 86 ++-- ...s__flake8_bandit__tests__S606_S606.py.snap | 86 ++-- ...s__flake8_bandit__tests__S607_S607.py.snap | 110 ++-- ...s__flake8_bandit__tests__S608_S608.py.snap | 295 ++++++----- ...s__flake8_bandit__tests__S609_S609.py.snap | 20 +- ...s__flake8_bandit__tests__S610_S610.py.snap | 55 +- ...s__flake8_bandit__tests__S611_S611.py.snap | 31 +- ...s__flake8_bandit__tests__S612_S612.py.snap | 5 +- ...s__flake8_bandit__tests__S701_S701.py.snap | 25 +- ...s__flake8_bandit__tests__S702_S702.py.snap | 15 +- ...s__flake8_bandit__tests__S704_S704.py.snap | 30 +- ...les__S704_S704_extend_markup_names.py.snap | 10 +- ...allables__S704_S704_skip_early_out.py.snap | 5 +- ..._bandit__tests__preview__S301_S301.py.snap | 15 +- ..._bandit__tests__preview__S307_S307.py.snap | 20 +- ..._bandit__tests__preview__S308_S308.py.snap | 70 +-- ..._bandit__tests__preview__S310_S310.py.snap | 130 +++-- ..._bandit__tests__preview__S311_S311.py.snap | 55 +- ..._bandit__tests__preview__S312_S312.py.snap | 25 +- ...S704_S704_whitelisted_markup_calls.py.snap | 5 +- ...e8_blind_except__tests__BLE001_BLE.py.snap | 130 +++-- ...e8_boolean_trap__tests__FBT001_FBT.py.snap | 55 +- ...e8_boolean_trap__tests__FBT002_FBT.py.snap | 21 +- ...e8_boolean_trap__tests__FBT003_FBT.py.snap | 36 +- ..._trap__tests__extend_allowed_callable.snap | 21 +- ...__flake8_bugbear__tests__B002_B002.py.snap | 21 +- ...__flake8_bugbear__tests__B003_B003.py.snap | 5 +- ...__flake8_bugbear__tests__B004_B004.py.snap | 42 +- ...__flake8_bugbear__tests__B005_B005.py.snap | 40 +- ...flake8_bugbear__tests__B006_B006_1.py.snap | 7 +- ...flake8_bugbear__tests__B006_B006_2.py.snap | 7 +- ...flake8_bugbear__tests__B006_B006_3.py.snap | 8 +- ...flake8_bugbear__tests__B006_B006_4.py.snap | 8 +- ...flake8_bugbear__tests__B006_B006_5.py.snap | 113 +++-- ...flake8_bugbear__tests__B006_B006_6.py.snap | 7 +- ...flake8_bugbear__tests__B006_B006_7.py.snap | 7 +- ...flake8_bugbear__tests__B006_B006_8.py.snap | 36 +- ...ke8_bugbear__tests__B006_B006_B008.py.snap | 175 ++++--- ...__flake8_bugbear__tests__B007_B007.py.snap | 96 ++-- ...ke8_bugbear__tests__B008_B006_B008.py.snap | 51 +- ...ke8_bugbear__tests__B009_B009_B010.py.snap | 126 +++-- ...ke8_bugbear__tests__B010_B009_B010.py.snap | 42 +- ...__flake8_bugbear__tests__B011_B011.py.snap | 15 +- ...__flake8_bugbear__tests__B012_B012.py.snap | 55 +- ...__flake8_bugbear__tests__B013_B013.py.snap | 15 +- ...__flake8_bugbear__tests__B014_B014.py.snap | 36 +- ...lake8_bugbear__tests__B015_B015.ipynb.snap | 16 +- ...__flake8_bugbear__tests__B015_B015.py.snap | 25 +- ...__flake8_bugbear__tests__B016_B016.py.snap | 15 +- ...flake8_bugbear__tests__B017_B017_0.py.snap | 40 +- ...lake8_bugbear__tests__B018_B018.ipynb.snap | 16 +- ...__flake8_bugbear__tests__B018_B018.py.snap | 135 +++-- ...__flake8_bugbear__tests__B019_B019.py.snap | 45 +- ...__flake8_bugbear__tests__B020_B020.py.snap | 15 +- ...__flake8_bugbear__tests__B021_B021.py.snap | 50 +- ...__flake8_bugbear__tests__B022_B022.py.snap | 10 +- ...__flake8_bugbear__tests__B023_B023.py.snap | 120 +++-- ...__flake8_bugbear__tests__B024_B024.py.snap | 41 +- ...__flake8_bugbear__tests__B025_B025.py.snap | 41 +- ...__flake8_bugbear__tests__B026_B026.py.snap | 36 +- ...__flake8_bugbear__tests__B027_B027.py.snap | 20 +- ...__flake8_bugbear__tests__B028_B028.py.snap | 28 +- ...__flake8_bugbear__tests__B029_B029.py.snap | 20 +- ...__flake8_bugbear__tests__B030_B030.py.snap | 56 ++- ...__flake8_bugbear__tests__B031_B031.py.snap | 115 +++-- ...__flake8_bugbear__tests__B032_B032.py.snap | 40 +- ...__flake8_bugbear__tests__B033_B033.py.snap | 63 ++- ...__flake8_bugbear__tests__B034_B034.py.snap | 50 +- ...__flake8_bugbear__tests__B035_B035.py.snap | 46 +- ...__flake8_bugbear__tests__B039_B039.py.snap | 98 ++-- ...__flake8_bugbear__tests__B901_B901.py.snap | 10 +- ...ests__B903_class_as_data_structure.py.snap | 35 +- ..._B903_py39_class_as_data_structure.py.snap | 30 +- ...__flake8_bugbear__tests__B904_B904.py.snap | 65 ++- ...rules__flake8_bugbear__tests__B905.py.snap | 70 +-- ...__flake8_bugbear__tests__B909_B909.py.snap | 195 ++++--- ...__flake8_bugbear__tests__B911_B911.py.snap | 112 +++-- ...extend_immutable_calls_arg_annotation.snap | 8 +- ...s__extend_immutable_calls_arg_default.snap | 15 +- ...ts__extend_mutable_contextvar_default.snap | 8 +- ...gbear__tests__preview__B017_B017_0.py.snap | 40 +- ...gbear__tests__preview__B017_B017_1.py.snap | 20 +- ..._flake8_builtins__tests__A001_A001.py.snap | 85 ++-- ...sts__A001_A001.py_builtins_ignorelist.snap | 80 +-- ..._flake8_builtins__tests__A002_A002.py.snap | 41 +- ...sts__A002_A002.py_builtins_ignorelist.snap | 31 +- ..._flake8_builtins__tests__A003_A003.py.snap | 10 +- ...sts__A003_A003.py_builtins_ignorelist.snap | 5 +- ..._flake8_builtins__tests__A004_A004.py.snap | 40 +- ...sts__A004_A004.py_builtins_ignorelist.snap | 36 +- ...e8_builtins__tests__A004_A004.py_py38.snap | 30 +- ...5_A005__modules__logging____init__.py.snap | 3 +- ...005_A005__modules__package__bisect.py.snap | 3 +- ...e__bisect.py_builtins_allowed_modules.snap | 3 +- ...__A005_A005__modules__package__xml.py.snap | 3 +- ...05_A005__modules__string____init__.py.snap | 3 +- ...___init__.py_builtins_allowed_modules.snap | 3 +- ...A005__modules__utils__logging.py_root.snap | 3 +- ..._A005__modules__utils__logging.py_src.snap | 3 +- ...A005__modules__utils__logging.py_true.snap | 3 +- ..._flake8_builtins__tests__A006_A006.py.snap | 35 +- ...sts__A006_A006.py_builtins_ignorelist.snap | 26 +- ...rules__flake8_commas__tests__COM81.py.snap | 350 +++++++------ ..._commas__tests__COM81_syntax_error.py.snap | 13 +- ...ake8_commas__tests__preview__COM81.py.snap | 392 +++++++++------ ...tests__preview__COM81_syntax_error.py.snap | 13 +- ...8_comprehensions__tests__C400_C400.py.snap | 63 ++- ...8_comprehensions__tests__C401_C401.py.snap | 175 ++++--- ...8_comprehensions__tests__C402_C402.py.snap | 91 ++-- ...8_comprehensions__tests__C403_C403.py.snap | 154 +++--- ...8_comprehensions__tests__C404_C404.py.snap | 70 +-- ...8_comprehensions__tests__C405_C405.py.snap | 217 ++++---- ...8_comprehensions__tests__C406_C406.py.snap | 28 +- ...8_comprehensions__tests__C408_C408.py.snap | 210 ++++---- ...low_dict_calls_with_keyword_arguments.snap | 63 ++- ...8_comprehensions__tests__C409_C409.py.snap | 77 +-- ...8_comprehensions__tests__C410_C410.py.snap | 42 +- ...8_comprehensions__tests__C411_C411.py.snap | 7 +- ...8_comprehensions__tests__C413_C413.py.snap | 112 +++-- ...8_comprehensions__tests__C414_C414.py.snap | 168 ++++--- ...8_comprehensions__tests__C415_C415.py.snap | 21 +- ...8_comprehensions__tests__C416_C416.py.snap | 49 +- ...8_comprehensions__tests__C417_C417.py.snap | 126 +++-- ...comprehensions__tests__C417_C417_1.py.snap | 7 +- ...8_comprehensions__tests__C418_C418.py.snap | 28 +- ...8_comprehensions__tests__C419_C419.py.snap | 63 ++- ...8_comprehensions__tests__C420_C420.py.snap | 84 ++-- ...comprehensions__tests__C420_C420_1.py.snap | 7 +- ...comprehensions__tests__C420_C420_2.py.snap | 7 +- ...ensions__tests__preview__C409_C409.py.snap | 105 ++-- ...sions__tests__preview__C419_C419_1.py.snap | 35 +- ...lake8_copyright__tests__char_boundary.snap | 4 +- ...ake8_copyright__tests__invalid_author.snap | 4 +- ..._flake8_copyright__tests__late_notice.snap | 4 +- ...id_author_with_comma_invalid_no_space.snap | 4 +- ...alid_author_with_comma_invalid_spaces.snap | 4 +- ..._valid_author_with_dash_invalid_space.snap | 4 +- ...valid_author_with_dash_invalid_spaces.snap | 4 +- ...e8_datetimez__tests__DTZ001_DTZ001.py.snap | 35 +- ...e8_datetimez__tests__DTZ002_DTZ002.py.snap | 14 +- ...e8_datetimez__tests__DTZ003_DTZ003.py.snap | 14 +- ...e8_datetimez__tests__DTZ004_DTZ004.py.snap | 14 +- ...e8_datetimez__tests__DTZ005_DTZ005.py.snap | 70 +-- ...e8_datetimez__tests__DTZ006_DTZ006.py.snap | 35 +- ...e8_datetimez__tests__DTZ007_DTZ007.py.snap | 35 +- ...e8_datetimez__tests__DTZ011_DTZ011.py.snap | 14 +- ...e8_datetimez__tests__DTZ012_DTZ012.py.snap | 14 +- ...e8_datetimez__tests__DTZ901_DTZ901.py.snap | 56 ++- ..._flake8_debugger__tests__T100_T100.py.snap | 125 +++-- ..._flake8_django__tests__DJ001_DJ001.py.snap | 91 ++-- ..._flake8_django__tests__DJ003_DJ003.py.snap | 11 +- ..._flake8_django__tests__DJ006_DJ006.py.snap | 6 +- ..._flake8_django__tests__DJ007_DJ007.py.snap | 11 +- ..._flake8_django__tests__DJ008_DJ008.py.snap | 25 +- ..._flake8_django__tests__DJ012_DJ012.py.snap | 35 +- ..._flake8_django__tests__DJ013_DJ013.py.snap | 11 +- ...__rules__flake8_errmsg__tests__custom.snap | 98 ++-- ...rules__flake8_errmsg__tests__defaults.snap | 119 +++-- ..._rules__flake8_errmsg__tests__preview.snap | 14 +- ...flake8_executable__tests__EXE001_1.py.snap | 5 +- ...flake8_executable__tests__EXE002_1.py.snap | 3 +- ...__flake8_executable__tests__EXE003.py.snap | 5 +- ...flake8_executable__tests__EXE004_1.py.snap | 9 +- ...flake8_executable__tests__EXE004_3.py.snap | 7 +- ...flake8_executable__tests__EXE004_4.py.snap | 7 +- ...flake8_executable__tests__EXE005_1.py.snap | 7 +- ...flake8_executable__tests__EXE005_2.py.snap | 7 +- ...flake8_executable__tests__EXE005_3.py.snap | 7 +- ...me__tests__line-contains-fixme_T00.py.snap | 10 +- ...xme__tests__line-contains-hack_T00.py.snap | 11 +- ...xme__tests__line-contains-todo_T00.py.snap | 15 +- ...ixme__tests__line-contains-xxx_T00.py.snap | 11 +- ...ture_annotations__tests__edge_case.py.snap | 14 +- ...02_no_future_import_uses_lowercase.py.snap | 8 +- ..._fa102_no_future_import_uses_union.py.snap | 15 +- ..._no_future_import_uses_union_inner.py.snap | 15 +- ...tations__tests__from_typing_import.py.snap | 7 +- ...ns__tests__from_typing_import_many.py.snap | 14 +- ..._annotations__tests__import_typing.py.snap | 7 +- ...notations__tests__import_typing_as.py.snap | 7 +- ...tring-in-get-text-func-call_INT001.py.snap | 5 +- ...ormat-in-get-text-func-call_INT002.py.snap | 6 +- ...rintf-in-get-text-func-call_INT003.py.snap | 6 +- ...icit_str_concat__tests__ISC001_ISC.py.snap | 189 ++++--- ...at__tests__ISC001_ISC_syntax_error.py.snap | 73 +-- ...icit_str_concat__tests__ISC002_ISC.py.snap | 10 +- ...at__tests__ISC002_ISC_syntax_error.py.snap | 45 +- ...icit_str_concat__tests__ISC003_ISC.py.snap | 119 +++-- ...oncat__tests__multiline_ISC001_ISC.py.snap | 189 ++++--- ...oncat__tests__multiline_ISC002_ISC.py.snap | 30 +- ...ke8_import_conventions__tests__custom.snap | 210 ++++---- ...ort_conventions__tests__custom_banned.snap | 40 +- ...onventions__tests__custom_banned_from.snap | 25 +- ...8_import_conventions__tests__defaults.snap | 99 ++-- ...port_conventions__tests__from_imports.snap | 56 ++- ...conventions__tests__override_defaults.snap | 70 +-- ...t_conventions__tests__remove_defaults.snap | 56 ++- ..._import_conventions__tests__same_name.snap | 8 +- ...ke8_import_conventions__tests__tricky.snap | 8 +- ...ake8_logging__tests__LOG001_LOG001.py.snap | 14 +- ...ake8_logging__tests__LOG002_LOG002.py.snap | 28 +- ...e8_logging__tests__LOG004_LOG004_0.py.snap | 63 ++- ...e8_logging__tests__LOG004_LOG004_1.py.snap | 7 +- ...ake8_logging__tests__LOG007_LOG007.py.snap | 25 +- ...ake8_logging__tests__LOG009_LOG009.py.snap | 14 +- ...e8_logging__tests__LOG014_LOG014_0.py.snap | 56 ++- ...e8_logging__tests__LOG014_LOG014_1.py.snap | 7 +- ...ake8_logging__tests__LOG015_LOG015.py.snap | 112 +++-- ...flake8_logging_format__tests__G001.py.snap | 75 +-- ...flake8_logging_format__tests__G002.py.snap | 20 +- ...flake8_logging_format__tests__G003.py.snap | 20 +- ...flake8_logging_format__tests__G004.py.snap | 30 +- ...flake8_logging_format__tests__G010.py.snap | 28 +- ...ake8_logging_format__tests__G101_1.py.snap | 11 +- ...ake8_logging_format__tests__G101_2.py.snap | 11 +- ...flake8_logging_format__tests__G201.py.snap | 20 +- ...flake8_logging_format__tests__G202.py.snap | 20 +- ...ke8_no_pep420__tests__test_fail_empty.snap | 4 +- ..._no_pep420__tests__test_fail_nonempty.snap | 4 +- ...__flake8_pie__tests__PIE790_PIE790.py.snap | 266 +++++----- ...__flake8_pie__tests__PIE794_PIE794.py.snap | 42 +- ...__flake8_pie__tests__PIE796_PIE796.py.snap | 56 ++- ...__flake8_pie__tests__PIE800_PIE800.py.snap | 133 ++--- ...__flake8_pie__tests__PIE804_PIE804.py.snap | 98 ++-- ...__flake8_pie__tests__PIE807_PIE807.py.snap | 43 +- ...__flake8_pie__tests__PIE808_PIE808.py.snap | 21 +- ...__flake8_pie__tests__PIE810_PIE810.py.snap | 56 ++- ...es__flake8_print__tests__T201_T201.py.snap | 28 +- ...es__flake8_print__tests__T203_T203.py.snap | 14 +- ..._flake8_pyi__tests__PYI001_PYI001.pyi.snap | 15 +- ..._flake8_pyi__tests__PYI002_PYI002.pyi.snap | 20 +- ..._flake8_pyi__tests__PYI003_PYI003.pyi.snap | 85 ++-- ..._flake8_pyi__tests__PYI004_PYI004.pyi.snap | 20 +- ..._flake8_pyi__tests__PYI005_PYI005.pyi.snap | 10 +- ...__flake8_pyi__tests__PYI006_PYI006.py.snap | 40 +- ..._flake8_pyi__tests__PYI006_PYI006.pyi.snap | 40 +- ..._flake8_pyi__tests__PYI007_PYI007.pyi.snap | 15 +- ..._flake8_pyi__tests__PYI008_PYI008.pyi.snap | 5 +- ..._flake8_pyi__tests__PYI009_PYI009.pyi.snap | 14 +- ..._flake8_pyi__tests__PYI010_PYI010.pyi.snap | 21 +- ..._flake8_pyi__tests__PYI011_PYI011.pyi.snap | 127 +++-- ..._flake8_pyi__tests__PYI012_PYI012.pyi.snap | 42 +- ...__flake8_pyi__tests__PYI013_PYI013.py.snap | 63 ++- ..._flake8_pyi__tests__PYI013_PYI013.pyi.snap | 70 +-- ..._flake8_pyi__tests__PYI014_PYI014.pyi.snap | 92 ++-- ..._flake8_pyi__tests__PYI015_PYI015.pyi.snap | 77 +-- ...__flake8_pyi__tests__PYI016_PYI016.py.snap | 350 +++++++------ ..._flake8_pyi__tests__PYI016_PYI016.pyi.snap | 336 +++++++------ ..._flake8_pyi__tests__PYI017_PYI017.pyi.snap | 20 +- ...__flake8_pyi__tests__PYI018_PYI018.py.snap | 35 +- ..._flake8_pyi__tests__PYI018_PYI018.pyi.snap | 35 +- ...flake8_pyi__tests__PYI019_PYI019_0.py.snap | 280 ++++++----- ...lake8_pyi__tests__PYI019_PYI019_0.pyi.snap | 266 +++++----- ...lake8_pyi__tests__PYI019_PYI019_1.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI020_PYI020.pyi.snap | 63 ++- ..._flake8_pyi__tests__PYI021_PYI021.pyi.snap | 35 +- ...__flake8_pyi__tests__PYI024_PYI024.py.snap | 21 +- ..._flake8_pyi__tests__PYI024_PYI024.pyi.snap | 21 +- ...flake8_pyi__tests__PYI025_PYI025_1.py.snap | 14 +- ...lake8_pyi__tests__PYI025_PYI025_1.pyi.snap | 35 +- ...flake8_pyi__tests__PYI025_PYI025_2.py.snap | 7 +- ...lake8_pyi__tests__PYI025_PYI025_2.pyi.snap | 7 +- ...flake8_pyi__tests__PYI025_PYI025_3.py.snap | 7 +- ...lake8_pyi__tests__PYI025_PYI025_3.pyi.snap | 7 +- ..._flake8_pyi__tests__PYI026_PYI026.pyi.snap | 42 +- ..._flake8_pyi__tests__PYI029_PYI029.pyi.snap | 21 +- ...__flake8_pyi__tests__PYI030_PYI030.py.snap | 203 ++++---- ..._flake8_pyi__tests__PYI030_PYI030.pyi.snap | 196 ++++---- ...__flake8_pyi__tests__PYI032_PYI032.py.snap | 29 +- ..._flake8_pyi__tests__PYI032_PYI032.pyi.snap | 29 +- ..._flake8_pyi__tests__PYI033_PYI033.pyi.snap | 97 ++-- ...__flake8_pyi__tests__PYI034_PYI034.py.snap | 168 ++++--- ..._flake8_pyi__tests__PYI034_PYI034.pyi.snap | 154 +++--- ..._flake8_pyi__tests__PYI035_PYI035.pyi.snap | 15 +- ...__flake8_pyi__tests__PYI036_PYI036.py.snap | 111 ++-- ..._flake8_pyi__tests__PYI036_PYI036.pyi.snap | 116 +++-- ...flake8_pyi__tests__PYI041_PYI041_1.py.snap | 133 ++--- ...lake8_pyi__tests__PYI041_PYI041_1.pyi.snap | 126 +++-- ...flake8_pyi__tests__PYI041_PYI041_2.py.snap | 7 +- ...__flake8_pyi__tests__PYI042_PYI042.py.snap | 20 +- ..._flake8_pyi__tests__PYI042_PYI042.pyi.snap | 20 +- ...__flake8_pyi__tests__PYI043_PYI043.py.snap | 20 +- ..._flake8_pyi__tests__PYI043_PYI043.pyi.snap | 20 +- ..._flake8_pyi__tests__PYI044_PYI044.pyi.snap | 14 +- ...__flake8_pyi__tests__PYI045_PYI045.py.snap | 36 +- ..._flake8_pyi__tests__PYI045_PYI045.pyi.snap | 35 +- ...__flake8_pyi__tests__PYI046_PYI046.py.snap | 16 +- ..._flake8_pyi__tests__PYI046_PYI046.pyi.snap | 16 +- ...__flake8_pyi__tests__PYI047_PYI047.py.snap | 20 +- ..._flake8_pyi__tests__PYI047_PYI047.pyi.snap | 20 +- ..._flake8_pyi__tests__PYI048_PYI048.pyi.snap | 15 +- ...__flake8_pyi__tests__PYI049_PYI049.py.snap | 16 +- ..._flake8_pyi__tests__PYI049_PYI049.pyi.snap | 20 +- ...__flake8_pyi__tests__PYI050_PYI050.py.snap | 26 +- ..._flake8_pyi__tests__PYI050_PYI050.pyi.snap | 56 ++- ...__flake8_pyi__tests__PYI051_PYI051.py.snap | 60 ++- ..._flake8_pyi__tests__PYI051_PYI051.pyi.snap | 60 ++- ..._flake8_pyi__tests__PYI052_PYI052.pyi.snap | 70 +-- ..._flake8_pyi__tests__PYI053_PYI053.pyi.snap | 56 ++- ..._flake8_pyi__tests__PYI054_PYI054.pyi.snap | 56 ++- ...__flake8_pyi__tests__PYI055_PYI055.py.snap | 56 ++- ..._flake8_pyi__tests__PYI055_PYI055.pyi.snap | 91 ++-- ...__flake8_pyi__tests__PYI056_PYI056.py.snap | 15 +- ..._flake8_pyi__tests__PYI056_PYI056.pyi.snap | 15 +- ...__flake8_pyi__tests__PYI057_PYI057.py.snap | 20 +- ..._flake8_pyi__tests__PYI057_PYI057.pyi.snap | 20 +- ...__flake8_pyi__tests__PYI058_PYI058.py.snap | 57 ++- ..._flake8_pyi__tests__PYI058_PYI058.pyi.snap | 63 ++- ...__flake8_pyi__tests__PYI059_PYI059.py.snap | 56 ++- ..._flake8_pyi__tests__PYI059_PYI059.pyi.snap | 35 +- ...__flake8_pyi__tests__PYI061_PYI061.py.snap | 182 ++++--- ..._flake8_pyi__tests__PYI061_PYI061.pyi.snap | 140 +++--- ...__flake8_pyi__tests__PYI062_PYI062.py.snap | 119 +++-- ..._flake8_pyi__tests__PYI062_PYI062.pyi.snap | 119 +++-- ...__flake8_pyi__tests__PYI063_PYI063.py.snap | 70 +-- ..._flake8_pyi__tests__PYI063_PYI063.pyi.snap | 70 +-- ...__flake8_pyi__tests__PYI064_PYI064.py.snap | 35 +- ..._flake8_pyi__tests__PYI064_PYI064.pyi.snap | 35 +- ..._flake8_pyi__tests__PYI066_PYI066.pyi.snap | 26 +- ...pyi__tests__preview__PYI016_PYI016.py.snap | 427 +++++++++------- ...yi__tests__preview__PYI016_PYI016.pyi.snap | 413 ++++++++------- ...e8_pyi__tests__py38_PYI026_PYI026.pyi.snap | 42 +- ...ke8_pyi__tests__py38_PYI061_PYI061.py.snap | 182 ++++--- ...e8_pyi__tests__py38_PYI061_PYI061.pyi.snap | 140 +++--- ...e8_pytest_style__tests__PT001_default.snap | 63 ++- ...ytest_style__tests__PT001_parentheses.snap | 22 +- ...es__flake8_pytest_style__tests__PT002.snap | 11 +- ...es__flake8_pytest_style__tests__PT003.snap | 56 ++- ..._pytest_style__tests__PT006_and_PT007.snap | 21 +- ...flake8_pytest_style__tests__PT006_csv.snap | 91 ++-- ...e8_pytest_style__tests__PT006_default.snap | 147 +++--- ...lake8_pytest_style__tests__PT006_list.snap | 133 ++--- ...est_style__tests__PT007_list_of_lists.snap | 70 +-- ...st_style__tests__PT007_list_of_tuples.snap | 70 +-- ...st_style__tests__PT007_tuple_of_lists.snap | 105 ++-- ...t_style__tests__PT007_tuple_of_tuples.snap | 105 ++-- ...es__flake8_pytest_style__tests__PT008.snap | 60 ++- ...es__flake8_pytest_style__tests__PT009.snap | 252 ++++++---- ...es__flake8_pytest_style__tests__PT010.snap | 6 +- ...e8_pytest_style__tests__PT011_default.snap | 30 +- ..._tests__PT011_extend_broad_exceptions.snap | 35 +- ...8_pytest_style__tests__PT011_glob_all.snap | 45 +- ...ytest_style__tests__PT011_glob_prefix.snap | 10 +- ...tests__PT011_replace_broad_exceptions.snap | 6 +- ...es__flake8_pytest_style__tests__PT012.snap | 55 +- ...es__flake8_pytest_style__tests__PT013.snap | 15 +- ...es__flake8_pytest_style__tests__PT014.snap | 71 +-- ...es__flake8_pytest_style__tests__PT015.snap | 86 ++-- ...es__flake8_pytest_style__tests__PT016.snap | 35 +- ...es__flake8_pytest_style__tests__PT017.snap | 6 +- ...es__flake8_pytest_style__tests__PT018.snap | 147 +++--- ...es__flake8_pytest_style__tests__PT019.snap | 20 +- ...es__flake8_pytest_style__tests__PT020.snap | 11 +- ...es__flake8_pytest_style__tests__PT021.snap | 11 +- ...es__flake8_pytest_style__tests__PT022.snap | 22 +- ...e8_pytest_style__tests__PT023_default.snap | 56 ++- ...ytest_style__tests__PT023_parentheses.snap | 35 +- ...es__flake8_pytest_style__tests__PT024.snap | 29 +- ...es__flake8_pytest_style__tests__PT025.snap | 15 +- ...es__flake8_pytest_style__tests__PT026.snap | 15 +- ...__flake8_pytest_style__tests__PT027_0.snap | 77 +-- ...__flake8_pytest_style__tests__PT027_1.snap | 42 +- ...es__flake8_pytest_style__tests__PT028.snap | 77 +-- ...es__flake8_pytest_style__tests__PT029.snap | 5 +- ...e8_pytest_style__tests__PT030_default.snap | 25 +- ..._tests__PT030_extend_broad_exceptions.snap | 30 +- ...8_pytest_style__tests__PT030_glob_all.snap | 35 +- ...ytest_style__tests__PT030_glob_prefix.snap | 5 +- ...tests__PT030_replace_broad_exceptions.snap | 6 +- ...es__flake8_pytest_style__tests__PT031.snap | 55 +- ...8_pytest_style__tests__is_pytest_test.snap | 28 +- ..._tests__only_docstring_doubles_all.py.snap | 7 +- ...es__tests__only_inline_doubles_all.py.snap | 7 +- ..._tests__only_multiline_doubles_all.py.snap | 7 +- ...ing_doubles_over_docstring_doubles.py.snap | 35 +- ...ubles_over_docstring_doubles_class.py.snap | 14 +- ...es_over_docstring_doubles_function.py.snap | 36 +- ...docstring_doubles_module_multiline.py.snap | 15 +- ...ocstring_doubles_module_singleline.py.snap | 14 +- ...ing_doubles_over_docstring_singles.py.snap | 21 +- ...ubles_over_docstring_singles_class.py.snap | 21 +- ...es_over_docstring_singles_function.py.snap | 21 +- ...g_singles_mixed_quotes_class_var_1.py.snap | 42 +- ...g_singles_mixed_quotes_class_var_2.py.snap | 42 +- ...xed_quotes_module_singleline_var_1.py.snap | 21 +- ...xed_quotes_module_singleline_var_2.py.snap | 21 +- ...docstring_singles_module_multiline.py.snap | 8 +- ...ocstring_singles_module_singleline.py.snap | 8 +- ...ing_singles_over_docstring_doubles.py.snap | 21 +- ...ngles_over_docstring_doubles_class.py.snap | 21 +- ...es_over_docstring_doubles_function.py.snap | 21 +- ...g_doubles_mixed_quotes_class_var_1.py.snap | 21 +- ...g_doubles_mixed_quotes_class_var_2.py.snap | 21 +- ...xed_quotes_module_singleline_var_1.py.snap | 7 +- ...xed_quotes_module_singleline_var_2.py.snap | 7 +- ...docstring_doubles_module_multiline.py.snap | 8 +- ...ocstring_doubles_module_singleline.py.snap | 8 +- ...ing_singles_over_docstring_singles.py.snap | 42 +- ...ngles_over_docstring_singles_class.py.snap | 14 +- ...es_over_docstring_singles_function.py.snap | 36 +- ...docstring_singles_module_multiline.py.snap | 15 +- ...ocstring_singles_module_singleline.py.snap | 14 +- ...ests__require_doubles_over_singles.py.snap | 22 +- ...quire_doubles_over_singles_escaped.py.snap | 140 +++--- ...re_doubles_over_singles_escaped_py311.snap | 91 ++-- ...s_over_singles_escaped_unnecessary.py.snap | 126 +++-- ...uire_doubles_over_singles_implicit.py.snap | 50 +- ...bles_over_singles_multiline_string.py.snap | 7 +- ...ver_singles_would_be_triple_quotes.py.snap | 29 +- ...ests__require_singles_over_doubles.py.snap | 22 +- ...quire_singles_over_doubles_escaped.py.snap | 161 +++--- ...re_singles_over_doubles_escaped_py311.snap | 112 +++-- ...s_over_doubles_escaped_unnecessary.py.snap | 133 ++--- ...uire_singles_over_doubles_implicit.py.snap | 50 +- ...gles_over_doubles_multiline_string.py.snap | 7 +- ...ver_doubles_would_be_triple_quotes.py.snap | 15 +- ...ry-paren-on-raise-exception_RSE102.py.snap | 105 ++-- ...lake8_return__tests__RET501_RET501.py.snap | 21 +- ...lake8_return__tests__RET502_RET502.py.snap | 8 +- ...lake8_return__tests__RET503_RET503.py.snap | 154 +++--- ...lake8_return__tests__RET504_RET504.py.snap | 105 ++-- ...lake8_return__tests__RET505_RET505.py.snap | 154 +++--- ...lake8_return__tests__RET506_RET506.py.snap | 50 +- ...lake8_return__tests__RET507_RET507.py.snap | 50 +- ...lake8_return__tests__RET508_RET508.py.snap | 57 ++- ...les__flake8_self__tests__ignore_names.snap | 11 +- ...ests__private-member-access_SLF001.py.snap | 55 +- ...ke8_simplify__tests__SIM101_SIM101.py.snap | 70 +-- ...ke8_simplify__tests__SIM102_SIM102.py.snap | 98 ++-- ...ke8_simplify__tests__SIM103_SIM103.py.snap | 119 +++-- ...8_simplify__tests__SIM105_SIM105_0.py.snap | 84 ++-- ...8_simplify__tests__SIM105_SIM105_1.py.snap | 8 +- ...8_simplify__tests__SIM105_SIM105_2.py.snap | 8 +- ...8_simplify__tests__SIM105_SIM105_3.py.snap | 7 +- ...8_simplify__tests__SIM105_SIM105_4.py.snap | 10 +- ...ke8_simplify__tests__SIM107_SIM107.py.snap | 6 +- ...ke8_simplify__tests__SIM108_SIM108.py.snap | 119 +++-- ...ke8_simplify__tests__SIM109_SIM109.py.snap | 29 +- ...ke8_simplify__tests__SIM110_SIM110.py.snap | 98 ++-- ...ke8_simplify__tests__SIM110_SIM111.py.snap | 98 ++-- ...ke8_simplify__tests__SIM112_SIM112.py.snap | 56 ++- ...ke8_simplify__tests__SIM113_SIM113.py.snap | 26 +- ...ke8_simplify__tests__SIM114_SIM114.py.snap | 126 +++-- ...ke8_simplify__tests__SIM115_SIM115.py.snap | 170 ++++--- ...ke8_simplify__tests__SIM116_SIM116.py.snap | 35 +- ...ke8_simplify__tests__SIM117_SIM117.py.snap | 98 ++-- ...ke8_simplify__tests__SIM118_SIM118.py.snap | 140 +++--- ...ke8_simplify__tests__SIM201_SIM201.py.snap | 21 +- ...ke8_simplify__tests__SIM202_SIM202.py.snap | 21 +- ...ke8_simplify__tests__SIM208_SIM208.py.snap | 35 +- ...ke8_simplify__tests__SIM210_SIM210.py.snap | 35 +- ...ke8_simplify__tests__SIM211_SIM211.py.snap | 21 +- ...ke8_simplify__tests__SIM212_SIM212.py.snap | 14 +- ...ke8_simplify__tests__SIM220_SIM220.py.snap | 21 +- ...ke8_simplify__tests__SIM221_SIM221.py.snap | 21 +- ...ke8_simplify__tests__SIM222_SIM222.py.snap | 364 ++++++++------ ...ke8_simplify__tests__SIM223_SIM223.py.snap | 350 +++++++------ ...ke8_simplify__tests__SIM300_SIM300.py.snap | 126 +++-- ...ke8_simplify__tests__SIM401_SIM401.py.snap | 49 +- ...ke8_simplify__tests__SIM905_SIM905.py.snap | 448 ++++++++++------- ...ke8_simplify__tests__SIM910_SIM910.py.snap | 63 ++- ...ke8_simplify__tests__SIM911_SIM911.py.snap | 35 +- ...ify__tests__preview__SIM117_SIM117.py.snap | 98 ++-- ...ake8_slots__tests__SLOT000_SLOT000.py.snap | 6 +- ...ake8_slots__tests__SLOT001_SLOT001.py.snap | 20 +- ...ake8_slots__tests__SLOT002_SLOT002.py.snap | 21 +- ..._tidy_imports__tests__ban_all_imports.snap | 120 +++-- ...dy_imports__tests__ban_parent_imports.snap | 92 ++-- ...ts__tests__ban_parent_imports_package.snap | 49 +- ...lake8_tidy_imports__tests__banned_api.snap | 60 ++- ...dy_imports__tests__banned_api_package.snap | 15 +- ...s__tests__banned_module_level_imports.snap | 40 +- ..._invalid-todo-capitalization_TD006.py.snap | 22 +- ...dos__tests__invalid-todo-tag_TD001.py.snap | 16 +- ...ssing-space-after-todo-colon_TD007.py.snap | 26 +- ...__tests__missing-todo-author_TD002.py.snap | 21 +- ...s__tests__missing-todo-colon_TD004.py.snap | 26 +- ...ts__missing-todo-description_TD005.py.snap | 21 +- ...os__tests__missing-todo-link_TD003.py.snap | 30 +- ...__TC001-TC002-TC003_TC001-3_future.py.snap | 21 +- ...ts__add_future_import__TC001_TC001.py.snap | 7 +- ..._future_import__TC001_TC001_future.py.snap | 14 +- ...import__TC001_TC001_future_present.py.snap | 7 +- ...ts__add_future_import__TC002_TC002.py.snap | 63 ++- ...ts__add_future_import__TC003_TC003.py.snap | 7 +- ...s__empty-type-checking-block_TC005.py.snap | 28 +- ..._type_checking__tests__exempt_modules.snap | 7 +- ...g__tests__github_issue_15681_fix_test.snap | 7 +- ...ke8_type_checking__tests__import_from.snap | 8 +- ...ests__import_from_type_checking_block.snap | 8 +- ...ype_checking__tests__multiple_members.snap | 15 +- ...sts__multiple_modules_different_types.snap | 14 +- ...ng__tests__multiple_modules_same_type.snap | 14 +- ...ype_checking__tests__no_typing_import.snap | 7 +- ...alias_TC008_union_syntax_pre_py310.py.snap | 14 +- ...mport-in-type-checking-block_quote.py.snap | 14 +- ...ping-only-third-party-import_quote.py.snap | 91 ++-- ...ing-only-third-party-import_quote2.py.snap | 63 ++- ...ing-only-third-party-import_quote3.py.snap | 49 +- ...ng__tests__quoted-type-alias_TC008.py.snap | 196 ++++---- ...ias_TC008_typing_execution_context.py.snap | 84 ++-- ...g__tests__runtime-cast-value_TC006.py.snap | 91 ++-- ...ort-in-type-checking-block_TC004_1.py.snap | 8 +- ...rt-in-type-checking-block_TC004_11.py.snap | 7 +- ...rt-in-type-checking-block_TC004_12.py.snap | 7 +- ...rt-in-type-checking-block_TC004_17.py.snap | 8 +- ...ort-in-type-checking-block_TC004_2.py.snap | 8 +- ...ort-in-type-checking-block_TC004_4.py.snap | 8 +- ...ort-in-type-checking-block_TC004_5.py.snap | 22 +- ...ort-in-type-checking-block_TC004_9.py.snap | 14 +- ...in-type-checking-block_module__app.py.snap | 14 +- ...mport-in-type-checking-block_quote.py.snap | 14 +- ...k_runtime_evaluated_base_classes_1.py.snap | 21 +- ...ock_runtime_evaluated_decorators_1.py.snap | 21 +- ...-in-type-checking-block_whitespace.py.snap | 7 +- ...ests__runtime-string-union_TC010_1.py.snap | 5 +- ...ests__runtime-string-union_TC010_2.py.snap | 25 +- ...y-standard-library-import_init_var.py.snap | 14 +- ...ly-standard-library-import_kw_only.py.snap | 7 +- ...ing-only-third-party-import_strict.py.snap | 56 ++- ...g__tests__tc004_precedence_over_tc007.snap | 7 +- ...g__tests__tc010_precedence_over_tc008.snap | 12 +- ...ests__type_checking_block_after_usage.snap | 7 +- ...g__tests__type_checking_block_comment.snap | 7 +- ...ng__tests__type_checking_block_inline.snap | 7 +- ...__tests__type_checking_block_own_line.snap | 7 +- ...ping-only-first-party-import_TC001.py.snap | 7 +- ...only-standard-library-import_TC003.py.snap | 7 +- ...rary-import_exempt_type_checking_1.py.snap | 7 +- ...rary-import_exempt_type_checking_2.py.snap | 7 +- ...rary-import_exempt_type_checking_3.py.snap | 7 +- ...y-standard-library-import_init_var.py.snap | 8 +- ...d-library-import_module__undefined.py.snap | 7 +- ...t_runtime_evaluated_base_classes_3.py.snap | 7 +- ...ort_runtime_evaluated_decorators_3.py.snap | 8 +- ...ibrary-import_singledispatchmethod.py.snap | 8 +- ...ping-only-third-party-import_TC002.py.snap | 63 ++- ...t_runtime_evaluated_base_classes_2.py.snap | 14 +- ...ort_runtime_evaluated_decorators_2.py.snap | 7 +- ...-third-party-import_singledispatch.py.snap | 7 +- ...ing-only-third-party-import_strict.py.snap | 14 +- ...hird-party-import_typing_modules_1.py.snap | 7 +- ...hird-party-import_typing_modules_2.py.snap | 7 +- ...s__typing_import_after_package_import.snap | 7 +- ...ing__tests__typing_import_after_usage.snap | 7 +- ...__typing_import_before_package_import.snap | 7 +- ...__tests__unquoted-type-alias_TC007.py.snap | 63 ++- ...nused_arguments__tests__ARG001_ARG.py.snap | 21 +- ...nused_arguments__tests__ARG002_ARG.py.snap | 40 +- ...nused_arguments__tests__ARG003_ARG.py.snap | 5 +- ...nused_arguments__tests__ARG004_ARG.py.snap | 20 +- ...nused_arguments__tests__ARG005_ARG.py.snap | 5 +- ...uments__tests__enforce_variadic_names.snap | 60 ++- ...guments__tests__ignore_variadic_names.snap | 40 +- ...e_pathlib__tests__PTH124_py_path_1.py.snap | 5 +- ...e_pathlib__tests__PTH124_py_path_2.py.snap | 5 +- ..._use_pathlib__tests__PTH201_PTH201.py.snap | 105 ++-- ..._use_pathlib__tests__PTH202_PTH202.py.snap | 224 +++++---- ...se_pathlib__tests__PTH202_PTH202_2.py.snap | 21 +- ..._use_pathlib__tests__PTH203_PTH203.py.snap | 98 ++-- ..._use_pathlib__tests__PTH204_PTH204.py.snap | 42 +- ..._use_pathlib__tests__PTH205_PTH205.py.snap | 42 +- ..._use_pathlib__tests__PTH206_PTH206.py.snap | 50 +- ..._use_pathlib__tests__PTH207_PTH207.py.snap | 15 +- ..._use_pathlib__tests__PTH208_PTH208.py.snap | 35 +- ..._use_pathlib__tests__PTH210_PTH210.py.snap | 259 ++++++---- ...se_pathlib__tests__PTH210_PTH210_1.py.snap | 210 ++++---- ..._use_pathlib__tests__PTH211_PTH211.py.snap | 20 +- ...ake8_use_pathlib__tests__full_name.py.snap | 227 +++++---- ...ake8_use_pathlib__tests__import_as.py.snap | 161 +++--- ...e8_use_pathlib__tests__import_from.py.snap | 197 +++++--- ...use_pathlib__tests__import_from_as.py.snap | 161 +++--- ...lib__tests__preview__PTH201_PTH201.py.snap | 141 +++--- ...lib__tests__preview__PTH202_PTH202.py.snap | 224 +++++---- ...b__tests__preview__PTH202_PTH202_2.py.snap | 21 +- ...lib__tests__preview__PTH203_PTH203.py.snap | 98 ++-- ...lib__tests__preview__PTH204_PTH204.py.snap | 42 +- ...lib__tests__preview__PTH205_PTH205.py.snap | 42 +- ..._pathlib__tests__preview_full_name.py.snap | 227 +++++---- ..._pathlib__tests__preview_import_as.py.snap | 161 +++--- ...athlib__tests__preview_import_from.py.snap | 197 +++++--- ...lib__tests__preview_import_from_as.py.snap | 161 +++--- ...rules__flynt__tests__FLY002_FLY002.py.snap | 49 +- ...kage_first_and_third_party_imports.py.snap | 7 +- ...kage_first_and_third_party_imports.py.snap | 7 +- ...tests__add_newline_before_comments.py.snap | 7 +- ..._isort__tests__as_imports_comments.py.snap | 7 +- ..._rules__isort__tests__bom_unsorted.py.snap | 9 +- ...sts__case_sensitive_case_sensitive.py.snap | 7 +- ...to_furthest_relative_imports_order.py.snap | 7 +- ...__isort__tests__combine_as_imports.py.snap | 7 +- ...bine_as_imports_combine_as_imports.py.snap | 7 +- ..._isort__tests__combine_import_from.py.snap | 7 +- ...ter__rules__isort__tests__comments.py.snap | 7 +- ..._isort__tests__deduplicate_imports.py.snap | 7 +- ...es__isort__tests__detect_same_package.snap | 7 +- ...les__isort__tests__fit_line_length.py.snap | 7 +- ...rt__tests__fit_line_length_comment.py.snap | 7 +- ...orce_single_line_force_single_line.py.snap | 7 +- ..._tests__force_sort_within_sections.py.snap | 7 +- ...ections_force_sort_within_sections.py.snap | 7 +- ..._force_sort_within_sections_future.py.snap | 7 +- ...sort_within_sections_with_as_names.py.snap | 7 +- ..._rules__isort__tests__force_to_top.py.snap | 7 +- ...__tests__force_to_top_force_to_top.py.snap | 7 +- ...__isort__tests__force_wrap_aliases.py.snap | 7 +- ...ce_wrap_aliases_force_wrap_aliases.py.snap | 7 +- ...les__isort__tests__forced_separate.py.snap | 7 +- ...__rules__isort__tests__future_from.py.snap | 7 +- ...kage_first_and_third_party_imports.py.snap | 7 +- ..._rules__isort__tests__if_elif_else.py.snap | 7 +- ...t__tests__import_from_after_import.py.snap | 7 +- ...les__isort__tests__inline_comments.py.snap | 7 +- ...__isort__tests__insert_empty_lines.py.snap | 28 +- ..._isort__tests__insert_empty_lines.pyi.snap | 21 +- ...sest_separate_local_folder_imports.py.snap | 7 +- ...lder_separate_local_folder_imports.py.snap | 7 +- ...ules__isort__tests__leading_prefix.py.snap | 28 +- ...gth_sort__length_sort_from_imports.py.snap | 7 +- ...ort__length_sort_non_ascii_members.py.snap | 7 +- ...ort__length_sort_non_ascii_modules.py.snap | 7 +- ...gth_sort_straight_and_from_imports.py.snap | 7 +- ...sort__length_sort_straight_imports.py.snap | 7 +- ..._length_sort_with_relative_imports.py.snap | 7 +- ...straight__length_sort_from_imports.py.snap | 7 +- ...gth_sort_straight_and_from_imports.py.snap | 7 +- ...ight__length_sort_straight_imports.py.snap | 7 +- ...es__isort__tests__line_ending_crlf.py.snap | 7 +- ...ules__isort__tests__line_ending_lf.py.snap | 7 +- ...isort__tests__lines_after_imports.pyi.snap | 7 +- ...s__lines_after_imports_class_after.py.snap | 7 +- ...ts__lines_after_imports_func_after.py.snap | 7 +- ...after_imports_lines_after_imports.pyi.snap | 7 +- ...ts_lines_after_imports_class_after.py.snap | 7 +- ...rts_lines_after_imports_func_after.py.snap | 7 +- ..._lines_after_imports_nothing_after.py.snap | 7 +- ...s_between_typeslines_between_types.py.snap | 7 +- ...isort__tests__magic_trailing_comma.py.snap | 7 +- ...r__rules__isort__tests__match_case.py.snap | 14 +- ...rules__isort__tests__natural_order.py.snap | 7 +- ..._isort__tests__no_detect_same_package.snap | 7 +- ...les__isort__tests__no_lines_before.py.snap | 7 +- ...no_lines_before.py_no_lines_before.py.snap | 7 +- ...o_lines_before_with_empty_sections.py.snap | 7 +- ...andard_library_no_standard_library.py.snap | 7 +- ..._rules__isort__tests__no_wrap_star.py.snap | 7 +- ...rules__isort__tests__order_by_type.py.snap | 7 +- ..._order_by_type_false_order_by_type.py.snap | 7 +- ..._order_by_type_with_custom_classes.py.snap | 7 +- ..._order_by_type_with_custom_classes.py.snap | 7 +- ...rder_by_type_with_custom_constants.py.snap | 7 +- ...rder_by_type_with_custom_constants.py.snap | 7 +- ...rder_by_type_with_custom_variables.py.snap | 7 +- ...rder_by_type_with_custom_variables.py.snap | 7 +- ...s__order_relative_imports_by_level.py.snap | 7 +- ...ort__tests__preserve_comment_order.py.snap | 7 +- ...isort__tests__preserve_import_star.py.snap | 7 +- ...isort__tests__preserve_indentation.py.snap | 14 +- ...comments_propagate_inline_comments.py.snap | 7 +- ...ort__tests__reorder_within_section.py.snap | 7 +- ...rt__tests__required_import_comment.py.snap | 6 +- ...uired_import_comments_and_newlines.py.snap | 6 +- ...__tests__required_import_docstring.py.snap | 6 +- ...docstring_followed_by_continuation.py.snap | 5 +- ...import_docstring_with_continuation.py.snap | 6 +- ...ed_import_docstring_with_semicolon.py.snap | 6 +- ...s__required_import_existing_import.py.snap | 6 +- ...equired_import_multiline_docstring.py.snap | 6 +- ..._isort__tests__required_import_off.py.snap | 6 +- ...ort__tests__required_import_unused.py.snap | 14 +- ..._tests__required_import_whitespace.py.snap | 5 +- ...required_import_with_alias_comment.py.snap | 6 +- ...t_with_alias_comments_and_newlines.py.snap | 6 +- ...quired_import_with_alias_docstring.py.snap | 6 +- ...docstring_followed_by_continuation.py.snap | 5 +- ..._alias_docstring_with_continuation.py.snap | 6 +- ...ith_alias_docstring_with_semicolon.py.snap | 6 +- ..._import_with_alias_existing_import.py.snap | 6 +- ...ort_with_alias_multiline_docstring.py.snap | 6 +- ...ts__required_import_with_alias_off.py.snap | 6 +- ...mport_with_useless_alias_this_this.py.snap | 8 +- ..._with_useless_alias_this_this_from.py.snap | 8 +- ..._tests__required_imports_docstring.py.snap | 11 +- ..._required_imports_multiple_strings.py.snap | 10 +- ...ort__tests__section_order_sections.py.snap | 7 +- ...__tests__sections_main_first_party.py.snap | 7 +- ...s__isort__tests__sections_sections.py.snap | 7 +- ...ests__separate_first_party_imports.py.snap | 7 +- ...rt__tests__separate_future_imports.py.snap | 7 +- ...sts__separate_local_folder_imports.py.snap | 7 +- ...ests__separate_third_party_imports.py.snap | 7 +- ..._linter__rules__isort__tests__skip.py.snap | 21 +- ...isort__tests__sort_similar_imports.py.snap | 7 +- ...linter__rules__isort__tests__split.py.snap | 21 +- ...railing_comma_magic_trailing_comma.py.snap | 7 +- ...__isort__tests__star_before_others.py.snap | 7 +- ...straight_required_import_docstring.py.snap | 6 +- ...traight_required_import_docstring.pyi.snap | 6 +- ...es__isort__tests__trailing_comment.py.snap | 35 +- ...les__isort__tests__trailing_suffix.py.snap | 14 +- ...er__rules__isort__tests__two_space.py.snap | 7 +- ...nter__rules__isort__tests__unicode.py.snap | 7 +- ...ules__mccabe__tests__max_complexity_0.snap | 110 ++-- ...ules__mccabe__tests__max_complexity_3.snap | 11 +- ...__numpy-deprecated-function_NPY003.py.snap | 70 +-- ...numpy-deprecated-type-alias_NPY001.py.snap | 56 ++- ..._tests__numpy-legacy-random_NPY002.py.snap | 260 ++++++---- ...__tests__numpy2-deprecation_NPY201.py.snap | 215 ++++---- ...tests__numpy2-deprecation_NPY201_2.py.snap | 187 ++++--- ...tests__numpy2-deprecation_NPY201_3.py.snap | 49 +- ...es__pandas_vet__tests__PD002_PD002.py.snap | 70 +-- ..._rules__pandas_vet__tests__PD002_fail.snap | 8 +- ..._rules__pandas_vet__tests__PD003_fail.snap | 6 +- ..._rules__pandas_vet__tests__PD004_fail.snap | 6 +- ..._rules__pandas_vet__tests__PD007_fail.snap | 6 +- ..._rules__pandas_vet__tests__PD008_fail.snap | 6 +- ..._rules__pandas_vet__tests__PD009_fail.snap | 6 +- ...__pandas_vet__tests__PD010_fail_pivot.snap | 6 +- ..._pandas_vet__tests__PD011_fail_values.snap | 6 +- ...PD012_pandas_use_of_dot_read_table.py.snap | 20 +- ...__pandas_vet__tests__PD013_fail_stack.snap | 6 +- ...ts__PD015_fail_merge_on_pandas_object.snap | 6 +- ...es__pandas_vet__tests__PD101_PD101.py.snap | 60 ++- ..._pandas_vet__tests__PD901_fail_df_var.snap | 6 +- ...les__pep8_naming__tests__N801_N801.py.snap | 35 +- ...les__pep8_naming__tests__N802_N802.py.snap | 45 +- ...les__pep8_naming__tests__N803_N803.py.snap | 25 +- ...les__pep8_naming__tests__N804_N804.py.snap | 77 +-- ...les__pep8_naming__tests__N805_N805.py.snap | 126 +++-- ...les__pep8_naming__tests__N806_N806.py.snap | 35 +- ...les__pep8_naming__tests__N807_N807.py.snap | 11 +- ...les__pep8_naming__tests__N811_N811.py.snap | 25 +- ...les__pep8_naming__tests__N812_N812.py.snap | 16 +- ...les__pep8_naming__tests__N813_N813.py.snap | 16 +- ...les__pep8_naming__tests__N814_N814.py.snap | 15 +- ...les__pep8_naming__tests__N815_N815.py.snap | 16 +- ...les__pep8_naming__tests__N816_N816.py.snap | 16 +- ...les__pep8_naming__tests__N817_N817.py.snap | 16 +- ...les__pep8_naming__tests__N818_N818.py.snap | 11 +- ...999_N999__module__MODULE____init__.py.snap | 4 +- ...module__invalid_name__0001_initial.py.snap | 4 +- ...N999__module__invalid_name__import.py.snap | 4 +- ..._module__mod with spaces____init__.py.snap | 4 +- ..._module__mod-with-dashes____init__.py.snap | 4 +- ...dule__valid_name__file-with-dashes.py.snap | 4 +- ...case_imported_as_incorrect_convention.snap | 25 +- ...naming__tests__classmethod_decorators.snap | 105 ++-- ...ing__tests__ignore_names_N801_N801.py.snap | 10 +- ...ing__tests__ignore_names_N802_N802.py.snap | 10 +- ...ing__tests__ignore_names_N803_N803.py.snap | 10 +- ...ing__tests__ignore_names_N804_N804.py.snap | 35 +- ...ing__tests__ignore_names_N805_N805.py.snap | 70 +-- ...ing__tests__ignore_names_N806_N806.py.snap | 10 +- ...ing__tests__ignore_names_N807_N807.py.snap | 10 +- ...ing__tests__ignore_names_N811_N811.py.snap | 10 +- ...ing__tests__ignore_names_N812_N812.py.snap | 10 +- ...ing__tests__ignore_names_N813_N813.py.snap | 15 +- ...ing__tests__ignore_names_N814_N814.py.snap | 15 +- ...ing__tests__ignore_names_N815_N815.py.snap | 30 +- ...ing__tests__ignore_names_N816_N816.py.snap | 15 +- ...ing__tests__ignore_names_N817_N817.py.snap | 10 +- ...ing__tests__ignore_names_N818_N818.py.snap | 10 +- ...aming__tests__staticmethod_decorators.snap | 119 +++-- ...__perflint__tests__PERF101_PERF101.py.snap | 91 ++-- ...__perflint__tests__PERF102_PERF102.py.snap | 85 ++-- ...__perflint__tests__PERF203_PERF203.py.snap | 5 +- ...__perflint__tests__PERF401_PERF401.py.snap | 189 ++++--- ...__perflint__tests__PERF402_PERF402.py.snap | 6 +- ...__perflint__tests__PERF403_PERF403.py.snap | 119 +++-- ...t__tests__preview__PERF401_PERF401.py.snap | 189 ++++--- ...t__tests__preview__PERF403_PERF403.py.snap | 119 +++-- ...les__pycodestyle__tests__E101_E101.py.snap | 15 +- ...ules__pycodestyle__tests__E111_E11.py.snap | 22 +- ...ules__pycodestyle__tests__E112_E11.py.snap | 22 +- ...ules__pycodestyle__tests__E113_E11.py.snap | 33 +- ...ules__pycodestyle__tests__E114_E11.py.snap | 17 +- ...ules__pycodestyle__tests__E115_E11.py.snap | 42 +- ...ules__pycodestyle__tests__E116_E11.py.snap | 32 +- ...ules__pycodestyle__tests__E117_E11.py.snap | 27 +- ...ules__pycodestyle__tests__E201_E20.py.snap | 70 +-- ...ules__pycodestyle__tests__E202_E20.py.snap | 63 ++- ...ules__pycodestyle__tests__E203_E20.py.snap | 126 +++-- ...les__pycodestyle__tests__E204_E204.py.snap | 22 +- ...ules__pycodestyle__tests__E211_E21.py.snap | 50 +- ...ules__pycodestyle__tests__E221_E22.py.snap | 63 ++- ...ules__pycodestyle__tests__E222_E22.py.snap | 42 +- ...ules__pycodestyle__tests__E223_E22.py.snap | 7 +- ...ules__pycodestyle__tests__E224_E22.py.snap | 8 +- ...ules__pycodestyle__tests__E225_E22.py.snap | 85 ++-- ...ules__pycodestyle__tests__E226_E22.py.snap | 183 ++++--- ...ules__pycodestyle__tests__E227_E22.py.snap | 57 ++- ...ules__pycodestyle__tests__E228_E22.py.snap | 22 +- ...ules__pycodestyle__tests__E231_E23.py.snap | 322 +++++++----- ...ules__pycodestyle__tests__E241_E24.py.snap | 29 +- ...ules__pycodestyle__tests__E242_E24.py.snap | 7 +- ...ules__pycodestyle__tests__E251_E25.py.snap | 78 +-- ...ules__pycodestyle__tests__E252_E25.py.snap | 168 ++++--- ...ules__pycodestyle__tests__E261_E26.py.snap | 8 +- ...ules__pycodestyle__tests__E262_E26.py.snap | 49 +- ...ules__pycodestyle__tests__E265_E26.py.snap | 42 +- ...ules__pycodestyle__tests__E266_E26.py.snap | 35 +- ...ules__pycodestyle__tests__E271_E27.py.snap | 70 +-- ...ules__pycodestyle__tests__E272_E27.py.snap | 21 +- ...ules__pycodestyle__tests__E273_E27.py.snap | 42 +- ...ules__pycodestyle__tests__E274_E27.py.snap | 14 +- ...ules__pycodestyle__tests__E275_E27.py.snap | 50 +- ...ules__pycodestyle__tests__E301_E30.py.snap | 36 +- ...tyle__tests__E301_E30_syntax_error.py.snap | 24 +- ...ules__pycodestyle__tests__E302_E30.py.snap | 98 ++-- ...ts__E302_E302_first_line_docstring.py.snap | 7 +- ...s__E302_E302_first_line_expression.py.snap | 7 +- ...sts__E302_E302_first_line_function.py.snap | 7 +- ...ts__E302_E302_first_line_statement.py.snap | 7 +- ...tyle__tests__E302_E30_syntax_error.py.snap | 24 +- ...ules__pycodestyle__tests__E303_E30.py.snap | 98 ++-- ...ests__E303_E303_first_line_comment.py.snap | 8 +- ...ts__E303_E303_first_line_docstring.py.snap | 8 +- ...s__E303_E303_first_line_expression.py.snap | 8 +- ...ts__E303_E303_first_line_statement.py.snap | 8 +- ...tyle__tests__E303_E30_syntax_error.py.snap | 24 +- ...ules__pycodestyle__tests__E304_E30.py.snap | 21 +- ...ules__pycodestyle__tests__E305_E30.py.snap | 42 +- ...tyle__tests__E305_E30_syntax_error.py.snap | 24 +- ...ules__pycodestyle__tests__E306_E30.py.snap | 78 +-- ...tyle__tests__E306_E30_syntax_error.py.snap | 24 +- ...ules__pycodestyle__tests__E401_E40.py.snap | 63 ++- ...ules__pycodestyle__tests__E402_E40.py.snap | 30 +- ...__pycodestyle__tests__E402_E402.ipynb.snap | 15 +- ...s__pycodestyle__tests__E402_E402_0.py.snap | 15 +- ...s__pycodestyle__tests__E402_E402_1.py.snap | 10 +- ...les__pycodestyle__tests__E501_E501.py.snap | 32 +- ...s__pycodestyle__tests__E501_E501_3.py.snap | 6 +- ...s__pycodestyle__tests__E501_E501_4.py.snap | Bin 9024 -> 9132 bytes ...ules__pycodestyle__tests__E701_E70.py.snap | 71 +-- ...ules__pycodestyle__tests__E702_E70.py.snap | 36 +- ...ules__pycodestyle__tests__E703_E70.py.snap | 36 +- ...__pycodestyle__tests__E703_E703.ipynb.snap | 15 +- ...les__pycodestyle__tests__E711_E711.py.snap | 70 +-- ...les__pycodestyle__tests__E712_E712.py.snap | 98 ++-- ...les__pycodestyle__tests__E713_E713.py.snap | 43 +- ...les__pycodestyle__tests__E714_E714.py.snap | 22 +- ...les__pycodestyle__tests__E721_E721.py.snap | 80 +-- ...les__pycodestyle__tests__E722_E722.py.snap | 16 +- ...les__pycodestyle__tests__E731_E731.py.snap | 168 ++++--- ...les__pycodestyle__tests__E741_E741.py.snap | 125 +++-- ...les__pycodestyle__tests__E742_E742.py.snap | 16 +- ...les__pycodestyle__tests__E743_E743.py.snap | 16 +- ...ules__pycodestyle__tests__W191_W19.py.snap | 206 +++++--- ...ules__pycodestyle__tests__W291_W29.py.snap | 22 +- ...les__pycodestyle__tests__W291_W291.py.snap | 28 +- ...s__pycodestyle__tests__W292_W292_0.py.snap | 7 +- ...ules__pycodestyle__tests__W293_W29.py.snap | 8 +- ...les__pycodestyle__tests__W293_W293.py.snap | 29 +- ...s__pycodestyle__tests__W605_W605_0.py.snap | 77 +-- ...s__pycodestyle__tests__W605_W605_1.py.snap | 231 +++++---- ...yle__tests__blank_lines_E301_notebook.snap | 8 +- ...yle__tests__blank_lines_E302_notebook.snap | 7 +- ...yle__tests__blank_lines_E303_notebook.snap | 14 +- ...__tests__blank_lines_E303_typing_stub.snap | 29 +- ...yle__tests__blank_lines_E304_notebook.snap | 7 +- ...__tests__blank_lines_E304_typing_stub.snap | 8 +- ...yle__tests__blank_lines_E305_notebook.snap | 8 +- ...yle__tests__blank_lines_E306_notebook.snap | 8 +- ...patibility-lines-after(-1)-between(0).snap | 49 +- ...mpatibility-lines-after(0)-between(0).snap | 42 +- ...mpatibility-lines-after(1)-between(1).snap | 35 +- ...mpatibility-lines-after(4)-between(4).snap | 56 ++- ..._tests__blank_lines_typing_stub_isort.snap | 105 ++-- ...pycodestyle__tests__constant_literals.snap | 189 ++++--- ...s__pycodestyle__tests__max_doc_length.snap | 35 +- ...yle__tests__max_doc_length_with_utf_8.snap | 35 +- ...destyle__tests__preview__E502_E502.py.snap | 98 ++-- ...tyle__tests__preview__W391_W391.ipynb.snap | 41 +- ...style__tests__preview__W391_W391_0.py.snap | 7 +- ...style__tests__preview__W391_W391_2.py.snap | 7 +- ...r__rules__pycodestyle__tests__shebang.snap | 8 +- ...rules__pycodestyle__tests__tab_size_1.snap | 25 +- ...rules__pycodestyle__tests__tab_size_2.snap | 45 +- ...rules__pycodestyle__tests__tab_size_4.snap | 55 +- ...rules__pycodestyle__tests__tab_size_8.snap | 55 +- ...__pycodestyle__tests__task_tags_false.snap | 116 +++-- ...patibility-lines-after(-1)-between(0).snap | 49 +- ...mpatibility-lines-after(0)-between(0).snap | 63 ++- ...mpatibility-lines-after(1)-between(1).snap | 49 +- ...mpatibility-lines-after(4)-between(4).snap | 35 +- ...er__rules__pycodestyle__tests__w292_4.snap | 7 +- ...hite_space_syntax_error_compatibility.snap | 3 +- ...extraneous-exception_DOC502_google.py.snap | 21 +- ...-extraneous-exception_DOC502_numpy.py.snap | 21 +- ...g-extraneous-returns_DOC202_google.py.snap | 21 +- ...ng-extraneous-returns_DOC202_numpy.py.snap | 14 +- ...ng-extraneous-yields_DOC403_google.py.snap | 14 +- ...ing-extraneous-yields_DOC403_numpy.py.snap | 14 +- ...ng-missing-exception_DOC501_google.py.snap | 63 ++- ...tion_DOC501_google.py_ignore_one_line.snap | 63 ++- ...ing-missing-exception_DOC501_numpy.py.snap | 42 +- ...ring-missing-returns_DOC201_google.py.snap | 49 +- ...urns_DOC201_google.py_ignore_one_line.snap | 35 +- ...tring-missing-returns_DOC201_numpy.py.snap | 70 +-- ...tring-missing-yields_DOC402_google.py.snap | 42 +- ...elds_DOC402_google.py_ignore_one_line.snap | 14 +- ...string-missing-yields_DOC402_numpy.py.snap | 49 +- ...__rules__pydocstyle__tests__D100_D.py.snap | 4 +- ...ts__D100__unrelated__pkg__D100_pub.py.snap | 4 +- ...__rules__pydocstyle__tests__D101_D.py.snap | 5 +- ...__rules__pydocstyle__tests__D102_D.py.snap | 26 +- ...es__pydocstyle__tests__D102_setter.py.snap | 6 +- ...__rules__pydocstyle__tests__D103_D.py.snap | 6 +- ...cstyle__tests__D104_D104____init__.py.snap | 4 +- ...__rules__pydocstyle__tests__D105_D.py.snap | 6 +- ...__rules__pydocstyle__tests__D107_D.py.snap | 10 +- ...__rules__pydocstyle__tests__D200_D.py.snap | 42 +- ...ules__pydocstyle__tests__D200_D200.py.snap | 21 +- ...__rules__pydocstyle__tests__D201_D.py.snap | 35 +- ...__rules__pydocstyle__tests__D202_D.py.snap | 35 +- ...ules__pydocstyle__tests__D202_D202.py.snap | 21 +- ...__rules__pydocstyle__tests__D203_D.py.snap | 42 +- ...__rules__pydocstyle__tests__D204_D.py.snap | 35 +- ...__rules__pydocstyle__tests__D205_D.py.snap | 14 +- ...__rules__pydocstyle__tests__D207_D.py.snap | 28 +- ...__rules__pydocstyle__tests__D208_D.py.snap | 147 +++--- ...ules__pydocstyle__tests__D208_D208.py.snap | 70 +-- ...__rules__pydocstyle__tests__D209_D.py.snap | 14 +- ...__rules__pydocstyle__tests__D210_D.py.snap | 28 +- ...__rules__pydocstyle__tests__D211_D.py.snap | 14 +- ...__rules__pydocstyle__tests__D212_D.py.snap | 21 +- ...__rules__pydocstyle__tests__D213_D.py.snap | 196 ++++---- ...ydocstyle__tests__D214_D214_module.py.snap | 14 +- ...__pydocstyle__tests__D214_sections.py.snap | 14 +- ...ules__pydocstyle__tests__D215_D215.py.snap | 8 +- ...__pydocstyle__tests__D215_sections.py.snap | 15 +- ...__rules__pydocstyle__tests__D300_D.py.snap | 70 +-- ...ules__pydocstyle__tests__D300_D300.py.snap | 15 +- ...__rules__pydocstyle__tests__D301_D.py.snap | 8 +- ...ules__pydocstyle__tests__D301_D301.py.snap | 28 +- ...__rules__pydocstyle__tests__D400_D.py.snap | 119 +++-- ...ules__pydocstyle__tests__D400_D400.py.snap | 91 ++-- ...__pydocstyle__tests__D400_D400_415.py.snap | 36 +- ...ules__pydocstyle__tests__D401_D401.py.snap | 35 +- ...__rules__pydocstyle__tests__D402_D.py.snap | 6 +- ...ules__pydocstyle__tests__D402_D402.py.snap | 10 +- ...ules__pydocstyle__tests__D403_D403.py.snap | 84 ++-- ...__rules__pydocstyle__tests__D404_D.py.snap | 20 +- ...__pydocstyle__tests__D405_sections.py.snap | 21 +- ...__pydocstyle__tests__D406_sections.py.snap | 21 +- ...__pydocstyle__tests__D407_sections.py.snap | 49 +- ...__pydocstyle__tests__D408_sections.py.snap | 7 +- ...__pydocstyle__tests__D409_sections.py.snap | 21 +- ...ules__pydocstyle__tests__D410_D410.py.snap | 14 +- ...__pydocstyle__tests__D410_sections.py.snap | 14 +- ...__pydocstyle__tests__D411_sections.py.snap | 22 +- ...__pydocstyle__tests__D412_sections.py.snap | 7 +- ...es__pydocstyle__tests__D412_sphinx.py.snap | 29 +- ...ules__pydocstyle__tests__D413_D413.py.snap | 35 +- ...__pydocstyle__tests__D413_sections.py.snap | 63 ++- ...__pydocstyle__tests__D414_sections.py.snap | 35 +- ...__rules__pydocstyle__tests__D415_D.py.snap | 112 +++-- ...__pydocstyle__tests__D415_D400_415.py.snap | 22 +- ...__pydocstyle__tests__D417_sections.py.snap | 55 +- ...__rules__pydocstyle__tests__D418_D.py.snap | 16 +- ...__rules__pydocstyle__tests__D419_D.py.snap | 15 +- ...linter__rules__pydocstyle__tests__all.snap | 20 +- ...linter__rules__pydocstyle__tests__bom.snap | 10 +- ...__rules__pydocstyle__tests__d209_d400.snap | 14 +- ...rules__pydocstyle__tests__d417_google.snap | 60 ++- ...ts__d417_google_ignore_var_parameters.snap | 50 +- ...__pydocstyle__tests__d417_unspecified.snap | 60 ++- ...417_unspecified_ignore_var_parameters.snap | 60 ++- ...ules__pyflakes__tests__F401_F401_0.py.snap | 105 ++-- ...les__pyflakes__tests__F401_F401_10.py.snap | 14 +- ...les__pyflakes__tests__F401_F401_11.py.snap | 8 +- ...les__pyflakes__tests__F401_F401_15.py.snap | 8 +- ...les__pyflakes__tests__F401_F401_17.py.snap | 14 +- ...les__pyflakes__tests__F401_F401_18.py.snap | 8 +- ...les__pyflakes__tests__F401_F401_23.py.snap | 8 +- ...les__pyflakes__tests__F401_F401_34.py.snap | 14 +- ...ules__pyflakes__tests__F401_F401_5.py.snap | 29 +- ...ules__pyflakes__tests__F401_F401_6.py.snap | 28 +- ...ules__pyflakes__tests__F401_F401_7.py.snap | 22 +- ...ules__pyflakes__tests__F401_F401_9.py.snap | 8 +- ...eprecated_option_F401_24____init__.py.snap | 22 +- ...on_F401_25__all_nonempty____init__.py.snap | 22 +- ...ption_F401_26__all_empty____init__.py.snap | 15 +- ...on_F401_27__all_mistyped____init__.py.snap | 15 +- ...on_F401_28__all_multiple____init__.py.snap | 15 +- ...F401_29__all_conditional____init__.py.snap | 14 +- ...ts__F401_deprecated_option_F401_30.py.snap | 7 +- ...sts__F401_stable_F401_24____init__.py.snap | 22 +- ...le_F401_25__all_nonempty____init__.py.snap | 22 +- ...table_F401_26__all_empty____init__.py.snap | 15 +- ...le_F401_27__all_mistyped____init__.py.snap | 15 +- ...le_F401_28__all_multiple____init__.py.snap | 15 +- ...F401_29__all_conditional____init__.py.snap | 14 +- ...les__pyflakes__tests__F402_F402.ipynb.snap | 11 +- ..._rules__pyflakes__tests__F402_F402.py.snap | 10 +- ..._rules__pyflakes__tests__F403_F403.py.snap | 10 +- ...ules__pyflakes__tests__F404_F404_0.py.snap | 5 +- ...ules__pyflakes__tests__F404_F404_1.py.snap | 5 +- ..._rules__pyflakes__tests__F405_F405.py.snap | 10 +- ..._rules__pyflakes__tests__F406_F406.py.snap | 11 +- ..._rules__pyflakes__tests__F407_F407.py.snap | 6 +- ..._rules__pyflakes__tests__F501_F50x.py.snap | 6 +- ..._rules__pyflakes__tests__F502_F502.py.snap | 36 +- ..._rules__pyflakes__tests__F502_F50x.py.snap | 6 +- ..._rules__pyflakes__tests__F503_F503.py.snap | 16 +- ..._rules__pyflakes__tests__F503_F50x.py.snap | 6 +- ..._rules__pyflakes__tests__F504_F504.py.snap | 51 +- ..._rules__pyflakes__tests__F504_F50x.py.snap | 8 +- ..._rules__pyflakes__tests__F505_F50x.py.snap | 6 +- ..._rules__pyflakes__tests__F506_F50x.py.snap | 15 +- ..._rules__pyflakes__tests__F507_F50x.py.snap | 11 +- ..._rules__pyflakes__tests__F508_F50x.py.snap | 5 +- ..._rules__pyflakes__tests__F509_F50x.py.snap | 6 +- ..._rules__pyflakes__tests__F521_F521.py.snap | 35 +- ..._rules__pyflakes__tests__F522_F522.py.snap | 42 +- ..._rules__pyflakes__tests__F523_F523.py.snap | 140 +++--- ..._rules__pyflakes__tests__F524_F524.py.snap | 36 +- ..._rules__pyflakes__tests__F525_F525.py.snap | 11 +- ..._rules__pyflakes__tests__F541_F541.py.snap | 140 +++--- ..._rules__pyflakes__tests__F601_F601.py.snap | 196 ++++---- ..._rules__pyflakes__tests__F602_F602.py.snap | 126 +++-- ..._rules__pyflakes__tests__F622_F622.py.snap | 6 +- ..._rules__pyflakes__tests__F631_F631.py.snap | 11 +- ..._rules__pyflakes__tests__F632_F632.py.snap | 84 ++-- ..._rules__pyflakes__tests__F633_F633.py.snap | 5 +- ..._rules__pyflakes__tests__F634_F634.py.snap | 15 +- ..._rules__pyflakes__tests__F701_F701.py.snap | 20 +- ..._rules__pyflakes__tests__F702_F702.py.snap | 20 +- ..._rules__pyflakes__tests__F704_F704.py.snap | 20 +- ..._rules__pyflakes__tests__F706_F706.py.snap | 11 +- ..._rules__pyflakes__tests__F707_F707.py.snap | 16 +- ..._rules__pyflakes__tests__F722_F722.py.snap | 30 +- ...ules__pyflakes__tests__F722_F722_1.py.snap | 15 +- ...ules__pyflakes__tests__F811_F811_0.py.snap | 8 +- ...ules__pyflakes__tests__F811_F811_1.py.snap | 8 +- ...les__pyflakes__tests__F811_F811_12.py.snap | 8 +- ...les__pyflakes__tests__F811_F811_15.py.snap | 8 +- ...les__pyflakes__tests__F811_F811_16.py.snap | 8 +- ...les__pyflakes__tests__F811_F811_17.py.snap | 14 +- ...ules__pyflakes__tests__F811_F811_2.py.snap | 8 +- ...les__pyflakes__tests__F811_F811_21.py.snap | 7 +- ...les__pyflakes__tests__F811_F811_23.py.snap | 8 +- ...les__pyflakes__tests__F811_F811_26.py.snap | 7 +- ...les__pyflakes__tests__F811_F811_28.py.snap | 7 +- ...es__pyflakes__tests__F811_F811_29.pyi.snap | 7 +- ...ules__pyflakes__tests__F811_F811_3.py.snap | 8 +- ...les__pyflakes__tests__F811_F811_30.py.snap | 21 +- ...les__pyflakes__tests__F811_F811_31.py.snap | 7 +- ...les__pyflakes__tests__F811_F811_32.py.snap | 7 +- ...ules__pyflakes__tests__F811_F811_4.py.snap | 8 +- ...ules__pyflakes__tests__F811_F811_5.py.snap | 8 +- ...ules__pyflakes__tests__F811_F811_6.py.snap | 8 +- ...ules__pyflakes__tests__F811_F811_8.py.snap | 8 +- ...ules__pyflakes__tests__F821_F821_0.py.snap | 65 ++- ...ules__pyflakes__tests__F821_F821_1.py.snap | 21 +- ...les__pyflakes__tests__F821_F821_11.py.snap | 11 +- ...es__pyflakes__tests__F821_F821_11.pyi.snap | 6 +- ...les__pyflakes__tests__F821_F821_12.py.snap | 11 +- ...les__pyflakes__tests__F821_F821_13.py.snap | 5 +- ...les__pyflakes__tests__F821_F821_17.py.snap | 145 +++--- ...les__pyflakes__tests__F821_F821_19.py.snap | 6 +- ...ules__pyflakes__tests__F821_F821_2.py.snap | 5 +- ...les__pyflakes__tests__F821_F821_20.py.snap | 5 +- ...les__pyflakes__tests__F821_F821_21.py.snap | 6 +- ...les__pyflakes__tests__F821_F821_26.py.snap | 46 +- ...les__pyflakes__tests__F821_F821_27.py.snap | 26 +- ...les__pyflakes__tests__F821_F821_28.py.snap | 5 +- ...ules__pyflakes__tests__F821_F821_3.py.snap | 10 +- ...les__pyflakes__tests__F821_F821_30.py.snap | 26 +- ...les__pyflakes__tests__F821_F821_31.py.snap | 31 +- ...ules__pyflakes__tests__F821_F821_4.py.snap | 25 +- ...ules__pyflakes__tests__F821_F821_5.py.snap | 6 +- ...les__pyflakes__tests__F821_F821_5.pyi.snap | 6 +- ...ules__pyflakes__tests__F821_F821_7.py.snap | 16 +- ...ules__pyflakes__tests__F821_F821_9.py.snap | 6 +- ...ules__pyflakes__tests__F822_F822_0.py.snap | 5 +- ...les__pyflakes__tests__F822_F822_0.pyi.snap | 5 +- ...ules__pyflakes__tests__F822_F822_1.py.snap | 5 +- ...les__pyflakes__tests__F822_F822_1b.py.snap | 5 +- ...ules__pyflakes__tests__F822_F822_3.py.snap | 6 +- ..._rules__pyflakes__tests__F823_F823.py.snap | 25 +- ...ules__pyflakes__tests__F841_F841_0.py.snap | 91 ++-- ...ules__pyflakes__tests__F841_F841_1.py.snap | 57 ++- ...ules__pyflakes__tests__F841_F841_3.py.snap | 280 ++++++----- ..._rules__pyflakes__tests__F842_F842.py.snap | 11 +- ..._rules__pyflakes__tests__F901_F901.py.snap | 22 +- ...tests__augmented_assignment_after_del.snap | 13 +- ...es__pyflakes__tests__default_builtins.snap | 6 +- ...flakes__tests__default_typing_modules.snap | 6 +- ...hadowed_global_import_in_global_scope.snap | 7 +- ...shadowed_global_import_in_local_scope.snap | 14 +- ...shadowed_import_shadow_in_local_scope.snap | 14 +- ..._shadowed_local_import_in_local_scope.snap | 7 +- ...r__rules__pyflakes__tests__double_del.snap | 6 +- ...pyflakes__tests__extra_typing_modules.snap | 6 +- ...s__f401_allowed_unused_imports_option.snap | 8 +- ...view_first_party_submodule_dunder_all.snap | 8 +- ...w_first_party_submodule_no_dunder_all.snap | 8 +- ...sion_but_old_target_version_specified.snap | 6 +- ...lakes__tests__f841_dummy_variable_rgx.snap | 112 +++-- ...__pyflakes__tests__future_annotations.snap | 13 +- ..._linter__rules__pyflakes__tests__init.snap | 7 +- ...er_multiple_unbinds_from_module_scope.snap | 15 +- ...s__load_after_unbind_from_class_scope.snap | 13 +- ...__load_after_unbind_from_module_scope.snap | 8 +- ...after_unbind_from_nested_module_scope.snap | 15 +- ...yflakes__tests__multi_statement_lines.snap | 112 +++-- ..._tests__nested_relative_typing_module.snap | 11 +- ...s__preview__F401_F401_24____init__.py.snap | 22 +- ...01_F401_25__all_nonempty____init__.py.snap | 22 +- ..._F401_F401_26__all_empty____init__.py.snap | 15 +- ...01_F401_27__all_mistyped____init__.py.snap | 15 +- ...01_F401_28__all_multiple____init__.py.snap | 15 +- ...F401_29__all_conditional____init__.py.snap | 14 +- ...s__preview__F401_F401_33____init__.py.snap | 8 +- ...kes__tests__preview__F401___init__.py.snap | 7 +- ...kes__tests__preview__F822___init__.py.snap | 15 +- ...in_body_after_double_shadowing_except.snap | 15 +- ..._print_in_body_after_shadowing_except.snap | 8 +- ...flakes__tests__relative_typing_module.snap | 6 +- ...grep_hooks__tests__PGH003_PGH003_0.py.snap | 20 +- ...grep_hooks__tests__PGH003_PGH003_1.py.snap | 15 +- ...grep_hooks__tests__PGH004_PGH004_0.py.snap | 29 +- ...grep_hooks__tests__PGH004_PGH004_1.py.snap | 6 +- ...grep_hooks__tests__PGH004_PGH004_2.py.snap | 15 +- ...grep_hooks__tests__PGH005_PGH005_0.py.snap | 45 +- ...s__tests__preview__PGH005_PGH005_0.py.snap | 95 ++-- ...C0105_type_name_incorrect_variance.py.snap | 160 +++--- ...nt__tests__PLC0131_type_bivariance.py.snap | 20 +- ...__PLC0132_type_param_name_mismatch.py.snap | 40 +- ...tests__PLC0205_single_string_slots.py.snap | 15 +- ...__PLC0206_dict_index_missing_items.py.snap | 30 +- ...ests__PLC0207_missing_maxsplit_arg.py.snap | 252 ++++++---- ..._tests__PLC0208_iteration_over_set.py.snap | 56 ++- ...nt__tests__PLC0414_import_aliasing.py.snap | 56 ++- ...LC0414_import_aliasing_2____init__.py.snap | 7 +- ...__PLC0415_import_outside_top_level.py.snap | 40 +- ...t__tests__PLC1802_len_as_condition.py.snap | 203 ++++---- ...s__PLC1901_compare_to_empty_string.py.snap | 25 +- ...int__tests__PLC2401_non_ascii_name.py.snap | 63 ++- ...s__PLC2403_non_ascii_module_import.py.snap | 28 +- ..._private_name__submodule____main__.py.snap | 35 +- ...s__PLC2801_unnecessary_dunder_call.py.snap | 418 ++++++++------- ...002_unnecessary_direct_lambda_call.py.snap | 15 +- ...lint__tests__PLE0100_yield_in_init.py.snap | 10 +- ...int__tests__PLE0101_return_in_init.py.snap | 10 +- ...tests__PLE0115_nonlocal_and_global.py.snap | 21 +- ...__PLE0117_nonlocal_without_binding.py.snap | 16 +- ...118_load_before_global_declaration.py.snap | 70 +-- ...tests__PLE0237_non_slot_assignment.py.snap | 16 +- ...nt__tests__PLE0241_duplicate_bases.py.snap | 63 ++- ...nexpected_special_method_signature.py.snap | 80 +-- ...PLE0303_invalid_return_type_length.py.snap | 26 +- ...__PLE0304_invalid_return_type_bool.py.snap | 10 +- ..._PLE0305_invalid_return_type_index.py.snap | 26 +- ...s__PLE0307_invalid_return_type_str.py.snap | 26 +- ..._PLE0308_invalid_return_type_bytes.py.snap | 21 +- ...__PLE0309_invalid_return_type_hash.py.snap | 21 +- ..._tests__PLE0604_invalid_all_object.py.snap | 10 +- ..._tests__PLE0605_invalid_all_format.py.snap | 65 ++- ...sts__PLE0643_potential_index_error.py.snap | 20 +- ...ests__PLE0704_misplaced_bare_raise.py.snap | 45 +- ..._PLE1132_repeated_keyword_argument.py.snap | 41 +- ...s__PLE1141_dict_iter_missing_items.py.snap | 14 +- ...ts__PLE1142_await_outside_async.ipynb.snap | 6 +- ...tests__PLE1142_await_outside_async.py.snap | 55 +- ...sts__PLE1205_logging_too_many_args.py.snap | 20 +- ...ests__PLE1206_logging_too_few_args.py.snap | 10 +- ...LE1300_bad_string_format_character.py.snap | 30 +- ...ts__PLE1307_bad_string_format_type.py.snap | 65 ++- ..._tests__PLE1310_bad_str_strip_call.py.snap | 110 ++-- ...ests__PLE1507_invalid_envvar_value.py.snap | 25 +- ...sts__PLE1519_singledispatch_method.py.snap | 21 +- ...1520_singledispatchmethod_function.py.snap | 8 +- ...E1700_yield_from_in_async_function.py.snap | 6 +- ...sts__PLE2502_bidirectional_unicode.py.snap | 23 +- ..._tests__PLE2510_invalid_characters.py.snap | Bin 4012 -> 3940 bytes ...10_invalid_characters_syntax_error.py.snap | 71 +-- ..._tests__PLE2512_invalid_characters.py.snap | Bin 4544 -> 4464 bytes ..._tests__PLE2513_invalid_characters.py.snap | Bin 5044 -> 4956 bytes ..._tests__PLE2514_invalid_characters.py.snap | Bin 1837 -> 1789 bytes ..._tests__PLE2515_invalid_characters.py.snap | Bin 7861 -> 7765 bytes ...ts__PLE4703_modified_iterating_set.py.snap | 42 +- ...ts__PLR0124_comparison_with_itself.py.snap | 60 ++- ...ts__PLR0133_comparison_of_constant.py.snap | 50 +- ...tests__PLR0202_no_method_decorator.py.snap | 14 +- ...tests__PLR0203_no_method_decorator.py.snap | 14 +- ...__PLR0206_property_with_parameters.py.snap | 46 +- ...nt__tests__PLR0402_import_aliasing.py.snap | 22 +- ...PLR0911_too_many_return_statements.py.snap | 6 +- ...__tests__PLR0912_too_many_branches.py.snap | 10 +- ..._tests__PLR0913_too_many_arguments.py.snap | 46 +- ...tests__PLR0915_too_many_statements.py.snap | 6 +- ...0917_too_many_positional_arguments.py.snap | 25 +- ...ts__PLR1702_too_many_nested_blocks.py.snap | 5 +- ...1704_redefined_argument_from_local.py.snap | 66 ++- ...int__tests__PLR1711_useless_return.py.snap | 43 +- ...R1714_repeated_equality_comparison.py.snap | 154 +++--- ...PLR1716_boolean_chained_comparison.py.snap | 168 ++++--- ...t__tests__PLR1722_sys_exit_alias_0.py.snap | 29 +- ...t__tests__PLR1722_sys_exit_alias_1.py.snap | 42 +- ...__tests__PLR1722_sys_exit_alias_10.py.snap | 8 +- ...__tests__PLR1722_sys_exit_alias_11.py.snap | 7 +- ...__tests__PLR1722_sys_exit_alias_12.py.snap | 7 +- ...__tests__PLR1722_sys_exit_alias_13.py.snap | 7 +- ...__tests__PLR1722_sys_exit_alias_14.py.snap | 7 +- ...__tests__PLR1722_sys_exit_alias_15.py.snap | 7 +- ...__tests__PLR1722_sys_exit_alias_16.py.snap | 28 +- ...t__tests__PLR1722_sys_exit_alias_2.py.snap | 28 +- ...t__tests__PLR1722_sys_exit_alias_3.py.snap | 22 +- ...t__tests__PLR1722_sys_exit_alias_4.py.snap | 28 +- ...t__tests__PLR1722_sys_exit_alias_5.py.snap | 28 +- ...t__tests__PLR1722_sys_exit_alias_6.py.snap | 15 +- ...t__tests__PLR1722_sys_exit_alias_7.py.snap | 8 +- ...t__tests__PLR1722_sys_exit_alias_8.py.snap | 8 +- ...t__tests__PLR1722_sys_exit_alias_9.py.snap | 8 +- ...nt__tests__PLR1730_if_stmt_min_max.py.snap | 245 +++++---- ...1733_unnecessary_dict_index_lookup.py.snap | 56 ++- ...1736_unnecessary_list_index_lookup.py.snap | 84 ++-- ...ts__PLR2004_magic_value_comparison.py.snap | 40 +- ...lint__tests__PLR2044_empty_comment.py.snap | 49 +- ...44_empty_comment_line_continuation.py.snap | 14 +- ...tests__PLR5501_collapsible_else_if.py.snap | 77 +-- ...__PLR6104_non_augmented_assignment.py.snap | 245 +++++---- ..._tests__PLR6201_literal_membership.py.snap | 28 +- ...pylint__tests__PLR6301_no_self_use.py.snap | 50 +- ...pylint__tests__PLW0101_unreachable.py.snap | 15 +- ..._tests__PLW0108_unnecessary_lambda.py.snap | 70 +-- ...ests__PLW0120_useless_else_on_loop.py.snap | 56 ++- ...s__PLW0127_self_assigning_variable.py.snap | 205 +++++--- ...__PLW0128_redeclared_assigned_name.py.snap | 50 +- ...__PLW0129_assert_on_string_literal.py.snap | 50 +- ...PLW0131_named_expr_without_context.py.snap | 16 +- ...LW0133_useless_exception_statement.py.snap | 91 ++-- ...int__tests__PLW0177_nan_comparison.py.snap | 75 +-- ..._PLW0211_bad_staticmethod_argument.py.snap | 20 +- ...LW0244_redefined_slots_in_subclass.py.snap | 20 +- ...ts__PLW0245_super_without_brackets.py.snap | 8 +- ...tests__PLW0406_import_self__module.py.snap | 16 +- ...W0602_global_variable_not_assigned.py.snap | 10 +- ...t__tests__PLW0603_global_statement.py.snap | 50 +- ...ts__PLW0604_global_at_module_level.py.snap | 10 +- ...ts__PLW0642_self_or_cls_assignment.py.snap | 105 ++-- ...tests__PLW0711_binary_op_exception.py.snap | 11 +- ...lint__tests__PLW1501_bad_open_mode.py.snap | 60 ++- ...ests__PLW1507_shallow_copy_environ.py.snap | 14 +- ...ts__PLW1508_invalid_envvar_default.py.snap | 30 +- ...LW1509_subprocess_popen_preexec_fn.py.snap | 20 +- ...W1510_subprocess_run_without_check.py.snap | 28 +- ...ests__PLW1514_unspecified_encoding.py.snap | 161 +++--- ...nt__tests__PLW1641_eq_without_hash.py.snap | 80 +-- ...__tests__PLW2101_useless_with_lock.py.snap | 55 +- ...tests__PLW2901_redefined_loop_name.py.snap | 135 +++-- ...ts__PLW3201_bad_dunder_method_name.py.snap | 35 +- ...int__tests__PLW3301_nested_min_max.py.snap | 119 +++-- ...ylint__tests__allow_magic_value_types.snap | 25 +- ...s__pylint__tests__continue_in_finally.snap | 65 ++- ..._import_outside_top_level_with_banned.snap | 50 +- ...inter__rules__pylint__tests__max_args.snap | 11 +- ..._tests__max_args_with_dummy_variables.snap | 6 +- ...ylint__tests__max_boolean_expressions.snap | 105 ++-- ...r__rules__pylint__tests__max_branches.snap | 10 +- ...s__pylint__tests__max_positional_args.snap | 11 +- ..._pylint__tests__max_return_statements.snap | 6 +- ..._rules__pylint__tests__max_statements.snap | 6 +- ...rules__pylint__tests__too_many_locals.snap | 6 +- ...ylint__tests__too_many_public_methods.snap | 5 +- crates/ruff_linter/src/rules/pyupgrade/mod.rs | 17 +- ...er__rules__pyupgrade__tests__UP001.py.snap | 14 +- ...er__rules__pyupgrade__tests__UP003.py.snap | 42 +- ...er__rules__pyupgrade__tests__UP004.py.snap | 168 ++++--- ...er__rules__pyupgrade__tests__UP005.py.snap | 29 +- ...__rules__pyupgrade__tests__UP006_0.py.snap | 120 +++-- ...__rules__pyupgrade__tests__UP006_1.py.snap | 8 +- ...__rules__pyupgrade__tests__UP006_2.py.snap | 8 +- ...__rules__pyupgrade__tests__UP006_3.py.snap | 8 +- ...er__rules__pyupgrade__tests__UP007.py.snap | 147 +++--- ...er__rules__pyupgrade__tests__UP008.py.snap | 105 ++-- ...__pyupgrade__tests__UP008.py__preview.snap | 105 ++-- ...__rules__pyupgrade__tests__UP009_0.py.snap | 7 +- ...__rules__pyupgrade__tests__UP009_1.py.snap | 7 +- ...__rules__pyupgrade__tests__UP009_6.py.snap | 8 +- ...__rules__pyupgrade__tests__UP009_7.py.snap | 8 +- ...rade__tests__UP009_utf8_code_other.py.snap | 8 +- ..._pyupgrade__tests__UP009_utf8_utf8.py.snap | 8 +- ...rade__tests__UP009_utf8_utf8_other.py.snap | 8 +- ...er__rules__pyupgrade__tests__UP010.py.snap | 77 +-- ...er__rules__pyupgrade__tests__UP011.py.snap | 29 +- ...er__rules__pyupgrade__tests__UP012.py.snap | 189 ++++--- ...er__rules__pyupgrade__tests__UP013.py.snap | 91 ++-- ...er__rules__pyupgrade__tests__UP014.py.snap | 42 +- ...er__rules__pyupgrade__tests__UP015.py.snap | 336 +++++++------ ...__rules__pyupgrade__tests__UP015_1.py.snap | 7 +- ...er__rules__pyupgrade__tests__UP018.py.snap | 238 +++++---- ..._rules__pyupgrade__tests__UP018_CR.py.snap | 25 +- ..._rules__pyupgrade__tests__UP018_LF.py.snap | 14 +- ...er__rules__pyupgrade__tests__UP019.py.snap | 29 +- ...er__rules__pyupgrade__tests__UP020.py.snap | 14 +- ...er__rules__pyupgrade__tests__UP021.py.snap | 21 +- ...er__rules__pyupgrade__tests__UP022.py.snap | 70 +-- ...er__rules__pyupgrade__tests__UP023.py.snap | 70 +-- ...__rules__pyupgrade__tests__UP024_0.py.snap | 106 ++-- ...__rules__pyupgrade__tests__UP024_1.py.snap | 22 +- ...__rules__pyupgrade__tests__UP024_2.py.snap | 161 +++--- ...__rules__pyupgrade__tests__UP024_4.py.snap | 8 +- ...er__rules__pyupgrade__tests__UP025.py.snap | 133 ++--- ...er__rules__pyupgrade__tests__UP026.py.snap | 182 ++++--- ...__rules__pyupgrade__tests__UP028_0.py.snap | 140 +++--- ...er__rules__pyupgrade__tests__UP029.py.snap | 29 +- ...__rules__pyupgrade__tests__UP030_0.py.snap | 182 ++++--- ...__rules__pyupgrade__tests__UP031_0.py.snap | 476 ++++++++++-------- ...__rules__pyupgrade__tests__UP032_0.py.snap | 441 +++++++++------- ...__rules__pyupgrade__tests__UP032_1.py.snap | 8 +- ...__rules__pyupgrade__tests__UP032_2.py.snap | 154 +++--- ...__rules__pyupgrade__tests__UP033_0.py.snap | 22 +- ...__rules__pyupgrade__tests__UP033_1.py.snap | 22 +- ...er__rules__pyupgrade__tests__UP034.py.snap | 70 +-- ...er__rules__pyupgrade__tests__UP035.py.snap | 412 ++++++++------- ...__rules__pyupgrade__tests__UP036_0.py.snap | 316 +++++++----- ...__rules__pyupgrade__tests__UP036_1.py.snap | 91 ++-- ...__rules__pyupgrade__tests__UP036_2.py.snap | 84 ++-- ...__rules__pyupgrade__tests__UP036_3.py.snap | 21 +- ...__rules__pyupgrade__tests__UP036_4.py.snap | 56 ++- ...__rules__pyupgrade__tests__UP036_5.py.snap | 82 +-- ...__rules__pyupgrade__tests__UP037_0.py.snap | 217 ++++---- ...__rules__pyupgrade__tests__UP037_1.py.snap | 8 +- ..._rules__pyupgrade__tests__UP037_2.pyi.snap | 70 +-- ...er__rules__pyupgrade__tests__UP038.py.snap | 14 +- ...er__rules__pyupgrade__tests__UP039.py.snap | 36 +- ...er__rules__pyupgrade__tests__UP040.py.snap | 154 +++--- ...r__rules__pyupgrade__tests__UP040.pyi.snap | 28 +- ...er__rules__pyupgrade__tests__UP041.py.snap | 50 +- ...er__rules__pyupgrade__tests__UP042.py.snap | 29 +- ...er__rules__pyupgrade__tests__UP043.py.snap | 50 +- ...er__rules__pyupgrade__tests__UP045.py.snap | 77 +-- ...__rules__pyupgrade__tests__UP046_0.py.snap | 120 +++-- ...__rules__pyupgrade__tests__UP046_1.py.snap | 8 +- ...er__rules__pyupgrade__tests__UP047.py.snap | 43 +- ...__rules__pyupgrade__tests__UP049_0.py.snap | 35 +- ...__rules__pyupgrade__tests__UP049_1.py.snap | 140 +++--- ...er__rules__pyupgrade__tests__UP050.py.snap | 77 +-- ...sts__add_future_annotation_UP037_0.py.snap | 217 ++++---- ...sts__add_future_annotation_UP037_1.py.snap | 14 +- ...ts__add_future_annotation_UP037_2.pyi.snap | 70 +-- ...timeout_error_alias_not_applied_py310.snap | 29 +- ...rade__tests__datetime_utc_alias_py311.snap | 28 +- ..._annotations_keep_runtime_typing_p310.snap | 28 +- ...tests__future_annotations_pep_585_p37.snap | 8 +- ...sts__future_annotations_pep_585_py310.snap | 28 +- ...tests__future_annotations_pep_604_p37.snap | 7 +- ...sts__future_annotations_pep_604_py310.snap | 14 +- ...yupgrade__tests__unpack_pep_646_py311.snap | 36 +- ...es__refurb__tests__FURB101_FURB101.py.snap | 51 +- ...es__refurb__tests__FURB103_FURB103.py.snap | 66 ++- ...es__refurb__tests__FURB105_FURB105.py.snap | 126 +++-- ...es__refurb__tests__FURB110_FURB110.py.snap | 56 ++- ...es__refurb__tests__FURB113_FURB113.py.snap | 126 +++-- ...es__refurb__tests__FURB116_FURB116.py.snap | 105 ++-- ...es__refurb__tests__FURB118_FURB118.py.snap | 280 ++++++----- ...es__refurb__tests__FURB122_FURB122.py.snap | 140 +++--- ...es__refurb__tests__FURB129_FURB129.py.snap | 126 +++-- ...es__refurb__tests__FURB131_FURB131.py.snap | 70 +-- ...es__refurb__tests__FURB132_FURB132.py.snap | 29 +- ...es__refurb__tests__FURB136_FURB136.py.snap | 63 ++- ...es__refurb__tests__FURB140_FURB140.py.snap | 63 ++- ...es__refurb__tests__FURB142_FURB142.py.snap | 126 +++-- ...es__refurb__tests__FURB145_FURB145.py.snap | 42 +- ...es__refurb__tests__FURB148_FURB148.py.snap | 168 ++++--- ...es__refurb__tests__FURB152_FURB152.py.snap | 105 ++-- ...es__refurb__tests__FURB154_FURB154.py.snap | 84 ++-- ...es__refurb__tests__FURB156_FURB156.py.snap | 98 ++-- ...es__refurb__tests__FURB157_FURB157.py.snap | 189 ++++--- ...es__refurb__tests__FURB161_FURB161.py.snap | 70 +-- ...es__refurb__tests__FURB162_FURB162.py.snap | 77 +-- ...es__refurb__tests__FURB163_FURB163.py.snap | 119 +++-- ...es__refurb__tests__FURB164_FURB164.py.snap | 259 ++++++---- ...es__refurb__tests__FURB166_FURB166.py.snap | 49 +- ...es__refurb__tests__FURB167_FURB167.py.snap | 15 +- ...es__refurb__tests__FURB168_FURB168.py.snap | 77 +-- ...es__refurb__tests__FURB169_FURB169.py.snap | 112 +++-- ...__refurb__tests__FURB171_FURB171_0.py.snap | 91 ++-- ...__refurb__tests__FURB171_FURB171_1.py.snap | 49 +- ...es__refurb__tests__FURB177_FURB177.py.snap | 70 +-- ...es__refurb__tests__FURB180_FURB180.py.snap | 28 +- ...es__refurb__tests__FURB181_FURB181.py.snap | 119 +++-- ...es__refurb__tests__FURB187_FURB187.py.snap | 22 +- ...es__refurb__tests__FURB188_FURB188.py.snap | 112 +++-- ...es__refurb__tests__FURB189_FURB189.py.snap | 35 +- ...es__refurb__tests__FURB192_FURB192.py.snap | 63 ++- ...sts__fstring_number_format_python_311.snap | 105 ++-- ...rb__tests__write_whole_file_python_39.snap | 51 +- ..._ruff__tests__PY39_RUF013_RUF013_0.py.snap | 141 +++--- ..._ruff__tests__PY39_RUF013_RUF013_1.py.snap | 8 +- ..._rules__ruff__tests__RUF005_RUF005.py.snap | 126 +++-- ..._ruff__tests__RUF005_RUF005_slices.py.snap | 28 +- ..._rules__ruff__tests__RUF006_RUF006.py.snap | 40 +- ..._rules__ruff__tests__RUF007_RUF007.py.snap | 70 +-- ..._rules__ruff__tests__RUF008_RUF008.py.snap | 25 +- ...__ruff__tests__RUF008_RUF008_attrs.py.snap | 21 +- ..._rules__ruff__tests__RUF009_RUF009.py.snap | 51 +- ...__ruff__tests__RUF009_RUF009_attrs.py.snap | 60 ++- ...uff__tests__RUF009_RUF009_deferred.py.snap | 10 +- ..._rules__ruff__tests__RUF010_RUF010.py.snap | 147 +++--- ..._rules__ruff__tests__RUF012_RUF012.py.snap | 55 +- ...ules__ruff__tests__RUF013_RUF013_0.py.snap | 141 +++--- ...ules__ruff__tests__RUF013_RUF013_1.py.snap | 8 +- ...ules__ruff__tests__RUF013_RUF013_3.py.snap | 22 +- ...ules__ruff__tests__RUF013_RUF013_4.py.snap | 8 +- ..._rules__ruff__tests__RUF015_RUF015.py.snap | 161 +++--- ..._rules__ruff__tests__RUF016_RUF016.py.snap | 200 +++++--- ...ules__ruff__tests__RUF017_RUF017_0.py.snap | 49 +- ...ules__ruff__tests__RUF017_RUF017_1.py.snap | 8 +- ..._rules__ruff__tests__RUF018_RUF018.py.snap | 10 +- ..._rules__ruff__tests__RUF019_RUF019.py.snap | 42 +- ..._rules__ruff__tests__RUF020_RUF020.py.snap | 91 ++-- ..._rules__ruff__tests__RUF021_RUF021.py.snap | 84 ++-- ..._rules__ruff__tests__RUF022_RUF022.py.snap | 245 +++++---- ..._rules__ruff__tests__RUF023_RUF023.py.snap | 175 ++++--- ..._rules__ruff__tests__RUF024_RUF024.py.snap | 49 +- ..._rules__ruff__tests__RUF026_RUF026.py.snap | 98 ++-- ...ules__ruff__tests__RUF027_RUF027_0.py.snap | 112 +++-- ..._rules__ruff__tests__RUF028_RUF028.py.snap | 78 +-- ..._rules__ruff__tests__RUF029_RUF029.py.snap | 31 +- ..._rules__ruff__tests__RUF030_RUF030.py.snap | 133 ++--- ..._rules__ruff__tests__RUF031_RUF031.py.snap | 63 ++- ..._rules__ruff__tests__RUF032_RUF032.py.snap | 77 +-- ..._rules__ruff__tests__RUF033_RUF033.py.snap | 147 +++--- ..._rules__ruff__tests__RUF034_RUF034.py.snap | 15 +- ..._rules__ruff__tests__RUF036_RUF036.py.snap | 41 +- ...rules__ruff__tests__RUF036_RUF036.pyi.snap | 40 +- ..._rules__ruff__tests__RUF037_RUF037.py.snap | 133 ++--- ..._rules__ruff__tests__RUF038_RUF038.py.snap | 42 +- ...rules__ruff__tests__RUF038_RUF038.pyi.snap | 42 +- ..._rules__ruff__tests__RUF040_RUF040.py.snap | 5 +- ..._rules__ruff__tests__RUF041_RUF041.py.snap | 77 +-- ...rules__ruff__tests__RUF041_RUF041.pyi.snap | 77 +-- ..._rules__ruff__tests__RUF046_RUF046.py.snap | 413 ++++++++------- ...les__ruff__tests__RUF046_RUF046_CR.py.snap | 10 +- ...les__ruff__tests__RUF046_RUF046_LF.py.snap | 7 +- ...es__ruff__tests__RUF047_RUF047_for.py.snap | 14 +- ...les__ruff__tests__RUF047_RUF047_if.py.snap | 56 ++- ...es__ruff__tests__RUF047_RUF047_try.py.snap | 14 +- ...__ruff__tests__RUF047_RUF047_while.py.snap | 14 +- ..._rules__ruff__tests__RUF048_RUF048.py.snap | 15 +- ...ules__ruff__tests__RUF048_RUF048_1.py.snap | 30 +- ..._rules__ruff__tests__RUF049_RUF049.py.snap | 49 +- ..._rules__ruff__tests__RUF051_RUF051.py.snap | 189 ++++--- ..._rules__ruff__tests__RUF052_RUF052.py.snap | 133 ++--- ..._rules__ruff__tests__RUF053_RUF053.py.snap | 238 +++++---- ..._rules__ruff__tests__RUF056_RUF056.py.snap | 203 ++++---- ..._rules__ruff__tests__RUF057_RUF057.py.snap | 91 ++-- ...ules__ruff__tests__RUF058_RUF058_0.py.snap | 49 +- ...ules__ruff__tests__RUF058_RUF058_1.py.snap | 7 +- ...ules__ruff__tests__RUF059_RUF059_0.py.snap | 77 +-- ...ules__ruff__tests__RUF059_RUF059_1.py.snap | 49 +- ...ules__ruff__tests__RUF059_RUF059_2.py.snap | 84 ++-- ...ules__ruff__tests__RUF059_RUF059_3.py.snap | 14 +- ..._rules__ruff__tests__RUF060_RUF060.py.snap | 115 +++-- ...sts__RUF061_RUF061_deprecated_call.py.snap | 21 +- ..._ruff__tests__RUF061_RUF061_raises.py.snap | 42 +- ...__ruff__tests__RUF061_RUF061_warns.py.snap | 21 +- ..._rules__ruff__tests__RUF064_RUF064.py.snap | 133 ++--- ...ules__ruff__tests__RUF101_RUF101_0.py.snap | 50 +- ...ules__ruff__tests__RUF101_RUF101_1.py.snap | 7 +- ..._rules__ruff__tests__RUF102_RUF102.py.snap | 77 +-- ...er__rules__ruff__tests__RUF200_bleach.snap | 6 +- ...s__ruff__tests__RUF200_invalid_author.snap | 6 +- ...__ruff__tests__RUF200_various_invalid.snap | 6 +- ...ess_annotations_from_class_dict_py310.snap | 20 +- ...ess_annotations_from_class_dict_py314.snap | 20 +- ...lass_dict_py39_with_typing_extensions.snap | 20 +- ..._tests__add_future_import_RUF013_0.py.snap | 140 +++--- ..._tests__add_future_import_RUF013_1.py.snap | 7 +- ..._tests__add_future_import_RUF013_3.py.snap | 21 +- ..._tests__add_future_import_RUF013_4.py.snap | 7 +- ...nter__rules__ruff__tests__confusables.snap | 100 ++-- ...var_regexp_preset__RUF052_RUF052.py_1.snap | 133 ++--- ...var_regexp_preset__RUF052_RUF052.py_2.snap | 138 ++--- ...sts__invalid_rule_code_external_rules.snap | 63 ++- ...remove_parentheses_starred_expr_py310.snap | 57 ++- ...ruff_linter__rules__ruff__tests__noqa.snap | 12 +- ...sts__prefer_parentheses_getitem_tuple.snap | 42 +- ...uff__tests__preview__RUF039_RUF039.py.snap | 196 ++++---- ...sts__preview__RUF039_RUF039_concat.py.snap | 259 ++++++---- ...uff__tests__preview__RUF043_RUF043.py.snap | 218 ++++---- ...uff__tests__preview__RUF045_RUF045.py.snap | 21 +- ...uff__tests__preview__RUF054_RUF054.py.snap | 28 +- ...f__tests__preview__RUF055_RUF055_0.py.snap | 101 ++-- ...f__tests__preview__RUF055_RUF055_1.py.snap | 14 +- ...f__tests__preview__RUF055_RUF055_2.py.snap | 57 ++- ...f__tests__preview__RUF055_RUF055_3.py.snap | 28 +- ...RUF039_RUF039_py_version_sensitive.py.snap | 7 +- ...RUF039_RUF039_py_version_sensitive.py.snap | 7 +- ...les__ruff__tests__preview_confusables.snap | 105 ++-- ...uff__tests__py314__RUF058_RUF058_2.py.snap | 21 +- ..._linter__rules__ruff__tests__ruf100_0.snap | 166 +++--- ...__rules__ruff__tests__ruf100_0_prefix.snap | 159 +++--- ..._linter__rules__ruff__tests__ruf100_1.snap | 57 ++- ..._linter__rules__ruff__tests__ruf100_2.snap | 7 +- ..._linter__rules__ruff__tests__ruf100_3.snap | 173 ++++--- ..._linter__rules__ruff__tests__ruf100_5.snap | 35 +- ...__rules__ruff__tests__ruff_noqa_codes.snap | 8 +- ...tests__ruff_noqa_filedirective_unused.snap | 7 +- ...oqa_filedirective_unused_last_of_many.snap | 14 +- ...rules__ruff__tests__ruff_noqa_invalid.snap | 15 +- ..._error-instead-of-exception_TRY400.py.snap | 77 +-- ...__tests__raise-vanilla-args_TRY003.py.snap | 21 +- ..._tests__raise-vanilla-class_TRY002.py.snap | 20 +- ...ps__tests__raise-within-try_TRY301.py.snap | 30 +- ...s__tests__try-consider-else_TRY300.py.snap | 6 +- ...pe-check-without-type-error_TRY004.py.snap | 180 ++++--- ...__tests__useless-try-except_TRY203.py.snap | 60 ++- ..._tests__verbose-log-message_TRY401.py.snap | 110 ++-- ...atops__tests__verbose-raise_TRY201.py.snap | 22 +- ...linter__tests__async_comprehension.py.snap | 15 +- ...n_in_sync_comprehension_notebook_3.10.snap | 3 +- ...ests__await_outside_async_function.py.snap | 10 +- ...__linter__tests__await_scope_notebook.snap | 5 +- ...ensions_pyi019_adds_typing_extensions.snap | 7 +- ..._adds_typing_with_extensions_disabled.snap | 7 +- ...ds_typing_without_extensions_disabled.snap | 7 +- ...linter__linter__tests__import_sorting.snap | 28 +- ...er__linter__tests__ipy_escape_command.snap | 14 +- ..._linter__tests__late_future_import.py.snap | 5 +- ...ts__load_before_global_declaration.py.snap | 10 +- ...er__tests__return_outside_function.py.snap | 20 +- ...ction_async_in_sync_error_on_310_3.10.snap | 3 +- ..._duplicate_match_class_attribute_3.10.snap | 3 +- ...cateMatchKey_duplicate_match_key_3.10.snap | 3 +- ...peParameter_duplicate_type_param_3.12.snap | 3 +- ...sion_walrus_in_return_annotation_3.12.snap | 3 +- ...ression_yield_from_in_base_class_3.12.snap | 3 +- ...d_expression_yield_in_type_alias_3.12.snap | 3 +- ...d_expression_yield_in_type_param_3.12.snap | 3 +- ...pression_invalid_star_expression_3.10.snap | 3 +- ...sion_invalid_star_expression_for_3.10.snap | 3 +- ...on_invalid_star_expression_yield_3.10.snap | 3 +- ...irrefutable_case_pattern_capture_3.10.snap | 3 +- ...rrefutable_case_pattern_wildcard_3.10.snap | 3 +- ...ignment_multiple_case_assignment_3.10.snap | 3 +- ...onVariable_rebound_comprehension_3.10.snap | 3 +- ...gnment_single_starred_assignment_3.10.snap | 3 +- ...rror_WriteToDebug_write_to_debug_3.10.snap | 3 +- ..._write_to_debug_class_type_param_3.12.snap | 3 +- ...write_to_debug_in_function_param_3.10.snap | 3 +- ...linter__linter__tests__undefined_name.snap | 5 +- ...inter__linter__tests__unused_variable.snap | 28 +- ...er__linter__tests__vscode_language_id.snap | 7 +- ...linter__linter__tests__yield_scope.py.snap | 65 ++- 1684 files changed, 46025 insertions(+), 33951 deletions(-) diff --git a/crates/ruff/tests/integration_test.rs b/crates/ruff/tests/integration_test.rs index d43ae77b60..f9122e3b5e 100644 --- a/crates/ruff/tests/integration_test.rs +++ b/crates/ruff/tests/integration_test.rs @@ -115,12 +115,13 @@ fn stdin_error() { success: false exit_code: 1 ----- stdout ----- - -:1:8: F401 [*] `os` imported but unused + F401 [*] `os` imported but unused + --> -:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` + help: Remove unused import: `os` Found 1 error. [*] 1 fixable with the `--fix` option. @@ -139,12 +140,13 @@ fn stdin_filename() { success: false exit_code: 1 ----- stdout ----- - F401.py:1:8: F401 [*] `os` imported but unused + F401 [*] `os` imported but unused + --> F401.py:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` + help: Remove unused import: `os` Found 1 error. [*] 1 fixable with the `--fix` option. @@ -174,19 +176,21 @@ import bar # unused import success: false exit_code: 1 ----- stdout ----- - bar.py:2:8: F401 [*] `bar` imported but unused + F401 [*] `bar` imported but unused + --> bar.py:2:8 | 2 | import bar # unused import - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `bar` + help: Remove unused import: `bar` - foo.py:2:8: F401 [*] `foo` imported but unused + F401 [*] `foo` imported but unused + --> foo.py:2:8 | 2 | import foo # unused import - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `foo` + help: Remove unused import: `foo` Found 2 errors. [*] 2 fixable with the `--fix` option. @@ -208,12 +212,13 @@ fn check_warn_stdin_filename_with_files() { success: false exit_code: 1 ----- stdout ----- - F401.py:1:8: F401 [*] `os` imported but unused + F401 [*] `os` imported but unused + --> F401.py:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` + help: Remove unused import: `os` Found 1 error. [*] 1 fixable with the `--fix` option. @@ -234,12 +239,13 @@ fn stdin_source_type_py() { success: false exit_code: 1 ----- stdout ----- - TCH.py:1:8: F401 [*] `os` imported but unused + F401 [*] `os` imported but unused + --> TCH.py:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` + help: Remove unused import: `os` Found 1 error. [*] 1 fixable with the `--fix` option. @@ -471,10 +477,11 @@ fn stdin_fix_jupyter() { "nbformat_minor": 5 } ----- stderr ----- - Jupyter.ipynb:cell 3:1:7: F821 Undefined name `x` + F821 Undefined name `x` + --> Jupyter.ipynb:cell 3:1:7 | 1 | print(x) - | ^ F821 + | ^ | Found 3 errors (2 fixed, 1 remaining). @@ -569,19 +576,21 @@ fn stdin_override_parser_ipynb() { success: false exit_code: 1 ----- stdout ----- - Jupyter.py:cell 1:1:8: F401 [*] `os` imported but unused + F401 [*] `os` imported but unused + --> Jupyter.py:cell 1:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` + help: Remove unused import: `os` - Jupyter.py:cell 3:1:8: F401 [*] `sys` imported but unused + F401 [*] `sys` imported but unused + --> Jupyter.py:cell 3:1:8 | 1 | import sys - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `sys` + help: Remove unused import: `sys` Found 2 errors. [*] 2 fixable with the `--fix` option. @@ -605,12 +614,13 @@ fn stdin_override_parser_py() { success: false exit_code: 1 ----- stdout ----- - F401.ipynb:1:8: F401 [*] `os` imported but unused + F401 [*] `os` imported but unused + --> F401.ipynb:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` + help: Remove unused import: `os` Found 1 error. [*] 1 fixable with the `--fix` option. @@ -633,12 +643,13 @@ fn stdin_fix_when_not_fixable_should_still_print_contents() { print(sys.version) ----- stderr ----- - -:3:4: F634 If test is a tuple, which is always `True` + F634 If test is a tuple, which is always `True` + --> -:3:4 | 1 | import sys 2 | 3 | if (1, 2): - | ^^^^^^ F634 + | ^^^^^^ 4 | print(sys.version) | @@ -798,7 +809,8 @@ fn stdin_parse_error() { success: false exit_code: 1 ----- stdout ----- - -:1:16: invalid-syntax: Expected one or more symbol names after import + invalid-syntax: Expected one or more symbol names after import + --> -:1:16 | 1 | from foo import | ^ @@ -818,14 +830,16 @@ fn stdin_multiple_parse_error() { success: false exit_code: 1 ----- stdout ----- - -:1:16: invalid-syntax: Expected one or more symbol names after import + invalid-syntax: Expected one or more symbol names after import + --> -:1:16 | 1 | from foo import | ^ 2 | bar = | - -:2:6: invalid-syntax: Expected an expression + invalid-syntax: Expected an expression + --> -:2:6 | 1 | from foo import 2 | bar = @@ -847,7 +861,8 @@ fn parse_error_not_included() { success: false exit_code: 1 ----- stdout ----- - -:1:6: invalid-syntax: Expected an expression + invalid-syntax: Expected an expression + --> -:1:6 | 1 | foo = | ^ @@ -867,10 +882,11 @@ fn full_output_preview() { success: false exit_code: 1 ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` + E741 Ambiguous variable name: `l` + --> -:1:1 | 1 | l = 1 - | ^ E741 + | ^ | Found 1 error. @@ -895,10 +911,11 @@ preview = true success: false exit_code: 1 ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` + E741 Ambiguous variable name: `l` + --> -:1:1 | 1 | l = 1 - | ^ E741 + | ^ | Found 1 error. @@ -916,10 +933,11 @@ fn full_output_format() { success: false exit_code: 1 ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` + E741 Ambiguous variable name: `l` + --> -:1:1 | 1 | l = 1 - | ^ E741 + | ^ | Found 1 error. @@ -1406,7 +1424,9 @@ fn redirect_direct() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF950 Hey this is a test rule that was redirected from another. + RUF950 Hey this is a test rule that was redirected from another. + --> -:1:1 + Found 1 error. ----- stderr ----- @@ -1438,7 +1458,9 @@ fn redirect_prefix() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF950 Hey this is a test rule that was redirected from another. + RUF950 Hey this is a test rule that was redirected from another. + --> -:1:1 + Found 1 error. ----- stderr ----- @@ -1455,7 +1477,9 @@ fn deprecated_direct() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF920 Hey this is a deprecated test rule. + RUF920 Hey this is a deprecated test rule. + --> -:1:1 + Found 1 error. ----- stderr ----- @@ -1472,8 +1496,12 @@ fn deprecated_multiple_direct() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF920 Hey this is a deprecated test rule. - -:1:1: RUF921 Hey this is another deprecated test rule. + RUF920 Hey this is a deprecated test rule. + --> -:1:1 + + RUF921 Hey this is another deprecated test rule. + --> -:1:1 + Found 2 errors. ----- stderr ----- @@ -1491,8 +1519,12 @@ fn deprecated_indirect() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF920 Hey this is a deprecated test rule. - -:1:1: RUF921 Hey this is another deprecated test rule. + RUF920 Hey this is a deprecated test rule. + --> -:1:1 + + RUF921 Hey this is another deprecated test rule. + --> -:1:1 + Found 2 errors. ----- stderr ----- @@ -1638,22 +1670,23 @@ fn check_input_from_argfile() -> Result<()> { (file_a_path.display().to_string().as_str(), "/path/to/a.py"), ]}, { assert_cmd_snapshot!(cmd - .pass_stdin(""), @r###" + .pass_stdin(""), @r" success: false exit_code: 1 ----- stdout ----- - /path/to/a.py:1:8: F401 [*] `os` imported but unused + F401 [*] `os` imported but unused + --> /path/to/a.py:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` + help: Remove unused import: `os` Found 1 error. [*] 1 fixable with the `--fix` option. ----- stderr ----- - "###); + "); }); Ok(()) @@ -1669,8 +1702,12 @@ fn check_hints_hidden_unsafe_fixes() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. - -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + RUF901 [*] Hey this is a stable test rule with a safe fix. + --> -:1:1 + + RUF902 Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 2 errors. [*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option). @@ -1687,7 +1724,9 @@ fn check_hints_hidden_unsafe_fixes_with_no_safe_fixes() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + RUF902 Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 1 error. No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). @@ -1705,8 +1744,12 @@ fn check_no_hint_for_hidden_unsafe_fixes_when_disabled() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. - -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + RUF901 [*] Hey this is a stable test rule with a safe fix. + --> -:1:1 + + RUF902 Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 2 errors. [*] 1 fixable with the --fix option. @@ -1725,7 +1768,9 @@ fn check_no_hint_for_hidden_unsafe_fixes_with_no_safe_fixes_when_disabled() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + RUF902 Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 1 error. ----- stderr ----- @@ -1742,8 +1787,12 @@ fn check_shows_unsafe_fixes_with_opt_in() { success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. - -:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix. + RUF901 [*] Hey this is a stable test rule with a safe fix. + --> -:1:1 + + RUF902 [*] Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 2 errors. [*] 2 fixable with the --fix option. @@ -1764,7 +1813,9 @@ fn fix_applies_safe_fixes_by_default() { # fix from stable-test-rule-safe-fix ----- stderr ----- - -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + RUF902 Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 2 errors (1 fixed, 1 remaining). No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). "); @@ -1801,7 +1852,9 @@ fn fix_does_not_apply_display_only_fixes() { ----- stdout ----- def add_to_list(item, some_list=[]): ... ----- stderr ----- - -:1:1: RUF903 Hey this is a stable test rule with a display only fix. + RUF903 Hey this is a stable test rule with a display only fix. + --> -:1:1 + Found 1 error. "); } @@ -1819,7 +1872,9 @@ fn fix_does_not_apply_display_only_fixes_with_unsafe_fixes_enabled() { ----- stdout ----- def add_to_list(item, some_list=[]): ... ----- stderr ----- - -:1:1: RUF903 Hey this is a stable test rule with a display only fix. + RUF903 Hey this is a stable test rule with a display only fix. + --> -:1:1 + Found 1 error. "); } @@ -1836,7 +1891,9 @@ fn fix_only_unsafe_fixes_available() { ----- stdout ----- ----- stderr ----- - -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + RUF902 Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 1 error. No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). "); @@ -1972,8 +2029,12 @@ extend-unsafe-fixes = ["RUF901"] success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF901 Hey this is a stable test rule with a safe fix. - -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + RUF901 Hey this is a stable test rule with a safe fix. + --> -:1:1 + + RUF902 Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 2 errors. No fixes available (2 hidden fixes can be enabled with the `--unsafe-fixes` option). @@ -2004,8 +2065,12 @@ extend-safe-fixes = ["RUF902"] success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. - -:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix. + RUF901 [*] Hey this is a stable test rule with a safe fix. + --> -:1:1 + + RUF902 [*] Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 2 errors. [*] 2 fixable with the `--fix` option. @@ -2038,8 +2103,12 @@ extend-safe-fixes = ["RUF902"] success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix. - -:1:1: RUF902 Hey this is a stable test rule with an unsafe fix. + RUF901 [*] Hey this is a stable test rule with a safe fix. + --> -:1:1 + + RUF902 Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + Found 2 errors. [*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option). @@ -2074,13 +2143,27 @@ extend-safe-fixes = ["RUF9"] success: false exit_code: 1 ----- stdout ----- - -:1:1: RUF900 Hey this is a stable test rule. - -:1:1: RUF901 Hey this is a stable test rule with a safe fix. - -:1:1: RUF902 [*] Hey this is a stable test rule with an unsafe fix. - -:1:1: RUF903 Hey this is a stable test rule with a display only fix. - -:1:1: RUF920 Hey this is a deprecated test rule. - -:1:1: RUF921 Hey this is another deprecated test rule. - -:1:1: RUF950 Hey this is a test rule that was redirected from another. + RUF900 Hey this is a stable test rule. + --> -:1:1 + + RUF901 Hey this is a stable test rule with a safe fix. + --> -:1:1 + + RUF902 [*] Hey this is a stable test rule with an unsafe fix. + --> -:1:1 + + RUF903 Hey this is a stable test rule with a display only fix. + --> -:1:1 + + RUF920 Hey this is a deprecated test rule. + --> -:1:1 + + RUF921 Hey this is another deprecated test rule. + --> -:1:1 + + RUF950 Hey this is a test rule that was redirected from another. + --> -:1:1 + Found 7 errors. [*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option). @@ -2141,10 +2224,11 @@ def log(x, base) -> float: success: false exit_code: 1 ----- stdout ----- - -:2:5: D417 Missing argument description in the docstring for `log`: `base` + D417 Missing argument description in the docstring for `log`: `base` + --> -:2:5 | 2 | def log(x, base) -> float: - | ^^^ D417 + | ^^^ 3 | """Calculate natural log of a value | @@ -2177,14 +2261,15 @@ select = ["RUF017"] success: false exit_code: 1 ----- stdout ----- - -:3:1: RUF017 Avoid quadratic list summation + RUF017 Avoid quadratic list summation + --> -:3:1 | 1 | x = [1, 2, 3] 2 | y = [4, 5, 6] 3 | sum([x, y], []) - | ^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^ | - = help: Replace with `functools.reduce` + help: Replace with `functools.reduce` Found 1 error. No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option). @@ -2217,14 +2302,15 @@ unfixable = ["RUF"] success: false exit_code: 1 ----- stdout ----- - -:3:1: RUF017 Avoid quadratic list summation + RUF017 Avoid quadratic list summation + --> -:3:1 | 1 | x = [1, 2, 3] 2 | y = [4, 5, 6] 3 | sum([x, y], []) - | ^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^ | - = help: Replace with `functools.reduce` + help: Replace with `functools.reduce` Found 1 error. @@ -2246,10 +2332,11 @@ fn pyproject_toml_stdin_syntax_error() { success: false exit_code: 1 ----- stdout ----- - pyproject.toml:1:9: RUF200 Failed to parse pyproject.toml: unclosed table, expected `]` + RUF200 Failed to parse pyproject.toml: unclosed table, expected `]` + --> pyproject.toml:1:9 | 1 | [project - | ^ RUF200 + | ^ | Found 1 error. @@ -2271,11 +2358,12 @@ fn pyproject_toml_stdin_schema_error() { success: false exit_code: 1 ----- stdout ----- - pyproject.toml:2:8: RUF200 Failed to parse pyproject.toml: invalid type: integer `1`, expected a string + RUF200 Failed to parse pyproject.toml: invalid type: integer `1`, expected a string + --> pyproject.toml:2:8 | 1 | [project] 2 | name = 1 - | ^ RUF200 + | ^ | Found 1 error. @@ -2363,11 +2451,12 @@ fn pyproject_toml_stdin_schema_error_fix() { [project] name = 1 ----- stderr ----- - pyproject.toml:2:8: RUF200 Failed to parse pyproject.toml: invalid type: integer `1`, expected a string + RUF200 Failed to parse pyproject.toml: invalid type: integer `1`, expected a string + --> pyproject.toml:2:8 | 1 | [project] 2 | name = 1 - | ^ RUF200 + | ^ | Found 1 error. diff --git a/crates/ruff/tests/snapshots/lint__output_format_full.snap b/crates/ruff/tests/snapshots/lint__output_format_full.snap index 81dd0f1263..d47237df55 100644 --- a/crates/ruff/tests/snapshots/lint__output_format_full.snap +++ b/crates/ruff/tests/snapshots/lint__output_format_full.snap @@ -16,25 +16,28 @@ info: success: false exit_code: 1 ----- stdout ----- -input.py:1:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> input.py:1:8 | 1 | import os # F401 - | ^^ F401 + | ^^ 2 | x = y # F821 3 | match 42: # invalid-syntax | - = help: Remove unused import: `os` +help: Remove unused import: `os` -input.py:2:5: F821 Undefined name `y` +F821 Undefined name `y` + --> input.py:2:5 | 1 | import os # F401 2 | x = y # F821 - | ^ F821 + | ^ 3 | match 42: # invalid-syntax 4 | case _: ... | -input.py:3:1: invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10) +invalid-syntax: Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10) + --> input.py:3:1 | 1 | import os # F401 2 | x = y # F821 diff --git a/crates/ruff_annotate_snippets/src/renderer/display_list.rs b/crates/ruff_annotate_snippets/src/renderer/display_list.rs index 03bcf66296..2728cfba7b 100644 --- a/crates/ruff_annotate_snippets/src/renderer/display_list.rs +++ b/crates/ruff_annotate_snippets/src/renderer/display_list.rs @@ -1201,11 +1201,16 @@ fn format_snippet<'m>( let is_file_level = snippet.annotations.iter().any(|ann| ann.is_file_level); if is_file_level { - assert!( - snippet.source.is_empty(), - "Non-empty file-level snippet that won't be rendered: {:?}", - snippet.source - ); + // TODO(brent) enable this assertion again once we set `is_file_level` for individual rules. + // It's causing too many false positives currently when the default is to make any + // annotation with a default range file-level. See + // https://github.com/astral-sh/ruff/issues/19688. + // + // assert!( + // snippet.source.is_empty(), + // "Non-empty file-level snippet that won't be rendered: {:?}", + // snippet.source + // ); let header = format_header(origin, main_range, &[], is_first, snippet.cell_index); return DisplaySet { display_lines: header.map_or_else(Vec::new, |header| vec![header]), diff --git a/crates/ruff_db/src/diagnostic/render.rs b/crates/ruff_db/src/diagnostic/render.rs index 8b8436cc49..43c676856d 100644 --- a/crates/ruff_db/src/diagnostic/render.rs +++ b/crates/ruff_db/src/diagnostic/render.rs @@ -2,15 +2,15 @@ use std::borrow::Cow; use std::collections::BTreeMap; use std::path::Path; +use full::FullRenderer; use ruff_annotate_snippets::{ Annotation as AnnotateAnnotation, Level as AnnotateLevel, Message as AnnotateMessage, - Renderer as AnnotateRenderer, Snippet as AnnotateSnippet, + Snippet as AnnotateSnippet, }; use ruff_notebook::{Notebook, NotebookIndex}; use ruff_source_file::{LineIndex, OneIndexed, SourceCode}; use ruff_text_size::{TextLen, TextRange, TextSize}; -use crate::diagnostic::stylesheet::DiagnosticStylesheet; use crate::{ Db, files::File, @@ -111,37 +111,7 @@ impl std::fmt::Display for DisplayDiagnostics<'_> { ConciseRenderer::new(self.resolver, self.config).render(f, self.diagnostics)?; } DiagnosticFormat::Full => { - let stylesheet = if self.config.color { - DiagnosticStylesheet::styled() - } else { - DiagnosticStylesheet::plain() - }; - - let mut renderer = if self.config.color { - AnnotateRenderer::styled() - } else { - AnnotateRenderer::plain() - } - .cut_indicator("…"); - - renderer = renderer - .error(stylesheet.error) - .warning(stylesheet.warning) - .info(stylesheet.info) - .note(stylesheet.note) - .help(stylesheet.help) - .line_no(stylesheet.line_no) - .emphasis(stylesheet.emphasis) - .none(stylesheet.none); - - for diag in self.diagnostics { - let resolved = Resolved::new(self.resolver, diag, self.config); - let renderable = resolved.to_renderable(self.config.context); - for diag in renderable.diagnostics.iter() { - writeln!(f, "{}", renderer.render(diag.to_annotate()))?; - } - writeln!(f)?; - } + FullRenderer::new(self.resolver, self.config).render(f, self.diagnostics)?; } DiagnosticFormat::Azure => { AzureRenderer::new(self.resolver).render(f, self.diagnostics)?; @@ -242,7 +212,12 @@ impl<'a> ResolvedDiagnostic<'a> { .annotations .iter() .filter_map(|ann| { - let path = ann.span.file.path(resolver); + let path = ann + .span + .file + .relative_path(resolver) + .to_str() + .unwrap_or_else(|| ann.span.file.path(resolver)); let diagnostic_source = ann.span.file.diagnostic_source(resolver); ResolvedAnnotation::new(path, &diagnostic_source, ann, resolver) }) diff --git a/crates/ruff_db/src/diagnostic/render/full.rs b/crates/ruff_db/src/diagnostic/render/full.rs index 5358b0ebb3..300e370705 100644 --- a/crates/ruff_db/src/diagnostic/render/full.rs +++ b/crates/ruff_db/src/diagnostic/render/full.rs @@ -1,3 +1,59 @@ +use ruff_annotate_snippets::Renderer as AnnotateRenderer; + +use crate::diagnostic::render::{FileResolver, Resolved}; +use crate::diagnostic::{Diagnostic, DisplayDiagnosticConfig, stylesheet::DiagnosticStylesheet}; + +pub(super) struct FullRenderer<'a> { + resolver: &'a dyn FileResolver, + config: &'a DisplayDiagnosticConfig, +} + +impl<'a> FullRenderer<'a> { + pub(super) fn new(resolver: &'a dyn FileResolver, config: &'a DisplayDiagnosticConfig) -> Self { + Self { resolver, config } + } + + pub(super) fn render( + &self, + f: &mut std::fmt::Formatter, + diagnostics: &[Diagnostic], + ) -> std::fmt::Result { + let stylesheet = if self.config.color { + DiagnosticStylesheet::styled() + } else { + DiagnosticStylesheet::plain() + }; + + let mut renderer = if self.config.color { + AnnotateRenderer::styled() + } else { + AnnotateRenderer::plain() + } + .cut_indicator("…"); + + renderer = renderer + .error(stylesheet.error) + .warning(stylesheet.warning) + .info(stylesheet.info) + .note(stylesheet.note) + .help(stylesheet.help) + .line_no(stylesheet.line_no) + .emphasis(stylesheet.emphasis) + .none(stylesheet.none); + + for diag in diagnostics { + let resolved = Resolved::new(self.resolver, diag, self.config); + let renderable = resolved.to_renderable(self.config.context); + for diag in renderable.diagnostics.iter() { + writeln!(f, "{}", renderer.render(diag.to_annotate()))?; + } + writeln!(f)?; + } + + Ok(()) + } +} + #[cfg(test)] mod tests { use ruff_diagnostics::Applicability; diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__default.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__default.snap index f3ff7977ad..480dd582a7 100644 --- a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__default.snap +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__default.snap @@ -1,28 +1,30 @@ --- source: crates/ruff_linter/src/message/text.rs expression: content -snapshot_kind: text --- -fib.py:1:8: F401 `os` imported but unused +F401 `os` imported but unused + --> fib.py:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` +help: Remove unused import: `os` -fib.py:6:5: F841 Local variable `x` is assigned to but never used +F841 Local variable `x` is assigned to but never used + --> fib.py:6:5 | 4 | def fibonacci(n): 5 | """Compute the nth number in the Fibonacci sequence.""" 6 | x = 1 - | ^ F841 + | ^ 7 | if n == 0: 8 | return 0 | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` -undef.py:1:4: F821 Undefined name `a` +F821 Undefined name `a` + --> undef.py:1:4 | 1 | if a == 1: pass - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status.snap index f3ff7977ad..480dd582a7 100644 --- a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status.snap +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status.snap @@ -1,28 +1,30 @@ --- source: crates/ruff_linter/src/message/text.rs expression: content -snapshot_kind: text --- -fib.py:1:8: F401 `os` imported but unused +F401 `os` imported but unused + --> fib.py:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` +help: Remove unused import: `os` -fib.py:6:5: F841 Local variable `x` is assigned to but never used +F841 Local variable `x` is assigned to but never used + --> fib.py:6:5 | 4 | def fibonacci(n): 5 | """Compute the nth number in the Fibonacci sequence.""" 6 | x = 1 - | ^ F841 + | ^ 7 | if n == 0: 8 | return 0 | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` -undef.py:1:4: F821 Undefined name `a` +F821 Undefined name `a` + --> undef.py:1:4 | 1 | if a == 1: pass - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status_unsafe.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status_unsafe.snap index 9d5ac7b6d6..adee375b6c 100644 --- a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status_unsafe.snap +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status_unsafe.snap @@ -1,28 +1,30 @@ --- source: crates/ruff_linter/src/message/text.rs expression: content -snapshot_kind: text --- -fib.py:1:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> fib.py:1:8 | 1 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` +help: Remove unused import: `os` -fib.py:6:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> fib.py:6:5 | 4 | def fibonacci(n): 5 | """Compute the nth number in the Fibonacci sequence.""" 6 | x = 1 - | ^ F841 + | ^ 7 | if n == 0: 8 | return 0 | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` -undef.py:1:4: F821 Undefined name `a` +F821 Undefined name `a` + --> undef.py:1:4 | 1 | if a == 1: pass - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__notebook_output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__notebook_output.snap index 3d8a6d9c4b..969d44dc7e 100644 --- a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__notebook_output.snap +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__notebook_output.snap @@ -2,29 +2,32 @@ source: crates/ruff_linter/src/message/text.rs expression: content --- -notebook.ipynb:cell 1:2:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> notebook.ipynb:cell 1:2:8 | 1 | # cell 1 2 | import os - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` +help: Remove unused import: `os` -notebook.ipynb:cell 2:2:8: F401 [*] `math` imported but unused +F401 [*] `math` imported but unused + --> notebook.ipynb:cell 2:2:8 | 1 | # cell 2 2 | import math - | ^^^^ F401 + | ^^^^ 3 | 4 | print('hello world') | - = help: Remove unused import: `math` +help: Remove unused import: `math` -notebook.ipynb:cell 3:4:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> notebook.ipynb:cell 3:4:5 | 2 | def foo(): 3 | print() 4 | x = 1 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__syntax_errors.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__syntax_errors.snap index 7dfac7710a..af19a135dd 100644 --- a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__syntax_errors.snap +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__syntax_errors.snap @@ -2,16 +2,17 @@ source: crates/ruff_linter/src/message/text.rs expression: content --- -syntax_errors.py:1:15: invalid-syntax: Expected one or more symbol names after import +invalid-syntax: Expected one or more symbol names after import + --> syntax_errors.py:1:15 | 1 | from os import | ^ 2 | 3 | if call(foo -4 | def bar(): | -syntax_errors.py:3:12: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> syntax_errors.py:3:12 | 1 | from os import 2 | diff --git a/crates/ruff_linter/src/message/text.rs b/crates/ruff_linter/src/message/text.rs index 483f19b4ee..b20e4f32b0 100644 --- a/crates/ruff_linter/src/message/text.rs +++ b/crates/ruff_linter/src/message/text.rs @@ -2,7 +2,6 @@ use std::borrow::Cow; use std::fmt::{Display, Formatter}; use std::io::Write; -use bitflags::bitflags; use colored::Colorize; use ruff_annotate_snippets::{Level, Renderer, Snippet}; @@ -17,25 +16,18 @@ use crate::message::diff::Diff; use crate::message::{Emitter, EmitterContext}; use crate::settings::types::UnsafeFixes; -bitflags! { - #[derive(Default)] - struct EmitterFlags: u8 { - /// Whether to show the diff of a fix, for diagnostics that have a fix. - const SHOW_FIX_DIFF = 1 << 1; - /// Whether to show the source code of a diagnostic. - const SHOW_SOURCE = 1 << 2; - } -} - pub struct TextEmitter { - flags: EmitterFlags, + /// Whether to show the diff of a fix, for diagnostics that have a fix. + /// + /// Note that this is not currently exposed in the CLI (#7352) and is only used in tests. + show_fix_diff: bool, config: DisplayDiagnosticConfig, } impl Default for TextEmitter { fn default() -> Self { Self { - flags: EmitterFlags::default(), + show_fix_diff: false, config: DisplayDiagnosticConfig::default() .format(DiagnosticFormat::Concise) .hide_severity(true) @@ -53,13 +45,17 @@ impl TextEmitter { #[must_use] pub fn with_show_fix_diff(mut self, show_fix_diff: bool) -> Self { - self.flags.set(EmitterFlags::SHOW_FIX_DIFF, show_fix_diff); + self.show_fix_diff = show_fix_diff; self } #[must_use] pub fn with_show_source(mut self, show_source: bool) -> Self { - self.flags.set(EmitterFlags::SHOW_SOURCE, show_source); + self.config = self.config.format(if show_source { + DiagnosticFormat::Full + } else { + DiagnosticFormat::Concise + }); self } @@ -94,23 +90,7 @@ impl Emitter for TextEmitter { for message in diagnostics { write!(writer, "{}", message.display(context, &self.config))?; - let filename = message.expect_ruff_filename(); - let notebook_index = context.notebook_index(&filename); - if self.flags.intersects(EmitterFlags::SHOW_SOURCE) { - // The `0..0` range is used to highlight file-level diagnostics. - if message.expect_range() != TextRange::default() { - writeln!( - writer, - "{}", - MessageCodeFrame { - message, - notebook_index - } - )?; - } - } - - if self.flags.intersects(EmitterFlags::SHOW_FIX_DIFF) { + if self.show_fix_diff { if let Some(diff) = Diff::from_message(message) { writeln!(writer, "{diff}")?; } diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap index c2ed187615..774ca95ff9 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap @@ -1,29 +1,32 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR001.py:11:1: AIR001 Task variable name should match the `task_id`: "my_task" +AIR001 Task variable name should match the `task_id`: "my_task" + --> AIR001.py:11:1 | 10 | my_task = PythonOperator(task_id="my_task", callable=my_callable) 11 | incorrect_name = PythonOperator(task_id="my_task") # AIR001 - | ^^^^^^^^^^^^^^ AIR001 + | ^^^^^^^^^^^^^^ 12 | 13 | my_task = AirbyteTriggerSyncOperator(task_id="my_task", callable=my_callable) | -AIR001.py:14:1: AIR001 Task variable name should match the `task_id`: "my_task" +AIR001 Task variable name should match the `task_id`: "my_task" + --> AIR001.py:14:1 | 13 | my_task = AirbyteTriggerSyncOperator(task_id="my_task", callable=my_callable) 14 | incorrect_name = AirbyteTriggerSyncOperator(task_id="my_task") # AIR001 - | ^^^^^^^^^^^^^^ AIR001 + | ^^^^^^^^^^^^^^ 15 | 16 | my_task = AppflowFlowRunOperator(task_id="my_task", callable=my_callable) | -AIR001.py:17:1: AIR001 Task variable name should match the `task_id`: "my_task" +AIR001 Task variable name should match the `task_id`: "my_task" + --> AIR001.py:17:1 | 16 | my_task = AppflowFlowRunOperator(task_id="my_task", callable=my_callable) 17 | incorrect_name = AppflowFlowRunOperator(task_id="my_task") # AIR001 - | ^^^^^^^^^^^^^^ AIR001 + | ^^^^^^^^^^^^^^ 18 | 19 | # Consider only from the `airflow.operators` (or providers operators) module | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap index 11ab436c40..2ca71e8bfa 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR002_AIR002.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR002.py:4:1: AIR002 DAG should have an explicit `schedule` argument +AIR002 DAG should have an explicit `schedule` argument + --> AIR002.py:4:1 | 2 | from airflow.timetables.simple import NullTimetable 3 | 4 | DAG(dag_id="class_default_schedule") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | DAG(dag_id="class_schedule", schedule="@hourly") | -AIR002.py:13:2: AIR002 DAG should have an explicit `schedule` argument +AIR002 DAG should have an explicit `schedule` argument + --> AIR002.py:13:2 | 13 | @dag() - | ^^^^^ AIR002 + | ^^^^^ 14 | def decorator_default_schedule(): 15 | pass | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_airflow_plugin.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_airflow_plugin.py.snap index 173877e2d8..504bcbe014 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_airflow_plugin.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_airflow_plugin.py.snap @@ -1,46 +1,50 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR301_airflow_plugin.py:7:5: AIR301 `operators` is removed in Airflow 3.0 +AIR301 `operators` is removed in Airflow 3.0 + --> AIR301_airflow_plugin.py:7:5 | 5 | name = "test_plugin" 6 | # --- Invalid extensions start 7 | operators = [PluginOperator] - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ 8 | sensors = [PluginSensorOperator] 9 | hooks = [PluginHook] | - = help: This extension should just be imported as a regular python module. +help: This extension should just be imported as a regular python module. -AIR301_airflow_plugin.py:8:5: AIR301 `sensors` is removed in Airflow 3.0 +AIR301 `sensors` is removed in Airflow 3.0 + --> AIR301_airflow_plugin.py:8:5 | 6 | # --- Invalid extensions start 7 | operators = [PluginOperator] 8 | sensors = [PluginSensorOperator] - | ^^^^^^^ AIR301 + | ^^^^^^^ 9 | hooks = [PluginHook] 10 | executors = [PluginExecutor] | - = help: This extension should just be imported as a regular python module. +help: This extension should just be imported as a regular python module. -AIR301_airflow_plugin.py:9:5: AIR301 `hooks` is removed in Airflow 3.0 +AIR301 `hooks` is removed in Airflow 3.0 + --> AIR301_airflow_plugin.py:9:5 | 7 | operators = [PluginOperator] 8 | sensors = [PluginSensorOperator] 9 | hooks = [PluginHook] - | ^^^^^ AIR301 + | ^^^^^ 10 | executors = [PluginExecutor] 11 | # --- Invalid extensions end | - = help: This extension should just be imported as a regular python module. +help: This extension should just be imported as a regular python module. -AIR301_airflow_plugin.py:10:5: AIR301 `executors` is removed in Airflow 3.0 +AIR301 `executors` is removed in Airflow 3.0 + --> AIR301_airflow_plugin.py:10:5 | 8 | sensors = [PluginSensorOperator] 9 | hooks = [PluginHook] 10 | executors = [PluginExecutor] - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ 11 | # --- Invalid extensions end 12 | macros = [plugin_macro] | - = help: This extension should just be imported as a regular python module. +help: This extension should just be imported as a regular python module. diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_args.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_args.py.snap index af858937ab..1142bee4af 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_args.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_args.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR301_args.py:21:39: AIR301 [*] `schedule_interval` is removed in Airflow 3.0 +AIR301 [*] `schedule_interval` is removed in Airflow 3.0 + --> AIR301_args.py:21:39 | 19 | DAG(dag_id="class_schedule", schedule="@hourly") 20 | 21 | DAG(dag_id="class_schedule_interval", schedule_interval="@hourly") - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 22 | 23 | DAG(dag_id="class_timetable", timetable=NullTimetable()) | - = help: Use `schedule` instead +help: Use `schedule` instead ℹ Safe fix 18 18 | @@ -22,14 +23,15 @@ AIR301_args.py:21:39: AIR301 [*] `schedule_interval` is removed in Airflow 3.0 23 23 | DAG(dag_id="class_timetable", timetable=NullTimetable()) 24 24 | -AIR301_args.py:23:31: AIR301 [*] `timetable` is removed in Airflow 3.0 +AIR301 [*] `timetable` is removed in Airflow 3.0 + --> AIR301_args.py:23:31 | 21 | DAG(dag_id="class_schedule_interval", schedule_interval="@hourly") 22 | 23 | DAG(dag_id="class_timetable", timetable=NullTimetable()) - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ | - = help: Use `schedule` instead +help: Use `schedule` instead ℹ Safe fix 20 20 | @@ -41,14 +43,15 @@ AIR301_args.py:23:31: AIR301 [*] `timetable` is removed in Airflow 3.0 25 25 | 26 26 | DAG(dag_id="class_fail_stop", fail_stop=True) -AIR301_args.py:26:31: AIR301 [*] `fail_stop` is removed in Airflow 3.0 +AIR301 [*] `fail_stop` is removed in Airflow 3.0 + --> AIR301_args.py:26:31 | 26 | DAG(dag_id="class_fail_stop", fail_stop=True) - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ 27 | 28 | DAG(dag_id="class_default_view", default_view="dag_default_view") | - = help: Use `fail_fast` instead +help: Use `fail_fast` instead ℹ Safe fix 23 23 | DAG(dag_id="class_timetable", timetable=NullTimetable()) @@ -60,34 +63,37 @@ AIR301_args.py:26:31: AIR301 [*] `fail_stop` is removed in Airflow 3.0 28 28 | DAG(dag_id="class_default_view", default_view="dag_default_view") 29 29 | -AIR301_args.py:28:34: AIR301 `default_view` is removed in Airflow 3.0 +AIR301 `default_view` is removed in Airflow 3.0 + --> AIR301_args.py:28:34 | 26 | DAG(dag_id="class_fail_stop", fail_stop=True) 27 | 28 | DAG(dag_id="class_default_view", default_view="dag_default_view") - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 29 | 30 | DAG(dag_id="class_orientation", orientation="BT") | -AIR301_args.py:30:33: AIR301 `orientation` is removed in Airflow 3.0 +AIR301 `orientation` is removed in Airflow 3.0 + --> AIR301_args.py:30:33 | 28 | DAG(dag_id="class_default_view", default_view="dag_default_view") 29 | 30 | DAG(dag_id="class_orientation", orientation="BT") - | ^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^ 31 | 32 | allow_future_exec_dates_dag = DAG(dag_id="class_allow_future_exec_dates") | -AIR301_args.py:41:6: AIR301 [*] `schedule_interval` is removed in Airflow 3.0 +AIR301 [*] `schedule_interval` is removed in Airflow 3.0 + --> AIR301_args.py:41:6 | 41 | @dag(schedule_interval="0 * * * *") - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 42 | def decorator_schedule_interval(): 43 | pass | - = help: Use `schedule` instead +help: Use `schedule` instead ℹ Safe fix 38 38 | pass @@ -99,14 +105,15 @@ AIR301_args.py:41:6: AIR301 [*] `schedule_interval` is removed in Airflow 3.0 43 43 | pass 44 44 | -AIR301_args.py:46:6: AIR301 [*] `timetable` is removed in Airflow 3.0 +AIR301 [*] `timetable` is removed in Airflow 3.0 + --> AIR301_args.py:46:6 | 46 | @dag(timetable=NullTimetable()) - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ 47 | def decorator_timetable(): 48 | pass | - = help: Use `schedule` instead +help: Use `schedule` instead ℹ Safe fix 43 43 | pass @@ -118,16 +125,17 @@ AIR301_args.py:46:6: AIR301 [*] `timetable` is removed in Airflow 3.0 48 48 | pass 49 49 | -AIR301_args.py:54:62: AIR301 [*] `execution_date` is removed in Airflow 3.0 +AIR301 [*] `execution_date` is removed in Airflow 3.0 + --> AIR301_args.py:54:62 | 52 | def decorator_deprecated_operator_args(): 53 | trigger_dagrun_op = trigger_dagrun.TriggerDagRunOperator( 54 | task_id="trigger_dagrun_op1", trigger_dag_id="test", execution_date="2024-12-04" - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 55 | ) 56 | trigger_dagrun_op2 = TriggerDagRunOperator( | - = help: Use `logical_date` instead +help: Use `logical_date` instead ℹ Safe fix 51 51 | @dag() @@ -139,15 +147,16 @@ AIR301_args.py:54:62: AIR301 [*] `execution_date` is removed in Airflow 3.0 56 56 | trigger_dagrun_op2 = TriggerDagRunOperator( 57 57 | task_id="trigger_dagrun_op2", trigger_dag_id="test", execution_date="2024-12-04" -AIR301_args.py:57:62: AIR301 [*] `execution_date` is removed in Airflow 3.0 +AIR301 [*] `execution_date` is removed in Airflow 3.0 + --> AIR301_args.py:57:62 | 55 | ) 56 | trigger_dagrun_op2 = TriggerDagRunOperator( 57 | task_id="trigger_dagrun_op2", trigger_dag_id="test", execution_date="2024-12-04" - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 58 | ) | - = help: Use `logical_date` instead +help: Use `logical_date` instead ℹ Safe fix 54 54 | task_id="trigger_dagrun_op1", trigger_dag_id="test", execution_date="2024-12-04" @@ -159,15 +168,16 @@ AIR301_args.py:57:62: AIR301 [*] `execution_date` is removed in Airflow 3.0 59 59 | 60 60 | branch_dt_op = datetime.BranchDateTimeOperator( -AIR301_args.py:61:33: AIR301 [*] `use_task_execution_day` is removed in Airflow 3.0 +AIR301 [*] `use_task_execution_day` is removed in Airflow 3.0 + --> AIR301_args.py:61:33 | 60 | branch_dt_op = datetime.BranchDateTimeOperator( 61 | task_id="branch_dt_op", use_task_execution_day=True, task_concurrency=5 - | ^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^ 62 | ) 63 | branch_dt_op2 = BranchDateTimeOperator( | - = help: Use `use_task_logical_date` instead +help: Use `use_task_logical_date` instead ℹ Safe fix 58 58 | ) @@ -179,15 +189,16 @@ AIR301_args.py:61:33: AIR301 [*] `use_task_execution_day` is removed in Airflow 63 63 | branch_dt_op2 = BranchDateTimeOperator( 64 64 | task_id="branch_dt_op2", -AIR301_args.py:61:62: AIR301 [*] `task_concurrency` is removed in Airflow 3.0 +AIR301 [*] `task_concurrency` is removed in Airflow 3.0 + --> AIR301_args.py:61:62 | 60 | branch_dt_op = datetime.BranchDateTimeOperator( 61 | task_id="branch_dt_op", use_task_execution_day=True, task_concurrency=5 - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 62 | ) 63 | branch_dt_op2 = BranchDateTimeOperator( | - = help: Use `max_active_tis_per_dag` instead +help: Use `max_active_tis_per_dag` instead ℹ Safe fix 58 58 | ) @@ -199,16 +210,17 @@ AIR301_args.py:61:62: AIR301 [*] `task_concurrency` is removed in Airflow 3.0 63 63 | branch_dt_op2 = BranchDateTimeOperator( 64 64 | task_id="branch_dt_op2", -AIR301_args.py:65:9: AIR301 [*] `use_task_execution_day` is removed in Airflow 3.0 +AIR301 [*] `use_task_execution_day` is removed in Airflow 3.0 + --> AIR301_args.py:65:9 | 63 | branch_dt_op2 = BranchDateTimeOperator( 64 | task_id="branch_dt_op2", 65 | use_task_execution_day=True, - | ^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^ 66 | sla=timedelta(seconds=10), 67 | ) | - = help: Use `use_task_logical_date` instead +help: Use `use_task_logical_date` instead ℹ Safe fix 62 62 | ) @@ -220,15 +232,16 @@ AIR301_args.py:65:9: AIR301 [*] `use_task_execution_day` is removed in Airflow 3 67 67 | ) 68 68 | -AIR301_args.py:92:9: AIR301 [*] `use_task_execution_day` is removed in Airflow 3.0 +AIR301 [*] `use_task_execution_day` is removed in Airflow 3.0 + --> AIR301_args.py:92:9 | 90 | follow_task_ids_if_true=None, 91 | week_day=1, 92 | use_task_execution_day=True, - | ^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^ 93 | ) | - = help: Use `use_task_logical_date` instead +help: Use `use_task_logical_date` instead ℹ Safe fix 89 89 | follow_task_ids_if_false=None, @@ -240,49 +253,54 @@ AIR301_args.py:92:9: AIR301 [*] `use_task_execution_day` is removed in Airflow 3 94 94 | 95 95 | trigger_dagrun_op >> trigger_dagrun_op2 -AIR301_args.py:102:15: AIR301 `filename_template` is removed in Airflow 3.0 +AIR301 `filename_template` is removed in Airflow 3.0 + --> AIR301_args.py:102:15 | 101 | # deprecated filename_template argument in FileTaskHandler 102 | S3TaskHandler(filename_template="/tmp/test") - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 103 | HdfsTaskHandler(filename_template="/tmp/test") 104 | ElasticsearchTaskHandler(filename_template="/tmp/test") | -AIR301_args.py:103:17: AIR301 `filename_template` is removed in Airflow 3.0 +AIR301 `filename_template` is removed in Airflow 3.0 + --> AIR301_args.py:103:17 | 101 | # deprecated filename_template argument in FileTaskHandler 102 | S3TaskHandler(filename_template="/tmp/test") 103 | HdfsTaskHandler(filename_template="/tmp/test") - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 104 | ElasticsearchTaskHandler(filename_template="/tmp/test") 105 | GCSTaskHandler(filename_template="/tmp/test") | -AIR301_args.py:104:26: AIR301 `filename_template` is removed in Airflow 3.0 +AIR301 `filename_template` is removed in Airflow 3.0 + --> AIR301_args.py:104:26 | 102 | S3TaskHandler(filename_template="/tmp/test") 103 | HdfsTaskHandler(filename_template="/tmp/test") 104 | ElasticsearchTaskHandler(filename_template="/tmp/test") - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 105 | GCSTaskHandler(filename_template="/tmp/test") | -AIR301_args.py:105:16: AIR301 `filename_template` is removed in Airflow 3.0 +AIR301 `filename_template` is removed in Airflow 3.0 + --> AIR301_args.py:105:16 | 103 | HdfsTaskHandler(filename_template="/tmp/test") 104 | ElasticsearchTaskHandler(filename_template="/tmp/test") 105 | GCSTaskHandler(filename_template="/tmp/test") - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 106 | 107 | FabAuthManager(None) | -AIR301_args.py:107:15: AIR301 `appbuilder` is removed in Airflow 3.0 +AIR301 `appbuilder` is removed in Airflow 3.0 + --> AIR301_args.py:107:15 | 105 | GCSTaskHandler(filename_template="/tmp/test") 106 | 107 | FabAuthManager(None) - | ^^^^^^ AIR301 + | ^^^^^^ | - = help: The constructor takes no parameter now +help: The constructor takes no parameter now diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_class_attribute.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_class_attribute.py.snap index 4fdecfe8a1..8bd2cd6bbb 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_class_attribute.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_class_attribute.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR301_class_attribute.py:25:19: AIR301 [*] `iter_datasets` is removed in Airflow 3.0 +AIR301 [*] `iter_datasets` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:25:19 | 23 | # airflow.Dataset 24 | dataset_from_root = DatasetFromRoot() 25 | dataset_from_root.iter_datasets() - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ 26 | dataset_from_root.iter_dataset_aliases() | - = help: Use `iter_assets` instead +help: Use `iter_assets` instead ℹ Safe fix 22 22 | @@ -21,16 +22,17 @@ AIR301_class_attribute.py:25:19: AIR301 [*] `iter_datasets` is removed in Airflo 27 27 | 28 28 | # airflow.datasets -AIR301_class_attribute.py:26:19: AIR301 [*] `iter_dataset_aliases` is removed in Airflow 3.0 +AIR301 [*] `iter_dataset_aliases` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:26:19 | 24 | dataset_from_root = DatasetFromRoot() 25 | dataset_from_root.iter_datasets() 26 | dataset_from_root.iter_dataset_aliases() - | ^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^ 27 | 28 | # airflow.datasets | - = help: Use `iter_asset_aliases` instead +help: Use `iter_asset_aliases` instead ℹ Safe fix 23 23 | # airflow.Dataset @@ -42,15 +44,16 @@ AIR301_class_attribute.py:26:19: AIR301 [*] `iter_dataset_aliases` is removed in 28 28 | # airflow.datasets 29 29 | dataset_to_test_method_call = Dataset() -AIR301_class_attribute.py:30:29: AIR301 [*] `iter_datasets` is removed in Airflow 3.0 +AIR301 [*] `iter_datasets` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:30:29 | 28 | # airflow.datasets 29 | dataset_to_test_method_call = Dataset() 30 | dataset_to_test_method_call.iter_datasets() - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ 31 | dataset_to_test_method_call.iter_dataset_aliases() | - = help: Use `iter_assets` instead +help: Use `iter_assets` instead ℹ Safe fix 27 27 | @@ -62,16 +65,17 @@ AIR301_class_attribute.py:30:29: AIR301 [*] `iter_datasets` is removed in Airflo 32 32 | 33 33 | alias_to_test_method_call = DatasetAlias() -AIR301_class_attribute.py:31:29: AIR301 [*] `iter_dataset_aliases` is removed in Airflow 3.0 +AIR301 [*] `iter_dataset_aliases` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:31:29 | 29 | dataset_to_test_method_call = Dataset() 30 | dataset_to_test_method_call.iter_datasets() 31 | dataset_to_test_method_call.iter_dataset_aliases() - | ^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^ 32 | 33 | alias_to_test_method_call = DatasetAlias() | - = help: Use `iter_asset_aliases` instead +help: Use `iter_asset_aliases` instead ℹ Safe fix 28 28 | # airflow.datasets @@ -83,14 +87,15 @@ AIR301_class_attribute.py:31:29: AIR301 [*] `iter_dataset_aliases` is removed in 33 33 | alias_to_test_method_call = DatasetAlias() 34 34 | alias_to_test_method_call.iter_datasets() -AIR301_class_attribute.py:34:27: AIR301 [*] `iter_datasets` is removed in Airflow 3.0 +AIR301 [*] `iter_datasets` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:34:27 | 33 | alias_to_test_method_call = DatasetAlias() 34 | alias_to_test_method_call.iter_datasets() - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ 35 | alias_to_test_method_call.iter_dataset_aliases() | - = help: Use `iter_assets` instead +help: Use `iter_assets` instead ℹ Safe fix 31 31 | dataset_to_test_method_call.iter_dataset_aliases() @@ -102,16 +107,17 @@ AIR301_class_attribute.py:34:27: AIR301 [*] `iter_datasets` is removed in Airflo 36 36 | 37 37 | any_to_test_method_call = DatasetAny() -AIR301_class_attribute.py:35:27: AIR301 [*] `iter_dataset_aliases` is removed in Airflow 3.0 +AIR301 [*] `iter_dataset_aliases` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:35:27 | 33 | alias_to_test_method_call = DatasetAlias() 34 | alias_to_test_method_call.iter_datasets() 35 | alias_to_test_method_call.iter_dataset_aliases() - | ^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^ 36 | 37 | any_to_test_method_call = DatasetAny() | - = help: Use `iter_asset_aliases` instead +help: Use `iter_asset_aliases` instead ℹ Safe fix 32 32 | @@ -123,14 +129,15 @@ AIR301_class_attribute.py:35:27: AIR301 [*] `iter_dataset_aliases` is removed in 37 37 | any_to_test_method_call = DatasetAny() 38 38 | any_to_test_method_call.iter_datasets() -AIR301_class_attribute.py:38:25: AIR301 [*] `iter_datasets` is removed in Airflow 3.0 +AIR301 [*] `iter_datasets` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:38:25 | 37 | any_to_test_method_call = DatasetAny() 38 | any_to_test_method_call.iter_datasets() - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ 39 | any_to_test_method_call.iter_dataset_aliases() | - = help: Use `iter_assets` instead +help: Use `iter_assets` instead ℹ Safe fix 35 35 | alias_to_test_method_call.iter_dataset_aliases() @@ -142,16 +149,17 @@ AIR301_class_attribute.py:38:25: AIR301 [*] `iter_datasets` is removed in Airflo 40 40 | 41 41 | # airflow.datasets.manager -AIR301_class_attribute.py:39:25: AIR301 [*] `iter_dataset_aliases` is removed in Airflow 3.0 +AIR301 [*] `iter_dataset_aliases` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:39:25 | 37 | any_to_test_method_call = DatasetAny() 38 | any_to_test_method_call.iter_datasets() 39 | any_to_test_method_call.iter_dataset_aliases() - | ^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^ 40 | 41 | # airflow.datasets.manager | - = help: Use `iter_asset_aliases` instead +help: Use `iter_asset_aliases` instead ℹ Safe fix 36 36 | @@ -163,15 +171,16 @@ AIR301_class_attribute.py:39:25: AIR301 [*] `iter_dataset_aliases` is removed in 41 41 | # airflow.datasets.manager 42 42 | dm = DatasetManager() -AIR301_class_attribute.py:42:6: AIR301 [*] `airflow.datasets.manager.DatasetManager` is removed in Airflow 3.0 +AIR301 [*] `airflow.datasets.manager.DatasetManager` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:42:6 | 41 | # airflow.datasets.manager 42 | dm = DatasetManager() - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 43 | dm.register_dataset_change() 44 | dm.create_datasets() | - = help: Use `AssetManager` from `airflow.assets.manager` instead. +help: Use `AssetManager` from `airflow.assets.manager` instead. ℹ Safe fix 19 19 | from airflow.providers_manager import ProvidersManager @@ -191,16 +200,17 @@ AIR301_class_attribute.py:42:6: AIR301 [*] `airflow.datasets.manager.DatasetMana 44 45 | dm.create_datasets() 45 46 | dm.notify_dataset_created() -AIR301_class_attribute.py:43:4: AIR301 [*] `register_dataset_change` is removed in Airflow 3.0 +AIR301 [*] `register_dataset_change` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:43:4 | 41 | # airflow.datasets.manager 42 | dm = DatasetManager() 43 | dm.register_dataset_change() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^ 44 | dm.create_datasets() 45 | dm.notify_dataset_created() | - = help: Use `register_asset_change` instead +help: Use `register_asset_change` instead ℹ Safe fix 40 40 | @@ -212,16 +222,17 @@ AIR301_class_attribute.py:43:4: AIR301 [*] `register_dataset_change` is removed 45 45 | dm.notify_dataset_created() 46 46 | dm.notify_dataset_changed() -AIR301_class_attribute.py:44:4: AIR301 [*] `create_datasets` is removed in Airflow 3.0 +AIR301 [*] `create_datasets` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:44:4 | 42 | dm = DatasetManager() 43 | dm.register_dataset_change() 44 | dm.create_datasets() - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ 45 | dm.notify_dataset_created() 46 | dm.notify_dataset_changed() | - = help: Use `create_assets` instead +help: Use `create_assets` instead ℹ Safe fix 41 41 | # airflow.datasets.manager @@ -233,16 +244,17 @@ AIR301_class_attribute.py:44:4: AIR301 [*] `create_datasets` is removed in Airfl 46 46 | dm.notify_dataset_changed() 47 47 | dm.notify_dataset_alias_created() -AIR301_class_attribute.py:45:4: AIR301 [*] `notify_dataset_created` is removed in Airflow 3.0 +AIR301 [*] `notify_dataset_created` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:45:4 | 43 | dm.register_dataset_change() 44 | dm.create_datasets() 45 | dm.notify_dataset_created() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^ 46 | dm.notify_dataset_changed() 47 | dm.notify_dataset_alias_created() | - = help: Use `notify_asset_created` instead +help: Use `notify_asset_created` instead ℹ Safe fix 42 42 | dm = DatasetManager() @@ -254,15 +266,16 @@ AIR301_class_attribute.py:45:4: AIR301 [*] `notify_dataset_created` is removed i 47 47 | dm.notify_dataset_alias_created() 48 48 | -AIR301_class_attribute.py:46:4: AIR301 [*] `notify_dataset_changed` is removed in Airflow 3.0 +AIR301 [*] `notify_dataset_changed` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:46:4 | 44 | dm.create_datasets() 45 | dm.notify_dataset_created() 46 | dm.notify_dataset_changed() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^ 47 | dm.notify_dataset_alias_created() | - = help: Use `notify_asset_changed` instead +help: Use `notify_asset_changed` instead ℹ Safe fix 43 43 | dm.register_dataset_change() @@ -274,16 +287,17 @@ AIR301_class_attribute.py:46:4: AIR301 [*] `notify_dataset_changed` is removed i 48 48 | 49 49 | # airflow.lineage.hook -AIR301_class_attribute.py:47:4: AIR301 [*] `notify_dataset_alias_created` is removed in Airflow 3.0 +AIR301 [*] `notify_dataset_alias_created` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:47:4 | 45 | dm.notify_dataset_created() 46 | dm.notify_dataset_changed() 47 | dm.notify_dataset_alias_created() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | 49 | # airflow.lineage.hook | - = help: Use `notify_asset_alias_created` instead +help: Use `notify_asset_alias_created` instead ℹ Safe fix 44 44 | dm.create_datasets() @@ -295,14 +309,15 @@ AIR301_class_attribute.py:47:4: AIR301 [*] `notify_dataset_alias_created` is rem 49 49 | # airflow.lineage.hook 50 50 | dl_info = DatasetLineageInfo() -AIR301_class_attribute.py:50:11: AIR301 [*] `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0 +AIR301 [*] `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:50:11 | 49 | # airflow.lineage.hook 50 | dl_info = DatasetLineageInfo() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 51 | dl_info.dataset | - = help: Use `AssetLineageInfo` from `airflow.lineage.hook` instead. +help: Use `AssetLineageInfo` from `airflow.lineage.hook` instead. ℹ Safe fix 9 9 | DatasetAny, @@ -323,16 +338,17 @@ AIR301_class_attribute.py:50:11: AIR301 [*] `airflow.lineage.hook.DatasetLineage 52 52 | 53 53 | hlc = HookLineageCollector() -AIR301_class_attribute.py:51:9: AIR301 [*] `dataset` is removed in Airflow 3.0 +AIR301 [*] `dataset` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:51:9 | 49 | # airflow.lineage.hook 50 | dl_info = DatasetLineageInfo() 51 | dl_info.dataset - | ^^^^^^^ AIR301 + | ^^^^^^^ 52 | 53 | hlc = HookLineageCollector() | - = help: Use `asset` instead +help: Use `asset` instead ℹ Safe fix 48 48 | @@ -344,15 +360,16 @@ AIR301_class_attribute.py:51:9: AIR301 [*] `dataset` is removed in Airflow 3.0 53 53 | hlc = HookLineageCollector() 54 54 | hlc.create_dataset() -AIR301_class_attribute.py:54:5: AIR301 [*] `create_dataset` is removed in Airflow 3.0 +AIR301 [*] `create_dataset` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:54:5 | 53 | hlc = HookLineageCollector() 54 | hlc.create_dataset() - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 55 | hlc.add_input_dataset() 56 | hlc.add_output_dataset() | - = help: Use `create_asset` instead +help: Use `create_asset` instead ℹ Safe fix 51 51 | dl_info.dataset @@ -364,16 +381,17 @@ AIR301_class_attribute.py:54:5: AIR301 [*] `create_dataset` is removed in Airflo 56 56 | hlc.add_output_dataset() 57 57 | hlc.collected_datasets() -AIR301_class_attribute.py:55:5: AIR301 [*] `add_input_dataset` is removed in Airflow 3.0 +AIR301 [*] `add_input_dataset` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:55:5 | 53 | hlc = HookLineageCollector() 54 | hlc.create_dataset() 55 | hlc.add_input_dataset() - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 56 | hlc.add_output_dataset() 57 | hlc.collected_datasets() | - = help: Use `add_input_asset` instead +help: Use `add_input_asset` instead ℹ Safe fix 52 52 | @@ -385,15 +403,16 @@ AIR301_class_attribute.py:55:5: AIR301 [*] `add_input_dataset` is removed in Air 57 57 | hlc.collected_datasets() 58 58 | -AIR301_class_attribute.py:56:5: AIR301 [*] `add_output_dataset` is removed in Airflow 3.0 +AIR301 [*] `add_output_dataset` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:56:5 | 54 | hlc.create_dataset() 55 | hlc.add_input_dataset() 56 | hlc.add_output_dataset() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 57 | hlc.collected_datasets() | - = help: Use `add_output_asset` instead +help: Use `add_output_asset` instead ℹ Safe fix 53 53 | hlc = HookLineageCollector() @@ -405,16 +424,17 @@ AIR301_class_attribute.py:56:5: AIR301 [*] `add_output_dataset` is removed in Ai 58 58 | 59 59 | # airflow.providers.amazon.auth_manager.aws_auth_manager -AIR301_class_attribute.py:57:5: AIR301 [*] `collected_datasets` is removed in Airflow 3.0 +AIR301 [*] `collected_datasets` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:57:5 | 55 | hlc.add_input_dataset() 56 | hlc.add_output_dataset() 57 | hlc.collected_datasets() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 58 | 59 | # airflow.providers.amazon.auth_manager.aws_auth_manager | - = help: Use `collected_assets` instead +help: Use `collected_assets` instead ℹ Safe fix 54 54 | hlc.create_dataset() @@ -426,16 +446,17 @@ AIR301_class_attribute.py:57:5: AIR301 [*] `collected_datasets` is removed in Ai 59 59 | # airflow.providers.amazon.auth_manager.aws_auth_manager 60 60 | aam = AwsAuthManager() -AIR301_class_attribute.py:61:5: AIR301 [*] `is_authorized_dataset` is removed in Airflow 3.0 +AIR301 [*] `is_authorized_dataset` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:61:5 | 59 | # airflow.providers.amazon.auth_manager.aws_auth_manager 60 | aam = AwsAuthManager() 61 | aam.is_authorized_dataset() - | ^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^ 62 | 63 | # airflow.providers.apache.beam.hooks | - = help: Use `is_authorized_asset` instead +help: Use `is_authorized_asset` instead ℹ Safe fix 58 58 | @@ -447,15 +468,16 @@ AIR301_class_attribute.py:61:5: AIR301 [*] `is_authorized_dataset` is removed in 63 63 | # airflow.providers.apache.beam.hooks 64 64 | # check get_conn_uri is caught if the class inherits from an airflow hook -AIR301_class_attribute.py:73:13: AIR301 [*] `get_conn_uri` is removed in Airflow 3.0 +AIR301 [*] `get_conn_uri` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:73:13 | 71 | # airflow.providers.google.cloud.secrets.secret_manager 72 | csm_backend = CloudSecretManagerBackend() 73 | csm_backend.get_conn_uri() - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 74 | csm_backend.get_connections() | - = help: Use `get_conn_value` instead +help: Use `get_conn_value` instead ℹ Safe fix 70 70 | @@ -467,16 +489,17 @@ AIR301_class_attribute.py:73:13: AIR301 [*] `get_conn_uri` is removed in Airflow 75 75 | 76 76 | # airflow.providers.hashicorp.secrets.vault -AIR301_class_attribute.py:74:13: AIR301 [*] `get_connections` is removed in Airflow 3.0 +AIR301 [*] `get_connections` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:74:13 | 72 | csm_backend = CloudSecretManagerBackend() 73 | csm_backend.get_conn_uri() 74 | csm_backend.get_connections() - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ 75 | 76 | # airflow.providers.hashicorp.secrets.vault | - = help: Use `get_connection` instead +help: Use `get_connection` instead ℹ Safe fix 71 71 | # airflow.providers.google.cloud.secrets.secret_manager @@ -488,15 +511,16 @@ AIR301_class_attribute.py:74:13: AIR301 [*] `get_connections` is removed in Airf 76 76 | # airflow.providers.hashicorp.secrets.vault 77 77 | vault_backend = VaultBackend() -AIR301_class_attribute.py:78:15: AIR301 [*] `get_conn_uri` is removed in Airflow 3.0 +AIR301 [*] `get_conn_uri` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:78:15 | 76 | # airflow.providers.hashicorp.secrets.vault 77 | vault_backend = VaultBackend() 78 | vault_backend.get_conn_uri() - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 79 | vault_backend.get_connections() | - = help: Use `get_conn_value` instead +help: Use `get_conn_value` instead ℹ Safe fix 75 75 | @@ -508,16 +532,17 @@ AIR301_class_attribute.py:78:15: AIR301 [*] `get_conn_uri` is removed in Airflow 80 80 | 81 81 | not_an_error = NotAir302SecretError() -AIR301_class_attribute.py:79:15: AIR301 [*] `get_connections` is removed in Airflow 3.0 +AIR301 [*] `get_connections` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:79:15 | 77 | vault_backend = VaultBackend() 78 | vault_backend.get_conn_uri() 79 | vault_backend.get_connections() - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ 80 | 81 | not_an_error = NotAir302SecretError() | - = help: Use `get_connection` instead +help: Use `get_connection` instead ℹ Safe fix 76 76 | # airflow.providers.hashicorp.secrets.vault @@ -529,16 +554,17 @@ AIR301_class_attribute.py:79:15: AIR301 [*] `get_connections` is removed in Airf 81 81 | not_an_error = NotAir302SecretError() 82 82 | not_an_error.get_conn_uri() -AIR301_class_attribute.py:86:4: AIR301 [*] `initialize_providers_dataset_uri_resources` is removed in Airflow 3.0 +AIR301 [*] `initialize_providers_dataset_uri_resources` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:86:4 | 84 | # airflow.providers_manager 85 | pm = ProvidersManager() 86 | pm.initialize_providers_dataset_uri_resources() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 | pm.dataset_factories 88 | pm.dataset_uri_handlers | - = help: Use `initialize_providers_asset_uri_resources` instead +help: Use `initialize_providers_asset_uri_resources` instead ℹ Safe fix 83 83 | @@ -550,16 +576,17 @@ AIR301_class_attribute.py:86:4: AIR301 [*] `initialize_providers_dataset_uri_res 88 88 | pm.dataset_uri_handlers 89 89 | pm.dataset_to_openlineage_converters -AIR301_class_attribute.py:87:4: AIR301 [*] `dataset_factories` is removed in Airflow 3.0 +AIR301 [*] `dataset_factories` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:87:4 | 85 | pm = ProvidersManager() 86 | pm.initialize_providers_dataset_uri_resources() 87 | pm.dataset_factories - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 88 | pm.dataset_uri_handlers 89 | pm.dataset_to_openlineage_converters | - = help: Use `asset_factories` instead +help: Use `asset_factories` instead ℹ Safe fix 84 84 | # airflow.providers_manager @@ -571,15 +598,16 @@ AIR301_class_attribute.py:87:4: AIR301 [*] `dataset_factories` is removed in Air 89 89 | pm.dataset_to_openlineage_converters 90 90 | -AIR301_class_attribute.py:88:4: AIR301 [*] `dataset_uri_handlers` is removed in Airflow 3.0 +AIR301 [*] `dataset_uri_handlers` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:88:4 | 86 | pm.initialize_providers_dataset_uri_resources() 87 | pm.dataset_factories 88 | pm.dataset_uri_handlers - | ^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^ 89 | pm.dataset_to_openlineage_converters | - = help: Use `asset_uri_handlers` instead +help: Use `asset_uri_handlers` instead ℹ Safe fix 85 85 | pm = ProvidersManager() @@ -591,16 +619,17 @@ AIR301_class_attribute.py:88:4: AIR301 [*] `dataset_uri_handlers` is removed in 90 90 | 91 91 | # airflow.secrets.base_secrets -AIR301_class_attribute.py:89:4: AIR301 [*] `dataset_to_openlineage_converters` is removed in Airflow 3.0 +AIR301 [*] `dataset_to_openlineage_converters` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:89:4 | 87 | pm.dataset_factories 88 | pm.dataset_uri_handlers 89 | pm.dataset_to_openlineage_converters - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | 91 | # airflow.secrets.base_secrets | - = help: Use `asset_to_openlineage_converters` instead +help: Use `asset_to_openlineage_converters` instead ℹ Safe fix 86 86 | pm.initialize_providers_dataset_uri_resources() @@ -612,15 +641,16 @@ AIR301_class_attribute.py:89:4: AIR301 [*] `dataset_to_openlineage_converters` i 91 91 | # airflow.secrets.base_secrets 92 92 | base_secret_backend = BaseSecretsBackend() -AIR301_class_attribute.py:93:21: AIR301 [*] `get_conn_uri` is removed in Airflow 3.0 +AIR301 [*] `get_conn_uri` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:93:21 | 91 | # airflow.secrets.base_secrets 92 | base_secret_backend = BaseSecretsBackend() 93 | base_secret_backend.get_conn_uri() - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 94 | base_secret_backend.get_connections() | - = help: Use `get_conn_value` instead +help: Use `get_conn_value` instead ℹ Safe fix 90 90 | @@ -632,16 +662,17 @@ AIR301_class_attribute.py:93:21: AIR301 [*] `get_conn_uri` is removed in Airflow 95 95 | 96 96 | # airflow.secrets.local_filesystem -AIR301_class_attribute.py:94:21: AIR301 [*] `get_connections` is removed in Airflow 3.0 +AIR301 [*] `get_connections` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:94:21 | 92 | base_secret_backend = BaseSecretsBackend() 93 | base_secret_backend.get_conn_uri() 94 | base_secret_backend.get_connections() - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ 95 | 96 | # airflow.secrets.local_filesystem | - = help: Use `get_connection` instead +help: Use `get_connection` instead ℹ Safe fix 91 91 | # airflow.secrets.base_secrets @@ -653,14 +684,15 @@ AIR301_class_attribute.py:94:21: AIR301 [*] `get_connections` is removed in Airf 96 96 | # airflow.secrets.local_filesystem 97 97 | lfb = LocalFilesystemBackend() -AIR301_class_attribute.py:98:5: AIR301 [*] `get_connections` is removed in Airflow 3.0 +AIR301 [*] `get_connections` is removed in Airflow 3.0 + --> AIR301_class_attribute.py:98:5 | 96 | # airflow.secrets.local_filesystem 97 | lfb = LocalFilesystemBackend() 98 | lfb.get_connections() - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ | - = help: Use `get_connection` instead +help: Use `get_connection` instead ℹ Safe fix 95 95 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_context.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_context.py.snap index e8dfc9d9fe..b72ae18913 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_context.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_context.py.snap @@ -1,310 +1,342 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR301_context.py:22:41: AIR301 `conf` is removed in Airflow 3.0 +AIR301 `conf` is removed in Airflow 3.0 + --> AIR301_context.py:22:41 | 20 | @task 21 | def access_invalid_key_task_out_of_dag(**context): 22 | print("access invalid key", context["conf"]) - | ^^^^^^ AIR301 + | ^^^^^^ 23 | print("access invalid key", context.get("conf")) | -AIR301_context.py:23:45: AIR301 `conf` is removed in Airflow 3.0 +AIR301 `conf` is removed in Airflow 3.0 + --> AIR301_context.py:23:45 | 21 | def access_invalid_key_task_out_of_dag(**context): 22 | print("access invalid key", context["conf"]) 23 | print("access invalid key", context.get("conf")) - | ^^^^^^ AIR301 + | ^^^^^^ | -AIR301_context.py:28:5: AIR301 `execution_date` is removed in Airflow 3.0 +AIR301 `execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:28:5 | 26 | @task 27 | def access_invalid_argument_task_out_of_dag( 28 | execution_date, tomorrow_ds, logical_date, **context - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 29 | ): 30 | print("execution date", execution_date) | -AIR301_context.py:28:21: AIR301 `tomorrow_ds` is removed in Airflow 3.0 +AIR301 `tomorrow_ds` is removed in Airflow 3.0 + --> AIR301_context.py:28:21 | 26 | @task 27 | def access_invalid_argument_task_out_of_dag( 28 | execution_date, tomorrow_ds, logical_date, **context - | ^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^ 29 | ): 30 | print("execution date", execution_date) | -AIR301_context.py:31:45: AIR301 `conf` is removed in Airflow 3.0 +AIR301 `conf` is removed in Airflow 3.0 + --> AIR301_context.py:31:45 | 29 | ): 30 | print("execution date", execution_date) 31 | print("access invalid key", context.get("conf")) - | ^^^^^^ AIR301 + | ^^^^^^ | -AIR301_context.py:40:30: AIR301 `execution_date` is removed in Airflow 3.0 +AIR301 `execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:40:30 | 39 | # Removed usage - should trigger violations 40 | execution_date = context["execution_date"] - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 41 | next_ds = context["next_ds"] 42 | next_ds_nodash = context["next_ds_nodash"] | -AIR301_context.py:41:23: AIR301 `next_ds` is removed in Airflow 3.0 +AIR301 `next_ds` is removed in Airflow 3.0 + --> AIR301_context.py:41:23 | 39 | # Removed usage - should trigger violations 40 | execution_date = context["execution_date"] 41 | next_ds = context["next_ds"] - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ 42 | next_ds_nodash = context["next_ds_nodash"] 43 | next_execution_date = context["next_execution_date"] | -AIR301_context.py:42:30: AIR301 `next_ds_nodash` is removed in Airflow 3.0 +AIR301 `next_ds_nodash` is removed in Airflow 3.0 + --> AIR301_context.py:42:30 | 40 | execution_date = context["execution_date"] 41 | next_ds = context["next_ds"] 42 | next_ds_nodash = context["next_ds_nodash"] - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 43 | next_execution_date = context["next_execution_date"] 44 | prev_ds = context["prev_ds"] | -AIR301_context.py:43:35: AIR301 `next_execution_date` is removed in Airflow 3.0 +AIR301 `next_execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:43:35 | 41 | next_ds = context["next_ds"] 42 | next_ds_nodash = context["next_ds_nodash"] 43 | next_execution_date = context["next_execution_date"] - | ^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^ 44 | prev_ds = context["prev_ds"] 45 | prev_ds_nodash = context["prev_ds_nodash"] | -AIR301_context.py:44:23: AIR301 `prev_ds` is removed in Airflow 3.0 +AIR301 `prev_ds` is removed in Airflow 3.0 + --> AIR301_context.py:44:23 | 42 | next_ds_nodash = context["next_ds_nodash"] 43 | next_execution_date = context["next_execution_date"] 44 | prev_ds = context["prev_ds"] - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ 45 | prev_ds_nodash = context["prev_ds_nodash"] 46 | prev_execution_date = context["prev_execution_date"] | -AIR301_context.py:45:30: AIR301 `prev_ds_nodash` is removed in Airflow 3.0 +AIR301 `prev_ds_nodash` is removed in Airflow 3.0 + --> AIR301_context.py:45:30 | 43 | next_execution_date = context["next_execution_date"] 44 | prev_ds = context["prev_ds"] 45 | prev_ds_nodash = context["prev_ds_nodash"] - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 46 | prev_execution_date = context["prev_execution_date"] 47 | prev_execution_date_success = context["prev_execution_date_success"] | -AIR301_context.py:46:35: AIR301 `prev_execution_date` is removed in Airflow 3.0 +AIR301 `prev_execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:46:35 | 44 | prev_ds = context["prev_ds"] 45 | prev_ds_nodash = context["prev_ds_nodash"] 46 | prev_execution_date = context["prev_execution_date"] - | ^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^ 47 | prev_execution_date_success = context["prev_execution_date_success"] 48 | tomorrow_ds = context["tomorrow_ds"] | -AIR301_context.py:47:43: AIR301 `prev_execution_date_success` is removed in Airflow 3.0 +AIR301 `prev_execution_date_success` is removed in Airflow 3.0 + --> AIR301_context.py:47:43 | 45 | prev_ds_nodash = context["prev_ds_nodash"] 46 | prev_execution_date = context["prev_execution_date"] 47 | prev_execution_date_success = context["prev_execution_date_success"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | tomorrow_ds = context["tomorrow_ds"] 49 | yesterday_ds = context["yesterday_ds"] | -AIR301_context.py:48:27: AIR301 `tomorrow_ds` is removed in Airflow 3.0 +AIR301 `tomorrow_ds` is removed in Airflow 3.0 + --> AIR301_context.py:48:27 | 46 | prev_execution_date = context["prev_execution_date"] 47 | prev_execution_date_success = context["prev_execution_date_success"] 48 | tomorrow_ds = context["tomorrow_ds"] - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ 49 | yesterday_ds = context["yesterday_ds"] 50 | yesterday_ds_nodash = context["yesterday_ds_nodash"] | -AIR301_context.py:49:28: AIR301 `yesterday_ds` is removed in Airflow 3.0 +AIR301 `yesterday_ds` is removed in Airflow 3.0 + --> AIR301_context.py:49:28 | 47 | prev_execution_date_success = context["prev_execution_date_success"] 48 | tomorrow_ds = context["tomorrow_ds"] 49 | yesterday_ds = context["yesterday_ds"] - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 50 | yesterday_ds_nodash = context["yesterday_ds_nodash"] | -AIR301_context.py:50:35: AIR301 `yesterday_ds_nodash` is removed in Airflow 3.0 +AIR301 `yesterday_ds_nodash` is removed in Airflow 3.0 + --> AIR301_context.py:50:35 | 48 | tomorrow_ds = context["tomorrow_ds"] 49 | yesterday_ds = context["yesterday_ds"] 50 | yesterday_ds_nodash = context["yesterday_ds_nodash"] - | ^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^ | -AIR301_context.py:56:30: AIR301 `execution_date` is removed in Airflow 3.0 +AIR301 `execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:56:30 | 54 | def print_config_with_get_current_context(): 55 | context = get_current_context() 56 | execution_date = context["execution_date"] - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 57 | next_ds = context["next_ds"] 58 | next_ds_nodash = context["next_ds_nodash"] | -AIR301_context.py:57:23: AIR301 `next_ds` is removed in Airflow 3.0 +AIR301 `next_ds` is removed in Airflow 3.0 + --> AIR301_context.py:57:23 | 55 | context = get_current_context() 56 | execution_date = context["execution_date"] 57 | next_ds = context["next_ds"] - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ 58 | next_ds_nodash = context["next_ds_nodash"] 59 | next_execution_date = context["next_execution_date"] | -AIR301_context.py:58:30: AIR301 `next_ds_nodash` is removed in Airflow 3.0 +AIR301 `next_ds_nodash` is removed in Airflow 3.0 + --> AIR301_context.py:58:30 | 56 | execution_date = context["execution_date"] 57 | next_ds = context["next_ds"] 58 | next_ds_nodash = context["next_ds_nodash"] - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 59 | next_execution_date = context["next_execution_date"] 60 | prev_ds = context["prev_ds"] | -AIR301_context.py:59:35: AIR301 `next_execution_date` is removed in Airflow 3.0 +AIR301 `next_execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:59:35 | 57 | next_ds = context["next_ds"] 58 | next_ds_nodash = context["next_ds_nodash"] 59 | next_execution_date = context["next_execution_date"] - | ^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^ 60 | prev_ds = context["prev_ds"] 61 | prev_ds_nodash = context["prev_ds_nodash"] | -AIR301_context.py:60:23: AIR301 `prev_ds` is removed in Airflow 3.0 +AIR301 `prev_ds` is removed in Airflow 3.0 + --> AIR301_context.py:60:23 | 58 | next_ds_nodash = context["next_ds_nodash"] 59 | next_execution_date = context["next_execution_date"] 60 | prev_ds = context["prev_ds"] - | ^^^^^^^^^ AIR301 + | ^^^^^^^^^ 61 | prev_ds_nodash = context["prev_ds_nodash"] 62 | prev_execution_date = context["prev_execution_date"] | -AIR301_context.py:61:30: AIR301 `prev_ds_nodash` is removed in Airflow 3.0 +AIR301 `prev_ds_nodash` is removed in Airflow 3.0 + --> AIR301_context.py:61:30 | 59 | next_execution_date = context["next_execution_date"] 60 | prev_ds = context["prev_ds"] 61 | prev_ds_nodash = context["prev_ds_nodash"] - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 62 | prev_execution_date = context["prev_execution_date"] 63 | prev_execution_date_success = context["prev_execution_date_success"] | -AIR301_context.py:62:35: AIR301 `prev_execution_date` is removed in Airflow 3.0 +AIR301 `prev_execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:62:35 | 60 | prev_ds = context["prev_ds"] 61 | prev_ds_nodash = context["prev_ds_nodash"] 62 | prev_execution_date = context["prev_execution_date"] - | ^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^ 63 | prev_execution_date_success = context["prev_execution_date_success"] 64 | tomorrow_ds = context["tomorrow_ds"] | -AIR301_context.py:63:43: AIR301 `prev_execution_date_success` is removed in Airflow 3.0 +AIR301 `prev_execution_date_success` is removed in Airflow 3.0 + --> AIR301_context.py:63:43 | 61 | prev_ds_nodash = context["prev_ds_nodash"] 62 | prev_execution_date = context["prev_execution_date"] 63 | prev_execution_date_success = context["prev_execution_date_success"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | tomorrow_ds = context["tomorrow_ds"] 65 | yesterday_ds = context["yesterday_ds"] | -AIR301_context.py:64:27: AIR301 `tomorrow_ds` is removed in Airflow 3.0 +AIR301 `tomorrow_ds` is removed in Airflow 3.0 + --> AIR301_context.py:64:27 | 62 | prev_execution_date = context["prev_execution_date"] 63 | prev_execution_date_success = context["prev_execution_date_success"] 64 | tomorrow_ds = context["tomorrow_ds"] - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ 65 | yesterday_ds = context["yesterday_ds"] 66 | yesterday_ds_nodash = context["yesterday_ds_nodash"] | -AIR301_context.py:65:28: AIR301 `yesterday_ds` is removed in Airflow 3.0 +AIR301 `yesterday_ds` is removed in Airflow 3.0 + --> AIR301_context.py:65:28 | 63 | prev_execution_date_success = context["prev_execution_date_success"] 64 | tomorrow_ds = context["tomorrow_ds"] 65 | yesterday_ds = context["yesterday_ds"] - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 66 | yesterday_ds_nodash = context["yesterday_ds_nodash"] | -AIR301_context.py:66:35: AIR301 `yesterday_ds_nodash` is removed in Airflow 3.0 +AIR301 `yesterday_ds_nodash` is removed in Airflow 3.0 + --> AIR301_context.py:66:35 | 64 | tomorrow_ds = context["tomorrow_ds"] 65 | yesterday_ds = context["yesterday_ds"] 66 | yesterday_ds_nodash = context["yesterday_ds_nodash"] - | ^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^ | -AIR301_context.py:73:22: AIR301 `tomorrow_ds` is removed in Airflow 3.0 +AIR301 `tomorrow_ds` is removed in Airflow 3.0 + --> AIR301_context.py:73:22 | 71 | """Print the Airflow context and ds variable from the context.""" 72 | print(ds) 73 | print(kwargs.get("tomorrow_ds")) - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ 74 | c = get_current_context() 75 | c.get("execution_date") | -AIR301_context.py:75:11: AIR301 `execution_date` is removed in Airflow 3.0 +AIR301 `execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:75:11 | 73 | print(kwargs.get("tomorrow_ds")) 74 | c = get_current_context() 75 | c.get("execution_date") - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ | -AIR301_context.py:87:49: AIR301 `conf` is removed in Airflow 3.0 +AIR301 `conf` is removed in Airflow 3.0 + --> AIR301_context.py:87:49 | 85 | @task() 86 | def access_invalid_key_task(**context): 87 | print("access invalid key", context.get("conf")) - | ^^^^^^ AIR301 + | ^^^^^^ 88 | 89 | @task() | -AIR301_context.py:90:42: AIR301 `execution_date` is removed in Airflow 3.0 +AIR301 `execution_date` is removed in Airflow 3.0 + --> AIR301_context.py:90:42 | 89 | @task() 90 | def access_invalid_key_explicit_task(execution_date): - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 91 | print(execution_date) | -AIR301_context.py:111:5: AIR301 [*] `schedule_interval` is removed in Airflow 3.0 +AIR301 [*] `schedule_interval` is removed in Airflow 3.0 + --> AIR301_context.py:111:5 | 109 | with DAG( 110 | dag_id="example_dag", 111 | schedule_interval="@daily", - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 112 | start_date=datetime(2023, 1, 1), 113 | template_searchpath=["/templates"], | - = help: Use `schedule` instead +help: Use `schedule` instead ℹ Safe fix 108 108 | @@ -316,11 +348,12 @@ AIR301_context.py:111:5: AIR301 [*] `schedule_interval` is removed in Airflow 3. 113 113 | template_searchpath=["/templates"], 114 114 | ) as dag: -AIR301_context.py:135:23: AIR301 `next_ds` is removed in Airflow 3.0 +AIR301 `next_ds` is removed in Airflow 3.0 + --> AIR301_context.py:135:23 | 134 | class CustomOperator(BaseOperator): 135 | def execute(self, next_ds, context): - | ^^^^^^^ AIR301 + | ^^^^^^^ 136 | execution_date = context["execution_date"] 137 | next_ds = context["next_ds"] | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_names.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_names.py.snap index 7a55d729e6..901d5f7628 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_names.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_names.py.snap @@ -1,294 +1,326 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR301_names.py:38:1: AIR301 `airflow.PY36` is removed in Airflow 3.0 +AIR301 `airflow.PY36` is removed in Airflow 3.0 + --> AIR301_names.py:38:1 | 37 | # airflow root 38 | PY36, PY37, PY38, PY39, PY310, PY311, PY312 - | ^^^^ AIR301 + | ^^^^ 39 | 40 | # airflow.api_connexion.security | - = help: Use `sys.version_info` instead +help: Use `sys.version_info` instead -AIR301_names.py:38:7: AIR301 `airflow.PY37` is removed in Airflow 3.0 +AIR301 `airflow.PY37` is removed in Airflow 3.0 + --> AIR301_names.py:38:7 | 37 | # airflow root 38 | PY36, PY37, PY38, PY39, PY310, PY311, PY312 - | ^^^^ AIR301 + | ^^^^ 39 | 40 | # airflow.api_connexion.security | - = help: Use `sys.version_info` instead +help: Use `sys.version_info` instead -AIR301_names.py:38:13: AIR301 `airflow.PY38` is removed in Airflow 3.0 +AIR301 `airflow.PY38` is removed in Airflow 3.0 + --> AIR301_names.py:38:13 | 37 | # airflow root 38 | PY36, PY37, PY38, PY39, PY310, PY311, PY312 - | ^^^^ AIR301 + | ^^^^ 39 | 40 | # airflow.api_connexion.security | - = help: Use `sys.version_info` instead +help: Use `sys.version_info` instead -AIR301_names.py:38:19: AIR301 `airflow.PY39` is removed in Airflow 3.0 +AIR301 `airflow.PY39` is removed in Airflow 3.0 + --> AIR301_names.py:38:19 | 37 | # airflow root 38 | PY36, PY37, PY38, PY39, PY310, PY311, PY312 - | ^^^^ AIR301 + | ^^^^ 39 | 40 | # airflow.api_connexion.security | - = help: Use `sys.version_info` instead +help: Use `sys.version_info` instead -AIR301_names.py:38:25: AIR301 `airflow.PY310` is removed in Airflow 3.0 +AIR301 `airflow.PY310` is removed in Airflow 3.0 + --> AIR301_names.py:38:25 | 37 | # airflow root 38 | PY36, PY37, PY38, PY39, PY310, PY311, PY312 - | ^^^^^ AIR301 + | ^^^^^ 39 | 40 | # airflow.api_connexion.security | - = help: Use `sys.version_info` instead +help: Use `sys.version_info` instead -AIR301_names.py:38:32: AIR301 `airflow.PY311` is removed in Airflow 3.0 +AIR301 `airflow.PY311` is removed in Airflow 3.0 + --> AIR301_names.py:38:32 | 37 | # airflow root 38 | PY36, PY37, PY38, PY39, PY310, PY311, PY312 - | ^^^^^ AIR301 + | ^^^^^ 39 | 40 | # airflow.api_connexion.security | - = help: Use `sys.version_info` instead +help: Use `sys.version_info` instead -AIR301_names.py:38:39: AIR301 `airflow.PY312` is removed in Airflow 3.0 +AIR301 `airflow.PY312` is removed in Airflow 3.0 + --> AIR301_names.py:38:39 | 37 | # airflow root 38 | PY36, PY37, PY38, PY39, PY310, PY311, PY312 - | ^^^^^ AIR301 + | ^^^^^ 39 | 40 | # airflow.api_connexion.security | - = help: Use `sys.version_info` instead +help: Use `sys.version_info` instead -AIR301_names.py:41:1: AIR301 `airflow.api_connexion.security.requires_access` is removed in Airflow 3.0 +AIR301 `airflow.api_connexion.security.requires_access` is removed in Airflow 3.0 + --> AIR301_names.py:41:1 | 40 | # airflow.api_connexion.security 41 | requires_access - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ 42 | 43 | # airflow.contrib.* | - = help: Use `airflow.api_fastapi.core_api.security.requires_access_*` instead +help: Use `airflow.api_fastapi.core_api.security.requires_access_*` instead -AIR301_names.py:44:1: AIR301 `airflow.contrib.aws_athena_hook.AWSAthenaHook` is removed in Airflow 3.0 +AIR301 `airflow.contrib.aws_athena_hook.AWSAthenaHook` is removed in Airflow 3.0 + --> AIR301_names.py:44:1 | 43 | # airflow.contrib.* 44 | AWSAthenaHook() - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ | - = help: The whole `airflow.contrib` module has been removed. +help: The whole `airflow.contrib` module has been removed. -AIR301_names.py:48:1: AIR301 `airflow.datasets.DatasetAliasEvent` is removed in Airflow 3.0 +AIR301 `airflow.datasets.DatasetAliasEvent` is removed in Airflow 3.0 + --> AIR301_names.py:48:1 | 47 | # airflow.datasets 48 | DatasetAliasEvent() - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ | -AIR301_names.py:52:1: AIR301 `airflow.operators.subdag.SubDagOperator` is removed in Airflow 3.0 +AIR301 `airflow.operators.subdag.SubDagOperator` is removed in Airflow 3.0 + --> AIR301_names.py:52:1 | 51 | # airflow.operators.subdag.* 52 | SubDagOperator() - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ | - = help: The whole `airflow.subdag` module has been removed. +help: The whole `airflow.subdag` module has been removed. -AIR301_names.py:61:1: AIR301 `airflow.triggers.external_task.TaskStateTrigger` is removed in Airflow 3.0 +AIR301 `airflow.triggers.external_task.TaskStateTrigger` is removed in Airflow 3.0 + --> AIR301_names.py:61:1 | 60 | # airflow.triggers.external_task 61 | TaskStateTrigger() - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 62 | 63 | # airflow.utils.date | -AIR301_names.py:64:1: AIR301 `airflow.utils.dates.date_range` is removed in Airflow 3.0 +AIR301 `airflow.utils.dates.date_range` is removed in Airflow 3.0 + --> AIR301_names.py:64:1 | 63 | # airflow.utils.date 64 | dates.date_range - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 65 | dates.days_ago | -AIR301_names.py:65:1: AIR301 `airflow.utils.dates.days_ago` is removed in Airflow 3.0 +AIR301 `airflow.utils.dates.days_ago` is removed in Airflow 3.0 + --> AIR301_names.py:65:1 | 63 | # airflow.utils.date 64 | dates.date_range 65 | dates.days_ago - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 66 | 67 | date_range | - = help: Use `pendulum.today('UTC').add(days=-N, ...)` instead +help: Use `pendulum.today('UTC').add(days=-N, ...)` instead -AIR301_names.py:67:1: AIR301 `airflow.utils.dates.date_range` is removed in Airflow 3.0 +AIR301 `airflow.utils.dates.date_range` is removed in Airflow 3.0 + --> AIR301_names.py:67:1 | 65 | dates.days_ago 66 | 67 | date_range - | ^^^^^^^^^^ AIR301 + | ^^^^^^^^^^ 68 | days_ago 69 | infer_time_unit | -AIR301_names.py:68:1: AIR301 `airflow.utils.dates.days_ago` is removed in Airflow 3.0 +AIR301 `airflow.utils.dates.days_ago` is removed in Airflow 3.0 + --> AIR301_names.py:68:1 | 67 | date_range 68 | days_ago - | ^^^^^^^^ AIR301 + | ^^^^^^^^ 69 | infer_time_unit 70 | parse_execution_date | - = help: Use `pendulum.today('UTC').add(days=-N, ...)` instead +help: Use `pendulum.today('UTC').add(days=-N, ...)` instead -AIR301_names.py:69:1: AIR301 `airflow.utils.dates.infer_time_unit` is removed in Airflow 3.0 +AIR301 `airflow.utils.dates.infer_time_unit` is removed in Airflow 3.0 + --> AIR301_names.py:69:1 | 67 | date_range 68 | days_ago 69 | infer_time_unit - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ 70 | parse_execution_date 71 | round_time | -AIR301_names.py:70:1: AIR301 `airflow.utils.dates.parse_execution_date` is removed in Airflow 3.0 +AIR301 `airflow.utils.dates.parse_execution_date` is removed in Airflow 3.0 + --> AIR301_names.py:70:1 | 68 | days_ago 69 | infer_time_unit 70 | parse_execution_date - | ^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^ 71 | round_time 72 | scale_time_units | -AIR301_names.py:71:1: AIR301 `airflow.utils.dates.round_time` is removed in Airflow 3.0 +AIR301 `airflow.utils.dates.round_time` is removed in Airflow 3.0 + --> AIR301_names.py:71:1 | 69 | infer_time_unit 70 | parse_execution_date 71 | round_time - | ^^^^^^^^^^ AIR301 + | ^^^^^^^^^^ 72 | scale_time_units | -AIR301_names.py:72:1: AIR301 `airflow.utils.dates.scale_time_units` is removed in Airflow 3.0 +AIR301 `airflow.utils.dates.scale_time_units` is removed in Airflow 3.0 + --> AIR301_names.py:72:1 | 70 | parse_execution_date 71 | round_time 72 | scale_time_units - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 73 | 74 | # This one was not deprecated. | -AIR301_names.py:79:1: AIR301 `airflow.utils.dag_cycle_tester.test_cycle` is removed in Airflow 3.0 +AIR301 `airflow.utils.dag_cycle_tester.test_cycle` is removed in Airflow 3.0 + --> AIR301_names.py:79:1 | 78 | # airflow.utils.dag_cycle_tester 79 | test_cycle - | ^^^^^^^^^^ AIR301 + | ^^^^^^^^^^ | -AIR301_names.py:83:1: AIR301 `airflow.utils.db.create_session` is removed in Airflow 3.0 +AIR301 `airflow.utils.db.create_session` is removed in Airflow 3.0 + --> AIR301_names.py:83:1 | 82 | # airflow.utils.db 83 | create_session - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 84 | 85 | # airflow.utils.decorators | -AIR301_names.py:86:1: AIR301 `airflow.utils.decorators.apply_defaults` is removed in Airflow 3.0 +AIR301 `airflow.utils.decorators.apply_defaults` is removed in Airflow 3.0 + --> AIR301_names.py:86:1 | 85 | # airflow.utils.decorators 86 | apply_defaults - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 87 | 88 | # airflow.utils.file | - = help: `apply_defaults` is now unconditionally done and can be safely removed. +help: `apply_defaults` is now unconditionally done and can be safely removed. -AIR301_names.py:89:1: AIR301 `airflow.utils.file.mkdirs` is removed in Airflow 3.0 +AIR301 `airflow.utils.file.mkdirs` is removed in Airflow 3.0 + --> AIR301_names.py:89:1 | 88 | # airflow.utils.file 89 | mkdirs - | ^^^^^^ AIR301 + | ^^^^^^ | - = help: Use `pathlib.Path({path}).mkdir` instead +help: Use `pathlib.Path({path}).mkdir` instead -AIR301_names.py:93:1: AIR301 `airflow.utils.state.SHUTDOWN` is removed in Airflow 3.0 +AIR301 `airflow.utils.state.SHUTDOWN` is removed in Airflow 3.0 + --> AIR301_names.py:93:1 | 92 | # airflow.utils.state 93 | SHUTDOWN - | ^^^^^^^^ AIR301 + | ^^^^^^^^ 94 | terminating_states | -AIR301_names.py:94:1: AIR301 `airflow.utils.state.terminating_states` is removed in Airflow 3.0 +AIR301 `airflow.utils.state.terminating_states` is removed in Airflow 3.0 + --> AIR301_names.py:94:1 | 92 | # airflow.utils.state 93 | SHUTDOWN 94 | terminating_states - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 95 | 96 | # airflow.utils.trigger_rule | -AIR301_names.py:97:1: AIR301 `airflow.utils.trigger_rule.TriggerRule.DUMMY` is removed in Airflow 3.0 +AIR301 `airflow.utils.trigger_rule.TriggerRule.DUMMY` is removed in Airflow 3.0 + --> AIR301_names.py:97:1 | 96 | # airflow.utils.trigger_rule 97 | TriggerRule.DUMMY - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 98 | TriggerRule.NONE_FAILED_OR_SKIPPED | -AIR301_names.py:98:1: AIR301 `airflow.utils.trigger_rule.TriggerRule.NONE_FAILED_OR_SKIPPED` is removed in Airflow 3.0 +AIR301 `airflow.utils.trigger_rule.TriggerRule.NONE_FAILED_OR_SKIPPED` is removed in Airflow 3.0 + --> AIR301_names.py:98:1 | 96 | # airflow.utils.trigger_rule 97 | TriggerRule.DUMMY 98 | TriggerRule.NONE_FAILED_OR_SKIPPED - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -AIR301_names.py:102:1: AIR301 `airflow.www.auth.has_access` is removed in Airflow 3.0 +AIR301 `airflow.www.auth.has_access` is removed in Airflow 3.0 + --> AIR301_names.py:102:1 | 101 | # airflow.www.auth 102 | has_access - | ^^^^^^^^^^ AIR301 + | ^^^^^^^^^^ 103 | has_access_dataset | -AIR301_names.py:103:1: AIR301 `airflow.www.auth.has_access_dataset` is removed in Airflow 3.0 +AIR301 `airflow.www.auth.has_access_dataset` is removed in Airflow 3.0 + --> AIR301_names.py:103:1 | 101 | # airflow.www.auth 102 | has_access 103 | has_access_dataset - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 104 | 105 | # airflow.www.utils | -AIR301_names.py:106:1: AIR301 `airflow.www.utils.get_sensitive_variables_fields` is removed in Airflow 3.0 +AIR301 `airflow.www.utils.get_sensitive_variables_fields` is removed in Airflow 3.0 + --> AIR301_names.py:106:1 | 105 | # airflow.www.utils 106 | get_sensitive_variables_fields - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 107 | should_hide_value_for_key | -AIR301_names.py:107:1: AIR301 `airflow.www.utils.should_hide_value_for_key` is removed in Airflow 3.0 +AIR301 `airflow.www.utils.should_hide_value_for_key` is removed in Airflow 3.0 + --> AIR301_names.py:107:1 | 105 | # airflow.www.utils 106 | get_sensitive_variables_fields 107 | should_hide_value_for_key - | ^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_names_fix.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_names_fix.py.snap index e9e738ca15..09537f148b 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_names_fix.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_names_fix.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR301_names_fix.py:17:1: AIR301 [*] `airflow.api_connexion.security.requires_access_dataset` is removed in Airflow 3.0 +AIR301 [*] `airflow.api_connexion.security.requires_access_dataset` is removed in Airflow 3.0 + --> AIR301_names_fix.py:17:1 | 15 | from airflow.security.permissions import RESOURCE_DATASET 16 | 17 | requires_access_dataset() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | DatasetDetails() | - = help: Use `requires_access_asset` from `airflow.api_fastapi.core_api.security` instead. +help: Use `requires_access_asset` from `airflow.api_fastapi.core_api.security` instead. ℹ Safe fix 13 13 | from airflow.metrics.validators import AllowListValidator, BlockListValidator @@ -24,16 +25,17 @@ AIR301_names_fix.py:17:1: AIR301 [*] `airflow.api_connexion.security.requires_ac 19 20 | DatasetDetails() 20 21 | -AIR301_names_fix.py:19:1: AIR301 [*] `airflow.auth.managers.models.resource_details.DatasetDetails` is removed in Airflow 3.0 +AIR301 [*] `airflow.auth.managers.models.resource_details.DatasetDetails` is removed in Airflow 3.0 + --> AIR301_names_fix.py:19:1 | 17 | requires_access_dataset() 18 | 19 | DatasetDetails() - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 20 | 21 | DatasetManager() | - = help: Use `AssetDetails` from `airflow.api_fastapi.auth.managers.models.resource_details` instead. +help: Use `AssetDetails` from `airflow.api_fastapi.auth.managers.models.resource_details` instead. ℹ Safe fix 13 13 | from airflow.metrics.validators import AllowListValidator, BlockListValidator @@ -49,16 +51,17 @@ AIR301_names_fix.py:19:1: AIR301 [*] `airflow.auth.managers.models.resource_deta 21 22 | DatasetManager() 22 23 | dataset_manager() -AIR301_names_fix.py:21:1: AIR301 [*] `airflow.datasets.manager.DatasetManager` is removed in Airflow 3.0 +AIR301 [*] `airflow.datasets.manager.DatasetManager` is removed in Airflow 3.0 + --> AIR301_names_fix.py:21:1 | 19 | DatasetDetails() 20 | 21 | DatasetManager() - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ 22 | dataset_manager() 23 | resolve_dataset_manager() | - = help: Use `AssetManager` from `airflow.assets.manager` instead. +help: Use `AssetManager` from `airflow.assets.manager` instead. ℹ Safe fix 13 13 | from airflow.metrics.validators import AllowListValidator, BlockListValidator @@ -76,14 +79,15 @@ AIR301_names_fix.py:21:1: AIR301 [*] `airflow.datasets.manager.DatasetManager` i 23 24 | resolve_dataset_manager() 24 25 | -AIR301_names_fix.py:22:1: AIR301 [*] `airflow.datasets.manager.dataset_manager` is removed in Airflow 3.0 +AIR301 [*] `airflow.datasets.manager.dataset_manager` is removed in Airflow 3.0 + --> AIR301_names_fix.py:22:1 | 21 | DatasetManager() 22 | dataset_manager() - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ 23 | resolve_dataset_manager() | - = help: Use `asset_manager` from `airflow.assets.manager` instead. +help: Use `asset_manager` from `airflow.assets.manager` instead. ℹ Safe fix 13 13 | from airflow.metrics.validators import AllowListValidator, BlockListValidator @@ -102,16 +106,17 @@ AIR301_names_fix.py:22:1: AIR301 [*] `airflow.datasets.manager.dataset_manager` 24 25 | 25 26 | DatasetLineageInfo() -AIR301_names_fix.py:23:1: AIR301 [*] `airflow.datasets.manager.resolve_dataset_manager` is removed in Airflow 3.0 +AIR301 [*] `airflow.datasets.manager.resolve_dataset_manager` is removed in Airflow 3.0 + --> AIR301_names_fix.py:23:1 | 21 | DatasetManager() 22 | dataset_manager() 23 | resolve_dataset_manager() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^ 24 | 25 | DatasetLineageInfo() | - = help: Use `resolve_asset_manager` from `airflow.assets.manager` instead. +help: Use `resolve_asset_manager` from `airflow.assets.manager` instead. ℹ Safe fix 13 13 | from airflow.metrics.validators import AllowListValidator, BlockListValidator @@ -131,16 +136,17 @@ AIR301_names_fix.py:23:1: AIR301 [*] `airflow.datasets.manager.resolve_dataset_m 25 26 | DatasetLineageInfo() 26 27 | -AIR301_names_fix.py:25:1: AIR301 [*] `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0 +AIR301 [*] `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0 + --> AIR301_names_fix.py:25:1 | 23 | resolve_dataset_manager() 24 | 25 | DatasetLineageInfo() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 26 | 27 | AllowListValidator() | - = help: Use `AssetLineageInfo` from `airflow.lineage.hook` instead. +help: Use `AssetLineageInfo` from `airflow.lineage.hook` instead. ℹ Safe fix 9 9 | dataset_manager, @@ -161,15 +167,16 @@ AIR301_names_fix.py:25:1: AIR301 [*] `airflow.lineage.hook.DatasetLineageInfo` i 27 27 | AllowListValidator() 28 28 | BlockListValidator() -AIR301_names_fix.py:27:1: AIR301 [*] `airflow.metrics.validators.AllowListValidator` is removed in Airflow 3.0 +AIR301 [*] `airflow.metrics.validators.AllowListValidator` is removed in Airflow 3.0 + --> AIR301_names_fix.py:27:1 | 25 | DatasetLineageInfo() 26 | 27 | AllowListValidator() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 28 | BlockListValidator() | - = help: Use `PatternAllowListValidator` from `airflow.metrics.validators` instead. +help: Use `PatternAllowListValidator` from `airflow.metrics.validators` instead. ℹ Safe fix 10 10 | resolve_dataset_manager, @@ -190,15 +197,16 @@ AIR301_names_fix.py:27:1: AIR301 [*] `airflow.metrics.validators.AllowListValida 29 29 | 30 30 | load_connections() -AIR301_names_fix.py:28:1: AIR301 [*] `airflow.metrics.validators.BlockListValidator` is removed in Airflow 3.0 +AIR301 [*] `airflow.metrics.validators.BlockListValidator` is removed in Airflow 3.0 + --> AIR301_names_fix.py:28:1 | 27 | AllowListValidator() 28 | BlockListValidator() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 29 | 30 | load_connections() | - = help: Use `PatternBlockListValidator` from `airflow.metrics.validators` instead. +help: Use `PatternBlockListValidator` from `airflow.metrics.validators` instead. ℹ Safe fix 10 10 | resolve_dataset_manager, @@ -219,16 +227,17 @@ AIR301_names_fix.py:28:1: AIR301 [*] `airflow.metrics.validators.BlockListValida 30 30 | load_connections() 31 31 | -AIR301_names_fix.py:30:1: AIR301 [*] `airflow.secrets.local_filesystem.load_connections` is removed in Airflow 3.0 +AIR301 [*] `airflow.secrets.local_filesystem.load_connections` is removed in Airflow 3.0 + --> AIR301_names_fix.py:30:1 | 28 | BlockListValidator() 29 | 30 | load_connections() - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 31 | 32 | RESOURCE_DATASET | - = help: Use `load_connections_dict` from `airflow.secrets.local_filesystem` instead. +help: Use `load_connections_dict` from `airflow.secrets.local_filesystem` instead. ℹ Safe fix 11 11 | ) @@ -249,14 +258,15 @@ AIR301_names_fix.py:30:1: AIR301 [*] `airflow.secrets.local_filesystem.load_conn 32 32 | RESOURCE_DATASET 33 33 | -AIR301_names_fix.py:32:1: AIR301 [*] `airflow.security.permissions.RESOURCE_DATASET` is removed in Airflow 3.0 +AIR301 [*] `airflow.security.permissions.RESOURCE_DATASET` is removed in Airflow 3.0 + --> AIR301_names_fix.py:32:1 | 30 | load_connections() 31 | 32 | RESOURCE_DATASET - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ | - = help: Use `RESOURCE_ASSET` from `airflow.security.permissions` instead. +help: Use `RESOURCE_ASSET` from `airflow.security.permissions` instead. ℹ Safe fix 12 12 | from airflow.lineage.hook import DatasetLineageInfo @@ -277,15 +287,16 @@ AIR301_names_fix.py:32:1: AIR301 [*] `airflow.security.permissions.RESOURCE_DATA 34 34 | 35 35 | from airflow.listeners.spec.dataset import ( -AIR301_names_fix.py:40:1: AIR301 [*] `airflow.listeners.spec.dataset.on_dataset_created` is removed in Airflow 3.0 +AIR301 [*] `airflow.listeners.spec.dataset.on_dataset_created` is removed in Airflow 3.0 + --> AIR301_names_fix.py:40:1 | 38 | ) 39 | 40 | on_dataset_created() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 41 | on_dataset_changed() | - = help: Use `on_asset_created` from `airflow.listeners.spec.asset` instead. +help: Use `on_asset_created` from `airflow.listeners.spec.asset` instead. ℹ Safe fix 36 36 | on_dataset_changed, @@ -299,13 +310,14 @@ AIR301_names_fix.py:40:1: AIR301 [*] `airflow.listeners.spec.dataset.on_dataset_ 42 43 | 43 44 | -AIR301_names_fix.py:41:1: AIR301 [*] `airflow.listeners.spec.dataset.on_dataset_changed` is removed in Airflow 3.0 +AIR301 [*] `airflow.listeners.spec.dataset.on_dataset_changed` is removed in Airflow 3.0 + --> AIR301_names_fix.py:41:1 | 40 | on_dataset_created() 41 | on_dataset_changed() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ | - = help: Use `on_asset_changed` from `airflow.listeners.spec.asset` instead. +help: Use `on_asset_changed` from `airflow.listeners.spec.asset` instead. ℹ Safe fix 36 36 | on_dataset_changed, @@ -320,16 +332,17 @@ AIR301_names_fix.py:41:1: AIR301 [*] `airflow.listeners.spec.dataset.on_dataset_ 43 44 | 44 45 | # airflow.operators.python -AIR301_names_fix.py:47:1: AIR301 [*] `airflow.operators.python.get_current_context` is removed in Airflow 3.0 +AIR301 [*] `airflow.operators.python.get_current_context` is removed in Airflow 3.0 + --> AIR301_names_fix.py:47:1 | 45 | from airflow.operators.python import get_current_context 46 | 47 | get_current_context() - | ^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^ 48 | 49 | # airflow.providers.mysql | - = help: Use `get_current_context` from `airflow.sdk` instead. +help: Use `get_current_context` from `airflow.sdk` instead. ℹ Unsafe fix 42 42 | @@ -341,16 +354,17 @@ AIR301_names_fix.py:47:1: AIR301 [*] `airflow.operators.python.get_current_conte 47 47 | get_current_context() 48 48 | -AIR301_names_fix.py:52:1: AIR301 [*] `airflow.providers.mysql.datasets.mysql.sanitize_uri` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.mysql.datasets.mysql.sanitize_uri` is removed in Airflow 3.0 + --> AIR301_names_fix.py:52:1 | 50 | from airflow.providers.mysql.datasets.mysql import sanitize_uri 51 | 52 | sanitize_uri - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 53 | 54 | # airflow.providers.postgres | - = help: Use `sanitize_uri` from `airflow.providers.mysql.assets.mysql` instead. +help: Use `sanitize_uri` from `airflow.providers.mysql.assets.mysql` instead. ℹ Unsafe fix 47 47 | get_current_context() @@ -362,16 +376,17 @@ AIR301_names_fix.py:52:1: AIR301 [*] `airflow.providers.mysql.datasets.mysql.san 52 52 | sanitize_uri 53 53 | -AIR301_names_fix.py:57:1: AIR301 [*] `airflow.providers.postgres.datasets.postgres.sanitize_uri` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.postgres.datasets.postgres.sanitize_uri` is removed in Airflow 3.0 + --> AIR301_names_fix.py:57:1 | 55 | from airflow.providers.postgres.datasets.postgres import sanitize_uri 56 | 57 | sanitize_uri - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 58 | 59 | # airflow.providers.trino | - = help: Use `sanitize_uri` from `airflow.providers.postgres.assets.postgres` instead. +help: Use `sanitize_uri` from `airflow.providers.postgres.assets.postgres` instead. ℹ Unsafe fix 52 52 | sanitize_uri @@ -383,16 +398,17 @@ AIR301_names_fix.py:57:1: AIR301 [*] `airflow.providers.postgres.datasets.postgr 57 57 | sanitize_uri 58 58 | -AIR301_names_fix.py:62:1: AIR301 [*] `airflow.providers.trino.datasets.trino.sanitize_uri` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.trino.datasets.trino.sanitize_uri` is removed in Airflow 3.0 + --> AIR301_names_fix.py:62:1 | 60 | from airflow.providers.trino.datasets.trino import sanitize_uri 61 | 62 | sanitize_uri - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 63 | 64 | # airflow.notifications.basenotifier | - = help: Use `sanitize_uri` from `airflow.providers.trino.assets.trino` instead. +help: Use `sanitize_uri` from `airflow.providers.trino.assets.trino` instead. ℹ Unsafe fix 57 57 | sanitize_uri @@ -404,16 +420,17 @@ AIR301_names_fix.py:62:1: AIR301 [*] `airflow.providers.trino.datasets.trino.san 62 62 | sanitize_uri 63 63 | -AIR301_names_fix.py:67:1: AIR301 [*] `airflow.notifications.basenotifier.BaseNotifier` is removed in Airflow 3.0 +AIR301 [*] `airflow.notifications.basenotifier.BaseNotifier` is removed in Airflow 3.0 + --> AIR301_names_fix.py:67:1 | 65 | from airflow.notifications.basenotifier import BaseNotifier 66 | 67 | BaseNotifier() - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 68 | 69 | # airflow.auth.manager | - = help: Use `BaseNotifier` from `airflow.sdk.bases.notifier` instead. +help: Use `BaseNotifier` from `airflow.sdk.bases.notifier` instead. ℹ Unsafe fix 62 62 | sanitize_uri @@ -425,14 +442,15 @@ AIR301_names_fix.py:67:1: AIR301 [*] `airflow.notifications.basenotifier.BaseNot 67 67 | BaseNotifier() 68 68 | -AIR301_names_fix.py:72:1: AIR301 [*] `airflow.auth.managers.base_auth_manager.BaseAuthManager` is removed in Airflow 3.0 +AIR301 [*] `airflow.auth.managers.base_auth_manager.BaseAuthManager` is removed in Airflow 3.0 + --> AIR301_names_fix.py:72:1 | 70 | from airflow.auth.managers.base_auth_manager import BaseAuthManager 71 | 72 | BaseAuthManager() - | ^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^ | - = help: Use `BaseAuthManager` from `airflow.api_fastapi.auth.managers.base_auth_manager` instead. +help: Use `BaseAuthManager` from `airflow.api_fastapi.auth.managers.base_auth_manager` instead. ℹ Unsafe fix 67 67 | BaseNotifier() @@ -444,14 +462,15 @@ AIR301_names_fix.py:72:1: AIR301 [*] `airflow.auth.managers.base_auth_manager.Ba 72 72 | BaseAuthManager() 73 73 | -AIR301_names_fix.py:87:1: AIR301 [*] `airflow.configuration.get` is removed in Airflow 3.0 +AIR301 [*] `airflow.configuration.get` is removed in Airflow 3.0 + --> AIR301_names_fix.py:87:1 | 86 | # airflow.configuration 87 | get, getboolean, getfloat, getint, has_option, remove_option, as_dict, set - | ^^^ AIR301 + | ^^^ 88 | from airflow.hooks.base_hook import BaseHook | - = help: Use `conf.get` from `airflow.configuration` instead. +help: Use `conf.get` from `airflow.configuration` instead. ℹ Safe fix 81 81 | has_option, @@ -467,14 +486,15 @@ AIR301_names_fix.py:87:1: AIR301 [*] `airflow.configuration.get` is removed in A 89 90 | 90 91 | # airflow.hooks -AIR301_names_fix.py:87:6: AIR301 [*] `airflow.configuration.getboolean` is removed in Airflow 3.0 +AIR301 [*] `airflow.configuration.getboolean` is removed in Airflow 3.0 + --> AIR301_names_fix.py:87:6 | 86 | # airflow.configuration 87 | get, getboolean, getfloat, getint, has_option, remove_option, as_dict, set - | ^^^^^^^^^^ AIR301 + | ^^^^^^^^^^ 88 | from airflow.hooks.base_hook import BaseHook | - = help: Use `conf.getboolean` from `airflow.configuration` instead. +help: Use `conf.getboolean` from `airflow.configuration` instead. ℹ Safe fix 81 81 | has_option, @@ -490,14 +510,15 @@ AIR301_names_fix.py:87:6: AIR301 [*] `airflow.configuration.getboolean` is remov 89 90 | 90 91 | # airflow.hooks -AIR301_names_fix.py:87:18: AIR301 [*] `airflow.configuration.getfloat` is removed in Airflow 3.0 +AIR301 [*] `airflow.configuration.getfloat` is removed in Airflow 3.0 + --> AIR301_names_fix.py:87:18 | 86 | # airflow.configuration 87 | get, getboolean, getfloat, getint, has_option, remove_option, as_dict, set - | ^^^^^^^^ AIR301 + | ^^^^^^^^ 88 | from airflow.hooks.base_hook import BaseHook | - = help: Use `conf.getfloat` from `airflow.configuration` instead. +help: Use `conf.getfloat` from `airflow.configuration` instead. ℹ Safe fix 81 81 | has_option, @@ -513,14 +534,15 @@ AIR301_names_fix.py:87:18: AIR301 [*] `airflow.configuration.getfloat` is remove 89 90 | 90 91 | # airflow.hooks -AIR301_names_fix.py:87:28: AIR301 [*] `airflow.configuration.getint` is removed in Airflow 3.0 +AIR301 [*] `airflow.configuration.getint` is removed in Airflow 3.0 + --> AIR301_names_fix.py:87:28 | 86 | # airflow.configuration 87 | get, getboolean, getfloat, getint, has_option, remove_option, as_dict, set - | ^^^^^^ AIR301 + | ^^^^^^ 88 | from airflow.hooks.base_hook import BaseHook | - = help: Use `conf.getint` from `airflow.configuration` instead. +help: Use `conf.getint` from `airflow.configuration` instead. ℹ Safe fix 81 81 | has_option, @@ -536,14 +558,15 @@ AIR301_names_fix.py:87:28: AIR301 [*] `airflow.configuration.getint` is removed 89 90 | 90 91 | # airflow.hooks -AIR301_names_fix.py:87:36: AIR301 [*] `airflow.configuration.has_option` is removed in Airflow 3.0 +AIR301 [*] `airflow.configuration.has_option` is removed in Airflow 3.0 + --> AIR301_names_fix.py:87:36 | 86 | # airflow.configuration 87 | get, getboolean, getfloat, getint, has_option, remove_option, as_dict, set - | ^^^^^^^^^^ AIR301 + | ^^^^^^^^^^ 88 | from airflow.hooks.base_hook import BaseHook | - = help: Use `conf.has_option` from `airflow.configuration` instead. +help: Use `conf.has_option` from `airflow.configuration` instead. ℹ Safe fix 81 81 | has_option, @@ -559,14 +582,15 @@ AIR301_names_fix.py:87:36: AIR301 [*] `airflow.configuration.has_option` is remo 89 90 | 90 91 | # airflow.hooks -AIR301_names_fix.py:87:48: AIR301 [*] `airflow.configuration.remove_option` is removed in Airflow 3.0 +AIR301 [*] `airflow.configuration.remove_option` is removed in Airflow 3.0 + --> AIR301_names_fix.py:87:48 | 86 | # airflow.configuration 87 | get, getboolean, getfloat, getint, has_option, remove_option, as_dict, set - | ^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^ 88 | from airflow.hooks.base_hook import BaseHook | - = help: Use `conf.remove_option` from `airflow.configuration` instead. +help: Use `conf.remove_option` from `airflow.configuration` instead. ℹ Safe fix 81 81 | has_option, @@ -582,14 +606,15 @@ AIR301_names_fix.py:87:48: AIR301 [*] `airflow.configuration.remove_option` is r 89 90 | 90 91 | # airflow.hooks -AIR301_names_fix.py:87:63: AIR301 [*] `airflow.configuration.as_dict` is removed in Airflow 3.0 +AIR301 [*] `airflow.configuration.as_dict` is removed in Airflow 3.0 + --> AIR301_names_fix.py:87:63 | 86 | # airflow.configuration 87 | get, getboolean, getfloat, getint, has_option, remove_option, as_dict, set - | ^^^^^^^ AIR301 + | ^^^^^^^ 88 | from airflow.hooks.base_hook import BaseHook | - = help: Use `conf.as_dict` from `airflow.configuration` instead. +help: Use `conf.as_dict` from `airflow.configuration` instead. ℹ Safe fix 81 81 | has_option, @@ -605,14 +630,15 @@ AIR301_names_fix.py:87:63: AIR301 [*] `airflow.configuration.as_dict` is removed 89 90 | 90 91 | # airflow.hooks -AIR301_names_fix.py:87:72: AIR301 [*] `airflow.configuration.set` is removed in Airflow 3.0 +AIR301 [*] `airflow.configuration.set` is removed in Airflow 3.0 + --> AIR301_names_fix.py:87:72 | 86 | # airflow.configuration 87 | get, getboolean, getfloat, getint, has_option, remove_option, as_dict, set - | ^^^ AIR301 + | ^^^ 88 | from airflow.hooks.base_hook import BaseHook | - = help: Use `conf.set` from `airflow.configuration` instead. +help: Use `conf.set` from `airflow.configuration` instead. ℹ Safe fix 81 81 | has_option, @@ -628,15 +654,16 @@ AIR301_names_fix.py:87:72: AIR301 [*] `airflow.configuration.set` is removed in 89 90 | 90 91 | # airflow.hooks -AIR301_names_fix.py:91:1: AIR301 [*] `airflow.hooks.base_hook.BaseHook` is removed in Airflow 3.0 +AIR301 [*] `airflow.hooks.base_hook.BaseHook` is removed in Airflow 3.0 + --> AIR301_names_fix.py:91:1 | 90 | # airflow.hooks 91 | BaseHook() - | ^^^^^^^^ AIR301 + | ^^^^^^^^ 92 | 93 | from airflow.sensors.base_sensor_operator import BaseSensorOperator | - = help: Use `BaseHook` from `airflow.hooks.base` instead. +help: Use `BaseHook` from `airflow.hooks.base` instead. ℹ Unsafe fix 85 85 | @@ -648,14 +675,15 @@ AIR301_names_fix.py:91:1: AIR301 [*] `airflow.hooks.base_hook.BaseHook` is remov 90 90 | # airflow.hooks 91 91 | BaseHook() -AIR301_names_fix.py:96:1: AIR301 [*] `airflow.sensors.base_sensor_operator.BaseSensorOperator` is removed in Airflow 3.0 +AIR301 [*] `airflow.sensors.base_sensor_operator.BaseSensorOperator` is removed in Airflow 3.0 + --> AIR301_names_fix.py:96:1 | 95 | # airflow.sensors.base_sensor_operator 96 | BaseSensorOperator() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 97 | BaseHook() | - = help: Use `BaseSensorOperator` from `airflow.sdk.bases.sensor` instead. +help: Use `BaseSensorOperator` from `airflow.sdk.bases.sensor` instead. ℹ Unsafe fix 90 90 | # airflow.hooks @@ -667,16 +695,17 @@ AIR301_names_fix.py:96:1: AIR301 [*] `airflow.sensors.base_sensor_operator.BaseS 95 95 | # airflow.sensors.base_sensor_operator 96 96 | BaseSensorOperator() -AIR301_names_fix.py:97:1: AIR301 [*] `airflow.hooks.base_hook.BaseHook` is removed in Airflow 3.0 +AIR301 [*] `airflow.hooks.base_hook.BaseHook` is removed in Airflow 3.0 + --> AIR301_names_fix.py:97:1 | 95 | # airflow.sensors.base_sensor_operator 96 | BaseSensorOperator() 97 | BaseHook() - | ^^^^^^^^ AIR301 + | ^^^^^^^^ 98 | 99 | from airflow.utils.helpers import chain as helper_chain | - = help: Use `BaseHook` from `airflow.hooks.base` instead. +help: Use `BaseHook` from `airflow.hooks.base` instead. ℹ Unsafe fix 85 85 | @@ -693,14 +722,15 @@ AIR301_names_fix.py:97:1: AIR301 [*] `airflow.hooks.base_hook.BaseHook` is remov 95 95 | # airflow.sensors.base_sensor_operator 96 96 | BaseSensorOperator() -AIR301_names_fix.py:103:1: AIR301 [*] `airflow.utils.helpers.chain` is removed in Airflow 3.0 +AIR301 [*] `airflow.utils.helpers.chain` is removed in Airflow 3.0 + --> AIR301_names_fix.py:103:1 | 102 | # airflow.utils.helpers 103 | helper_chain - | ^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^ 104 | helper_cross_downstream | - = help: Use `chain` from `airflow.sdk` instead. +help: Use `chain` from `airflow.sdk` instead. ℹ Safe fix 98 98 | @@ -715,16 +745,17 @@ AIR301_names_fix.py:103:1: AIR301 [*] `airflow.utils.helpers.chain` is removed i 105 106 | 106 107 | # airflow.utils.file -AIR301_names_fix.py:104:1: AIR301 [*] `airflow.utils.helpers.cross_downstream` is removed in Airflow 3.0 +AIR301 [*] `airflow.utils.helpers.cross_downstream` is removed in Airflow 3.0 + --> AIR301_names_fix.py:104:1 | 102 | # airflow.utils.helpers 103 | helper_chain 104 | helper_cross_downstream - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^ 105 | 106 | # airflow.utils.file | - = help: Use `cross_downstream` from `airflow.sdk` instead. +help: Use `cross_downstream` from `airflow.sdk` instead. ℹ Safe fix 98 98 | @@ -740,16 +771,17 @@ AIR301_names_fix.py:104:1: AIR301 [*] `airflow.utils.helpers.cross_downstream` i 106 107 | # airflow.utils.file 107 108 | from airflow.utils.file import TemporaryDirectory -AIR301_names_fix.py:109:1: AIR301 [*] `airflow.utils.file.TemporaryDirectory` is removed in Airflow 3.0 +AIR301 [*] `airflow.utils.file.TemporaryDirectory` is removed in Airflow 3.0 + --> AIR301_names_fix.py:109:1 | 107 | from airflow.utils.file import TemporaryDirectory 108 | 109 | TemporaryDirectory() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 110 | 111 | from airflow.utils.log import secrets_masker | - = help: Use `TemporaryDirectory` from `tempfile` instead. +help: Use `TemporaryDirectory` from `tempfile` instead. ℹ Unsafe fix 104 104 | helper_cross_downstream @@ -761,13 +793,14 @@ AIR301_names_fix.py:109:1: AIR301 [*] `airflow.utils.file.TemporaryDirectory` is 109 109 | TemporaryDirectory() 110 110 | -AIR301_names_fix.py:114:1: AIR301 [*] `airflow.utils.log.secrets_masker` is removed in Airflow 3.0 +AIR301 [*] `airflow.utils.log.secrets_masker` is removed in Airflow 3.0 + --> AIR301_names_fix.py:114:1 | 113 | # airflow.utils.log 114 | secrets_masker - | ^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^ | - = help: Use `secrets_masker` from `airflow.sdk.execution_time` instead. +help: Use `secrets_masker` from `airflow.sdk.execution_time` instead. ℹ Unsafe fix 108 108 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_provider_names_fix.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_provider_names_fix.py.snap index 6c53d5dd66..825dad7e21 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_provider_names_fix.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR301_AIR301_provider_names_fix.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR301_provider_names_fix.py:11:1: AIR301 [*] `airflow.providers.amazon.aws.auth_manager.avp.entities.AvpEntities.DATASET` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.amazon.aws.auth_manager.avp.entities.AvpEntities.DATASET` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:11:1 | 9 | from airflow.security.permissions import RESOURCE_DATASET 10 | 11 | AvpEntities.DATASET - | ^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^ 12 | 13 | # airflow.providers.openlineage.utils.utils | - = help: Use `AvpEntities.ASSET` from `airflow.providers.amazon.aws.auth_manager.avp.entities` instead. +help: Use `AvpEntities.ASSET` from `airflow.providers.amazon.aws.auth_manager.avp.entities` instead. ℹ Safe fix 8 8 | from airflow.secrets.local_filesystem import load_connections @@ -22,14 +23,15 @@ AIR301_provider_names_fix.py:11:1: AIR301 [*] `airflow.providers.amazon.aws.auth 13 13 | # airflow.providers.openlineage.utils.utils 14 14 | DatasetInfo() -AIR301_provider_names_fix.py:14:1: AIR301 [*] `airflow.providers.openlineage.utils.utils.DatasetInfo` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.openlineage.utils.utils.DatasetInfo` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:14:1 | 13 | # airflow.providers.openlineage.utils.utils 14 | DatasetInfo() - | ^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^ 15 | translate_airflow_dataset() | - = help: Use `AssetInfo` from `airflow.providers.openlineage.utils.utils` instead. +help: Use `AssetInfo` from `airflow.providers.openlineage.utils.utils` instead. ℹ Safe fix 4 4 | from airflow.providers.openlineage.utils.utils import ( @@ -49,16 +51,17 @@ AIR301_provider_names_fix.py:14:1: AIR301 [*] `airflow.providers.openlineage.uti 16 17 | 17 18 | # airflow.secrets.local_filesystem -AIR301_provider_names_fix.py:15:1: AIR301 [*] `airflow.providers.openlineage.utils.utils.translate_airflow_dataset` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.openlineage.utils.utils.translate_airflow_dataset` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:15:1 | 13 | # airflow.providers.openlineage.utils.utils 14 | DatasetInfo() 15 | translate_airflow_dataset() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | # airflow.secrets.local_filesystem | - = help: Use `translate_airflow_asset` from `airflow.providers.openlineage.utils.utils` instead. +help: Use `translate_airflow_asset` from `airflow.providers.openlineage.utils.utils` instead. ℹ Safe fix 4 4 | from airflow.providers.openlineage.utils.utils import ( @@ -78,15 +81,16 @@ AIR301_provider_names_fix.py:15:1: AIR301 [*] `airflow.providers.openlineage.uti 17 18 | # airflow.secrets.local_filesystem 18 19 | load_connections() -AIR301_provider_names_fix.py:18:1: AIR301 [*] `airflow.secrets.local_filesystem.load_connections` is removed in Airflow 3.0 +AIR301 [*] `airflow.secrets.local_filesystem.load_connections` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:18:1 | 17 | # airflow.secrets.local_filesystem 18 | load_connections() - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 19 | 20 | # airflow.security.permissions | - = help: Use `load_connections_dict` from `airflow.secrets.local_filesystem` instead. +help: Use `load_connections_dict` from `airflow.secrets.local_filesystem` instead. ℹ Safe fix 5 5 | DatasetInfo, @@ -107,15 +111,16 @@ AIR301_provider_names_fix.py:18:1: AIR301 [*] `airflow.secrets.local_filesystem. 20 20 | # airflow.security.permissions 21 21 | RESOURCE_DATASET -AIR301_provider_names_fix.py:21:1: AIR301 [*] `airflow.security.permissions.RESOURCE_DATASET` is removed in Airflow 3.0 +AIR301 [*] `airflow.security.permissions.RESOURCE_DATASET` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:21:1 | 20 | # airflow.security.permissions 21 | RESOURCE_DATASET - | ^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^ 22 | 23 | from airflow.providers.amazon.aws.datasets.s3 import ( | - = help: Use `RESOURCE_ASSET` from `airflow.security.permissions` instead. +help: Use `RESOURCE_ASSET` from `airflow.security.permissions` instead. ℹ Safe fix 6 6 | translate_airflow_dataset, @@ -136,15 +141,16 @@ AIR301_provider_names_fix.py:21:1: AIR301 [*] `airflow.security.permissions.RESO 23 23 | from airflow.providers.amazon.aws.datasets.s3 import ( 24 24 | convert_dataset_to_openlineage as s3_convert_dataset_to_openlineage, -AIR301_provider_names_fix.py:28:1: AIR301 [*] `airflow.providers.amazon.aws.datasets.s3.create_dataset` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.amazon.aws.datasets.s3.create_dataset` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:28:1 | 26 | from airflow.providers.amazon.aws.datasets.s3 import create_dataset as s3_create_dataset 27 | 28 | s3_create_dataset() - | ^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^ 29 | s3_convert_dataset_to_openlineage() | - = help: Use `create_asset` from `airflow.providers.amazon.aws.assets.s3` instead. +help: Use `create_asset` from `airflow.providers.amazon.aws.assets.s3` instead. ℹ Safe fix 24 24 | convert_dataset_to_openlineage as s3_convert_dataset_to_openlineage, @@ -158,15 +164,16 @@ AIR301_provider_names_fix.py:28:1: AIR301 [*] `airflow.providers.amazon.aws.data 30 31 | 31 32 | from airflow.providers.common.io.dataset.file import ( -AIR301_provider_names_fix.py:29:1: AIR301 [*] `airflow.providers.amazon.aws.datasets.s3.convert_dataset_to_openlineage` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.amazon.aws.datasets.s3.convert_dataset_to_openlineage` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:29:1 | 28 | s3_create_dataset() 29 | s3_convert_dataset_to_openlineage() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | from airflow.providers.common.io.dataset.file import ( | - = help: Use `convert_asset_to_openlineage` from `airflow.providers.amazon.aws.assets.s3` instead. +help: Use `convert_asset_to_openlineage` from `airflow.providers.amazon.aws.assets.s3` instead. ℹ Safe fix 24 24 | convert_dataset_to_openlineage as s3_convert_dataset_to_openlineage, @@ -181,16 +188,17 @@ AIR301_provider_names_fix.py:29:1: AIR301 [*] `airflow.providers.amazon.aws.data 31 32 | from airflow.providers.common.io.dataset.file import ( 32 33 | convert_dataset_to_openlineage as io_convert_dataset_to_openlineage, -AIR301_provider_names_fix.py:45:1: AIR301 [*] `airflow.providers.google.datasets.bigquery.create_dataset` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.google.datasets.bigquery.create_dataset` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:45:1 | 43 | ) 44 | 45 | bigquery_create_dataset() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^ 46 | 47 | # airflow.providers.google.datasets.gcs | - = help: Use `create_asset` from `airflow.providers.google.assets.bigquery` instead. +help: Use `create_asset` from `airflow.providers.google.assets.bigquery` instead. ℹ Safe fix 41 41 | from airflow.providers.google.datasets.bigquery import ( @@ -204,15 +212,16 @@ AIR301_provider_names_fix.py:45:1: AIR301 [*] `airflow.providers.google.datasets 47 48 | # airflow.providers.google.datasets.gcs 48 49 | from airflow.providers.google.datasets.gcs import ( -AIR301_provider_names_fix.py:53:1: AIR301 [*] `airflow.providers.google.datasets.gcs.create_dataset` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.google.datasets.gcs.create_dataset` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:53:1 | 51 | from airflow.providers.google.datasets.gcs import create_dataset as gcs_create_dataset 52 | 53 | gcs_create_dataset() - | ^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^ 54 | gcs_convert_dataset_to_openlineage() | - = help: Use `create_asset` from `airflow.providers.google.assets.gcs` instead. +help: Use `create_asset` from `airflow.providers.google.assets.gcs` instead. ℹ Safe fix 49 49 | convert_dataset_to_openlineage as gcs_convert_dataset_to_openlineage, @@ -224,13 +233,14 @@ AIR301_provider_names_fix.py:53:1: AIR301 [*] `airflow.providers.google.datasets 54 |+create_asset() 54 55 | gcs_convert_dataset_to_openlineage() -AIR301_provider_names_fix.py:54:1: AIR301 [*] `airflow.providers.google.datasets.gcs.convert_dataset_to_openlineage` is removed in Airflow 3.0 +AIR301 [*] `airflow.providers.google.datasets.gcs.convert_dataset_to_openlineage` is removed in Airflow 3.0 + --> AIR301_provider_names_fix.py:54:1 | 53 | gcs_create_dataset() 54 | gcs_convert_dataset_to_openlineage() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `convert_asset_to_openlineage` from `airflow.providers.google.assets.gcs` instead. +help: Use `convert_asset_to_openlineage` from `airflow.providers.google.assets.gcs` instead. ℹ Safe fix 49 49 | convert_dataset_to_openlineage as gcs_convert_dataset_to_openlineage, diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_amazon.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_amazon.py.snap index 398278fd91..f7dd72b481 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_amazon.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_amazon.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_amazon.py:14:1: AIR302 [*] `airflow.hooks.S3_hook.S3Hook` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.S3_hook.S3Hook` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:14:1 | 12 | from airflow.sensors.s3_key_sensor import S3KeySensor 13 | 14 | S3Hook() - | ^^^^^^ AIR302 + | ^^^^^^ 15 | provide_bucket_name() | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `S3Hook` from `airflow.providers.amazon.aws.hooks.s3` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `S3Hook` from `airflow.providers.amazon.aws.hooks.s3` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -28,15 +29,16 @@ AIR302_amazon.py:14:1: AIR302 [*] `airflow.hooks.S3_hook.S3Hook` is moved into ` 14 14 | S3Hook() 15 15 | provide_bucket_name() -AIR302_amazon.py:15:1: AIR302 [*] `airflow.hooks.S3_hook.provide_bucket_name` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.S3_hook.provide_bucket_name` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:15:1 | 14 | S3Hook() 15 | provide_bucket_name() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 16 | 17 | GCSToS3Operator() | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `provide_bucket_name` from `airflow.providers.amazon.aws.hooks.s3` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `provide_bucket_name` from `airflow.providers.amazon.aws.hooks.s3` instead. ℹ Unsafe fix 2 2 | @@ -55,16 +57,17 @@ AIR302_amazon.py:15:1: AIR302 [*] `airflow.hooks.S3_hook.provide_bucket_name` is 14 14 | S3Hook() 15 15 | provide_bucket_name() -AIR302_amazon.py:17:1: AIR302 [*] `airflow.operators.gcs_to_s3.GCSToS3Operator` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.gcs_to_s3.GCSToS3Operator` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:17:1 | 15 | provide_bucket_name() 16 | 17 | GCSToS3Operator() - | ^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^ 18 | GoogleApiToS3Operator() 19 | RedshiftToS3Operator() | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `GCSToS3Operator` from `airflow.providers.amazon.aws.transfers.gcs_to_s3` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `GCSToS3Operator` from `airflow.providers.amazon.aws.transfers.gcs_to_s3` instead. ℹ Unsafe fix 4 4 | S3Hook, @@ -81,15 +84,16 @@ AIR302_amazon.py:17:1: AIR302 [*] `airflow.operators.gcs_to_s3.GCSToS3Operator` 14 14 | S3Hook() 15 15 | provide_bucket_name() -AIR302_amazon.py:18:1: AIR302 [*] `airflow.operators.google_api_to_s3_transfer.GoogleApiToS3Operator` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.google_api_to_s3_transfer.GoogleApiToS3Operator` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:18:1 | 17 | GCSToS3Operator() 18 | GoogleApiToS3Operator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 19 | RedshiftToS3Operator() 20 | S3FileTransformOperator() | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `GoogleApiToS3Operator` from `airflow.providers.amazon.aws.transfers.google_api_to_s3` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `GoogleApiToS3Operator` from `airflow.providers.amazon.aws.transfers.google_api_to_s3` instead. ℹ Unsafe fix 5 5 | provide_bucket_name, @@ -105,16 +109,17 @@ AIR302_amazon.py:18:1: AIR302 [*] `airflow.operators.google_api_to_s3_transfer.G 14 14 | S3Hook() 15 15 | provide_bucket_name() -AIR302_amazon.py:19:1: AIR302 [*] `airflow.operators.redshift_to_s3_operator.RedshiftToS3Operator` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.redshift_to_s3_operator.RedshiftToS3Operator` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:19:1 | 17 | GCSToS3Operator() 18 | GoogleApiToS3Operator() 19 | RedshiftToS3Operator() - | ^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^ 20 | S3FileTransformOperator() 21 | S3ToRedshiftOperator() | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `RedshiftToS3Operator` from `airflow.providers.amazon.aws.transfers.redshift_to_s3` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `RedshiftToS3Operator` from `airflow.providers.amazon.aws.transfers.redshift_to_s3` instead. ℹ Unsafe fix 6 6 | ) @@ -129,16 +134,17 @@ AIR302_amazon.py:19:1: AIR302 [*] `airflow.operators.redshift_to_s3_operator.Red 14 14 | S3Hook() 15 15 | provide_bucket_name() -AIR302_amazon.py:20:1: AIR302 [*] `airflow.operators.s3_file_transform_operator.S3FileTransformOperator` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.s3_file_transform_operator.S3FileTransformOperator` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:20:1 | 18 | GoogleApiToS3Operator() 19 | RedshiftToS3Operator() 20 | S3FileTransformOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^ 21 | S3ToRedshiftOperator() 22 | S3KeySensor() | - = help: Install `apache-airflow-providers-amazon>=3.0.0` and use `S3FileTransformOperator` from `airflow.providers.amazon.aws.operators.s3` instead. +help: Install `apache-airflow-providers-amazon>=3.0.0` and use `S3FileTransformOperator` from `airflow.providers.amazon.aws.operators.s3` instead. ℹ Unsafe fix 7 7 | from airflow.operators.gcs_to_s3 import GCSToS3Operator @@ -152,15 +158,16 @@ AIR302_amazon.py:20:1: AIR302 [*] `airflow.operators.s3_file_transform_operator. 14 14 | S3Hook() 15 15 | provide_bucket_name() -AIR302_amazon.py:21:1: AIR302 [*] `airflow.operators.s3_to_redshift_operator.S3ToRedshiftOperator` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.s3_to_redshift_operator.S3ToRedshiftOperator` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:21:1 | 19 | RedshiftToS3Operator() 20 | S3FileTransformOperator() 21 | S3ToRedshiftOperator() - | ^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^ 22 | S3KeySensor() | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `S3ToRedshiftOperator` from `airflow.providers.amazon.aws.transfers.s3_to_redshift` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `S3ToRedshiftOperator` from `airflow.providers.amazon.aws.transfers.s3_to_redshift` instead. ℹ Unsafe fix 8 8 | from airflow.operators.google_api_to_s3_transfer import GoogleApiToS3Operator @@ -173,16 +180,17 @@ AIR302_amazon.py:21:1: AIR302 [*] `airflow.operators.s3_to_redshift_operator.S3T 14 14 | S3Hook() 15 15 | provide_bucket_name() -AIR302_amazon.py:22:1: AIR302 [*] `airflow.sensors.s3_key_sensor.S3KeySensor` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.s3_key_sensor.S3KeySensor` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:22:1 | 20 | S3FileTransformOperator() 21 | S3ToRedshiftOperator() 22 | S3KeySensor() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 23 | 24 | from airflow.operators.google_api_to_s3_transfer import GoogleApiToS3Transfer | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `S3KeySensor` from `airflow.providers.amazon.aws.sensors.s3` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `S3KeySensor` from `airflow.providers.amazon.aws.sensors.s3` instead. ℹ Unsafe fix 9 9 | from airflow.operators.redshift_to_s3_operator import RedshiftToS3Operator @@ -194,16 +202,17 @@ AIR302_amazon.py:22:1: AIR302 [*] `airflow.sensors.s3_key_sensor.S3KeySensor` is 14 14 | S3Hook() 15 15 | provide_bucket_name() -AIR302_amazon.py:26:1: AIR302 [*] `airflow.operators.google_api_to_s3_transfer.GoogleApiToS3Transfer` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.google_api_to_s3_transfer.GoogleApiToS3Transfer` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:26:1 | 24 | from airflow.operators.google_api_to_s3_transfer import GoogleApiToS3Transfer 25 | 26 | GoogleApiToS3Transfer() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | from airflow.operators.redshift_to_s3_operator import RedshiftToS3Transfer | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `GoogleApiToS3Operator` from `airflow.providers.amazon.aws.transfers.google_api_to_s3` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `GoogleApiToS3Operator` from `airflow.providers.amazon.aws.transfers.google_api_to_s3` instead. ℹ Unsafe fix 22 22 | S3KeySensor() @@ -214,16 +223,17 @@ AIR302_amazon.py:26:1: AIR302 [*] `airflow.operators.google_api_to_s3_transfer.G 26 27 | GoogleApiToS3Transfer() 27 28 | -AIR302_amazon.py:30:1: AIR302 [*] `airflow.operators.redshift_to_s3_operator.RedshiftToS3Transfer` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.redshift_to_s3_operator.RedshiftToS3Transfer` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:30:1 | 28 | from airflow.operators.redshift_to_s3_operator import RedshiftToS3Transfer 29 | 30 | RedshiftToS3Transfer() - | ^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^ 31 | 32 | from airflow.operators.s3_to_redshift_operator import S3ToRedshiftTransfer | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `RedshiftToS3Operator` from `airflow.providers.amazon.aws.transfers.redshift_to_s3` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `RedshiftToS3Operator` from `airflow.providers.amazon.aws.transfers.redshift_to_s3` instead. ℹ Unsafe fix 26 26 | GoogleApiToS3Transfer() @@ -234,14 +244,15 @@ AIR302_amazon.py:30:1: AIR302 [*] `airflow.operators.redshift_to_s3_operator.Red 30 31 | RedshiftToS3Transfer() 31 32 | -AIR302_amazon.py:34:1: AIR302 [*] `airflow.operators.s3_to_redshift_operator.S3ToRedshiftTransfer` is moved into `amazon` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.s3_to_redshift_operator.S3ToRedshiftTransfer` is moved into `amazon` provider in Airflow 3.0; + --> AIR302_amazon.py:34:1 | 32 | from airflow.operators.s3_to_redshift_operator import S3ToRedshiftTransfer 33 | 34 | S3ToRedshiftTransfer() - | ^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-amazon>=1.0.0` and use `S3ToRedshiftOperator` from `airflow.providers.amazon.aws.transfers.s3_to_redshift` instead. +help: Install `apache-airflow-providers-amazon>=1.0.0` and use `S3ToRedshiftOperator` from `airflow.providers.amazon.aws.transfers.s3_to_redshift` instead. ℹ Unsafe fix 30 30 | RedshiftToS3Transfer() diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_celery.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_celery.py.snap index 991c2bcad8..8339afac1f 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_celery.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_celery.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_celery.py:9:1: AIR302 [*] `airflow.config_templates.default_celery.DEFAULT_CELERY_CONFIG` is moved into `celery` provider in Airflow 3.0; +AIR302 [*] `airflow.config_templates.default_celery.DEFAULT_CELERY_CONFIG` is moved into `celery` provider in Airflow 3.0; + --> AIR302_celery.py:9:1 | 7 | ) 8 | 9 | DEFAULT_CELERY_CONFIG - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | app | - = help: Install `apache-airflow-providers-celery>=3.3.0` and use `DEFAULT_CELERY_CONFIG` from `airflow.providers.celery.executors.default_celery` instead. +help: Install `apache-airflow-providers-celery>=3.3.0` and use `DEFAULT_CELERY_CONFIG` from `airflow.providers.celery.executors.default_celery` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -25,15 +26,16 @@ AIR302_celery.py:9:1: AIR302 [*] `airflow.config_templates.default_celery.DEFAUL 9 9 | DEFAULT_CELERY_CONFIG 10 10 | -AIR302_celery.py:11:1: AIR302 [*] `airflow.executors.celery_executor.app` is moved into `celery` provider in Airflow 3.0; +AIR302 [*] `airflow.executors.celery_executor.app` is moved into `celery` provider in Airflow 3.0; + --> AIR302_celery.py:11:1 | 9 | DEFAULT_CELERY_CONFIG 10 | 11 | app - | ^^^ AIR302 + | ^^^ 12 | CeleryExecutor() | - = help: Install `apache-airflow-providers-celery>=3.3.0` and use `app` from `airflow.providers.celery.executors.celery_executor_utils` instead. +help: Install `apache-airflow-providers-celery>=3.3.0` and use `app` from `airflow.providers.celery.executors.celery_executor_utils` instead. ℹ Unsafe fix 3 3 | from airflow.config_templates.default_celery import DEFAULT_CELERY_CONFIG @@ -46,13 +48,14 @@ AIR302_celery.py:11:1: AIR302 [*] `airflow.executors.celery_executor.app` is mov 9 9 | DEFAULT_CELERY_CONFIG 10 10 | -AIR302_celery.py:12:1: AIR302 [*] `airflow.executors.celery_executor.CeleryExecutor` is moved into `celery` provider in Airflow 3.0; +AIR302 [*] `airflow.executors.celery_executor.CeleryExecutor` is moved into `celery` provider in Airflow 3.0; + --> AIR302_celery.py:12:1 | 11 | app 12 | CeleryExecutor() - | ^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-celery>=3.3.0` and use `CeleryExecutor` from `airflow.providers.celery.executors.celery_executor` instead. +help: Install `apache-airflow-providers-celery>=3.3.0` and use `CeleryExecutor` from `airflow.providers.celery.executors.celery_executor` instead. ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_common_sql.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_common_sql.py.snap index 22798b4011..992829cd41 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_common_sql.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_common_sql.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_common_sql.py:8:1: AIR302 [*] `airflow.hooks.dbapi.ConnectorProtocol` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.dbapi.ConnectorProtocol` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:8:1 | 6 | ) 7 | 8 | ConnectorProtocol() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ 9 | DbApiHook() | - = help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `ConnectorProtocol` from `airflow.providers.common.sql.hooks.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `ConnectorProtocol` from `airflow.providers.common.sql.hooks.sql` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -23,15 +24,16 @@ AIR302_common_sql.py:8:1: AIR302 [*] `airflow.hooks.dbapi.ConnectorProtocol` is 8 8 | ConnectorProtocol() 9 9 | DbApiHook() -AIR302_common_sql.py:9:1: AIR302 [*] `airflow.hooks.dbapi.DbApiHook` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.dbapi.DbApiHook` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:9:1 | 8 | ConnectorProtocol() 9 | DbApiHook() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 10 | 11 | from airflow.hooks.dbapi_hook import DbApiHook | - = help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `DbApiHook` from `airflow.providers.common.sql.hooks.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `DbApiHook` from `airflow.providers.common.sql.hooks.sql` instead. ℹ Unsafe fix 2 2 | @@ -44,15 +46,16 @@ AIR302_common_sql.py:9:1: AIR302 [*] `airflow.hooks.dbapi.DbApiHook` is moved in 8 8 | ConnectorProtocol() 9 9 | DbApiHook() -AIR302_common_sql.py:14:1: AIR302 [*] `airflow.hooks.dbapi_hook.DbApiHook` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.dbapi_hook.DbApiHook` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:14:1 | 12 | from airflow.operators.check_operator import SQLCheckOperator 13 | 14 | DbApiHook() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 15 | SQLCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `DbApiHook` from `airflow.providers.common.sql.hooks.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `DbApiHook` from `airflow.providers.common.sql.hooks.sql` instead. ℹ Unsafe fix 8 8 | ConnectorProtocol() @@ -65,13 +68,14 @@ AIR302_common_sql.py:14:1: AIR302 [*] `airflow.hooks.dbapi_hook.DbApiHook` is mo 14 14 | DbApiHook() 15 15 | SQLCheckOperator() -AIR302_common_sql.py:15:1: AIR302 [*] `airflow.operators.check_operator.SQLCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.check_operator.SQLCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:15:1 | 14 | DbApiHook() 15 | SQLCheckOperator() - | ^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 9 9 | DbApiHook() @@ -83,15 +87,16 @@ AIR302_common_sql.py:15:1: AIR302 [*] `airflow.operators.check_operator.SQLCheck 14 14 | DbApiHook() 15 15 | SQLCheckOperator() -AIR302_common_sql.py:21:1: AIR302 [*] `airflow.operators.sql.SQLCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.SQLCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:21:1 | 19 | from airflow.operators.sql import SQLCheckOperator 20 | 21 | SQLCheckOperator() - | ^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^ 22 | CheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 16 16 | @@ -103,13 +108,14 @@ AIR302_common_sql.py:21:1: AIR302 [*] `airflow.operators.sql.SQLCheckOperator` i 21 21 | SQLCheckOperator() 22 22 | CheckOperator() -AIR302_common_sql.py:22:1: AIR302 [*] `airflow.operators.check_operator.CheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.check_operator.CheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:22:1 | 21 | SQLCheckOperator() 22 | CheckOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 17 17 | @@ -120,14 +126,15 @@ AIR302_common_sql.py:22:1: AIR302 [*] `airflow.operators.check_operator.CheckOpe 21 22 | SQLCheckOperator() 22 23 | CheckOperator() -AIR302_common_sql.py:27:1: AIR302 [*] `airflow.operators.druid_check_operator.CheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.druid_check_operator.CheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:27:1 | 25 | from airflow.operators.druid_check_operator import CheckOperator 26 | 27 | CheckOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 23 23 | @@ -138,14 +145,15 @@ AIR302_common_sql.py:27:1: AIR302 [*] `airflow.operators.druid_check_operator.Ch 27 28 | CheckOperator() 28 29 | -AIR302_common_sql.py:32:1: AIR302 [*] `airflow.operators.presto_check_operator.CheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.presto_check_operator.CheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:32:1 | 30 | from airflow.operators.presto_check_operator import CheckOperator 31 | 32 | CheckOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 28 28 | @@ -156,16 +164,17 @@ AIR302_common_sql.py:32:1: AIR302 [*] `airflow.operators.presto_check_operator.C 32 33 | CheckOperator() 33 34 | -AIR302_common_sql.py:42:1: AIR302 [*] `airflow.operators.druid_check_operator.DruidCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.druid_check_operator.DruidCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:42:1 | 40 | from airflow.operators.presto_check_operator import PrestoCheckOperator 41 | 42 | DruidCheckOperator() - | ^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^ 43 | PrestoCheckOperator() 44 | IntervalCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 38 38 | ) @@ -176,15 +185,16 @@ AIR302_common_sql.py:42:1: AIR302 [*] `airflow.operators.druid_check_operator.Dr 42 43 | DruidCheckOperator() 43 44 | PrestoCheckOperator() -AIR302_common_sql.py:43:1: AIR302 [*] `airflow.operators.presto_check_operator.PrestoCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.presto_check_operator.PrestoCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:43:1 | 42 | DruidCheckOperator() 43 | PrestoCheckOperator() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 44 | IntervalCheckOperator() 45 | SQLIntervalCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 38 38 | ) @@ -195,15 +205,16 @@ AIR302_common_sql.py:43:1: AIR302 [*] `airflow.operators.presto_check_operator.P 42 43 | DruidCheckOperator() 43 44 | PrestoCheckOperator() -AIR302_common_sql.py:44:1: AIR302 [*] `airflow.operators.check_operator.IntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.check_operator.IntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:44:1 | 42 | DruidCheckOperator() 43 | PrestoCheckOperator() 44 | IntervalCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 45 | SQLIntervalCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 34 34 | @@ -218,14 +229,15 @@ AIR302_common_sql.py:44:1: AIR302 [*] `airflow.operators.check_operator.Interval 42 42 | DruidCheckOperator() 43 43 | PrestoCheckOperator() -AIR302_common_sql.py:45:1: AIR302 [*] `airflow.operators.check_operator.SQLIntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.check_operator.SQLIntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:45:1 | 43 | PrestoCheckOperator() 44 | IntervalCheckOperator() 45 | SQLIntervalCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 34 34 | @@ -240,16 +252,17 @@ AIR302_common_sql.py:45:1: AIR302 [*] `airflow.operators.check_operator.SQLInter 42 42 | DruidCheckOperator() 43 43 | PrestoCheckOperator() -AIR302_common_sql.py:54:1: AIR302 [*] `airflow.operators.presto_check_operator.IntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.presto_check_operator.IntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:54:1 | 52 | from airflow.operators.sql import SQLIntervalCheckOperator 53 | 54 | IntervalCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 55 | SQLIntervalCheckOperator() 56 | PrestoIntervalCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 50 50 | PrestoIntervalCheckOperator, @@ -260,14 +273,15 @@ AIR302_common_sql.py:54:1: AIR302 [*] `airflow.operators.presto_check_operator.I 54 55 | IntervalCheckOperator() 55 56 | SQLIntervalCheckOperator() -AIR302_common_sql.py:55:1: AIR302 [*] `airflow.operators.sql.SQLIntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.SQLIntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:55:1 | 54 | IntervalCheckOperator() 55 | SQLIntervalCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 56 | PrestoIntervalCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 49 49 | IntervalCheckOperator, @@ -279,14 +293,15 @@ AIR302_common_sql.py:55:1: AIR302 [*] `airflow.operators.sql.SQLIntervalCheckOpe 54 54 | IntervalCheckOperator() 55 55 | SQLIntervalCheckOperator() -AIR302_common_sql.py:56:1: AIR302 [*] `airflow.operators.presto_check_operator.PrestoIntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.presto_check_operator.PrestoIntervalCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:56:1 | 54 | IntervalCheckOperator() 55 | SQLIntervalCheckOperator() 56 | PrestoIntervalCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLIntervalCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 50 50 | PrestoIntervalCheckOperator, @@ -297,15 +312,16 @@ AIR302_common_sql.py:56:1: AIR302 [*] `airflow.operators.presto_check_operator.P 54 55 | IntervalCheckOperator() 55 56 | SQLIntervalCheckOperator() -AIR302_common_sql.py:64:1: AIR302 [*] `airflow.operators.check_operator.SQLThresholdCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.check_operator.SQLThresholdCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:64:1 | 62 | ) 63 | 64 | SQLThresholdCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 65 | ThresholdCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLThresholdCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLThresholdCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 57 57 | @@ -319,13 +335,14 @@ AIR302_common_sql.py:64:1: AIR302 [*] `airflow.operators.check_operator.SQLThres 64 64 | SQLThresholdCheckOperator() 65 65 | ThresholdCheckOperator() -AIR302_common_sql.py:65:1: AIR302 [*] `airflow.operators.check_operator.ThresholdCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.check_operator.ThresholdCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:65:1 | 64 | SQLThresholdCheckOperator() 65 | ThresholdCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLThresholdCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLThresholdCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 57 57 | @@ -339,14 +356,15 @@ AIR302_common_sql.py:65:1: AIR302 [*] `airflow.operators.check_operator.Threshol 64 64 | SQLThresholdCheckOperator() 65 65 | ThresholdCheckOperator() -AIR302_common_sql.py:70:1: AIR302 [*] `airflow.operators.sql.SQLThresholdCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.SQLThresholdCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:70:1 | 68 | from airflow.operators.sql import SQLThresholdCheckOperator 69 | 70 | SQLThresholdCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLThresholdCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLThresholdCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 65 65 | ThresholdCheckOperator() @@ -358,15 +376,16 @@ AIR302_common_sql.py:70:1: AIR302 [*] `airflow.operators.sql.SQLThresholdCheckOp 70 70 | SQLThresholdCheckOperator() 71 71 | -AIR302_common_sql.py:78:1: AIR302 [*] `airflow.operators.check_operator.SQLValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.check_operator.SQLValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:78:1 | 76 | ) 77 | 78 | SQLValueCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 79 | ValueCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 71 71 | @@ -380,13 +399,14 @@ AIR302_common_sql.py:78:1: AIR302 [*] `airflow.operators.check_operator.SQLValue 78 78 | SQLValueCheckOperator() 79 79 | ValueCheckOperator() -AIR302_common_sql.py:79:1: AIR302 [*] `airflow.operators.check_operator.ValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.check_operator.ValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:79:1 | 78 | SQLValueCheckOperator() 79 | ValueCheckOperator() - | ^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 71 71 | @@ -400,16 +420,17 @@ AIR302_common_sql.py:79:1: AIR302 [*] `airflow.operators.check_operator.ValueChe 78 78 | SQLValueCheckOperator() 79 79 | ValueCheckOperator() -AIR302_common_sql.py:88:1: AIR302 [*] `airflow.operators.sql.SQLValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.SQLValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:88:1 | 86 | from airflow.operators.sql import SQLValueCheckOperator 87 | 88 | SQLValueCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 89 | ValueCheckOperator() 90 | PrestoValueCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 83 83 | PrestoValueCheckOperator, @@ -421,14 +442,15 @@ AIR302_common_sql.py:88:1: AIR302 [*] `airflow.operators.sql.SQLValueCheckOperat 88 88 | SQLValueCheckOperator() 89 89 | ValueCheckOperator() -AIR302_common_sql.py:89:1: AIR302 [*] `airflow.operators.presto_check_operator.ValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.presto_check_operator.ValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:89:1 | 88 | SQLValueCheckOperator() 89 | ValueCheckOperator() - | ^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^ 90 | PrestoValueCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 84 84 | ValueCheckOperator, @@ -439,14 +461,15 @@ AIR302_common_sql.py:89:1: AIR302 [*] `airflow.operators.presto_check_operator.V 88 89 | SQLValueCheckOperator() 89 90 | ValueCheckOperator() -AIR302_common_sql.py:90:1: AIR302 [*] `airflow.operators.presto_check_operator.PrestoValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.presto_check_operator.PrestoValueCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:90:1 | 88 | SQLValueCheckOperator() 89 | ValueCheckOperator() 90 | PrestoValueCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLValueCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 84 84 | ValueCheckOperator, @@ -457,16 +480,17 @@ AIR302_common_sql.py:90:1: AIR302 [*] `airflow.operators.presto_check_operator.P 88 89 | SQLValueCheckOperator() 89 90 | ValueCheckOperator() -AIR302_common_sql.py:102:1: AIR302 [*] `airflow.operators.sql.BaseSQLOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.BaseSQLOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:102:1 | 100 | ) 101 | 102 | BaseSQLOperator() - | ^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^ 103 | BranchSQLOperator() 104 | SQLTableCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `BaseSQLOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `BaseSQLOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 91 91 | @@ -484,15 +508,16 @@ AIR302_common_sql.py:102:1: AIR302 [*] `airflow.operators.sql.BaseSQLOperator` i 102 102 | BaseSQLOperator() 103 103 | BranchSQLOperator() -AIR302_common_sql.py:103:1: AIR302 [*] `airflow.operators.sql.BranchSQLOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.BranchSQLOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:103:1 | 102 | BaseSQLOperator() 103 | BranchSQLOperator() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ 104 | SQLTableCheckOperator() 105 | SQLColumnCheckOperator() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `BranchSQLOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `BranchSQLOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 92 92 | @@ -509,16 +534,17 @@ AIR302_common_sql.py:103:1: AIR302 [*] `airflow.operators.sql.BranchSQLOperator` 102 102 | BaseSQLOperator() 103 103 | BranchSQLOperator() -AIR302_common_sql.py:104:1: AIR302 [*] `airflow.operators.sql.SQLTableCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.SQLTableCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:104:1 | 102 | BaseSQLOperator() 103 | BranchSQLOperator() 104 | SQLTableCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 105 | SQLColumnCheckOperator() 106 | _convert_to_float_if_possible() | - = help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLTableCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.1.0` and use `SQLTableCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 94 94 | BaseSQLOperator, @@ -533,16 +559,17 @@ AIR302_common_sql.py:104:1: AIR302 [*] `airflow.operators.sql.SQLTableCheckOpera 102 102 | BaseSQLOperator() 103 103 | BranchSQLOperator() -AIR302_common_sql.py:105:1: AIR302 [*] `airflow.operators.sql.SQLColumnCheckOperator` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.SQLColumnCheckOperator` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:105:1 | 103 | BranchSQLOperator() 104 | SQLTableCheckOperator() 105 | SQLColumnCheckOperator() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^ 106 | _convert_to_float_if_possible() 107 | parse_boolean() | - = help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `SQLColumnCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `SQLColumnCheckOperator` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 93 93 | from airflow.operators.sql import ( @@ -558,15 +585,16 @@ AIR302_common_sql.py:105:1: AIR302 [*] `airflow.operators.sql.SQLColumnCheckOper 102 102 | BaseSQLOperator() 103 103 | BranchSQLOperator() -AIR302_common_sql.py:106:1: AIR302 [*] `airflow.operators.sql._convert_to_float_if_possible` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql._convert_to_float_if_possible` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:106:1 | 104 | SQLTableCheckOperator() 105 | SQLColumnCheckOperator() 106 | _convert_to_float_if_possible() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 107 | parse_boolean() | - = help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `_convert_to_float_if_possible` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `_convert_to_float_if_possible` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 95 95 | BranchSQLOperator, @@ -580,14 +608,15 @@ AIR302_common_sql.py:106:1: AIR302 [*] `airflow.operators.sql._convert_to_float_ 102 102 | BaseSQLOperator() 103 103 | BranchSQLOperator() -AIR302_common_sql.py:107:1: AIR302 [*] `airflow.operators.sql.parse_boolean` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.sql.parse_boolean` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:107:1 | 105 | SQLColumnCheckOperator() 106 | _convert_to_float_if_possible() 107 | parse_boolean() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `parse_boolean` from `airflow.providers.common.sql.operators.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `parse_boolean` from `airflow.providers.common.sql.operators.sql` instead. ℹ Unsafe fix 96 96 | SQLColumnCheckOperator, @@ -600,14 +629,15 @@ AIR302_common_sql.py:107:1: AIR302 [*] `airflow.operators.sql.parse_boolean` is 102 102 | BaseSQLOperator() 103 103 | BranchSQLOperator() -AIR302_common_sql.py:112:1: AIR302 [*] `airflow.sensors.sql.SqlSensor` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.sql.SqlSensor` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:112:1 | 110 | from airflow.sensors.sql import SqlSensor 111 | 112 | SqlSensor() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `SqlSensor` from `airflow.providers.common.sql.sensors.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `SqlSensor` from `airflow.providers.common.sql.sensors.sql` instead. ℹ Unsafe fix 107 107 | parse_boolean() @@ -619,14 +649,15 @@ AIR302_common_sql.py:112:1: AIR302 [*] `airflow.sensors.sql.SqlSensor` is moved 112 112 | SqlSensor() 113 113 | -AIR302_common_sql.py:117:1: AIR302 [*] `airflow.sensors.sql_sensor.SqlSensor` is moved into `common-sql` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.sql_sensor.SqlSensor` is moved into `common-sql` provider in Airflow 3.0; + --> AIR302_common_sql.py:117:1 | 115 | from airflow.sensors.sql_sensor import SqlSensor 116 | 117 | SqlSensor() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ | - = help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `SqlSensor` from `airflow.providers.common.sql.sensors.sql` instead. +help: Install `apache-airflow-providers-common-sql>=1.0.0` and use `SqlSensor` from `airflow.providers.common.sql.sensors.sql` instead. ℹ Unsafe fix 112 112 | SqlSensor() diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_daskexecutor.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_daskexecutor.py.snap index 5015a44a45..2c066e1f07 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_daskexecutor.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_daskexecutor.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_daskexecutor.py:5:1: AIR302 [*] `airflow.executors.dask_executor.DaskExecutor` is moved into `daskexecutor` provider in Airflow 3.0; +AIR302 [*] `airflow.executors.dask_executor.DaskExecutor` is moved into `daskexecutor` provider in Airflow 3.0; + --> AIR302_daskexecutor.py:5:1 | 3 | from airflow.executors.dask_executor import DaskExecutor 4 | 5 | DaskExecutor() - | ^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-daskexecutor>=1.0.0` and use `DaskExecutor` from `airflow.providers.daskexecutor.executors.dask_executor` instead. +help: Install `apache-airflow-providers-daskexecutor>=1.0.0` and use `DaskExecutor` from `airflow.providers.daskexecutor.executors.dask_executor` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_druid.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_druid.py.snap index 9dc5ba8ef9..16512766a5 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_druid.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_druid.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_druid.py:12:1: AIR302 [*] `airflow.hooks.druid_hook.DruidDbApiHook` is moved into `apache-druid` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.druid_hook.DruidDbApiHook` is moved into `apache-druid` provider in Airflow 3.0; + --> AIR302_druid.py:12:1 | 10 | ) 11 | 12 | DruidDbApiHook() - | ^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^ 13 | DruidHook() | - = help: Install `apache-airflow-providers-apache-druid>=1.0.0` and use `DruidDbApiHook` from `airflow.providers.apache.druid.hooks.druid` instead. +help: Install `apache-airflow-providers-apache-druid>=1.0.0` and use `DruidDbApiHook` from `airflow.providers.apache.druid.hooks.druid` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -27,15 +28,16 @@ AIR302_druid.py:12:1: AIR302 [*] `airflow.hooks.druid_hook.DruidDbApiHook` is mo 12 12 | DruidDbApiHook() 13 13 | DruidHook() -AIR302_druid.py:13:1: AIR302 [*] `airflow.hooks.druid_hook.DruidHook` is moved into `apache-druid` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.druid_hook.DruidHook` is moved into `apache-druid` provider in Airflow 3.0; + --> AIR302_druid.py:13:1 | 12 | DruidDbApiHook() 13 | DruidHook() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 14 | 15 | HiveToDruidOperator() | - = help: Install `apache-airflow-providers-apache-druid>=1.0.0` and use `DruidHook` from `airflow.providers.apache.druid.hooks.druid` instead. +help: Install `apache-airflow-providers-apache-druid>=1.0.0` and use `DruidHook` from `airflow.providers.apache.druid.hooks.druid` instead. ℹ Unsafe fix 2 2 | @@ -52,15 +54,16 @@ AIR302_druid.py:13:1: AIR302 [*] `airflow.hooks.druid_hook.DruidHook` is moved i 12 12 | DruidDbApiHook() 13 13 | DruidHook() -AIR302_druid.py:15:1: AIR302 [*] `airflow.operators.hive_to_druid.HiveToDruidOperator` is moved into `apache-druid` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.hive_to_druid.HiveToDruidOperator` is moved into `apache-druid` provider in Airflow 3.0; + --> AIR302_druid.py:15:1 | 13 | DruidHook() 14 | 15 | HiveToDruidOperator() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 16 | HiveToDruidTransfer() | - = help: Install `apache-airflow-providers-apache-druid>=1.0.0` and use `HiveToDruidOperator` from `airflow.providers.apache.druid.transfers.hive_to_druid` instead. +help: Install `apache-airflow-providers-apache-druid>=1.0.0` and use `HiveToDruidOperator` from `airflow.providers.apache.druid.transfers.hive_to_druid` instead. ℹ Unsafe fix 5 5 | DruidHook, @@ -74,13 +77,14 @@ AIR302_druid.py:15:1: AIR302 [*] `airflow.operators.hive_to_druid.HiveToDruidOpe 12 12 | DruidDbApiHook() 13 13 | DruidHook() -AIR302_druid.py:16:1: AIR302 [*] `airflow.operators.hive_to_druid.HiveToDruidTransfer` is moved into `apache-druid` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.hive_to_druid.HiveToDruidTransfer` is moved into `apache-druid` provider in Airflow 3.0; + --> AIR302_druid.py:16:1 | 15 | HiveToDruidOperator() 16 | HiveToDruidTransfer() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-apache-druid>=1.0.0` and use `HiveToDruidOperator` from `airflow.providers.apache.druid.transfers.hive_to_druid` instead. +help: Install `apache-airflow-providers-apache-druid>=1.0.0` and use `HiveToDruidOperator` from `airflow.providers.apache.druid.transfers.hive_to_druid` instead. ℹ Unsafe fix 5 5 | DruidHook, diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_fab.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_fab.py.snap index 1bd1da740f..96eaaef6f0 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_fab.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_fab.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_fab.py:10:1: AIR302 [*] `airflow.api.auth.backend.basic_auth.CLIENT_AUTH` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.basic_auth.CLIENT_AUTH` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:10:1 | 8 | ) 9 | 10 | CLIENT_AUTH - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 11 | init_app() 12 | auth_current_user() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `CLIENT_AUTH` from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `CLIENT_AUTH` from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -26,15 +27,16 @@ AIR302_fab.py:10:1: AIR302 [*] `airflow.api.auth.backend.basic_auth.CLIENT_AUTH` 10 10 | CLIENT_AUTH 11 11 | init_app() -AIR302_fab.py:11:1: AIR302 [*] `airflow.api.auth.backend.basic_auth.init_app` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.basic_auth.init_app` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:11:1 | 10 | CLIENT_AUTH 11 | init_app() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 12 | auth_current_user() 13 | requires_authentication() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `init_app` from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `init_app` from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. ℹ Unsafe fix 3 3 | from airflow.api.auth.backend.basic_auth import ( @@ -48,15 +50,16 @@ AIR302_fab.py:11:1: AIR302 [*] `airflow.api.auth.backend.basic_auth.init_app` is 10 10 | CLIENT_AUTH 11 11 | init_app() -AIR302_fab.py:12:1: AIR302 [*] `airflow.api.auth.backend.basic_auth.auth_current_user` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.basic_auth.auth_current_user` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:12:1 | 10 | CLIENT_AUTH 11 | init_app() 12 | auth_current_user() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ 13 | requires_authentication() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `auth_current_user` from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `auth_current_user` from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. ℹ Unsafe fix 2 2 | @@ -71,16 +74,17 @@ AIR302_fab.py:12:1: AIR302 [*] `airflow.api.auth.backend.basic_auth.auth_current 10 10 | CLIENT_AUTH 11 11 | init_app() -AIR302_fab.py:13:1: AIR302 [*] `airflow.api.auth.backend.basic_auth.requires_authentication` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.basic_auth.requires_authentication` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:13:1 | 11 | init_app() 12 | auth_current_user() 13 | requires_authentication() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | from airflow.api.auth.backend.kerberos_auth import ( | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `requires_authentication` from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `requires_authentication` from `airflow.providers.fab.auth_manager.api.auth.backend.basic_auth` instead. ℹ Unsafe fix 4 4 | CLIENT_AUTH, @@ -93,16 +97,17 @@ AIR302_fab.py:13:1: AIR302 [*] `airflow.api.auth.backend.basic_auth.requires_aut 10 10 | CLIENT_AUTH 11 11 | init_app() -AIR302_fab.py:23:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.log` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.kerberos_auth.log` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:23:1 | 21 | ) 22 | 23 | log() - | ^^^ AIR302 + | ^^^ 24 | CLIENT_AUTH 25 | find_user() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `log` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `log` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 16 16 | CLIENT_AUTH, @@ -116,15 +121,16 @@ AIR302_fab.py:23:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.log` is m 23 23 | log() 24 24 | CLIENT_AUTH -AIR302_fab.py:24:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.CLIENT_AUTH` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.kerberos_auth.CLIENT_AUTH` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:24:1 | 23 | log() 24 | CLIENT_AUTH - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 25 | find_user() 26 | init_app() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `CLIENT_AUTH` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `CLIENT_AUTH` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 13 13 | requires_authentication() @@ -141,16 +147,17 @@ AIR302_fab.py:24:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.CLIENT_AU 23 23 | log() 24 24 | CLIENT_AUTH -AIR302_fab.py:25:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.find_user` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.kerberos_auth.find_user` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:25:1 | 23 | log() 24 | CLIENT_AUTH 25 | find_user() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 26 | init_app() 27 | requires_authentication() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `find_user` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `find_user` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 14 14 | @@ -166,15 +173,16 @@ AIR302_fab.py:25:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.find_user 23 23 | log() 24 24 | CLIENT_AUTH -AIR302_fab.py:26:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.init_app` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.kerberos_auth.init_app` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:26:1 | 24 | CLIENT_AUTH 25 | find_user() 26 | init_app() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 27 | requires_authentication() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `init_app` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `init_app` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 15 15 | from airflow.api.auth.backend.kerberos_auth import ( @@ -189,16 +197,17 @@ AIR302_fab.py:26:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.init_app` 23 23 | log() 24 24 | CLIENT_AUTH -AIR302_fab.py:27:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.requires_authentication` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.api.auth.backend.kerberos_auth.requires_authentication` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:27:1 | 25 | find_user() 26 | init_app() 27 | requires_authentication() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | from airflow.auth.managers.fab.api.auth.backend.kerberos_auth import ( | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `requires_authentication` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `requires_authentication` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 17 17 | find_user, @@ -211,16 +220,17 @@ AIR302_fab.py:27:1: AIR302 [*] `airflow.api.auth.backend.kerberos_auth.requires_ 23 23 | log() 24 24 | CLIENT_AUTH -AIR302_fab.py:37:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.log` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.log` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:37:1 | 35 | ) 36 | 37 | log() - | ^^^ AIR302 + | ^^^ 38 | CLIENT_AUTH 39 | find_user() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `log` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `log` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 30 30 | CLIENT_AUTH, @@ -234,15 +244,16 @@ AIR302_fab.py:37:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerbe 37 37 | log() 38 38 | CLIENT_AUTH -AIR302_fab.py:38:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.CLIENT_AUTH` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.CLIENT_AUTH` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:38:1 | 37 | log() 38 | CLIENT_AUTH - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 39 | find_user() 40 | init_app() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `CLIENT_AUTH` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `CLIENT_AUTH` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 27 27 | requires_authentication() @@ -259,16 +270,17 @@ AIR302_fab.py:38:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerbe 37 37 | log() 38 38 | CLIENT_AUTH -AIR302_fab.py:39:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.find_user` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.find_user` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:39:1 | 37 | log() 38 | CLIENT_AUTH 39 | find_user() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 40 | init_app() 41 | requires_authentication() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `find_user` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `find_user` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 28 28 | @@ -284,15 +296,16 @@ AIR302_fab.py:39:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerbe 37 37 | log() 38 38 | CLIENT_AUTH -AIR302_fab.py:40:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.init_app` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.init_app` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:40:1 | 38 | CLIENT_AUTH 39 | find_user() 40 | init_app() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 41 | requires_authentication() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `init_app` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `init_app` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 29 29 | from airflow.auth.managers.fab.api.auth.backend.kerberos_auth import ( @@ -307,16 +320,17 @@ AIR302_fab.py:40:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerbe 37 37 | log() 38 38 | CLIENT_AUTH -AIR302_fab.py:41:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.requires_authentication` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerberos_auth.requires_authentication` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:41:1 | 39 | find_user() 40 | init_app() 41 | requires_authentication() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^ 42 | 43 | from airflow.auth.managers.fab.fab_auth_manager import FabAuthManager | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `requires_authentication` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `requires_authentication` from `airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth` instead. ℹ Unsafe fix 31 31 | find_user, @@ -329,16 +343,17 @@ AIR302_fab.py:41:1: AIR302 [*] `airflow.auth.managers.fab.api.auth.backend.kerbe 37 37 | log() 38 38 | CLIENT_AUTH -AIR302_fab.py:49:1: AIR302 [*] `airflow.auth.managers.fab.fab_auth_manager.FabAuthManager` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.auth.managers.fab.fab_auth_manager.FabAuthManager` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:49:1 | 47 | ) 48 | 49 | FabAuthManager() - | ^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^ 50 | MAX_NUM_DATABASE_USER_SESSIONS 51 | FabAirflowSecurityManagerOverride() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `FabAuthManager` from `airflow.providers.fab.auth_manager.fab_auth_manager` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `FabAuthManager` from `airflow.providers.fab.auth_manager.fab_auth_manager` instead. ℹ Unsafe fix 40 40 | init_app() @@ -354,14 +369,15 @@ AIR302_fab.py:49:1: AIR302 [*] `airflow.auth.managers.fab.fab_auth_manager.FabAu 49 49 | FabAuthManager() 50 50 | MAX_NUM_DATABASE_USER_SESSIONS -AIR302_fab.py:50:1: AIR302 [*] `airflow.auth.managers.fab.security_manager.override.MAX_NUM_DATABASE_USER_SESSIONS` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.auth.managers.fab.security_manager.override.MAX_NUM_DATABASE_USER_SESSIONS` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:50:1 | 49 | FabAuthManager() 50 | MAX_NUM_DATABASE_USER_SESSIONS - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 51 | FabAirflowSecurityManagerOverride() | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `MAX_NUM_DATABASE_USER_SESSIONS` from `airflow.providers.fab.auth_manager.security_manager.override` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `MAX_NUM_DATABASE_USER_SESSIONS` from `airflow.providers.fab.auth_manager.security_manager.override` instead. ℹ Unsafe fix 42 42 | @@ -375,16 +391,17 @@ AIR302_fab.py:50:1: AIR302 [*] `airflow.auth.managers.fab.security_manager.overr 49 49 | FabAuthManager() 50 50 | MAX_NUM_DATABASE_USER_SESSIONS -AIR302_fab.py:51:1: AIR302 [*] `airflow.auth.managers.fab.security_manager.override.FabAirflowSecurityManagerOverride` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.auth.managers.fab.security_manager.override.FabAirflowSecurityManagerOverride` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:51:1 | 49 | FabAuthManager() 50 | MAX_NUM_DATABASE_USER_SESSIONS 51 | FabAirflowSecurityManagerOverride() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | 53 | from airflow.www.security import FabAirflowSecurityManagerOverride | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `FabAirflowSecurityManagerOverride` from `airflow.providers.fab.auth_manager.security_manager.override` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `FabAirflowSecurityManagerOverride` from `airflow.providers.fab.auth_manager.security_manager.override` instead. ℹ Unsafe fix 43 43 | from airflow.auth.managers.fab.fab_auth_manager import FabAuthManager @@ -397,14 +414,15 @@ AIR302_fab.py:51:1: AIR302 [*] `airflow.auth.managers.fab.security_manager.overr 49 49 | FabAuthManager() 50 50 | MAX_NUM_DATABASE_USER_SESSIONS -AIR302_fab.py:55:1: AIR302 [*] `airflow.www.security.FabAirflowSecurityManagerOverride` is moved into `fab` provider in Airflow 3.0; +AIR302 [*] `airflow.www.security.FabAirflowSecurityManagerOverride` is moved into `fab` provider in Airflow 3.0; + --> AIR302_fab.py:55:1 | 53 | from airflow.www.security import FabAirflowSecurityManagerOverride 54 | 55 | FabAirflowSecurityManagerOverride() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-fab>=1.0.0` and use `FabAirflowSecurityManagerOverride` from `airflow.providers.fab.auth_manager.security_manager.override` instead. +help: Install `apache-airflow-providers-fab>=1.0.0` and use `FabAirflowSecurityManagerOverride` from `airflow.providers.fab.auth_manager.security_manager.override` instead. ℹ Unsafe fix 50 50 | MAX_NUM_DATABASE_USER_SESSIONS diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_hdfs.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_hdfs.py.snap index a3e75ff1ec..ad7950f7e3 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_hdfs.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_hdfs.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_hdfs.py:6:1: AIR302 [*] `airflow.hooks.webhdfs_hook.WebHDFSHook` is moved into `apache-hdfs` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.webhdfs_hook.WebHDFSHook` is moved into `apache-hdfs` provider in Airflow 3.0; + --> AIR302_hdfs.py:6:1 | 4 | from airflow.sensors.web_hdfs_sensor import WebHdfsSensor 5 | 6 | WebHDFSHook() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 7 | WebHdfsSensor() | - = help: Install `apache-airflow-providers-apache-hdfs>=1.0.0` and use `WebHDFSHook` from `airflow.providers.apache.hdfs.hooks.webhdfs` instead. +help: Install `apache-airflow-providers-apache-hdfs>=1.0.0` and use `WebHDFSHook` from `airflow.providers.apache.hdfs.hooks.webhdfs` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -21,13 +22,14 @@ AIR302_hdfs.py:6:1: AIR302 [*] `airflow.hooks.webhdfs_hook.WebHDFSHook` is moved 6 6 | WebHDFSHook() 7 7 | WebHdfsSensor() -AIR302_hdfs.py:7:1: AIR302 [*] `airflow.sensors.web_hdfs_sensor.WebHdfsSensor` is moved into `apache-hdfs` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.web_hdfs_sensor.WebHdfsSensor` is moved into `apache-hdfs` provider in Airflow 3.0; + --> AIR302_hdfs.py:7:1 | 6 | WebHDFSHook() 7 | WebHdfsSensor() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-apache-hdfs>=1.0.0` and use `WebHdfsSensor` from `airflow.providers.apache.hdfs.sensors.web_hdfs` instead. +help: Install `apache-airflow-providers-apache-hdfs>=1.0.0` and use `WebHdfsSensor` from `airflow.providers.apache.hdfs.sensors.web_hdfs` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_hive.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_hive.py.snap index b941acb2d7..9783310e59 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_hive.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_hive.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_hive.py:18:1: AIR302 [*] `airflow.hooks.hive_hooks.HIVE_QUEUE_PRIORITIES` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.hive_hooks.HIVE_QUEUE_PRIORITIES` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:18:1 | 16 | from airflow.operators.hive_to_samba_operator import HiveToSambaOperator 17 | 18 | HIVE_QUEUE_PRIORITIES - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 19 | HiveCliHook() 20 | HiveMetastoreHook() | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HIVE_QUEUE_PRIORITIES` from `airflow.providers.apache.hive.hooks.hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HIVE_QUEUE_PRIORITIES` from `airflow.providers.apache.hive.hooks.hive` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -29,15 +30,16 @@ AIR302_hive.py:18:1: AIR302 [*] `airflow.hooks.hive_hooks.HIVE_QUEUE_PRIORITIES` 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:19:1: AIR302 [*] `airflow.hooks.hive_hooks.HiveCliHook` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.hive_hooks.HiveCliHook` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:19:1 | 18 | HIVE_QUEUE_PRIORITIES 19 | HiveCliHook() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 20 | HiveMetastoreHook() 21 | HiveServer2Hook() | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveCliHook` from `airflow.providers.apache.hive.hooks.hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveCliHook` from `airflow.providers.apache.hive.hooks.hive` instead. ℹ Unsafe fix 2 2 | @@ -56,15 +58,16 @@ AIR302_hive.py:19:1: AIR302 [*] `airflow.hooks.hive_hooks.HiveCliHook` is moved 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:20:1: AIR302 [*] `airflow.hooks.hive_hooks.HiveMetastoreHook` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.hive_hooks.HiveMetastoreHook` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:20:1 | 18 | HIVE_QUEUE_PRIORITIES 19 | HiveCliHook() 20 | HiveMetastoreHook() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ 21 | HiveServer2Hook() | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveMetastoreHook` from `airflow.providers.apache.hive.hooks.hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveMetastoreHook` from `airflow.providers.apache.hive.hooks.hive` instead. ℹ Unsafe fix 3 3 | from airflow.hooks.hive_hooks import ( @@ -83,16 +86,17 @@ AIR302_hive.py:20:1: AIR302 [*] `airflow.hooks.hive_hooks.HiveMetastoreHook` is 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:21:1: AIR302 [*] `airflow.hooks.hive_hooks.HiveServer2Hook` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.hive_hooks.HiveServer2Hook` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:21:1 | 19 | HiveCliHook() 20 | HiveMetastoreHook() 21 | HiveServer2Hook() - | ^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^ 22 | 23 | closest_ds_partition() | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveServer2Hook` from `airflow.providers.apache.hive.hooks.hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveServer2Hook` from `airflow.providers.apache.hive.hooks.hive` instead. ℹ Unsafe fix 4 4 | HIVE_QUEUE_PRIORITIES, @@ -111,15 +115,16 @@ AIR302_hive.py:21:1: AIR302 [*] `airflow.hooks.hive_hooks.HiveServer2Hook` is mo 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:23:1: AIR302 [*] `airflow.macros.hive.closest_ds_partition` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.macros.hive.closest_ds_partition` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:23:1 | 21 | HiveServer2Hook() 22 | 23 | closest_ds_partition() - | ^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^ 24 | max_partition() | - = help: Install `apache-airflow-providers-apache-hive>=5.1.0` and use `closest_ds_partition` from `airflow.providers.apache.hive.macros.hive` instead. +help: Install `apache-airflow-providers-apache-hive>=5.1.0` and use `closest_ds_partition` from `airflow.providers.apache.hive.macros.hive` instead. ℹ Unsafe fix 7 7 | HiveServer2Hook, @@ -137,15 +142,16 @@ AIR302_hive.py:23:1: AIR302 [*] `airflow.macros.hive.closest_ds_partition` is mo 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:24:1: AIR302 [*] `airflow.macros.hive.max_partition` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.macros.hive.max_partition` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:24:1 | 23 | closest_ds_partition() 24 | max_partition() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ 25 | 26 | HiveOperator() | - = help: Install `apache-airflow-providers-apache-hive>=5.1.0` and use `max_partition` from `airflow.providers.apache.hive.macros.hive` instead. +help: Install `apache-airflow-providers-apache-hive>=5.1.0` and use `max_partition` from `airflow.providers.apache.hive.macros.hive` instead. ℹ Unsafe fix 8 8 | ) @@ -162,16 +168,17 @@ AIR302_hive.py:24:1: AIR302 [*] `airflow.macros.hive.max_partition` is moved int 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:26:1: AIR302 [*] `airflow.operators.hive_operator.HiveOperator` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.hive_operator.HiveOperator` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:26:1 | 24 | max_partition() 25 | 26 | HiveOperator() - | ^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^ 27 | HiveStatsCollectionOperator() 28 | HiveToMySqlOperator() | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveOperator` from `airflow.providers.apache.hive.operators.hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveOperator` from `airflow.providers.apache.hive.operators.hive` instead. ℹ Unsafe fix 10 10 | closest_ds_partition, @@ -186,15 +193,16 @@ AIR302_hive.py:26:1: AIR302 [*] `airflow.operators.hive_operator.HiveOperator` i 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:27:1: AIR302 [*] `airflow.operators.hive_stats_operator.HiveStatsCollectionOperator` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.hive_stats_operator.HiveStatsCollectionOperator` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:27:1 | 26 | HiveOperator() 27 | HiveStatsCollectionOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | HiveToMySqlOperator() 29 | HiveToSambaOperator() | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveStatsCollectionOperator` from `airflow.providers.apache.hive.operators.hive_stats` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveStatsCollectionOperator` from `airflow.providers.apache.hive.operators.hive_stats` instead. ℹ Unsafe fix 11 11 | max_partition, @@ -208,15 +216,16 @@ AIR302_hive.py:27:1: AIR302 [*] `airflow.operators.hive_stats_operator.HiveStats 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:28:1: AIR302 [*] `airflow.operators.hive_to_mysql.HiveToMySqlOperator` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.hive_to_mysql.HiveToMySqlOperator` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:28:1 | 26 | HiveOperator() 27 | HiveStatsCollectionOperator() 28 | HiveToMySqlOperator() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 29 | HiveToSambaOperator() | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveToMySqlOperator` from `airflow.providers.apache.hive.transfers.hive_to_mysql` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveToMySqlOperator` from `airflow.providers.apache.hive.transfers.hive_to_mysql` instead. ℹ Unsafe fix 12 12 | ) @@ -229,14 +238,15 @@ AIR302_hive.py:28:1: AIR302 [*] `airflow.operators.hive_to_mysql.HiveToMySqlOper 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:29:1: AIR302 [*] `airflow.operators.hive_to_samba_operator.HiveToSambaOperator` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.hive_to_samba_operator.HiveToSambaOperator` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:29:1 | 27 | HiveStatsCollectionOperator() 28 | HiveToMySqlOperator() 29 | HiveToSambaOperator() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveToSambaOperator` from `airflow.providers.apache.hive.transfers.hive_to_samba` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveToSambaOperator` from `airflow.providers.apache.hive.transfers.hive_to_samba` instead. ℹ Unsafe fix 13 13 | from airflow.operators.hive_operator import HiveOperator @@ -248,16 +258,17 @@ AIR302_hive.py:29:1: AIR302 [*] `airflow.operators.hive_to_samba_operator.HiveTo 18 18 | HIVE_QUEUE_PRIORITIES 19 19 | HiveCliHook() -AIR302_hive.py:34:1: AIR302 [*] `airflow.operators.hive_to_mysql.HiveToMySqlTransfer` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.hive_to_mysql.HiveToMySqlTransfer` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:34:1 | 32 | from airflow.operators.hive_to_mysql import HiveToMySqlTransfer 33 | 34 | HiveToMySqlTransfer() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 35 | 36 | from airflow.operators.mysql_to_hive import MySqlToHiveOperator | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveToMySqlOperator` from `airflow.providers.apache.hive.transfers.hive_to_mysql` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HiveToMySqlOperator` from `airflow.providers.apache.hive.transfers.hive_to_mysql` instead. ℹ Unsafe fix 30 30 | @@ -268,16 +279,17 @@ AIR302_hive.py:34:1: AIR302 [*] `airflow.operators.hive_to_mysql.HiveToMySqlTran 34 35 | HiveToMySqlTransfer() 35 36 | -AIR302_hive.py:38:1: AIR302 [*] `airflow.operators.mysql_to_hive.MySqlToHiveOperator` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.mysql_to_hive.MySqlToHiveOperator` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:38:1 | 36 | from airflow.operators.mysql_to_hive import MySqlToHiveOperator 37 | 38 | MySqlToHiveOperator() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 39 | 40 | from airflow.operators.mysql_to_hive import MySqlToHiveTransfer | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MySqlToHiveOperator` from `airflow.providers.apache.hive.transfers.mysql_to_hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MySqlToHiveOperator` from `airflow.providers.apache.hive.transfers.mysql_to_hive` instead. ℹ Unsafe fix 33 33 | @@ -289,16 +301,17 @@ AIR302_hive.py:38:1: AIR302 [*] `airflow.operators.mysql_to_hive.MySqlToHiveOper 38 38 | MySqlToHiveOperator() 39 39 | -AIR302_hive.py:42:1: AIR302 [*] `airflow.operators.mysql_to_hive.MySqlToHiveTransfer` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.mysql_to_hive.MySqlToHiveTransfer` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:42:1 | 40 | from airflow.operators.mysql_to_hive import MySqlToHiveTransfer 41 | 42 | MySqlToHiveTransfer() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 43 | 44 | from airflow.operators.mssql_to_hive import MsSqlToHiveOperator | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MySqlToHiveOperator` from `airflow.providers.apache.hive.transfers.mysql_to_hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MySqlToHiveOperator` from `airflow.providers.apache.hive.transfers.mysql_to_hive` instead. ℹ Unsafe fix 38 38 | MySqlToHiveOperator() @@ -309,16 +322,17 @@ AIR302_hive.py:42:1: AIR302 [*] `airflow.operators.mysql_to_hive.MySqlToHiveTran 42 43 | MySqlToHiveTransfer() 43 44 | -AIR302_hive.py:46:1: AIR302 [*] `airflow.operators.mssql_to_hive.MsSqlToHiveOperator` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.mssql_to_hive.MsSqlToHiveOperator` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:46:1 | 44 | from airflow.operators.mssql_to_hive import MsSqlToHiveOperator 45 | 46 | MsSqlToHiveOperator() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 47 | 48 | from airflow.operators.mssql_to_hive import MsSqlToHiveTransfer | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MsSqlToHiveOperator` from `airflow.providers.apache.hive.transfers.mssql_to_hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MsSqlToHiveOperator` from `airflow.providers.apache.hive.transfers.mssql_to_hive` instead. ℹ Unsafe fix 41 41 | @@ -330,16 +344,17 @@ AIR302_hive.py:46:1: AIR302 [*] `airflow.operators.mssql_to_hive.MsSqlToHiveOper 46 46 | MsSqlToHiveOperator() 47 47 | -AIR302_hive.py:50:1: AIR302 [*] `airflow.operators.mssql_to_hive.MsSqlToHiveTransfer` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.mssql_to_hive.MsSqlToHiveTransfer` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:50:1 | 48 | from airflow.operators.mssql_to_hive import MsSqlToHiveTransfer 49 | 50 | MsSqlToHiveTransfer() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 51 | 52 | from airflow.operators.s3_to_hive_operator import S3ToHiveOperator | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MsSqlToHiveOperator` from `airflow.providers.apache.hive.transfers.mssql_to_hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MsSqlToHiveOperator` from `airflow.providers.apache.hive.transfers.mssql_to_hive` instead. ℹ Unsafe fix 46 46 | MsSqlToHiveOperator() @@ -350,16 +365,17 @@ AIR302_hive.py:50:1: AIR302 [*] `airflow.operators.mssql_to_hive.MsSqlToHiveTran 50 51 | MsSqlToHiveTransfer() 51 52 | -AIR302_hive.py:54:1: AIR302 [*] `airflow.operators.s3_to_hive_operator.S3ToHiveOperator` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.s3_to_hive_operator.S3ToHiveOperator` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:54:1 | 52 | from airflow.operators.s3_to_hive_operator import S3ToHiveOperator 53 | 54 | S3ToHiveOperator() - | ^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^ 55 | 56 | from airflow.operators.s3_to_hive_operator import S3ToHiveTransfer | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `S3ToHiveOperator` from `airflow.providers.apache.hive.transfers.s3_to_hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `S3ToHiveOperator` from `airflow.providers.apache.hive.transfers.s3_to_hive` instead. ℹ Unsafe fix 49 49 | @@ -371,16 +387,17 @@ AIR302_hive.py:54:1: AIR302 [*] `airflow.operators.s3_to_hive_operator.S3ToHiveO 54 54 | S3ToHiveOperator() 55 55 | -AIR302_hive.py:58:1: AIR302 [*] `airflow.operators.s3_to_hive_operator.S3ToHiveTransfer` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.s3_to_hive_operator.S3ToHiveTransfer` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:58:1 | 56 | from airflow.operators.s3_to_hive_operator import S3ToHiveTransfer 57 | 58 | S3ToHiveTransfer() - | ^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^ 59 | 60 | from airflow.sensors.hive_partition_sensor import HivePartitionSensor | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `S3ToHiveOperator` from `airflow.providers.apache.hive.transfers.s3_to_hive` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `S3ToHiveOperator` from `airflow.providers.apache.hive.transfers.s3_to_hive` instead. ℹ Unsafe fix 54 54 | S3ToHiveOperator() @@ -391,16 +408,17 @@ AIR302_hive.py:58:1: AIR302 [*] `airflow.operators.s3_to_hive_operator.S3ToHiveT 58 59 | S3ToHiveTransfer() 59 60 | -AIR302_hive.py:62:1: AIR302 [*] `airflow.sensors.hive_partition_sensor.HivePartitionSensor` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.hive_partition_sensor.HivePartitionSensor` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:62:1 | 60 | from airflow.sensors.hive_partition_sensor import HivePartitionSensor 61 | 62 | HivePartitionSensor() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 63 | 64 | from airflow.sensors.metastore_partition_sensor import MetastorePartitionSensor | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HivePartitionSensor` from `airflow.providers.apache.hive.sensors.hive_partition` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `HivePartitionSensor` from `airflow.providers.apache.hive.sensors.hive_partition` instead. ℹ Unsafe fix 57 57 | @@ -412,16 +430,17 @@ AIR302_hive.py:62:1: AIR302 [*] `airflow.sensors.hive_partition_sensor.HiveParti 62 62 | HivePartitionSensor() 63 63 | -AIR302_hive.py:66:1: AIR302 [*] `airflow.sensors.metastore_partition_sensor.MetastorePartitionSensor` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.metastore_partition_sensor.MetastorePartitionSensor` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:66:1 | 64 | from airflow.sensors.metastore_partition_sensor import MetastorePartitionSensor 65 | 66 | MetastorePartitionSensor() - | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 67 | 68 | from airflow.sensors.named_hive_partition_sensor import NamedHivePartitionSensor | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MetastorePartitionSensor` from `airflow.providers.apache.hive.sensors.metastore_partition` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `MetastorePartitionSensor` from `airflow.providers.apache.hive.sensors.metastore_partition` instead. ℹ Unsafe fix 61 61 | @@ -433,14 +452,15 @@ AIR302_hive.py:66:1: AIR302 [*] `airflow.sensors.metastore_partition_sensor.Meta 66 66 | MetastorePartitionSensor() 67 67 | -AIR302_hive.py:70:1: AIR302 [*] `airflow.sensors.named_hive_partition_sensor.NamedHivePartitionSensor` is moved into `apache-hive` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.named_hive_partition_sensor.NamedHivePartitionSensor` is moved into `apache-hive` provider in Airflow 3.0; + --> AIR302_hive.py:70:1 | 68 | from airflow.sensors.named_hive_partition_sensor import NamedHivePartitionSensor 69 | 70 | NamedHivePartitionSensor() - | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `NamedHivePartitionSensor` from `airflow.providers.apache.hive.sensors.named_hive_partition` instead. +help: Install `apache-airflow-providers-apache-hive>=1.0.0` and use `NamedHivePartitionSensor` from `airflow.providers.apache.hive.sensors.named_hive_partition` instead. ℹ Unsafe fix 65 65 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_http.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_http.py.snap index 3a8993133e..0010d981b8 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_http.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_http.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_http.py:7:1: AIR302 [*] `airflow.hooks.http_hook.HttpHook` is moved into `http` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.http_hook.HttpHook` is moved into `http` provider in Airflow 3.0; + --> AIR302_http.py:7:1 | 5 | from airflow.sensors.http_sensor import HttpSensor 6 | 7 | HttpHook() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 8 | SimpleHttpOperator() 9 | HttpSensor() | - = help: Install `apache-airflow-providers-http>=1.0.0` and use `HttpHook` from `airflow.providers.http.hooks.http` instead. +help: Install `apache-airflow-providers-http>=1.0.0` and use `HttpHook` from `airflow.providers.http.hooks.http` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -23,14 +24,15 @@ AIR302_http.py:7:1: AIR302 [*] `airflow.hooks.http_hook.HttpHook` is moved into 7 7 | HttpHook() 8 8 | SimpleHttpOperator() -AIR302_http.py:8:1: AIR302 [*] `airflow.operators.http_operator.SimpleHttpOperator` is moved into `http` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.http_operator.SimpleHttpOperator` is moved into `http` provider in Airflow 3.0; + --> AIR302_http.py:8:1 | 7 | HttpHook() 8 | SimpleHttpOperator() - | ^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^ 9 | HttpSensor() | - = help: Install `apache-airflow-providers-http>=5.0.0` and use `HttpOperator` from `airflow.providers.http.operators.http` instead. +help: Install `apache-airflow-providers-http>=5.0.0` and use `HttpOperator` from `airflow.providers.http.operators.http` instead. ℹ Safe fix 3 3 | from airflow.hooks.http_hook import HttpHook @@ -43,14 +45,15 @@ AIR302_http.py:8:1: AIR302 [*] `airflow.operators.http_operator.SimpleHttpOperat 9 |+HttpOperator() 9 10 | HttpSensor() -AIR302_http.py:9:1: AIR302 [*] `airflow.sensors.http_sensor.HttpSensor` is moved into `http` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.http_sensor.HttpSensor` is moved into `http` provider in Airflow 3.0; + --> AIR302_http.py:9:1 | 7 | HttpHook() 8 | SimpleHttpOperator() 9 | HttpSensor() - | ^^^^^^^^^^ AIR302 + | ^^^^^^^^^^ | - = help: Install `apache-airflow-providers-http>=1.0.0` and use `HttpSensor` from `airflow.providers.http.sensors.http` instead. +help: Install `apache-airflow-providers-http>=1.0.0` and use `HttpSensor` from `airflow.providers.http.sensors.http` instead. ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_jdbc.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_jdbc.py.snap index dd6177f543..337e988991 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_jdbc.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_jdbc.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_jdbc.py:8:1: AIR302 [*] `airflow.hooks.jdbc_hook.JdbcHook` is moved into `jdbc` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.jdbc_hook.JdbcHook` is moved into `jdbc` provider in Airflow 3.0; + --> AIR302_jdbc.py:8:1 | 6 | ) 7 | 8 | JdbcHook() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 9 | jaydebeapi() | - = help: Install `apache-airflow-providers-jdbc>=1.0.0` and use `JdbcHook` from `airflow.providers.jdbc.hooks.jdbc` instead. +help: Install `apache-airflow-providers-jdbc>=1.0.0` and use `JdbcHook` from `airflow.providers.jdbc.hooks.jdbc` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -23,13 +24,14 @@ AIR302_jdbc.py:8:1: AIR302 [*] `airflow.hooks.jdbc_hook.JdbcHook` is moved into 8 8 | JdbcHook() 9 9 | jaydebeapi() -AIR302_jdbc.py:9:1: AIR302 [*] `airflow.hooks.jdbc_hook.jaydebeapi` is moved into `jdbc` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.jdbc_hook.jaydebeapi` is moved into `jdbc` provider in Airflow 3.0; + --> AIR302_jdbc.py:9:1 | 8 | JdbcHook() 9 | jaydebeapi() - | ^^^^^^^^^^ AIR302 + | ^^^^^^^^^^ | - = help: Install `apache-airflow-providers-jdbc>=1.0.0` and use `jaydebeapi` from `airflow.providers.jdbc.hooks.jdbc` instead. +help: Install `apache-airflow-providers-jdbc>=1.0.0` and use `jaydebeapi` from `airflow.providers.jdbc.hooks.jdbc` instead. ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_kubernetes.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_kubernetes.py.snap index f46860be15..d594255c68 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_kubernetes.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_kubernetes.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_kubernetes.py:22:1: AIR302 [*] `airflow.executors.kubernetes_executor_types.ALL_NAMESPACES` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.executors.kubernetes_executor_types.ALL_NAMESPACES` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:22:1 | 20 | ) 21 | 22 | ALL_NAMESPACES - | ^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^ 23 | POD_EXECUTOR_DONE_KEY | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `ALL_NAMESPACES` from `airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `ALL_NAMESPACES` from `airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -28,15 +29,16 @@ AIR302_kubernetes.py:22:1: AIR302 [*] `airflow.executors.kubernetes_executor_typ 22 22 | ALL_NAMESPACES 23 23 | POD_EXECUTOR_DONE_KEY -AIR302_kubernetes.py:23:1: AIR302 [*] `airflow.executors.kubernetes_executor_types.POD_EXECUTOR_DONE_KEY` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.executors.kubernetes_executor_types.POD_EXECUTOR_DONE_KEY` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:23:1 | 22 | ALL_NAMESPACES 23 | POD_EXECUTOR_DONE_KEY - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 24 | 25 | K8SModel() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `POD_EXECUTOR_DONE_KEY` from `airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `POD_EXECUTOR_DONE_KEY` from `airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types` instead. ℹ Unsafe fix 2 2 | @@ -55,15 +57,16 @@ AIR302_kubernetes.py:23:1: AIR302 [*] `airflow.executors.kubernetes_executor_typ 22 22 | ALL_NAMESPACES 23 23 | POD_EXECUTOR_DONE_KEY -AIR302_kubernetes.py:25:1: AIR302 [*] `airflow.kubernetes.k8s_model.K8SModel` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.k8s_model.K8SModel` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:25:1 | 23 | POD_EXECUTOR_DONE_KEY 24 | 25 | K8SModel() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 26 | append_to_pod() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `K8SModel` from `airflow.providers.cncf.kubernetes.k8s_model` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `K8SModel` from `airflow.providers.cncf.kubernetes.k8s_model` instead. ℹ Unsafe fix 5 5 | POD_EXECUTOR_DONE_KEY, @@ -82,15 +85,16 @@ AIR302_kubernetes.py:25:1: AIR302 [*] `airflow.kubernetes.k8s_model.K8SModel` is 22 22 | ALL_NAMESPACES 23 23 | POD_EXECUTOR_DONE_KEY -AIR302_kubernetes.py:26:1: AIR302 [*] `airflow.kubernetes.k8s_model.append_to_pod` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.k8s_model.append_to_pod` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:26:1 | 25 | K8SModel() 26 | append_to_pod() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ 27 | 28 | _disable_verify_ssl() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `append_to_pod` from `airflow.providers.cncf.kubernetes.k8s_model` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `append_to_pod` from `airflow.providers.cncf.kubernetes.k8s_model` instead. ℹ Unsafe fix 6 6 | ) @@ -109,16 +113,17 @@ AIR302_kubernetes.py:26:1: AIR302 [*] `airflow.kubernetes.k8s_model.append_to_po 22 22 | ALL_NAMESPACES 23 23 | POD_EXECUTOR_DONE_KEY -AIR302_kubernetes.py:28:1: AIR302 [*] `airflow.kubernetes.kube_client._disable_verify_ssl` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kube_client._disable_verify_ssl` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:28:1 | 26 | append_to_pod() 27 | 28 | _disable_verify_ssl() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 29 | _enable_tcp_keepalive() 30 | get_kube_client() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `_disable_verify_ssl` from `airflow.providers.cncf.kubernetes.kube_client` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `_disable_verify_ssl` from `airflow.providers.cncf.kubernetes.kube_client` instead. ℹ Unsafe fix 9 9 | append_to_pod, @@ -137,14 +142,15 @@ AIR302_kubernetes.py:28:1: AIR302 [*] `airflow.kubernetes.kube_client._disable_v 22 22 | ALL_NAMESPACES 23 23 | POD_EXECUTOR_DONE_KEY -AIR302_kubernetes.py:29:1: AIR302 [*] `airflow.kubernetes.kube_client._enable_tcp_keepalive` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kube_client._enable_tcp_keepalive` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:29:1 | 28 | _disable_verify_ssl() 29 | _enable_tcp_keepalive() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 30 | get_kube_client() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `_enable_tcp_keepalive` from `airflow.providers.cncf.kubernetes.kube_client` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `_enable_tcp_keepalive` from `airflow.providers.cncf.kubernetes.kube_client` instead. ℹ Unsafe fix 10 10 | ) @@ -163,16 +169,17 @@ AIR302_kubernetes.py:29:1: AIR302 [*] `airflow.kubernetes.kube_client._enable_tc 22 22 | ALL_NAMESPACES 23 23 | POD_EXECUTOR_DONE_KEY -AIR302_kubernetes.py:30:1: AIR302 [*] `airflow.kubernetes.kube_client.get_kube_client` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kube_client.get_kube_client` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:30:1 | 28 | _disable_verify_ssl() 29 | _enable_tcp_keepalive() 30 | get_kube_client() - | ^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^ 31 | 32 | add_pod_suffix() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `get_kube_client` from `airflow.providers.cncf.kubernetes.kube_client` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `get_kube_client` from `airflow.providers.cncf.kubernetes.kube_client` instead. ℹ Unsafe fix 11 11 | from airflow.kubernetes.kube_client import ( @@ -190,16 +197,17 @@ AIR302_kubernetes.py:30:1: AIR302 [*] `airflow.kubernetes.kube_client.get_kube_c 22 22 | ALL_NAMESPACES 23 23 | POD_EXECUTOR_DONE_KEY -AIR302_kubernetes.py:32:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.add_pod_suffix` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.add_pod_suffix` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:32:1 | 30 | get_kube_client() 31 | 32 | add_pod_suffix() - | ^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^ 33 | annotations_for_logging_task_metadata() 34 | create_pod_id() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=10.0.0` and use `add_unique_suffix` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=10.0.0` and use `add_unique_suffix` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. ℹ Safe fix 18 18 | annotations_for_logging_task_metadata, @@ -219,14 +227,15 @@ AIR302_kubernetes.py:32:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_func 34 35 | create_pod_id() 35 36 | -AIR302_kubernetes.py:33:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.annotations_for_logging_task_metadata` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.annotations_for_logging_task_metadata` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:33:1 | 32 | add_pod_suffix() 33 | annotations_for_logging_task_metadata() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | create_pod_id() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `annotations_for_logging_task_metadata` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `annotations_for_logging_task_metadata` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. ℹ Unsafe fix 15 15 | ) @@ -240,14 +249,15 @@ AIR302_kubernetes.py:33:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_func 22 22 | ALL_NAMESPACES 23 23 | POD_EXECUTOR_DONE_KEY -AIR302_kubernetes.py:34:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.create_pod_id` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.create_pod_id` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:34:1 | 32 | add_pod_suffix() 33 | annotations_for_logging_task_metadata() 34 | create_pod_id() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-cncf-kubernetes>=10.0.0` and use `create_unique_id` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=10.0.0` and use `create_unique_id` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. ℹ Safe fix 18 18 | annotations_for_logging_task_metadata, @@ -267,16 +277,17 @@ AIR302_kubernetes.py:34:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_func 36 37 | 37 38 | from airflow.kubernetes.pod_generator import ( -AIR302_kubernetes.py:49:1: AIR302 [*] `airflow.kubernetes.pod_generator.PodDefaults` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.PodDefaults` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:49:1 | 47 | ) 48 | 49 | PodDefaults() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 50 | PodGenerator() 51 | add_pod_suffix() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodDefaults` from `airflow.providers.cncf.kubernetes.utils.xcom_sidecar` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodDefaults` from `airflow.providers.cncf.kubernetes.utils.xcom_sidecar` instead. ℹ Unsafe fix 35 35 | @@ -295,15 +306,16 @@ AIR302_kubernetes.py:49:1: AIR302 [*] `airflow.kubernetes.pod_generator.PodDefau 49 49 | PodDefaults() 50 50 | PodGenerator() -AIR302_kubernetes.py:50:1: AIR302 [*] `airflow.kubernetes.pod_generator.PodGenerator` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.PodGenerator` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:50:1 | 49 | PodDefaults() 50 | PodGenerator() - | ^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^ 51 | add_pod_suffix() 52 | datetime_to_label_safe_datestring() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodGenerator` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodGenerator` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 36 36 | @@ -322,16 +334,17 @@ AIR302_kubernetes.py:50:1: AIR302 [*] `airflow.kubernetes.pod_generator.PodGener 49 49 | PodDefaults() 50 50 | PodGenerator() -AIR302_kubernetes.py:51:1: AIR302 [*] `airflow.kubernetes.pod_generator.add_pod_suffix` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.add_pod_suffix` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:51:1 | 49 | PodDefaults() 50 | PodGenerator() 51 | add_pod_suffix() - | ^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^ 52 | datetime_to_label_safe_datestring() 53 | extend_object_field() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=10.0.0` and use `add_unique_suffix` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=10.0.0` and use `add_unique_suffix` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. ℹ Safe fix 45 45 | merge_objects, @@ -347,16 +360,17 @@ AIR302_kubernetes.py:51:1: AIR302 [*] `airflow.kubernetes.pod_generator.add_pod_ 53 54 | extend_object_field() 54 55 | label_safe_datestring_to_datetime() -AIR302_kubernetes.py:52:1: AIR302 [*] `airflow.kubernetes.pod_generator.datetime_to_label_safe_datestring` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.datetime_to_label_safe_datestring` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:52:1 | 50 | PodGenerator() 51 | add_pod_suffix() 52 | datetime_to_label_safe_datestring() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 53 | extend_object_field() 54 | label_safe_datestring_to_datetime() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `datetime_to_label_safe_datestring` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `datetime_to_label_safe_datestring` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 38 38 | PodDefaults, @@ -374,16 +388,17 @@ AIR302_kubernetes.py:52:1: AIR302 [*] `airflow.kubernetes.pod_generator.datetime 49 49 | PodDefaults() 50 50 | PodGenerator() -AIR302_kubernetes.py:53:1: AIR302 [*] `airflow.kubernetes.pod_generator.extend_object_field` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.extend_object_field` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:53:1 | 51 | add_pod_suffix() 52 | datetime_to_label_safe_datestring() 53 | extend_object_field() - | ^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^ 54 | label_safe_datestring_to_datetime() 55 | make_safe_label_value() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `extend_object_field` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `extend_object_field` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 39 39 | PodGenerator, @@ -400,16 +415,17 @@ AIR302_kubernetes.py:53:1: AIR302 [*] `airflow.kubernetes.pod_generator.extend_o 49 49 | PodDefaults() 50 50 | PodGenerator() -AIR302_kubernetes.py:54:1: AIR302 [*] `airflow.kubernetes.pod_generator.label_safe_datestring_to_datetime` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.label_safe_datestring_to_datetime` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:54:1 | 52 | datetime_to_label_safe_datestring() 53 | extend_object_field() 54 | label_safe_datestring_to_datetime() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | make_safe_label_value() 56 | merge_objects() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `label_safe_datestring_to_datetime` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `label_safe_datestring_to_datetime` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 40 40 | add_pod_suffix, @@ -425,16 +441,17 @@ AIR302_kubernetes.py:54:1: AIR302 [*] `airflow.kubernetes.pod_generator.label_sa 49 49 | PodDefaults() 50 50 | PodGenerator() -AIR302_kubernetes.py:55:1: AIR302 [*] `airflow.kubernetes.pod_generator.make_safe_label_value` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.make_safe_label_value` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:55:1 | 53 | extend_object_field() 54 | label_safe_datestring_to_datetime() 55 | make_safe_label_value() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 56 | merge_objects() 57 | rand_str() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `make_safe_label_value` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `make_safe_label_value` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 41 41 | datetime_to_label_safe_datestring, @@ -449,15 +466,16 @@ AIR302_kubernetes.py:55:1: AIR302 [*] `airflow.kubernetes.pod_generator.make_saf 49 49 | PodDefaults() 50 50 | PodGenerator() -AIR302_kubernetes.py:56:1: AIR302 [*] `airflow.kubernetes.pod_generator.merge_objects` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.merge_objects` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:56:1 | 54 | label_safe_datestring_to_datetime() 55 | make_safe_label_value() 56 | merge_objects() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ 57 | rand_str() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `merge_objects` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `merge_objects` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 42 42 | extend_object_field, @@ -471,16 +489,17 @@ AIR302_kubernetes.py:56:1: AIR302 [*] `airflow.kubernetes.pod_generator.merge_ob 49 49 | PodDefaults() 50 50 | PodGenerator() -AIR302_kubernetes.py:57:1: AIR302 [*] `airflow.kubernetes.pod_generator.rand_str` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.rand_str` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:57:1 | 55 | make_safe_label_value() 56 | merge_objects() 57 | rand_str() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 58 | 59 | from airflow.kubernetes.pod_generator_deprecated import ( | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `rand_str` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `rand_str` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. ℹ Unsafe fix 43 43 | label_safe_datestring_to_datetime, @@ -493,16 +512,17 @@ AIR302_kubernetes.py:57:1: AIR302 [*] `airflow.kubernetes.pod_generator.rand_str 49 49 | PodDefaults() 50 50 | PodGenerator() -AIR302_kubernetes.py:69:1: AIR302 [*] `airflow.kubernetes.pod_generator_deprecated.PodDefaults` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator_deprecated.PodDefaults` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:69:1 | 67 | ) 68 | 69 | PodDefaults() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 70 | PodGenerator() 71 | make_safe_label_value() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodDefaults` from `airflow.providers.cncf.kubernetes.utils.xcom_sidecar` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodDefaults` from `airflow.providers.cncf.kubernetes.utils.xcom_sidecar` instead. ℹ Unsafe fix 57 57 | rand_str() @@ -521,14 +541,15 @@ AIR302_kubernetes.py:69:1: AIR302 [*] `airflow.kubernetes.pod_generator_deprecat 69 69 | PodDefaults() 70 70 | PodGenerator() -AIR302_kubernetes.py:70:1: AIR302 [*] `airflow.kubernetes.pod_generator_deprecated.PodGenerator` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator_deprecated.PodGenerator` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:70:1 | 69 | PodDefaults() 70 | PodGenerator() - | ^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^ 71 | make_safe_label_value() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodGenerator` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodGenerator` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 58 58 | @@ -546,16 +567,17 @@ AIR302_kubernetes.py:70:1: AIR302 [*] `airflow.kubernetes.pod_generator_deprecat 69 69 | PodDefaults() 70 70 | PodGenerator() -AIR302_kubernetes.py:71:1: AIR302 [*] `airflow.kubernetes.pod_generator_deprecated.make_safe_label_value` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator_deprecated.make_safe_label_value` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:71:1 | 69 | PodDefaults() 70 | PodGenerator() 71 | make_safe_label_value() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | PodLauncher() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `make_safe_label_value` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `make_safe_label_value` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 59 59 | from airflow.kubernetes.pod_generator_deprecated import ( @@ -572,15 +594,16 @@ AIR302_kubernetes.py:71:1: AIR302 [*] `airflow.kubernetes.pod_generator_deprecat 69 69 | PodDefaults() 70 70 | PodGenerator() -AIR302_kubernetes.py:73:1: AIR302 [*] `airflow.kubernetes.pod_launcher.PodLauncher` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_launcher.PodLauncher` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:73:1 | 71 | make_safe_label_value() 72 | 73 | PodLauncher() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 74 | PodStatus() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=3.0.0` and use `PodManager` from `airflow.providers.cncf.kubernetes.utils.pod_manager` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=3.0.0` and use `PodManager` from `airflow.providers.cncf.kubernetes.utils.pod_manager` instead. ℹ Safe fix 65 65 | PodLauncher, @@ -598,15 +621,16 @@ AIR302_kubernetes.py:73:1: AIR302 [*] `airflow.kubernetes.pod_launcher.PodLaunch 75 76 | 76 77 | from airflow.kubernetes.pod_launcher_deprecated import ( -AIR302_kubernetes.py:74:1: AIR302 [*] `airflow.kubernetes.pod_launcher.PodStatus` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_launcher.PodStatus` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:74:1 | 73 | PodLauncher() 74 | PodStatus() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 75 | 76 | from airflow.kubernetes.pod_launcher_deprecated import ( | - = help: Install `apache-airflow-providers-cncf-kubernetes>=3.0.0` and use `PodPhase` from ` airflow.providers.cncf.kubernetes.utils.pod_manager` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=3.0.0` and use `PodPhase` from ` airflow.providers.cncf.kubernetes.utils.pod_manager` instead. ℹ Safe fix 65 65 | PodLauncher, @@ -625,16 +649,17 @@ AIR302_kubernetes.py:74:1: AIR302 [*] `airflow.kubernetes.pod_launcher.PodStatus 76 77 | from airflow.kubernetes.pod_launcher_deprecated import ( 77 78 | PodDefaults, -AIR302_kubernetes.py:90:1: AIR302 [*] `airflow.kubernetes.pod_launcher_deprecated.PodDefaults` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_launcher_deprecated.PodDefaults` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:90:1 | 88 | from airflow.kubernetes.volume_mount import VolumeMount 89 | 90 | PodDefaults() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 91 | PodLauncher() 92 | PodStatus() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodDefaults` from `airflow.providers.cncf.kubernetes.utils.xcom_sidecar` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodDefaults` from `airflow.providers.cncf.kubernetes.utils.xcom_sidecar` instead. ℹ Unsafe fix 74 74 | PodStatus() @@ -653,15 +678,16 @@ AIR302_kubernetes.py:90:1: AIR302 [*] `airflow.kubernetes.pod_launcher_deprecate 90 90 | PodDefaults() 91 91 | PodLauncher() -AIR302_kubernetes.py:91:1: AIR302 [*] `airflow.kubernetes.pod_launcher_deprecated.PodLauncher` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_launcher_deprecated.PodLauncher` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:91:1 | 90 | PodDefaults() 91 | PodLauncher() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 92 | PodStatus() 93 | get_kube_client() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=3.0.0` and use `PodManager` from `airflow.providers.cncf.kubernetes.utils.pod_manager` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=3.0.0` and use `PodManager` from `airflow.providers.cncf.kubernetes.utils.pod_manager` instead. ℹ Safe fix 86 86 | ) @@ -676,15 +702,16 @@ AIR302_kubernetes.py:91:1: AIR302 [*] `airflow.kubernetes.pod_launcher_deprecate 93 94 | get_kube_client() 94 95 | -AIR302_kubernetes.py:92:1: AIR302 [*] `airflow.kubernetes.pod_launcher_deprecated.PodStatus` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_launcher_deprecated.PodStatus` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:92:1 | 90 | PodDefaults() 91 | PodLauncher() 92 | PodStatus() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 93 | get_kube_client() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=3.0.0` and use `PodPhase` from ` airflow.providers.cncf.kubernetes.utils.pod_manager` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=3.0.0` and use `PodPhase` from ` airflow.providers.cncf.kubernetes.utils.pod_manager` instead. ℹ Safe fix 86 86 | ) @@ -700,16 +727,17 @@ AIR302_kubernetes.py:92:1: AIR302 [*] `airflow.kubernetes.pod_launcher_deprecate 94 95 | 95 96 | PodRuntimeInfoEnv() -AIR302_kubernetes.py:93:1: AIR302 [*] `airflow.kubernetes.pod_launcher_deprecated.get_kube_client` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_launcher_deprecated.get_kube_client` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:93:1 | 91 | PodLauncher() 92 | PodStatus() 93 | get_kube_client() - | ^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^ 94 | 95 | PodRuntimeInfoEnv() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `get_kube_client` from `airflow.providers.cncf.kubernetes.kube_client` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `get_kube_client` from `airflow.providers.cncf.kubernetes.kube_client` instead. ℹ Unsafe fix 77 77 | PodDefaults, @@ -728,16 +756,17 @@ AIR302_kubernetes.py:93:1: AIR302 [*] `airflow.kubernetes.pod_launcher_deprecate 90 90 | PodDefaults() 91 91 | PodLauncher() -AIR302_kubernetes.py:95:1: AIR302 [*] `airflow.kubernetes.pod_runtime_info_env.PodRuntimeInfoEnv` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_runtime_info_env.PodRuntimeInfoEnv` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:95:1 | 93 | get_kube_client() 94 | 95 | PodRuntimeInfoEnv() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ 96 | K8SModel() 97 | Secret() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `V1EnvVar` from `kubernetes.client.models` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `V1EnvVar` from `kubernetes.client.models` instead. ℹ Safe fix 86 86 | ) @@ -756,15 +785,16 @@ AIR302_kubernetes.py:95:1: AIR302 [*] `airflow.kubernetes.pod_runtime_info_env.P 97 98 | Secret() 98 99 | Volume() -AIR302_kubernetes.py:96:1: AIR302 [*] `airflow.kubernetes.secret.K8SModel` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.secret.K8SModel` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:96:1 | 95 | PodRuntimeInfoEnv() 96 | K8SModel() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 97 | Secret() 98 | Volume() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `K8SModel` from `airflow.providers.cncf.kubernetes.k8s_model` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `K8SModel` from `airflow.providers.cncf.kubernetes.k8s_model` instead. ℹ Unsafe fix 81 81 | ) @@ -780,16 +810,17 @@ AIR302_kubernetes.py:96:1: AIR302 [*] `airflow.kubernetes.secret.K8SModel` is mo 90 90 | PodDefaults() 91 91 | PodLauncher() -AIR302_kubernetes.py:97:1: AIR302 [*] `airflow.kubernetes.secret.Secret` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.secret.Secret` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:97:1 | 95 | PodRuntimeInfoEnv() 96 | K8SModel() 97 | Secret() - | ^^^^^^ AIR302 + | ^^^^^^ 98 | Volume() 99 | VolumeMount() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `Secret` from `airflow.providers.cncf.kubernetes.secret` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `Secret` from `airflow.providers.cncf.kubernetes.secret` instead. ℹ Unsafe fix 82 82 | from airflow.kubernetes.pod_runtime_info_env import PodRuntimeInfoEnv @@ -804,15 +835,16 @@ AIR302_kubernetes.py:97:1: AIR302 [*] `airflow.kubernetes.secret.Secret` is move 90 90 | PodDefaults() 91 91 | PodLauncher() -AIR302_kubernetes.py:98:1: AIR302 [*] `airflow.kubernetes.volume.Volume` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.volume.Volume` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:98:1 | 96 | K8SModel() 97 | Secret() 98 | Volume() - | ^^^^^^ AIR302 + | ^^^^^^ 99 | VolumeMount() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `V1Volume` from `kubernetes.client.models` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `V1Volume` from `kubernetes.client.models` instead. ℹ Safe fix 86 86 | ) @@ -832,16 +864,17 @@ AIR302_kubernetes.py:98:1: AIR302 [*] `airflow.kubernetes.volume.Volume` is move 100 101 | 101 102 | from airflow.kubernetes.kubernetes_helper_functions import ( -AIR302_kubernetes.py:99:1: AIR302 [*] `airflow.kubernetes.volume_mount.VolumeMount` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.volume_mount.VolumeMount` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:99:1 | 97 | Secret() 98 | Volume() 99 | VolumeMount() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ 100 | 101 | from airflow.kubernetes.kubernetes_helper_functions import ( | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `V1VolumeMount` from `kubernetes.client.models` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `V1VolumeMount` from `kubernetes.client.models` instead. ℹ Safe fix 86 86 | ) @@ -861,16 +894,17 @@ AIR302_kubernetes.py:99:1: AIR302 [*] `airflow.kubernetes.volume_mount.VolumeMou 101 102 | from airflow.kubernetes.kubernetes_helper_functions import ( 102 103 | annotations_to_key, -AIR302_kubernetes.py:107:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.annotations_to_key` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.annotations_to_key` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:107:1 | 105 | ) 106 | 107 | annotations_to_key() - | ^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^ 108 | get_logs_task_metadata() 109 | rand_str() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `annotations_to_key` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `annotations_to_key` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. ℹ Unsafe fix 99 99 | VolumeMount() @@ -885,14 +919,15 @@ AIR302_kubernetes.py:107:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_fun 107 107 | annotations_to_key() 108 108 | get_logs_task_metadata() -AIR302_kubernetes.py:108:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.get_logs_task_metadata` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.get_logs_task_metadata` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:108:1 | 107 | annotations_to_key() 108 | get_logs_task_metadata() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^ 109 | rand_str() | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `get_logs_task_metadata` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `get_logs_task_metadata` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. ℹ Unsafe fix 100 100 | @@ -906,16 +941,17 @@ AIR302_kubernetes.py:108:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_fun 107 107 | annotations_to_key() 108 108 | get_logs_task_metadata() -AIR302_kubernetes.py:109:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.rand_str` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.kubernetes_helper_functions.rand_str` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:109:1 | 107 | annotations_to_key() 108 | get_logs_task_metadata() 109 | rand_str() - | ^^^^^^^^ AIR302 + | ^^^^^^^^ 110 | 111 | from airflow.kubernetes.pod_generator import PodGeneratorDeprecated | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `rand_str` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `rand_str` from `airflow.providers.cncf.kubernetes.kubernetes_helper_functions` instead. ℹ Unsafe fix 101 101 | from airflow.kubernetes.kubernetes_helper_functions import ( @@ -928,14 +964,15 @@ AIR302_kubernetes.py:109:1: AIR302 [*] `airflow.kubernetes.kubernetes_helper_fun 107 107 | annotations_to_key() 108 108 | get_logs_task_metadata() -AIR302_kubernetes.py:113:1: AIR302 [*] `airflow.kubernetes.pod_generator.PodGeneratorDeprecated` is moved into `cncf-kubernetes` provider in Airflow 3.0; +AIR302 [*] `airflow.kubernetes.pod_generator.PodGeneratorDeprecated` is moved into `cncf-kubernetes` provider in Airflow 3.0; + --> AIR302_kubernetes.py:113:1 | 111 | from airflow.kubernetes.pod_generator import PodGeneratorDeprecated 112 | 113 | PodGeneratorDeprecated() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodGenerator` from `airflow.providers.cncf.kubernetes.pod_generator` instead. +help: Install `apache-airflow-providers-cncf-kubernetes>=7.4.0` and use `PodGenerator` from `airflow.providers.cncf.kubernetes.pod_generator` instead. ℹ Unsafe fix 109 109 | rand_str() diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_mysql.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_mysql.py.snap index 7dee3ad223..be6bb3af6c 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_mysql.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_mysql.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_mysql.py:9:1: AIR302 [*] `airflow.hooks.mysql_hook.MySqlHook` is moved into `mysql` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.mysql_hook.MySqlHook` is moved into `mysql` provider in Airflow 3.0; + --> AIR302_mysql.py:9:1 | 7 | ) 8 | 9 | MySqlHook() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 10 | PrestoToMySqlOperator() 11 | PrestoToMySqlTransfer() | - = help: Install `apache-airflow-providers-mysql>=1.0.0` and use `MySqlHook` from `airflow.providers.mysql.hooks.mysql` instead. +help: Install `apache-airflow-providers-mysql>=1.0.0` and use `MySqlHook` from `airflow.providers.mysql.hooks.mysql` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -25,14 +26,15 @@ AIR302_mysql.py:9:1: AIR302 [*] `airflow.hooks.mysql_hook.MySqlHook` is moved in 9 9 | MySqlHook() 10 10 | PrestoToMySqlOperator() -AIR302_mysql.py:10:1: AIR302 [*] `airflow.operators.presto_to_mysql.PrestoToMySqlOperator` is moved into `mysql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.presto_to_mysql.PrestoToMySqlOperator` is moved into `mysql` provider in Airflow 3.0; + --> AIR302_mysql.py:10:1 | 9 | MySqlHook() 10 | PrestoToMySqlOperator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 11 | PrestoToMySqlTransfer() | - = help: Install `apache-airflow-providers-mysql>=1.0.0` and use `PrestoToMySqlOperator` from `airflow.providers.mysql.transfers.presto_to_mysql` instead. +help: Install `apache-airflow-providers-mysql>=1.0.0` and use `PrestoToMySqlOperator` from `airflow.providers.mysql.transfers.presto_to_mysql` instead. ℹ Unsafe fix 2 2 | @@ -46,14 +48,15 @@ AIR302_mysql.py:10:1: AIR302 [*] `airflow.operators.presto_to_mysql.PrestoToMySq 9 9 | MySqlHook() 10 10 | PrestoToMySqlOperator() -AIR302_mysql.py:11:1: AIR302 [*] `airflow.operators.presto_to_mysql.PrestoToMySqlTransfer` is moved into `mysql` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.presto_to_mysql.PrestoToMySqlTransfer` is moved into `mysql` provider in Airflow 3.0; + --> AIR302_mysql.py:11:1 | 9 | MySqlHook() 10 | PrestoToMySqlOperator() 11 | PrestoToMySqlTransfer() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-mysql>=1.0.0` and use `PrestoToMySqlOperator` from `airflow.providers.mysql.transfers.presto_to_mysql` instead. +help: Install `apache-airflow-providers-mysql>=1.0.0` and use `PrestoToMySqlOperator` from `airflow.providers.mysql.transfers.presto_to_mysql` instead. ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_oracle.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_oracle.py.snap index c29dc82076..8dc85d21cc 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_oracle.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_oracle.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_oracle.py:5:1: AIR302 [*] `airflow.hooks.oracle_hook.OracleHook` is moved into `oracle` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.oracle_hook.OracleHook` is moved into `oracle` provider in Airflow 3.0; + --> AIR302_oracle.py:5:1 | 3 | from airflow.hooks.oracle_hook import OracleHook 4 | 5 | OracleHook() - | ^^^^^^^^^^ AIR302 + | ^^^^^^^^^^ | - = help: Install `apache-airflow-providers-oracle>=1.0.0` and use `OracleHook` from `airflow.providers.oracle.hooks.oracle` instead. +help: Install `apache-airflow-providers-oracle>=1.0.0` and use `OracleHook` from `airflow.providers.oracle.hooks.oracle` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_papermill.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_papermill.py.snap index 99e06729e5..52fdb8d0c4 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_papermill.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_papermill.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_papermill.py:5:1: AIR302 [*] `airflow.operators.papermill_operator.PapermillOperator` is moved into `papermill` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.papermill_operator.PapermillOperator` is moved into `papermill` provider in Airflow 3.0; + --> AIR302_papermill.py:5:1 | 3 | from airflow.operators.papermill_operator import PapermillOperator 4 | 5 | PapermillOperator() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-papermill>=1.0.0` and use `PapermillOperator` from `airflow.providers.papermill.operators.papermill` instead. +help: Install `apache-airflow-providers-papermill>=1.0.0` and use `PapermillOperator` from `airflow.providers.papermill.operators.papermill` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_pig.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_pig.py.snap index a9e0812af0..7f3d08abfd 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_pig.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_pig.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_pig.py:6:1: AIR302 [*] `airflow.hooks.pig_hook.PigCliHook` is moved into `apache-pig` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.pig_hook.PigCliHook` is moved into `apache-pig` provider in Airflow 3.0; + --> AIR302_pig.py:6:1 | 4 | from airflow.operators.pig_operator import PigOperator 5 | 6 | PigCliHook() - | ^^^^^^^^^^ AIR302 + | ^^^^^^^^^^ 7 | PigOperator() | - = help: Install `apache-airflow-providers-apache-pig>=1.0.0` and use `PigCliHook` from `airflow.providers.apache.pig.hooks.pig` instead. +help: Install `apache-airflow-providers-apache-pig>=1.0.0` and use `PigCliHook` from `airflow.providers.apache.pig.hooks.pig` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -21,13 +22,14 @@ AIR302_pig.py:6:1: AIR302 [*] `airflow.hooks.pig_hook.PigCliHook` is moved into 6 6 | PigCliHook() 7 7 | PigOperator() -AIR302_pig.py:7:1: AIR302 [*] `airflow.operators.pig_operator.PigOperator` is moved into `apache-pig` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.pig_operator.PigOperator` is moved into `apache-pig` provider in Airflow 3.0; + --> AIR302_pig.py:7:1 | 6 | PigCliHook() 7 | PigOperator() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-apache-pig>=1.0.0` and use `PigOperator` from `airflow.providers.apache.pig.operators.pig` instead. +help: Install `apache-airflow-providers-apache-pig>=1.0.0` and use `PigOperator` from `airflow.providers.apache.pig.operators.pig` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_postgres.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_postgres.py.snap index 6f026c0465..a3fc68d859 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_postgres.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_postgres.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_postgres.py:6:1: AIR302 [*] `airflow.hooks.postgres_hook.PostgresHook` is moved into `postgres` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.postgres_hook.PostgresHook` is moved into `postgres` provider in Airflow 3.0; + --> AIR302_postgres.py:6:1 | 4 | from airflow.operators.postgres_operator import Mapping 5 | 6 | PostgresHook() - | ^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^ 7 | Mapping() | - = help: Install `apache-airflow-providers-postgres>=1.0.0` and use `PostgresHook` from `airflow.providers.postgres.hooks.postgres` instead. +help: Install `apache-airflow-providers-postgres>=1.0.0` and use `PostgresHook` from `airflow.providers.postgres.hooks.postgres` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -21,9 +22,10 @@ AIR302_postgres.py:6:1: AIR302 [*] `airflow.hooks.postgres_hook.PostgresHook` is 6 6 | PostgresHook() 7 7 | Mapping() -AIR302_postgres.py:7:1: AIR302 `airflow.operators.postgres_operator.Mapping` is removed in Airflow 3.0 +AIR302 `airflow.operators.postgres_operator.Mapping` is removed in Airflow 3.0 + --> AIR302_postgres.py:7:1 | 6 | PostgresHook() 7 | Mapping() - | ^^^^^^^ AIR302 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_presto.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_presto.py.snap index 3c0117a196..fcf52b13db 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_presto.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_presto.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_presto.py:5:1: AIR302 [*] `airflow.hooks.presto_hook.PrestoHook` is moved into `presto` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.presto_hook.PrestoHook` is moved into `presto` provider in Airflow 3.0; + --> AIR302_presto.py:5:1 | 3 | from airflow.hooks.presto_hook import PrestoHook 4 | 5 | PrestoHook() - | ^^^^^^^^^^ AIR302 + | ^^^^^^^^^^ | - = help: Install `apache-airflow-providers-presto>=1.0.0` and use `PrestoHook` from `airflow.providers.presto.hooks.presto` instead. +help: Install `apache-airflow-providers-presto>=1.0.0` and use `PrestoHook` from `airflow.providers.presto.hooks.presto` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_samba.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_samba.py.snap index 02ec8f7313..715985d795 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_samba.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_samba.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_samba.py:5:1: AIR302 [*] `airflow.hooks.samba_hook.SambaHook` is moved into `samba` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.samba_hook.SambaHook` is moved into `samba` provider in Airflow 3.0; + --> AIR302_samba.py:5:1 | 3 | from airflow.hooks.samba_hook import SambaHook 4 | 5 | SambaHook() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ | - = help: Install `apache-airflow-providers-samba>=1.0.0` and use `SambaHook` from `airflow.providers.samba.hooks.samba` instead. +help: Install `apache-airflow-providers-samba>=1.0.0` and use `SambaHook` from `airflow.providers.samba.hooks.samba` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_slack.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_slack.py.snap index fbb1c5033c..018cc38991 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_slack.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_slack.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_slack.py:6:1: AIR302 [*] `airflow.hooks.slack_hook.SlackHook` is moved into `slack` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.slack_hook.SlackHook` is moved into `slack` provider in Airflow 3.0; + --> AIR302_slack.py:6:1 | 4 | from airflow.operators.slack_operator import SlackAPIOperator, SlackAPIPostOperator 5 | 6 | SlackHook() - | ^^^^^^^^^ AIR302 + | ^^^^^^^^^ 7 | SlackAPIOperator() 8 | SlackAPIPostOperator() | - = help: Install `apache-airflow-providers-slack>=1.0.0` and use `SlackHook` from `airflow.providers.slack.hooks.slack` instead. +help: Install `apache-airflow-providers-slack>=1.0.0` and use `SlackHook` from `airflow.providers.slack.hooks.slack` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -22,14 +23,15 @@ AIR302_slack.py:6:1: AIR302 [*] `airflow.hooks.slack_hook.SlackHook` is moved in 6 6 | SlackHook() 7 7 | SlackAPIOperator() -AIR302_slack.py:7:1: AIR302 [*] `airflow.operators.slack_operator.SlackAPIOperator` is moved into `slack` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.slack_operator.SlackAPIOperator` is moved into `slack` provider in Airflow 3.0; + --> AIR302_slack.py:7:1 | 6 | SlackHook() 7 | SlackAPIOperator() - | ^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^ 8 | SlackAPIPostOperator() | - = help: Install `apache-airflow-providers-slack>=1.0.0` and use `SlackAPIOperator` from `airflow.providers.slack.operators.slack` instead. +help: Install `apache-airflow-providers-slack>=1.0.0` and use `SlackAPIOperator` from `airflow.providers.slack.operators.slack` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -42,14 +44,15 @@ AIR302_slack.py:7:1: AIR302 [*] `airflow.operators.slack_operator.SlackAPIOperat 6 7 | SlackHook() 7 8 | SlackAPIOperator() -AIR302_slack.py:8:1: AIR302 [*] `airflow.operators.slack_operator.SlackAPIPostOperator` is moved into `slack` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.slack_operator.SlackAPIPostOperator` is moved into `slack` provider in Airflow 3.0; + --> AIR302_slack.py:8:1 | 6 | SlackHook() 7 | SlackAPIOperator() 8 | SlackAPIPostOperator() - | ^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-slack>=1.0.0` and use `SlackAPIPostOperator` from `airflow.providers.slack.operators.slack` instead. +help: Install `apache-airflow-providers-slack>=1.0.0` and use `SlackAPIPostOperator` from `airflow.providers.slack.operators.slack` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_smtp.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_smtp.py.snap index ed41848604..14e55dc53c 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_smtp.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_smtp.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_smtp.py:5:1: AIR302 [*] `airflow.operators.email_operator.EmailOperator` is moved into `smtp` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.email_operator.EmailOperator` is moved into `smtp` provider in Airflow 3.0; + --> AIR302_smtp.py:5:1 | 3 | from airflow.operators.email_operator import EmailOperator 4 | 5 | EmailOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ 6 | 7 | from airflow.operators.email import EmailOperator | - = help: Install `apache-airflow-providers-smtp>=1.0.0` and use `EmailOperator` from `airflow.providers.smtp.operators.smtp` instead. +help: Install `apache-airflow-providers-smtp>=1.0.0` and use `EmailOperator` from `airflow.providers.smtp.operators.smtp` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -21,14 +22,15 @@ AIR302_smtp.py:5:1: AIR302 [*] `airflow.operators.email_operator.EmailOperator` 5 5 | EmailOperator() 6 6 | -AIR302_smtp.py:9:1: AIR302 [*] `airflow.operators.email.EmailOperator` is moved into `smtp` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.email.EmailOperator` is moved into `smtp` provider in Airflow 3.0; + --> AIR302_smtp.py:9:1 | 7 | from airflow.operators.email import EmailOperator 8 | 9 | EmailOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-smtp>=1.0.0` and use `EmailOperator` from `airflow.providers.smtp.operators.smtp` instead. +help: Install `apache-airflow-providers-smtp>=1.0.0` and use `EmailOperator` from `airflow.providers.smtp.operators.smtp` instead. ℹ Unsafe fix 4 4 | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_sqlite.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_sqlite.py.snap index 543d17fc0c..114f5101a3 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_sqlite.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_sqlite.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_sqlite.py:5:1: AIR302 [*] `airflow.hooks.sqlite_hook.SqliteHook` is moved into `sqlite` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.sqlite_hook.SqliteHook` is moved into `sqlite` provider in Airflow 3.0; + --> AIR302_sqlite.py:5:1 | 3 | from airflow.hooks.sqlite_hook import SqliteHook 4 | 5 | SqliteHook() - | ^^^^^^^^^^ AIR302 + | ^^^^^^^^^^ | - = help: Install `apache-airflow-providers-sqlite>=1.0.0` and use `SqliteHook` from `airflow.providers.sqlite.hooks.sqlite` instead. +help: Install `apache-airflow-providers-sqlite>=1.0.0` and use `SqliteHook` from `airflow.providers.sqlite.hooks.sqlite` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_standard.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_standard.py.snap index 4ad415626d..5b3da4538e 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_standard.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_standard.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_standard.py:20:1: AIR302 [*] `airflow.operators.bash_operator.BashOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.bash_operator.BashOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:20:1 | 18 | ) 19 | 20 | BashOperator() - | ^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^ 21 | 22 | TriggerDagRunLink() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `BashOperator` from `airflow.providers.standard.operators.bash` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `BashOperator` from `airflow.providers.standard.operators.bash` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -28,15 +29,16 @@ AIR302_standard.py:20:1: AIR302 [*] `airflow.operators.bash_operator.BashOperato 20 20 | BashOperator() 21 21 | -AIR302_standard.py:22:1: AIR302 [*] `airflow.operators.dagrun_operator.TriggerDagRunLink` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.dagrun_operator.TriggerDagRunLink` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:22:1 | 20 | BashOperator() 21 | 22 | TriggerDagRunLink() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ 23 | TriggerDagRunOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `TriggerDagRunLink` from `airflow.providers.standard.operators.trigger_dagrun` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `TriggerDagRunLink` from `airflow.providers.standard.operators.trigger_dagrun` instead. ℹ Unsafe fix 2 2 | @@ -55,15 +57,16 @@ AIR302_standard.py:22:1: AIR302 [*] `airflow.operators.dagrun_operator.TriggerDa 20 20 | BashOperator() 21 21 | -AIR302_standard.py:23:1: AIR302 [*] `airflow.operators.dagrun_operator.TriggerDagRunOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.dagrun_operator.TriggerDagRunOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:23:1 | 22 | TriggerDagRunLink() 23 | TriggerDagRunOperator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 24 | 25 | LatestOnlyOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `TriggerDagRunOperator` from `airflow.providers.standard.operators.trigger_dagrun` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `TriggerDagRunOperator` from `airflow.providers.standard.operators.trigger_dagrun` instead. ℹ Unsafe fix 3 3 | from airflow.operators.bash_operator import BashOperator @@ -82,16 +85,17 @@ AIR302_standard.py:23:1: AIR302 [*] `airflow.operators.dagrun_operator.TriggerDa 20 20 | BashOperator() 21 21 | -AIR302_standard.py:25:1: AIR302 [*] `airflow.operators.latest_only_operator.LatestOnlyOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.latest_only_operator.LatestOnlyOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:25:1 | 23 | TriggerDagRunOperator() 24 | 25 | LatestOnlyOperator() - | ^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^ 26 | 27 | BranchPythonOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `LatestOnlyOperator` from `airflow.providers.standard.operators.latest_only` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `LatestOnlyOperator` from `airflow.providers.standard.operators.latest_only` instead. ℹ Unsafe fix 5 5 | TriggerDagRunLink, @@ -110,16 +114,17 @@ AIR302_standard.py:25:1: AIR302 [*] `airflow.operators.latest_only_operator.Late 20 20 | BashOperator() 21 21 | -AIR302_standard.py:27:1: AIR302 [*] `airflow.operators.python_operator.BranchPythonOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.python_operator.BranchPythonOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:27:1 | 25 | LatestOnlyOperator() 26 | 27 | BranchPythonOperator() - | ^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^ 28 | PythonOperator() 29 | PythonVirtualenvOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `BranchPythonOperator` from `airflow.providers.standard.operators.python` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `BranchPythonOperator` from `airflow.providers.standard.operators.python` instead. ℹ Unsafe fix 7 7 | ) @@ -138,15 +143,16 @@ AIR302_standard.py:27:1: AIR302 [*] `airflow.operators.python_operator.BranchPyt 20 20 | BashOperator() 21 21 | -AIR302_standard.py:28:1: AIR302 [*] `airflow.operators.python_operator.PythonOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.python_operator.PythonOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:28:1 | 27 | BranchPythonOperator() 28 | PythonOperator() - | ^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^ 29 | PythonVirtualenvOperator() 30 | ShortCircuitOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `PythonOperator` from `airflow.providers.standard.operators.python` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `PythonOperator` from `airflow.providers.standard.operators.python` instead. ℹ Unsafe fix 8 8 | from airflow.operators.latest_only_operator import LatestOnlyOperator @@ -165,15 +171,16 @@ AIR302_standard.py:28:1: AIR302 [*] `airflow.operators.python_operator.PythonOpe 20 20 | BashOperator() 21 21 | -AIR302_standard.py:29:1: AIR302 [*] `airflow.operators.python_operator.PythonVirtualenvOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.python_operator.PythonVirtualenvOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:29:1 | 27 | BranchPythonOperator() 28 | PythonOperator() 29 | PythonVirtualenvOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 30 | ShortCircuitOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `PythonVirtualenvOperator` from `airflow.providers.standard.operators.python` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `PythonVirtualenvOperator` from `airflow.providers.standard.operators.python` instead. ℹ Unsafe fix 9 9 | from airflow.operators.python_operator import ( @@ -191,16 +198,17 @@ AIR302_standard.py:29:1: AIR302 [*] `airflow.operators.python_operator.PythonVir 20 20 | BashOperator() 21 21 | -AIR302_standard.py:30:1: AIR302 [*] `airflow.operators.python_operator.ShortCircuitOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.python_operator.ShortCircuitOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:30:1 | 28 | PythonOperator() 29 | PythonVirtualenvOperator() 30 | ShortCircuitOperator() - | ^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^ 31 | 32 | ExternalTaskMarker() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `ShortCircuitOperator` from `airflow.providers.standard.operators.python` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `ShortCircuitOperator` from `airflow.providers.standard.operators.python` instead. ℹ Unsafe fix 10 10 | BranchPythonOperator, @@ -217,15 +225,16 @@ AIR302_standard.py:30:1: AIR302 [*] `airflow.operators.python_operator.ShortCirc 20 20 | BashOperator() 21 21 | -AIR302_standard.py:32:1: AIR302 [*] `airflow.sensors.external_task_sensor.ExternalTaskMarker` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.external_task_sensor.ExternalTaskMarker` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:32:1 | 30 | ShortCircuitOperator() 31 | 32 | ExternalTaskMarker() - | ^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^ 33 | ExternalTaskSensor() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalTaskMarker` from `airflow.providers.standard.sensors.external_task` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalTaskMarker` from `airflow.providers.standard.sensors.external_task` instead. ℹ Unsafe fix 13 13 | ShortCircuitOperator, @@ -239,13 +248,14 @@ AIR302_standard.py:32:1: AIR302 [*] `airflow.sensors.external_task_sensor.Extern 20 20 | BashOperator() 21 21 | -AIR302_standard.py:33:1: AIR302 [*] `airflow.sensors.external_task_sensor.ExternalTaskSensor` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.external_task_sensor.ExternalTaskSensor` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:33:1 | 32 | ExternalTaskMarker() 33 | ExternalTaskSensor() - | ^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalTaskSensor` from `airflow.providers.standard.sensors.external_task` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalTaskSensor` from `airflow.providers.standard.sensors.external_task` instead. ℹ Unsafe fix 14 14 | ) @@ -258,16 +268,17 @@ AIR302_standard.py:33:1: AIR302 [*] `airflow.sensors.external_task_sensor.Extern 20 20 | BashOperator() 21 21 | -AIR302_standard.py:38:1: AIR302 [*] `airflow.hooks.subprocess.SubprocessResult` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.subprocess.SubprocessResult` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:38:1 | 36 | from airflow.hooks.subprocess import SubprocessResult 37 | 38 | SubprocessResult() - | ^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^ 39 | 40 | from airflow.hooks.subprocess import working_directory | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `SubprocessResult` from `airflow.providers.standard.hooks.subprocess` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `SubprocessResult` from `airflow.providers.standard.hooks.subprocess` instead. ℹ Unsafe fix 33 33 | ExternalTaskSensor() @@ -279,16 +290,17 @@ AIR302_standard.py:38:1: AIR302 [*] `airflow.hooks.subprocess.SubprocessResult` 38 38 | SubprocessResult() 39 39 | -AIR302_standard.py:42:1: AIR302 [*] `airflow.hooks.subprocess.working_directory` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.subprocess.working_directory` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:42:1 | 40 | from airflow.hooks.subprocess import working_directory 41 | 42 | working_directory() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ 43 | 44 | from airflow.operators.datetime import target_times_as_dates | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `working_directory` from `airflow.providers.standard.hooks.subprocess` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `working_directory` from `airflow.providers.standard.hooks.subprocess` instead. ℹ Unsafe fix 37 37 | @@ -300,16 +312,17 @@ AIR302_standard.py:42:1: AIR302 [*] `airflow.hooks.subprocess.working_directory` 42 42 | working_directory() 43 43 | -AIR302_standard.py:46:1: AIR302 [*] `airflow.operators.datetime.target_times_as_dates` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.datetime.target_times_as_dates` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:46:1 | 44 | from airflow.operators.datetime import target_times_as_dates 45 | 46 | target_times_as_dates() - | ^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^ 47 | 48 | from airflow.operators.trigger_dagrun import TriggerDagRunLink | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `target_times_as_dates` from `airflow.providers.standard.operators.datetime` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `target_times_as_dates` from `airflow.providers.standard.operators.datetime` instead. ℹ Unsafe fix 41 41 | @@ -321,16 +334,17 @@ AIR302_standard.py:46:1: AIR302 [*] `airflow.operators.datetime.target_times_as_ 46 46 | target_times_as_dates() 47 47 | -AIR302_standard.py:50:1: AIR302 [*] `airflow.operators.trigger_dagrun.TriggerDagRunLink` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.trigger_dagrun.TriggerDagRunLink` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:50:1 | 48 | from airflow.operators.trigger_dagrun import TriggerDagRunLink 49 | 50 | TriggerDagRunLink() - | ^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^ 51 | 52 | from airflow.sensors.external_task import ExternalTaskSensorLink | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `TriggerDagRunLink` from `airflow.providers.standard.operators.trigger_dagrun` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `TriggerDagRunLink` from `airflow.providers.standard.operators.trigger_dagrun` instead. ℹ Unsafe fix 45 45 | @@ -342,16 +356,17 @@ AIR302_standard.py:50:1: AIR302 [*] `airflow.operators.trigger_dagrun.TriggerDag 50 50 | TriggerDagRunLink() 51 51 | -AIR302_standard.py:54:1: AIR302 [*] `airflow.sensors.external_task.ExternalTaskSensorLink` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.external_task.ExternalTaskSensorLink` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:54:1 | 52 | from airflow.sensors.external_task import ExternalTaskSensorLink 53 | 54 | ExternalTaskSensorLink() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^ 55 | 56 | from airflow.sensors.time_delta import WaitSensor | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalDagLink` from `airflow.providers.standard.sensors.external_task` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalDagLink` from `airflow.providers.standard.sensors.external_task` instead. ℹ Safe fix 50 50 | TriggerDagRunLink() @@ -365,16 +380,17 @@ AIR302_standard.py:54:1: AIR302 [*] `airflow.sensors.external_task.ExternalTaskS 56 57 | from airflow.sensors.time_delta import WaitSensor 57 58 | -AIR302_standard.py:58:1: AIR302 [*] `airflow.sensors.time_delta.WaitSensor` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.time_delta.WaitSensor` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:58:1 | 56 | from airflow.sensors.time_delta import WaitSensor 57 | 58 | WaitSensor() - | ^^^^^^^^^^ AIR302 + | ^^^^^^^^^^ 59 | 60 | from airflow.operators.dummy import DummyOperator | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `WaitSensor` from `airflow.providers.standard.sensors.time_delta` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `WaitSensor` from `airflow.providers.standard.sensors.time_delta` instead. ℹ Unsafe fix 53 53 | @@ -386,16 +402,17 @@ AIR302_standard.py:58:1: AIR302 [*] `airflow.sensors.time_delta.WaitSensor` is m 58 58 | WaitSensor() 59 59 | -AIR302_standard.py:62:1: AIR302 [*] `airflow.operators.dummy.DummyOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.dummy.DummyOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:62:1 | 60 | from airflow.operators.dummy import DummyOperator 61 | 62 | DummyOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ 63 | 64 | from airflow.operators.dummy import EmptyOperator | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. ℹ Safe fix 58 58 | WaitSensor() @@ -409,16 +426,17 @@ AIR302_standard.py:62:1: AIR302 [*] `airflow.operators.dummy.DummyOperator` is m 64 65 | from airflow.operators.dummy import EmptyOperator 65 66 | -AIR302_standard.py:66:1: AIR302 [*] `airflow.operators.dummy.EmptyOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.dummy.EmptyOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:66:1 | 64 | from airflow.operators.dummy import EmptyOperator 65 | 66 | EmptyOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ 67 | 68 | from airflow.operators.dummy_operator import DummyOperator | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. ℹ Unsafe fix 61 61 | @@ -430,16 +448,17 @@ AIR302_standard.py:66:1: AIR302 [*] `airflow.operators.dummy.EmptyOperator` is m 66 66 | EmptyOperator() 67 67 | -AIR302_standard.py:70:1: AIR302 [*] `airflow.operators.dummy_operator.DummyOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.dummy_operator.DummyOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:70:1 | 68 | from airflow.operators.dummy_operator import DummyOperator 69 | 70 | DummyOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ 71 | 72 | from airflow.operators.dummy_operator import EmptyOperator | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. ℹ Unsafe fix 66 66 | EmptyOperator() @@ -450,16 +469,17 @@ AIR302_standard.py:70:1: AIR302 [*] `airflow.operators.dummy_operator.DummyOpera 70 71 | DummyOperator() 71 72 | -AIR302_standard.py:74:1: AIR302 [*] `airflow.operators.dummy_operator.EmptyOperator` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.operators.dummy_operator.EmptyOperator` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:74:1 | 72 | from airflow.operators.dummy_operator import EmptyOperator 73 | 74 | EmptyOperator() - | ^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^ 75 | 76 | from airflow.sensors.external_task_sensor import ExternalTaskSensorLink | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. ℹ Unsafe fix 69 69 | @@ -471,14 +491,15 @@ AIR302_standard.py:74:1: AIR302 [*] `airflow.operators.dummy_operator.EmptyOpera 74 74 | EmptyOperator() 75 75 | -AIR302_standard.py:78:1: AIR302 [*] `airflow.sensors.external_task_sensor.ExternalTaskSensorLink` is moved into `standard` provider in Airflow 3.0; +AIR302 [*] `airflow.sensors.external_task_sensor.ExternalTaskSensorLink` is moved into `standard` provider in Airflow 3.0; + --> AIR302_standard.py:78:1 | 76 | from airflow.sensors.external_task_sensor import ExternalTaskSensorLink 77 | 78 | ExternalTaskSensorLink() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalDagLink` from `airflow.providers.standard.sensors.external_task` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalDagLink` from `airflow.providers.standard.sensors.external_task` instead. ℹ Safe fix 74 74 | EmptyOperator() diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_zendesk.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_zendesk.py.snap index e0ee88653f..c6213da3a5 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_zendesk.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR302_AIR302_zendesk.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR302_zendesk.py:5:1: AIR302 [*] `airflow.hooks.zendesk_hook.ZendeskHook` is moved into `zendesk` provider in Airflow 3.0; +AIR302 [*] `airflow.hooks.zendesk_hook.ZendeskHook` is moved into `zendesk` provider in Airflow 3.0; + --> AIR302_zendesk.py:5:1 | 3 | from airflow.hooks.zendesk_hook import ZendeskHook 4 | 5 | ZendeskHook() - | ^^^^^^^^^^^ AIR302 + | ^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-zendesk>=1.0.0` and use `ZendeskHook` from `airflow.providers.zendesk.hooks.zendesk` instead. +help: Install `apache-airflow-providers-zendesk>=1.0.0` and use `ZendeskHook` from `airflow.providers.zendesk.hooks.zendesk` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_args.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_args.py.snap index 2637a92e53..871c3389d7 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_args.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_args.py.snap @@ -1,25 +1,28 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR311_args.py:13:34: AIR311 `sla_miss_callback` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 `sla_miss_callback` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_args.py:13:34 | 13 | DAG(dag_id="class_sla_callback", sla_miss_callback=sla_callback) - | ^^^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^^^ | -AIR311_args.py:16:6: AIR311 `sla_miss_callback` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 `sla_miss_callback` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_args.py:16:6 | 16 | @dag(sla_miss_callback=sla_callback) - | ^^^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^^^ 17 | def decorator_sla_callback(): 18 | pass | -AIR311_args.py:25:9: AIR311 `sla` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 `sla` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_args.py:25:9 | 23 | branch_dt_op2 = BranchDateTimeOperator( 24 | task_id="branch_dt_op2", 25 | sla=timedelta(seconds=10), - | ^^^ AIR311 + | ^^^ 26 | ) | diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_names.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_names.py.snap index b34b16ffcc..1477d7e535 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_names.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR311_AIR311_names.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR311_names.py:20:1: AIR311 [*] `airflow.Dataset` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.Dataset` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:20:1 | 19 | # airflow 20 | DatasetFromRoot() - | ^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^ 21 | 22 | # airflow.datasets | - = help: Use `Asset` from `airflow.sdk` instead. +help: Use `Asset` from `airflow.sdk` instead. ℹ Safe fix 15 15 | task, @@ -24,15 +25,16 @@ AIR311_names.py:20:1: AIR311 [*] `airflow.Dataset` is removed in Airflow 3.0; It 22 23 | # airflow.datasets 23 24 | Dataset() -AIR311_names.py:23:1: AIR311 [*] `airflow.datasets.Dataset` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.datasets.Dataset` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:23:1 | 22 | # airflow.datasets 23 | Dataset() - | ^^^^^^^ AIR311 + | ^^^^^^^ 24 | DatasetAlias() 25 | DatasetAll() | - = help: Use `Asset` from `airflow.sdk` instead. +help: Use `Asset` from `airflow.sdk` instead. ℹ Safe fix 15 15 | task, @@ -50,16 +52,17 @@ AIR311_names.py:23:1: AIR311 [*] `airflow.datasets.Dataset` is removed in Airflo 25 26 | DatasetAll() 26 27 | DatasetAny() -AIR311_names.py:24:1: AIR311 [*] `airflow.datasets.DatasetAlias` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.datasets.DatasetAlias` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:24:1 | 22 | # airflow.datasets 23 | Dataset() 24 | DatasetAlias() - | ^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^ 25 | DatasetAll() 26 | DatasetAny() | - = help: Use `AssetAlias` from `airflow.sdk` instead. +help: Use `AssetAlias` from `airflow.sdk` instead. ℹ Safe fix 15 15 | task, @@ -78,16 +81,17 @@ AIR311_names.py:24:1: AIR311 [*] `airflow.datasets.DatasetAlias` is removed in A 26 27 | DatasetAny() 27 28 | Metadata() -AIR311_names.py:25:1: AIR311 [*] `airflow.datasets.DatasetAll` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.datasets.DatasetAll` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:25:1 | 23 | Dataset() 24 | DatasetAlias() 25 | DatasetAll() - | ^^^^^^^^^^ AIR311 + | ^^^^^^^^^^ 26 | DatasetAny() 27 | Metadata() | - = help: Use `AssetAll` from `airflow.sdk` instead. +help: Use `AssetAll` from `airflow.sdk` instead. ℹ Safe fix 15 15 | task, @@ -107,16 +111,17 @@ AIR311_names.py:25:1: AIR311 [*] `airflow.datasets.DatasetAll` is removed in Air 27 28 | Metadata() 28 29 | expand_alias_to_datasets() -AIR311_names.py:26:1: AIR311 [*] `airflow.datasets.DatasetAny` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.datasets.DatasetAny` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:26:1 | 24 | DatasetAlias() 25 | DatasetAll() 26 | DatasetAny() - | ^^^^^^^^^^ AIR311 + | ^^^^^^^^^^ 27 | Metadata() 28 | expand_alias_to_datasets() | - = help: Use `AssetAny` from `airflow.sdk` instead. +help: Use `AssetAny` from `airflow.sdk` instead. ℹ Safe fix 15 15 | task, @@ -136,15 +141,16 @@ AIR311_names.py:26:1: AIR311 [*] `airflow.datasets.DatasetAny` is removed in Air 28 29 | expand_alias_to_datasets() 29 30 | -AIR311_names.py:27:1: AIR311 [*] `airflow.datasets.metadata.Metadata` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.datasets.metadata.Metadata` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:27:1 | 25 | DatasetAll() 26 | DatasetAny() 27 | Metadata() - | ^^^^^^^^ AIR311 + | ^^^^^^^^ 28 | expand_alias_to_datasets() | - = help: Use `Metadata` from `airflow.sdk` instead. +help: Use `Metadata` from `airflow.sdk` instead. ℹ Unsafe fix 8 8 | DatasetAny, @@ -162,16 +168,17 @@ AIR311_names.py:27:1: AIR311 [*] `airflow.datasets.metadata.Metadata` is removed 19 19 | # airflow 20 20 | DatasetFromRoot() -AIR311_names.py:28:1: AIR311 [*] `airflow.datasets.expand_alias_to_datasets` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.datasets.expand_alias_to_datasets` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:28:1 | 26 | DatasetAny() 27 | Metadata() 28 | expand_alias_to_datasets() - | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 29 | 30 | # airflow.decorators | - = help: Use `expand_alias_to_assets` from `airflow.models.asset` instead. +help: Use `expand_alias_to_assets` from `airflow.models.asset` instead. ℹ Safe fix 15 15 | task, @@ -191,15 +198,16 @@ AIR311_names.py:28:1: AIR311 [*] `airflow.datasets.expand_alias_to_datasets` is 30 31 | # airflow.decorators 31 32 | dag() -AIR311_names.py:31:1: AIR311 [*] `airflow.decorators.dag` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.decorators.dag` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:31:1 | 30 | # airflow.decorators 31 | dag() - | ^^^ AIR311 + | ^^^ 32 | task() 33 | task_group() | - = help: Use `dag` from `airflow.sdk` instead. +help: Use `dag` from `airflow.sdk` instead. ℹ Unsafe fix 10 10 | ) @@ -215,16 +223,17 @@ AIR311_names.py:31:1: AIR311 [*] `airflow.decorators.dag` is removed in Airflow 19 19 | # airflow 20 20 | DatasetFromRoot() -AIR311_names.py:32:1: AIR311 [*] `airflow.decorators.task` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.decorators.task` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:32:1 | 30 | # airflow.decorators 31 | dag() 32 | task() - | ^^^^ AIR311 + | ^^^^ 33 | task_group() 34 | setup() | - = help: Use `task` from `airflow.sdk` instead. +help: Use `task` from `airflow.sdk` instead. ℹ Unsafe fix 12 12 | from airflow.decorators import ( @@ -238,16 +247,17 @@ AIR311_names.py:32:1: AIR311 [*] `airflow.decorators.task` is removed in Airflow 19 19 | # airflow 20 20 | DatasetFromRoot() -AIR311_names.py:33:1: AIR311 [*] `airflow.decorators.task_group` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.decorators.task_group` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:33:1 | 31 | dag() 32 | task() 33 | task_group() - | ^^^^^^^^^^ AIR311 + | ^^^^^^^^^^ 34 | setup() 35 | from airflow.decorators import teardown | - = help: Use `task_group` from `airflow.sdk` instead. +help: Use `task_group` from `airflow.sdk` instead. ℹ Unsafe fix 13 13 | dag, @@ -260,16 +270,17 @@ AIR311_names.py:33:1: AIR311 [*] `airflow.decorators.task_group` is removed in A 19 19 | # airflow 20 20 | DatasetFromRoot() -AIR311_names.py:34:1: AIR311 [*] `airflow.decorators.setup` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.decorators.setup` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:34:1 | 32 | task() 33 | task_group() 34 | setup() - | ^^^^^ AIR311 + | ^^^^^ 35 | from airflow.decorators import teardown 36 | from airflow.io.path import ObjectStoragePath | - = help: Use `setup` from `airflow.sdk` instead. +help: Use `setup` from `airflow.sdk` instead. ℹ Unsafe fix 11 11 | from airflow.datasets.metadata import Metadata @@ -284,15 +295,16 @@ AIR311_names.py:34:1: AIR311 [*] `airflow.decorators.setup` is removed in Airflo 19 19 | # airflow 20 20 | DatasetFromRoot() -AIR311_names.py:48:1: AIR311 [*] `airflow.decorators.teardown` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.decorators.teardown` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:48:1 | 47 | # airflow.decorators 48 | teardown() - | ^^^^^^^^ AIR311 + | ^^^^^^^^ 49 | 50 | # # airflow.io | - = help: Use `teardown` from `airflow.sdk` instead. +help: Use `teardown` from `airflow.sdk` instead. ℹ Unsafe fix 32 32 | task() @@ -311,14 +323,15 @@ AIR311_names.py:48:1: AIR311 [*] `airflow.decorators.teardown` is removed in Air 47 47 | # airflow.decorators 48 48 | teardown() -AIR311_names.py:51:1: AIR311 [*] `airflow.io.path.ObjectStoragePath` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.io.path.ObjectStoragePath` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:51:1 | 50 | # # airflow.io 51 | ObjectStoragePath() - | ^^^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^^^ 52 | attach() | - = help: Use `ObjectStoragePath` from `airflow.sdk` instead. +help: Use `ObjectStoragePath` from `airflow.sdk` instead. ℹ Unsafe fix 33 33 | task_group() @@ -337,16 +350,17 @@ AIR311_names.py:51:1: AIR311 [*] `airflow.io.path.ObjectStoragePath` is removed 47 47 | # airflow.decorators 48 48 | teardown() -AIR311_names.py:52:1: AIR311 [*] `airflow.io.storage.attach` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.io.storage.attach` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:52:1 | 50 | # # airflow.io 51 | ObjectStoragePath() 52 | attach() - | ^^^^^^ AIR311 + | ^^^^^^ 53 | 54 | # airflow.models | - = help: Use `attach` from `airflow.sdk.io` instead. +help: Use `attach` from `airflow.sdk.io` instead. ℹ Unsafe fix 34 34 | setup() @@ -365,15 +379,16 @@ AIR311_names.py:52:1: AIR311 [*] `airflow.io.storage.attach` is removed in Airfl 47 47 | # airflow.decorators 48 48 | teardown() -AIR311_names.py:55:1: AIR311 [*] `airflow.models.Connection` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.models.Connection` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:55:1 | 54 | # airflow.models 55 | Connection() - | ^^^^^^^^^^ AIR311 + | ^^^^^^^^^^ 56 | DAGFromModel() 57 | Variable() | - = help: Use `Connection` from `airflow.sdk` instead. +help: Use `Connection` from `airflow.sdk` instead. ℹ Unsafe fix 37 37 | from airflow.io.storage import attach @@ -390,15 +405,16 @@ AIR311_names.py:55:1: AIR311 [*] `airflow.models.Connection` is removed in Airfl 47 47 | # airflow.decorators 48 48 | teardown() -AIR311_names.py:56:1: AIR311 [*] `airflow.models.DAG` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.models.DAG` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:56:1 | 54 | # airflow.models 55 | Connection() 56 | DAGFromModel() - | ^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^ 57 | Variable() | - = help: Use `DAG` from `airflow.sdk` instead. +help: Use `DAG` from `airflow.sdk` instead. ℹ Safe fix 43 43 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream @@ -418,16 +434,17 @@ AIR311_names.py:56:1: AIR311 [*] `airflow.models.DAG` is removed in Airflow 3.0; 58 59 | 59 60 | # airflow.models.baseoperator -AIR311_names.py:57:1: AIR311 [*] `airflow.models.Variable` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.models.Variable` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:57:1 | 55 | Connection() 56 | DAGFromModel() 57 | Variable() - | ^^^^^^^^ AIR311 + | ^^^^^^^^ 58 | 59 | # airflow.models.baseoperator | - = help: Use `Variable` from `airflow.sdk` instead. +help: Use `Variable` from `airflow.sdk` instead. ℹ Unsafe fix 38 38 | from airflow.models import DAG as DAGFromModel @@ -443,15 +460,16 @@ AIR311_names.py:57:1: AIR311 [*] `airflow.models.Variable` is removed in Airflow 47 47 | # airflow.decorators 48 48 | teardown() -AIR311_names.py:60:1: AIR311 [*] `airflow.models.baseoperator.chain` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.models.baseoperator.chain` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:60:1 | 59 | # airflow.models.baseoperator 60 | chain() - | ^^^^^ AIR311 + | ^^^^^ 61 | chain_linear() 62 | cross_downstream() | - = help: Use `chain` from `airflow.sdk` instead. +help: Use `chain` from `airflow.sdk` instead. ℹ Unsafe fix 40 40 | Connection, @@ -466,15 +484,16 @@ AIR311_names.py:60:1: AIR311 [*] `airflow.models.baseoperator.chain` is removed 47 48 | # airflow.decorators 48 49 | teardown() -AIR311_names.py:61:1: AIR311 [*] `airflow.models.baseoperator.chain_linear` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.models.baseoperator.chain_linear` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:61:1 | 59 | # airflow.models.baseoperator 60 | chain() 61 | chain_linear() - | ^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^ 62 | cross_downstream() | - = help: Use `chain_linear` from `airflow.sdk` instead. +help: Use `chain_linear` from `airflow.sdk` instead. ℹ Unsafe fix 40 40 | Connection, @@ -489,16 +508,17 @@ AIR311_names.py:61:1: AIR311 [*] `airflow.models.baseoperator.chain_linear` is r 47 48 | # airflow.decorators 48 49 | teardown() -AIR311_names.py:62:1: AIR311 [*] `airflow.models.baseoperator.cross_downstream` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.models.baseoperator.cross_downstream` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:62:1 | 60 | chain() 61 | chain_linear() 62 | cross_downstream() - | ^^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^^ 63 | 64 | # airflow.models.baseoperatolinker | - = help: Use `cross_downstream` from `airflow.sdk` instead. +help: Use `cross_downstream` from `airflow.sdk` instead. ℹ Unsafe fix 40 40 | Connection, @@ -513,15 +533,16 @@ AIR311_names.py:62:1: AIR311 [*] `airflow.models.baseoperator.cross_downstream` 47 48 | # airflow.decorators 48 49 | teardown() -AIR311_names.py:65:1: AIR311 [*] `airflow.models.baseoperatorlink.BaseOperatorLink` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.models.baseoperatorlink.BaseOperatorLink` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:65:1 | 64 | # airflow.models.baseoperatolinker 65 | BaseOperatorLink() - | ^^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^^ 66 | 67 | # airflow.models.dag | - = help: Use `BaseOperatorLink` from `airflow.sdk` instead. +help: Use `BaseOperatorLink` from `airflow.sdk` instead. ℹ Unsafe fix 41 41 | Variable, @@ -534,15 +555,16 @@ AIR311_names.py:65:1: AIR311 [*] `airflow.models.baseoperatorlink.BaseOperatorLi 47 47 | # airflow.decorators 48 48 | teardown() -AIR311_names.py:68:1: AIR311 [*] `airflow.models.dag.DAG` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.models.dag.DAG` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:68:1 | 67 | # airflow.models.dag 68 | DAGFromDag() - | ^^^^^^^^^^ AIR311 + | ^^^^^^^^^^ 69 | from airflow.timetables.datasets import DatasetOrTimeSchedule 70 | from airflow.utils.dag_parsing_context import get_parsing_context | - = help: Use `DAG` from `airflow.sdk` instead. +help: Use `DAG` from `airflow.sdk` instead. ℹ Safe fix 43 43 | from airflow.models.baseoperator import chain, chain_linear, cross_downstream @@ -562,15 +584,16 @@ AIR311_names.py:68:1: AIR311 [*] `airflow.models.dag.DAG` is removed in Airflow 70 71 | from airflow.utils.dag_parsing_context import get_parsing_context 71 72 | -AIR311_names.py:73:1: AIR311 [*] `airflow.timetables.datasets.DatasetOrTimeSchedule` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.timetables.datasets.DatasetOrTimeSchedule` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:73:1 | 72 | # airflow.timetables.datasets 73 | DatasetOrTimeSchedule() - | ^^^^^^^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^^^^^^^ 74 | 75 | # airflow.utils.dag_parsing_context | - = help: Use `AssetOrTimeSchedule` from `airflow.timetables.assets` instead. +help: Use `AssetOrTimeSchedule` from `airflow.timetables.assets` instead. ℹ Safe fix 68 68 | DAGFromDag() @@ -585,13 +608,14 @@ AIR311_names.py:73:1: AIR311 [*] `airflow.timetables.datasets.DatasetOrTimeSched 75 76 | # airflow.utils.dag_parsing_context 76 77 | get_parsing_context() -AIR311_names.py:76:1: AIR311 [*] `airflow.utils.dag_parsing_context.get_parsing_context` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR311 [*] `airflow.utils.dag_parsing_context.get_parsing_context` is removed in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR311_names.py:76:1 | 75 | # airflow.utils.dag_parsing_context 76 | get_parsing_context() - | ^^^^^^^^^^^^^^^^^^^ AIR311 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Use `get_parsing_context` from `airflow.sdk` instead. +help: Use `get_parsing_context` from `airflow.sdk` instead. ℹ Unsafe fix 67 67 | # airflow.models.dag diff --git a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR312_AIR312.py.snap b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR312_AIR312.py.snap index e59605546d..628ffe31dc 100644 --- a/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR312_AIR312.py.snap +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR312_AIR312.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/airflow/mod.rs --- -AIR312.py:14:1: AIR312 [*] `airflow.hooks.filesystem.FSHook` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.hooks.filesystem.FSHook` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:14:1 | 12 | from airflow.sensors.date_time import DateTimeSensor 13 | 14 | FSHook() - | ^^^^^^ AIR312 + | ^^^^^^ 15 | PackageIndexHook() 16 | SubprocessHook() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `FSHook` from `airflow.providers.standard.hooks.filesystem` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `FSHook` from `airflow.providers.standard.hooks.filesystem` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -28,14 +29,15 @@ AIR312.py:14:1: AIR312 [*] `airflow.hooks.filesystem.FSHook` is deprecated and m 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:15:1: AIR312 [*] `airflow.hooks.package_index.PackageIndexHook` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.hooks.package_index.PackageIndexHook` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:15:1 | 14 | FSHook() 15 | PackageIndexHook() - | ^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^ 16 | SubprocessHook() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `PackageIndexHook` from `airflow.providers.standard.hooks.package_index` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `PackageIndexHook` from `airflow.providers.standard.hooks.package_index` instead. ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -54,16 +56,17 @@ AIR312.py:15:1: AIR312 [*] `airflow.hooks.package_index.PackageIndexHook` is dep 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:16:1: AIR312 [*] `airflow.hooks.subprocess.SubprocessHook` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.hooks.subprocess.SubprocessHook` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:16:1 | 14 | FSHook() 15 | PackageIndexHook() 16 | SubprocessHook() - | ^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^ 17 | 18 | BashOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `SubprocessHook` from `airflow.providers.standard.hooks.subprocess` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `SubprocessHook` from `airflow.providers.standard.hooks.subprocess` instead. ℹ Unsafe fix 2 2 | @@ -82,16 +85,17 @@ AIR312.py:16:1: AIR312 [*] `airflow.hooks.subprocess.SubprocessHook` is deprecat 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:18:1: AIR312 [*] `airflow.operators.bash.BashOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.bash.BashOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:18:1 | 16 | SubprocessHook() 17 | 18 | BashOperator() - | ^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^ 19 | BranchDateTimeOperator() 20 | TriggerDagRunOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `BashOperator` from `airflow.providers.standard.operators.bash` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `BashOperator` from `airflow.providers.standard.operators.bash` instead. ℹ Unsafe fix 3 3 | from airflow.hooks.filesystem import FSHook @@ -109,15 +113,16 @@ AIR312.py:18:1: AIR312 [*] `airflow.operators.bash.BashOperator` is deprecated a 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:19:1: AIR312 [*] `airflow.operators.datetime.BranchDateTimeOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.datetime.BranchDateTimeOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:19:1 | 18 | BashOperator() 19 | BranchDateTimeOperator() - | ^^^^^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^^^^^ 20 | TriggerDagRunOperator() 21 | EmptyOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `BranchDateTimeOperator` from `airflow.providers.standard.operators.datetime` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `BranchDateTimeOperator` from `airflow.providers.standard.operators.datetime` instead. ℹ Unsafe fix 4 4 | from airflow.hooks.package_index import PackageIndexHook @@ -134,15 +139,16 @@ AIR312.py:19:1: AIR312 [*] `airflow.operators.datetime.BranchDateTimeOperator` i 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:20:1: AIR312 [*] `airflow.operators.trigger_dagrun.TriggerDagRunOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.trigger_dagrun.TriggerDagRunOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:20:1 | 18 | BashOperator() 19 | BranchDateTimeOperator() 20 | TriggerDagRunOperator() - | ^^^^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^^^^ 21 | EmptyOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `TriggerDagRunOperator` from `airflow.providers.standard.operators.trigger_dagrun` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `TriggerDagRunOperator` from `airflow.providers.standard.operators.trigger_dagrun` instead. ℹ Unsafe fix 7 7 | from airflow.operators.datetime import BranchDateTimeOperator @@ -156,16 +162,17 @@ AIR312.py:20:1: AIR312 [*] `airflow.operators.trigger_dagrun.TriggerDagRunOperat 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:21:1: AIR312 [*] `airflow.operators.empty.EmptyOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.empty.EmptyOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:21:1 | 19 | BranchDateTimeOperator() 20 | TriggerDagRunOperator() 21 | EmptyOperator() - | ^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^ 22 | 23 | LatestOnlyOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `EmptyOperator` from `airflow.providers.standard.operators.empty` instead. ℹ Unsafe fix 5 5 | from airflow.hooks.subprocess import SubprocessHook @@ -181,16 +188,17 @@ AIR312.py:21:1: AIR312 [*] `airflow.operators.empty.EmptyOperator` is deprecated 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:23:1: AIR312 [*] `airflow.operators.latest_only.LatestOnlyOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.latest_only.LatestOnlyOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:23:1 | 21 | EmptyOperator() 22 | 23 | LatestOnlyOperator() - | ^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^ 24 | BranchDayOfWeekOperator() 25 | DateTimeSensor() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `LatestOnlyOperator` from `airflow.providers.standard.operators.latest_only` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `LatestOnlyOperator` from `airflow.providers.standard.operators.latest_only` instead. ℹ Unsafe fix 6 6 | from airflow.operators.bash import BashOperator @@ -205,14 +213,15 @@ AIR312.py:23:1: AIR312 [*] `airflow.operators.latest_only.LatestOnlyOperator` is 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:24:1: AIR312 [*] `airflow.operators.weekday.BranchDayOfWeekOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.weekday.BranchDayOfWeekOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:24:1 | 23 | LatestOnlyOperator() 24 | BranchDayOfWeekOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^^^^^^ 25 | DateTimeSensor() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `BranchDayOfWeekOperator` from `airflow.providers.standard.operators.weekday` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `BranchDayOfWeekOperator` from `airflow.providers.standard.operators.weekday` instead. ℹ Unsafe fix 8 8 | from airflow.operators.empty import EmptyOperator @@ -225,16 +234,17 @@ AIR312.py:24:1: AIR312 [*] `airflow.operators.weekday.BranchDayOfWeekOperator` i 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:25:1: AIR312 [*] `airflow.sensors.date_time.DateTimeSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.date_time.DateTimeSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:25:1 | 23 | LatestOnlyOperator() 24 | BranchDayOfWeekOperator() 25 | DateTimeSensor() - | ^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^ 26 | 27 | from airflow.operators.python import ( | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `DateTimeSensor` from `airflow.providers.standard.sensors.date_time` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `DateTimeSensor` from `airflow.providers.standard.sensors.date_time` instead. ℹ Unsafe fix 9 9 | from airflow.operators.latest_only import LatestOnlyOperator @@ -246,16 +256,17 @@ AIR312.py:25:1: AIR312 [*] `airflow.sensors.date_time.DateTimeSensor` is depreca 14 14 | FSHook() 15 15 | PackageIndexHook() -AIR312.py:44:1: AIR312 [*] `airflow.operators.python.BranchPythonOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.python.BranchPythonOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:44:1 | 42 | from airflow.sensors.filesystem import FileSensor 43 | 44 | BranchPythonOperator() - | ^^^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^^^ 45 | PythonOperator() 46 | PythonVirtualenvOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `BranchPythonOperator` from `airflow.providers.standard.operators.python` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `BranchPythonOperator` from `airflow.providers.standard.operators.python` instead. ℹ Unsafe fix 25 25 | DateTimeSensor() @@ -274,15 +285,16 @@ AIR312.py:44:1: AIR312 [*] `airflow.operators.python.BranchPythonOperator` is de 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:45:1: AIR312 [*] `airflow.operators.python.PythonOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.python.PythonOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:45:1 | 44 | BranchPythonOperator() 45 | PythonOperator() - | ^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^ 46 | PythonVirtualenvOperator() 47 | ShortCircuitOperator() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `PythonOperator` from `airflow.providers.standard.operators.python` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `PythonOperator` from `airflow.providers.standard.operators.python` instead. ℹ Unsafe fix 26 26 | @@ -301,16 +313,17 @@ AIR312.py:45:1: AIR312 [*] `airflow.operators.python.PythonOperator` is deprecat 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:46:1: AIR312 [*] `airflow.operators.python.PythonVirtualenvOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.python.PythonVirtualenvOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:46:1 | 44 | BranchPythonOperator() 45 | PythonOperator() 46 | PythonVirtualenvOperator() - | ^^^^^^^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 47 | ShortCircuitOperator() 48 | DateTimeSensorAsync() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `PythonVirtualenvOperator` from `airflow.providers.standard.operators.python` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `PythonVirtualenvOperator` from `airflow.providers.standard.operators.python` instead. ℹ Unsafe fix 27 27 | from airflow.operators.python import ( @@ -329,16 +342,17 @@ AIR312.py:46:1: AIR312 [*] `airflow.operators.python.PythonVirtualenvOperator` i 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:47:1: AIR312 [*] `airflow.operators.python.ShortCircuitOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.operators.python.ShortCircuitOperator` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:47:1 | 45 | PythonOperator() 46 | PythonVirtualenvOperator() 47 | ShortCircuitOperator() - | ^^^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^^^ 48 | DateTimeSensorAsync() 49 | ExternalTaskMarker() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `ShortCircuitOperator` from `airflow.providers.standard.operators.python` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `ShortCircuitOperator` from `airflow.providers.standard.operators.python` instead. ℹ Unsafe fix 28 28 | BranchPythonOperator, @@ -357,16 +371,17 @@ AIR312.py:47:1: AIR312 [*] `airflow.operators.python.ShortCircuitOperator` is de 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:48:1: AIR312 [*] `airflow.sensors.date_time.DateTimeSensorAsync` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.date_time.DateTimeSensorAsync` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:48:1 | 46 | PythonVirtualenvOperator() 47 | ShortCircuitOperator() 48 | DateTimeSensorAsync() - | ^^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^^ 49 | ExternalTaskMarker() 50 | ExternalTaskSensor() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `DateTimeSensorAsync` from `airflow.providers.standard.sensors.date_time` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `DateTimeSensorAsync` from `airflow.providers.standard.sensors.date_time` instead. ℹ Unsafe fix 30 30 | PythonVirtualenvOperator, @@ -385,16 +400,17 @@ AIR312.py:48:1: AIR312 [*] `airflow.sensors.date_time.DateTimeSensorAsync` is de 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:49:1: AIR312 [*] `airflow.sensors.external_task.ExternalTaskMarker` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.external_task.ExternalTaskMarker` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:49:1 | 47 | ShortCircuitOperator() 48 | DateTimeSensorAsync() 49 | ExternalTaskMarker() - | ^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^ 50 | ExternalTaskSensor() 51 | FileSensor() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalTaskMarker` from `airflow.providers.standard.sensors.external_task` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalTaskMarker` from `airflow.providers.standard.sensors.external_task` instead. ℹ Unsafe fix 32 32 | ) @@ -413,16 +429,17 @@ AIR312.py:49:1: AIR312 [*] `airflow.sensors.external_task.ExternalTaskMarker` is 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:50:1: AIR312 [*] `airflow.sensors.external_task.ExternalTaskSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.external_task.ExternalTaskSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:50:1 | 48 | DateTimeSensorAsync() 49 | ExternalTaskMarker() 50 | ExternalTaskSensor() - | ^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^ 51 | FileSensor() 52 | TimeSensor() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalTaskSensor` from `airflow.providers.standard.sensors.external_task` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `ExternalTaskSensor` from `airflow.providers.standard.sensors.external_task` instead. ℹ Unsafe fix 33 33 | from airflow.sensors.date_time import DateTimeSensorAsync @@ -440,16 +457,17 @@ AIR312.py:50:1: AIR312 [*] `airflow.sensors.external_task.ExternalTaskSensor` is 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:51:1: AIR312 [*] `airflow.sensors.filesystem.FileSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.filesystem.FileSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:51:1 | 49 | ExternalTaskMarker() 50 | ExternalTaskSensor() 51 | FileSensor() - | ^^^^^^^^^^ AIR312 + | ^^^^^^^^^^ 52 | TimeSensor() 53 | TimeSensorAsync() | - = help: Install `apache-airflow-providers-standard>=0.0.2` and use `FileSensor` from `airflow.providers.standard.sensors.filesystem` instead. +help: Install `apache-airflow-providers-standard>=0.0.2` and use `FileSensor` from `airflow.providers.standard.sensors.filesystem` instead. ℹ Unsafe fix 39 39 | TimeSensor, @@ -461,15 +479,16 @@ AIR312.py:51:1: AIR312 [*] `airflow.sensors.filesystem.FileSensor` is deprecated 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:52:1: AIR312 [*] `airflow.sensors.time_sensor.TimeSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.time_sensor.TimeSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:52:1 | 50 | ExternalTaskSensor() 51 | FileSensor() 52 | TimeSensor() - | ^^^^^^^^^^ AIR312 + | ^^^^^^^^^^ 53 | TimeSensorAsync() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `TimeSensor` from `airflow.providers.standard.sensors.time` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `TimeSensor` from `airflow.providers.standard.sensors.time` instead. ℹ Unsafe fix 36 36 | ExternalTaskSensor, @@ -484,16 +503,17 @@ AIR312.py:52:1: AIR312 [*] `airflow.sensors.time_sensor.TimeSensor` is deprecate 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:53:1: AIR312 [*] `airflow.sensors.time_sensor.TimeSensorAsync` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.time_sensor.TimeSensorAsync` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:53:1 | 51 | FileSensor() 52 | TimeSensor() 53 | TimeSensorAsync() - | ^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^ 54 | 55 | from airflow.sensors.time_delta import ( | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `TimeSensorAsync` from `airflow.providers.standard.sensors.time` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `TimeSensorAsync` from `airflow.providers.standard.sensors.time` instead. ℹ Unsafe fix 37 37 | ) @@ -507,16 +527,17 @@ AIR312.py:53:1: AIR312 [*] `airflow.sensors.time_sensor.TimeSensorAsync` is depr 44 44 | BranchPythonOperator() 45 45 | PythonOperator() -AIR312.py:70:1: AIR312 [*] `airflow.sensors.time_delta.TimeDeltaSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.time_delta.TimeDeltaSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:70:1 | 68 | ) 69 | 70 | TimeDeltaSensor() - | ^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^ 71 | TimeDeltaSensorAsync() 72 | DayOfWeekSensor() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `TimeDeltaSensor` from `airflow.providers.standard.sensors.time_delta` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `TimeDeltaSensor` from `airflow.providers.standard.sensors.time_delta` instead. ℹ Unsafe fix 53 53 | TimeSensorAsync() @@ -535,15 +556,16 @@ AIR312.py:70:1: AIR312 [*] `airflow.sensors.time_delta.TimeDeltaSensor` is depre 70 70 | TimeDeltaSensor() 71 71 | TimeDeltaSensorAsync() -AIR312.py:71:1: AIR312 [*] `airflow.sensors.time_delta.TimeDeltaSensorAsync` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.time_delta.TimeDeltaSensorAsync` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:71:1 | 70 | TimeDeltaSensor() 71 | TimeDeltaSensorAsync() - | ^^^^^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^^^^^ 72 | DayOfWeekSensor() 73 | DagStateTrigger() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `TimeDeltaSensorAsync` from `airflow.providers.standard.sensors.time_delta` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `TimeDeltaSensorAsync` from `airflow.providers.standard.sensors.time_delta` instead. ℹ Unsafe fix 54 54 | @@ -562,16 +584,17 @@ AIR312.py:71:1: AIR312 [*] `airflow.sensors.time_delta.TimeDeltaSensorAsync` is 70 70 | TimeDeltaSensor() 71 71 | TimeDeltaSensorAsync() -AIR312.py:72:1: AIR312 [*] `airflow.sensors.weekday.DayOfWeekSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.sensors.weekday.DayOfWeekSensor` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:72:1 | 70 | TimeDeltaSensor() 71 | TimeDeltaSensorAsync() 72 | DayOfWeekSensor() - | ^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^ 73 | DagStateTrigger() 74 | WorkflowTrigger() | - = help: Install `apache-airflow-providers-standard>=0.0.1` and use `DayOfWeekSensor` from `airflow.providers.standard.sensors.weekday` instead. +help: Install `apache-airflow-providers-standard>=0.0.1` and use `DayOfWeekSensor` from `airflow.providers.standard.sensors.weekday` instead. ℹ Unsafe fix 56 56 | TimeDeltaSensor, @@ -590,16 +613,17 @@ AIR312.py:72:1: AIR312 [*] `airflow.sensors.weekday.DayOfWeekSensor` is deprecat 70 70 | TimeDeltaSensor() 71 71 | TimeDeltaSensorAsync() -AIR312.py:73:1: AIR312 [*] `airflow.triggers.external_task.DagStateTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.triggers.external_task.DagStateTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:73:1 | 71 | TimeDeltaSensorAsync() 72 | DayOfWeekSensor() 73 | DagStateTrigger() - | ^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^ 74 | WorkflowTrigger() 75 | FileTrigger() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `DagStateTrigger` from `airflow.providers.standard.triggers.external_task` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `DagStateTrigger` from `airflow.providers.standard.triggers.external_task` instead. ℹ Unsafe fix 58 58 | ) @@ -618,16 +642,17 @@ AIR312.py:73:1: AIR312 [*] `airflow.triggers.external_task.DagStateTrigger` is d 70 70 | TimeDeltaSensor() 71 71 | TimeDeltaSensorAsync() -AIR312.py:74:1: AIR312 [*] `airflow.triggers.external_task.WorkflowTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.triggers.external_task.WorkflowTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:74:1 | 72 | DayOfWeekSensor() 73 | DagStateTrigger() 74 | WorkflowTrigger() - | ^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^ 75 | FileTrigger() 76 | DateTimeTrigger() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `WorkflowTrigger` from `airflow.providers.standard.triggers.external_task` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `WorkflowTrigger` from `airflow.providers.standard.triggers.external_task` instead. ℹ Unsafe fix 59 59 | from airflow.sensors.weekday import DayOfWeekSensor @@ -645,16 +670,17 @@ AIR312.py:74:1: AIR312 [*] `airflow.triggers.external_task.WorkflowTrigger` is d 70 70 | TimeDeltaSensor() 71 71 | TimeDeltaSensorAsync() -AIR312.py:75:1: AIR312 [*] `airflow.triggers.file.FileTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.triggers.file.FileTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:75:1 | 73 | DagStateTrigger() 74 | WorkflowTrigger() 75 | FileTrigger() - | ^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^ 76 | DateTimeTrigger() 77 | TimeDeltaTrigger() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `FileTrigger` from `airflow.providers.standard.triggers.file` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `FileTrigger` from `airflow.providers.standard.triggers.file` instead. ℹ Unsafe fix 61 61 | DagStateTrigger, @@ -670,15 +696,16 @@ AIR312.py:75:1: AIR312 [*] `airflow.triggers.file.FileTrigger` is deprecated and 70 70 | TimeDeltaSensor() 71 71 | TimeDeltaSensorAsync() -AIR312.py:76:1: AIR312 [*] `airflow.triggers.temporal.DateTimeTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.triggers.temporal.DateTimeTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:76:1 | 74 | WorkflowTrigger() 75 | FileTrigger() 76 | DateTimeTrigger() - | ^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^ 77 | TimeDeltaTrigger() | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `DateTimeTrigger` from `airflow.providers.standard.triggers.temporal` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `DateTimeTrigger` from `airflow.providers.standard.triggers.temporal` instead. ℹ Unsafe fix 63 63 | ) @@ -692,14 +719,15 @@ AIR312.py:76:1: AIR312 [*] `airflow.triggers.temporal.DateTimeTrigger` is deprec 70 70 | TimeDeltaSensor() 71 71 | TimeDeltaSensorAsync() -AIR312.py:77:1: AIR312 [*] `airflow.triggers.temporal.TimeDeltaTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. +AIR312 [*] `airflow.triggers.temporal.TimeDeltaTrigger` is deprecated and moved into `standard` provider in Airflow 3.0; It still works in Airflow 3.0 but is expected to be removed in a future version. + --> AIR312.py:77:1 | 75 | FileTrigger() 76 | DateTimeTrigger() 77 | TimeDeltaTrigger() - | ^^^^^^^^^^^^^^^^ AIR312 + | ^^^^^^^^^^^^^^^^ | - = help: Install `apache-airflow-providers-standard>=0.0.3` and use `TimeDeltaTrigger` from `airflow.providers.standard.triggers.temporal` instead. +help: Install `apache-airflow-providers-standard>=0.0.3` and use `TimeDeltaTrigger` from `airflow.providers.standard.triggers.temporal` instead. ℹ Unsafe fix 64 64 | from airflow.triggers.file import FileTrigger diff --git a/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap index 37331b9007..395f946062 100644 --- a/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap +++ b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/eradicate/mod.rs --- -ERA001.py:1:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:1:1 | 1 | #import os - | ^^^^^^^^^^ ERA001 + | ^^^^^^^^^^ 2 | # from foo import junk 3 | #a = 3 | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 1 |-#import os @@ -16,15 +17,16 @@ ERA001.py:1:1: ERA001 Found commented-out code 3 2 | #a = 3 4 3 | a = 4 -ERA001.py:2:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:2:1 | 1 | #import os 2 | # from foo import junk - | ^^^^^^^^^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^^^^^^^^^ 3 | #a = 3 4 | a = 4 | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 1 1 | #import os @@ -33,16 +35,17 @@ ERA001.py:2:1: ERA001 Found commented-out code 4 3 | a = 4 5 4 | #foo(1, 2, 3) -ERA001.py:3:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:3:1 | 1 | #import os 2 | # from foo import junk 3 | #a = 3 - | ^^^^^^ ERA001 + | ^^^^^^ 4 | a = 4 5 | #foo(1, 2, 3) | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 1 1 | #import os @@ -52,16 +55,17 @@ ERA001.py:3:1: ERA001 Found commented-out code 5 4 | #foo(1, 2, 3) 6 5 | -ERA001.py:5:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:5:1 | 3 | #a = 3 4 | a = 4 5 | #foo(1, 2, 3) - | ^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^ 6 | 7 | def foo(x, y, z): | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 2 2 | # from foo import junk @@ -72,15 +76,16 @@ ERA001.py:5:1: ERA001 Found commented-out code 7 6 | def foo(x, y, z): 8 7 | content = 1 # print('hello') -ERA001.py:13:5: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:13:5 | 11 | # This is a real comment. 12 | # # This is a (nested) comment. 13 | #return True - | ^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^ 14 | return False | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 10 10 | @@ -91,14 +96,15 @@ ERA001.py:13:5: ERA001 Found commented-out code 15 14 | 16 15 | #import os # noqa: ERA001 -ERA001.py:21:5: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:21:5 | 19 | class A(): 20 | pass 21 | # b = c - | ^^^^^^^ ERA001 + | ^^^^^^^ | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 18 18 | @@ -109,16 +115,17 @@ ERA001.py:21:5: ERA001 Found commented-out code 23 22 | 24 23 | dictionary = { -ERA001.py:26:5: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:26:5 | 24 | dictionary = { 25 | # "key1": 123, # noqa: ERA001 26 | # "key2": 456, - | ^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^ 27 | # "key3": 789, # test 28 | } | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 23 23 | @@ -129,15 +136,16 @@ ERA001.py:26:5: ERA001 Found commented-out code 28 27 | } 29 28 | -ERA001.py:27:5: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:27:5 | 25 | # "key1": 123, # noqa: ERA001 26 | # "key2": 456, 27 | # "key3": 789, # test - | ^^^^^^^^^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^^^^^^^^^ 28 | } | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 24 24 | dictionary = { @@ -148,16 +156,17 @@ ERA001.py:27:5: ERA001 Found commented-out code 29 28 | 30 29 | #import os # noqa -ERA001.py:32:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:32:1 | 30 | #import os # noqa 31 | 32 | # case 1: - | ^^^^^^^^^ ERA001 + | ^^^^^^^^^ 33 | # try: 34 | # try: # with comment | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 29 29 | @@ -168,15 +177,16 @@ ERA001.py:32:1: ERA001 Found commented-out code 34 33 | # try: # with comment 35 34 | # try: print() -ERA001.py:33:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:33:1 | 32 | # case 1: 33 | # try: - | ^^^^^^ ERA001 + | ^^^^^^ 34 | # try: # with comment 35 | # try: print() | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 30 30 | #import os # noqa @@ -187,16 +197,17 @@ ERA001.py:33:1: ERA001 Found commented-out code 35 34 | # try: print() 36 35 | # except: -ERA001.py:34:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:34:1 | 32 | # case 1: 33 | # try: 34 | # try: # with comment - | ^^^^^^^^^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^^^^^^^^^ 35 | # try: print() 36 | # except: | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 31 31 | @@ -207,16 +218,17 @@ ERA001.py:34:1: ERA001 Found commented-out code 36 35 | # except: 37 36 | # except Foo: -ERA001.py:35:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:35:1 | 33 | # try: 34 | # try: # with comment 35 | # try: print() - | ^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^ 36 | # except: 37 | # except Foo: | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 32 32 | # case 1: @@ -227,16 +239,17 @@ ERA001.py:35:1: ERA001 Found commented-out code 37 36 | # except Foo: 38 37 | # except Exception as e: print(e) -ERA001.py:36:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:36:1 | 34 | # try: # with comment 35 | # try: print() 36 | # except: - | ^^^^^^^^^ ERA001 + | ^^^^^^^^^ 37 | # except Foo: 38 | # except Exception as e: print(e) | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 33 33 | # try: @@ -247,15 +260,16 @@ ERA001.py:36:1: ERA001 Found commented-out code 38 37 | # except Exception as e: print(e) 39 38 | -ERA001.py:37:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:37:1 | 35 | # try: print() 36 | # except: 37 | # except Foo: - | ^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^ 38 | # except Exception as e: print(e) | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 34 34 | # try: # with comment @@ -266,14 +280,15 @@ ERA001.py:37:1: ERA001 Found commented-out code 39 38 | 40 39 | -ERA001.py:38:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:38:1 | 36 | # except: 37 | # except Foo: 38 | # except Exception as e: print(e) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 35 35 | # try: print() @@ -284,15 +299,16 @@ ERA001.py:38:1: ERA001 Found commented-out code 40 39 | 41 40 | # Script tag without an opening tag (Error) -ERA001.py:44:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:44:1 | 43 | # requires-python = ">=3.11" 44 | # dependencies = [ - | ^^^^^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^^^^^ 45 | # "requests<3", 46 | # "rich", | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 41 41 | # Script tag without an opening tag (Error) @@ -303,15 +319,16 @@ ERA001.py:44:1: ERA001 Found commented-out code 46 45 | # "rich", 47 46 | # ] -ERA001.py:47:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:47:1 | 45 | # "requests<3", 46 | # "rich", 47 | # ] - | ^^^ ERA001 + | ^^^ 48 | # /// | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 44 44 | # dependencies = [ @@ -322,16 +339,17 @@ ERA001.py:47:1: ERA001 Found commented-out code 49 48 | 50 49 | # Script tag (OK) -ERA001.py:75:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:75:1 | 73 | # /// script 74 | # requires-python = ">=3.11" 75 | # dependencies = [ - | ^^^^^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^^^^^ 76 | # "requests<3", 77 | # "rich", | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 72 72 | @@ -342,16 +360,17 @@ ERA001.py:75:1: ERA001 Found commented-out code 77 76 | # "rich", 78 77 | # ] -ERA001.py:78:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> ERA001.py:78:1 | 76 | # "requests<3", 77 | # "rich", 78 | # ] - | ^^^ ERA001 + | ^^^ 79 | 80 | # Script tag block followed by normal block (Ok) | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 75 75 | # dependencies = [ diff --git a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_0.py.snap b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_0.py.snap index 6bc341dd02..cc586b5dad 100644 --- a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_0.py.snap +++ b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_0.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/fastapi/mod.rs -snapshot_kind: text --- -FAST002_0.py:24:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:24:5 | 22 | @app.get("/items/") 23 | def get_items( 24 | current_user: User = Depends(get_current_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | some_security_param: str = Security(get_oauth2_user), 26 | ): | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -31,16 +31,17 @@ FAST002_0.py:24:5: FAST002 [*] FastAPI dependency without `Annotated` 26 27 | ): 27 28 | pass -FAST002_0.py:25:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:25:5 | 23 | def get_items( 24 | current_user: User = Depends(get_current_user), 25 | some_security_param: str = Security(get_oauth2_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | ): 27 | pass | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -60,16 +61,17 @@ FAST002_0.py:25:5: FAST002 [*] FastAPI dependency without `Annotated` 27 28 | pass 28 29 | -FAST002_0.py:32:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:32:5 | 30 | @app.post("/stuff/") 31 | def do_stuff( 32 | some_path_param: str = Path(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | some_cookie_param: str = Cookie(), 34 | some_file_param: UploadFile = File(), | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -89,16 +91,17 @@ FAST002_0.py:32:5: FAST002 [*] FastAPI dependency without `Annotated` 34 35 | some_file_param: UploadFile = File(), 35 36 | some_form_param: str = Form(), -FAST002_0.py:33:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:33:5 | 31 | def do_stuff( 32 | some_path_param: str = Path(), 33 | some_cookie_param: str = Cookie(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | some_file_param: UploadFile = File(), 35 | some_form_param: str = Form(), | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -118,16 +121,17 @@ FAST002_0.py:33:5: FAST002 [*] FastAPI dependency without `Annotated` 35 36 | some_form_param: str = Form(), 36 37 | some_query_param: str | None = Query(default=None), -FAST002_0.py:34:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:34:5 | 32 | some_path_param: str = Path(), 33 | some_cookie_param: str = Cookie(), 34 | some_file_param: UploadFile = File(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | some_form_param: str = Form(), 36 | some_query_param: str | None = Query(default=None), | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -147,16 +151,17 @@ FAST002_0.py:34:5: FAST002 [*] FastAPI dependency without `Annotated` 36 37 | some_query_param: str | None = Query(default=None), 37 38 | some_body_param: str = Body("foo"), -FAST002_0.py:35:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:35:5 | 33 | some_cookie_param: str = Cookie(), 34 | some_file_param: UploadFile = File(), 35 | some_form_param: str = Form(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | some_query_param: str | None = Query(default=None), 37 | some_body_param: str = Body("foo"), | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -176,16 +181,17 @@ FAST002_0.py:35:5: FAST002 [*] FastAPI dependency without `Annotated` 37 38 | some_body_param: str = Body("foo"), 38 39 | some_header_param: int = Header(default=5), -FAST002_0.py:36:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:36:5 | 34 | some_file_param: UploadFile = File(), 35 | some_form_param: str = Form(), 36 | some_query_param: str | None = Query(default=None), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | some_body_param: str = Body("foo"), 38 | some_header_param: int = Header(default=5), | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -205,16 +211,17 @@ FAST002_0.py:36:5: FAST002 [*] FastAPI dependency without `Annotated` 38 39 | some_header_param: int = Header(default=5), 39 40 | ): -FAST002_0.py:37:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:37:5 | 35 | some_form_param: str = Form(), 36 | some_query_param: str | None = Query(default=None), 37 | some_body_param: str = Body("foo"), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | some_header_param: int = Header(default=5), 39 | ): | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -234,16 +241,17 @@ FAST002_0.py:37:5: FAST002 [*] FastAPI dependency without `Annotated` 39 40 | ): 40 41 | # do stuff -FAST002_0.py:38:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:38:5 | 36 | some_query_param: str | None = Query(default=None), 37 | some_body_param: str = Body("foo"), 38 | some_header_param: int = Header(default=5), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | ): 40 | # do stuff | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -263,16 +271,17 @@ FAST002_0.py:38:5: FAST002 [*] FastAPI dependency without `Annotated` 40 41 | # do stuff 41 42 | pass -FAST002_0.py:47:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:47:5 | 45 | skip: int, 46 | limit: int, 47 | current_user: User = Depends(get_current_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | ): 49 | pass | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -292,16 +301,17 @@ FAST002_0.py:47:5: FAST002 [*] FastAPI dependency without `Annotated` 49 50 | pass 50 51 | -FAST002_0.py:53:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:53:5 | 51 | @app.get("/users/") 52 | def get_users( 53 | current_user: User = Depends(get_current_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | skip: int = 0, 55 | limit: int = 10, | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -321,14 +331,15 @@ FAST002_0.py:53:5: FAST002 [*] FastAPI dependency without `Annotated` 55 56 | limit: int = 10, 56 57 | ): -FAST002_0.py:61:25: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:61:25 | 60 | @app.get("/items/{item_id}") 61 | async def read_items(*, item_id: int = Path(title="The ID of the item to get"), q: str): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 62 | pass | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -348,13 +359,14 @@ FAST002_0.py:61:25: FAST002 [*] FastAPI dependency without `Annotated` 63 64 | 64 65 | # Non fixable errors -FAST002_0.py:70:5: FAST002 FastAPI dependency without `Annotated` +FAST002 FastAPI dependency without `Annotated` + --> FAST002_0.py:70:5 | 68 | skip: int = 0, 69 | limit: int = 10, 70 | current_user: User = Depends(get_current_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 71 | ): 72 | pass | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` diff --git a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_0.py_py38.snap b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_0.py_py38.snap index 2bc02fdeee..31a2121a47 100644 --- a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_0.py_py38.snap +++ b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_0.py_py38.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/fastapi/mod.rs -snapshot_kind: text --- -FAST002_0.py:24:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:24:5 | 22 | @app.get("/items/") 23 | def get_items( 24 | current_user: User = Depends(get_current_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | some_security_param: str = Security(get_oauth2_user), 26 | ): | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -31,16 +31,17 @@ FAST002_0.py:24:5: FAST002 [*] FastAPI dependency without `Annotated` 26 27 | ): 27 28 | pass -FAST002_0.py:25:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:25:5 | 23 | def get_items( 24 | current_user: User = Depends(get_current_user), 25 | some_security_param: str = Security(get_oauth2_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | ): 27 | pass | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -60,16 +61,17 @@ FAST002_0.py:25:5: FAST002 [*] FastAPI dependency without `Annotated` 27 28 | pass 28 29 | -FAST002_0.py:32:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:32:5 | 30 | @app.post("/stuff/") 31 | def do_stuff( 32 | some_path_param: str = Path(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | some_cookie_param: str = Cookie(), 34 | some_file_param: UploadFile = File(), | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -89,16 +91,17 @@ FAST002_0.py:32:5: FAST002 [*] FastAPI dependency without `Annotated` 34 35 | some_file_param: UploadFile = File(), 35 36 | some_form_param: str = Form(), -FAST002_0.py:33:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:33:5 | 31 | def do_stuff( 32 | some_path_param: str = Path(), 33 | some_cookie_param: str = Cookie(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | some_file_param: UploadFile = File(), 35 | some_form_param: str = Form(), | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -118,16 +121,17 @@ FAST002_0.py:33:5: FAST002 [*] FastAPI dependency without `Annotated` 35 36 | some_form_param: str = Form(), 36 37 | some_query_param: str | None = Query(default=None), -FAST002_0.py:34:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:34:5 | 32 | some_path_param: str = Path(), 33 | some_cookie_param: str = Cookie(), 34 | some_file_param: UploadFile = File(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | some_form_param: str = Form(), 36 | some_query_param: str | None = Query(default=None), | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -147,16 +151,17 @@ FAST002_0.py:34:5: FAST002 [*] FastAPI dependency without `Annotated` 36 37 | some_query_param: str | None = Query(default=None), 37 38 | some_body_param: str = Body("foo"), -FAST002_0.py:35:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:35:5 | 33 | some_cookie_param: str = Cookie(), 34 | some_file_param: UploadFile = File(), 35 | some_form_param: str = Form(), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | some_query_param: str | None = Query(default=None), 37 | some_body_param: str = Body("foo"), | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -176,16 +181,17 @@ FAST002_0.py:35:5: FAST002 [*] FastAPI dependency without `Annotated` 37 38 | some_body_param: str = Body("foo"), 38 39 | some_header_param: int = Header(default=5), -FAST002_0.py:36:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:36:5 | 34 | some_file_param: UploadFile = File(), 35 | some_form_param: str = Form(), 36 | some_query_param: str | None = Query(default=None), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | some_body_param: str = Body("foo"), 38 | some_header_param: int = Header(default=5), | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -205,16 +211,17 @@ FAST002_0.py:36:5: FAST002 [*] FastAPI dependency without `Annotated` 38 39 | some_header_param: int = Header(default=5), 39 40 | ): -FAST002_0.py:37:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:37:5 | 35 | some_form_param: str = Form(), 36 | some_query_param: str | None = Query(default=None), 37 | some_body_param: str = Body("foo"), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | some_header_param: int = Header(default=5), 39 | ): | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -234,16 +241,17 @@ FAST002_0.py:37:5: FAST002 [*] FastAPI dependency without `Annotated` 39 40 | ): 40 41 | # do stuff -FAST002_0.py:38:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:38:5 | 36 | some_query_param: str | None = Query(default=None), 37 | some_body_param: str = Body("foo"), 38 | some_header_param: int = Header(default=5), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | ): 40 | # do stuff | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -263,16 +271,17 @@ FAST002_0.py:38:5: FAST002 [*] FastAPI dependency without `Annotated` 40 41 | # do stuff 41 42 | pass -FAST002_0.py:47:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:47:5 | 45 | skip: int, 46 | limit: int, 47 | current_user: User = Depends(get_current_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | ): 49 | pass | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -292,16 +301,17 @@ FAST002_0.py:47:5: FAST002 [*] FastAPI dependency without `Annotated` 49 50 | pass 50 51 | -FAST002_0.py:53:5: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:53:5 | 51 | @app.get("/users/") 52 | def get_users( 53 | current_user: User = Depends(get_current_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | skip: int = 0, 55 | limit: int = 10, | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -321,14 +331,15 @@ FAST002_0.py:53:5: FAST002 [*] FastAPI dependency without `Annotated` 55 56 | limit: int = 10, 56 57 | ): -FAST002_0.py:61:25: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_0.py:61:25 | 60 | @app.get("/items/{item_id}") 61 | async def read_items(*, item_id: int = Path(title="The ID of the item to get"), q: str): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 62 | pass | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 12 12 | Security, @@ -348,13 +359,14 @@ FAST002_0.py:61:25: FAST002 [*] FastAPI dependency without `Annotated` 63 64 | 64 65 | # Non fixable errors -FAST002_0.py:70:5: FAST002 FastAPI dependency without `Annotated` +FAST002 FastAPI dependency without `Annotated` + --> FAST002_0.py:70:5 | 68 | skip: int = 0, 69 | limit: int = 10, 70 | current_user: User = Depends(get_current_user), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 71 | ): 72 | pass | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` diff --git a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_1.py.snap b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_1.py.snap index d93b32d102..90cef9a1a3 100644 --- a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_1.py.snap +++ b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_1.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/fastapi/mod.rs -snapshot_kind: text --- -FAST002_1.py:10:13: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_1.py:10:13 | 9 | @app.get("/test") 10 | def handler(echo: str = Query("")): - | ^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^ 11 | return echo | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 2 2 | values. See #15043 for more details.""" @@ -27,14 +27,15 @@ FAST002_1.py:10:13: FAST002 [*] FastAPI dependency without `Annotated` 12 13 | 13 14 | -FAST002_1.py:15:14: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_1.py:15:14 | 14 | @app.get("/test") 15 | def handler2(echo: str = Query(default="")): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | return echo | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 2 2 | values. See #15043 for more details.""" @@ -54,14 +55,15 @@ FAST002_1.py:15:14: FAST002 [*] FastAPI dependency without `Annotated` 17 18 | 18 19 | -FAST002_1.py:20:14: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_1.py:20:14 | 19 | @app.get("/test") 20 | def handler3(echo: str = Query("123", min_length=3, max_length=50)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | return echo | - = help: Replace with `typing.Annotated` +help: Replace with `typing.Annotated` ℹ Unsafe fix 2 2 | values. See #15043 for more details.""" diff --git a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_1.py_py38.snap b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_1.py_py38.snap index 3359b5ce5c..d67640cbc7 100644 --- a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_1.py_py38.snap +++ b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-non-annotated-dependency_FAST002_1.py_py38.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/fastapi/mod.rs -snapshot_kind: text --- -FAST002_1.py:10:13: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_1.py:10:13 | 9 | @app.get("/test") 10 | def handler(echo: str = Query("")): - | ^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^ 11 | return echo | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 2 2 | values. See #15043 for more details.""" @@ -27,14 +27,15 @@ FAST002_1.py:10:13: FAST002 [*] FastAPI dependency without `Annotated` 12 13 | 13 14 | -FAST002_1.py:15:14: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_1.py:15:14 | 14 | @app.get("/test") 15 | def handler2(echo: str = Query(default="")): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | return echo | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 2 2 | values. See #15043 for more details.""" @@ -54,14 +55,15 @@ FAST002_1.py:15:14: FAST002 [*] FastAPI dependency without `Annotated` 17 18 | 18 19 | -FAST002_1.py:20:14: FAST002 [*] FastAPI dependency without `Annotated` +FAST002 [*] FastAPI dependency without `Annotated` + --> FAST002_1.py:20:14 | 19 | @app.get("/test") 20 | def handler3(echo: str = Query("123", min_length=3, max_length=50)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | return echo | - = help: Replace with `typing_extensions.Annotated` +help: Replace with `typing_extensions.Annotated` ℹ Unsafe fix 2 2 | values. See #15043 for more details.""" diff --git a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-redundant-response-model_FAST001.py.snap b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-redundant-response-model_FAST001.py.snap index 79953ce698..16221a6d45 100644 --- a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-redundant-response-model_FAST001.py.snap +++ b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-redundant-response-model_FAST001.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/fastapi/mod.rs --- -FAST001.py:17:22: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:17:22 | 17 | @app.post("/items/", response_model=Item) - | ^^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^^ 18 | async def create_item(item: Item) -> Item: 19 | return item | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 14 14 | # Errors @@ -20,14 +21,15 @@ FAST001.py:17:22: FAST001 [*] FastAPI route with redundant `response_model` argu 19 19 | return item 20 20 | -FAST001.py:22:22: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:22:22 | 22 | @app.post("/items/", response_model=list[Item]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | async def create_item(item: Item) -> list[Item]: 24 | return item | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 19 19 | return item @@ -39,14 +41,15 @@ FAST001.py:22:22: FAST001 [*] FastAPI route with redundant `response_model` argu 24 24 | return item 25 25 | -FAST001.py:27:22: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:27:22 | 27 | @app.post("/items/", response_model=List[Item]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | async def create_item(item: Item) -> List[Item]: 29 | return item | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 24 24 | return item @@ -58,14 +61,15 @@ FAST001.py:27:22: FAST001 [*] FastAPI route with redundant `response_model` argu 29 29 | return item 30 30 | -FAST001.py:32:22: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:32:22 | 32 | @app.post("/items/", response_model=Dict[str, Item]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | async def create_item(item: Item) -> Dict[str, Item]: 34 | return item | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 29 29 | return item @@ -77,14 +81,15 @@ FAST001.py:32:22: FAST001 [*] FastAPI route with redundant `response_model` argu 34 34 | return item 35 35 | -FAST001.py:37:22: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:37:22 | 37 | @app.post("/items/", response_model=str) - | ^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^ 38 | async def create_item(item: Item) -> str: 39 | return item | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 34 34 | return item @@ -96,14 +101,15 @@ FAST001.py:37:22: FAST001 [*] FastAPI route with redundant `response_model` argu 39 39 | return item 40 40 | -FAST001.py:42:21: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:42:21 | 42 | @app.get("/items/", response_model=Item) - | ^^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^^ 43 | async def create_item(item: Item) -> Item: 44 | return item | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 39 39 | return item @@ -115,14 +121,15 @@ FAST001.py:42:21: FAST001 [*] FastAPI route with redundant `response_model` argu 44 44 | return item 45 45 | -FAST001.py:47:21: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:47:21 | 47 | @app.get("/items/", response_model=Item) - | ^^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^^ 48 | @app.post("/items/", response_model=Item) 49 | async def create_item(item: Item) -> Item: | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 44 44 | return item @@ -134,15 +141,16 @@ FAST001.py:47:21: FAST001 [*] FastAPI route with redundant `response_model` argu 49 49 | async def create_item(item: Item) -> Item: 50 50 | return item -FAST001.py:48:22: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:48:22 | 47 | @app.get("/items/", response_model=Item) 48 | @app.post("/items/", response_model=Item) - | ^^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^^ 49 | async def create_item(item: Item) -> Item: 50 | return item | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 45 45 | @@ -154,14 +162,15 @@ FAST001.py:48:22: FAST001 [*] FastAPI route with redundant `response_model` argu 50 50 | return item 51 51 | -FAST001.py:53:24: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:53:24 | 53 | @router.get("/items/", response_model=Item) - | ^^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^^ 54 | async def create_item(item: Item) -> Item: 55 | return item | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 50 50 | return item @@ -173,16 +182,17 @@ FAST001.py:53:24: FAST001 [*] FastAPI route with redundant `response_model` argu 55 55 | return item 56 56 | -FAST001.py:118:23: FAST001 [*] FastAPI route with redundant `response_model` argument +FAST001 [*] FastAPI route with redundant `response_model` argument + --> FAST001.py:118:23 | 116 | def setup_app(app_arg: FastAPI, non_app: str) -> None: 117 | # Error 118 | @app_arg.get("/", response_model=str) - | ^^^^^^^^^^^^^^^^^^ FAST001 + | ^^^^^^^^^^^^^^^^^^ 119 | async def get_root() -> str: 120 | return "Hello World!" | - = help: Remove argument +help: Remove argument ℹ Unsafe fix 115 115 | diff --git a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-unused-path-parameter_FAST003.py.snap b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-unused-path-parameter_FAST003.py.snap index 6869770ac3..bbd030304c 100644 --- a/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-unused-path-parameter_FAST003.py.snap +++ b/crates/ruff_linter/src/rules/fastapi/snapshots/ruff_linter__rules__fastapi__tests__fast-api-unused-path-parameter_FAST003.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/fastapi/mod.rs --- -FAST003.py:9:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature + --> FAST003.py:9:19 | 8 | # Errors 9 | @app.get("/things/{thing_id}") - | ^^^^^^^^^^ FAST003 + | ^^^^^^^^^^ 10 | async def read_thing(query: str): 11 | return {"query": query} | - = help: Add `thing_id` to function signature +help: Add `thing_id` to function signature ℹ Unsafe fix 7 7 | @@ -21,14 +22,15 @@ FAST003.py:9:19: FAST003 [*] Parameter `thing_id` appears in route path, but not 12 12 | 13 13 | -FAST003.py:14:23: FAST003 [*] Parameter `isbn` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `isbn` appears in route path, but not in `read_thing` signature + --> FAST003.py:14:23 | 14 | @app.get("/books/isbn-{isbn}") - | ^^^^^^ FAST003 + | ^^^^^^ 15 | async def read_thing(): 16 | ... | - = help: Add `isbn` to function signature +help: Add `isbn` to function signature ℹ Unsafe fix 12 12 | @@ -40,14 +42,15 @@ FAST003.py:14:23: FAST003 [*] Parameter `isbn` appears in route path, but not in 17 17 | 18 18 | -FAST003.py:19:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature + --> FAST003.py:19:19 | 19 | @app.get("/things/{thing_id:path}") - | ^^^^^^^^^^^^^^^ FAST003 + | ^^^^^^^^^^^^^^^ 20 | async def read_thing(query: str): 21 | return {"query": query} | - = help: Add `thing_id` to function signature +help: Add `thing_id` to function signature ℹ Unsafe fix 17 17 | @@ -59,14 +62,15 @@ FAST003.py:19:19: FAST003 [*] Parameter `thing_id` appears in route path, but no 22 22 | 23 23 | -FAST003.py:24:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature + --> FAST003.py:24:19 | 24 | @app.get("/things/{thing_id : path}") - | ^^^^^^^^^^^^^^^^^ FAST003 + | ^^^^^^^^^^^^^^^^^ 25 | async def read_thing(query: str): 26 | return {"query": query} | - = help: Add `thing_id` to function signature +help: Add `thing_id` to function signature ℹ Unsafe fix 22 22 | @@ -78,14 +82,15 @@ FAST003.py:24:19: FAST003 [*] Parameter `thing_id` appears in route path, but no 27 27 | 28 28 | -FAST003.py:29:27: FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature + --> FAST003.py:29:27 | 29 | @app.get("/books/{author}/{title}") - | ^^^^^^^ FAST003 + | ^^^^^^^ 30 | async def read_thing(author: str): 31 | return {"author": author} | - = help: Add `title` to function signature +help: Add `title` to function signature ℹ Unsafe fix 27 27 | @@ -97,14 +102,15 @@ FAST003.py:29:27: FAST003 [*] Parameter `title` appears in route path, but not i 32 32 | 33 33 | -FAST003.py:34:18: FAST003 [*] Parameter `author_name` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `author_name` appears in route path, but not in `read_thing` signature + --> FAST003.py:34:18 | 34 | @app.get("/books/{author_name}/{title}") - | ^^^^^^^^^^^^^ FAST003 + | ^^^^^^^^^^^^^ 35 | async def read_thing(): 36 | ... | - = help: Add `author_name` to function signature +help: Add `author_name` to function signature ℹ Unsafe fix 32 32 | @@ -116,14 +122,15 @@ FAST003.py:34:18: FAST003 [*] Parameter `author_name` appears in route path, but 37 37 | 38 38 | -FAST003.py:34:32: FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature + --> FAST003.py:34:32 | 34 | @app.get("/books/{author_name}/{title}") - | ^^^^^^^ FAST003 + | ^^^^^^^ 35 | async def read_thing(): 36 | ... | - = help: Add `title` to function signature +help: Add `title` to function signature ℹ Unsafe fix 32 32 | @@ -135,30 +142,33 @@ FAST003.py:34:32: FAST003 [*] Parameter `title` appears in route path, but not i 37 37 | 38 38 | -FAST003.py:39:18: FAST003 Parameter `author` appears in route path, but only as a positional-only argument in `read_thing` signature +FAST003 Parameter `author` appears in route path, but only as a positional-only argument in `read_thing` signature + --> FAST003.py:39:18 | 39 | @app.get("/books/{author}/{title}") - | ^^^^^^^^ FAST003 + | ^^^^^^^^ 40 | async def read_thing(author: str, title: str, /): 41 | return {"author": author, "title": title} | -FAST003.py:39:27: FAST003 Parameter `title` appears in route path, but only as a positional-only argument in `read_thing` signature +FAST003 Parameter `title` appears in route path, but only as a positional-only argument in `read_thing` signature + --> FAST003.py:39:27 | 39 | @app.get("/books/{author}/{title}") - | ^^^^^^^ FAST003 + | ^^^^^^^ 40 | async def read_thing(author: str, title: str, /): 41 | return {"author": author, "title": title} | -FAST003.py:44:27: FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature + --> FAST003.py:44:27 | 44 | @app.get("/books/{author}/{title}/{page}") - | ^^^^^^^ FAST003 + | ^^^^^^^ 45 | async def read_thing( 46 | author: str, | - = help: Add `title` to function signature +help: Add `title` to function signature ℹ Unsafe fix 44 44 | @app.get("/books/{author}/{title}/{page}") @@ -170,14 +180,15 @@ FAST003.py:44:27: FAST003 [*] Parameter `title` appears in route path, but not i 49 49 | 50 50 | -FAST003.py:44:35: FAST003 [*] Parameter `page` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `page` appears in route path, but not in `read_thing` signature + --> FAST003.py:44:35 | 44 | @app.get("/books/{author}/{title}/{page}") - | ^^^^^^ FAST003 + | ^^^^^^ 45 | async def read_thing( 46 | author: str, | - = help: Add `page` to function signature +help: Add `page` to function signature ℹ Unsafe fix 44 44 | @app.get("/books/{author}/{title}/{page}") @@ -189,14 +200,15 @@ FAST003.py:44:35: FAST003 [*] Parameter `page` appears in route path, but not in 49 49 | 50 50 | -FAST003.py:51:18: FAST003 [*] Parameter `author` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `author` appears in route path, but not in `read_thing` signature + --> FAST003.py:51:18 | 51 | @app.get("/books/{author}/{title}") - | ^^^^^^^^ FAST003 + | ^^^^^^^^ 52 | async def read_thing(): 53 | ... | - = help: Add `author` to function signature +help: Add `author` to function signature ℹ Unsafe fix 49 49 | @@ -208,14 +220,15 @@ FAST003.py:51:18: FAST003 [*] Parameter `author` appears in route path, but not 54 54 | 55 55 | -FAST003.py:51:27: FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature + --> FAST003.py:51:27 | 51 | @app.get("/books/{author}/{title}") - | ^^^^^^^ FAST003 + | ^^^^^^^ 52 | async def read_thing(): 53 | ... | - = help: Add `title` to function signature +help: Add `title` to function signature ℹ Unsafe fix 49 49 | @@ -227,14 +240,15 @@ FAST003.py:51:27: FAST003 [*] Parameter `title` appears in route path, but not i 54 54 | 55 55 | -FAST003.py:56:27: FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature + --> FAST003.py:56:27 | 56 | @app.get("/books/{author}/{title}") - | ^^^^^^^ FAST003 + | ^^^^^^^ 57 | async def read_thing(*, author: str): 58 | ... | - = help: Add `title` to function signature +help: Add `title` to function signature ℹ Unsafe fix 54 54 | @@ -246,14 +260,15 @@ FAST003.py:56:27: FAST003 [*] Parameter `title` appears in route path, but not i 59 59 | 60 60 | -FAST003.py:61:27: FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `title` appears in route path, but not in `read_thing` signature + --> FAST003.py:61:27 | 61 | @app.get("/books/{author}/{title}") - | ^^^^^^^ FAST003 + | ^^^^^^^ 62 | async def read_thing(hello, /, *, author: str): 63 | ... | - = help: Add `title` to function signature +help: Add `title` to function signature ℹ Unsafe fix 59 59 | @@ -265,14 +280,15 @@ FAST003.py:61:27: FAST003 [*] Parameter `title` appears in route path, but not i 64 64 | 65 65 | -FAST003.py:66:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature + --> FAST003.py:66:19 | 66 | @app.get("/things/{thing_id}") - | ^^^^^^^^^^ FAST003 + | ^^^^^^^^^^ 67 | async def read_thing( 68 | query: str, | - = help: Add `thing_id` to function signature +help: Add `thing_id` to function signature ℹ Unsafe fix 65 65 | @@ -284,14 +300,15 @@ FAST003.py:66:19: FAST003 [*] Parameter `thing_id` appears in route path, but no 70 70 | return {"query": query} 71 71 | -FAST003.py:73:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature + --> FAST003.py:73:19 | 73 | @app.get("/things/{thing_id}") - | ^^^^^^^^^^ FAST003 + | ^^^^^^^^^^ 74 | async def read_thing( 75 | query: str = "default", | - = help: Add `thing_id` to function signature +help: Add `thing_id` to function signature ℹ Unsafe fix 72 72 | @@ -303,14 +320,15 @@ FAST003.py:73:19: FAST003 [*] Parameter `thing_id` appears in route path, but no 77 77 | return {"query": query} 78 78 | -FAST003.py:80:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `thing_id` appears in route path, but not in `read_thing` signature + --> FAST003.py:80:19 | 80 | @app.get("/things/{thing_id}") - | ^^^^^^^^^^ FAST003 + | ^^^^^^^^^^ 81 | async def read_thing( 82 | *, query: str = "default", | - = help: Add `thing_id` to function signature +help: Add `thing_id` to function signature ℹ Unsafe fix 79 79 | @@ -322,14 +340,15 @@ FAST003.py:80:19: FAST003 [*] Parameter `thing_id` appears in route path, but no 84 84 | return {"query": query} 85 85 | -FAST003.py:87:18: FAST003 [*] Parameter `name` appears in route path, but not in `read_thing` signature +FAST003 [*] Parameter `name` appears in route path, but not in `read_thing` signature + --> FAST003.py:87:18 | 87 | @app.get("/books/{name}/{title}") - | ^^^^^^ FAST003 + | ^^^^^^ 88 | async def read_thing(*, author: Annotated[str, Path(alias="author_name")], title: str): 89 | return {"author": author, "title": title} | - = help: Add `name` to function signature +help: Add `name` to function signature ℹ Unsafe fix 85 85 | @@ -341,15 +360,16 @@ FAST003.py:87:18: FAST003 [*] Parameter `name` appears in route path, but not in 90 90 | 91 91 | -FAST003.py:158:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `single` signature +FAST003 [*] Parameter `thing_id` appears in route path, but not in `single` signature + --> FAST003.py:158:19 | 157 | ### Errors 158 | @app.get("/things/{thing_id}") - | ^^^^^^^^^^ FAST003 + | ^^^^^^^^^^ 159 | async def single(other: Annotated[str, Depends(something_else)]): ... 160 | @app.get("/things/{thing_id}") | - = help: Add `thing_id` to function signature +help: Add `thing_id` to function signature ℹ Unsafe fix 156 156 | @@ -361,15 +381,16 @@ FAST003.py:158:19: FAST003 [*] Parameter `thing_id` appears in route path, but n 161 161 | async def default(other: str = Depends(something_else)): ... 162 162 | -FAST003.py:160:19: FAST003 [*] Parameter `thing_id` appears in route path, but not in `default` signature +FAST003 [*] Parameter `thing_id` appears in route path, but not in `default` signature + --> FAST003.py:160:19 | 158 | @app.get("/things/{thing_id}") 159 | async def single(other: Annotated[str, Depends(something_else)]): ... 160 | @app.get("/things/{thing_id}") - | ^^^^^^^^^^ FAST003 + | ^^^^^^^^^^ 161 | async def default(other: str = Depends(something_else)): ... | - = help: Add `thing_id` to function signature +help: Add `thing_id` to function signature ℹ Unsafe fix 158 158 | @app.get("/things/{thing_id}") @@ -381,15 +402,16 @@ FAST003.py:160:19: FAST003 [*] Parameter `thing_id` appears in route path, but n 163 163 | 164 164 | ### No errors -FAST003.py:197:12: FAST003 [*] Parameter `id` appears in route path, but not in `get_id_pydantic_full` signature +FAST003 [*] Parameter `id` appears in route path, but not in `get_id_pydantic_full` signature + --> FAST003.py:197:12 | 196 | # Errors 197 | @app.get("/{id}") - | ^^^^ FAST003 + | ^^^^ 198 | async def get_id_pydantic_full( 199 | params: Annotated[PydanticParams, Depends(PydanticParams)], | - = help: Add `id` to function signature +help: Add `id` to function signature ℹ Unsafe fix 196 196 | # Errors @@ -401,16 +423,17 @@ FAST003.py:197:12: FAST003 [*] Parameter `id` appears in route path, but not in 201 201 | @app.get("/{id}") 202 202 | async def get_id_pydantic_short(params: Annotated[PydanticParams, Depends()]): ... -FAST003.py:201:12: FAST003 [*] Parameter `id` appears in route path, but not in `get_id_pydantic_short` signature +FAST003 [*] Parameter `id` appears in route path, but not in `get_id_pydantic_short` signature + --> FAST003.py:201:12 | 199 | params: Annotated[PydanticParams, Depends(PydanticParams)], 200 | ): ... 201 | @app.get("/{id}") - | ^^^^ FAST003 + | ^^^^ 202 | async def get_id_pydantic_short(params: Annotated[PydanticParams, Depends()]): ... 203 | @app.get("/{id}") | - = help: Add `id` to function signature +help: Add `id` to function signature ℹ Unsafe fix 199 199 | params: Annotated[PydanticParams, Depends(PydanticParams)], @@ -422,15 +445,16 @@ FAST003.py:201:12: FAST003 [*] Parameter `id` appears in route path, but not in 204 204 | async def get_id_init_not_annotated(params = Depends(InitParams)): ... 205 205 | -FAST003.py:203:12: FAST003 [*] Parameter `id` appears in route path, but not in `get_id_init_not_annotated` signature +FAST003 [*] Parameter `id` appears in route path, but not in `get_id_init_not_annotated` signature + --> FAST003.py:203:12 | 201 | @app.get("/{id}") 202 | async def get_id_pydantic_short(params: Annotated[PydanticParams, Depends()]): ... 203 | @app.get("/{id}") - | ^^^^ FAST003 + | ^^^^ 204 | async def get_id_init_not_annotated(params = Depends(InitParams)): ... | - = help: Add `id` to function signature +help: Add `id` to function signature ℹ Unsafe fix 201 201 | @app.get("/{id}") diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap index bd81dd2410..b018bd2580 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT101.py:6:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` +YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` + --> YTT101.py:6:7 | 4 | print(sys.version) 5 | 6 | print(sys.version[:3]) - | ^^^^^^^^^^^ YTT101 + | ^^^^^^^^^^^ 7 | print(version[:3]) 8 | print(v[:3]) | -YTT101.py:7:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` +YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` + --> YTT101.py:7:7 | 6 | print(sys.version[:3]) 7 | print(version[:3]) - | ^^^^^^^ YTT101 + | ^^^^^^^ 8 | print(v[:3]) | -YTT101.py:8:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` +YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` + --> YTT101.py:8:7 | 6 | print(sys.version[:3]) 7 | print(version[:3]) 8 | print(v[:3]) - | ^ YTT101 + | ^ 9 | 10 | # the tool is timid and only flags certain numeric slices | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap index b5b82d89fa..24afa44e35 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT102.py:4:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` +YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` + --> YTT102.py:4:12 | 2 | from sys import version 3 | 4 | py_minor = sys.version[2] - | ^^^^^^^^^^^ YTT102 + | ^^^^^^^^^^^ 5 | py_minor = version[2] | -YTT102.py:5:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` +YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` + --> YTT102.py:5:12 | 4 | py_minor = sys.version[2] 5 | py_minor = version[2] - | ^^^^^^^ YTT102 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap index fb884488c8..356e19d247 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap @@ -1,48 +1,53 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT103.py:4:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` +YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + --> YTT103.py:4:1 | 2 | from sys import version 3 | 4 | version < "3.5" - | ^^^^^^^ YTT103 + | ^^^^^^^ 5 | sys.version < "3.5" 6 | sys.version <= "3.5" | -YTT103.py:5:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` +YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + --> YTT103.py:5:1 | 4 | version < "3.5" 5 | sys.version < "3.5" - | ^^^^^^^^^^^ YTT103 + | ^^^^^^^^^^^ 6 | sys.version <= "3.5" 7 | sys.version > "3.5" | -YTT103.py:6:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` +YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + --> YTT103.py:6:1 | 4 | version < "3.5" 5 | sys.version < "3.5" 6 | sys.version <= "3.5" - | ^^^^^^^^^^^ YTT103 + | ^^^^^^^^^^^ 7 | sys.version > "3.5" 8 | sys.version >= "3.5" | -YTT103.py:7:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` +YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + --> YTT103.py:7:1 | 5 | sys.version < "3.5" 6 | sys.version <= "3.5" 7 | sys.version > "3.5" - | ^^^^^^^^^^^ YTT103 + | ^^^^^^^^^^^ 8 | sys.version >= "3.5" | -YTT103.py:8:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` +YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + --> YTT103.py:8:1 | 6 | sys.version <= "3.5" 7 | sys.version > "3.5" 8 | sys.version >= "3.5" - | ^^^^^^^^^^^ YTT103 + | ^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap index f5422cad3d..1bf91d93d8 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT201.py:7:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` +YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` + --> YTT201.py:7:7 | 5 | PY3 = sys.version_info[0] >= 3 6 | 7 | PY3 = sys.version_info[0] == 3 - | ^^^^^^^^^^^^^^^^^^^ YTT201 + | ^^^^^^^^^^^^^^^^^^^ 8 | PY3 = version_info[0] == 3 9 | PY2 = sys.version_info[0] != 3 | -YTT201.py:8:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` +YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` + --> YTT201.py:8:7 | 7 | PY3 = sys.version_info[0] == 3 8 | PY3 = version_info[0] == 3 - | ^^^^^^^^^^^^^^^ YTT201 + | ^^^^^^^^^^^^^^^ 9 | PY2 = sys.version_info[0] != 3 10 | PY2 = version_info[0] != 3 | -YTT201.py:9:7: YTT201 `sys.version_info[0] != 3` referenced (python4), use `<` +YTT201 `sys.version_info[0] != 3` referenced (python4), use `<` + --> YTT201.py:9:7 | 7 | PY3 = sys.version_info[0] == 3 8 | PY3 = version_info[0] == 3 9 | PY2 = sys.version_info[0] != 3 - | ^^^^^^^^^^^^^^^^^^^ YTT201 + | ^^^^^^^^^^^^^^^^^^^ 10 | PY2 = version_info[0] != 3 | -YTT201.py:10:7: YTT201 `sys.version_info[0] != 3` referenced (python4), use `<` +YTT201 `sys.version_info[0] != 3` referenced (python4), use `<` + --> YTT201.py:10:7 | 8 | PY3 = version_info[0] == 3 9 | PY2 = sys.version_info[0] != 3 10 | PY2 = version_info[0] != 3 - | ^^^^^^^^^^^^^^^ YTT201 + | ^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap index da923c2649..9131dd3ae2 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap @@ -1,21 +1,23 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT202.py:4:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2` +YTT202 `six.PY3` referenced (python4), use `not six.PY2` + --> YTT202.py:4:4 | 2 | from six import PY3 3 | 4 | if six.PY3: - | ^^^^^^^ YTT202 + | ^^^^^^^ 5 | print("3") 6 | if PY3: | -YTT202.py:6:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2` +YTT202 `six.PY3` referenced (python4), use `not six.PY2` + --> YTT202.py:6:4 | 4 | if six.PY3: 5 | print("3") 6 | if PY3: - | ^^^ YTT202 + | ^^^ 7 | print("3") | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap index 98340c2c0d..564a40092f 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT203.py:4:1: YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple +YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple + --> YTT203.py:4:1 | 2 | from sys import version_info 3 | 4 | sys.version_info[1] >= 5 - | ^^^^^^^^^^^^^^^^^^^ YTT203 + | ^^^^^^^^^^^^^^^^^^^ 5 | version_info[1] < 6 | -YTT203.py:5:1: YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple +YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple + --> YTT203.py:5:1 | 4 | sys.version_info[1] >= 5 5 | version_info[1] < 6 - | ^^^^^^^^^^^^^^^ YTT203 + | ^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap index 0d59be0063..3d8deee9a6 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT204.py:4:1: YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple +YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple + --> YTT204.py:4:1 | 2 | from sys import version_info 3 | 4 | sys.version_info.minor <= 7 - | ^^^^^^^^^^^^^^^^^^^^^^ YTT204 + | ^^^^^^^^^^^^^^^^^^^^^^ 5 | version_info.minor > 8 | -YTT204.py:5:1: YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple +YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple + --> YTT204.py:5:1 | 4 | sys.version_info.minor <= 7 5 | version_info.minor > 8 - | ^^^^^^^^^^^^^^^^^^ YTT204 + | ^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap index df1b27d330..d22cefefaa 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT301.py:4:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` +YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` + --> YTT301.py:4:12 | 2 | from sys import version 3 | 4 | py_major = sys.version[0] - | ^^^^^^^^^^^ YTT301 + | ^^^^^^^^^^^ 5 | py_major = version[0] | -YTT301.py:5:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` +YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` + --> YTT301.py:5:12 | 4 | py_major = sys.version[0] 5 | py_major = version[0] - | ^^^^^^^ YTT301 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap index 27e563290e..a6d0a05293 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap @@ -1,48 +1,53 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT302.py:4:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` +YTT302 `sys.version` compared to string (python10), use `sys.version_info` + --> YTT302.py:4:1 | 2 | from sys import version 3 | 4 | version < "3" - | ^^^^^^^ YTT302 + | ^^^^^^^ 5 | sys.version < "3" 6 | sys.version <= "3" | -YTT302.py:5:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` +YTT302 `sys.version` compared to string (python10), use `sys.version_info` + --> YTT302.py:5:1 | 4 | version < "3" 5 | sys.version < "3" - | ^^^^^^^^^^^ YTT302 + | ^^^^^^^^^^^ 6 | sys.version <= "3" 7 | sys.version > "3" | -YTT302.py:6:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` +YTT302 `sys.version` compared to string (python10), use `sys.version_info` + --> YTT302.py:6:1 | 4 | version < "3" 5 | sys.version < "3" 6 | sys.version <= "3" - | ^^^^^^^^^^^ YTT302 + | ^^^^^^^^^^^ 7 | sys.version > "3" 8 | sys.version >= "3" | -YTT302.py:7:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` +YTT302 `sys.version` compared to string (python10), use `sys.version_info` + --> YTT302.py:7:1 | 5 | sys.version < "3" 6 | sys.version <= "3" 7 | sys.version > "3" - | ^^^^^^^^^^^ YTT302 + | ^^^^^^^^^^^ 8 | sys.version >= "3" | -YTT302.py:8:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` +YTT302 `sys.version` compared to string (python10), use `sys.version_info` + --> YTT302.py:8:1 | 6 | sys.version <= "3" 7 | sys.version > "3" 8 | sys.version >= "3" - | ^^^^^^^^^^^ YTT302 + | ^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap index 8cda6c2108..187ac8f9fe 100644 --- a/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_2020/mod.rs --- -YTT303.py:4:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` +YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` + --> YTT303.py:4:7 | 2 | from sys import version 3 | 4 | print(sys.version[:1]) - | ^^^^^^^^^^^ YTT303 + | ^^^^^^^^^^^ 5 | print(version[:1]) | -YTT303.py:5:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` +YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` + --> YTT303.py:5:7 | 4 | print(sys.version[:1]) 5 | print(version[:1]) - | ^^^^^^^ YTT303 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_overload.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_overload.snap index dc8485ff44..24a9104bc6 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_overload.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_overload.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs -snapshot_kind: text --- -allow_overload.py:29:9: ANN201 Missing return type annotation for public function `bar` +ANN201 Missing return type annotation for public function `bar` + --> allow_overload.py:29:9 | 28 | class X: 29 | def bar(i): - | ^^^ ANN201 + | ^^^ 30 | return i | - = help: Add return type annotation +help: Add return type annotation diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_star_arg_any.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_star_arg_any.snap index 3a69fd737a..75fd0c8009 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_star_arg_any.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_star_arg_any.snap @@ -1,35 +1,38 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs -snapshot_kind: text --- -allow_star_arg_any.py:10:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> allow_star_arg_any.py:10:12 | 9 | # ANN401 10 | def foo(a: Any, *args: str, **kwargs: str) -> int: - | ^^^ ANN401 + | ^^^ 11 | pass | -allow_star_arg_any.py:15:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` + --> allow_star_arg_any.py:15:47 | 14 | # ANN401 15 | def foo(a: int, *args: str, **kwargs: str) -> Any: - | ^^^ ANN401 + | ^^^ 16 | pass | -allow_star_arg_any.py:40:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> allow_star_arg_any.py:40:29 | 39 | # ANN401 40 | def foo_method(self, a: Any, *params: str, **options: str) -> int: - | ^^^ ANN401 + | ^^^ 41 | pass | -allow_star_arg_any.py:44:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo_method` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo_method` + --> allow_star_arg_any.py:44:67 | 43 | # ANN401 44 | def foo_method(self, a: int, *params: str, **options: str) -> Any: - | ^^^ ANN401 + | ^^^ 45 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type.snap index d3c838bb14..b3ddc0faa2 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs -snapshot_kind: text --- -auto_return_type.py:1:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:1:5 | 1 | def func(): - | ^^^^ ANN201 + | ^^^^ 2 | return 1 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 1 |-def func(): @@ -17,13 +17,14 @@ auto_return_type.py:1:5: ANN201 [*] Missing return type annotation for public fu 3 3 | 4 4 | -auto_return_type.py:5:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:5:5 | 5 | def func(): - | ^^^^ ANN201 + | ^^^^ 6 | return 1.5 | - = help: Add return type annotation: `float` +help: Add return type annotation: `float` ℹ Unsafe fix 2 2 | return 1 @@ -35,14 +36,15 @@ auto_return_type.py:5:5: ANN201 [*] Missing return type annotation for public fu 7 7 | 8 8 | -auto_return_type.py:9:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:9:5 | 9 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 10 | if x > 0: 11 | return 1 | - = help: Add return type annotation: `float` +help: Add return type annotation: `float` ℹ Unsafe fix 6 6 | return 1.5 @@ -54,13 +56,14 @@ auto_return_type.py:9:5: ANN201 [*] Missing return type annotation for public fu 11 11 | return 1 12 12 | else: -auto_return_type.py:16:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:16:5 | 16 | def func(): - | ^^^^ ANN201 + | ^^^^ 17 | return True | - = help: Add return type annotation: `bool` +help: Add return type annotation: `bool` ℹ Unsafe fix 13 13 | return 1.5 @@ -72,14 +75,15 @@ auto_return_type.py:16:5: ANN201 [*] Missing return type annotation for public f 18 18 | 19 19 | -auto_return_type.py:20:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:20:5 | 20 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 21 | if x > 0: 22 | return None | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 17 17 | return True @@ -91,13 +95,14 @@ auto_return_type.py:20:5: ANN201 [*] Missing return type annotation for public f 22 22 | return None 23 23 | else: -auto_return_type.py:27:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:27:5 | 27 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 28 | return 1 or 2.5 if x > 0 else 1.5 or "str" | - = help: Add return type annotation: `str | float` +help: Add return type annotation: `str | float` ℹ Unsafe fix 24 24 | return @@ -109,13 +114,14 @@ auto_return_type.py:27:5: ANN201 [*] Missing return type annotation for public f 29 29 | 30 30 | -auto_return_type.py:31:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:31:5 | 31 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 32 | return 1 + 2.5 if x > 0 else 1.5 or "str" | - = help: Add return type annotation: `str | float` +help: Add return type annotation: `str | float` ℹ Unsafe fix 28 28 | return 1 or 2.5 if x > 0 else 1.5 or "str" @@ -127,31 +133,34 @@ auto_return_type.py:31:5: ANN201 [*] Missing return type annotation for public f 33 33 | 34 34 | -auto_return_type.py:35:5: ANN201 Missing return type annotation for public function `func` +ANN201 Missing return type annotation for public function `func` + --> auto_return_type.py:35:5 | 35 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 36 | if not x: 37 | return None | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:41:5: ANN201 Missing return type annotation for public function `func` +ANN201 Missing return type annotation for public function `func` + --> auto_return_type.py:41:5 | 41 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 42 | return {"foo": 1} | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:45:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:45:5 | 45 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 46 | if not x: 47 | return 1 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 42 42 | return {"foo": 1} @@ -163,14 +172,15 @@ auto_return_type.py:45:5: ANN201 [*] Missing return type annotation for public f 47 47 | return 1 48 48 | else: -auto_return_type.py:52:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:52:5 | 52 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 53 | if not x: 54 | return 1 | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 49 49 | return True @@ -182,14 +192,15 @@ auto_return_type.py:52:5: ANN201 [*] Missing return type annotation for public f 54 54 | return 1 55 55 | else: -auto_return_type.py:59:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:59:5 | 59 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 60 | if not x: 61 | return 1 | - = help: Add return type annotation: `str | int | None` +help: Add return type annotation: `str | int | None` ℹ Unsafe fix 56 56 | return None @@ -201,14 +212,15 @@ auto_return_type.py:59:5: ANN201 [*] Missing return type annotation for public f 61 61 | return 1 62 62 | elif x > 5: -auto_return_type.py:68:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:68:5 | 68 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 69 | if x: 70 | return 1 | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 65 65 | return None @@ -220,13 +232,14 @@ auto_return_type.py:68:5: ANN201 [*] Missing return type annotation for public f 70 70 | return 1 71 71 | -auto_return_type.py:73:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:73:5 | 73 | def func(): - | ^^^^ ANN201 + | ^^^^ 74 | x = 1 | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 70 70 | return 1 @@ -238,14 +251,15 @@ auto_return_type.py:73:5: ANN201 [*] Missing return type annotation for public f 75 75 | 76 76 | -auto_return_type.py:77:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:77:5 | 77 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 78 | if x > 0: 79 | return 1 | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 74 74 | x = 1 @@ -257,14 +271,15 @@ auto_return_type.py:77:5: ANN201 [*] Missing return type annotation for public f 79 79 | return 1 80 80 | -auto_return_type.py:82:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:82:5 | 82 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 83 | match x: 84 | case [1, 2, 3]: | - = help: Add return type annotation: `str | int | None` +help: Add return type annotation: `str | int | None` ℹ Unsafe fix 79 79 | return 1 @@ -276,14 +291,15 @@ auto_return_type.py:82:5: ANN201 [*] Missing return type annotation for public f 84 84 | case [1, 2, 3]: 85 85 | return 1 -auto_return_type.py:90:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:90:5 | 90 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 91 | for i in range(5): 92 | if i > 0: | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 87 87 | return "foo" @@ -295,14 +311,15 @@ auto_return_type.py:90:5: ANN201 [*] Missing return type annotation for public f 92 92 | if i > 0: 93 93 | return 1 -auto_return_type.py:96:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:96:5 | 96 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 97 | for i in range(5): 98 | if i > 0: | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 93 93 | return 1 @@ -314,14 +331,15 @@ auto_return_type.py:96:5: ANN201 [*] Missing return type annotation for public f 98 98 | if i > 0: 99 99 | return 1 -auto_return_type.py:104:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:104:5 | 104 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 105 | for i in range(5): 106 | if i > 0: | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 101 101 | return 4 @@ -333,14 +351,15 @@ auto_return_type.py:104:5: ANN201 [*] Missing return type annotation for public 106 106 | if i > 0: 107 107 | break -auto_return_type.py:112:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:112:5 | 112 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 113 | try: 114 | pass | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 109 109 | return 4 @@ -352,14 +371,15 @@ auto_return_type.py:112:5: ANN201 [*] Missing return type annotation for public 114 114 | pass 115 115 | except: -auto_return_type.py:119:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:119:5 | 119 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 120 | try: 121 | pass | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 116 116 | return 1 @@ -371,14 +391,15 @@ auto_return_type.py:119:5: ANN201 [*] Missing return type annotation for public 121 121 | pass 122 122 | except: -auto_return_type.py:128:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:128:5 | 128 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 129 | try: 130 | pass | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 125 125 | return 2 @@ -390,14 +411,15 @@ auto_return_type.py:128:5: ANN201 [*] Missing return type annotation for public 130 130 | pass 131 131 | except: -auto_return_type.py:137:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:137:5 | 137 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 138 | try: 139 | return 1 | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 134 134 | return 2 @@ -409,14 +431,15 @@ auto_return_type.py:137:5: ANN201 [*] Missing return type annotation for public 139 139 | return 1 140 140 | except: -auto_return_type.py:146:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:146:5 | 146 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 147 | while x > 0: 148 | break | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 143 143 | pass @@ -428,63 +451,69 @@ auto_return_type.py:146:5: ANN201 [*] Missing return type annotation for public 148 148 | break 149 149 | return 1 -auto_return_type.py:158:9: ANN201 Missing return type annotation for public function `method` +ANN201 Missing return type annotation for public function `method` + --> auto_return_type.py:158:9 | 156 | class Foo(abc.ABC): 157 | @abstractmethod 158 | def method(self): - | ^^^^^^ ANN201 + | ^^^^^^ 159 | pass | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:162:9: ANN201 Missing return type annotation for public function `method` +ANN201 Missing return type annotation for public function `method` + --> auto_return_type.py:162:9 | 161 | @abc.abstractmethod 162 | def method(self): - | ^^^^^^ ANN201 + | ^^^^^^ 163 | """Docstring.""" | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:166:9: ANN201 Missing return type annotation for public function `method` +ANN201 Missing return type annotation for public function `method` + --> auto_return_type.py:166:9 | 165 | @abc.abstractmethod 166 | def method(self): - | ^^^^^^ ANN201 + | ^^^^^^ 167 | ... | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:171:9: ANN205 Missing return type annotation for staticmethod `method` +ANN205 Missing return type annotation for staticmethod `method` + --> auto_return_type.py:171:9 | 169 | @staticmethod 170 | @abstractmethod 171 | def method(): - | ^^^^^^ ANN205 + | ^^^^^^ 172 | pass | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:176:9: ANN206 Missing return type annotation for classmethod `method` +ANN206 Missing return type annotation for classmethod `method` + --> auto_return_type.py:176:9 | 174 | @classmethod 175 | @abstractmethod 176 | def method(cls): - | ^^^^^^ ANN206 + | ^^^^^^ 177 | pass | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:180:9: ANN201 [*] Missing return type annotation for public function `method` +ANN201 [*] Missing return type annotation for public function `method` + --> auto_return_type.py:180:9 | 179 | @abstractmethod 180 | def method(self): - | ^^^^^^ ANN201 + | ^^^^^^ 181 | if self.x > 0: 182 | return 1 | - = help: Add return type annotation: `float` +help: Add return type annotation: `float` ℹ Unsafe fix 177 177 | pass @@ -496,14 +525,15 @@ auto_return_type.py:180:9: ANN201 [*] Missing return type annotation for public 182 182 | return 1 183 183 | else: -auto_return_type.py:187:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:187:5 | 187 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 188 | try: 189 | pass | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 184 184 | return 1.5 @@ -515,14 +545,15 @@ auto_return_type.py:187:5: ANN201 [*] Missing return type annotation for public 189 189 | pass 190 190 | except: -auto_return_type.py:194:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:194:5 | 194 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 195 | try: 196 | pass | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 191 191 | return 2 @@ -534,14 +565,15 @@ auto_return_type.py:194:5: ANN201 [*] Missing return type annotation for public 196 196 | pass 197 197 | except: -auto_return_type.py:203:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:203:5 | 203 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 204 | if not x: 205 | raise ValueError | - = help: Add return type annotation: `Never` +help: Add return type annotation: `Never` ℹ Unsafe fix 151 151 | @@ -561,14 +593,15 @@ auto_return_type.py:203:5: ANN201 [*] Missing return type annotation for public 205 206 | raise ValueError 206 207 | else: -auto_return_type.py:210:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:210:5 | 210 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 211 | if not x: 212 | raise ValueError | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 207 207 | raise TypeError @@ -580,14 +613,15 @@ auto_return_type.py:210:5: ANN201 [*] Missing return type annotation for public 212 212 | raise ValueError 213 213 | else: -auto_return_type.py:234:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:234:5 | 234 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 235 | if not x: 236 | return 1 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 231 231 | return i @@ -599,14 +633,15 @@ auto_return_type.py:234:5: ANN201 [*] Missing return type annotation for public 236 236 | return 1 237 237 | raise ValueError -auto_return_type.py:240:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:240:5 | 240 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 241 | if not x: 242 | return 1 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 237 237 | raise ValueError @@ -618,14 +653,15 @@ auto_return_type.py:240:5: ANN201 [*] Missing return type annotation for public 242 242 | return 1 243 243 | else: -auto_return_type.py:248:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:248:5 | 248 | def func(): - | ^^^^ ANN201 + | ^^^^ 249 | try: 250 | raise ValueError | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 245 245 | raise ValueError @@ -637,14 +673,15 @@ auto_return_type.py:248:5: ANN201 [*] Missing return type annotation for public 250 250 | raise ValueError 251 251 | except: -auto_return_type.py:255:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:255:5 | 255 | def func(): - | ^^^^ ANN201 + | ^^^^ 256 | try: 257 | return 1 | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 252 252 | return 2 @@ -656,14 +693,15 @@ auto_return_type.py:255:5: ANN201 [*] Missing return type annotation for public 257 257 | return 1 258 258 | except: -auto_return_type.py:262:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:262:5 | 262 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 263 | for _ in range(3): 264 | if x > 0: | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 259 259 | pass @@ -675,14 +713,15 @@ auto_return_type.py:262:5: ANN201 [*] Missing return type annotation for public 264 264 | if x > 0: 265 265 | return 1 -auto_return_type.py:269:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:269:5 | 269 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 270 | if x > 5: 271 | raise ValueError | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 266 266 | raise ValueError @@ -694,14 +733,15 @@ auto_return_type.py:269:5: ANN201 [*] Missing return type annotation for public 271 271 | raise ValueError 272 272 | else: -auto_return_type.py:276:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:276:5 | 276 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 277 | if x > 5: 278 | raise ValueError | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 273 273 | pass @@ -713,14 +753,15 @@ auto_return_type.py:276:5: ANN201 [*] Missing return type annotation for public 278 278 | raise ValueError 279 279 | elif x > 10: -auto_return_type.py:283:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:283:5 | 283 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 284 | if x > 5: 285 | raise ValueError | - = help: Add return type annotation: `int | None` +help: Add return type annotation: `int | None` ℹ Unsafe fix 280 280 | pass @@ -732,14 +773,15 @@ auto_return_type.py:283:5: ANN201 [*] Missing return type annotation for public 285 285 | raise ValueError 286 286 | elif x > 10: -auto_return_type.py:290:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:290:5 | 290 | def func(): - | ^^^^ ANN201 + | ^^^^ 291 | try: 292 | return 5 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 287 287 | return 5 @@ -751,14 +793,15 @@ auto_return_type.py:290:5: ANN201 [*] Missing return type annotation for public 292 292 | return 5 293 293 | except: -auto_return_type.py:299:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:299:5 | 299 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 300 | match x: 301 | case [1, 2, 3]: | - = help: Add return type annotation: `str | int` +help: Add return type annotation: `str | int` ℹ Unsafe fix 296 296 | raise ValueError diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type_py38.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type_py38.snap index 49b9a07c81..1e30ffef69 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type_py38.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__auto_return_type_py38.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs --- -auto_return_type.py:1:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:1:5 | 1 | def func(): - | ^^^^ ANN201 + | ^^^^ 2 | return 1 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 1 |-def func(): @@ -16,13 +17,14 @@ auto_return_type.py:1:5: ANN201 [*] Missing return type annotation for public fu 3 3 | 4 4 | -auto_return_type.py:5:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:5:5 | 5 | def func(): - | ^^^^ ANN201 + | ^^^^ 6 | return 1.5 | - = help: Add return type annotation: `float` +help: Add return type annotation: `float` ℹ Unsafe fix 2 2 | return 1 @@ -34,14 +36,15 @@ auto_return_type.py:5:5: ANN201 [*] Missing return type annotation for public fu 7 7 | 8 8 | -auto_return_type.py:9:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:9:5 | 9 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 10 | if x > 0: 11 | return 1 | - = help: Add return type annotation: `float` +help: Add return type annotation: `float` ℹ Unsafe fix 6 6 | return 1.5 @@ -53,13 +56,14 @@ auto_return_type.py:9:5: ANN201 [*] Missing return type annotation for public fu 11 11 | return 1 12 12 | else: -auto_return_type.py:16:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:16:5 | 16 | def func(): - | ^^^^ ANN201 + | ^^^^ 17 | return True | - = help: Add return type annotation: `bool` +help: Add return type annotation: `bool` ℹ Unsafe fix 13 13 | return 1.5 @@ -71,14 +75,15 @@ auto_return_type.py:16:5: ANN201 [*] Missing return type annotation for public f 18 18 | 19 19 | -auto_return_type.py:20:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:20:5 | 20 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 21 | if x > 0: 22 | return None | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 17 17 | return True @@ -90,13 +95,14 @@ auto_return_type.py:20:5: ANN201 [*] Missing return type annotation for public f 22 22 | return None 23 23 | else: -auto_return_type.py:27:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:27:5 | 27 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 28 | return 1 or 2.5 if x > 0 else 1.5 or "str" | - = help: Add return type annotation: `Union[str, float]` +help: Add return type annotation: `Union[str, float]` ℹ Unsafe fix 1 |+from typing import Union @@ -113,13 +119,14 @@ auto_return_type.py:27:5: ANN201 [*] Missing return type annotation for public f 29 30 | 30 31 | -auto_return_type.py:31:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:31:5 | 31 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 32 | return 1 + 2.5 if x > 0 else 1.5 or "str" | - = help: Add return type annotation: `Union[str, float]` +help: Add return type annotation: `Union[str, float]` ℹ Unsafe fix 1 |+from typing import Union @@ -136,31 +143,34 @@ auto_return_type.py:31:5: ANN201 [*] Missing return type annotation for public f 33 34 | 34 35 | -auto_return_type.py:35:5: ANN201 Missing return type annotation for public function `func` +ANN201 Missing return type annotation for public function `func` + --> auto_return_type.py:35:5 | 35 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 36 | if not x: 37 | return None | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:41:5: ANN201 Missing return type annotation for public function `func` +ANN201 Missing return type annotation for public function `func` + --> auto_return_type.py:41:5 | 41 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 42 | return {"foo": 1} | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:45:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:45:5 | 45 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 46 | if not x: 47 | return 1 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 42 42 | return {"foo": 1} @@ -172,14 +182,15 @@ auto_return_type.py:45:5: ANN201 [*] Missing return type annotation for public f 47 47 | return 1 48 48 | else: -auto_return_type.py:52:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:52:5 | 52 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 53 | if not x: 54 | return 1 | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 1 |+from typing import Optional @@ -196,14 +207,15 @@ auto_return_type.py:52:5: ANN201 [*] Missing return type annotation for public f 54 55 | return 1 55 56 | else: -auto_return_type.py:59:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:59:5 | 59 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 60 | if not x: 61 | return 1 | - = help: Add return type annotation: `Union[str, int, None]` +help: Add return type annotation: `Union[str, int, None]` ℹ Unsafe fix 1 |+from typing import Union @@ -220,14 +232,15 @@ auto_return_type.py:59:5: ANN201 [*] Missing return type annotation for public f 61 62 | return 1 62 63 | elif x > 5: -auto_return_type.py:68:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:68:5 | 68 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 69 | if x: 70 | return 1 | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 1 |+from typing import Optional @@ -244,13 +257,14 @@ auto_return_type.py:68:5: ANN201 [*] Missing return type annotation for public f 70 71 | return 1 71 72 | -auto_return_type.py:73:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:73:5 | 73 | def func(): - | ^^^^ ANN201 + | ^^^^ 74 | x = 1 | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 70 70 | return 1 @@ -262,14 +276,15 @@ auto_return_type.py:73:5: ANN201 [*] Missing return type annotation for public f 75 75 | 76 76 | -auto_return_type.py:77:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:77:5 | 77 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 78 | if x > 0: 79 | return 1 | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 1 |+from typing import Optional @@ -286,14 +301,15 @@ auto_return_type.py:77:5: ANN201 [*] Missing return type annotation for public f 79 80 | return 1 80 81 | -auto_return_type.py:82:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:82:5 | 82 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 83 | match x: 84 | case [1, 2, 3]: | - = help: Add return type annotation: `Union[str, int, None]` +help: Add return type annotation: `Union[str, int, None]` ℹ Unsafe fix 1 |+from typing import Union @@ -310,14 +326,15 @@ auto_return_type.py:82:5: ANN201 [*] Missing return type annotation for public f 84 85 | case [1, 2, 3]: 85 86 | return 1 -auto_return_type.py:90:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:90:5 | 90 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 91 | for i in range(5): 92 | if i > 0: | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 1 |+from typing import Optional @@ -334,14 +351,15 @@ auto_return_type.py:90:5: ANN201 [*] Missing return type annotation for public f 92 93 | if i > 0: 93 94 | return 1 -auto_return_type.py:96:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:96:5 | 96 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 97 | for i in range(5): 98 | if i > 0: | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 93 93 | return 1 @@ -353,14 +371,15 @@ auto_return_type.py:96:5: ANN201 [*] Missing return type annotation for public f 98 98 | if i > 0: 99 99 | return 1 -auto_return_type.py:104:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:104:5 | 104 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 105 | for i in range(5): 106 | if i > 0: | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 1 |+from typing import Optional @@ -377,14 +396,15 @@ auto_return_type.py:104:5: ANN201 [*] Missing return type annotation for public 106 107 | if i > 0: 107 108 | break -auto_return_type.py:112:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:112:5 | 112 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 113 | try: 114 | pass | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 1 |+from typing import Optional @@ -401,14 +421,15 @@ auto_return_type.py:112:5: ANN201 [*] Missing return type annotation for public 114 115 | pass 115 116 | except: -auto_return_type.py:119:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:119:5 | 119 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 120 | try: 121 | pass | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 116 116 | return 1 @@ -420,14 +441,15 @@ auto_return_type.py:119:5: ANN201 [*] Missing return type annotation for public 121 121 | pass 122 122 | except: -auto_return_type.py:128:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:128:5 | 128 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 129 | try: 130 | pass | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 125 125 | return 2 @@ -439,14 +461,15 @@ auto_return_type.py:128:5: ANN201 [*] Missing return type annotation for public 130 130 | pass 131 131 | except: -auto_return_type.py:137:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:137:5 | 137 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 138 | try: 139 | return 1 | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 1 |+from typing import Optional @@ -463,14 +486,15 @@ auto_return_type.py:137:5: ANN201 [*] Missing return type annotation for public 139 140 | return 1 140 141 | except: -auto_return_type.py:146:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:146:5 | 146 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 147 | while x > 0: 148 | break | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 1 |+from typing import Optional @@ -487,63 +511,69 @@ auto_return_type.py:146:5: ANN201 [*] Missing return type annotation for public 148 149 | break 149 150 | return 1 -auto_return_type.py:158:9: ANN201 Missing return type annotation for public function `method` +ANN201 Missing return type annotation for public function `method` + --> auto_return_type.py:158:9 | 156 | class Foo(abc.ABC): 157 | @abstractmethod 158 | def method(self): - | ^^^^^^ ANN201 + | ^^^^^^ 159 | pass | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:162:9: ANN201 Missing return type annotation for public function `method` +ANN201 Missing return type annotation for public function `method` + --> auto_return_type.py:162:9 | 161 | @abc.abstractmethod 162 | def method(self): - | ^^^^^^ ANN201 + | ^^^^^^ 163 | """Docstring.""" | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:166:9: ANN201 Missing return type annotation for public function `method` +ANN201 Missing return type annotation for public function `method` + --> auto_return_type.py:166:9 | 165 | @abc.abstractmethod 166 | def method(self): - | ^^^^^^ ANN201 + | ^^^^^^ 167 | ... | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:171:9: ANN205 Missing return type annotation for staticmethod `method` +ANN205 Missing return type annotation for staticmethod `method` + --> auto_return_type.py:171:9 | 169 | @staticmethod 170 | @abstractmethod 171 | def method(): - | ^^^^^^ ANN205 + | ^^^^^^ 172 | pass | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:176:9: ANN206 Missing return type annotation for classmethod `method` +ANN206 Missing return type annotation for classmethod `method` + --> auto_return_type.py:176:9 | 174 | @classmethod 175 | @abstractmethod 176 | def method(cls): - | ^^^^^^ ANN206 + | ^^^^^^ 177 | pass | - = help: Add return type annotation +help: Add return type annotation -auto_return_type.py:180:9: ANN201 [*] Missing return type annotation for public function `method` +ANN201 [*] Missing return type annotation for public function `method` + --> auto_return_type.py:180:9 | 179 | @abstractmethod 180 | def method(self): - | ^^^^^^ ANN201 + | ^^^^^^ 181 | if self.x > 0: 182 | return 1 | - = help: Add return type annotation: `float` +help: Add return type annotation: `float` ℹ Unsafe fix 177 177 | pass @@ -555,14 +585,15 @@ auto_return_type.py:180:9: ANN201 [*] Missing return type annotation for public 182 182 | return 1 183 183 | else: -auto_return_type.py:187:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:187:5 | 187 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 188 | try: 189 | pass | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 151 151 | @@ -582,14 +613,15 @@ auto_return_type.py:187:5: ANN201 [*] Missing return type annotation for public 189 190 | pass 190 191 | except: -auto_return_type.py:194:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:194:5 | 194 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 195 | try: 196 | pass | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 191 191 | return 2 @@ -601,14 +633,15 @@ auto_return_type.py:194:5: ANN201 [*] Missing return type annotation for public 196 196 | pass 197 197 | except: -auto_return_type.py:203:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:203:5 | 203 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 204 | if not x: 205 | raise ValueError | - = help: Add return type annotation: `NoReturn` +help: Add return type annotation: `NoReturn` ℹ Unsafe fix 151 151 | @@ -628,14 +661,15 @@ auto_return_type.py:203:5: ANN201 [*] Missing return type annotation for public 205 206 | raise ValueError 206 207 | else: -auto_return_type.py:210:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:210:5 | 210 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 211 | if not x: 212 | raise ValueError | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 207 207 | raise TypeError @@ -647,14 +681,15 @@ auto_return_type.py:210:5: ANN201 [*] Missing return type annotation for public 212 212 | raise ValueError 213 213 | else: -auto_return_type.py:234:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:234:5 | 234 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 235 | if not x: 236 | return 1 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 231 231 | return i @@ -666,14 +701,15 @@ auto_return_type.py:234:5: ANN201 [*] Missing return type annotation for public 236 236 | return 1 237 237 | raise ValueError -auto_return_type.py:240:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:240:5 | 240 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 241 | if not x: 242 | return 1 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 237 237 | raise ValueError @@ -685,14 +721,15 @@ auto_return_type.py:240:5: ANN201 [*] Missing return type annotation for public 242 242 | return 1 243 243 | else: -auto_return_type.py:248:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:248:5 | 248 | def func(): - | ^^^^ ANN201 + | ^^^^ 249 | try: 250 | raise ValueError | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 214 214 | return 1 @@ -713,14 +750,15 @@ auto_return_type.py:248:5: ANN201 [*] Missing return type annotation for public 250 250 | raise ValueError 251 251 | except: -auto_return_type.py:255:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:255:5 | 255 | def func(): - | ^^^^ ANN201 + | ^^^^ 256 | try: 257 | return 1 | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 214 214 | return 1 @@ -741,14 +779,15 @@ auto_return_type.py:255:5: ANN201 [*] Missing return type annotation for public 257 257 | return 1 258 258 | except: -auto_return_type.py:262:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:262:5 | 262 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 263 | for _ in range(3): 264 | if x > 0: | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 259 259 | pass @@ -760,14 +799,15 @@ auto_return_type.py:262:5: ANN201 [*] Missing return type annotation for public 264 264 | if x > 0: 265 265 | return 1 -auto_return_type.py:269:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:269:5 | 269 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 270 | if x > 5: 271 | raise ValueError | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 266 266 | raise ValueError @@ -779,14 +819,15 @@ auto_return_type.py:269:5: ANN201 [*] Missing return type annotation for public 271 271 | raise ValueError 272 272 | else: -auto_return_type.py:276:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:276:5 | 276 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 277 | if x > 5: 278 | raise ValueError | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 273 273 | pass @@ -798,14 +839,15 @@ auto_return_type.py:276:5: ANN201 [*] Missing return type annotation for public 278 278 | raise ValueError 279 279 | elif x > 10: -auto_return_type.py:283:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:283:5 | 283 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 284 | if x > 5: 285 | raise ValueError | - = help: Add return type annotation: `Optional[int]` +help: Add return type annotation: `Optional[int]` ℹ Unsafe fix 214 214 | return 1 @@ -826,14 +868,15 @@ auto_return_type.py:283:5: ANN201 [*] Missing return type annotation for public 285 285 | raise ValueError 286 286 | elif x > 10: -auto_return_type.py:290:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:290:5 | 290 | def func(): - | ^^^^ ANN201 + | ^^^^ 291 | try: 292 | return 5 | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 287 287 | return 5 @@ -845,14 +888,15 @@ auto_return_type.py:290:5: ANN201 [*] Missing return type annotation for public 292 292 | return 5 293 293 | except: -auto_return_type.py:299:5: ANN201 [*] Missing return type annotation for public function `func` +ANN201 [*] Missing return type annotation for public function `func` + --> auto_return_type.py:299:5 | 299 | def func(x: int): - | ^^^^ ANN201 + | ^^^^ 300 | match x: 301 | case [1, 2, 3]: | - = help: Add return type annotation: `Union[str, int]` +help: Add return type annotation: `Union[str, int]` ℹ Unsafe fix 214 214 | return 1 diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap index d3837dec75..a9b1798e2e 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs --- -annotation_presence.py:5:5: ANN201 [*] Missing return type annotation for public function `foo` +ANN201 [*] Missing return type annotation for public function `foo` + --> annotation_presence.py:5:5 | 4 | # Error 5 | def foo(a, b): - | ^^^ ANN201 + | ^^^ 6 | pass | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 2 2 | from typing_extensions import override @@ -20,30 +21,33 @@ annotation_presence.py:5:5: ANN201 [*] Missing return type annotation for public 7 7 | 8 8 | -annotation_presence.py:5:9: ANN001 Missing type annotation for function argument `a` +ANN001 Missing type annotation for function argument `a` + --> annotation_presence.py:5:9 | 4 | # Error 5 | def foo(a, b): - | ^ ANN001 + | ^ 6 | pass | -annotation_presence.py:5:12: ANN001 Missing type annotation for function argument `b` +ANN001 Missing type annotation for function argument `b` + --> annotation_presence.py:5:12 | 4 | # Error 5 | def foo(a, b): - | ^ ANN001 + | ^ 6 | pass | -annotation_presence.py:10:5: ANN201 [*] Missing return type annotation for public function `foo` +ANN201 [*] Missing return type annotation for public function `foo` + --> annotation_presence.py:10:5 | 9 | # Error 10 | def foo(a: int, b): - | ^^^ ANN201 + | ^^^ 11 | pass | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 7 7 | @@ -55,30 +59,33 @@ annotation_presence.py:10:5: ANN201 [*] Missing return type annotation for publi 12 12 | 13 13 | -annotation_presence.py:10:17: ANN001 Missing type annotation for function argument `b` +ANN001 Missing type annotation for function argument `b` + --> annotation_presence.py:10:17 | 9 | # Error 10 | def foo(a: int, b): - | ^ ANN001 + | ^ 11 | pass | -annotation_presence.py:15:17: ANN001 Missing type annotation for function argument `b` +ANN001 Missing type annotation for function argument `b` + --> annotation_presence.py:15:17 | 14 | # Error 15 | def foo(a: int, b) -> int: - | ^ ANN001 + | ^ 16 | pass | -annotation_presence.py:20:5: ANN201 [*] Missing return type annotation for public function `foo` +ANN201 [*] Missing return type annotation for public function `foo` + --> annotation_presence.py:20:5 | 19 | # Error 20 | def foo(a: int, b: int): - | ^^^ ANN201 + | ^^^ 21 | pass | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 17 17 | @@ -90,14 +97,15 @@ annotation_presence.py:20:5: ANN201 [*] Missing return type annotation for publi 22 22 | 23 23 | -annotation_presence.py:25:5: ANN201 [*] Missing return type annotation for public function `foo` +ANN201 [*] Missing return type annotation for public function `foo` + --> annotation_presence.py:25:5 | 24 | # Error 25 | def foo(): - | ^^^ ANN201 + | ^^^ 26 | pass | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 22 22 | @@ -109,167 +117,186 @@ annotation_presence.py:25:5: ANN201 [*] Missing return type annotation for publi 27 27 | 28 28 | -annotation_presence.py:45:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> annotation_presence.py:45:12 | 44 | # ANN401 45 | def foo(a: Any, *args: str, **kwargs: str) -> int: - | ^^^ ANN401 + | ^^^ 46 | pass | -annotation_presence.py:50:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` + --> annotation_presence.py:50:47 | 49 | # ANN401 50 | def foo(a: int, *args: str, **kwargs: str) -> Any: - | ^^^ ANN401 + | ^^^ 51 | pass | -annotation_presence.py:55:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args` + --> annotation_presence.py:55:24 | 54 | # ANN401 55 | def foo(a: int, *args: Any, **kwargs: Any) -> int: - | ^^^ ANN401 + | ^^^ 56 | pass | -annotation_presence.py:55:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` + --> annotation_presence.py:55:39 | 54 | # ANN401 55 | def foo(a: int, *args: Any, **kwargs: Any) -> int: - | ^^^ ANN401 + | ^^^ 56 | pass | -annotation_presence.py:60:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args` + --> annotation_presence.py:60:24 | 59 | # ANN401 60 | def foo(a: int, *args: Any, **kwargs: str) -> int: - | ^^^ ANN401 + | ^^^ 61 | pass | -annotation_presence.py:65:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` + --> annotation_presence.py:65:39 | 64 | # ANN401 65 | def foo(a: int, *args: str, **kwargs: Any) -> int: - | ^^^ ANN401 + | ^^^ 66 | pass | -annotation_presence.py:79:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> annotation_presence.py:79:29 | 78 | # ANN401 79 | def foo(self: "Foo", a: Any, *params: str, **options: str) -> int: - | ^^^ ANN401 + | ^^^ 80 | pass | -annotation_presence.py:83:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` + --> annotation_presence.py:83:67 | 82 | # ANN401 83 | def foo(self: "Foo", a: int, *params: str, **options: str) -> Any: - | ^^^ ANN401 + | ^^^ 84 | pass | -annotation_presence.py:87:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params` + --> annotation_presence.py:87:43 | 86 | # ANN401 87 | def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int: - | ^^^ ANN401 + | ^^^ 88 | pass | -annotation_presence.py:87:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options` + --> annotation_presence.py:87:59 | 86 | # ANN401 87 | def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int: - | ^^^ ANN401 + | ^^^ 88 | pass | -annotation_presence.py:91:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params` + --> annotation_presence.py:91:43 | 90 | # ANN401 91 | def foo(self: "Foo", a: int, *params: Any, **options: str) -> int: - | ^^^ ANN401 + | ^^^ 92 | pass | -annotation_presence.py:95:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options` + --> annotation_presence.py:95:59 | 94 | # ANN401 95 | def foo(self: "Foo", a: int, *params: str, **options: Any) -> int: - | ^^^ ANN401 + | ^^^ 96 | pass | -annotation_presence.py:149:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> annotation_presence.py:149:10 | 148 | # ANN401 149 | def f(a: Any | int) -> None: ... - | ^^^^^^^^^ ANN401 + | ^^^^^^^^^ 150 | def f(a: int | Any) -> None: ... 151 | def f(a: Union[str, bytes, Any]) -> None: ... | -annotation_presence.py:150:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> annotation_presence.py:150:10 | 148 | # ANN401 149 | def f(a: Any | int) -> None: ... 150 | def f(a: int | Any) -> None: ... - | ^^^^^^^^^ ANN401 + | ^^^^^^^^^ 151 | def f(a: Union[str, bytes, Any]) -> None: ... 152 | def f(a: Optional[Any]) -> None: ... | -annotation_presence.py:151:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> annotation_presence.py:151:10 | 149 | def f(a: Any | int) -> None: ... 150 | def f(a: int | Any) -> None: ... 151 | def f(a: Union[str, bytes, Any]) -> None: ... - | ^^^^^^^^^^^^^^^^^^^^^^ ANN401 + | ^^^^^^^^^^^^^^^^^^^^^^ 152 | def f(a: Optional[Any]) -> None: ... 153 | def f(a: Annotated[Any, ...]) -> None: ... | -annotation_presence.py:152:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> annotation_presence.py:152:10 | 150 | def f(a: int | Any) -> None: ... 151 | def f(a: Union[str, bytes, Any]) -> None: ... 152 | def f(a: Optional[Any]) -> None: ... - | ^^^^^^^^^^^^^ ANN401 + | ^^^^^^^^^^^^^ 153 | def f(a: Annotated[Any, ...]) -> None: ... 154 | def f(a: "Union[str, bytes, Any]") -> None: ... | -annotation_presence.py:153:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> annotation_presence.py:153:10 | 151 | def f(a: Union[str, bytes, Any]) -> None: ... 152 | def f(a: Optional[Any]) -> None: ... 153 | def f(a: Annotated[Any, ...]) -> None: ... - | ^^^^^^^^^^^^^^^^^^^ ANN401 + | ^^^^^^^^^^^^^^^^^^^ 154 | def f(a: "Union[str, bytes, Any]") -> None: ... | -annotation_presence.py:154:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` +ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + --> annotation_presence.py:154:10 | 152 | def f(a: Optional[Any]) -> None: ... 153 | def f(a: Annotated[Any, ...]) -> None: ... 154 | def f(a: "Union[str, bytes, Any]") -> None: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^ ANN401 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -annotation_presence.py:159:9: ANN204 [*] Missing return type annotation for special method `__init__` +ANN204 [*] Missing return type annotation for special method `__init__` + --> annotation_presence.py:159:9 | 157 | class Foo: 158 | @decorator() 159 | def __init__(self: "Foo", foo: int): - | ^^^^^^^^ ANN204 + | ^^^^^^^^ 160 | ... | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 156 156 | @@ -281,15 +308,16 @@ annotation_presence.py:159:9: ANN204 [*] Missing return type annotation for spec 161 161 | 162 162 | -annotation_presence.py:165:9: ANN204 [*] Missing return type annotation for special method `__init__` +ANN204 [*] Missing return type annotation for special method `__init__` + --> annotation_presence.py:165:9 | 163 | # Regression test for: https://github.com/astral-sh/ruff/issues/7711 164 | class Class: 165 | def __init__(self): - | ^^^^^^^^ ANN204 + | ^^^^^^^^ 166 | print(f"{self.attr=}") | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 162 162 | diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap index 71e528ec5d..b6f926aa7a 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs --- -ignore_fully_untyped.py:24:5: ANN201 [*] Missing return type annotation for public function `error_partially_typed_1` +ANN201 [*] Missing return type annotation for public function `error_partially_typed_1` + --> ignore_fully_untyped.py:24:5 | 24 | def error_partially_typed_1(a: int, b): - | ^^^^^^^^^^^^^^^^^^^^^^^ ANN201 + | ^^^^^^^^^^^^^^^^^^^^^^^ 25 | pass | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 21 21 | pass @@ -19,27 +20,30 @@ ignore_fully_untyped.py:24:5: ANN201 [*] Missing return type annotation for publ 26 26 | 27 27 | -ignore_fully_untyped.py:24:37: ANN001 Missing type annotation for function argument `b` +ANN001 Missing type annotation for function argument `b` + --> ignore_fully_untyped.py:24:37 | 24 | def error_partially_typed_1(a: int, b): - | ^ ANN001 + | ^ 25 | pass | -ignore_fully_untyped.py:28:37: ANN001 Missing type annotation for function argument `b` +ANN001 Missing type annotation for function argument `b` + --> ignore_fully_untyped.py:28:37 | 28 | def error_partially_typed_2(a: int, b) -> int: - | ^ ANN001 + | ^ 29 | pass | -ignore_fully_untyped.py:32:5: ANN201 [*] Missing return type annotation for public function `error_partially_typed_3` +ANN201 [*] Missing return type annotation for public function `error_partially_typed_3` + --> ignore_fully_untyped.py:32:5 | 32 | def error_partially_typed_3(a: int, b: int): - | ^^^^^^^^^^^^^^^^^^^^^^^ ANN201 + | ^^^^^^^^^^^^^^^^^^^^^^^ 33 | pass | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 29 29 | pass @@ -51,15 +55,16 @@ ignore_fully_untyped.py:32:5: ANN201 [*] Missing return type annotation for publ 34 34 | 35 35 | -ignore_fully_untyped.py:43:9: ANN201 [*] Missing return type annotation for public function `error_typed_self` +ANN201 [*] Missing return type annotation for public function `error_typed_self` + --> ignore_fully_untyped.py:43:9 | 41 | pass 42 | 43 | def error_typed_self(self: X): - | ^^^^^^^^^^^^^^^^ ANN201 + | ^^^^^^^^^^^^^^^^ 44 | pass | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 40 40 | def ok_untyped_method(self): diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap index e6ea74c2d4..5a937ee087 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs -snapshot_kind: text --- -mypy_init_return.py:5:9: ANN204 [*] Missing return type annotation for special method `__init__` +ANN204 [*] Missing return type annotation for special method `__init__` + --> mypy_init_return.py:5:9 | 3 | # Error 4 | class Foo: 5 | def __init__(self): - | ^^^^^^^^ ANN204 + | ^^^^^^^^ 6 | ... | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 2 2 | @@ -22,15 +22,16 @@ mypy_init_return.py:5:9: ANN204 [*] Missing return type annotation for special m 7 7 | 8 8 | -mypy_init_return.py:11:9: ANN204 [*] Missing return type annotation for special method `__init__` +ANN204 [*] Missing return type annotation for special method `__init__` + --> mypy_init_return.py:11:9 | 9 | # Error 10 | class Foo: 11 | def __init__(self, foo): - | ^^^^^^^^ ANN204 + | ^^^^^^^^ 12 | ... | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 8 8 | @@ -42,14 +43,15 @@ mypy_init_return.py:11:9: ANN204 [*] Missing return type annotation for special 13 13 | 14 14 | -mypy_init_return.py:40:5: ANN202 [*] Missing return type annotation for private function `__init__` +ANN202 [*] Missing return type annotation for private function `__init__` + --> mypy_init_return.py:40:5 | 39 | # Error 40 | def __init__(self, foo: int): - | ^^^^^^^^ ANN202 + | ^^^^^^^^ 41 | ... | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 37 37 | @@ -61,15 +63,16 @@ mypy_init_return.py:40:5: ANN202 [*] Missing return type annotation for private 42 42 | 43 43 | -mypy_init_return.py:47:9: ANN204 [*] Missing return type annotation for special method `__init__` +ANN204 [*] Missing return type annotation for special method `__init__` + --> mypy_init_return.py:47:9 | 45 | # of a vararg falsely indicated that the function has a typed argument. 46 | class Foo: 47 | def __init__(self, *arg): - | ^^^^^^^^ ANN204 + | ^^^^^^^^ 48 | ... | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 44 44 | # Error – used to be ok for a moment since the mere presence diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap index bc8e91807b..b824397f1a 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs --- -simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for special method `__str__` +ANN204 [*] Missing return type annotation for special method `__str__` + --> simple_magic_methods.py:2:9 | 1 | class Foo: 2 | def __str__(self): - | ^^^^^^^ ANN204 + | ^^^^^^^ 3 | ... | - = help: Add return type annotation: `str` +help: Add return type annotation: `str` ℹ Unsafe fix 1 1 | class Foo: @@ -18,15 +19,16 @@ simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for speci 4 4 | 5 5 | def __repr__(self): -simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for special method `__repr__` +ANN204 [*] Missing return type annotation for special method `__repr__` + --> simple_magic_methods.py:5:9 | 3 | ... 4 | 5 | def __repr__(self): - | ^^^^^^^^ ANN204 + | ^^^^^^^^ 6 | ... | - = help: Add return type annotation: `str` +help: Add return type annotation: `str` ℹ Unsafe fix 2 2 | def __str__(self): @@ -38,15 +40,16 @@ simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for speci 7 7 | 8 8 | def __len__(self): -simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for special method `__len__` +ANN204 [*] Missing return type annotation for special method `__len__` + --> simple_magic_methods.py:8:9 | 6 | ... 7 | 8 | def __len__(self): - | ^^^^^^^ ANN204 + | ^^^^^^^ 9 | ... | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 5 5 | def __repr__(self): @@ -58,15 +61,16 @@ simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for speci 10 10 | 11 11 | def __length_hint__(self): -simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for special method `__length_hint__` +ANN204 [*] Missing return type annotation for special method `__length_hint__` + --> simple_magic_methods.py:11:9 | 9 | ... 10 | 11 | def __length_hint__(self): - | ^^^^^^^^^^^^^^^ ANN204 + | ^^^^^^^^^^^^^^^ 12 | ... | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 8 8 | def __len__(self): @@ -78,15 +82,16 @@ simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for spec 13 13 | 14 14 | def __init__(self): -simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for special method `__init__` +ANN204 [*] Missing return type annotation for special method `__init__` + --> simple_magic_methods.py:14:9 | 12 | ... 13 | 14 | def __init__(self): - | ^^^^^^^^ ANN204 + | ^^^^^^^^ 15 | ... | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 11 11 | def __length_hint__(self): @@ -98,15 +103,16 @@ simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for spec 16 16 | 17 17 | def __del__(self): -simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for special method `__del__` +ANN204 [*] Missing return type annotation for special method `__del__` + --> simple_magic_methods.py:17:9 | 15 | ... 16 | 17 | def __del__(self): - | ^^^^^^^ ANN204 + | ^^^^^^^ 18 | ... | - = help: Add return type annotation: `None` +help: Add return type annotation: `None` ℹ Unsafe fix 14 14 | def __init__(self): @@ -118,15 +124,16 @@ simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for spec 19 19 | 20 20 | def __bool__(self): -simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for special method `__bool__` +ANN204 [*] Missing return type annotation for special method `__bool__` + --> simple_magic_methods.py:20:9 | 18 | ... 19 | 20 | def __bool__(self): - | ^^^^^^^^ ANN204 + | ^^^^^^^^ 21 | ... | - = help: Add return type annotation: `bool` +help: Add return type annotation: `bool` ℹ Unsafe fix 17 17 | def __del__(self): @@ -138,15 +145,16 @@ simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for spec 22 22 | 23 23 | def __bytes__(self): -simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for special method `__bytes__` +ANN204 [*] Missing return type annotation for special method `__bytes__` + --> simple_magic_methods.py:23:9 | 21 | ... 22 | 23 | def __bytes__(self): - | ^^^^^^^^^ ANN204 + | ^^^^^^^^^ 24 | ... | - = help: Add return type annotation: `bytes` +help: Add return type annotation: `bytes` ℹ Unsafe fix 20 20 | def __bool__(self): @@ -158,15 +166,16 @@ simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for spec 25 25 | 26 26 | def __format__(self, format_spec): -simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for special method `__format__` +ANN204 [*] Missing return type annotation for special method `__format__` + --> simple_magic_methods.py:26:9 | 24 | ... 25 | 26 | def __format__(self, format_spec): - | ^^^^^^^^^^ ANN204 + | ^^^^^^^^^^ 27 | ... | - = help: Add return type annotation: `str` +help: Add return type annotation: `str` ℹ Unsafe fix 23 23 | def __bytes__(self): @@ -178,15 +187,16 @@ simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for spec 28 28 | 29 29 | def __contains__(self, item): -simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for special method `__contains__` +ANN204 [*] Missing return type annotation for special method `__contains__` + --> simple_magic_methods.py:29:9 | 27 | ... 28 | 29 | def __contains__(self, item): - | ^^^^^^^^^^^^ ANN204 + | ^^^^^^^^^^^^ 30 | ... | - = help: Add return type annotation: `bool` +help: Add return type annotation: `bool` ℹ Unsafe fix 26 26 | def __format__(self, format_spec): @@ -198,15 +208,16 @@ simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for spec 31 31 | 32 32 | def __complex__(self): -simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for special method `__complex__` +ANN204 [*] Missing return type annotation for special method `__complex__` + --> simple_magic_methods.py:32:9 | 30 | ... 31 | 32 | def __complex__(self): - | ^^^^^^^^^^^ ANN204 + | ^^^^^^^^^^^ 33 | ... | - = help: Add return type annotation: `complex` +help: Add return type annotation: `complex` ℹ Unsafe fix 29 29 | def __contains__(self, item): @@ -218,15 +229,16 @@ simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for spec 34 34 | 35 35 | def __int__(self): -simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for special method `__int__` +ANN204 [*] Missing return type annotation for special method `__int__` + --> simple_magic_methods.py:35:9 | 33 | ... 34 | 35 | def __int__(self): - | ^^^^^^^ ANN204 + | ^^^^^^^ 36 | ... | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 32 32 | def __complex__(self): @@ -238,15 +250,16 @@ simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for spec 37 37 | 38 38 | def __float__(self): -simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for special method `__float__` +ANN204 [*] Missing return type annotation for special method `__float__` + --> simple_magic_methods.py:38:9 | 36 | ... 37 | 38 | def __float__(self): - | ^^^^^^^^^ ANN204 + | ^^^^^^^^^ 39 | ... | - = help: Add return type annotation: `float` +help: Add return type annotation: `float` ℹ Unsafe fix 35 35 | def __int__(self): @@ -258,15 +271,16 @@ simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for spec 40 40 | 41 41 | def __index__(self): -simple_magic_methods.py:41:9: ANN204 [*] Missing return type annotation for special method `__index__` +ANN204 [*] Missing return type annotation for special method `__index__` + --> simple_magic_methods.py:41:9 | 39 | ... 40 | 41 | def __index__(self): - | ^^^^^^^^^ ANN204 + | ^^^^^^^^^ 42 | ... | - = help: Add return type annotation: `int` +help: Add return type annotation: `int` ℹ Unsafe fix 38 38 | def __float__(self): diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap index f4f793dbda..ee8a25dae0 100644 --- a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs -snapshot_kind: text --- -suppress_none_returning.py:45:5: ANN201 [*] Missing return type annotation for public function `foo` +ANN201 [*] Missing return type annotation for public function `foo` + --> suppress_none_returning.py:45:5 | 44 | # Error 45 | def foo(): - | ^^^ ANN201 + | ^^^ 46 | return True | - = help: Add return type annotation: `bool` +help: Add return type annotation: `bool` ℹ Unsafe fix 42 42 | @@ -21,15 +21,16 @@ suppress_none_returning.py:45:5: ANN201 [*] Missing return type annotation for p 47 47 | 48 48 | -suppress_none_returning.py:50:5: ANN201 [*] Missing return type annotation for public function `foo` +ANN201 [*] Missing return type annotation for public function `foo` + --> suppress_none_returning.py:50:5 | 49 | # Error 50 | def foo(): - | ^^^ ANN201 + | ^^^ 51 | a = 2 + 2 52 | if a == 4: | - = help: Add return type annotation: `bool | None` +help: Add return type annotation: `bool | None` ℹ Unsafe fix 47 47 | @@ -41,10 +42,11 @@ suppress_none_returning.py:50:5: ANN201 [*] Missing return type annotation for p 52 52 | if a == 4: 53 53 | return True -suppress_none_returning.py:59:9: ANN001 Missing type annotation for function argument `a` +ANN001 Missing type annotation for function argument `a` + --> suppress_none_returning.py:59:9 | 58 | # Error (on the argument, but not the return type) 59 | def foo(a): - | ^ ANN001 + | ^ 60 | a = 2 + 2 | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap index 2d3adc5b36..8f5fac5cbc 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap @@ -1,90 +1,101 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC100.py:8:5: ASYNC100 A `with trio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with trio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:8:5 | 7 | async def func(): 8 | / with trio.fail_after(): 9 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:18:5: ASYNC100 A `with trio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with trio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:18:5 | 17 | async def func(): 18 | / with trio.move_on_after(): 19 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:45:5: ASYNC100 A `with anyio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with anyio.move_on_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:45:5 | 44 | async def func(): 45 | / with anyio.move_on_after(delay=0.2): 46 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:50:5: ASYNC100 A `with anyio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with anyio.fail_after(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:50:5 | 49 | async def func(): 50 | / with anyio.fail_after(): 51 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:55:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:55:5 | 54 | async def func(): 55 | / with anyio.CancelScope(): 56 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:60:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:60:5 | 59 | async def func(): 60 | / with anyio.CancelScope(), nullcontext(): 61 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:65:5: ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with anyio.CancelScope(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:65:5 | 64 | async def func(): 65 | / with nullcontext(), anyio.CancelScope(): 66 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:70:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:70:5 | 69 | async def func(): 70 | / async with asyncio.timeout(delay=0.2): 71 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:75:5: ASYNC100 A `with asyncio.timeout_at(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with asyncio.timeout_at(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:75:5 | 74 | async def func(): 75 | / async with asyncio.timeout_at(when=0.2): 76 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:85:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:85:5 | 84 | async def func(): 85 | / async with asyncio.timeout(delay=0.2), asyncio.TaskGroup(), asyncio.timeout(delay=0.2): 86 | | ... - | |___________^ ASYNC100 + | |___________^ | -ASYNC100.py:95:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. +ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint. + --> ASYNC100.py:95:5 | 94 | async def func(): 95 | / async with asyncio.timeout(delay=0.2), asyncio.timeout(delay=0.2): 96 | | ... - | |___________^ ASYNC100 + | |___________^ | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap index 13b59fdecc..74bfb836ba 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC105_ASYNC105.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC105.py:30:5: ASYNC105 [*] Call to `trio.aclose_forcefully` is not immediately awaited +ASYNC105 [*] Call to `trio.aclose_forcefully` is not immediately awaited + --> ASYNC105.py:30:5 | 29 | # ASYNC105 30 | trio.aclose_forcefully(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | trio.open_file(foo) 32 | trio.open_ssl_over_tcp_listeners(foo, foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 27 27 | await trio.lowlevel.wait_writable(foo) @@ -21,16 +22,17 @@ ASYNC105.py:30:5: ASYNC105 [*] Call to `trio.aclose_forcefully` is not immediate 32 32 | trio.open_ssl_over_tcp_listeners(foo, foo) 33 33 | trio.open_ssl_over_tcp_stream(foo, foo) -ASYNC105.py:31:5: ASYNC105 [*] Call to `trio.open_file` is not immediately awaited +ASYNC105 [*] Call to `trio.open_file` is not immediately awaited + --> ASYNC105.py:31:5 | 29 | # ASYNC105 30 | trio.aclose_forcefully(foo) 31 | trio.open_file(foo) - | ^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^ 32 | trio.open_ssl_over_tcp_listeners(foo, foo) 33 | trio.open_ssl_over_tcp_stream(foo, foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 28 28 | @@ -42,16 +44,17 @@ ASYNC105.py:31:5: ASYNC105 [*] Call to `trio.open_file` is not immediately await 33 33 | trio.open_ssl_over_tcp_stream(foo, foo) 34 34 | trio.open_tcp_listeners(foo) -ASYNC105.py:32:5: ASYNC105 [*] Call to `trio.open_ssl_over_tcp_listeners` is not immediately awaited +ASYNC105 [*] Call to `trio.open_ssl_over_tcp_listeners` is not immediately awaited + --> ASYNC105.py:32:5 | 30 | trio.aclose_forcefully(foo) 31 | trio.open_file(foo) 32 | trio.open_ssl_over_tcp_listeners(foo, foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | trio.open_ssl_over_tcp_stream(foo, foo) 34 | trio.open_tcp_listeners(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 29 29 | # ASYNC105 @@ -63,16 +66,17 @@ ASYNC105.py:32:5: ASYNC105 [*] Call to `trio.open_ssl_over_tcp_listeners` is not 34 34 | trio.open_tcp_listeners(foo) 35 35 | trio.open_tcp_stream(foo, foo) -ASYNC105.py:33:5: ASYNC105 [*] Call to `trio.open_ssl_over_tcp_stream` is not immediately awaited +ASYNC105 [*] Call to `trio.open_ssl_over_tcp_stream` is not immediately awaited + --> ASYNC105.py:33:5 | 31 | trio.open_file(foo) 32 | trio.open_ssl_over_tcp_listeners(foo, foo) 33 | trio.open_ssl_over_tcp_stream(foo, foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | trio.open_tcp_listeners(foo) 35 | trio.open_tcp_stream(foo, foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 30 30 | trio.aclose_forcefully(foo) @@ -84,16 +88,17 @@ ASYNC105.py:33:5: ASYNC105 [*] Call to `trio.open_ssl_over_tcp_stream` is not im 35 35 | trio.open_tcp_stream(foo, foo) 36 36 | trio.open_unix_socket(foo) -ASYNC105.py:34:5: ASYNC105 [*] Call to `trio.open_tcp_listeners` is not immediately awaited +ASYNC105 [*] Call to `trio.open_tcp_listeners` is not immediately awaited + --> ASYNC105.py:34:5 | 32 | trio.open_ssl_over_tcp_listeners(foo, foo) 33 | trio.open_ssl_over_tcp_stream(foo, foo) 34 | trio.open_tcp_listeners(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | trio.open_tcp_stream(foo, foo) 36 | trio.open_unix_socket(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 31 31 | trio.open_file(foo) @@ -105,16 +110,17 @@ ASYNC105.py:34:5: ASYNC105 [*] Call to `trio.open_tcp_listeners` is not immediat 36 36 | trio.open_unix_socket(foo) 37 37 | trio.run_process(foo) -ASYNC105.py:35:5: ASYNC105 [*] Call to `trio.open_tcp_stream` is not immediately awaited +ASYNC105 [*] Call to `trio.open_tcp_stream` is not immediately awaited + --> ASYNC105.py:35:5 | 33 | trio.open_ssl_over_tcp_stream(foo, foo) 34 | trio.open_tcp_listeners(foo) 35 | trio.open_tcp_stream(foo, foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | trio.open_unix_socket(foo) 37 | trio.run_process(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 32 32 | trio.open_ssl_over_tcp_listeners(foo, foo) @@ -126,16 +132,17 @@ ASYNC105.py:35:5: ASYNC105 [*] Call to `trio.open_tcp_stream` is not immediately 37 37 | trio.run_process(foo) 38 38 | trio.serve_listeners(foo, foo) -ASYNC105.py:36:5: ASYNC105 [*] Call to `trio.open_unix_socket` is not immediately awaited +ASYNC105 [*] Call to `trio.open_unix_socket` is not immediately awaited + --> ASYNC105.py:36:5 | 34 | trio.open_tcp_listeners(foo) 35 | trio.open_tcp_stream(foo, foo) 36 | trio.open_unix_socket(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | trio.run_process(foo) 38 | trio.serve_listeners(foo, foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 33 33 | trio.open_ssl_over_tcp_stream(foo, foo) @@ -147,16 +154,17 @@ ASYNC105.py:36:5: ASYNC105 [*] Call to `trio.open_unix_socket` is not immediatel 38 38 | trio.serve_listeners(foo, foo) 39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) -ASYNC105.py:37:5: ASYNC105 [*] Call to `trio.run_process` is not immediately awaited +ASYNC105 [*] Call to `trio.run_process` is not immediately awaited + --> ASYNC105.py:37:5 | 35 | trio.open_tcp_stream(foo, foo) 36 | trio.open_unix_socket(foo) 37 | trio.run_process(foo) - | ^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^ 38 | trio.serve_listeners(foo, foo) 39 | trio.serve_ssl_over_tcp(foo, foo, foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 34 34 | trio.open_tcp_listeners(foo) @@ -168,16 +176,17 @@ ASYNC105.py:37:5: ASYNC105 [*] Call to `trio.run_process` is not immediately awa 39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) 40 40 | trio.serve_tcp(foo, foo) -ASYNC105.py:38:5: ASYNC105 [*] Call to `trio.serve_listeners` is not immediately awaited +ASYNC105 [*] Call to `trio.serve_listeners` is not immediately awaited + --> ASYNC105.py:38:5 | 36 | trio.open_unix_socket(foo) 37 | trio.run_process(foo) 38 | trio.serve_listeners(foo, foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | trio.serve_ssl_over_tcp(foo, foo, foo) 40 | trio.serve_tcp(foo, foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 35 35 | trio.open_tcp_stream(foo, foo) @@ -189,16 +198,17 @@ ASYNC105.py:38:5: ASYNC105 [*] Call to `trio.serve_listeners` is not immediately 40 40 | trio.serve_tcp(foo, foo) 41 41 | trio.sleep(foo) -ASYNC105.py:39:5: ASYNC105 [*] Call to `trio.serve_ssl_over_tcp` is not immediately awaited +ASYNC105 [*] Call to `trio.serve_ssl_over_tcp` is not immediately awaited + --> ASYNC105.py:39:5 | 37 | trio.run_process(foo) 38 | trio.serve_listeners(foo, foo) 39 | trio.serve_ssl_over_tcp(foo, foo, foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | trio.serve_tcp(foo, foo) 41 | trio.sleep(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 36 36 | trio.open_unix_socket(foo) @@ -210,16 +220,17 @@ ASYNC105.py:39:5: ASYNC105 [*] Call to `trio.serve_ssl_over_tcp` is not immediat 41 41 | trio.sleep(foo) 42 42 | trio.sleep_forever() -ASYNC105.py:40:5: ASYNC105 [*] Call to `trio.serve_tcp` is not immediately awaited +ASYNC105 [*] Call to `trio.serve_tcp` is not immediately awaited + --> ASYNC105.py:40:5 | 38 | trio.serve_listeners(foo, foo) 39 | trio.serve_ssl_over_tcp(foo, foo, foo) 40 | trio.serve_tcp(foo, foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 41 | trio.sleep(foo) 42 | trio.sleep_forever() | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 37 37 | trio.run_process(foo) @@ -231,16 +242,17 @@ ASYNC105.py:40:5: ASYNC105 [*] Call to `trio.serve_tcp` is not immediately await 42 42 | trio.sleep_forever() 43 43 | trio.sleep_until(foo) -ASYNC105.py:41:5: ASYNC105 [*] Call to `trio.sleep` is not immediately awaited +ASYNC105 [*] Call to `trio.sleep` is not immediately awaited + --> ASYNC105.py:41:5 | 39 | trio.serve_ssl_over_tcp(foo, foo, foo) 40 | trio.serve_tcp(foo, foo) 41 | trio.sleep(foo) - | ^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^ 42 | trio.sleep_forever() 43 | trio.sleep_until(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 38 38 | trio.serve_listeners(foo, foo) @@ -252,16 +264,17 @@ ASYNC105.py:41:5: ASYNC105 [*] Call to `trio.sleep` is not immediately awaited 43 43 | trio.sleep_until(foo) 44 44 | trio.lowlevel.cancel_shielded_checkpoint() -ASYNC105.py:42:5: ASYNC105 [*] Call to `trio.sleep_forever` is not immediately awaited +ASYNC105 [*] Call to `trio.sleep_forever` is not immediately awaited + --> ASYNC105.py:42:5 | 40 | trio.serve_tcp(foo, foo) 41 | trio.sleep(foo) 42 | trio.sleep_forever() - | ^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^ 43 | trio.sleep_until(foo) 44 | trio.lowlevel.cancel_shielded_checkpoint() | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 39 39 | trio.serve_ssl_over_tcp(foo, foo, foo) @@ -273,16 +286,17 @@ ASYNC105.py:42:5: ASYNC105 [*] Call to `trio.sleep_forever` is not immediately a 44 44 | trio.lowlevel.cancel_shielded_checkpoint() 45 45 | trio.lowlevel.checkpoint() -ASYNC105.py:44:5: ASYNC105 [*] Call to `trio.lowlevel.cancel_shielded_checkpoint` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.cancel_shielded_checkpoint` is not immediately awaited + --> ASYNC105.py:44:5 | 42 | trio.sleep_forever() 43 | trio.sleep_until(foo) 44 | trio.lowlevel.cancel_shielded_checkpoint() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | trio.lowlevel.checkpoint() 46 | trio.lowlevel.checkpoint_if_cancelled() | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 41 41 | trio.sleep(foo) @@ -294,16 +308,17 @@ ASYNC105.py:44:5: ASYNC105 [*] Call to `trio.lowlevel.cancel_shielded_checkpoint 46 46 | trio.lowlevel.checkpoint_if_cancelled() 47 47 | trio.lowlevel.open_process() -ASYNC105.py:45:5: ASYNC105 [*] Call to `trio.lowlevel.checkpoint` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.checkpoint` is not immediately awaited + --> ASYNC105.py:45:5 | 43 | trio.sleep_until(foo) 44 | trio.lowlevel.cancel_shielded_checkpoint() 45 | trio.lowlevel.checkpoint() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | trio.lowlevel.checkpoint_if_cancelled() 47 | trio.lowlevel.open_process() | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 42 42 | trio.sleep_forever() @@ -315,16 +330,17 @@ ASYNC105.py:45:5: ASYNC105 [*] Call to `trio.lowlevel.checkpoint` is not immedia 47 47 | trio.lowlevel.open_process() 48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) -ASYNC105.py:46:5: ASYNC105 [*] Call to `trio.lowlevel.checkpoint_if_cancelled` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.checkpoint_if_cancelled` is not immediately awaited + --> ASYNC105.py:46:5 | 44 | trio.lowlevel.cancel_shielded_checkpoint() 45 | trio.lowlevel.checkpoint() 46 | trio.lowlevel.checkpoint_if_cancelled() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | trio.lowlevel.open_process() 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 43 43 | trio.sleep_until(foo) @@ -336,16 +352,17 @@ ASYNC105.py:46:5: ASYNC105 [*] Call to `trio.lowlevel.checkpoint_if_cancelled` i 48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) 49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) -ASYNC105.py:47:5: ASYNC105 [*] Call to `trio.lowlevel.open_process` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.open_process` is not immediately awaited + --> ASYNC105.py:47:5 | 45 | trio.lowlevel.checkpoint() 46 | trio.lowlevel.checkpoint_if_cancelled() 47 | trio.lowlevel.open_process() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 44 44 | trio.lowlevel.cancel_shielded_checkpoint() @@ -357,16 +374,17 @@ ASYNC105.py:47:5: ASYNC105 [*] Call to `trio.lowlevel.open_process` is not immed 49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) 50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) -ASYNC105.py:48:5: ASYNC105 [*] Call to `trio.lowlevel.permanently_detach_coroutine_object` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.permanently_detach_coroutine_object` is not immediately awaited + --> ASYNC105.py:48:5 | 46 | trio.lowlevel.checkpoint_if_cancelled() 47 | trio.lowlevel.open_process() 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 45 45 | trio.lowlevel.checkpoint() @@ -378,16 +396,17 @@ ASYNC105.py:48:5: ASYNC105 [*] Call to `trio.lowlevel.permanently_detach_corouti 50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) 51 51 | trio.lowlevel.wait_readable(foo) -ASYNC105.py:49:5: ASYNC105 [*] Call to `trio.lowlevel.reattach_detached_coroutine_object` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.reattach_detached_coroutine_object` is not immediately awaited + --> ASYNC105.py:49:5 | 47 | trio.lowlevel.open_process() 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) 51 | trio.lowlevel.wait_readable(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 46 46 | trio.lowlevel.checkpoint_if_cancelled() @@ -399,16 +418,17 @@ ASYNC105.py:49:5: ASYNC105 [*] Call to `trio.lowlevel.reattach_detached_coroutin 51 51 | trio.lowlevel.wait_readable(foo) 52 52 | trio.lowlevel.wait_task_rescheduled(foo) -ASYNC105.py:50:5: ASYNC105 [*] Call to `trio.lowlevel.temporarily_detach_coroutine_object` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.temporarily_detach_coroutine_object` is not immediately awaited + --> ASYNC105.py:50:5 | 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 51 | trio.lowlevel.wait_readable(foo) 52 | trio.lowlevel.wait_task_rescheduled(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 47 47 | trio.lowlevel.open_process() @@ -420,16 +440,17 @@ ASYNC105.py:50:5: ASYNC105 [*] Call to `trio.lowlevel.temporarily_detach_corouti 52 52 | trio.lowlevel.wait_task_rescheduled(foo) 53 53 | trio.lowlevel.wait_writable(foo) -ASYNC105.py:51:5: ASYNC105 [*] Call to `trio.lowlevel.wait_readable` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.wait_readable` is not immediately awaited + --> ASYNC105.py:51:5 | 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) 51 | trio.lowlevel.wait_readable(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | trio.lowlevel.wait_task_rescheduled(foo) 53 | trio.lowlevel.wait_writable(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 48 48 | trio.lowlevel.permanently_detach_coroutine_object(foo) @@ -441,15 +462,16 @@ ASYNC105.py:51:5: ASYNC105 [*] Call to `trio.lowlevel.wait_readable` is not imme 53 53 | trio.lowlevel.wait_writable(foo) 54 54 | -ASYNC105.py:52:5: ASYNC105 [*] Call to `trio.lowlevel.wait_task_rescheduled` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.wait_task_rescheduled` is not immediately awaited + --> ASYNC105.py:52:5 | 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) 51 | trio.lowlevel.wait_readable(foo) 52 | trio.lowlevel.wait_task_rescheduled(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 53 | trio.lowlevel.wait_writable(foo) | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 49 49 | trio.lowlevel.reattach_detached_coroutine_object(foo, foo) @@ -461,16 +483,17 @@ ASYNC105.py:52:5: ASYNC105 [*] Call to `trio.lowlevel.wait_task_rescheduled` is 54 54 | 55 55 | async with await trio.open_file(foo): # Ok -ASYNC105.py:53:5: ASYNC105 [*] Call to `trio.lowlevel.wait_writable` is not immediately awaited +ASYNC105 [*] Call to `trio.lowlevel.wait_writable` is not immediately awaited + --> ASYNC105.py:53:5 | 51 | trio.lowlevel.wait_readable(foo) 52 | trio.lowlevel.wait_task_rescheduled(foo) 53 | trio.lowlevel.wait_writable(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | 55 | async with await trio.open_file(foo): # Ok | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 50 50 | trio.lowlevel.temporarily_detach_coroutine_object(foo) @@ -482,15 +505,16 @@ ASYNC105.py:53:5: ASYNC105 [*] Call to `trio.lowlevel.wait_writable` is not imme 55 55 | async with await trio.open_file(foo): # Ok 56 56 | pass -ASYNC105.py:58:16: ASYNC105 [*] Call to `trio.open_file` is not immediately awaited +ASYNC105 [*] Call to `trio.open_file` is not immediately awaited + --> ASYNC105.py:58:16 | 56 | pass 57 | 58 | async with trio.open_file(foo): # ASYNC105 - | ^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^ 59 | pass | - = help: Add `await` +help: Add `await` ℹ Unsafe fix 55 55 | async with await trio.open_file(foo): # Ok @@ -502,11 +526,12 @@ ASYNC105.py:58:16: ASYNC105 [*] Call to `trio.open_file` is not immediately awai 60 60 | 61 61 | -ASYNC105.py:64:5: ASYNC105 Call to `trio.open_file` is not immediately awaited +ASYNC105 Call to `trio.open_file` is not immediately awaited + --> ASYNC105.py:64:5 | 62 | def func() -> None: 63 | # ASYNC105 (without fix) 64 | trio.open_file(foo) - | ^^^^^^^^^^^^^^^^^^^ ASYNC105 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Add `await` +help: Add `await` diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_0.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_0.py.snap index af1607c156..e1332cc3fb 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_0.py.snap @@ -1,19 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- -ASYNC109_0.py:8:16: ASYNC109 Async function definition with a `timeout` parameter +ASYNC109 Async function definition with a `timeout` parameter + --> ASYNC109_0.py:8:16 | 8 | async def func(timeout): - | ^^^^^^^ ASYNC109 + | ^^^^^^^ 9 | ... | - = help: Use `trio.fail_after` instead +help: Use `trio.fail_after` instead -ASYNC109_0.py:12:16: ASYNC109 Async function definition with a `timeout` parameter +ASYNC109 Async function definition with a `timeout` parameter + --> ASYNC109_0.py:12:16 | 12 | async def func(timeout=10): - | ^^^^^^^^^^ ASYNC109 + | ^^^^^^^^^^ 13 | ... | - = help: Use `trio.fail_after` instead +help: Use `trio.fail_after` instead diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_0.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_0.py.snap index af1607c156..e1332cc3fb 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_0.py.snap @@ -1,19 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- -ASYNC109_0.py:8:16: ASYNC109 Async function definition with a `timeout` parameter +ASYNC109 Async function definition with a `timeout` parameter + --> ASYNC109_0.py:8:16 | 8 | async def func(timeout): - | ^^^^^^^ ASYNC109 + | ^^^^^^^ 9 | ... | - = help: Use `trio.fail_after` instead +help: Use `trio.fail_after` instead -ASYNC109_0.py:12:16: ASYNC109 Async function definition with a `timeout` parameter +ASYNC109 Async function definition with a `timeout` parameter + --> ASYNC109_0.py:12:16 | 12 | async def func(timeout=10): - | ^^^^^^^^^^ ASYNC109 + | ^^^^^^^^^^ 13 | ... | - = help: Use `trio.fail_after` instead +help: Use `trio.fail_after` instead diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_1.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_1.py.snap index 6936d2e811..0d221a3994 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC109_ASYNC109_1.py.snap @@ -1,19 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- -ASYNC109_1.py:5:16: ASYNC109 Async function definition with a `timeout` parameter +ASYNC109 Async function definition with a `timeout` parameter + --> ASYNC109_1.py:5:16 | 5 | async def func(timeout): - | ^^^^^^^ ASYNC109 + | ^^^^^^^ 6 | ... | - = help: Use `asyncio.timeout` instead +help: Use `asyncio.timeout` instead -ASYNC109_1.py:9:16: ASYNC109 Async function definition with a `timeout` parameter +ASYNC109 Async function definition with a `timeout` parameter + --> ASYNC109_1.py:9:16 | 9 | async def func(timeout=10): - | ^^^^^^^^^^ ASYNC109 + | ^^^^^^^^^^ 10 | ... | - = help: Use `asyncio.timeout` instead +help: Use `asyncio.timeout` instead diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC110_ASYNC110.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC110_ASYNC110.py.snap index 13439f5582..97f6df299d 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC110_ASYNC110.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC110_ASYNC110.py.snap @@ -1,42 +1,47 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC110.py:7:5: ASYNC110 Use `trio.Event` instead of awaiting `trio.sleep` in a `while` loop +ASYNC110 Use `trio.Event` instead of awaiting `trio.sleep` in a `while` loop + --> ASYNC110.py:7:5 | 6 | async def func(): 7 | / while True: 8 | | await trio.sleep(10) - | |____________________________^ ASYNC110 + | |____________________________^ | -ASYNC110.py:12:5: ASYNC110 Use `trio.Event` instead of awaiting `trio.sleep` in a `while` loop +ASYNC110 Use `trio.Event` instead of awaiting `trio.sleep` in a `while` loop + --> ASYNC110.py:12:5 | 11 | async def func(): 12 | / while True: 13 | | await trio.sleep_until(10) - | |__________________________________^ ASYNC110 + | |__________________________________^ | -ASYNC110.py:22:5: ASYNC110 Use `anyio.Event` instead of awaiting `anyio.sleep` in a `while` loop +ASYNC110 Use `anyio.Event` instead of awaiting `anyio.sleep` in a `while` loop + --> ASYNC110.py:22:5 | 21 | async def func(): 22 | / while True: 23 | | await anyio.sleep(10) - | |_____________________________^ ASYNC110 + | |_____________________________^ | -ASYNC110.py:27:5: ASYNC110 Use `anyio.Event` instead of awaiting `anyio.sleep` in a `while` loop +ASYNC110 Use `anyio.Event` instead of awaiting `anyio.sleep` in a `while` loop + --> ASYNC110.py:27:5 | 26 | async def func(): 27 | / while True: 28 | | await anyio.sleep_until(10) - | |___________________________________^ ASYNC110 + | |___________________________________^ | -ASYNC110.py:37:5: ASYNC110 Use `asyncio.Event` instead of awaiting `asyncio.sleep` in a `while` loop +ASYNC110 Use `asyncio.Event` instead of awaiting `asyncio.sleep` in a `while` loop + --> ASYNC110.py:37:5 | 36 | async def func(): 37 | / while True: 38 | | await asyncio.sleep(10) - | |_______________________________^ ASYNC110 + | |_______________________________^ | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap index 18c6ea8dac..89ff8a9eaf 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC115_ASYNC115.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC115.py:5:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` + --> ASYNC115.py:5:11 | 3 | from trio import sleep 4 | 5 | await trio.sleep(0) # ASYNC115 - | ^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^ 6 | await trio.sleep(1) # OK 7 | await trio.sleep(0, 1) # OK | - = help: Replace with `trio.lowlevel.checkpoint()` +help: Replace with `trio.lowlevel.checkpoint()` ℹ Safe fix 2 2 | import trio @@ -22,16 +23,17 @@ ASYNC115.py:5:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio 7 7 | await trio.sleep(0, 1) # OK 8 8 | await trio.sleep(...) # OK -ASYNC115.py:11:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` + --> ASYNC115.py:11:5 | 9 | await trio.sleep() # OK 10 | 11 | trio.sleep(0) # ASYNC115 - | ^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^ 12 | foo = 0 13 | trio.sleep(foo) # OK | - = help: Replace with `trio.lowlevel.checkpoint()` +help: Replace with `trio.lowlevel.checkpoint()` ℹ Safe fix 8 8 | await trio.sleep(...) # OK @@ -43,16 +45,17 @@ ASYNC115.py:11:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio 13 13 | trio.sleep(foo) # OK 14 14 | trio.sleep(1) # OK -ASYNC115.py:17:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` + --> ASYNC115.py:17:5 | 15 | time.sleep(0) # OK 16 | 17 | sleep(0) # ASYNC115 - | ^^^^^^^^ ASYNC115 + | ^^^^^^^^ 18 | 19 | bar = "bar" | - = help: Replace with `trio.lowlevel.checkpoint()` +help: Replace with `trio.lowlevel.checkpoint()` ℹ Safe fix 14 14 | trio.sleep(1) # OK @@ -64,14 +67,15 @@ ASYNC115.py:17:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio 19 19 | bar = "bar" 20 20 | trio.sleep(bar) -ASYNC115.py:48:14: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` + --> ASYNC115.py:48:14 | 46 | import trio 47 | 48 | trio.run(trio.sleep(0)) # ASYNC115 - | ^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^ | - = help: Replace with `trio.lowlevel.checkpoint()` +help: Replace with `trio.lowlevel.checkpoint()` ℹ Safe fix 45 45 | def func(): @@ -83,13 +87,14 @@ ASYNC115.py:48:14: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `tri 50 50 | 51 51 | from trio import Event, sleep -ASYNC115.py:55:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` + --> ASYNC115.py:55:5 | 54 | def func(): 55 | sleep(0) # ASYNC115 - | ^^^^^^^^ ASYNC115 + | ^^^^^^^^ | - = help: Replace with `trio.lowlevel.checkpoint()` +help: Replace with `trio.lowlevel.checkpoint()` ℹ Safe fix 48 48 | trio.run(trio.sleep(0)) # ASYNC115 @@ -106,13 +111,14 @@ ASYNC115.py:55:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio 57 57 | 58 58 | async def func(): -ASYNC115.py:59:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` + --> ASYNC115.py:59:11 | 58 | async def func(): 59 | await sleep(seconds=0) # ASYNC115 - | ^^^^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^^^^ | - = help: Replace with `trio.lowlevel.checkpoint()` +help: Replace with `trio.lowlevel.checkpoint()` ℹ Safe fix 48 48 | trio.run(trio.sleep(0)) # ASYNC115 @@ -133,16 +139,17 @@ ASYNC115.py:59:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `tri 61 61 | 62 62 | def func(): -ASYNC115.py:85:11: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` +ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` + --> ASYNC115.py:85:11 | 83 | from anyio import sleep 84 | 85 | await anyio.sleep(0) # ASYNC115 - | ^^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^^ 86 | await anyio.sleep(1) # OK 87 | await anyio.sleep(0, 1) # OK | - = help: Replace with `anyio.lowlevel.checkpoint()` +help: Replace with `anyio.lowlevel.checkpoint()` ℹ Safe fix 82 82 | import anyio @@ -154,16 +161,17 @@ ASYNC115.py:85:11: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `an 87 87 | await anyio.sleep(0, 1) # OK 88 88 | await anyio.sleep(...) # OK -ASYNC115.py:91:5: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` +ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` + --> ASYNC115.py:91:5 | 89 | await anyio.sleep() # OK 90 | 91 | anyio.sleep(0) # ASYNC115 - | ^^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^^ 92 | foo = 0 93 | anyio.sleep(foo) # OK | - = help: Replace with `anyio.lowlevel.checkpoint()` +help: Replace with `anyio.lowlevel.checkpoint()` ℹ Safe fix 88 88 | await anyio.sleep(...) # OK @@ -175,16 +183,17 @@ ASYNC115.py:91:5: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `any 93 93 | anyio.sleep(foo) # OK 94 94 | anyio.sleep(1) # OK -ASYNC115.py:97:5: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` +ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` + --> ASYNC115.py:97:5 | 95 | time.sleep(0) # OK 96 | 97 | sleep(0) # ASYNC115 - | ^^^^^^^^ ASYNC115 + | ^^^^^^^^ 98 | 99 | bar = "bar" | - = help: Replace with `anyio.lowlevel.checkpoint()` +help: Replace with `anyio.lowlevel.checkpoint()` ℹ Safe fix 94 94 | anyio.sleep(1) # OK @@ -196,14 +205,15 @@ ASYNC115.py:97:5: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `any 99 99 | bar = "bar" 100 100 | anyio.sleep(bar) -ASYNC115.py:128:15: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` +ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` + --> ASYNC115.py:128:15 | 126 | import anyio 127 | 128 | anyio.run(anyio.sleep(0)) # ASYNC115 - | ^^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^^ | - = help: Replace with `anyio.lowlevel.checkpoint()` +help: Replace with `anyio.lowlevel.checkpoint()` ℹ Safe fix 125 125 | def func(): @@ -215,15 +225,16 @@ ASYNC115.py:128:15: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `a 130 130 | 131 131 | def func(): -ASYNC115.py:156:11: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` +ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)` + --> ASYNC115.py:156:11 | 154 | await anyio.sleep(seconds=1) # OK 155 | 156 | await anyio.sleep(delay=0) # ASYNC115 - | ^^^^^^^^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^^^^^^^^ 157 | await anyio.sleep(seconds=0) # OK | - = help: Replace with `anyio.lowlevel.checkpoint()` +help: Replace with `anyio.lowlevel.checkpoint()` ℹ Safe fix 153 153 | await anyio.sleep(delay=1) # OK @@ -235,15 +246,16 @@ ASYNC115.py:156:11: ASYNC115 [*] Use `anyio.lowlevel.checkpoint()` instead of `a 158 158 | 159 159 | -ASYNC115.py:166:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` + --> ASYNC115.py:166:11 | 164 | await trio.sleep(delay=1) # OK 165 | 166 | await trio.sleep(seconds=0) # ASYNC115 - | ^^^^^^^^^^^^^^^^^^^^^ ASYNC115 + | ^^^^^^^^^^^^^^^^^^^^^ 167 | await trio.sleep(delay=0) # OK | - = help: Replace with `trio.lowlevel.checkpoint()` +help: Replace with `trio.lowlevel.checkpoint()` ℹ Safe fix 163 163 | await trio.sleep(seconds=1) # OK @@ -255,17 +267,18 @@ ASYNC115.py:166:11: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `tr 168 168 | 169 169 | # https://github.com/astral-sh/ruff/issues/18740 -ASYNC115.py:175:5: ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +ASYNC115 [*] Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` + --> ASYNC115.py:175:5 | 174 | await ( 175 | / trio # comment 176 | | .sleep( # comment 177 | | 0 # comment 178 | | ) - | |_____^ ASYNC115 + | |_____^ 179 | ) | - = help: Replace with `trio.lowlevel.checkpoint()` +help: Replace with `trio.lowlevel.checkpoint()` ℹ Unsafe fix 172 172 | import trio diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap index 1e04f8065a..12e4d43158 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC116_ASYNC116.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC116.py:11:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:11:11 | 10 | # These examples are probably not meant to ever wake up: 11 | await trio.sleep(100000) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^ 12 | 13 | # 'inf literal' overflow trick | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 8 8 | import trio @@ -21,15 +22,16 @@ ASYNC116.py:11:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu 13 13 | # 'inf literal' overflow trick 14 14 | await trio.sleep(1e999) # error: 116, "async" -ASYNC116.py:14:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:14:11 | 13 | # 'inf literal' overflow trick 14 | await trio.sleep(1e999) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^ 15 | 16 | await trio.sleep(86399) | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 11 11 | await trio.sleep(100000) # error: 116, "async" @@ -41,15 +43,16 @@ ASYNC116.py:14:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu 16 16 | await trio.sleep(86399) 17 17 | await trio.sleep(86400) -ASYNC116.py:18:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:18:11 | 16 | await trio.sleep(86399) 17 | await trio.sleep(86400) 18 | await trio.sleep(86400.01) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^^^ 19 | await trio.sleep(86401) # error: 116, "async" | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 15 15 | @@ -61,16 +64,17 @@ ASYNC116.py:18:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu 20 20 | 21 21 | await trio.sleep(-1) # will raise a runtime error -ASYNC116.py:19:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:19:11 | 17 | await trio.sleep(86400) 18 | await trio.sleep(86400.01) # error: 116, "async" 19 | await trio.sleep(86401) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^ 20 | 21 | await trio.sleep(-1) # will raise a runtime error | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 16 16 | await trio.sleep(86399) @@ -82,15 +86,16 @@ ASYNC116.py:19:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu 21 21 | await trio.sleep(-1) # will raise a runtime error 22 22 | await trio.sleep(0) # handled by different check -ASYNC116.py:48:5: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:48:5 | 47 | # does not require the call to be awaited, nor in an async fun 48 | trio.sleep(86401) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^ 49 | # also checks that we don't break visit_Call 50 | trio.run(trio.sleep(86401)) # error: 116, "async" | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 45 45 | import trio @@ -102,14 +107,15 @@ ASYNC116.py:48:5: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usua 50 50 | trio.run(trio.sleep(86401)) # error: 116, "async" 51 51 | -ASYNC116.py:50:14: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:50:14 | 48 | trio.sleep(86401) # error: 116, "async" 49 | # also checks that we don't break visit_Call 50 | trio.run(trio.sleep(86401)) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^ | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 47 47 | # does not require the call to be awaited, nor in an async fun @@ -121,13 +127,14 @@ ASYNC116.py:50:14: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu 52 52 | 53 53 | async def import_from_trio(): -ASYNC116.py:57:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:57:11 | 56 | # catch from import 57 | await sleep(86401) # error: 116, "async" - | ^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^ | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. @@ -147,15 +154,16 @@ ASYNC116.py:57:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usu 59 60 | 60 61 | async def import_anyio(): -ASYNC116.py:64:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` +ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` + --> ASYNC116.py:64:11 | 63 | # These examples are probably not meant to ever wake up: 64 | await anyio.sleep(100000) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^^ 65 | 66 | # 'inf literal' overflow trick | - = help: Replace with `anyio.sleep_forever()` +help: Replace with `anyio.sleep_forever()` ℹ Unsafe fix 61 61 | import anyio @@ -167,15 +175,16 @@ ASYNC116.py:64:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should us 66 66 | # 'inf literal' overflow trick 67 67 | await anyio.sleep(1e999) # error: 116, "async" -ASYNC116.py:67:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` +ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` + --> ASYNC116.py:67:11 | 66 | # 'inf literal' overflow trick 67 | await anyio.sleep(1e999) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^ 68 | 69 | await anyio.sleep(86399) | - = help: Replace with `anyio.sleep_forever()` +help: Replace with `anyio.sleep_forever()` ℹ Unsafe fix 64 64 | await anyio.sleep(100000) # error: 116, "async" @@ -187,15 +196,16 @@ ASYNC116.py:67:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should us 69 69 | await anyio.sleep(86399) 70 70 | await anyio.sleep(86400) -ASYNC116.py:71:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` +ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` + --> ASYNC116.py:71:11 | 69 | await anyio.sleep(86399) 70 | await anyio.sleep(86400) 71 | await anyio.sleep(86400.01) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^^^^ 72 | await anyio.sleep(86401) # error: 116, "async" | - = help: Replace with `anyio.sleep_forever()` +help: Replace with `anyio.sleep_forever()` ℹ Unsafe fix 68 68 | @@ -207,16 +217,17 @@ ASYNC116.py:71:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should us 73 73 | 74 74 | await anyio.sleep(-1) # will raise a runtime error -ASYNC116.py:72:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` +ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` + --> ASYNC116.py:72:11 | 70 | await anyio.sleep(86400) 71 | await anyio.sleep(86400.01) # error: 116, "async" 72 | await anyio.sleep(86401) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^ 73 | 74 | await anyio.sleep(-1) # will raise a runtime error | - = help: Replace with `anyio.sleep_forever()` +help: Replace with `anyio.sleep_forever()` ℹ Unsafe fix 69 69 | await anyio.sleep(86399) @@ -228,15 +239,16 @@ ASYNC116.py:72:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should us 74 74 | await anyio.sleep(-1) # will raise a runtime error 75 75 | await anyio.sleep(0) # handled by different check -ASYNC116.py:101:5: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` +ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` + --> ASYNC116.py:101:5 | 100 | # does not require the call to be awaited, nor in an async fun 101 | anyio.sleep(86401) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^ 102 | # also checks that we don't break visit_Call 103 | anyio.run(anyio.sleep(86401)) # error: 116, "async" | - = help: Replace with `anyio.sleep_forever()` +help: Replace with `anyio.sleep_forever()` ℹ Unsafe fix 98 98 | import anyio @@ -248,14 +260,15 @@ ASYNC116.py:101:5: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should us 103 103 | anyio.run(anyio.sleep(86401)) # error: 116, "async" 104 104 | -ASYNC116.py:103:15: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` +ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` + --> ASYNC116.py:103:15 | 101 | anyio.sleep(86401) # error: 116, "async" 102 | # also checks that we don't break visit_Call 103 | anyio.run(anyio.sleep(86401)) # error: 116, "async" - | ^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace with `anyio.sleep_forever()` +help: Replace with `anyio.sleep_forever()` ℹ Unsafe fix 100 100 | # does not require the call to be awaited, nor in an async fun @@ -267,13 +280,14 @@ ASYNC116.py:103:15: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should u 105 105 | 106 106 | async def import_from_anyio(): -ASYNC116.py:110:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` +ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` + --> ASYNC116.py:110:11 | 109 | # catch from import 110 | await sleep(86401) # error: 116, "async" - | ^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^ | - = help: Replace with `anyio.sleep_forever()` +help: Replace with `anyio.sleep_forever()` ℹ Unsafe fix 2 2 | # ASYNCIO_NO_ERROR - no asyncio.sleep_forever, so check intentionally doesn't trigger. @@ -293,15 +307,16 @@ ASYNC116.py:110:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should u 112 113 | 113 114 | async def test_anyio_async116_helpers(): -ASYNC116.py:119:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` +ASYNC116 [*] `anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()` + --> ASYNC116.py:119:11 | 117 | await anyio.sleep(seconds=1) # OK 118 | 119 | await anyio.sleep(delay=86401) # ASYNC116 - | ^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 120 | await anyio.sleep(seconds=86401) # OK | - = help: Replace with `anyio.sleep_forever()` +help: Replace with `anyio.sleep_forever()` ℹ Unsafe fix 116 116 | await anyio.sleep(delay=1) # OK @@ -313,15 +328,16 @@ ASYNC116.py:119:11: ASYNC116 [*] `anyio.sleep()` with >24 hour interval should u 121 121 | 122 122 | -ASYNC116.py:129:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:129:11 | 127 | await trio.sleep(delay=1) # OK 128 | 129 | await trio.sleep(seconds=86401) # ASYNC116 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 130 | await trio.sleep(delay=86401) # OK | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 126 126 | await trio.sleep(seconds=1) # OK @@ -333,15 +349,16 @@ ASYNC116.py:129:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should us 131 131 | 132 132 | -ASYNC116.py:137:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:137:11 | 135 | from trio import sleep 136 | 137 | await sleep(18446744073709551616) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 138 | await trio.sleep(99999999999999999999) | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 134 134 | import trio @@ -351,13 +368,14 @@ ASYNC116.py:137:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should us 137 |+ await trio.sleep_forever() 138 138 | await trio.sleep(99999999999999999999) -ASYNC116.py:138:11: ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` +ASYNC116 [*] `trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()` + --> ASYNC116.py:138:11 | 137 | await sleep(18446744073709551616) 138 | await trio.sleep(99999999999999999999) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `trio.sleep_forever()` +help: Replace with `trio.sleep_forever()` ℹ Unsafe fix 135 135 | from trio import sleep diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC210_ASYNC210.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC210_ASYNC210.py.snap index 3b05d9961d..6082f3daca 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC210_ASYNC210.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC210_ASYNC210.py.snap @@ -1,229 +1,254 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC210.py:8:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:8:5 | 7 | async def foo(): 8 | urllib.request.urlopen("http://example.com/foo/bar").read() # ASYNC210 - | ^^^^^^^^^^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^^^^^^^^^^ | -ASYNC210.py:12:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:12:5 | 11 | async def foo(): 12 | requests.get() # ASYNC210 - | ^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^ | -ASYNC210.py:16:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:16:5 | 15 | async def foo(): 16 | httpx.get() # ASYNC210 - | ^^^^^^^^^ ASYNC210 + | ^^^^^^^^^ | -ASYNC210.py:20:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:20:5 | 19 | async def foo(): 20 | requests.post() # ASYNC210 - | ^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^ | -ASYNC210.py:24:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:24:5 | 23 | async def foo(): 24 | httpx.post() # ASYNC210 - | ^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^ | -ASYNC210.py:28:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:28:5 | 27 | async def foo(): 28 | requests.get() # ASYNC210 - | ^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^ 29 | requests.get(...) # ASYNC210 30 | requests.get # Ok | -ASYNC210.py:29:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:29:5 | 27 | async def foo(): 28 | requests.get() # ASYNC210 29 | requests.get(...) # ASYNC210 - | ^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^ 30 | requests.get # Ok 31 | print(requests.get()) # ASYNC210 | -ASYNC210.py:31:11: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:31:11 | 29 | requests.get(...) # ASYNC210 30 | requests.get # Ok 31 | print(requests.get()) # ASYNC210 - | ^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^ 32 | print(requests.get(requests.get())) # ASYNC210 | -ASYNC210.py:32:11: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:32:11 | 30 | requests.get # Ok 31 | print(requests.get()) # ASYNC210 32 | print(requests.get(requests.get())) # ASYNC210 - | ^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^ 33 | 34 | requests.options() # ASYNC210 | -ASYNC210.py:32:24: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:32:24 | 30 | requests.get # Ok 31 | print(requests.get()) # ASYNC210 32 | print(requests.get(requests.get())) # ASYNC210 - | ^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^ 33 | 34 | requests.options() # ASYNC210 | -ASYNC210.py:34:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:34:5 | 32 | print(requests.get(requests.get())) # ASYNC210 33 | 34 | requests.options() # ASYNC210 - | ^^^^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^^^^ 35 | requests.head() # ASYNC210 36 | requests.post() # ASYNC210 | -ASYNC210.py:35:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:35:5 | 34 | requests.options() # ASYNC210 35 | requests.head() # ASYNC210 - | ^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^ 36 | requests.post() # ASYNC210 37 | requests.put() # ASYNC210 | -ASYNC210.py:36:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:36:5 | 34 | requests.options() # ASYNC210 35 | requests.head() # ASYNC210 36 | requests.post() # ASYNC210 - | ^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^ 37 | requests.put() # ASYNC210 38 | requests.patch() # ASYNC210 | -ASYNC210.py:37:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:37:5 | 35 | requests.head() # ASYNC210 36 | requests.post() # ASYNC210 37 | requests.put() # ASYNC210 - | ^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^ 38 | requests.patch() # ASYNC210 39 | requests.delete() # ASYNC210 | -ASYNC210.py:38:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:38:5 | 36 | requests.post() # ASYNC210 37 | requests.put() # ASYNC210 38 | requests.patch() # ASYNC210 - | ^^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^^ 39 | requests.delete() # ASYNC210 40 | requests.foo() | -ASYNC210.py:39:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:39:5 | 37 | requests.put() # ASYNC210 38 | requests.patch() # ASYNC210 39 | requests.delete() # ASYNC210 - | ^^^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^^^ 40 | requests.foo() | -ASYNC210.py:42:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:42:5 | 40 | requests.foo() 41 | 42 | httpx.options("") # ASYNC210 - | ^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^ 43 | httpx.head("") # ASYNC210 44 | httpx.post("") # ASYNC210 | -ASYNC210.py:43:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:43:5 | 42 | httpx.options("") # ASYNC210 43 | httpx.head("") # ASYNC210 - | ^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^ 44 | httpx.post("") # ASYNC210 45 | httpx.put("") # ASYNC210 | -ASYNC210.py:44:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:44:5 | 42 | httpx.options("") # ASYNC210 43 | httpx.head("") # ASYNC210 44 | httpx.post("") # ASYNC210 - | ^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^ 45 | httpx.put("") # ASYNC210 46 | httpx.patch("") # ASYNC210 | -ASYNC210.py:45:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:45:5 | 43 | httpx.head("") # ASYNC210 44 | httpx.post("") # ASYNC210 45 | httpx.put("") # ASYNC210 - | ^^^^^^^^^ ASYNC210 + | ^^^^^^^^^ 46 | httpx.patch("") # ASYNC210 47 | httpx.delete("") # ASYNC210 | -ASYNC210.py:46:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:46:5 | 44 | httpx.post("") # ASYNC210 45 | httpx.put("") # ASYNC210 46 | httpx.patch("") # ASYNC210 - | ^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^ 47 | httpx.delete("") # ASYNC210 48 | httpx.foo() # Ok | -ASYNC210.py:47:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:47:5 | 45 | httpx.put("") # ASYNC210 46 | httpx.patch("") # ASYNC210 47 | httpx.delete("") # ASYNC210 - | ^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^ 48 | httpx.foo() # Ok | -ASYNC210.py:50:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:50:5 | 48 | httpx.foo() # Ok 49 | 50 | urllib3.request() # ASYNC210 - | ^^^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^^^ 51 | urllib3.request(...) # ASYNC210 | -ASYNC210.py:51:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:51:5 | 50 | urllib3.request() # ASYNC210 51 | urllib3.request(...) # ASYNC210 - | ^^^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^^^ 52 | 53 | urllib.request.urlopen("") # ASYNC210 | -ASYNC210.py:53:5: ASYNC210 Async functions should not call blocking HTTP methods +ASYNC210 Async functions should not call blocking HTTP methods + --> ASYNC210.py:53:5 | 51 | urllib3.request(...) # ASYNC210 52 | 53 | urllib.request.urlopen("") # ASYNC210 - | ^^^^^^^^^^^^^^^^^^^^^^ ASYNC210 + | ^^^^^^^^^^^^^^^^^^^^^^ 54 | 55 | r = {} | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC220_ASYNC22x.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC220_ASYNC22x.py.snap index 6be0e845ea..2132c93ebd 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC220_ASYNC22x.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC220_ASYNC22x.py.snap @@ -1,77 +1,85 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC22x.py:31:5: ASYNC220 Async functions should not create subprocesses with blocking methods +ASYNC220 Async functions should not create subprocesses with blocking methods + --> ASYNC22x.py:31:5 | 29 | subprocess.getoutput() # ASYNC221 30 | ) 31 | subprocess.Popen() # ASYNC220 - | ^^^^^^^^^^^^^^^^ ASYNC220 + | ^^^^^^^^^^^^^^^^ 32 | os.system() # ASYNC221 | -ASYNC22x.py:73:5: ASYNC220 Async functions should not create subprocesses with blocking methods +ASYNC220 Async functions should not create subprocesses with blocking methods + --> ASYNC22x.py:73:5 | 72 | # if mode is given, and is not os.P_WAIT: ASYNC220 73 | os.spawnl(os.P_NOWAIT) # ASYNC220 - | ^^^^^^^^^ ASYNC220 + | ^^^^^^^^^ 74 | os.spawnl(P_NOWAIT) # ASYNC220 75 | os.spawnl(mode=os.P_NOWAIT) # ASYNC220 | -ASYNC22x.py:74:5: ASYNC220 Async functions should not create subprocesses with blocking methods +ASYNC220 Async functions should not create subprocesses with blocking methods + --> ASYNC22x.py:74:5 | 72 | # if mode is given, and is not os.P_WAIT: ASYNC220 73 | os.spawnl(os.P_NOWAIT) # ASYNC220 74 | os.spawnl(P_NOWAIT) # ASYNC220 - | ^^^^^^^^^ ASYNC220 + | ^^^^^^^^^ 75 | os.spawnl(mode=os.P_NOWAIT) # ASYNC220 76 | os.spawnl(mode=P_NOWAIT) # ASYNC220 | -ASYNC22x.py:75:5: ASYNC220 Async functions should not create subprocesses with blocking methods +ASYNC220 Async functions should not create subprocesses with blocking methods + --> ASYNC22x.py:75:5 | 73 | os.spawnl(os.P_NOWAIT) # ASYNC220 74 | os.spawnl(P_NOWAIT) # ASYNC220 75 | os.spawnl(mode=os.P_NOWAIT) # ASYNC220 - | ^^^^^^^^^ ASYNC220 + | ^^^^^^^^^ 76 | os.spawnl(mode=P_NOWAIT) # ASYNC220 | -ASYNC22x.py:76:5: ASYNC220 Async functions should not create subprocesses with blocking methods +ASYNC220 Async functions should not create subprocesses with blocking methods + --> ASYNC22x.py:76:5 | 74 | os.spawnl(P_NOWAIT) # ASYNC220 75 | os.spawnl(mode=os.P_NOWAIT) # ASYNC220 76 | os.spawnl(mode=P_NOWAIT) # ASYNC220 - | ^^^^^^^^^ ASYNC220 + | ^^^^^^^^^ 77 | 78 | P_WAIT = os.P_WAIT | -ASYNC22x.py:86:5: ASYNC220 Async functions should not create subprocesses with blocking methods +ASYNC220 Async functions should not create subprocesses with blocking methods + --> ASYNC22x.py:86:5 | 85 | # other weird cases: ASYNC220 86 | os.spawnl(0) # ASYNC220 - | ^^^^^^^^^ ASYNC220 + | ^^^^^^^^^ 87 | os.spawnl(1) # ASYNC220 88 | os.spawnl(foo()) # ASYNC220 | -ASYNC22x.py:87:5: ASYNC220 Async functions should not create subprocesses with blocking methods +ASYNC220 Async functions should not create subprocesses with blocking methods + --> ASYNC22x.py:87:5 | 85 | # other weird cases: ASYNC220 86 | os.spawnl(0) # ASYNC220 87 | os.spawnl(1) # ASYNC220 - | ^^^^^^^^^ ASYNC220 + | ^^^^^^^^^ 88 | os.spawnl(foo()) # ASYNC220 | -ASYNC22x.py:88:5: ASYNC220 Async functions should not create subprocesses with blocking methods +ASYNC220 Async functions should not create subprocesses with blocking methods + --> ASYNC22x.py:88:5 | 86 | os.spawnl(0) # ASYNC220 87 | os.spawnl(1) # ASYNC220 88 | os.spawnl(foo()) # ASYNC220 - | ^^^^^^^^^ ASYNC220 + | ^^^^^^^^^ 89 | 90 | # ASYNC222 | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC221_ASYNC22x.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC221_ASYNC22x.py.snap index b838d96026..1a3756bca5 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC221_ASYNC22x.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC221_ASYNC22x.py.snap @@ -1,226 +1,250 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC22x.py:8:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:8:5 | 7 | async def func(): 8 | subprocess.run("foo") # ASYNC221 - | ^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^ | -ASYNC22x.py:12:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:12:5 | 11 | async def func(): 12 | subprocess.call("foo") # ASYNC221 - | ^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^ | -ASYNC22x.py:29:9: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:29:9 | 27 | async def foo(): 28 | await async_fun( 29 | subprocess.getoutput() # ASYNC221 - | ^^^^^^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^^^^^^ 30 | ) 31 | subprocess.Popen() # ASYNC220 | -ASYNC22x.py:32:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:32:5 | 30 | ) 31 | subprocess.Popen() # ASYNC220 32 | os.system() # ASYNC221 - | ^^^^^^^^^ ASYNC221 + | ^^^^^^^^^ 33 | 34 | system() | -ASYNC22x.py:38:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:38:5 | 36 | os.anything() 37 | 38 | subprocess.run() # ASYNC221 - | ^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^ 39 | subprocess.call() # ASYNC221 40 | subprocess.check_call() # ASYNC221 | -ASYNC22x.py:39:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:39:5 | 38 | subprocess.run() # ASYNC221 39 | subprocess.call() # ASYNC221 - | ^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^ 40 | subprocess.check_call() # ASYNC221 41 | subprocess.check_output() # ASYNC221 | -ASYNC22x.py:40:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:40:5 | 38 | subprocess.run() # ASYNC221 39 | subprocess.call() # ASYNC221 40 | subprocess.check_call() # ASYNC221 - | ^^^^^^^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^^^^^^^ 41 | subprocess.check_output() # ASYNC221 42 | subprocess.getoutput() # ASYNC221 | -ASYNC22x.py:41:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:41:5 | 39 | subprocess.call() # ASYNC221 40 | subprocess.check_call() # ASYNC221 41 | subprocess.check_output() # ASYNC221 - | ^^^^^^^^^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^^^^^^^^^ 42 | subprocess.getoutput() # ASYNC221 43 | subprocess.getstatusoutput() # ASYNC221 | -ASYNC22x.py:42:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:42:5 | 40 | subprocess.check_call() # ASYNC221 41 | subprocess.check_output() # ASYNC221 42 | subprocess.getoutput() # ASYNC221 - | ^^^^^^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^^^^^^ 43 | subprocess.getstatusoutput() # ASYNC221 | -ASYNC22x.py:43:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:43:5 | 41 | subprocess.check_output() # ASYNC221 42 | subprocess.getoutput() # ASYNC221 43 | subprocess.getstatusoutput() # ASYNC221 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | await async_fun( | -ASYNC22x.py:46:9: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:46:9 | 45 | await async_fun( 46 | subprocess.getoutput() # ASYNC221 - | ^^^^^^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^^^^^^ 47 | ) | -ASYNC22x.py:54:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:54:5 | 52 | subprocess() 53 | 54 | os.posix_spawn() # ASYNC221 - | ^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^ 55 | os.posix_spawnp() # ASYNC221 | -ASYNC22x.py:55:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:55:5 | 54 | os.posix_spawn() # ASYNC221 55 | os.posix_spawnp() # ASYNC221 - | ^^^^^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^^^^^ 56 | 57 | os.spawn() | -ASYNC22x.py:61:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:61:5 | 59 | os.spawnllll() 60 | 61 | os.spawnl() # ASYNC221 - | ^^^^^^^^^ ASYNC221 + | ^^^^^^^^^ 62 | os.spawnle() # ASYNC221 63 | os.spawnlp() # ASYNC221 | -ASYNC22x.py:62:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:62:5 | 61 | os.spawnl() # ASYNC221 62 | os.spawnle() # ASYNC221 - | ^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^ 63 | os.spawnlp() # ASYNC221 64 | os.spawnlpe() # ASYNC221 | -ASYNC22x.py:63:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:63:5 | 61 | os.spawnl() # ASYNC221 62 | os.spawnle() # ASYNC221 63 | os.spawnlp() # ASYNC221 - | ^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^ 64 | os.spawnlpe() # ASYNC221 65 | os.spawnv() # ASYNC221 | -ASYNC22x.py:64:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:64:5 | 62 | os.spawnle() # ASYNC221 63 | os.spawnlp() # ASYNC221 64 | os.spawnlpe() # ASYNC221 - | ^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^ 65 | os.spawnv() # ASYNC221 66 | os.spawnve() # ASYNC221 | -ASYNC22x.py:65:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:65:5 | 63 | os.spawnlp() # ASYNC221 64 | os.spawnlpe() # ASYNC221 65 | os.spawnv() # ASYNC221 - | ^^^^^^^^^ ASYNC221 + | ^^^^^^^^^ 66 | os.spawnve() # ASYNC221 67 | os.spawnvp() # ASYNC221 | -ASYNC22x.py:66:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:66:5 | 64 | os.spawnlpe() # ASYNC221 65 | os.spawnv() # ASYNC221 66 | os.spawnve() # ASYNC221 - | ^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^ 67 | os.spawnvp() # ASYNC221 68 | os.spawnvpe() # ASYNC221 | -ASYNC22x.py:67:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:67:5 | 65 | os.spawnv() # ASYNC221 66 | os.spawnve() # ASYNC221 67 | os.spawnvp() # ASYNC221 - | ^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^ 68 | os.spawnvpe() # ASYNC221 | -ASYNC22x.py:68:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:68:5 | 66 | os.spawnve() # ASYNC221 67 | os.spawnvp() # ASYNC221 68 | os.spawnvpe() # ASYNC221 - | ^^^^^^^^^^^ ASYNC221 + | ^^^^^^^^^^^ 69 | 70 | P_NOWAIT = os.P_NOWAIT | -ASYNC22x.py:81:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:81:5 | 80 | # if it is P_WAIT, ASYNC221 81 | os.spawnl(P_WAIT) # ASYNC221 - | ^^^^^^^^^ ASYNC221 + | ^^^^^^^^^ 82 | os.spawnl(mode=os.P_WAIT) # ASYNC221 83 | os.spawnl(mode=P_WAIT) # ASYNC221 | -ASYNC22x.py:82:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:82:5 | 80 | # if it is P_WAIT, ASYNC221 81 | os.spawnl(P_WAIT) # ASYNC221 82 | os.spawnl(mode=os.P_WAIT) # ASYNC221 - | ^^^^^^^^^ ASYNC221 + | ^^^^^^^^^ 83 | os.spawnl(mode=P_WAIT) # ASYNC221 | -ASYNC22x.py:83:5: ASYNC221 Async functions should not run processes with blocking methods +ASYNC221 Async functions should not run processes with blocking methods + --> ASYNC22x.py:83:5 | 81 | os.spawnl(P_WAIT) # ASYNC221 82 | os.spawnl(mode=os.P_WAIT) # ASYNC221 83 | os.spawnl(mode=P_WAIT) # ASYNC221 - | ^^^^^^^^^ ASYNC221 + | ^^^^^^^^^ 84 | 85 | # other weird cases: ASYNC220 | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC222_ASYNC22x.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC222_ASYNC22x.py.snap index 66ca87ebfe..13e4a52a62 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC222_ASYNC22x.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC222_ASYNC22x.py.snap @@ -1,64 +1,71 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC22x.py:20:5: ASYNC222 Async functions should not wait on processes with blocking methods +ASYNC222 Async functions should not wait on processes with blocking methods + --> ASYNC22x.py:20:5 | 19 | async def func(): 20 | os.wait4(10) # ASYNC222 - | ^^^^^^^^ ASYNC222 + | ^^^^^^^^ | -ASYNC22x.py:24:5: ASYNC222 Async functions should not wait on processes with blocking methods +ASYNC222 Async functions should not wait on processes with blocking methods + --> ASYNC22x.py:24:5 | 23 | async def func(): 24 | os.wait(12) # ASYNC222 - | ^^^^^^^ ASYNC222 + | ^^^^^^^ | -ASYNC22x.py:91:5: ASYNC222 Async functions should not wait on processes with blocking methods +ASYNC222 Async functions should not wait on processes with blocking methods + --> ASYNC22x.py:91:5 | 90 | # ASYNC222 91 | os.wait() # ASYNC222 - | ^^^^^^^ ASYNC222 + | ^^^^^^^ 92 | os.wait3() # ASYNC222 93 | os.wait4() # ASYNC222 | -ASYNC22x.py:92:5: ASYNC222 Async functions should not wait on processes with blocking methods +ASYNC222 Async functions should not wait on processes with blocking methods + --> ASYNC22x.py:92:5 | 90 | # ASYNC222 91 | os.wait() # ASYNC222 92 | os.wait3() # ASYNC222 - | ^^^^^^^^ ASYNC222 + | ^^^^^^^^ 93 | os.wait4() # ASYNC222 94 | os.waitid() # ASYNC222 | -ASYNC22x.py:93:5: ASYNC222 Async functions should not wait on processes with blocking methods +ASYNC222 Async functions should not wait on processes with blocking methods + --> ASYNC22x.py:93:5 | 91 | os.wait() # ASYNC222 92 | os.wait3() # ASYNC222 93 | os.wait4() # ASYNC222 - | ^^^^^^^^ ASYNC222 + | ^^^^^^^^ 94 | os.waitid() # ASYNC222 95 | os.waitpid() # ASYNC222 | -ASYNC22x.py:94:5: ASYNC222 Async functions should not wait on processes with blocking methods +ASYNC222 Async functions should not wait on processes with blocking methods + --> ASYNC22x.py:94:5 | 92 | os.wait3() # ASYNC222 93 | os.wait4() # ASYNC222 94 | os.waitid() # ASYNC222 - | ^^^^^^^^^ ASYNC222 + | ^^^^^^^^^ 95 | os.waitpid() # ASYNC222 | -ASYNC22x.py:95:5: ASYNC222 Async functions should not wait on processes with blocking methods +ASYNC222 Async functions should not wait on processes with blocking methods + --> ASYNC22x.py:95:5 | 93 | os.wait4() # ASYNC222 94 | os.waitid() # ASYNC222 95 | os.waitpid() # ASYNC222 - | ^^^^^^^^^^ ASYNC222 + | ^^^^^^^^^^ 96 | 97 | os.waitpi() | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC230_ASYNC230.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC230_ASYNC230.py.snap index b842175406..912a451a2b 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC230_ASYNC230.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC230_ASYNC230.py.snap @@ -1,101 +1,113 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs --- -ASYNC230.py:6:5: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:6:5 | 5 | async def foo(): 6 | open("") # ASYNC230 - | ^^^^ ASYNC230 + | ^^^^ 7 | io.open_code("") # ASYNC230 | -ASYNC230.py:7:5: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:7:5 | 5 | async def foo(): 6 | open("") # ASYNC230 7 | io.open_code("") # ASYNC230 - | ^^^^^^^^^^^^ ASYNC230 + | ^^^^^^^^^^^^ 8 | 9 | with open(""): # ASYNC230 | -ASYNC230.py:9:10: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:9:10 | 7 | io.open_code("") # ASYNC230 8 | 9 | with open(""): # ASYNC230 - | ^^^^ ASYNC230 + | ^^^^ 10 | ... | -ASYNC230.py:12:10: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:12:10 | 10 | ... 11 | 12 | with open("") as f: # ASYNC230 - | ^^^^ ASYNC230 + | ^^^^ 13 | ... | -ASYNC230.py:15:17: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:15:17 | 13 | ... 14 | 15 | with foo(), open(""): # ASYNC230 - | ^^^^ ASYNC230 + | ^^^^ 16 | ... | -ASYNC230.py:18:16: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:18:16 | 16 | ... 17 | 18 | async with open(""): # ASYNC230 - | ^^^^ ASYNC230 + | ^^^^ 19 | ... | -ASYNC230.py:29:5: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:29:5 | 28 | async def func(): 29 | open("foo") # ASYNC230 - | ^^^^ ASYNC230 + | ^^^^ | -ASYNC230.py:36:5: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:36:5 | 35 | async def func(): 36 | Path("foo").open() # ASYNC230 - | ^^^^^^^^^^^^^^^^ ASYNC230 + | ^^^^^^^^^^^^^^^^ | -ASYNC230.py:41:5: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:41:5 | 39 | async def func(): 40 | p = Path("foo") 41 | p.open() # ASYNC230 - | ^^^^^^ ASYNC230 + | ^^^^^^ | -ASYNC230.py:45:10: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:45:10 | 44 | async def func(): 45 | with Path("foo").open() as f: # ASYNC230 - | ^^^^^^^^^^^^^^^^ ASYNC230 + | ^^^^^^^^^^^^^^^^ 46 | pass | -ASYNC230.py:53:9: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:53:9 | 52 | async def bar(): 53 | p.open() # ASYNC230 - | ^^^^^^ ASYNC230 + | ^^^^^^ | -ASYNC230.py:59:5: ASYNC230 Async functions should not open files with blocking methods like `open` +ASYNC230 Async functions should not open files with blocking methods like `open` + --> ASYNC230.py:59:5 | 57 | (p1, p2) = (Path("foo"), Path("bar")) 58 | 59 | p1.open() # ASYNC230 - | ^^^^^^^ ASYNC230 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC251_ASYNC251.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC251_ASYNC251.py.snap index 878f40cb8f..bc6ec0e246 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC251_ASYNC251.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC251_ASYNC251.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_async/mod.rs -snapshot_kind: text --- -ASYNC251.py:6:5: ASYNC251 Async functions should not call `time.sleep` +ASYNC251 Async functions should not call `time.sleep` + --> ASYNC251.py:6:5 | 5 | async def func(): 6 | time.sleep(1) # ASYNC251 - | ^^^^^^^^^^ ASYNC251 + | ^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S101_S101.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S101_S101.py.snap index 899d296ad8..8a600103fd 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S101_S101.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S101_S101.py.snap @@ -1,26 +1,28 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S101.py:1:1: S101 Use of `assert` detected +S101 Use of `assert` detected + --> S101.py:1:1 | 1 | assert True # S101 - | ^^^^^^ S101 + | ^^^^^^ | -S101.py:6:5: S101 Use of `assert` detected +S101 Use of `assert` detected + --> S101.py:6:5 | 4 | def fn(): 5 | x = 1 6 | assert x == 1 # S101 - | ^^^^^^ S101 + | ^^^^^^ 7 | assert x == 2 # S101 | -S101.py:7:5: S101 Use of `assert` detected +S101 Use of `assert` detected + --> S101.py:7:5 | 5 | x = 1 6 | assert x == 1 # S101 7 | assert x == 2 # S101 - | ^^^^^^ S101 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap index 317ef1d7f4..d424ab9357 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S102.py:3:5: S102 Use of `exec` detected +S102 Use of `exec` detected + --> S102.py:3:5 | 1 | def fn(): 2 | # Error 3 | exec('x = 2') - | ^^^^ S102 + | ^^^^ 4 | 5 | exec('y = 3') | -S102.py:5:1: S102 Use of `exec` detected +S102 Use of `exec` detected + --> S102.py:5:1 | 3 | exec('x = 2') 4 | 5 | exec('y = 3') - | ^^^^ S102 + | ^^^^ | -S102.py:11:5: S102 Use of `exec` detected +S102 Use of `exec` detected + --> S102.py:11:5 | 9 | def _(): 10 | from builtins import exec 11 | exec('') # Error - | ^^^^ S102 + | ^^^^ 12 | 13 | def _(): | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap index f400e65f28..64afdabaf9 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap @@ -1,138 +1,152 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S103.py:6:25: S103 `os.chmod` setting a permissive mask `0o227` on file or directory +S103 `os.chmod` setting a permissive mask `0o227` on file or directory + --> S103.py:6:25 | 4 | keyfile = "foo" 5 | 6 | os.chmod("/etc/passwd", 0o227) # Error - | ^^^^^ S103 + | ^^^^^ 7 | os.chmod("/etc/passwd", 0o7) # Error 8 | os.chmod("/etc/passwd", 0o664) # OK | -S103.py:7:25: S103 `os.chmod` setting a permissive mask `0o7` on file or directory +S103 `os.chmod` setting a permissive mask `0o7` on file or directory + --> S103.py:7:25 | 6 | os.chmod("/etc/passwd", 0o227) # Error 7 | os.chmod("/etc/passwd", 0o7) # Error - | ^^^ S103 + | ^^^ 8 | os.chmod("/etc/passwd", 0o664) # OK 9 | os.chmod("/etc/passwd", 0o777) # Error | -S103.py:9:25: S103 `os.chmod` setting a permissive mask `0o777` on file or directory +S103 `os.chmod` setting a permissive mask `0o777` on file or directory + --> S103.py:9:25 | 7 | os.chmod("/etc/passwd", 0o7) # Error 8 | os.chmod("/etc/passwd", 0o664) # OK 9 | os.chmod("/etc/passwd", 0o777) # Error - | ^^^^^ S103 + | ^^^^^ 10 | os.chmod("/etc/passwd", 0o770) # Error 11 | os.chmod("/etc/passwd", 0o776) # Error | -S103.py:10:25: S103 `os.chmod` setting a permissive mask `0o770` on file or directory +S103 `os.chmod` setting a permissive mask `0o770` on file or directory + --> S103.py:10:25 | 8 | os.chmod("/etc/passwd", 0o664) # OK 9 | os.chmod("/etc/passwd", 0o777) # Error 10 | os.chmod("/etc/passwd", 0o770) # Error - | ^^^^^ S103 + | ^^^^^ 11 | os.chmod("/etc/passwd", 0o776) # Error 12 | os.chmod("/etc/passwd", 0o760) # OK | -S103.py:11:25: S103 `os.chmod` setting a permissive mask `0o776` on file or directory +S103 `os.chmod` setting a permissive mask `0o776` on file or directory + --> S103.py:11:25 | 9 | os.chmod("/etc/passwd", 0o777) # Error 10 | os.chmod("/etc/passwd", 0o770) # Error 11 | os.chmod("/etc/passwd", 0o776) # Error - | ^^^^^ S103 + | ^^^^^ 12 | os.chmod("/etc/passwd", 0o760) # OK 13 | os.chmod("~/.bashrc", 511) # Error | -S103.py:13:23: S103 `os.chmod` setting a permissive mask `0o777` on file or directory +S103 `os.chmod` setting a permissive mask `0o777` on file or directory + --> S103.py:13:23 | 11 | os.chmod("/etc/passwd", 0o776) # Error 12 | os.chmod("/etc/passwd", 0o760) # OK 13 | os.chmod("~/.bashrc", 511) # Error - | ^^^ S103 + | ^^^ 14 | os.chmod("/etc/hosts", 0o777) # Error 15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error | -S103.py:14:24: S103 `os.chmod` setting a permissive mask `0o777` on file or directory +S103 `os.chmod` setting a permissive mask `0o777` on file or directory + --> S103.py:14:24 | 12 | os.chmod("/etc/passwd", 0o760) # OK 13 | os.chmod("~/.bashrc", 511) # Error 14 | os.chmod("/etc/hosts", 0o777) # Error - | ^^^^^ S103 + | ^^^^^ 15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error 16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK | -S103.py:15:25: S103 `os.chmod` setting a permissive mask `0o777` on file or directory +S103 `os.chmod` setting a permissive mask `0o777` on file or directory + --> S103.py:15:25 | 13 | os.chmod("~/.bashrc", 511) # Error 14 | os.chmod("/etc/hosts", 0o777) # Error 15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error - | ^^^^^ S103 + | ^^^^^ 16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK 17 | os.chmod(keyfile, 0o777) # Error | -S103.py:17:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory +S103 `os.chmod` setting a permissive mask `0o777` on file or directory + --> S103.py:17:19 | 15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error 16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK 17 | os.chmod(keyfile, 0o777) # Error - | ^^^^^ S103 + | ^^^^^ 18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error 19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error | -S103.py:18:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory +S103 `os.chmod` setting a permissive mask `0o777` on file or directory + --> S103.py:18:19 | 16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK 17 | os.chmod(keyfile, 0o777) # Error 18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error - | ^^^^^^^^^^^^^^^^^^ S103 + | ^^^^^^^^^^^^^^^^^^ 19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error 20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error | -S103.py:19:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory +S103 `os.chmod` setting a permissive mask `0o777` on file or directory + --> S103.py:19:19 | 17 | os.chmod(keyfile, 0o777) # Error 18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error 19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error 21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK | -S103.py:20:27: S103 `os.chmod` setting a permissive mask `0o10` on file or directory +S103 `os.chmod` setting a permissive mask `0o10` on file or directory + --> S103.py:20:27 | 18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error 19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error 20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error - | ^^^^^^^^^^^^ S103 + | ^^^^^^^^^^^^ 21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK 22 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error | -S103.py:22:25: S103 `os.chmod` setting a permissive mask `0o2` on file or directory +S103 `os.chmod` setting a permissive mask `0o2` on file or directory + --> S103.py:22:25 | 20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error 21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK 22 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error - | ^^^^^^^^^^^^ S103 + | ^^^^^^^^^^^^ 23 | os.chmod("/etc/passwd", 0o100000000) # Error | -S103.py:23:25: S103 `os.chmod` setting an invalid mask on file or directory +S103 `os.chmod` setting an invalid mask on file or directory + --> S103.py:23:25 | 21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK 22 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error 23 | os.chmod("/etc/passwd", 0o100000000) # Error - | ^^^^^^^^^^^ S103 + | ^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S104_S104.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S104_S104.py.snap index bcad262f2f..a34d204422 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S104_S104.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S104_S104.py.snap @@ -1,70 +1,78 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S104.py:9:1: S104 Possible binding to all interfaces +S104 Possible binding to all interfaces + --> S104.py:9:1 | 8 | # Error 9 | "0.0.0.0" - | ^^^^^^^^^ S104 + | ^^^^^^^^^ 10 | '0.0.0.0' 11 | f"0.0.0.0" | -S104.py:10:1: S104 Possible binding to all interfaces +S104 Possible binding to all interfaces + --> S104.py:10:1 | 8 | # Error 9 | "0.0.0.0" 10 | '0.0.0.0' - | ^^^^^^^^^ S104 + | ^^^^^^^^^ 11 | f"0.0.0.0" | -S104.py:11:3: S104 Possible binding to all interfaces +S104 Possible binding to all interfaces + --> S104.py:11:3 | 9 | "0.0.0.0" 10 | '0.0.0.0' 11 | f"0.0.0.0" - | ^^^^^^^ S104 + | ^^^^^^^ | -S104.py:15:6: S104 Possible binding to all interfaces +S104 Possible binding to all interfaces + --> S104.py:15:6 | 14 | # Error 15 | func("0.0.0.0") - | ^^^^^^^^^ S104 + | ^^^^^^^^^ | -S104.py:19:9: S104 Possible binding to all interfaces +S104 Possible binding to all interfaces + --> S104.py:19:9 | 18 | def my_func(): 19 | x = "0.0.0.0" - | ^^^^^^^^^ S104 + | ^^^^^^^^^ 20 | print(x) | -S104.py:24:1: S104 Possible binding to all interfaces +S104 Possible binding to all interfaces + --> S104.py:24:1 | 23 | # Implicit string concatenation 24 | "0.0.0.0" f"0.0.0.0{expr}0.0.0.0" - | ^^^^^^^^^ S104 + | ^^^^^^^^^ 25 | 26 | # t-strings - all ok | -S104.py:24:13: S104 Possible binding to all interfaces +S104 Possible binding to all interfaces + --> S104.py:24:13 | 23 | # Implicit string concatenation 24 | "0.0.0.0" f"0.0.0.0{expr}0.0.0.0" - | ^^^^^^^ S104 + | ^^^^^^^ 25 | 26 | # t-strings - all ok | -S104.py:24:26: S104 Possible binding to all interfaces +S104 Possible binding to all interfaces + --> S104.py:24:26 | 23 | # Implicit string concatenation 24 | "0.0.0.0" f"0.0.0.0{expr}0.0.0.0" - | ^^^^^^^ S104 + | ^^^^^^^ 25 | 26 | # t-strings - all ok | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap index 851cb57409..fe9c896f66 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap @@ -1,395 +1,436 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S105.py:13:12: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:13:12 | 12 | # Errors 13 | password = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 14 | _pass = "s3cr3t" 15 | passwd = "s3cr3t" | -S105.py:14:9: S105 Possible hardcoded password assigned to: "_pass" +S105 Possible hardcoded password assigned to: "_pass" + --> S105.py:14:9 | 12 | # Errors 13 | password = "s3cr3t" 14 | _pass = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 15 | passwd = "s3cr3t" 16 | pwd = "s3cr3t" | -S105.py:15:10: S105 Possible hardcoded password assigned to: "passwd" +S105 Possible hardcoded password assigned to: "passwd" + --> S105.py:15:10 | 13 | password = "s3cr3t" 14 | _pass = "s3cr3t" 15 | passwd = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 16 | pwd = "s3cr3t" 17 | secret = "s3cr3t" | -S105.py:16:7: S105 Possible hardcoded password assigned to: "pwd" +S105 Possible hardcoded password assigned to: "pwd" + --> S105.py:16:7 | 14 | _pass = "s3cr3t" 15 | passwd = "s3cr3t" 16 | pwd = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 17 | secret = "s3cr3t" 18 | token = "s3cr3t" | -S105.py:17:10: S105 Possible hardcoded password assigned to: "secret" +S105 Possible hardcoded password assigned to: "secret" + --> S105.py:17:10 | 15 | passwd = "s3cr3t" 16 | pwd = "s3cr3t" 17 | secret = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 18 | token = "s3cr3t" 19 | secrete = "s3cr3t" | -S105.py:18:9: S105 Possible hardcoded password assigned to: "token" +S105 Possible hardcoded password assigned to: "token" + --> S105.py:18:9 | 16 | pwd = "s3cr3t" 17 | secret = "s3cr3t" 18 | token = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 19 | secrete = "s3cr3t" 20 | safe = password = "s3cr3t" | -S105.py:19:11: S105 Possible hardcoded password assigned to: "secrete" +S105 Possible hardcoded password assigned to: "secrete" + --> S105.py:19:11 | 17 | secret = "s3cr3t" 18 | token = "s3cr3t" 19 | secrete = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 20 | safe = password = "s3cr3t" 21 | password = safe = "s3cr3t" | -S105.py:20:19: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:20:19 | 18 | token = "s3cr3t" 19 | secrete = "s3cr3t" 20 | safe = password = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 21 | password = safe = "s3cr3t" 22 | PASSWORD = "s3cr3t" | -S105.py:21:19: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:21:19 | 19 | secrete = "s3cr3t" 20 | safe = password = "s3cr3t" 21 | password = safe = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 22 | PASSWORD = "s3cr3t" 23 | PassWord = "s3cr3t" | -S105.py:22:12: S105 Possible hardcoded password assigned to: "PASSWORD" +S105 Possible hardcoded password assigned to: "PASSWORD" + --> S105.py:22:12 | 20 | safe = password = "s3cr3t" 21 | password = safe = "s3cr3t" 22 | PASSWORD = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 23 | PassWord = "s3cr3t" 24 | password: str = "s3cr3t" | -S105.py:23:12: S105 Possible hardcoded password assigned to: "PassWord" +S105 Possible hardcoded password assigned to: "PassWord" + --> S105.py:23:12 | 21 | password = safe = "s3cr3t" 22 | PASSWORD = "s3cr3t" 23 | PassWord = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 24 | password: str = "s3cr3t" 25 | password: Final = "s3cr3t" | -S105.py:24:17: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:24:17 | 22 | PASSWORD = "s3cr3t" 23 | PassWord = "s3cr3t" 24 | password: str = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 25 | password: Final = "s3cr3t" | -S105.py:25:19: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:25:19 | 23 | PassWord = "s3cr3t" 24 | password: str = "s3cr3t" 25 | password: Final = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 26 | 27 | d["password"] = "s3cr3t" | -S105.py:27:17: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:27:17 | 25 | password: Final = "s3cr3t" 26 | 27 | d["password"] = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 28 | d["pass"] = "s3cr3t" 29 | d["passwd"] = "s3cr3t" | -S105.py:28:13: S105 Possible hardcoded password assigned to: "pass" +S105 Possible hardcoded password assigned to: "pass" + --> S105.py:28:13 | 27 | d["password"] = "s3cr3t" 28 | d["pass"] = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 29 | d["passwd"] = "s3cr3t" 30 | d["pwd"] = "s3cr3t" | -S105.py:29:15: S105 Possible hardcoded password assigned to: "passwd" +S105 Possible hardcoded password assigned to: "passwd" + --> S105.py:29:15 | 27 | d["password"] = "s3cr3t" 28 | d["pass"] = "s3cr3t" 29 | d["passwd"] = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 30 | d["pwd"] = "s3cr3t" 31 | d["secret"] = "s3cr3t" | -S105.py:30:12: S105 Possible hardcoded password assigned to: "pwd" +S105 Possible hardcoded password assigned to: "pwd" + --> S105.py:30:12 | 28 | d["pass"] = "s3cr3t" 29 | d["passwd"] = "s3cr3t" 30 | d["pwd"] = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 31 | d["secret"] = "s3cr3t" 32 | d["token"] = "s3cr3t" | -S105.py:31:15: S105 Possible hardcoded password assigned to: "secret" +S105 Possible hardcoded password assigned to: "secret" + --> S105.py:31:15 | 29 | d["passwd"] = "s3cr3t" 30 | d["pwd"] = "s3cr3t" 31 | d["secret"] = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 32 | d["token"] = "s3cr3t" 33 | d["secrete"] = "s3cr3t" | -S105.py:32:14: S105 Possible hardcoded password assigned to: "token" +S105 Possible hardcoded password assigned to: "token" + --> S105.py:32:14 | 30 | d["pwd"] = "s3cr3t" 31 | d["secret"] = "s3cr3t" 32 | d["token"] = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 33 | d["secrete"] = "s3cr3t" 34 | safe = d["password"] = "s3cr3t" | -S105.py:33:16: S105 Possible hardcoded password assigned to: "secrete" +S105 Possible hardcoded password assigned to: "secrete" + --> S105.py:33:16 | 31 | d["secret"] = "s3cr3t" 32 | d["token"] = "s3cr3t" 33 | d["secrete"] = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 34 | safe = d["password"] = "s3cr3t" 35 | d["password"] = safe = "s3cr3t" | -S105.py:34:24: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:34:24 | 32 | d["token"] = "s3cr3t" 33 | d["secrete"] = "s3cr3t" 34 | safe = d["password"] = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 35 | d["password"] = safe = "s3cr3t" | -S105.py:35:24: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:35:24 | 33 | d["secrete"] = "s3cr3t" 34 | safe = d["password"] = "s3cr3t" 35 | d["password"] = safe = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ | -S105.py:39:16: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:39:16 | 38 | class MyClass: 39 | password = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 40 | safe = password | -S105.py:43:20: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:43:20 | 43 | MyClass.password = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 44 | MyClass._pass = "s3cr3t" 45 | MyClass.passwd = "s3cr3t" | -S105.py:44:17: S105 Possible hardcoded password assigned to: "_pass" +S105 Possible hardcoded password assigned to: "_pass" + --> S105.py:44:17 | 43 | MyClass.password = "s3cr3t" 44 | MyClass._pass = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 45 | MyClass.passwd = "s3cr3t" 46 | MyClass.pwd = "s3cr3t" | -S105.py:45:18: S105 Possible hardcoded password assigned to: "passwd" +S105 Possible hardcoded password assigned to: "passwd" + --> S105.py:45:18 | 43 | MyClass.password = "s3cr3t" 44 | MyClass._pass = "s3cr3t" 45 | MyClass.passwd = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 46 | MyClass.pwd = "s3cr3t" 47 | MyClass.secret = "s3cr3t" | -S105.py:46:15: S105 Possible hardcoded password assigned to: "pwd" +S105 Possible hardcoded password assigned to: "pwd" + --> S105.py:46:15 | 44 | MyClass._pass = "s3cr3t" 45 | MyClass.passwd = "s3cr3t" 46 | MyClass.pwd = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 47 | MyClass.secret = "s3cr3t" 48 | MyClass.token = "s3cr3t" | -S105.py:47:18: S105 Possible hardcoded password assigned to: "secret" +S105 Possible hardcoded password assigned to: "secret" + --> S105.py:47:18 | 45 | MyClass.passwd = "s3cr3t" 46 | MyClass.pwd = "s3cr3t" 47 | MyClass.secret = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 48 | MyClass.token = "s3cr3t" 49 | MyClass.secrete = "s3cr3t" | -S105.py:48:17: S105 Possible hardcoded password assigned to: "token" +S105 Possible hardcoded password assigned to: "token" + --> S105.py:48:17 | 46 | MyClass.pwd = "s3cr3t" 47 | MyClass.secret = "s3cr3t" 48 | MyClass.token = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 49 | MyClass.secrete = "s3cr3t" | -S105.py:49:19: S105 Possible hardcoded password assigned to: "secrete" +S105 Possible hardcoded password assigned to: "secrete" + --> S105.py:49:19 | 47 | MyClass.secret = "s3cr3t" 48 | MyClass.token = "s3cr3t" 49 | MyClass.secrete = "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 50 | 51 | password == "s3cr3t" | -S105.py:51:13: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:51:13 | 49 | MyClass.secrete = "s3cr3t" 50 | 51 | password == "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 52 | _pass == "s3cr3t" 53 | passwd == "s3cr3t" | -S105.py:52:10: S105 Possible hardcoded password assigned to: "_pass" +S105 Possible hardcoded password assigned to: "_pass" + --> S105.py:52:10 | 51 | password == "s3cr3t" 52 | _pass == "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 53 | passwd == "s3cr3t" 54 | pwd == "s3cr3t" | -S105.py:53:11: S105 Possible hardcoded password assigned to: "passwd" +S105 Possible hardcoded password assigned to: "passwd" + --> S105.py:53:11 | 51 | password == "s3cr3t" 52 | _pass == "s3cr3t" 53 | passwd == "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 54 | pwd == "s3cr3t" 55 | secret == "s3cr3t" | -S105.py:54:8: S105 Possible hardcoded password assigned to: "pwd" +S105 Possible hardcoded password assigned to: "pwd" + --> S105.py:54:8 | 52 | _pass == "s3cr3t" 53 | passwd == "s3cr3t" 54 | pwd == "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 55 | secret == "s3cr3t" 56 | token == "s3cr3t" | -S105.py:55:11: S105 Possible hardcoded password assigned to: "secret" +S105 Possible hardcoded password assigned to: "secret" + --> S105.py:55:11 | 53 | passwd == "s3cr3t" 54 | pwd == "s3cr3t" 55 | secret == "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 56 | token == "s3cr3t" 57 | secrete == "s3cr3t" | -S105.py:56:10: S105 Possible hardcoded password assigned to: "token" +S105 Possible hardcoded password assigned to: "token" + --> S105.py:56:10 | 54 | pwd == "s3cr3t" 55 | secret == "s3cr3t" 56 | token == "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 57 | secrete == "s3cr3t" 58 | password == safe == "s3cr3t" | -S105.py:57:12: S105 Possible hardcoded password assigned to: "secrete" +S105 Possible hardcoded password assigned to: "secrete" + --> S105.py:57:12 | 55 | secret == "s3cr3t" 56 | token == "s3cr3t" 57 | secrete == "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 58 | password == safe == "s3cr3t" | -S105.py:58:21: S105 Possible hardcoded password assigned to: "password" +S105 Possible hardcoded password assigned to: "password" + --> S105.py:58:21 | 56 | token == "s3cr3t" 57 | secrete == "s3cr3t" 58 | password == safe == "s3cr3t" - | ^^^^^^^^ S105 + | ^^^^^^^^ 59 | 60 | if token == "1\n2": | -S105.py:60:13: S105 Possible hardcoded password assigned to: "token" +S105 Possible hardcoded password assigned to: "token" + --> S105.py:60:13 | 58 | password == safe == "s3cr3t" 59 | 60 | if token == "1\n2": - | ^^^^^^ S105 + | ^^^^^^ 61 | pass | -S105.py:63:13: S105 Possible hardcoded password assigned to: "token" +S105 Possible hardcoded password assigned to: "token" + --> S105.py:63:13 | 61 | pass 62 | 63 | if token == "3\t4": - | ^^^^^^ S105 + | ^^^^^^ 64 | pass | -S105.py:66:13: S105 Possible hardcoded password assigned to: "token" +S105 Possible hardcoded password assigned to: "token" + --> S105.py:66:13 | 64 | pass 65 | 66 | if token == "5\r6": - | ^^^^^^ S105 + | ^^^^^^ 67 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S106_S106.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S106_S106.py.snap index 06b8944aaf..3550dbb83a 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S106_S106.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S106_S106.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S106.py:14:9: S106 Possible hardcoded password assigned to argument: "password" +S106 Possible hardcoded password assigned to argument: "password" + --> S106.py:14:9 | 13 | # Error 14 | func(1, password="s3cr3t") - | ^^^^^^^^^^^^^^^^^ S106 + | ^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S107_S107.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S107_S107.py.snap index 05ef29a254..ae2b98ac41 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S107_S107.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S107_S107.py.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S107.py:5:29: S107 Possible hardcoded password assigned to function default: "password" +S107 Possible hardcoded password assigned to function default: "password" + --> S107.py:5:29 | 5 | def default(first, password="default"): - | ^^^^^^^^^ S107 + | ^^^^^^^^^ 6 | pass | -S107.py:13:45: S107 Possible hardcoded password assigned to function default: "password" +S107 Possible hardcoded password assigned to function default: "password" + --> S107.py:13:45 | 13 | def default_posonly(first, /, pos, password="posonly"): - | ^^^^^^^^^ S107 + | ^^^^^^^^^ 14 | pass | -S107.py:21:39: S107 Possible hardcoded password assigned to function default: "password" +S107 Possible hardcoded password assigned to function default: "password" + --> S107.py:21:39 | 21 | def default_kwonly(first, *, password="kwonly"): - | ^^^^^^^^ S107 + | ^^^^^^^^ 22 | pass | -S107.py:29:39: S107 Possible hardcoded password assigned to function default: "secret" +S107 Possible hardcoded password assigned to function default: "secret" + --> S107.py:29:39 | 29 | def default_all(first, /, pos, secret="posonly", *, password="kwonly"): - | ^^^^^^^^^ S107 + | ^^^^^^^^^ 30 | pass | -S107.py:29:62: S107 Possible hardcoded password assigned to function default: "password" +S107 Possible hardcoded password assigned to function default: "password" + --> S107.py:29:62 | 29 | def default_all(first, /, pos, secret="posonly", *, password="kwonly"): - | ^^^^^^^^ S107 + | ^^^^^^^^ 30 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap index 2b601edf61..c21f0824bd 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap @@ -1,64 +1,71 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:5:11 | 3 | f.write("def") 4 | 5 | with open("/tmp/abc", "w") as f: - | ^^^^^^^^^^ S108 + | ^^^^^^^^^^ 6 | f.write("def") | -S108.py:8:13: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:8:13 | 6 | f.write("def") 7 | 8 | with open(f"/tmp/abc", "w") as f: - | ^^^^^^^^ S108 + | ^^^^^^^^ 9 | f.write("def") | -S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" +S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" + --> S108.py:11:11 | 9 | f.write("def") 10 | 11 | with open("/var/tmp/123", "w") as f: - | ^^^^^^^^^^^^^^ S108 + | ^^^^^^^^^^^^^^ 12 | f.write("def") | -S108.py:14:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" +S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" + --> S108.py:14:11 | 12 | f.write("def") 13 | 14 | with open("/dev/shm/unit/test", "w") as f: - | ^^^^^^^^^^^^^^^^^^^^ S108 + | ^^^^^^^^^^^^^^^^^^^^ 15 | f.write("def") | -S108.py:22:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:22:11 | 21 | # Implicit string concatenation 22 | with open("/tmp/" "abc", "w") as f: - | ^^^^^^^^^^^^^ S108 + | ^^^^^^^^^^^^^ 23 | f.write("def") | -S108.py:25:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:25:11 | 23 | f.write("def") 24 | 25 | with open("/tmp/abc" f"/tmp/abc", "w") as f: - | ^^^^^^^^^^ S108 + | ^^^^^^^^^^ 26 | f.write("def") | -S108.py:25:24: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:25:24 | 23 | f.write("def") 24 | 25 | with open("/tmp/abc" f"/tmp/abc", "w") as f: - | ^^^^^^^^ S108 + | ^^^^^^^^ 26 | f.write("def") | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap index bcaf957a3d..65f5392730 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap @@ -1,72 +1,80 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:5:11 | 3 | f.write("def") 4 | 5 | with open("/tmp/abc", "w") as f: - | ^^^^^^^^^^ S108 + | ^^^^^^^^^^ 6 | f.write("def") | -S108.py:8:13: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:8:13 | 6 | f.write("def") 7 | 8 | with open(f"/tmp/abc", "w") as f: - | ^^^^^^^^ S108 + | ^^^^^^^^ 9 | f.write("def") | -S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" +S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" + --> S108.py:11:11 | 9 | f.write("def") 10 | 11 | with open("/var/tmp/123", "w") as f: - | ^^^^^^^^^^^^^^ S108 + | ^^^^^^^^^^^^^^ 12 | f.write("def") | -S108.py:14:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" +S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" + --> S108.py:14:11 | 12 | f.write("def") 13 | 14 | with open("/dev/shm/unit/test", "w") as f: - | ^^^^^^^^^^^^^^^^^^^^ S108 + | ^^^^^^^^^^^^^^^^^^^^ 15 | f.write("def") | -S108.py:18:11: S108 Probable insecure usage of temporary file or directory: "/foo/bar" +S108 Probable insecure usage of temporary file or directory: "/foo/bar" + --> S108.py:18:11 | 17 | # not ok by config 18 | with open("/foo/bar", "w") as f: - | ^^^^^^^^^^ S108 + | ^^^^^^^^^^ 19 | f.write("def") | -S108.py:22:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:22:11 | 21 | # Implicit string concatenation 22 | with open("/tmp/" "abc", "w") as f: - | ^^^^^^^^^^^^^ S108 + | ^^^^^^^^^^^^^ 23 | f.write("def") | -S108.py:25:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:25:11 | 23 | f.write("def") 24 | 25 | with open("/tmp/abc" f"/tmp/abc", "w") as f: - | ^^^^^^^^^^ S108 + | ^^^^^^^^^^ 26 | f.write("def") | -S108.py:25:24: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" +S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + --> S108.py:25:24 | 23 | f.write("def") 24 | 25 | with open("/tmp/abc" f"/tmp/abc", "w") as f: - | ^^^^^^^^ S108 + | ^^^^^^^^ 26 | f.write("def") | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap index ecf235771f..571b29c1bf 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception +S110 `try`-`except`-`pass` detected, consider logging the exception + --> S110.py:3:1 | 1 | try: 2 | pass 3 | / except Exception: 4 | | pass - | |________^ S110 + | |________^ 5 | 6 | try: | -S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception +S110 `try`-`except`-`pass` detected, consider logging the exception + --> S110.py:8:1 | 6 | try: 7 | pass 8 | / except: 9 | | pass - | |________^ S110 + | |________^ 10 | 11 | try: | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap index a0971f71ad..948db1015b 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap @@ -1,33 +1,36 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception +S110 `try`-`except`-`pass` detected, consider logging the exception + --> S110.py:3:1 | 1 | try: 2 | pass 3 | / except Exception: 4 | | pass - | |________^ S110 + | |________^ 5 | 6 | try: | -S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception +S110 `try`-`except`-`pass` detected, consider logging the exception + --> S110.py:8:1 | 6 | try: 7 | pass 8 | / except: 9 | | pass - | |________^ S110 + | |________^ 10 | 11 | try: | -S110.py:13:1: S110 `try`-`except`-`pass` detected, consider logging the exception +S110 `try`-`except`-`pass` detected, consider logging the exception + --> S110.py:13:1 | 11 | try: 12 | pass 13 | / except ValueError: 14 | | pass - | |________^ S110 + | |________^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap index 2159815d39..b874b6df40 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap @@ -1,46 +1,50 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S112.py:4:5: S112 `try`-`except`-`continue` detected, consider logging the exception +S112 `try`-`except`-`continue` detected, consider logging the exception + --> S112.py:4:5 | 2 | try: 3 | pass 4 | / except Exception: 5 | | continue - | |________________^ S112 + | |________________^ 6 | 7 | try: | -S112.py:9:5: S112 `try`-`except`-`continue` detected, consider logging the exception +S112 `try`-`except`-`continue` detected, consider logging the exception + --> S112.py:9:5 | 7 | try: 8 | pass 9 | / except: 10 | | continue - | |________________^ S112 + | |________________^ 11 | 12 | try: | -S112.py:14:5: S112 `try`-`except`-`continue` detected, consider logging the exception +S112 `try`-`except`-`continue` detected, consider logging the exception + --> S112.py:14:5 | 12 | try: 13 | pass 14 | / except (Exception,): 15 | | continue - | |________________^ S112 + | |________________^ 16 | 17 | try: | -S112.py:19:5: S112 `try`-`except`-`continue` detected, consider logging the exception +S112 `try`-`except`-`continue` detected, consider logging the exception + --> S112.py:19:5 | 17 | try: 18 | pass 19 | / except (Exception, ValueError): 20 | | continue - | |________________^ S112 + | |________________^ 21 | 22 | try: | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap index 9ae00a6a68..c4f4ee11de 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap @@ -1,237 +1,261 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S113.py:46:1: S113 Probable use of `requests` call without timeout +S113 Probable use of `requests` call without timeout + --> S113.py:46:1 | 45 | # Errors 46 | requests.get('https://gmail.com') - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 47 | requests.get('https://gmail.com', timeout=None) 48 | requests.post('https://gmail.com') | -S113.py:47:35: S113 Probable use of `requests` call with timeout set to `None` +S113 Probable use of `requests` call with timeout set to `None` + --> S113.py:47:35 | 45 | # Errors 46 | requests.get('https://gmail.com') 47 | requests.get('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 48 | requests.post('https://gmail.com') 49 | requests.post('https://gmail.com', timeout=None) | -S113.py:48:1: S113 Probable use of `requests` call without timeout +S113 Probable use of `requests` call without timeout + --> S113.py:48:1 | 46 | requests.get('https://gmail.com') 47 | requests.get('https://gmail.com', timeout=None) 48 | requests.post('https://gmail.com') - | ^^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^^ 49 | requests.post('https://gmail.com', timeout=None) 50 | requests.put('https://gmail.com') | -S113.py:49:36: S113 Probable use of `requests` call with timeout set to `None` +S113 Probable use of `requests` call with timeout set to `None` + --> S113.py:49:36 | 47 | requests.get('https://gmail.com', timeout=None) 48 | requests.post('https://gmail.com') 49 | requests.post('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 50 | requests.put('https://gmail.com') 51 | requests.put('https://gmail.com', timeout=None) | -S113.py:50:1: S113 Probable use of `requests` call without timeout +S113 Probable use of `requests` call without timeout + --> S113.py:50:1 | 48 | requests.post('https://gmail.com') 49 | requests.post('https://gmail.com', timeout=None) 50 | requests.put('https://gmail.com') - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 51 | requests.put('https://gmail.com', timeout=None) 52 | requests.delete('https://gmail.com') | -S113.py:51:35: S113 Probable use of `requests` call with timeout set to `None` +S113 Probable use of `requests` call with timeout set to `None` + --> S113.py:51:35 | 49 | requests.post('https://gmail.com', timeout=None) 50 | requests.put('https://gmail.com') 51 | requests.put('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 52 | requests.delete('https://gmail.com') 53 | requests.delete('https://gmail.com', timeout=None) | -S113.py:52:1: S113 Probable use of `requests` call without timeout +S113 Probable use of `requests` call without timeout + --> S113.py:52:1 | 50 | requests.put('https://gmail.com') 51 | requests.put('https://gmail.com', timeout=None) 52 | requests.delete('https://gmail.com') - | ^^^^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^^^^ 53 | requests.delete('https://gmail.com', timeout=None) 54 | requests.patch('https://gmail.com') | -S113.py:53:38: S113 Probable use of `requests` call with timeout set to `None` +S113 Probable use of `requests` call with timeout set to `None` + --> S113.py:53:38 | 51 | requests.put('https://gmail.com', timeout=None) 52 | requests.delete('https://gmail.com') 53 | requests.delete('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 54 | requests.patch('https://gmail.com') 55 | requests.patch('https://gmail.com', timeout=None) | -S113.py:54:1: S113 Probable use of `requests` call without timeout +S113 Probable use of `requests` call without timeout + --> S113.py:54:1 | 52 | requests.delete('https://gmail.com') 53 | requests.delete('https://gmail.com', timeout=None) 54 | requests.patch('https://gmail.com') - | ^^^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^^^ 55 | requests.patch('https://gmail.com', timeout=None) 56 | requests.options('https://gmail.com') | -S113.py:55:37: S113 Probable use of `requests` call with timeout set to `None` +S113 Probable use of `requests` call with timeout set to `None` + --> S113.py:55:37 | 53 | requests.delete('https://gmail.com', timeout=None) 54 | requests.patch('https://gmail.com') 55 | requests.patch('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 56 | requests.options('https://gmail.com') 57 | requests.options('https://gmail.com', timeout=None) | -S113.py:56:1: S113 Probable use of `requests` call without timeout +S113 Probable use of `requests` call without timeout + --> S113.py:56:1 | 54 | requests.patch('https://gmail.com') 55 | requests.patch('https://gmail.com', timeout=None) 56 | requests.options('https://gmail.com') - | ^^^^^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^^^^^ 57 | requests.options('https://gmail.com', timeout=None) 58 | requests.head('https://gmail.com') | -S113.py:57:39: S113 Probable use of `requests` call with timeout set to `None` +S113 Probable use of `requests` call with timeout set to `None` + --> S113.py:57:39 | 55 | requests.patch('https://gmail.com', timeout=None) 56 | requests.options('https://gmail.com') 57 | requests.options('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 58 | requests.head('https://gmail.com') 59 | requests.head('https://gmail.com', timeout=None) | -S113.py:58:1: S113 Probable use of `requests` call without timeout +S113 Probable use of `requests` call without timeout + --> S113.py:58:1 | 56 | requests.options('https://gmail.com') 57 | requests.options('https://gmail.com', timeout=None) 58 | requests.head('https://gmail.com') - | ^^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^^ 59 | requests.head('https://gmail.com', timeout=None) | -S113.py:59:36: S113 Probable use of `requests` call with timeout set to `None` +S113 Probable use of `requests` call with timeout set to `None` + --> S113.py:59:36 | 57 | requests.options('https://gmail.com', timeout=None) 58 | requests.head('https://gmail.com') 59 | requests.head('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 60 | 61 | httpx.get('https://gmail.com', timeout=None) | -S113.py:61:32: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:61:32 | 59 | requests.head('https://gmail.com', timeout=None) 60 | 61 | httpx.get('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 62 | httpx.post('https://gmail.com', timeout=None) 63 | httpx.put('https://gmail.com', timeout=None) | -S113.py:62:33: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:62:33 | 61 | httpx.get('https://gmail.com', timeout=None) 62 | httpx.post('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 63 | httpx.put('https://gmail.com', timeout=None) 64 | httpx.delete('https://gmail.com', timeout=None) | -S113.py:63:32: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:63:32 | 61 | httpx.get('https://gmail.com', timeout=None) 62 | httpx.post('https://gmail.com', timeout=None) 63 | httpx.put('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 64 | httpx.delete('https://gmail.com', timeout=None) 65 | httpx.patch('https://gmail.com', timeout=None) | -S113.py:64:35: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:64:35 | 62 | httpx.post('https://gmail.com', timeout=None) 63 | httpx.put('https://gmail.com', timeout=None) 64 | httpx.delete('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 65 | httpx.patch('https://gmail.com', timeout=None) 66 | httpx.options('https://gmail.com', timeout=None) | -S113.py:65:34: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:65:34 | 63 | httpx.put('https://gmail.com', timeout=None) 64 | httpx.delete('https://gmail.com', timeout=None) 65 | httpx.patch('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 66 | httpx.options('https://gmail.com', timeout=None) 67 | httpx.head('https://gmail.com', timeout=None) | -S113.py:66:36: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:66:36 | 64 | httpx.delete('https://gmail.com', timeout=None) 65 | httpx.patch('https://gmail.com', timeout=None) 66 | httpx.options('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 67 | httpx.head('https://gmail.com', timeout=None) 68 | httpx.Client(timeout=None) | -S113.py:67:33: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:67:33 | 65 | httpx.patch('https://gmail.com', timeout=None) 66 | httpx.options('https://gmail.com', timeout=None) 67 | httpx.head('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 68 | httpx.Client(timeout=None) 69 | httpx.AsyncClient(timeout=None) | -S113.py:68:14: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:68:14 | 66 | httpx.options('https://gmail.com', timeout=None) 67 | httpx.head('https://gmail.com', timeout=None) 68 | httpx.Client(timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 69 | httpx.AsyncClient(timeout=None) | -S113.py:69:19: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:69:19 | 67 | httpx.head('https://gmail.com', timeout=None) 68 | httpx.Client(timeout=None) 69 | httpx.AsyncClient(timeout=None) - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 70 | 71 | with httpx.Client(timeout=None) as client: | -S113.py:71:19: S113 Probable use of `httpx` call with timeout set to `None` +S113 Probable use of `httpx` call with timeout set to `None` + --> S113.py:71:19 | 69 | httpx.AsyncClient(timeout=None) 70 | 71 | with httpx.Client(timeout=None) as client: - | ^^^^^^^^^^^^ S113 + | ^^^^^^^^^^^^ 72 | client.get('https://gmail.com') | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap index 11115cc0ba..584b1f8b75 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S201.py:10:9: S201 Use of `debug=True` in Flask app detected +S201 Use of `debug=True` in Flask app detected + --> S201.py:10:9 | 9 | # OK 10 | app.run(debug=True) - | ^^^^^^^^^^ S201 + | ^^^^^^^^^^ 11 | 12 | # Errors | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S202_S202.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S202_S202.py.snap index 711d7de30b..965dd832fe 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S202_S202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S202_S202.py.snap @@ -1,48 +1,52 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S202.py:8:5: S202 Uses of `tarfile.extractall()` +S202 Uses of `tarfile.extractall()` + --> S202.py:8:5 | 6 | def unsafe_archive_handler(filename): 7 | tar = tarfile.open(filename) 8 | tar.extractall(path=tempfile.mkdtemp()) - | ^^^^^^^^^^^^^^ S202 + | ^^^^^^^^^^^^^^ 9 | tar.close() | -S202.py:14:5: S202 Uses of `tarfile.extractall()` +S202 Uses of `tarfile.extractall()` + --> S202.py:14:5 | 12 | def managed_members_archive_handler(filename): 13 | tar = tarfile.open(filename) 14 | tar.extractall(path=tempfile.mkdtemp(), members=members_filter(tar)) - | ^^^^^^^^^^^^^^ S202 + | ^^^^^^^^^^^^^^ 15 | tar.close() | -S202.py:20:5: S202 Uses of `tarfile.extractall()` +S202 Uses of `tarfile.extractall()` + --> S202.py:20:5 | 18 | def list_members_archive_handler(filename): 19 | tar = tarfile.open(filename) 20 | tar.extractall(path=tempfile.mkdtemp(), members=[]) - | ^^^^^^^^^^^^^^ S202 + | ^^^^^^^^^^^^^^ 21 | tar.close() | -S202.py:26:5: S202 Uses of `tarfile.extractall()` +S202 Uses of `tarfile.extractall()` + --> S202.py:26:5 | 24 | def provided_members_archive_handler(filename): 25 | tar = tarfile.open(filename) 26 | tarfile.extractall(path=tempfile.mkdtemp(), members=tar) - | ^^^^^^^^^^^^^^^^^^ S202 + | ^^^^^^^^^^^^^^^^^^ 27 | tar.close() | -S202.py:38:5: S202 Uses of `tarfile.extractall()` +S202 Uses of `tarfile.extractall()` + --> S202.py:38:5 | 36 | def filter_fully_trusted(filename): 37 | tar = tarfile.open(filename) 38 | tarfile.extractall(path=tempfile.mkdtemp(), filter="fully_trusted") - | ^^^^^^^^^^^^^^^^^^ S202 + | ^^^^^^^^^^^^^^^^^^ 39 | tar.close() | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap index 4e27b0d75b..c15dd78222 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S301.py:3:1: S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue +S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue + --> S301.py:3:1 | 1 | import pickle 2 | 3 | pickle.loads() - | ^^^^^^^^^^^^^^ S301 + | ^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap index 7d474f3d31..2c79297a12 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S307.py:3:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` +S307 Use of possibly insecure function; consider using `ast.literal_eval` + --> S307.py:3:7 | 1 | import os 2 | 3 | print(eval("1+1")) # S307 - | ^^^^^^^^^^^ S307 + | ^^^^^^^^^^^ 4 | print(eval("os.getcwd()")) # S307 | -S307.py:4:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` +S307 Use of possibly insecure function; consider using `ast.literal_eval` + --> S307.py:4:7 | 3 | print(eval("1+1")) # S307 4 | print(eval("os.getcwd()")) # S307 - | ^^^^^^^^^^^^^^^^^^^ S307 + | ^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S308_S308.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S308_S308.py.snap index f48701e74c..d631498e48 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S308_S308.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S308_S308.py.snap @@ -1,116 +1,128 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S308.py:6:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:6:5 | 4 | def bad_func(): 5 | inject = "harmful_input" 6 | mark_safe(inject) - | ^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^ 7 | mark_safe("I will add" + inject + "to my string") 8 | mark_safe("I will add %s to my string" % inject) | -S308.py:7:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:7:5 | 5 | inject = "harmful_input" 6 | mark_safe(inject) 7 | mark_safe("I will add" + inject + "to my string") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | mark_safe("I will add %s to my string" % inject) 9 | mark_safe("I will add {} to my string".format(inject)) | -S308.py:8:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:8:5 | 6 | mark_safe(inject) 7 | mark_safe("I will add" + inject + "to my string") 8 | mark_safe("I will add %s to my string" % inject) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | mark_safe("I will add {} to my string".format(inject)) 10 | mark_safe(f"I will add {inject} to my string") | -S308.py:9:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:9:5 | 7 | mark_safe("I will add" + inject + "to my string") 8 | mark_safe("I will add %s to my string" % inject) 9 | mark_safe("I will add {} to my string".format(inject)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | mark_safe(f"I will add {inject} to my string") | -S308.py:10:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:10:5 | 8 | mark_safe("I will add %s to my string" % inject) 9 | mark_safe("I will add {} to my string".format(inject)) 10 | mark_safe(f"I will add {inject} to my string") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | def good_func(): | -S308.py:16:1: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:16:1 | 16 | @mark_safe - | ^^^^^^^^^^ S308 + | ^^^^^^^^^^ 17 | def some_func(): 18 | return '' | -S308.py:26:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:26:5 | 24 | def bad_func(): 25 | inject = "harmful_input" 26 | mark_safe(inject) - | ^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^ 27 | mark_safe("I will add" + inject + "to my string") 28 | mark_safe("I will add %s to my string" % inject) | -S308.py:27:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:27:5 | 25 | inject = "harmful_input" 26 | mark_safe(inject) 27 | mark_safe("I will add" + inject + "to my string") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | mark_safe("I will add %s to my string" % inject) 29 | mark_safe("I will add {} to my string".format(inject)) | -S308.py:28:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:28:5 | 26 | mark_safe(inject) 27 | mark_safe("I will add" + inject + "to my string") 28 | mark_safe("I will add %s to my string" % inject) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | mark_safe("I will add {} to my string".format(inject)) 30 | mark_safe(f"I will add {inject} to my string") | -S308.py:29:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:29:5 | 27 | mark_safe("I will add" + inject + "to my string") 28 | mark_safe("I will add %s to my string" % inject) 29 | mark_safe("I will add {} to my string".format(inject)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | mark_safe(f"I will add {inject} to my string") | -S308.py:30:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:30:5 | 28 | mark_safe("I will add %s to my string" % inject) 29 | mark_safe("I will add {} to my string".format(inject)) 30 | mark_safe(f"I will add {inject} to my string") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | 32 | def good_func(): | -S308.py:36:1: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:36:1 | 36 | @mark_safe - | ^^^^^^^^^^ S308 + | ^^^^^^^^^^ 37 | def some_func(): 38 | return '' | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S310_S310.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S310_S310.py.snap index 1a90de58fa..4a4b61876e 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S310_S310.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S310_S310.py.snap @@ -1,232 +1,256 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S310.py:6:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:6:1 | 4 | urllib.request.urlopen(url=f'http://www.google.com') 5 | urllib.request.urlopen(url='http://' + 'www' + '.google.com') 6 | urllib.request.urlopen(url='http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | urllib.request.urlopen(url=f'http://www.google.com', **kwargs) 8 | urllib.request.urlopen('http://www.google.com') | -S310.py:7:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:7:1 | 5 | urllib.request.urlopen(url='http://' + 'www' + '.google.com') 6 | urllib.request.urlopen(url='http://www.google.com', **kwargs) 7 | urllib.request.urlopen(url=f'http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | urllib.request.urlopen('http://www.google.com') 9 | urllib.request.urlopen(f'http://www.google.com') | -S310.py:10:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:10:1 | 8 | urllib.request.urlopen('http://www.google.com') 9 | urllib.request.urlopen(f'http://www.google.com') 10 | urllib.request.urlopen('file:///foo/bar/baz') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | urllib.request.urlopen(url) | -S310.py:11:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:11:1 | 9 | urllib.request.urlopen(f'http://www.google.com') 10 | urllib.request.urlopen('file:///foo/bar/baz') 11 | urllib.request.urlopen(url) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | urllib.request.Request(url='http://www.google.com') | -S310.py:16:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:16:1 | 14 | urllib.request.Request(url=f'http://www.google.com') 15 | urllib.request.Request(url='http://' + 'www' + '.google.com') 16 | urllib.request.Request(url='http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | urllib.request.Request(url=f'http://www.google.com', **kwargs) 18 | urllib.request.Request('http://www.google.com') | -S310.py:17:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:17:1 | 15 | urllib.request.Request(url='http://' + 'www' + '.google.com') 16 | urllib.request.Request(url='http://www.google.com', **kwargs) 17 | urllib.request.Request(url=f'http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | urllib.request.Request('http://www.google.com') 19 | urllib.request.Request(f'http://www.google.com') | -S310.py:20:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:20:1 | 18 | urllib.request.Request('http://www.google.com') 19 | urllib.request.Request(f'http://www.google.com') 20 | urllib.request.Request('file:///foo/bar/baz') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | urllib.request.Request(url) | -S310.py:21:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:21:1 | 19 | urllib.request.Request(f'http://www.google.com') 20 | urllib.request.Request('file:///foo/bar/baz') 21 | urllib.request.Request(url) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') | -S310.py:23:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:23:1 | 21 | urllib.request.Request(url) 22 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') | -S310.py:24:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:24:1 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) | -S310.py:25:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:25:1 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) | -S310.py:26:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:26:1 | 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) 28 | urllib.request.URLopener().open('http://www.google.com') | -S310.py:27:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:27:1 | 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | urllib.request.URLopener().open('http://www.google.com') 29 | urllib.request.URLopener().open(f'http://www.google.com') | -S310.py:28:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:28:1 | 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) 28 | urllib.request.URLopener().open('http://www.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | urllib.request.URLopener().open(f'http://www.google.com') 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') | -S310.py:29:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:29:1 | 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) 28 | urllib.request.URLopener().open('http://www.google.com') 29 | urllib.request.URLopener().open(f'http://www.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') 31 | urllib.request.URLopener().open('file:///foo/bar/baz') | -S310.py:30:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:30:1 | 28 | urllib.request.URLopener().open('http://www.google.com') 29 | urllib.request.URLopener().open(f'http://www.google.com') 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | urllib.request.URLopener().open('file:///foo/bar/baz') 32 | urllib.request.URLopener().open(url) | -S310.py:31:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:31:1 | 29 | urllib.request.URLopener().open(f'http://www.google.com') 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') 31 | urllib.request.URLopener().open('file:///foo/bar/baz') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | urllib.request.URLopener().open(url) | -S310.py:32:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:32:1 | 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') 31 | urllib.request.URLopener().open('file:///foo/bar/baz') 32 | urllib.request.URLopener().open(url) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | 34 | urllib.request.urlopen(url=urllib.request.Request('http://www.google.com')) | -S310.py:37:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:37:1 | 35 | urllib.request.urlopen(url=urllib.request.Request(f'http://www.google.com')) 36 | urllib.request.urlopen(url=urllib.request.Request('http://' + 'www' + '.google.com')) 37 | urllib.request.urlopen(url=urllib.request.Request('http://www.google.com'), **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | urllib.request.urlopen(url=urllib.request.Request(f'http://www.google.com'), **kwargs) 39 | urllib.request.urlopen(urllib.request.Request('http://www.google.com')) | -S310.py:38:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:38:1 | 36 | urllib.request.urlopen(url=urllib.request.Request('http://' + 'www' + '.google.com')) 37 | urllib.request.urlopen(url=urllib.request.Request('http://www.google.com'), **kwargs) 38 | urllib.request.urlopen(url=urllib.request.Request(f'http://www.google.com'), **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | urllib.request.urlopen(urllib.request.Request('http://www.google.com')) 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) | -S310.py:41:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:41:1 | 39 | urllib.request.urlopen(urllib.request.Request('http://www.google.com')) 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) 41 | urllib.request.urlopen(urllib.request.Request('file:///foo/bar/baz')) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | urllib.request.urlopen(urllib.request.Request(url)) | -S310.py:41:24: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:41:24 | 39 | urllib.request.urlopen(urllib.request.Request('http://www.google.com')) 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) 41 | urllib.request.urlopen(urllib.request.Request('file:///foo/bar/baz')) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | urllib.request.urlopen(urllib.request.Request(url)) | -S310.py:42:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:42:1 | 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) 41 | urllib.request.urlopen(urllib.request.Request('file:///foo/bar/baz')) 42 | urllib.request.urlopen(urllib.request.Request(url)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -S310.py:42:24: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:42:24 | 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) 41 | urllib.request.urlopen(urllib.request.Request('file:///foo/bar/baz')) 42 | urllib.request.urlopen(urllib.request.Request(url)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S311_S311.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S311_S311.py.snap index 858f04e4a3..fb58851427 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S311_S311.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S311_S311.py.snap @@ -1,90 +1,99 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S311.py:10:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:10:1 | 9 | # Errors 10 | random.Random() - | ^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^ 11 | random.random() 12 | random.randrange() | -S311.py:11:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:11:1 | 9 | # Errors 10 | random.Random() 11 | random.random() - | ^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^ 12 | random.randrange() 13 | random.randint() | -S311.py:12:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:12:1 | 10 | random.Random() 11 | random.random() 12 | random.randrange() - | ^^^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^^^ 13 | random.randint() 14 | random.choice() | -S311.py:13:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:13:1 | 11 | random.random() 12 | random.randrange() 13 | random.randint() - | ^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^ 14 | random.choice() 15 | random.choices() | -S311.py:14:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:14:1 | 12 | random.randrange() 13 | random.randint() 14 | random.choice() - | ^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^ 15 | random.choices() 16 | random.uniform() | -S311.py:15:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:15:1 | 13 | random.randint() 14 | random.choice() 15 | random.choices() - | ^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^ 16 | random.uniform() 17 | random.triangular() | -S311.py:16:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:16:1 | 14 | random.choice() 15 | random.choices() 16 | random.uniform() - | ^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^ 17 | random.triangular() 18 | random.randbytes() | -S311.py:17:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:17:1 | 15 | random.choices() 16 | random.uniform() 17 | random.triangular() - | ^^^^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^^^^ 18 | random.randbytes() | -S311.py:18:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:18:1 | 16 | random.uniform() 17 | random.triangular() 18 | random.randbytes() - | ^^^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^^^ 19 | 20 | # Unrelated | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap index 93e90da5ce..f585796d40 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap @@ -1,19 +1,21 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S312.py:3:1: S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. +S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. + --> S312.py:3:1 | 1 | from telnetlib import Telnet 2 | 3 | Telnet("localhost", 23) - | ^^^^^^^^^^^^^^^^^^^^^^^ S312 + | ^^^^^^^^^^^^^^^^^^^^^^^ | -S312.py:14:24: S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. +S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. + --> S312.py:14:24 | 13 | from typing import Annotated 14 | foo: Annotated[Telnet, telnetlib.Telnet()] - | ^^^^^^^^^^^^^^^^^^ S312 + | ^^^^^^^^^^^^^^^^^^ 15 | 16 | def _() -> Telnet: ... | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap index a2a47b4b13..397ca12952 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap @@ -1,207 +1,228 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S324.py:7:13: S324 Probable use of insecure hash functions in `hashlib`: `md5` +S324 Probable use of insecure hash functions in `hashlib`: `md5` + --> S324.py:7:13 | 6 | # Errors 7 | hashlib.new('md5') - | ^^^^^ S324 + | ^^^^^ 8 | hashlib.new('md4', b'test') 9 | hashlib.new(name='md5', data=b'test') | -S324.py:8:13: S324 Probable use of insecure hash functions in `hashlib`: `md4` +S324 Probable use of insecure hash functions in `hashlib`: `md4` + --> S324.py:8:13 | 6 | # Errors 7 | hashlib.new('md5') 8 | hashlib.new('md4', b'test') - | ^^^^^ S324 + | ^^^^^ 9 | hashlib.new(name='md5', data=b'test') 10 | hashlib.new('MD4', data=b'test') | -S324.py:9:18: S324 Probable use of insecure hash functions in `hashlib`: `md5` +S324 Probable use of insecure hash functions in `hashlib`: `md5` + --> S324.py:9:18 | 7 | hashlib.new('md5') 8 | hashlib.new('md4', b'test') 9 | hashlib.new(name='md5', data=b'test') - | ^^^^^ S324 + | ^^^^^ 10 | hashlib.new('MD4', data=b'test') 11 | hashlib.new('sha1') | -S324.py:10:13: S324 Probable use of insecure hash functions in `hashlib`: `MD4` +S324 Probable use of insecure hash functions in `hashlib`: `MD4` + --> S324.py:10:13 | 8 | hashlib.new('md4', b'test') 9 | hashlib.new(name='md5', data=b'test') 10 | hashlib.new('MD4', data=b'test') - | ^^^^^ S324 + | ^^^^^ 11 | hashlib.new('sha1') 12 | hashlib.new('sha1', data=b'test') | -S324.py:11:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` +S324 Probable use of insecure hash functions in `hashlib`: `sha1` + --> S324.py:11:13 | 9 | hashlib.new(name='md5', data=b'test') 10 | hashlib.new('MD4', data=b'test') 11 | hashlib.new('sha1') - | ^^^^^^ S324 + | ^^^^^^ 12 | hashlib.new('sha1', data=b'test') 13 | hashlib.new('sha', data=b'test') | -S324.py:12:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` +S324 Probable use of insecure hash functions in `hashlib`: `sha1` + --> S324.py:12:13 | 10 | hashlib.new('MD4', data=b'test') 11 | hashlib.new('sha1') 12 | hashlib.new('sha1', data=b'test') - | ^^^^^^ S324 + | ^^^^^^ 13 | hashlib.new('sha', data=b'test') 14 | hashlib.new(name='SHA', data=b'test') | -S324.py:13:13: S324 Probable use of insecure hash functions in `hashlib`: `sha` +S324 Probable use of insecure hash functions in `hashlib`: `sha` + --> S324.py:13:13 | 11 | hashlib.new('sha1') 12 | hashlib.new('sha1', data=b'test') 13 | hashlib.new('sha', data=b'test') - | ^^^^^ S324 + | ^^^^^ 14 | hashlib.new(name='SHA', data=b'test') 15 | hashlib.sha(data=b'test') | -S324.py:14:18: S324 Probable use of insecure hash functions in `hashlib`: `SHA` +S324 Probable use of insecure hash functions in `hashlib`: `SHA` + --> S324.py:14:18 | 12 | hashlib.new('sha1', data=b'test') 13 | hashlib.new('sha', data=b'test') 14 | hashlib.new(name='SHA', data=b'test') - | ^^^^^ S324 + | ^^^^^ 15 | hashlib.sha(data=b'test') 16 | hashlib.md5() | -S324.py:15:1: S324 Probable use of insecure hash functions in `hashlib`: `sha` +S324 Probable use of insecure hash functions in `hashlib`: `sha` + --> S324.py:15:1 | 13 | hashlib.new('sha', data=b'test') 14 | hashlib.new(name='SHA', data=b'test') 15 | hashlib.sha(data=b'test') - | ^^^^^^^^^^^ S324 + | ^^^^^^^^^^^ 16 | hashlib.md5() 17 | hashlib_new('sha1') | -S324.py:16:1: S324 Probable use of insecure hash functions in `hashlib`: `md5` +S324 Probable use of insecure hash functions in `hashlib`: `md5` + --> S324.py:16:1 | 14 | hashlib.new(name='SHA', data=b'test') 15 | hashlib.sha(data=b'test') 16 | hashlib.md5() - | ^^^^^^^^^^^ S324 + | ^^^^^^^^^^^ 17 | hashlib_new('sha1') 18 | hashlib_sha1('sha1') | -S324.py:17:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` +S324 Probable use of insecure hash functions in `hashlib`: `sha1` + --> S324.py:17:13 | 15 | hashlib.sha(data=b'test') 16 | hashlib.md5() 17 | hashlib_new('sha1') - | ^^^^^^ S324 + | ^^^^^^ 18 | hashlib_sha1('sha1') 19 | # usedforsecurity arg only available in Python 3.9+ | -S324.py:18:1: S324 Probable use of insecure hash functions in `hashlib`: `sha1` +S324 Probable use of insecure hash functions in `hashlib`: `sha1` + --> S324.py:18:1 | 16 | hashlib.md5() 17 | hashlib_new('sha1') 18 | hashlib_sha1('sha1') - | ^^^^^^^^^^^^ S324 + | ^^^^^^^^^^^^ 19 | # usedforsecurity arg only available in Python 3.9+ 20 | hashlib.new('sha1', usedforsecurity=True) | -S324.py:20:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` +S324 Probable use of insecure hash functions in `hashlib`: `sha1` + --> S324.py:20:13 | 18 | hashlib_sha1('sha1') 19 | # usedforsecurity arg only available in Python 3.9+ 20 | hashlib.new('sha1', usedforsecurity=True) - | ^^^^^^ S324 + | ^^^^^^ 21 | 22 | crypt.crypt("test", salt=crypt.METHOD_CRYPT) | -S324.py:22:26: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_CRYPT` +S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_CRYPT` + --> S324.py:22:26 | 20 | hashlib.new('sha1', usedforsecurity=True) 21 | 22 | crypt.crypt("test", salt=crypt.METHOD_CRYPT) - | ^^^^^^^^^^^^^^^^^^ S324 + | ^^^^^^^^^^^^^^^^^^ 23 | crypt.crypt("test", salt=crypt.METHOD_MD5) 24 | crypt.crypt("test", salt=crypt.METHOD_BLOWFISH) | -S324.py:23:26: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_MD5` +S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_MD5` + --> S324.py:23:26 | 22 | crypt.crypt("test", salt=crypt.METHOD_CRYPT) 23 | crypt.crypt("test", salt=crypt.METHOD_MD5) - | ^^^^^^^^^^^^^^^^ S324 + | ^^^^^^^^^^^^^^^^ 24 | crypt.crypt("test", salt=crypt.METHOD_BLOWFISH) 25 | crypt.crypt("test", crypt.METHOD_BLOWFISH) | -S324.py:24:26: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_BLOWFISH` +S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_BLOWFISH` + --> S324.py:24:26 | 22 | crypt.crypt("test", salt=crypt.METHOD_CRYPT) 23 | crypt.crypt("test", salt=crypt.METHOD_MD5) 24 | crypt.crypt("test", salt=crypt.METHOD_BLOWFISH) - | ^^^^^^^^^^^^^^^^^^^^^ S324 + | ^^^^^^^^^^^^^^^^^^^^^ 25 | crypt.crypt("test", crypt.METHOD_BLOWFISH) | -S324.py:25:21: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_BLOWFISH` +S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_BLOWFISH` + --> S324.py:25:21 | 23 | crypt.crypt("test", salt=crypt.METHOD_MD5) 24 | crypt.crypt("test", salt=crypt.METHOD_BLOWFISH) 25 | crypt.crypt("test", crypt.METHOD_BLOWFISH) - | ^^^^^^^^^^^^^^^^^^^^^ S324 + | ^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | crypt.mksalt(crypt.METHOD_CRYPT) | -S324.py:27:14: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_CRYPT` +S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_CRYPT` + --> S324.py:27:14 | 25 | crypt.crypt("test", crypt.METHOD_BLOWFISH) 26 | 27 | crypt.mksalt(crypt.METHOD_CRYPT) - | ^^^^^^^^^^^^^^^^^^ S324 + | ^^^^^^^^^^^^^^^^^^ 28 | crypt.mksalt(crypt.METHOD_MD5) 29 | crypt.mksalt(crypt.METHOD_BLOWFISH) | -S324.py:28:14: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_MD5` +S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_MD5` + --> S324.py:28:14 | 27 | crypt.mksalt(crypt.METHOD_CRYPT) 28 | crypt.mksalt(crypt.METHOD_MD5) - | ^^^^^^^^^^^^^^^^ S324 + | ^^^^^^^^^^^^^^^^ 29 | crypt.mksalt(crypt.METHOD_BLOWFISH) | -S324.py:29:14: S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_BLOWFISH` +S324 Probable use of insecure hash functions in `crypt`: `crypt.METHOD_BLOWFISH` + --> S324.py:29:14 | 27 | crypt.mksalt(crypt.METHOD_CRYPT) 28 | crypt.mksalt(crypt.METHOD_MD5) 29 | crypt.mksalt(crypt.METHOD_BLOWFISH) - | ^^^^^^^^^^^^^^^^^^^^^ S324 + | ^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | # OK | -S324.py:51:13: S324 Probable use of insecure hash functions in `hashlib`: `Md5` +S324 Probable use of insecure hash functions in `hashlib`: `Md5` + --> S324.py:51:13 | 49 | # From issue: https://github.com/astral-sh/ruff/issues/16525#issuecomment-2706188584 50 | # Errors 51 | hashlib.new("Md5") - | ^^^^^ S324 + | ^^^^^ 52 | 53 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S401_S401.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S401_S401.py.snap index 8079727d4d..ab44b4f761 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S401_S401.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S401_S401.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S401.py:1:8: S401 `telnetlib` and related modules are considered insecure. Use SSH or another encrypted protocol. +S401 `telnetlib` and related modules are considered insecure. Use SSH or another encrypted protocol. + --> S401.py:1:8 | 1 | import telnetlib # S401 - | ^^^^^^^^^ S401 + | ^^^^^^^^^ 2 | from telnetlib import Telnet # S401 | -S401.py:2:6: S401 `telnetlib` and related modules are considered insecure. Use SSH or another encrypted protocol. +S401 `telnetlib` and related modules are considered insecure. Use SSH or another encrypted protocol. + --> S401.py:2:6 | 1 | import telnetlib # S401 2 | from telnetlib import Telnet # S401 - | ^^^^^^^^^ S401 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S402_S402.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S402_S402.py.snap index 96383582dc..a264f60e5f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S402_S402.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S402_S402.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S402.py:1:8: S402 `ftplib` and related modules are considered insecure. Use SSH, SFTP, SCP, or another encrypted protocol. +S402 `ftplib` and related modules are considered insecure. Use SSH, SFTP, SCP, or another encrypted protocol. + --> S402.py:1:8 | 1 | import ftplib # S402 - | ^^^^^^ S402 + | ^^^^^^ 2 | from ftplib import FTP # S402 | -S402.py:2:6: S402 `ftplib` and related modules are considered insecure. Use SSH, SFTP, SCP, or another encrypted protocol. +S402 `ftplib` and related modules are considered insecure. Use SSH, SFTP, SCP, or another encrypted protocol. + --> S402.py:2:6 | 1 | import ftplib # S402 2 | from ftplib import FTP # S402 - | ^^^^^^ S402 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S403_S403.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S403_S403.py.snap index 23b2b90a22..bb3e712c16 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S403_S403.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S403_S403.py.snap @@ -1,77 +1,84 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S403.py:1:8: S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure +S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure + --> S403.py:1:8 | 1 | import dill # S403 - | ^^^^ S403 + | ^^^^ 2 | from dill import objects # S403 3 | import shelve | -S403.py:2:6: S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure +S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure + --> S403.py:2:6 | 1 | import dill # S403 2 | from dill import objects # S403 - | ^^^^ S403 + | ^^^^ 3 | import shelve 4 | from shelve import open | -S403.py:3:8: S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure +S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure + --> S403.py:3:8 | 1 | import dill # S403 2 | from dill import objects # S403 3 | import shelve - | ^^^^^^ S403 + | ^^^^^^ 4 | from shelve import open 5 | import cPickle | -S403.py:4:6: S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure +S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure + --> S403.py:4:6 | 2 | from dill import objects # S403 3 | import shelve 4 | from shelve import open - | ^^^^^^ S403 + | ^^^^^^ 5 | import cPickle 6 | from cPickle import load | -S403.py:5:8: S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure +S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure + --> S403.py:5:8 | 3 | import shelve 4 | from shelve import open 5 | import cPickle - | ^^^^^^^ S403 + | ^^^^^^^ 6 | from cPickle import load 7 | import pickle | -S403.py:6:6: S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure +S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure + --> S403.py:6:6 | 4 | from shelve import open 5 | import cPickle 6 | from cPickle import load - | ^^^^^^^ S403 + | ^^^^^^^ 7 | import pickle 8 | from pickle import load | -S403.py:7:8: S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure +S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure + --> S403.py:7:8 | 5 | import cPickle 6 | from cPickle import load 7 | import pickle - | ^^^^^^ S403 + | ^^^^^^ 8 | from pickle import load | -S403.py:8:6: S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure +S403 `pickle`, `cPickle`, `dill`, and `shelve` modules are possibly insecure + --> S403.py:8:6 | 6 | from cPickle import load 7 | import pickle 8 | from pickle import load - | ^^^^^^ S403 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S404_S404.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S404_S404.py.snap index d63505043c..26db33929d 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S404_S404.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S404_S404.py.snap @@ -1,27 +1,29 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S404.py:1:8: S404 `subprocess` module is possibly insecure +S404 `subprocess` module is possibly insecure + --> S404.py:1:8 | 1 | import subprocess # S404 - | ^^^^^^^^^^ S404 + | ^^^^^^^^^^ 2 | from subprocess import Popen # S404 3 | from subprocess import Popen as pop # S404 | -S404.py:2:6: S404 `subprocess` module is possibly insecure +S404 `subprocess` module is possibly insecure + --> S404.py:2:6 | 1 | import subprocess # S404 2 | from subprocess import Popen # S404 - | ^^^^^^^^^^ S404 + | ^^^^^^^^^^ 3 | from subprocess import Popen as pop # S404 | -S404.py:3:6: S404 `subprocess` module is possibly insecure +S404 `subprocess` module is possibly insecure + --> S404.py:3:6 | 1 | import subprocess # S404 2 | from subprocess import Popen # S404 3 | from subprocess import Popen as pop # S404 - | ^^^^^^^^^^ S404 + | ^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S405_S405.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S405_S405.py.snap index ccd188524f..8589ad87fe 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S405_S405.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S405_S405.py.snap @@ -1,37 +1,40 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S405.py:1:8: S405 `xml.etree` methods are vulnerable to XML attacks +S405 `xml.etree` methods are vulnerable to XML attacks + --> S405.py:1:8 | 1 | import xml.etree.cElementTree # S405 - | ^^^^^^^^^^^^^^^^^^^^^^ S405 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | from xml.etree import cElementTree # S405 3 | import xml.etree.ElementTree # S405 | -S405.py:2:6: S405 `xml.etree` methods are vulnerable to XML attacks +S405 `xml.etree` methods are vulnerable to XML attacks + --> S405.py:2:6 | 1 | import xml.etree.cElementTree # S405 2 | from xml.etree import cElementTree # S405 - | ^^^^^^^^^ S405 + | ^^^^^^^^^ 3 | import xml.etree.ElementTree # S405 4 | from xml.etree import ElementTree # S405 | -S405.py:3:8: S405 `xml.etree` methods are vulnerable to XML attacks +S405 `xml.etree` methods are vulnerable to XML attacks + --> S405.py:3:8 | 1 | import xml.etree.cElementTree # S405 2 | from xml.etree import cElementTree # S405 3 | import xml.etree.ElementTree # S405 - | ^^^^^^^^^^^^^^^^^^^^^ S405 + | ^^^^^^^^^^^^^^^^^^^^^ 4 | from xml.etree import ElementTree # S405 | -S405.py:4:6: S405 `xml.etree` methods are vulnerable to XML attacks +S405 `xml.etree` methods are vulnerable to XML attacks + --> S405.py:4:6 | 2 | from xml.etree import cElementTree # S405 3 | import xml.etree.ElementTree # S405 4 | from xml.etree import ElementTree # S405 - | ^^^^^^^^^ S405 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S406_S406.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S406_S406.py.snap index 09c4b4e2a1..4935a4a321 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S406_S406.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S406_S406.py.snap @@ -1,27 +1,29 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S406.py:1:6: S406 `xml.sax` methods are vulnerable to XML attacks +S406 `xml.sax` methods are vulnerable to XML attacks + --> S406.py:1:6 | 1 | from xml import sax # S406 - | ^^^ S406 + | ^^^ 2 | import xml.sax as xmls # S406 3 | import xml.sax # S406 | -S406.py:2:8: S406 `xml.sax` methods are vulnerable to XML attacks +S406 `xml.sax` methods are vulnerable to XML attacks + --> S406.py:2:8 | 1 | from xml import sax # S406 2 | import xml.sax as xmls # S406 - | ^^^^^^^^^^^^^^^ S406 + | ^^^^^^^^^^^^^^^ 3 | import xml.sax # S406 | -S406.py:3:8: S406 `xml.sax` methods are vulnerable to XML attacks +S406 `xml.sax` methods are vulnerable to XML attacks + --> S406.py:3:8 | 1 | from xml import sax # S406 2 | import xml.sax as xmls # S406 3 | import xml.sax # S406 - | ^^^^^^^ S406 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S407_S407.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S407_S407.py.snap index 481d087be8..f9d67dfe4a 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S407_S407.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S407_S407.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S407.py:1:6: S407 `xml.dom.expatbuilder` is vulnerable to XML attacks +S407 `xml.dom.expatbuilder` is vulnerable to XML attacks + --> S407.py:1:6 | 1 | from xml.dom import expatbuilder # S407 - | ^^^^^^^ S407 + | ^^^^^^^ 2 | import xml.dom.expatbuilder # S407 | -S407.py:2:8: S407 `xml.dom.expatbuilder` is vulnerable to XML attacks +S407 `xml.dom.expatbuilder` is vulnerable to XML attacks + --> S407.py:2:8 | 1 | from xml.dom import expatbuilder # S407 2 | import xml.dom.expatbuilder # S407 - | ^^^^^^^^^^^^^^^^^^^^ S407 + | ^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S408_S408.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S408_S408.py.snap index eddba46724..d88a35b987 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S408_S408.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S408_S408.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S408.py:1:6: S408 `xml.dom.minidom` is vulnerable to XML attacks +S408 `xml.dom.minidom` is vulnerable to XML attacks + --> S408.py:1:6 | 1 | from xml.dom.minidom import parseString # S408 - | ^^^^^^^^^^^^^^^ S408 + | ^^^^^^^^^^^^^^^ 2 | import xml.dom.minidom # S408 | -S408.py:2:8: S408 `xml.dom.minidom` is vulnerable to XML attacks +S408 `xml.dom.minidom` is vulnerable to XML attacks + --> S408.py:2:8 | 1 | from xml.dom.minidom import parseString # S408 2 | import xml.dom.minidom # S408 - | ^^^^^^^^^^^^^^^ S408 + | ^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S409_S409.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S409_S409.py.snap index 4622262669..f6333d760f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S409_S409.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S409_S409.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S409.py:1:6: S409 `xml.dom.pulldom` is vulnerable to XML attacks +S409 `xml.dom.pulldom` is vulnerable to XML attacks + --> S409.py:1:6 | 1 | from xml.dom.pulldom import parseString # S409 - | ^^^^^^^^^^^^^^^ S409 + | ^^^^^^^^^^^^^^^ 2 | import xml.dom.pulldom # S409 | -S409.py:2:8: S409 `xml.dom.pulldom` is vulnerable to XML attacks +S409 `xml.dom.pulldom` is vulnerable to XML attacks + --> S409.py:2:8 | 1 | from xml.dom.pulldom import parseString # S409 2 | import xml.dom.pulldom # S409 - | ^^^^^^^^^^^^^^^ S409 + | ^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S410_S410.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S410_S410.py.snap index f9477882ae..f2bbac41cf 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S410_S410.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S410_S410.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S410.py:1:8: S410 `lxml` is vulnerable to XML attacks +S410 `lxml` is vulnerable to XML attacks + --> S410.py:1:8 | 1 | import lxml # S410 - | ^^^^ S410 + | ^^^^ 2 | from lxml import etree # S410 | -S410.py:2:6: S410 `lxml` is vulnerable to XML attacks +S410 `lxml` is vulnerable to XML attacks + --> S410.py:2:6 | 1 | import lxml # S410 2 | from lxml import etree # S410 - | ^^^^ S410 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S411_S411.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S411_S411.py.snap index 8d89fa5679..117d693b21 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S411_S411.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S411_S411.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S411.py:1:8: S411 XMLRPC is vulnerable to remote XML attacks +S411 XMLRPC is vulnerable to remote XML attacks + --> S411.py:1:8 | 1 | import xmlrpc # S411 - | ^^^^^^ S411 + | ^^^^^^ 2 | from xmlrpc import server # S411 | -S411.py:2:6: S411 XMLRPC is vulnerable to remote XML attacks +S411 XMLRPC is vulnerable to remote XML attacks + --> S411.py:2:6 | 1 | import xmlrpc # S411 2 | from xmlrpc import server # S411 - | ^^^^^^ S411 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S412_S412.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S412_S412.py.snap index c8c325b36e..8fc8360557 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S412_S412.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S412_S412.py.snap @@ -1,9 +1,9 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S412.py:1:6: S412 `httpoxy` is a set of vulnerabilities that affect application code running inCGI, or CGI-like environments. The use of CGI for web applications should be avoided +S412 `httpoxy` is a set of vulnerabilities that affect application code running inCGI, or CGI-like environments. The use of CGI for web applications should be avoided + --> S412.py:1:6 | 1 | from twisted.web.twcgi import CGIScript # S412 - | ^^^^^^^^^^^^^^^^^ S412 + | ^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S413_S413.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S413_S413.py.snap index 5fe7a86643..ace5f2b1b2 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S413_S413.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S413_S413.py.snap @@ -1,37 +1,40 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S413.py:1:8: S413 `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability +S413 `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability + --> S413.py:1:8 | 1 | import Crypto.Hash # S413 - | ^^^^^^^^^^^ S413 + | ^^^^^^^^^^^ 2 | from Crypto.Hash import MD2 # S413 3 | import Crypto.PublicKey # S413 | -S413.py:2:6: S413 `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability +S413 `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability + --> S413.py:2:6 | 1 | import Crypto.Hash # S413 2 | from Crypto.Hash import MD2 # S413 - | ^^^^^^^^^^^ S413 + | ^^^^^^^^^^^ 3 | import Crypto.PublicKey # S413 4 | from Crypto.PublicKey import RSA # S413 | -S413.py:3:8: S413 `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability +S413 `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability + --> S413.py:3:8 | 1 | import Crypto.Hash # S413 2 | from Crypto.Hash import MD2 # S413 3 | import Crypto.PublicKey # S413 - | ^^^^^^^^^^^^^^^^ S413 + | ^^^^^^^^^^^^^^^^ 4 | from Crypto.PublicKey import RSA # S413 | -S413.py:4:6: S413 `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability +S413 `pycrypto` library is known to have publicly disclosed buffer overflow vulnerability + --> S413.py:4:6 | 2 | from Crypto.Hash import MD2 # S413 3 | import Crypto.PublicKey # S413 4 | from Crypto.PublicKey import RSA # S413 - | ^^^^^^^^^^^^^^^^ S413 + | ^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S415_S415.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S415_S415.py.snap index 86c659fb21..dd5ea30bb3 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S415_S415.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S415_S415.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S415.py:1:8: S415 An IPMI-related module is being imported. Prefer an encrypted protocol over IPMI. +S415 An IPMI-related module is being imported. Prefer an encrypted protocol over IPMI. + --> S415.py:1:8 | 1 | import pyghmi # S415 - | ^^^^^^ S415 + | ^^^^^^ 2 | from pyghmi import foo # S415 | -S415.py:2:6: S415 An IPMI-related module is being imported. Prefer an encrypted protocol over IPMI. +S415 An IPMI-related module is being imported. Prefer an encrypted protocol over IPMI. + --> S415.py:2:6 | 1 | import pyghmi # S415 2 | from pyghmi import foo # S415 - | ^^^^^^ S415 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap index 5c2e46e3d1..3d654321c0 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap @@ -1,178 +1,196 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S501.py:5:47: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + --> S501.py:5:47 | 4 | requests.get('https://gmail.com', timeout=30, verify=True) 5 | requests.get('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 6 | requests.post('https://gmail.com', timeout=30, verify=True) 7 | requests.post('https://gmail.com', timeout=30, verify=False) | -S501.py:7:48: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + --> S501.py:7:48 | 5 | requests.get('https://gmail.com', timeout=30, verify=False) 6 | requests.post('https://gmail.com', timeout=30, verify=True) 7 | requests.post('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 8 | requests.put('https://gmail.com', timeout=30, verify=True) 9 | requests.put('https://gmail.com', timeout=30, verify=False) | -S501.py:9:47: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + --> S501.py:9:47 | 7 | requests.post('https://gmail.com', timeout=30, verify=False) 8 | requests.put('https://gmail.com', timeout=30, verify=True) 9 | requests.put('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 10 | requests.delete('https://gmail.com', timeout=30, verify=True) 11 | requests.delete('https://gmail.com', timeout=30, verify=False) | -S501.py:11:50: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + --> S501.py:11:50 | 9 | requests.put('https://gmail.com', timeout=30, verify=False) 10 | requests.delete('https://gmail.com', timeout=30, verify=True) 11 | requests.delete('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 12 | requests.patch('https://gmail.com', timeout=30, verify=True) 13 | requests.patch('https://gmail.com', timeout=30, verify=False) | -S501.py:13:49: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + --> S501.py:13:49 | 11 | requests.delete('https://gmail.com', timeout=30, verify=False) 12 | requests.patch('https://gmail.com', timeout=30, verify=True) 13 | requests.patch('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 14 | requests.options('https://gmail.com', timeout=30, verify=True) 15 | requests.options('https://gmail.com', timeout=30, verify=False) | -S501.py:15:51: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + --> S501.py:15:51 | 13 | requests.patch('https://gmail.com', timeout=30, verify=False) 14 | requests.options('https://gmail.com', timeout=30, verify=True) 15 | requests.options('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 16 | requests.head('https://gmail.com', timeout=30, verify=True) 17 | requests.head('https://gmail.com', timeout=30, verify=False) | -S501.py:17:48: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + --> S501.py:17:48 | 15 | requests.options('https://gmail.com', timeout=30, verify=False) 16 | requests.head('https://gmail.com', timeout=30, verify=True) 17 | requests.head('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 18 | 19 | httpx.request('GET', 'https://gmail.com', verify=True) | -S501.py:20:43: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:20:43 | 19 | httpx.request('GET', 'https://gmail.com', verify=True) 20 | httpx.request('GET', 'https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 21 | httpx.get('https://gmail.com', verify=True) 22 | httpx.get('https://gmail.com', verify=False) | -S501.py:22:32: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:22:32 | 20 | httpx.request('GET', 'https://gmail.com', verify=False) 21 | httpx.get('https://gmail.com', verify=True) 22 | httpx.get('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 23 | httpx.options('https://gmail.com', verify=True) 24 | httpx.options('https://gmail.com', verify=False) | -S501.py:24:36: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:24:36 | 22 | httpx.get('https://gmail.com', verify=False) 23 | httpx.options('https://gmail.com', verify=True) 24 | httpx.options('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 25 | httpx.head('https://gmail.com', verify=True) 26 | httpx.head('https://gmail.com', verify=False) | -S501.py:26:33: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:26:33 | 24 | httpx.options('https://gmail.com', verify=False) 25 | httpx.head('https://gmail.com', verify=True) 26 | httpx.head('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 27 | httpx.post('https://gmail.com', verify=True) 28 | httpx.post('https://gmail.com', verify=False) | -S501.py:28:33: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:28:33 | 26 | httpx.head('https://gmail.com', verify=False) 27 | httpx.post('https://gmail.com', verify=True) 28 | httpx.post('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 29 | httpx.put('https://gmail.com', verify=True) 30 | httpx.put('https://gmail.com', verify=False) | -S501.py:30:32: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:30:32 | 28 | httpx.post('https://gmail.com', verify=False) 29 | httpx.put('https://gmail.com', verify=True) 30 | httpx.put('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 31 | httpx.patch('https://gmail.com', verify=True) 32 | httpx.patch('https://gmail.com', verify=False) | -S501.py:32:34: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:32:34 | 30 | httpx.put('https://gmail.com', verify=False) 31 | httpx.patch('https://gmail.com', verify=True) 32 | httpx.patch('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 33 | httpx.delete('https://gmail.com', verify=True) 34 | httpx.delete('https://gmail.com', verify=False) | -S501.py:34:35: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:34:35 | 32 | httpx.patch('https://gmail.com', verify=False) 33 | httpx.delete('https://gmail.com', verify=True) 34 | httpx.delete('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 35 | httpx.stream('https://gmail.com', verify=True) 36 | httpx.stream('https://gmail.com', verify=False) | -S501.py:36:35: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:36:35 | 34 | httpx.delete('https://gmail.com', verify=False) 35 | httpx.stream('https://gmail.com', verify=True) 36 | httpx.stream('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 37 | httpx.Client() 38 | httpx.Client(verify=False) | -S501.py:38:14: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:38:14 | 36 | httpx.stream('https://gmail.com', verify=False) 37 | httpx.Client() 38 | httpx.Client(verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ 39 | httpx.AsyncClient() 40 | httpx.AsyncClient(verify=False) | -S501.py:40:19: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks +S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + --> S501.py:40:19 | 38 | httpx.Client(verify=False) 39 | httpx.AsyncClient() 40 | httpx.AsyncClient(verify=False) - | ^^^^^^^^^^^^ S501 + | ^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S502_S502.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S502_S502.py.snap index 4087d85ab4..9f3624b643 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S502_S502.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S502_S502.py.snap @@ -1,70 +1,77 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S502.py:6:13: S502 Call made with insecure SSL protocol: `PROTOCOL_SSLv3` +S502 Call made with insecure SSL protocol: `PROTOCOL_SSLv3` + --> S502.py:6:13 | 4 | from OpenSSL.SSL import Context 5 | 6 | wrap_socket(ssl_version=ssl.PROTOCOL_SSLv3) # S502 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1) # S502 8 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_SSLv2) # S502 | -S502.py:7:17: S502 Call made with insecure SSL protocol: `PROTOCOL_TLSv1` +S502 Call made with insecure SSL protocol: `PROTOCOL_TLSv1` + --> S502.py:7:17 | 6 | wrap_socket(ssl_version=ssl.PROTOCOL_SSLv3) # S502 7 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1) # S502 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_SSLv2) # S502 9 | SSL.Context(method=SSL.SSLv2_METHOD) # S502 | -S502.py:8:17: S502 Call made with insecure SSL protocol: `PROTOCOL_SSLv2` +S502 Call made with insecure SSL protocol: `PROTOCOL_SSLv2` + --> S502.py:8:17 | 6 | wrap_socket(ssl_version=ssl.PROTOCOL_SSLv3) # S502 7 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1) # S502 8 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_SSLv2) # S502 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | SSL.Context(method=SSL.SSLv2_METHOD) # S502 10 | SSL.Context(method=SSL.SSLv23_METHOD) # S502 | -S502.py:9:13: S502 Call made with insecure SSL protocol: `SSLv2_METHOD` +S502 Call made with insecure SSL protocol: `SSLv2_METHOD` + --> S502.py:9:13 | 7 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1) # S502 8 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_SSLv2) # S502 9 | SSL.Context(method=SSL.SSLv2_METHOD) # S502 - | ^^^^^^^^^^^^^^^^^^^^^^^ S502 + | ^^^^^^^^^^^^^^^^^^^^^^^ 10 | SSL.Context(method=SSL.SSLv23_METHOD) # S502 11 | Context(method=SSL.SSLv3_METHOD) # S502 | -S502.py:10:13: S502 Call made with insecure SSL protocol: `SSLv23_METHOD` +S502 Call made with insecure SSL protocol: `SSLv23_METHOD` + --> S502.py:10:13 | 8 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_SSLv2) # S502 9 | SSL.Context(method=SSL.SSLv2_METHOD) # S502 10 | SSL.Context(method=SSL.SSLv23_METHOD) # S502 - | ^^^^^^^^^^^^^^^^^^^^^^^^ S502 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 11 | Context(method=SSL.SSLv3_METHOD) # S502 12 | Context(method=SSL.TLSv1_METHOD) # S502 | -S502.py:11:9: S502 Call made with insecure SSL protocol: `SSLv3_METHOD` +S502 Call made with insecure SSL protocol: `SSLv3_METHOD` + --> S502.py:11:9 | 9 | SSL.Context(method=SSL.SSLv2_METHOD) # S502 10 | SSL.Context(method=SSL.SSLv23_METHOD) # S502 11 | Context(method=SSL.SSLv3_METHOD) # S502 - | ^^^^^^^^^^^^^^^^^^^^^^^ S502 + | ^^^^^^^^^^^^^^^^^^^^^^^ 12 | Context(method=SSL.TLSv1_METHOD) # S502 | -S502.py:12:9: S502 Call made with insecure SSL protocol: `TLSv1_METHOD` +S502 Call made with insecure SSL protocol: `TLSv1_METHOD` + --> S502.py:12:9 | 10 | SSL.Context(method=SSL.SSLv23_METHOD) # S502 11 | Context(method=SSL.SSLv3_METHOD) # S502 12 | Context(method=SSL.TLSv1_METHOD) # S502 - | ^^^^^^^^^^^^^^^^^^^^^^^ S502 + | ^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | wrap_socket(ssl_version=ssl.PROTOCOL_TLS_CLIENT) # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S503_S503.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S503_S503.py.snap index 7ada319330..8d0b9a3dfe 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S503_S503.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S503_S503.py.snap @@ -1,31 +1,34 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S503.py:6:18: S503 Argument default set to insecure SSL protocol: `PROTOCOL_SSLv2` +S503 Argument default set to insecure SSL protocol: `PROTOCOL_SSLv2` + --> S503.py:6:18 | 6 | def func(version=ssl.PROTOCOL_SSLv2): # S503 - | ^^^^^^^^^^^^^^^^^^ S503 + | ^^^^^^^^^^^^^^^^^^ 7 | pass | -S503.py:10:19: S503 Argument default set to insecure SSL protocol: `SSLv2_METHOD` +S503 Argument default set to insecure SSL protocol: `SSLv2_METHOD` + --> S503.py:10:19 | 10 | def func(protocol=SSL.SSLv2_METHOD): # S503 - | ^^^^^^^^^^^^^^^^ S503 + | ^^^^^^^^^^^^^^^^ 11 | pass | -S503.py:14:18: S503 Argument default set to insecure SSL protocol: `SSLv23_METHOD` +S503 Argument default set to insecure SSL protocol: `SSLv23_METHOD` + --> S503.py:14:18 | 14 | def func(version=SSL.SSLv23_METHOD): # S503 - | ^^^^^^^^^^^^^^^^^ S503 + | ^^^^^^^^^^^^^^^^^ 15 | pass | -S503.py:18:19: S503 Argument default set to insecure SSL protocol: `PROTOCOL_TLSv1` +S503 Argument default set to insecure SSL protocol: `PROTOCOL_TLSv1` + --> S503.py:18:19 | 18 | def func(protocol=PROTOCOL_TLSv1): # S503 - | ^^^^^^^^^^^^^^ S503 + | ^^^^^^^^^^^^^^ 19 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S504_S504.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S504_S504.py.snap index faf1b6729a..b6576caae3 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S504_S504.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S504_S504.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S504.py:4:1: S504 `ssl.wrap_socket` called without an `ssl_version`` +S504 `ssl.wrap_socket` called without an `ssl_version`` + --> S504.py:4:1 | 2 | from ssl import wrap_socket 3 | 4 | ssl.wrap_socket() # S504 - | ^^^^^^^^^^^^^^^^^ S504 + | ^^^^^^^^^^^^^^^^^ 5 | wrap_socket() # S504 6 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_2) # OK | -S504.py:5:1: S504 `ssl.wrap_socket` called without an `ssl_version`` +S504 `ssl.wrap_socket` called without an `ssl_version`` + --> S504.py:5:1 | 4 | ssl.wrap_socket() # S504 5 | wrap_socket() # S504 - | ^^^^^^^^^^^^^ S504 + | ^^^^^^^^^^^^^ 6 | ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLSv1_2) # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S505_S505.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S505_S505.py.snap index 0177c4b1e4..d3fb7f096f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S505_S505.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S505_S505.py.snap @@ -1,140 +1,154 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S505.py:29:35: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:29:35 | 28 | # Errors 29 | dsa.generate_private_key(key_size=2047, backend=backends.default_backend()) - | ^^^^ S505 + | ^^^^ 30 | ec.generate_private_key(curve=ec.SECT163R2, backend=backends.default_backend()) 31 | rsa.generate_private_key( | -S505.py:30:31: S505 EC key sizes below 224 bits are considered breakable +S505 EC key sizes below 224 bits are considered breakable + --> S505.py:30:31 | 28 | # Errors 29 | dsa.generate_private_key(key_size=2047, backend=backends.default_backend()) 30 | ec.generate_private_key(curve=ec.SECT163R2, backend=backends.default_backend()) - | ^^^^^^^^^^^^ S505 + | ^^^^^^^^^^^^ 31 | rsa.generate_private_key( 32 | public_exponent=65537, key_size=2047, backend=backends.default_backend() | -S505.py:32:37: S505 RSA key sizes below 2048 bits are considered breakable +S505 RSA key sizes below 2048 bits are considered breakable + --> S505.py:32:37 | 30 | ec.generate_private_key(curve=ec.SECT163R2, backend=backends.default_backend()) 31 | rsa.generate_private_key( 32 | public_exponent=65537, key_size=2047, backend=backends.default_backend() - | ^^^^ S505 + | ^^^^ 33 | ) 34 | pycrypto_dsa.generate(bits=2047) | -S505.py:34:28: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:34:28 | 32 | public_exponent=65537, key_size=2047, backend=backends.default_backend() 33 | ) 34 | pycrypto_dsa.generate(bits=2047) - | ^^^^ S505 + | ^^^^ 35 | pycrypto_rsa.generate(bits=2047) 36 | pycryptodomex_dsa.generate(bits=2047) | -S505.py:35:28: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:35:28 | 33 | ) 34 | pycrypto_dsa.generate(bits=2047) 35 | pycrypto_rsa.generate(bits=2047) - | ^^^^ S505 + | ^^^^ 36 | pycryptodomex_dsa.generate(bits=2047) 37 | pycryptodomex_rsa.generate(bits=2047) | -S505.py:36:33: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:36:33 | 34 | pycrypto_dsa.generate(bits=2047) 35 | pycrypto_rsa.generate(bits=2047) 36 | pycryptodomex_dsa.generate(bits=2047) - | ^^^^ S505 + | ^^^^ 37 | pycryptodomex_rsa.generate(bits=2047) 38 | dsa.generate_private_key(2047, backends.default_backend()) | -S505.py:37:33: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:37:33 | 35 | pycrypto_rsa.generate(bits=2047) 36 | pycryptodomex_dsa.generate(bits=2047) 37 | pycryptodomex_rsa.generate(bits=2047) - | ^^^^ S505 + | ^^^^ 38 | dsa.generate_private_key(2047, backends.default_backend()) 39 | ec.generate_private_key(ec.SECT163R2, backends.default_backend()) | -S505.py:38:26: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:38:26 | 36 | pycryptodomex_dsa.generate(bits=2047) 37 | pycryptodomex_rsa.generate(bits=2047) 38 | dsa.generate_private_key(2047, backends.default_backend()) - | ^^^^ S505 + | ^^^^ 39 | ec.generate_private_key(ec.SECT163R2, backends.default_backend()) 40 | rsa.generate_private_key(3, 2047, backends.default_backend()) | -S505.py:39:25: S505 EC key sizes below 224 bits are considered breakable +S505 EC key sizes below 224 bits are considered breakable + --> S505.py:39:25 | 37 | pycryptodomex_rsa.generate(bits=2047) 38 | dsa.generate_private_key(2047, backends.default_backend()) 39 | ec.generate_private_key(ec.SECT163R2, backends.default_backend()) - | ^^^^^^^^^^^^ S505 + | ^^^^^^^^^^^^ 40 | rsa.generate_private_key(3, 2047, backends.default_backend()) 41 | pycrypto_dsa.generate(2047) | -S505.py:40:29: S505 RSA key sizes below 2048 bits are considered breakable +S505 RSA key sizes below 2048 bits are considered breakable + --> S505.py:40:29 | 38 | dsa.generate_private_key(2047, backends.default_backend()) 39 | ec.generate_private_key(ec.SECT163R2, backends.default_backend()) 40 | rsa.generate_private_key(3, 2047, backends.default_backend()) - | ^^^^ S505 + | ^^^^ 41 | pycrypto_dsa.generate(2047) 42 | pycrypto_rsa.generate(2047) | -S505.py:41:23: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:41:23 | 39 | ec.generate_private_key(ec.SECT163R2, backends.default_backend()) 40 | rsa.generate_private_key(3, 2047, backends.default_backend()) 41 | pycrypto_dsa.generate(2047) - | ^^^^ S505 + | ^^^^ 42 | pycrypto_rsa.generate(2047) 43 | pycryptodomex_dsa.generate(2047) | -S505.py:42:23: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:42:23 | 40 | rsa.generate_private_key(3, 2047, backends.default_backend()) 41 | pycrypto_dsa.generate(2047) 42 | pycrypto_rsa.generate(2047) - | ^^^^ S505 + | ^^^^ 43 | pycryptodomex_dsa.generate(2047) 44 | pycryptodomex_rsa.generate(2047) | -S505.py:43:28: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:43:28 | 41 | pycrypto_dsa.generate(2047) 42 | pycrypto_rsa.generate(2047) 43 | pycryptodomex_dsa.generate(2047) - | ^^^^ S505 + | ^^^^ 44 | pycryptodomex_rsa.generate(2047) | -S505.py:44:28: S505 DSA key sizes below 2048 bits are considered breakable +S505 DSA key sizes below 2048 bits are considered breakable + --> S505.py:44:28 | 42 | pycrypto_rsa.generate(2047) 43 | pycryptodomex_dsa.generate(2047) 44 | pycryptodomex_rsa.generate(2047) - | ^^^^ S505 + | ^^^^ 45 | 46 | # Don't crash when the size is variable. | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap index e20574f581..5e77be8256 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S506.py:10:9: S506 Probable use of unsafe `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. +S506 Probable use of unsafe `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. + --> S506.py:10:9 | 8 | def test_yaml_load(): 9 | ystr = yaml.dump({"a": 1, "b": 2, "c": 3}) 10 | y = yaml.load(ystr) - | ^^^^^^^^^ S506 + | ^^^^^^^^^ 11 | yaml.dump(y) 12 | try: | -S506.py:24:24: S506 Probable use of unsafe loader `Loader` with `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. +S506 Probable use of unsafe loader `Loader` with `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. + --> S506.py:24:24 | 24 | yaml.load("{}", Loader=yaml.Loader) - | ^^^^^^^^^^^ S506 + | ^^^^^^^^^^^ 25 | 26 | # no issue should be found | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap index 0cf6adf522..440bf47015 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap @@ -1,80 +1,88 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S507.py:15:40: S507 Paramiko call with policy set to automatically trust the unknown host key +S507 Paramiko call with policy set to automatically trust the unknown host key + --> S507.py:15:40 | 14 | # Errors 15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) - | ^^^^^^^^^^^^^^^^^^^^ S507 + | ^^^^^^^^^^^^^^^^^^^^ 16 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) 17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | -S507.py:16:40: S507 Paramiko call with policy set to automatically trust the unknown host key +S507 Paramiko call with policy set to automatically trust the unknown host key + --> S507.py:16:40 | 14 | # Errors 15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) 16 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) - | ^^^^^^^^^^^^^^^^^^^^ S507 + | ^^^^^^^^^^^^^^^^^^^^ 17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) 18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | -S507.py:17:40: S507 Paramiko call with policy set to automatically trust the unknown host key +S507 Paramiko call with policy set to automatically trust the unknown host key + --> S507.py:17:40 | 15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) 16 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) 17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) - | ^^^^^^^^^^^^^^^^^^^^^^ S507 + | ^^^^^^^^^^^^^^^^^^^^^^ 18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) 19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | -S507.py:18:40: S507 Paramiko call with policy set to automatically trust the unknown host key +S507 Paramiko call with policy set to automatically trust the unknown host key + --> S507.py:18:40 | 16 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) 17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) 18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) - | ^^^^^^^^^^^^^ S507 + | ^^^^^^^^^^^^^ 19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) 20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | -S507.py:19:47: S507 Paramiko call with policy set to automatically trust the unknown host key +S507 Paramiko call with policy set to automatically trust the unknown host key + --> S507.py:19:47 | 17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) 18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) 19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) - | ^^^^^^^^^^^^^^^^^^^^ S507 + | ^^^^^^^^^^^^^^^^^^^^ 20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) 21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) | -S507.py:20:47: S507 Paramiko call with policy set to automatically trust the unknown host key +S507 Paramiko call with policy set to automatically trust the unknown host key + --> S507.py:20:47 | 18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) 19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) 20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) - | ^^^^^^^^^^^^^^^^^^^^ S507 + | ^^^^^^^^^^^^^^^^^^^^ 21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) 22 | ssh_client_from_paramiko.set_missing_host_key_policy(paramiko.AutoAddPolicy) | -S507.py:21:47: S507 Paramiko call with policy set to automatically trust the unknown host key +S507 Paramiko call with policy set to automatically trust the unknown host key + --> S507.py:21:47 | 19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) 20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) 21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) - | ^^^^^^^^^^^^^ S507 + | ^^^^^^^^^^^^^ 22 | ssh_client_from_paramiko.set_missing_host_key_policy(paramiko.AutoAddPolicy) | -S507.py:22:54: S507 Paramiko call with policy set to automatically trust the unknown host key +S507 Paramiko call with policy set to automatically trust the unknown host key + --> S507.py:22:54 | 20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) 21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) 22 | ssh_client_from_paramiko.set_missing_host_key_policy(paramiko.AutoAddPolicy) - | ^^^^^^^^^^^^^^^^^^^^^^ S507 + | ^^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | # Unrelated | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap index 34e169f486..acbb09666a 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S508.py:3:25: S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able. +S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able. + --> S508.py:3:25 | 1 | from pysnmp.hlapi import CommunityData 2 | 3 | CommunityData("public", mpModel=0) # S508 - | ^^^^^^^^^ S508 + | ^^^^^^^^^ 4 | CommunityData("public", mpModel=1) # S508 | -S508.py:4:25: S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able. +S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able. + --> S508.py:4:25 | 3 | CommunityData("public", mpModel=0) # S508 4 | CommunityData("public", mpModel=1) # S508 - | ^^^^^^^^^ S508 + | ^^^^^^^^^ 5 | 6 | CommunityData("public", mpModel=2) # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap index f676630f91..c52b437891 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S509.py:4:12: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. +S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. + --> S509.py:4:12 | 4 | insecure = UsmUserData("securityName") # S509 - | ^^^^^^^^^^^ S509 + | ^^^^^^^^^^^ 5 | auth_no_priv = UsmUserData("securityName", "authName") # S509 | -S509.py:5:16: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. +S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. + --> S509.py:5:16 | 4 | insecure = UsmUserData("securityName") # S509 5 | auth_no_priv = UsmUserData("securityName", "authName") # S509 - | ^^^^^^^^^^^ S509 + | ^^^^^^^^^^^ 6 | 7 | less_insecure = UsmUserData("securityName", "authName", "privName") # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap index 3479fa2b9e..bd0d6b4e13 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S601.py:3:1: S601 Possible shell injection via Paramiko call; check inputs are properly sanitized +S601 Possible shell injection via Paramiko call; check inputs are properly sanitized + --> S601.py:3:1 | 1 | import paramiko 2 | 3 | paramiko.exec_command('something; really; unsafe') - | ^^^^^^^^^^^^^^^^^^^^^ S601 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap index 54f3baf9f8..75f4454ebf 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap @@ -1,115 +1,127 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S602.py:4:1: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:4:1 | 3 | # Check different Popen wrappers are checked. 4 | Popen("true", shell=True) - | ^^^^^ S602 + | ^^^^^ 5 | call("true", shell=True) 6 | check_call("true", shell=True) | -S602.py:5:1: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:5:1 | 3 | # Check different Popen wrappers are checked. 4 | Popen("true", shell=True) 5 | call("true", shell=True) - | ^^^^ S602 + | ^^^^ 6 | check_call("true", shell=True) 7 | check_output("true", shell=True) | -S602.py:6:1: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:6:1 | 4 | Popen("true", shell=True) 5 | call("true", shell=True) 6 | check_call("true", shell=True) - | ^^^^^^^^^^ S602 + | ^^^^^^^^^^ 7 | check_output("true", shell=True) 8 | run("true", shell=True) | -S602.py:7:1: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:7:1 | 5 | call("true", shell=True) 6 | check_call("true", shell=True) 7 | check_output("true", shell=True) - | ^^^^^^^^^^^^ S602 + | ^^^^^^^^^^^^ 8 | run("true", shell=True) | -S602.py:8:1: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:8:1 | 6 | check_call("true", shell=True) 7 | check_output("true", shell=True) 8 | run("true", shell=True) - | ^^^ S602 + | ^^^ 9 | 10 | # Check values that truthy values are treated as true. | -S602.py:11:1: S602 `subprocess` call with truthy `shell` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with truthy `shell` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:11:1 | 10 | # Check values that truthy values are treated as true. 11 | Popen("true", shell=1) - | ^^^^^ S602 + | ^^^^^ 12 | Popen("true", shell=[1]) 13 | Popen("true", shell={1: 1}) | -S602.py:12:1: S602 `subprocess` call with truthy `shell` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with truthy `shell` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:12:1 | 10 | # Check values that truthy values are treated as true. 11 | Popen("true", shell=1) 12 | Popen("true", shell=[1]) - | ^^^^^ S602 + | ^^^^^ 13 | Popen("true", shell={1: 1}) 14 | Popen("true", shell=(1,)) | -S602.py:13:1: S602 `subprocess` call with truthy `shell` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with truthy `shell` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:13:1 | 11 | Popen("true", shell=1) 12 | Popen("true", shell=[1]) 13 | Popen("true", shell={1: 1}) - | ^^^^^ S602 + | ^^^^^ 14 | Popen("true", shell=(1,)) | -S602.py:14:1: S602 `subprocess` call with truthy `shell` seems safe, but may be changed in the future; consider rewriting without `shell` +S602 `subprocess` call with truthy `shell` seems safe, but may be changed in the future; consider rewriting without `shell` + --> S602.py:14:1 | 12 | Popen("true", shell=[1]) 13 | Popen("true", shell={1: 1}) 14 | Popen("true", shell=(1,)) - | ^^^^^ S602 + | ^^^^^ 15 | 16 | # Check command argument looks unsafe. | -S602.py:18:1: S602 `subprocess` call with `shell=True` identified, security issue +S602 `subprocess` call with `shell=True` identified, security issue + --> S602.py:18:1 | 16 | # Check command argument looks unsafe. 17 | var_string = "true" 18 | Popen(var_string, shell=True) - | ^^^^^ S602 + | ^^^^^ 19 | Popen([var_string], shell=True) 20 | Popen([var_string, ""], shell=True) | -S602.py:19:1: S602 `subprocess` call with `shell=True` identified, security issue +S602 `subprocess` call with `shell=True` identified, security issue + --> S602.py:19:1 | 17 | var_string = "true" 18 | Popen(var_string, shell=True) 19 | Popen([var_string], shell=True) - | ^^^^^ S602 + | ^^^^^ 20 | Popen([var_string, ""], shell=True) | -S602.py:20:1: S602 `subprocess` call with `shell=True` identified, security issue +S602 `subprocess` call with `shell=True` identified, security issue + --> S602.py:20:1 | 18 | Popen(var_string, shell=True) 19 | Popen([var_string], shell=True) 20 | Popen([var_string, ""], shell=True) - | ^^^^^ S602 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap index 2b8d7c974f..586ccb21b9 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap @@ -1,125 +1,138 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S603.py:5:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:5:1 | 3 | # Different Popen wrappers are checked. 4 | a = input() 5 | Popen(a, shell=False) - | ^^^^^ S603 + | ^^^^^ 6 | call(a, shell=False) 7 | check_call(a, shell=False) | -S603.py:6:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:6:1 | 4 | a = input() 5 | Popen(a, shell=False) 6 | call(a, shell=False) - | ^^^^ S603 + | ^^^^ 7 | check_call(a, shell=False) 8 | check_output(a, shell=False) | -S603.py:7:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:7:1 | 5 | Popen(a, shell=False) 6 | call(a, shell=False) 7 | check_call(a, shell=False) - | ^^^^^^^^^^ S603 + | ^^^^^^^^^^ 8 | check_output(a, shell=False) 9 | run(a, shell=False) | -S603.py:8:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:8:1 | 6 | call(a, shell=False) 7 | check_call(a, shell=False) 8 | check_output(a, shell=False) - | ^^^^^^^^^^^^ S603 + | ^^^^^^^^^^^^ 9 | run(a, shell=False) | -S603.py:9:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:9:1 | 7 | check_call(a, shell=False) 8 | check_output(a, shell=False) 9 | run(a, shell=False) - | ^^^ S603 + | ^^^ 10 | 11 | # Falsey values are treated as false. | -S603.py:12:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:12:1 | 11 | # Falsey values are treated as false. 12 | Popen(a, shell=0) - | ^^^^^ S603 + | ^^^^^ 13 | Popen(a, shell=[]) 14 | Popen(a, shell={}) | -S603.py:13:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:13:1 | 11 | # Falsey values are treated as false. 12 | Popen(a, shell=0) 13 | Popen(a, shell=[]) - | ^^^^^ S603 + | ^^^^^ 14 | Popen(a, shell={}) 15 | Popen(a, shell=None) | -S603.py:14:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:14:1 | 12 | Popen(a, shell=0) 13 | Popen(a, shell=[]) 14 | Popen(a, shell={}) - | ^^^^^ S603 + | ^^^^^ 15 | Popen(a, shell=None) | -S603.py:15:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:15:1 | 13 | Popen(a, shell=[]) 14 | Popen(a, shell={}) 15 | Popen(a, shell=None) - | ^^^^^ S603 + | ^^^^^ 16 | 17 | # Unknown values are treated as falsey. | -S603.py:18:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:18:1 | 17 | # Unknown values are treated as falsey. 18 | Popen(a, shell=True if True else False) - | ^^^^^ S603 + | ^^^^^ 19 | 20 | # No value is also caught. | -S603.py:21:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:21:1 | 20 | # No value is also caught. 21 | Popen(a) - | ^^^^^ S603 + | ^^^^^ 22 | 23 | # Literals are fine, they're trusted. | -S603.py:34:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:34:1 | 32 | # Not through assignments though. 33 | cmd = ["true"] 34 | run(cmd) - | ^^^ S603 + | ^^^ 35 | 36 | # Instant named expressions are fine. | -S603.py:41:1: S603 `subprocess` call: check for execution of untrusted input +S603 `subprocess` call: check for execution of untrusted input + --> S603.py:41:1 | 39 | # But non-instant are not. 40 | (e := "echo") 41 | run(e) - | ^^^ S603 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S604_S604.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S604_S604.py.snap index a84c6314e6..85cd9d2583 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S604_S604.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S604_S604.py.snap @@ -1,9 +1,9 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S604.py:5:1: S604 Function call with `shell=True` parameter identified, security issue +S604 Function call with `shell=True` parameter identified, security issue + --> S604.py:5:1 | 5 | foo(shell=True) - | ^^^ S604 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S605_S605.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S605_S605.py.snap index 9ad1400574..61d315bcba 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S605_S605.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S605_S605.py.snap @@ -1,166 +1,182 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S605.py:8:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:8:1 | 7 | # Check all shell functions. 8 | os.system("true") - | ^^^^^^^^^ S605 + | ^^^^^^^^^ 9 | os.popen("true") 10 | os.popen2("true") | -S605.py:9:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:9:1 | 7 | # Check all shell functions. 8 | os.system("true") 9 | os.popen("true") - | ^^^^^^^^ S605 + | ^^^^^^^^ 10 | os.popen2("true") 11 | os.popen3("true") | -S605.py:10:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:10:1 | 8 | os.system("true") 9 | os.popen("true") 10 | os.popen2("true") - | ^^^^^^^^^ S605 + | ^^^^^^^^^ 11 | os.popen3("true") 12 | os.popen4("true") | -S605.py:11:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:11:1 | 9 | os.popen("true") 10 | os.popen2("true") 11 | os.popen3("true") - | ^^^^^^^^^ S605 + | ^^^^^^^^^ 12 | os.popen4("true") 13 | popen2.popen2("true") | -S605.py:12:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:12:1 | 10 | os.popen2("true") 11 | os.popen3("true") 12 | os.popen4("true") - | ^^^^^^^^^ S605 + | ^^^^^^^^^ 13 | popen2.popen2("true") 14 | popen2.popen3("true") | -S605.py:13:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:13:1 | 11 | os.popen3("true") 12 | os.popen4("true") 13 | popen2.popen2("true") - | ^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^ 14 | popen2.popen3("true") 15 | popen2.popen4("true") | -S605.py:14:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:14:1 | 12 | os.popen4("true") 13 | popen2.popen2("true") 14 | popen2.popen3("true") - | ^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^ 15 | popen2.popen4("true") 16 | popen2.Popen3("true") | -S605.py:15:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:15:1 | 13 | popen2.popen2("true") 14 | popen2.popen3("true") 15 | popen2.popen4("true") - | ^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^ 16 | popen2.Popen3("true") 17 | popen2.Popen4("true") | -S605.py:16:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:16:1 | 14 | popen2.popen3("true") 15 | popen2.popen4("true") 16 | popen2.Popen3("true") - | ^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^ 17 | popen2.Popen4("true") 18 | commands.getoutput("true") | -S605.py:17:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:17:1 | 15 | popen2.popen4("true") 16 | popen2.Popen3("true") 17 | popen2.Popen4("true") - | ^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^ 18 | commands.getoutput("true") 19 | commands.getstatusoutput("true") | -S605.py:18:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:18:1 | 16 | popen2.Popen3("true") 17 | popen2.Popen4("true") 18 | commands.getoutput("true") - | ^^^^^^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^^^^^^ 19 | commands.getstatusoutput("true") 20 | subprocess.getoutput("true") | -S605.py:19:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:19:1 | 17 | popen2.Popen4("true") 18 | commands.getoutput("true") 19 | commands.getstatusoutput("true") - | ^^^^^^^^^^^^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 20 | subprocess.getoutput("true") 21 | subprocess.getstatusoutput("true") | -S605.py:20:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:20:1 | 18 | commands.getoutput("true") 19 | commands.getstatusoutput("true") 20 | subprocess.getoutput("true") - | ^^^^^^^^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^^^^^^^^ 21 | subprocess.getstatusoutput("true") | -S605.py:21:1: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` +S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + --> S605.py:21:1 | 19 | commands.getstatusoutput("true") 20 | subprocess.getoutput("true") 21 | subprocess.getstatusoutput("true") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S605 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -S605.py:26:1: S605 Starting a process with a shell, possible injection detected +S605 Starting a process with a shell, possible injection detected + --> S605.py:26:1 | 24 | # Check command argument looks unsafe. 25 | var_string = "true" 26 | os.system(var_string) - | ^^^^^^^^^ S605 + | ^^^^^^^^^ 27 | os.system([var_string]) 28 | os.system([var_string, ""]) | -S605.py:27:1: S605 Starting a process with a shell, possible injection detected +S605 Starting a process with a shell, possible injection detected + --> S605.py:27:1 | 25 | var_string = "true" 26 | os.system(var_string) 27 | os.system([var_string]) - | ^^^^^^^^^ S605 + | ^^^^^^^^^ 28 | os.system([var_string, ""]) | -S605.py:28:1: S605 Starting a process with a shell, possible injection detected +S605 Starting a process with a shell, possible injection detected + --> S605.py:28:1 | 26 | os.system(var_string) 27 | os.system([var_string]) 28 | os.system([var_string, ""]) - | ^^^^^^^^^ S605 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S606_S606.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S606_S606.py.snap index 6b98f57167..17361ece3f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S606_S606.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S606_S606.py.snap @@ -1,169 +1,185 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S606.py:4:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:4:1 | 3 | # Check all shell functions. 4 | os.execl("true") - | ^^^^^^^^ S606 + | ^^^^^^^^ 5 | os.execle("true") 6 | os.execlp("true") | -S606.py:5:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:5:1 | 3 | # Check all shell functions. 4 | os.execl("true") 5 | os.execle("true") - | ^^^^^^^^^ S606 + | ^^^^^^^^^ 6 | os.execlp("true") 7 | os.execlpe("true") | -S606.py:6:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:6:1 | 4 | os.execl("true") 5 | os.execle("true") 6 | os.execlp("true") - | ^^^^^^^^^ S606 + | ^^^^^^^^^ 7 | os.execlpe("true") 8 | os.execv("true") | -S606.py:7:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:7:1 | 5 | os.execle("true") 6 | os.execlp("true") 7 | os.execlpe("true") - | ^^^^^^^^^^ S606 + | ^^^^^^^^^^ 8 | os.execv("true") 9 | os.execve("true") | -S606.py:8:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:8:1 | 6 | os.execlp("true") 7 | os.execlpe("true") 8 | os.execv("true") - | ^^^^^^^^ S606 + | ^^^^^^^^ 9 | os.execve("true") 10 | os.execvp("true") | -S606.py:9:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:9:1 | 7 | os.execlpe("true") 8 | os.execv("true") 9 | os.execve("true") - | ^^^^^^^^^ S606 + | ^^^^^^^^^ 10 | os.execvp("true") 11 | os.execvpe("true") | -S606.py:10:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:10:1 | 8 | os.execv("true") 9 | os.execve("true") 10 | os.execvp("true") - | ^^^^^^^^^ S606 + | ^^^^^^^^^ 11 | os.execvpe("true") 12 | os.spawnl("true") | -S606.py:11:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:11:1 | 9 | os.execve("true") 10 | os.execvp("true") 11 | os.execvpe("true") - | ^^^^^^^^^^ S606 + | ^^^^^^^^^^ 12 | os.spawnl("true") 13 | os.spawnle("true") | -S606.py:12:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:12:1 | 10 | os.execvp("true") 11 | os.execvpe("true") 12 | os.spawnl("true") - | ^^^^^^^^^ S606 + | ^^^^^^^^^ 13 | os.spawnle("true") 14 | os.spawnlp("true") | -S606.py:13:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:13:1 | 11 | os.execvpe("true") 12 | os.spawnl("true") 13 | os.spawnle("true") - | ^^^^^^^^^^ S606 + | ^^^^^^^^^^ 14 | os.spawnlp("true") 15 | os.spawnlpe("true") | -S606.py:14:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:14:1 | 12 | os.spawnl("true") 13 | os.spawnle("true") 14 | os.spawnlp("true") - | ^^^^^^^^^^ S606 + | ^^^^^^^^^^ 15 | os.spawnlpe("true") 16 | os.spawnv("true") | -S606.py:15:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:15:1 | 13 | os.spawnle("true") 14 | os.spawnlp("true") 15 | os.spawnlpe("true") - | ^^^^^^^^^^^ S606 + | ^^^^^^^^^^^ 16 | os.spawnv("true") 17 | os.spawnve("true") | -S606.py:16:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:16:1 | 14 | os.spawnlp("true") 15 | os.spawnlpe("true") 16 | os.spawnv("true") - | ^^^^^^^^^ S606 + | ^^^^^^^^^ 17 | os.spawnve("true") 18 | os.spawnvp("true") | -S606.py:17:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:17:1 | 15 | os.spawnlpe("true") 16 | os.spawnv("true") 17 | os.spawnve("true") - | ^^^^^^^^^^ S606 + | ^^^^^^^^^^ 18 | os.spawnvp("true") 19 | os.spawnvpe("true") | -S606.py:18:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:18:1 | 16 | os.spawnv("true") 17 | os.spawnve("true") 18 | os.spawnvp("true") - | ^^^^^^^^^^ S606 + | ^^^^^^^^^^ 19 | os.spawnvpe("true") 20 | os.startfile("true") | -S606.py:19:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:19:1 | 17 | os.spawnve("true") 18 | os.spawnvp("true") 19 | os.spawnvpe("true") - | ^^^^^^^^^^^ S606 + | ^^^^^^^^^^^ 20 | os.startfile("true") | -S606.py:20:1: S606 Starting a process without a shell +S606 Starting a process without a shell + --> S606.py:20:1 | 18 | os.spawnvp("true") 19 | os.spawnvpe("true") 20 | os.startfile("true") - | ^^^^^^^^^^^^ S606 + | ^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap index ca8c9abd84..5cf617e75e 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap @@ -1,221 +1,243 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S607.py:9:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:9:11 | 7 | subprocess.check_output("true") 8 | subprocess.run("true") 9 | os.system("true") - | ^^^^^^ S607 + | ^^^^^^ 10 | os.popen("true") 11 | os.popen2("true") | -S607.py:10:10: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:10:10 | 8 | subprocess.run("true") 9 | os.system("true") 10 | os.popen("true") - | ^^^^^^ S607 + | ^^^^^^ 11 | os.popen2("true") 12 | os.popen3("true") | -S607.py:11:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:11:11 | 9 | os.system("true") 10 | os.popen("true") 11 | os.popen2("true") - | ^^^^^^ S607 + | ^^^^^^ 12 | os.popen3("true") 13 | os.popen4("true") | -S607.py:12:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:12:11 | 10 | os.popen("true") 11 | os.popen2("true") 12 | os.popen3("true") - | ^^^^^^ S607 + | ^^^^^^ 13 | os.popen4("true") 14 | popen2.popen2("true") | -S607.py:13:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:13:11 | 11 | os.popen2("true") 12 | os.popen3("true") 13 | os.popen4("true") - | ^^^^^^ S607 + | ^^^^^^ 14 | popen2.popen2("true") 15 | popen2.popen3("true") | -S607.py:21:10: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:21:10 | 19 | commands.getoutput("true") 20 | commands.getstatusoutput("true") 21 | os.execl("true") - | ^^^^^^ S607 + | ^^^^^^ 22 | os.execle("true") 23 | os.execlp("true") | -S607.py:22:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:22:11 | 20 | commands.getstatusoutput("true") 21 | os.execl("true") 22 | os.execle("true") - | ^^^^^^ S607 + | ^^^^^^ 23 | os.execlp("true") 24 | os.execlpe("true") | -S607.py:23:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:23:11 | 21 | os.execl("true") 22 | os.execle("true") 23 | os.execlp("true") - | ^^^^^^ S607 + | ^^^^^^ 24 | os.execlpe("true") 25 | os.execv("true") | -S607.py:24:12: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:24:12 | 22 | os.execle("true") 23 | os.execlp("true") 24 | os.execlpe("true") - | ^^^^^^ S607 + | ^^^^^^ 25 | os.execv("true") 26 | os.execve("true") | -S607.py:25:10: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:25:10 | 23 | os.execlp("true") 24 | os.execlpe("true") 25 | os.execv("true") - | ^^^^^^ S607 + | ^^^^^^ 26 | os.execve("true") 27 | os.execvp("true") | -S607.py:26:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:26:11 | 24 | os.execlpe("true") 25 | os.execv("true") 26 | os.execve("true") - | ^^^^^^ S607 + | ^^^^^^ 27 | os.execvp("true") 28 | os.execvpe("true") | -S607.py:27:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:27:11 | 25 | os.execv("true") 26 | os.execve("true") 27 | os.execvp("true") - | ^^^^^^ S607 + | ^^^^^^ 28 | os.execvpe("true") 29 | os.spawnl("true") | -S607.py:28:12: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:28:12 | 26 | os.execve("true") 27 | os.execvp("true") 28 | os.execvpe("true") - | ^^^^^^ S607 + | ^^^^^^ 29 | os.spawnl("true") 30 | os.spawnle("true") | -S607.py:29:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:29:11 | 27 | os.execvp("true") 28 | os.execvpe("true") 29 | os.spawnl("true") - | ^^^^^^ S607 + | ^^^^^^ 30 | os.spawnle("true") 31 | os.spawnlp("true") | -S607.py:30:12: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:30:12 | 28 | os.execvpe("true") 29 | os.spawnl("true") 30 | os.spawnle("true") - | ^^^^^^ S607 + | ^^^^^^ 31 | os.spawnlp("true") 32 | os.spawnlpe("true") | -S607.py:31:12: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:31:12 | 29 | os.spawnl("true") 30 | os.spawnle("true") 31 | os.spawnlp("true") - | ^^^^^^ S607 + | ^^^^^^ 32 | os.spawnlpe("true") 33 | os.spawnv("true") | -S607.py:32:13: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:32:13 | 30 | os.spawnle("true") 31 | os.spawnlp("true") 32 | os.spawnlpe("true") - | ^^^^^^ S607 + | ^^^^^^ 33 | os.spawnv("true") 34 | os.spawnve("true") | -S607.py:33:11: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:33:11 | 31 | os.spawnlp("true") 32 | os.spawnlpe("true") 33 | os.spawnv("true") - | ^^^^^^ S607 + | ^^^^^^ 34 | os.spawnve("true") 35 | os.spawnvp("true") | -S607.py:34:12: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:34:12 | 32 | os.spawnlpe("true") 33 | os.spawnv("true") 34 | os.spawnve("true") - | ^^^^^^ S607 + | ^^^^^^ 35 | os.spawnvp("true") 36 | os.spawnvpe("true") | -S607.py:35:12: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:35:12 | 33 | os.spawnv("true") 34 | os.spawnve("true") 35 | os.spawnvp("true") - | ^^^^^^ S607 + | ^^^^^^ 36 | os.spawnvpe("true") 37 | os.startfile("true") | -S607.py:36:13: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:36:13 | 34 | os.spawnve("true") 35 | os.spawnvp("true") 36 | os.spawnvpe("true") - | ^^^^^^ S607 + | ^^^^^^ 37 | os.startfile("true") | -S607.py:37:14: S607 Starting a process with a partial executable path +S607 Starting a process with a partial executable path + --> S607.py:37:14 | 35 | os.spawnvp("true") 36 | os.spawnvpe("true") 37 | os.startfile("true") - | ^^^^^^ S607 + | ^^^^^^ 38 | 39 | # Check it does not fail for full paths. | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap index b19b9631f6..09918609c0 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap @@ -1,351 +1,388 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S608.py:2:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:2:10 | 1 | # single-line failures 2 | query1 = "SELECT %s FROM table" % (var,) # bad - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | query2 = "SELECT var FROM " + table 4 | query3 = "SELECT " + val + " FROM " + table | -S608.py:3:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:3:10 | 1 | # single-line failures 2 | query1 = "SELECT %s FROM table" % (var,) # bad 3 | query2 = "SELECT var FROM " + table - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | query3 = "SELECT " + val + " FROM " + table 5 | query4 = "SELECT {} FROM table;".format(var) | -S608.py:4:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:4:10 | 2 | query1 = "SELECT %s FROM table" % (var,) # bad 3 | query2 = "SELECT var FROM " + table 4 | query3 = "SELECT " + val + " FROM " + table - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | query4 = "SELECT {} FROM table;".format(var) 6 | query5 = f"SELECT * FROM table WHERE var = {var}" | -S608.py:5:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:5:10 | 3 | query2 = "SELECT var FROM " + table 4 | query3 = "SELECT " + val + " FROM " + table 5 | query4 = "SELECT {} FROM table;".format(var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | query5 = f"SELECT * FROM table WHERE var = {var}" | -S608.py:6:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:6:10 | 4 | query3 = "SELECT " + val + " FROM " + table 5 | query4 = "SELECT {} FROM table;".format(var) 6 | query5 = f"SELECT * FROM table WHERE var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) | -S608.py:8:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:8:10 | 6 | query5 = f"SELECT * FROM table WHERE var = {var}" 7 | 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | query7 = "DELETE FROM table WHERE VAR = " + var 10 | query8 = "DELETE FROM " + table + "WHERE var = " + var | -S608.py:9:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:9:10 | 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) 9 | query7 = "DELETE FROM table WHERE VAR = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | query8 = "DELETE FROM " + table + "WHERE var = " + var 11 | query9 = "DELETE FROM table WHERE var = {}".format(var) | -S608.py:10:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:10:10 | 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) 9 | query7 = "DELETE FROM table WHERE VAR = " + var 10 | query8 = "DELETE FROM " + table + "WHERE var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | query9 = "DELETE FROM table WHERE var = {}".format(var) 12 | query10 = f"DELETE FROM table WHERE var = {var}" | -S608.py:11:10: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:11:10 | 9 | query7 = "DELETE FROM table WHERE VAR = " + var 10 | query8 = "DELETE FROM " + table + "WHERE var = " + var 11 | query9 = "DELETE FROM table WHERE var = {}".format(var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | query10 = f"DELETE FROM table WHERE var = {var}" | -S608.py:12:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:12:11 | 10 | query8 = "DELETE FROM " + table + "WHERE var = " + var 11 | query9 = "DELETE FROM table WHERE var = {}".format(var) 12 | query10 = f"DELETE FROM table WHERE var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) | -S608.py:14:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:14:11 | 12 | query10 = f"DELETE FROM table WHERE var = {var}" 13 | 14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" 16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) | -S608.py:15:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:15:11 | 14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) 15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) 17 | query14 = f"INSERT INTO {table} VALUES var = {var}" | -S608.py:16:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:16:11 | 14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) 15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" 16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | query14 = f"INSERT INTO {table} VALUES var = {var}" | -S608.py:17:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:17:11 | 15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" 16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) 17 | query14 = f"INSERT INTO {table} VALUES var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | query15 = "UPDATE %s SET var = %s" % (table, var) | -S608.py:19:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:19:11 | 17 | query14 = f"INSERT INTO {table} VALUES var = {var}" 18 | 19 | query15 = "UPDATE %s SET var = %s" % (table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | query16 = "UPDATE " + table + " SET var = " + var 21 | query17 = "UPDATE {} SET var = {}".format(table, var) | -S608.py:20:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:20:11 | 19 | query15 = "UPDATE %s SET var = %s" % (table, var) 20 | query16 = "UPDATE " + table + " SET var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | query17 = "UPDATE {} SET var = {}".format(table, var) 22 | query18 = f"UPDATE {table} SET var = {var}" | -S608.py:21:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:21:11 | 19 | query15 = "UPDATE %s SET var = %s" % (table, var) 20 | query16 = "UPDATE " + table + " SET var = " + var 21 | query17 = "UPDATE {} SET var = {}".format(table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | query18 = f"UPDATE {table} SET var = {var}" | -S608.py:22:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:22:11 | 20 | query16 = "UPDATE " + table + " SET var = " + var 21 | query17 = "UPDATE {} SET var = {}".format(table, var) 22 | query18 = f"UPDATE {table} SET var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | query19 = "select %s from table" % (var,) | -S608.py:24:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:24:11 | 22 | query18 = f"UPDATE {table} SET var = {var}" 23 | 24 | query19 = "select %s from table" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | query20 = "select var from " + table 26 | query21 = "select " + val + " from " + table | -S608.py:25:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:25:11 | 24 | query19 = "select %s from table" % (var,) 25 | query20 = "select var from " + table - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | query21 = "select " + val + " from " + table 27 | query22 = "select {} from table;".format(var) | -S608.py:26:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:26:11 | 24 | query19 = "select %s from table" % (var,) 25 | query20 = "select var from " + table 26 | query21 = "select " + val + " from " + table - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | query22 = "select {} from table;".format(var) 28 | query23 = f"select * from table where var = {var}" | -S608.py:27:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:27:11 | 25 | query20 = "select var from " + table 26 | query21 = "select " + val + " from " + table 27 | query22 = "select {} from table;".format(var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | query23 = f"select * from table where var = {var}" | -S608.py:28:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:28:11 | 26 | query21 = "select " + val + " from " + table 27 | query22 = "select {} from table;".format(var) 28 | query23 = f"select * from table where var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | 30 | query24 = "delete from table where var = %s" % (var,) | -S608.py:30:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:30:11 | 28 | query23 = f"select * from table where var = {var}" 29 | 30 | query24 = "delete from table where var = %s" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | query25 = "delete from table where var = " + var 32 | query26 = "delete from " + table + "where var = " + var | -S608.py:31:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:31:11 | 30 | query24 = "delete from table where var = %s" % (var,) 31 | query25 = "delete from table where var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | query26 = "delete from " + table + "where var = " + var 33 | query27 = "delete from table where var = {}".format(var) | -S608.py:32:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:32:11 | 30 | query24 = "delete from table where var = %s" % (var,) 31 | query25 = "delete from table where var = " + var 32 | query26 = "delete from " + table + "where var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | query27 = "delete from table where var = {}".format(var) 34 | query28 = f"delete from table where var = {var}" | -S608.py:33:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:33:11 | 31 | query25 = "delete from table where var = " + var 32 | query26 = "delete from " + table + "where var = " + var 33 | query27 = "delete from table where var = {}".format(var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | query28 = f"delete from table where var = {var}" | -S608.py:34:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:34:11 | 32 | query26 = "delete from " + table + "where var = " + var 33 | query27 = "delete from table where var = {}".format(var) 34 | query28 = f"delete from table where var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | query29 = "insert into table values (%s)" % (var,) | -S608.py:36:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:36:11 | 34 | query28 = f"delete from table where var = {var}" 35 | 36 | query29 = "insert into table values (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | query30 = "insert into table values (" + var + ")" 38 | query31 = "insert into {} values ({})".format(table, var) | -S608.py:37:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:37:11 | 36 | query29 = "insert into table values (%s)" % (var,) 37 | query30 = "insert into table values (" + var + ")" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | query31 = "insert into {} values ({})".format(table, var) 39 | query32 = f"insert into {table} values var = {var}" | -S608.py:38:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:38:11 | 36 | query29 = "insert into table values (%s)" % (var,) 37 | query30 = "insert into table values (" + var + ")" 38 | query31 = "insert into {} values ({})".format(table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | query32 = f"insert into {table} values var = {var}" | -S608.py:39:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:39:11 | 37 | query30 = "insert into table values (" + var + ")" 38 | query31 = "insert into {} values ({})".format(table, var) 39 | query32 = f"insert into {table} values var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | 41 | query33 = "update %s set var = %s" % (table, var) | -S608.py:41:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:41:11 | 39 | query32 = f"insert into {table} values var = {var}" 40 | 41 | query33 = "update %s set var = %s" % (table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | query34 = "update " + table + " set var = " + var 43 | query35 = "update {} set var = {}".format(table, var) | -S608.py:42:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:42:11 | 41 | query33 = "update %s set var = %s" % (table, var) 42 | query34 = "update " + table + " set var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | query35 = "update {} set var = {}".format(table, var) 44 | query36 = f"update {table} set var = {var}" | -S608.py:43:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:43:11 | 41 | query33 = "update %s set var = %s" % (table, var) 42 | query34 = "update " + table + " set var = " + var 43 | query35 = "update {} set var = {}".format(table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | query36 = f"update {table} set var = {var}" | -S608.py:44:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:44:11 | 42 | query34 = "update " + table + " set var = " + var 43 | query35 = "update {} set var = {}".format(table, var) 44 | query36 = f"update {table} set var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | # multi-line failures | -S608.py:48:12: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:48:12 | 46 | # multi-line failures 47 | def query37(): @@ -355,12 +392,13 @@ S608.py:48:12: S608 Possible SQL injection vector through string-based query con 50 | | FROM table 51 | | WHERE var = %s 52 | | """ % var - | |_____________^ S608 + | |_____________^ 53 | 54 | def query38(): | -S608.py:55:12: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:55:12 | 54 | def query38(): 55 | return """ @@ -369,12 +407,13 @@ S608.py:55:12: S608 Possible SQL injection vector through string-based query con 57 | | FROM TABLE 58 | | WHERE var = 59 | | """ + var - | |_____________^ S608 + | |_____________^ 60 | 61 | def query39(): | -S608.py:62:12: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:62:12 | 61 | def query39(): 62 | return """ @@ -383,12 +422,13 @@ S608.py:62:12: S608 Possible SQL injection vector through string-based query con 64 | | FROM table 65 | | WHERE var = {} 66 | | """.format(var) - | |___________________^ S608 + | |___________________^ 67 | 68 | def query40(): | -S608.py:69:12: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:69:12 | 68 | def query40(): 69 | return f""" @@ -397,106 +437,117 @@ S608.py:69:12: S608 Possible SQL injection vector through string-based query con 71 | | FROM table 72 | | WHERE var = {var} 73 | | """ - | |_______^ S608 + | |_______^ 74 | 75 | def query41(): | -S608.py:77:9: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:77:9 | 75 | def query41(): 76 | return ( 77 | / "SELECT * " 78 | | "FROM table " 79 | | f"WHERE var = {var}" - | |____________________________^ S608 + | |____________________________^ 80 | ) | -S608.py:83:26: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:83:26 | 82 | # # cursor-wrapped failures 83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") 85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) | -S608.py:84:26: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:84:26 | 82 | # # cursor-wrapped failures 83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) 84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) 86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) | -S608.py:85:26: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:85:26 | 83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) 84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") 85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) | -S608.py:86:30: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:86:30 | 84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") 85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) 86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 | 88 | # # pass | -S608.py:98:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:98:11 | 97 | # # INSERT without INTO (e.g. MySQL and derivatives) 98 | query46 = "INSERT table VALUES (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 99 | 100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) | -S608.py:101:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:101:11 | 100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) 101 | query47 = "REPLACE INTO table VALUES (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 102 | query48 = "REPLACE table VALUES (%s)" % (var,) | -S608.py:102:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:102:11 | 100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) 101 | query47 = "REPLACE INTO table VALUES (%s)" % (var,) 102 | query48 = "REPLACE table VALUES (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 103 | 104 | query49 = "Deselect something that is not SQL even though it has a ' from ' somewhere in %s." % "there" | -S608.py:111:1: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:111:1 | 110 | # # errors 111 | "SELECT * FROM " + ("table1" if x > 0 else "table2") # query50 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 112 | "SELECT * FROM " + ("table1" if x > 0 else ["table2"]) # query51 | -S608.py:112:1: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:112:1 | 110 | # # errors 111 | "SELECT * FROM " + ("table1" if x > 0 else "table2") # query50 112 | "SELECT * FROM " + ("table1" if x > 0 else ["table2"]) # query51 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 113 | 114 | # test cases from #12044 | -S608.py:117:12: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:117:12 | 116 | def query52(): 117 | return f""" @@ -504,12 +555,13 @@ S608.py:117:12: S608 Possible SQL injection vector through string-based query co 118 | | SELECT {var} 119 | | FROM bar 120 | | """ - | |_______^ S608 + | |_______^ 121 | 122 | def query53(): | -S608.py:123:12: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:123:12 | 122 | def query53(): 123 | return f""" @@ -518,12 +570,13 @@ S608.py:123:12: S608 Possible SQL injection vector through string-based query co 125 | | {var} 126 | | FROM bar 127 | | """ - | |_______^ S608 + | |_______^ 128 | 129 | def query54(): | -S608.py:130:12: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:130:12 | 129 | def query54(): 130 | return f""" @@ -532,12 +585,13 @@ S608.py:130:12: S608 Possible SQL injection vector through string-based query co 132 | | FROM 133 | | bar 134 | | """ - | |_______^ S608 + | |_______^ 135 | 136 | query55 = f"""SELECT * FROM | -S608.py:136:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:136:11 | 134 | """ 135 | @@ -545,12 +599,13 @@ S608.py:136:11: S608 Possible SQL injection vector through string-based query co | ___________^ 137 | | {var}.table 138 | | """ - | |___^ S608 + | |___^ 139 | 140 | query56 = f"""SELECT * | -S608.py:140:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:140:11 | 138 | """ 139 | @@ -558,12 +613,13 @@ S608.py:140:11: S608 Possible SQL injection vector through string-based query co | ___________^ 141 | | FROM {var}.table 142 | | """ - | |___^ S608 + | |___^ 143 | 144 | query57 = f""" | -S608.py:144:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:144:11 | 142 | """ 143 | @@ -572,12 +628,13 @@ S608.py:144:11: S608 Possible SQL injection vector through string-based query co 145 | | SELECT * 146 | | FROM {var}.table 147 | | """ - | |___^ S608 + | |___^ 148 | 149 | query57 = f""" | -S608.py:160:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:160:11 | 159 | # https://github.com/astral-sh/ruff/issues/15653 160 | query59 = f""" @@ -585,12 +642,13 @@ S608.py:160:11: S608 Possible SQL injection vector through string-based query co 161 | | SELECT *, foo 162 | | FROM ({user_input}) raw 163 | | """ - | |___^ S608 + | |___^ 164 | query60 = f""" 165 | SELECT *, | -S608.py:164:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:164:11 | 162 | FROM ({user_input}) raw 163 | """ @@ -600,16 +658,17 @@ S608.py:164:11: S608 Possible SQL injection vector through string-based query co 166 | | foo 167 | | FROM ({user_input}) raw 168 | | """ - | |___^ S608 + | |___^ 169 | 170 | # https://github.com/astral-sh/ruff/issues/17967 | -S608.py:180:11: S608 Possible SQL injection vector through string-based query construction +S608 Possible SQL injection vector through string-based query construction + --> S608.py:180:11 | 178 | FROM ({user_input}) raw 179 | """ 180 | query64 = f"update {t"{table}"} set var = {t"{var}"}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 181 | query65 = t"update {f"{table}"} set var = {f"{var}"}" | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap index 2482ce3206..1891b78f00 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap @@ -1,39 +1,43 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S609.py:4:10: S609 Possible wildcard injection in call due to `*` usage +S609 Possible wildcard injection in call due to `*` usage + --> S609.py:4:10 | 2 | import subprocess 3 | 4 | os.popen("chmod +w foo*") - | ^^^^^^^^^^^^^^^ S609 + | ^^^^^^^^^^^^^^^ 5 | subprocess.Popen("/bin/chown root: *", shell=True) 6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) | -S609.py:5:18: S609 Possible wildcard injection in call due to `*` usage +S609 Possible wildcard injection in call due to `*` usage + --> S609.py:5:18 | 4 | os.popen("chmod +w foo*") 5 | subprocess.Popen("/bin/chown root: *", shell=True) - | ^^^^^^^^^^^^^^^^^^^^ S609 + | ^^^^^^^^^^^^^^^^^^^^ 6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) 7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") | -S609.py:6:18: S609 Possible wildcard injection in call due to `*` usage +S609 Possible wildcard injection in call due to `*` usage + --> S609.py:6:18 | 4 | os.popen("chmod +w foo*") 5 | subprocess.Popen("/bin/chown root: *", shell=True) 6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S609 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") 8 | os.system("tar cf foo.tar bar/*") | -S609.py:8:11: S609 Possible wildcard injection in call due to `*` usage +S609 Possible wildcard injection in call due to `*` usage + --> S609.py:8:11 | 6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) 7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") 8 | os.system("tar cf foo.tar bar/*") - | ^^^^^^^^^^^^^^^^^^^^^^ S609 + | ^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S610_S610.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S610_S610.py.snap index 4a8bf84b1a..914a0ecfeb 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S610_S610.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S610_S610.py.snap @@ -1,105 +1,116 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S610.py:4:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:4:44 | 3 | # Errors 4 | User.objects.filter(username='admin').extra(dict(could_be='insecure')) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | User.objects.filter(username='admin').extra(select=dict(could_be='insecure')) 6 | User.objects.filter(username='admin').extra(select={'test': '%secure' % 'nos'}) | -S610.py:5:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:5:44 | 3 | # Errors 4 | User.objects.filter(username='admin').extra(dict(could_be='insecure')) 5 | User.objects.filter(username='admin').extra(select=dict(could_be='insecure')) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | User.objects.filter(username='admin').extra(select={'test': '%secure' % 'nos'}) 7 | User.objects.filter(username='admin').extra(select={'test': '{}secure'.format('nos')}) | -S610.py:6:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:6:44 | 4 | User.objects.filter(username='admin').extra(dict(could_be='insecure')) 5 | User.objects.filter(username='admin').extra(select=dict(could_be='insecure')) 6 | User.objects.filter(username='admin').extra(select={'test': '%secure' % 'nos'}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | User.objects.filter(username='admin').extra(select={'test': '{}secure'.format('nos')}) 8 | User.objects.filter(username='admin').extra(where=['%secure' % 'nos']) | -S610.py:7:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:7:44 | 5 | User.objects.filter(username='admin').extra(select=dict(could_be='insecure')) 6 | User.objects.filter(username='admin').extra(select={'test': '%secure' % 'nos'}) 7 | User.objects.filter(username='admin').extra(select={'test': '{}secure'.format('nos')}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | User.objects.filter(username='admin').extra(where=['%secure' % 'nos']) 9 | User.objects.filter(username='admin').extra(where=['{}secure'.format('no')]) | -S610.py:8:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:8:44 | 6 | User.objects.filter(username='admin').extra(select={'test': '%secure' % 'nos'}) 7 | User.objects.filter(username='admin').extra(select={'test': '{}secure'.format('nos')}) 8 | User.objects.filter(username='admin').extra(where=['%secure' % 'nos']) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | User.objects.filter(username='admin').extra(where=['{}secure'.format('no')]) | -S610.py:9:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:9:44 | 7 | User.objects.filter(username='admin').extra(select={'test': '{}secure'.format('nos')}) 8 | User.objects.filter(username='admin').extra(where=['%secure' % 'nos']) 9 | User.objects.filter(username='admin').extra(where=['{}secure'.format('no')]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | query = '"username") AS "username", * FROM "auth_user" WHERE 1=1 OR "username"=? --' | -S610.py:12:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:12:44 | 11 | query = '"username") AS "username", * FROM "auth_user" WHERE 1=1 OR "username"=? --' 12 | User.objects.filter(username='admin').extra(select={'test': query}) - | ^^^^^^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | where_var = ['1=1) OR 1=1 AND (1=1'] | -S610.py:15:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:15:44 | 14 | where_var = ['1=1) OR 1=1 AND (1=1'] 15 | User.objects.filter(username='admin').extra(where=where_var) - | ^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^ 16 | 17 | where_str = '1=1) OR 1=1 AND (1=1' | -S610.py:18:44: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:18:44 | 17 | where_str = '1=1) OR 1=1 AND (1=1' 18 | User.objects.filter(username='admin').extra(where=[where_str]) - | ^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^ 19 | 20 | tables_var = ['django_content_type" WHERE "auth_user"."username"="admin'] | -S610.py:21:25: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:21:25 | 20 | tables_var = ['django_content_type" WHERE "auth_user"."username"="admin'] 21 | User.objects.all().extra(tables=tables_var).distinct() - | ^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^ 22 | 23 | tables_str = 'django_content_type" WHERE "auth_user"."username"="admin' | -S610.py:24:25: S610 Use of Django `extra` can lead to SQL injection vulnerabilities +S610 Use of Django `extra` can lead to SQL injection vulnerabilities + --> S610.py:24:25 | 23 | tables_str = 'django_content_type" WHERE "auth_user"."username"="admin' 24 | User.objects.all().extra(tables=[tables_str]).distinct() - | ^^^^^^^^^^^^^^^^^^^^^ S610 + | ^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S611_S611.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S611_S611.py.snap index f3fd1629c5..8ef3a7c3e5 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S611_S611.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S611_S611.py.snap @@ -1,59 +1,64 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs -snapshot_kind: text --- -S611.py:5:27: S611 Use of `RawSQL` can lead to SQL injection vulnerabilities +S611 Use of `RawSQL` can lead to SQL injection vulnerabilities + --> S611.py:5:27 | 4 | User.objects.annotate(val=RawSQL('secure', [])) 5 | User.objects.annotate(val=RawSQL('%secure' % 'nos', [])) - | ^^^^^^ S611 + | ^^^^^^ 6 | User.objects.annotate(val=RawSQL('{}secure'.format('no'), [])) 7 | raw = '"username") AS "val" FROM "auth_user" WHERE "username"="admin" --' | -S611.py:6:27: S611 Use of `RawSQL` can lead to SQL injection vulnerabilities +S611 Use of `RawSQL` can lead to SQL injection vulnerabilities + --> S611.py:6:27 | 4 | User.objects.annotate(val=RawSQL('secure', [])) 5 | User.objects.annotate(val=RawSQL('%secure' % 'nos', [])) 6 | User.objects.annotate(val=RawSQL('{}secure'.format('no'), [])) - | ^^^^^^ S611 + | ^^^^^^ 7 | raw = '"username") AS "val" FROM "auth_user" WHERE "username"="admin" --' 8 | User.objects.annotate(val=RawSQL(raw, [])) | -S611.py:8:27: S611 Use of `RawSQL` can lead to SQL injection vulnerabilities +S611 Use of `RawSQL` can lead to SQL injection vulnerabilities + --> S611.py:8:27 | 6 | User.objects.annotate(val=RawSQL('{}secure'.format('no'), [])) 7 | raw = '"username") AS "val" FROM "auth_user" WHERE "username"="admin" --' 8 | User.objects.annotate(val=RawSQL(raw, [])) - | ^^^^^^ S611 + | ^^^^^^ 9 | raw = '"username") AS "val" FROM "auth_user"' \ 10 | ' WHERE "username"="admin" OR 1=%s --' | -S611.py:11:27: S611 Use of `RawSQL` can lead to SQL injection vulnerabilities +S611 Use of `RawSQL` can lead to SQL injection vulnerabilities + --> S611.py:11:27 | 9 | raw = '"username") AS "val" FROM "auth_user"' \ 10 | ' WHERE "username"="admin" OR 1=%s --' 11 | User.objects.annotate(val=RawSQL(raw, [0])) - | ^^^^^^ S611 + | ^^^^^^ 12 | User.objects.annotate(val=RawSQL(sql='{}secure'.format('no'), params=[])) 13 | User.objects.annotate(val=RawSQL(params=[], sql='{}secure'.format('no'))) | -S611.py:12:27: S611 Use of `RawSQL` can lead to SQL injection vulnerabilities +S611 Use of `RawSQL` can lead to SQL injection vulnerabilities + --> S611.py:12:27 | 10 | ' WHERE "username"="admin" OR 1=%s --' 11 | User.objects.annotate(val=RawSQL(raw, [0])) 12 | User.objects.annotate(val=RawSQL(sql='{}secure'.format('no'), params=[])) - | ^^^^^^ S611 + | ^^^^^^ 13 | User.objects.annotate(val=RawSQL(params=[], sql='{}secure'.format('no'))) | -S611.py:13:27: S611 Use of `RawSQL` can lead to SQL injection vulnerabilities +S611 Use of `RawSQL` can lead to SQL injection vulnerabilities + --> S611.py:13:27 | 11 | User.objects.annotate(val=RawSQL(raw, [0])) 12 | User.objects.annotate(val=RawSQL(sql='{}secure'.format('no'), params=[])) 13 | User.objects.annotate(val=RawSQL(params=[], sql='{}secure'.format('no'))) - | ^^^^^^ S611 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap index f7a16b78e4..e80d8f95fb 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S612.py:3:5: S612 Use of insecure `logging.config.listen` detected +S612 Use of insecure `logging.config.listen` detected + --> S612.py:3:5 | 1 | import logging.config 2 | 3 | t = logging.config.listen(9999) - | ^^^^^^^^^^^^^^^^^^^^^ S612 + | ^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | def verify_func(): | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap index 61b156e891..f441488f52 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap @@ -1,49 +1,54 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S701.py:9:57: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. +S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. + --> S701.py:9:57 | 7 | templateEnv = jinja2.Environment(autoescape=True, 8 | loader=templateLoader ) 9 | Environment(loader=templateLoader, load=templateLoader, autoescape=something) # S701 - | ^^^^^^^^^^^^^^^^^^^^ S701 + | ^^^^^^^^^^^^^^^^^^^^ 10 | templateEnv = jinja2.Environment(autoescape=False, loader=templateLoader ) # S701 11 | Environment(loader=templateLoader, | -S701.py:10:34: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. +S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. + --> S701.py:10:34 | 8 | loader=templateLoader ) 9 | Environment(loader=templateLoader, load=templateLoader, autoescape=something) # S701 10 | templateEnv = jinja2.Environment(autoescape=False, loader=templateLoader ) # S701 - | ^^^^^^^^^^^^^^^^ S701 + | ^^^^^^^^^^^^^^^^ 11 | Environment(loader=templateLoader, 12 | load=templateLoader, | -S701.py:13:13: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. +S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. + --> S701.py:13:13 | 11 | Environment(loader=templateLoader, 12 | load=templateLoader, 13 | autoescape=False) # S701 - | ^^^^^^^^^^^^^^^^ S701 + | ^^^^^^^^^^^^^^^^ 14 | 15 | Environment(loader=templateLoader, # S701 | -S701.py:15:1: S701 By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True` or the `select_autoescape` function to mitigate XSS vulnerabilities. +S701 By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True` or the `select_autoescape` function to mitigate XSS vulnerabilities. + --> S701.py:15:1 | 13 | autoescape=False) # S701 14 | 15 | Environment(loader=templateLoader, # S701 - | ^^^^^^^^^^^ S701 + | ^^^^^^^^^^^ 16 | load=templateLoader) | -S701.py:29:36: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. +S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. + --> S701.py:29:36 | 27 | def fake_func(): 28 | return 'foobar' 29 | Environment(loader=templateLoader, autoescape=fake_func()) # S701 - | ^^^^^^^^^^^^^^^^^^^^^^ S701 + | ^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S702_S702.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S702_S702.py.snap index 3297e5af7e..ac840f237c 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S702_S702.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S702_S702.py.snap @@ -1,26 +1,29 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S702.py:6:1: S702 Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks +S702 Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks + --> S702.py:6:1 | 6 | Template("hello") - | ^^^^^^^^ S702 + | ^^^^^^^^ 7 | 8 | mako.template.Template("hern") | -S702.py:8:1: S702 Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks +S702 Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks + --> S702.py:8:1 | 6 | Template("hello") 7 | 8 | mako.template.Template("hern") - | ^^^^^^^^^^^^^^^^^^^^^^ S702 + | ^^^^^^^^^^^^^^^^^^^^^^ 9 | template.Template("hern") | -S702.py:9:1: S702 Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks +S702 Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks + --> S702.py:9:1 | 8 | mako.template.Template("hern") 9 | template.Template("hern") - | ^^^^^^^^^^^^^^^^^ S702 + | ^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S704_S704.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S704_S704.py.snap index 02a25f90f6..b8e8dbf079 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S704_S704.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S704_S704.py.snap @@ -1,58 +1,64 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S704.py:5:1: S704 Unsafe use of `markupsafe.Markup` detected +S704 Unsafe use of `markupsafe.Markup` detected + --> S704.py:5:1 | 4 | content = "" 5 | Markup(f"unsafe {content}") # S704 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | flask.Markup("unsafe {}".format(content)) # S704 7 | Markup("safe {}").format(content) | -S704.py:6:1: S704 Unsafe use of `flask.Markup` detected +S704 Unsafe use of `flask.Markup` detected + --> S704.py:6:1 | 4 | content = "" 5 | Markup(f"unsafe {content}") # S704 6 | flask.Markup("unsafe {}".format(content)) # S704 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | Markup("safe {}").format(content) 8 | flask.Markup(b"safe {}", encoding='utf-8').format(content) | -S704.py:10:1: S704 Unsafe use of `markupsafe.Markup` detected +S704 Unsafe use of `markupsafe.Markup` detected + --> S704.py:10:1 | 8 | flask.Markup(b"safe {}", encoding='utf-8').format(content) 9 | escape(content) 10 | Markup(content) # S704 - | ^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^ 11 | flask.Markup("unsafe %s" % content) # S704 12 | Markup(object="safe") | -S704.py:11:1: S704 Unsafe use of `flask.Markup` detected +S704 Unsafe use of `flask.Markup` detected + --> S704.py:11:1 | 9 | escape(content) 10 | Markup(content) # S704 11 | flask.Markup("unsafe %s" % content) # S704 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | Markup(object="safe") 13 | Markup(object="unsafe {}".format(content)) # Not currently detected | -S704.py:17:1: S704 Unsafe use of `markupsafe.Markup` detected +S704 Unsafe use of `markupsafe.Markup` detected + --> S704.py:17:1 | 15 | # NOTE: We may be able to get rid of these false positives with ty 16 | # if it includes comprehensive constant expression detection/evaluation. 17 | Markup("*" * 8) # S704 (false positive) - | ^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^ 18 | flask.Markup("hello {}".format("world")) # S704 (false positive) | -S704.py:18:1: S704 Unsafe use of `flask.Markup` detected +S704 Unsafe use of `flask.Markup` detected + --> S704.py:18:1 | 16 | # if it includes comprehensive constant expression detection/evaluation. 17 | Markup("*" * 8) # S704 (false positive) 18 | flask.Markup("hello {}".format("world")) # S704 (false positive) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__extend_allow_callables__S704_S704_extend_markup_names.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__extend_allow_callables__S704_S704_extend_markup_names.py.snap index 924e5f9623..79837b781f 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__extend_allow_callables__S704_S704_extend_markup_names.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__extend_allow_callables__S704_S704_extend_markup_names.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S704_extend_markup_names.py:5:1: S704 Unsafe use of `markupsafe.Markup` detected +S704 Unsafe use of `markupsafe.Markup` detected + --> S704_extend_markup_names.py:5:1 | 4 | content = "" 5 | Markup(f"unsafe {content}") # S704 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | literal(f"unsafe {content}") # S704 | -S704_extend_markup_names.py:6:1: S704 Unsafe use of `webhelpers.html.literal` detected +S704 Unsafe use of `webhelpers.html.literal` detected + --> S704_extend_markup_names.py:6:1 | 4 | content = "" 5 | Markup(f"unsafe {content}") # S704 6 | literal(f"unsafe {content}") # S704 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__extend_allow_callables__S704_S704_skip_early_out.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__extend_allow_callables__S704_S704_skip_early_out.py.snap index 8c04fdf49f..30e3e0491d 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__extend_allow_callables__S704_S704_skip_early_out.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__extend_allow_callables__S704_S704_skip_early_out.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S704_skip_early_out.py:7:1: S704 Unsafe use of `webhelpers.html.literal` detected +S704 Unsafe use of `webhelpers.html.literal` detected + --> S704_skip_early_out.py:7:1 | 5 | # markupsafe or flask first. 6 | content = "" 7 | literal(f"unsafe {content}") # S704 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S301_S301.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S301_S301.py.snap index e89cb34be1..22be1472f5 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S301_S301.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S301_S301.py.snap @@ -1,26 +1,29 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S301.py:3:1: S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue +S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue + --> S301.py:3:1 | 1 | import pickle 2 | 3 | pickle.loads() - | ^^^^^^^^^^^^^^ S301 + | ^^^^^^^^^^^^^^ | -S301.py:7:5: S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue +S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue + --> S301.py:7:5 | 6 | # https://github.com/astral-sh/ruff/issues/15522 7 | map(pickle.load, []) - | ^^^^^^^^^^^ S301 + | ^^^^^^^^^^^ 8 | foo = pickle.load | -S301.py:8:7: S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue +S301 `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue + --> S301.py:8:7 | 6 | # https://github.com/astral-sh/ruff/issues/15522 7 | map(pickle.load, []) 8 | foo = pickle.load - | ^^^^^^^^^^^ S301 + | ^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S307_S307.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S307_S307.py.snap index dbad2672aa..370c77c3ac 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S307_S307.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S307_S307.py.snap @@ -1,34 +1,38 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S307.py:3:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` +S307 Use of possibly insecure function; consider using `ast.literal_eval` + --> S307.py:3:7 | 1 | import os 2 | 3 | print(eval("1+1")) # S307 - | ^^^^^^^^^^^ S307 + | ^^^^^^^^^^^ 4 | print(eval("os.getcwd()")) # S307 | -S307.py:4:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` +S307 Use of possibly insecure function; consider using `ast.literal_eval` + --> S307.py:4:7 | 3 | print(eval("1+1")) # S307 4 | print(eval("os.getcwd()")) # S307 - | ^^^^^^^^^^^^^^^^^^^ S307 + | ^^^^^^^^^^^^^^^^^^^ | -S307.py:16:5: S307 Use of possibly insecure function; consider using `ast.literal_eval` +S307 Use of possibly insecure function; consider using `ast.literal_eval` + --> S307.py:16:5 | 15 | # https://github.com/astral-sh/ruff/issues/15522 16 | map(eval, []) - | ^^^^ S307 + | ^^^^ 17 | foo = eval | -S307.py:17:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` +S307 Use of possibly insecure function; consider using `ast.literal_eval` + --> S307.py:17:7 | 15 | # https://github.com/astral-sh/ruff/issues/15522 16 | map(eval, []) 17 | foo = eval - | ^^^^ S307 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S308_S308.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S308_S308.py.snap index bc0f4d524e..c2fcb4b8f1 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S308_S308.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S308_S308.py.snap @@ -1,132 +1,146 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S308.py:6:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:6:5 | 4 | def bad_func(): 5 | inject = "harmful_input" 6 | mark_safe(inject) - | ^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^ 7 | mark_safe("I will add" + inject + "to my string") 8 | mark_safe("I will add %s to my string" % inject) | -S308.py:7:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:7:5 | 5 | inject = "harmful_input" 6 | mark_safe(inject) 7 | mark_safe("I will add" + inject + "to my string") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | mark_safe("I will add %s to my string" % inject) 9 | mark_safe("I will add {} to my string".format(inject)) | -S308.py:8:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:8:5 | 6 | mark_safe(inject) 7 | mark_safe("I will add" + inject + "to my string") 8 | mark_safe("I will add %s to my string" % inject) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | mark_safe("I will add {} to my string".format(inject)) 10 | mark_safe(f"I will add {inject} to my string") | -S308.py:9:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:9:5 | 7 | mark_safe("I will add" + inject + "to my string") 8 | mark_safe("I will add %s to my string" % inject) 9 | mark_safe("I will add {} to my string".format(inject)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | mark_safe(f"I will add {inject} to my string") | -S308.py:10:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:10:5 | 8 | mark_safe("I will add %s to my string" % inject) 9 | mark_safe("I will add {} to my string".format(inject)) 10 | mark_safe(f"I will add {inject} to my string") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | def good_func(): | -S308.py:16:2: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:16:2 | 16 | @mark_safe - | ^^^^^^^^^ S308 + | ^^^^^^^^^ 17 | def some_func(): 18 | return '' | -S308.py:26:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:26:5 | 24 | def bad_func(): 25 | inject = "harmful_input" 26 | mark_safe(inject) - | ^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^ 27 | mark_safe("I will add" + inject + "to my string") 28 | mark_safe("I will add %s to my string" % inject) | -S308.py:27:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:27:5 | 25 | inject = "harmful_input" 26 | mark_safe(inject) 27 | mark_safe("I will add" + inject + "to my string") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | mark_safe("I will add %s to my string" % inject) 29 | mark_safe("I will add {} to my string".format(inject)) | -S308.py:28:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:28:5 | 26 | mark_safe(inject) 27 | mark_safe("I will add" + inject + "to my string") 28 | mark_safe("I will add %s to my string" % inject) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | mark_safe("I will add {} to my string".format(inject)) 30 | mark_safe(f"I will add {inject} to my string") | -S308.py:29:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:29:5 | 27 | mark_safe("I will add" + inject + "to my string") 28 | mark_safe("I will add %s to my string" % inject) 29 | mark_safe("I will add {} to my string".format(inject)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | mark_safe(f"I will add {inject} to my string") | -S308.py:30:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:30:5 | 28 | mark_safe("I will add %s to my string" % inject) 29 | mark_safe("I will add {} to my string".format(inject)) 30 | mark_safe(f"I will add {inject} to my string") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S308 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | 32 | def good_func(): | -S308.py:36:2: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:36:2 | 36 | @mark_safe - | ^^^^^^^^^ S308 + | ^^^^^^^^^ 37 | def some_func(): 38 | return '' | -S308.py:42:5: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:42:5 | 41 | # https://github.com/astral-sh/ruff/issues/15522 42 | map(mark_safe, []) - | ^^^^^^^^^ S308 + | ^^^^^^^^^ 43 | foo = mark_safe | -S308.py:43:7: S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities +S308 Use of `mark_safe` may expose cross-site scripting vulnerabilities + --> S308.py:43:7 | 41 | # https://github.com/astral-sh/ruff/issues/15522 42 | map(mark_safe, []) 43 | foo = mark_safe - | ^^^^^^^^^ S308 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S310_S310.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S310_S310.py.snap index 6a02c7b1fd..490d8db719 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S310_S310.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S310_S310.py.snap @@ -1,248 +1,274 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S310.py:6:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:6:1 | 4 | urllib.request.urlopen(url=f'http://www.google.com') 5 | urllib.request.urlopen(url='http://' + 'www' + '.google.com') 6 | urllib.request.urlopen(url='http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | urllib.request.urlopen(url=f'http://www.google.com', **kwargs) 8 | urllib.request.urlopen('http://www.google.com') | -S310.py:7:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:7:1 | 5 | urllib.request.urlopen(url='http://' + 'www' + '.google.com') 6 | urllib.request.urlopen(url='http://www.google.com', **kwargs) 7 | urllib.request.urlopen(url=f'http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | urllib.request.urlopen('http://www.google.com') 9 | urllib.request.urlopen(f'http://www.google.com') | -S310.py:10:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:10:1 | 8 | urllib.request.urlopen('http://www.google.com') 9 | urllib.request.urlopen(f'http://www.google.com') 10 | urllib.request.urlopen('file:///foo/bar/baz') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | urllib.request.urlopen(url) | -S310.py:11:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:11:1 | 9 | urllib.request.urlopen(f'http://www.google.com') 10 | urllib.request.urlopen('file:///foo/bar/baz') 11 | urllib.request.urlopen(url) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | urllib.request.Request(url='http://www.google.com') | -S310.py:16:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:16:1 | 14 | urllib.request.Request(url=f'http://www.google.com') 15 | urllib.request.Request(url='http://' + 'www' + '.google.com') 16 | urllib.request.Request(url='http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | urllib.request.Request(url=f'http://www.google.com', **kwargs) 18 | urllib.request.Request('http://www.google.com') | -S310.py:17:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:17:1 | 15 | urllib.request.Request(url='http://' + 'www' + '.google.com') 16 | urllib.request.Request(url='http://www.google.com', **kwargs) 17 | urllib.request.Request(url=f'http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | urllib.request.Request('http://www.google.com') 19 | urllib.request.Request(f'http://www.google.com') | -S310.py:20:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:20:1 | 18 | urllib.request.Request('http://www.google.com') 19 | urllib.request.Request(f'http://www.google.com') 20 | urllib.request.Request('file:///foo/bar/baz') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | urllib.request.Request(url) | -S310.py:21:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:21:1 | 19 | urllib.request.Request(f'http://www.google.com') 20 | urllib.request.Request('file:///foo/bar/baz') 21 | urllib.request.Request(url) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') | -S310.py:23:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:23:1 | 21 | urllib.request.Request(url) 22 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') | -S310.py:24:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:24:1 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) | -S310.py:25:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:25:1 | 23 | urllib.request.URLopener().open(fullurl='http://www.google.com') 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) | -S310.py:26:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:26:1 | 24 | urllib.request.URLopener().open(fullurl=f'http://www.google.com') 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) 28 | urllib.request.URLopener().open('http://www.google.com') | -S310.py:27:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:27:1 | 25 | urllib.request.URLopener().open(fullurl='http://' + 'www' + '.google.com') 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | urllib.request.URLopener().open('http://www.google.com') 29 | urllib.request.URLopener().open(f'http://www.google.com') | -S310.py:28:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:28:1 | 26 | urllib.request.URLopener().open(fullurl='http://www.google.com', **kwargs) 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) 28 | urllib.request.URLopener().open('http://www.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | urllib.request.URLopener().open(f'http://www.google.com') 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') | -S310.py:29:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:29:1 | 27 | urllib.request.URLopener().open(fullurl=f'http://www.google.com', **kwargs) 28 | urllib.request.URLopener().open('http://www.google.com') 29 | urllib.request.URLopener().open(f'http://www.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') 31 | urllib.request.URLopener().open('file:///foo/bar/baz') | -S310.py:30:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:30:1 | 28 | urllib.request.URLopener().open('http://www.google.com') 29 | urllib.request.URLopener().open(f'http://www.google.com') 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | urllib.request.URLopener().open('file:///foo/bar/baz') 32 | urllib.request.URLopener().open(url) | -S310.py:31:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:31:1 | 29 | urllib.request.URLopener().open(f'http://www.google.com') 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') 31 | urllib.request.URLopener().open('file:///foo/bar/baz') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | urllib.request.URLopener().open(url) | -S310.py:32:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:32:1 | 30 | urllib.request.URLopener().open('http://' + 'www' + '.google.com') 31 | urllib.request.URLopener().open('file:///foo/bar/baz') 32 | urllib.request.URLopener().open(url) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | 34 | urllib.request.urlopen(url=urllib.request.Request('http://www.google.com')) | -S310.py:37:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:37:1 | 35 | urllib.request.urlopen(url=urllib.request.Request(f'http://www.google.com')) 36 | urllib.request.urlopen(url=urllib.request.Request('http://' + 'www' + '.google.com')) 37 | urllib.request.urlopen(url=urllib.request.Request('http://www.google.com'), **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | urllib.request.urlopen(url=urllib.request.Request(f'http://www.google.com'), **kwargs) 39 | urllib.request.urlopen(urllib.request.Request('http://www.google.com')) | -S310.py:38:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:38:1 | 36 | urllib.request.urlopen(url=urllib.request.Request('http://' + 'www' + '.google.com')) 37 | urllib.request.urlopen(url=urllib.request.Request('http://www.google.com'), **kwargs) 38 | urllib.request.urlopen(url=urllib.request.Request(f'http://www.google.com'), **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | urllib.request.urlopen(urllib.request.Request('http://www.google.com')) 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) | -S310.py:41:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:41:1 | 39 | urllib.request.urlopen(urllib.request.Request('http://www.google.com')) 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) 41 | urllib.request.urlopen(urllib.request.Request('file:///foo/bar/baz')) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | urllib.request.urlopen(urllib.request.Request(url)) | -S310.py:41:24: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:41:24 | 39 | urllib.request.urlopen(urllib.request.Request('http://www.google.com')) 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) 41 | urllib.request.urlopen(urllib.request.Request('file:///foo/bar/baz')) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | urllib.request.urlopen(urllib.request.Request(url)) | -S310.py:42:1: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:42:1 | 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) 41 | urllib.request.urlopen(urllib.request.Request('file:///foo/bar/baz')) 42 | urllib.request.urlopen(urllib.request.Request(url)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -S310.py:42:24: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:42:24 | 40 | urllib.request.urlopen(urllib.request.Request(f'http://www.google.com')) 41 | urllib.request.urlopen(urllib.request.Request('file:///foo/bar/baz')) 42 | urllib.request.urlopen(urllib.request.Request(url)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -S310.py:46:5: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:46:5 | 45 | # https://github.com/astral-sh/ruff/issues/15522 46 | map(urllib.request.urlopen, []) - | ^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^ 47 | foo = urllib.request.urlopen | -S310.py:47:7: S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. +S310 Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected. + --> S310.py:47:7 | 45 | # https://github.com/astral-sh/ruff/issues/15522 46 | map(urllib.request.urlopen, []) 47 | foo = urllib.request.urlopen - | ^^^^^^^^^^^^^^^^^^^^^^ S310 + | ^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S311_S311.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S311_S311.py.snap index 2a410db20b..a7527710df 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S311_S311.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S311_S311.py.snap @@ -1,106 +1,117 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S311.py:10:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:10:1 | 9 | # Errors 10 | random.Random() - | ^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^ 11 | random.random() 12 | random.randrange() | -S311.py:11:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:11:1 | 9 | # Errors 10 | random.Random() 11 | random.random() - | ^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^ 12 | random.randrange() 13 | random.randint() | -S311.py:12:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:12:1 | 10 | random.Random() 11 | random.random() 12 | random.randrange() - | ^^^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^^^ 13 | random.randint() 14 | random.choice() | -S311.py:13:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:13:1 | 11 | random.random() 12 | random.randrange() 13 | random.randint() - | ^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^ 14 | random.choice() 15 | random.choices() | -S311.py:14:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:14:1 | 12 | random.randrange() 13 | random.randint() 14 | random.choice() - | ^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^ 15 | random.choices() 16 | random.uniform() | -S311.py:15:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:15:1 | 13 | random.randint() 14 | random.choice() 15 | random.choices() - | ^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^ 16 | random.uniform() 17 | random.triangular() | -S311.py:16:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:16:1 | 14 | random.choice() 15 | random.choices() 16 | random.uniform() - | ^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^ 17 | random.triangular() 18 | random.randbytes() | -S311.py:17:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:17:1 | 15 | random.choices() 16 | random.uniform() 17 | random.triangular() - | ^^^^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^^^^ 18 | random.randbytes() | -S311.py:18:1: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:18:1 | 16 | random.uniform() 17 | random.triangular() 18 | random.randbytes() - | ^^^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^^^ 19 | 20 | # Unrelated | -S311.py:26:5: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:26:5 | 25 | # https://github.com/astral-sh/ruff/issues/15522 26 | map(random.randrange, []) - | ^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^ 27 | foo = random.randrange | -S311.py:27:7: S311 Standard pseudo-random generators are not suitable for cryptographic purposes +S311 Standard pseudo-random generators are not suitable for cryptographic purposes + --> S311.py:27:7 | 25 | # https://github.com/astral-sh/ruff/issues/15522 26 | map(random.randrange, []) 27 | foo = random.randrange - | ^^^^^^^^^^^^^^^^ S311 + | ^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S312_S312.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S312_S312.py.snap index 4d81c740bf..f2b0afc046 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S312_S312.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__preview__S312_S312.py.snap @@ -1,46 +1,51 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S312.py:3:1: S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. +S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. + --> S312.py:3:1 | 1 | from telnetlib import Telnet 2 | 3 | Telnet("localhost", 23) - | ^^^^^^^^^^^^^^^^^^^^^^^ S312 + | ^^^^^^^^^^^^^^^^^^^^^^^ | -S312.py:7:5: S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. +S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. + --> S312.py:7:5 | 6 | # https://github.com/astral-sh/ruff/issues/15522 7 | map(Telnet, []) - | ^^^^^^ S312 + | ^^^^^^ 8 | foo = Telnet | -S312.py:8:7: S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. +S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. + --> S312.py:8:7 | 6 | # https://github.com/astral-sh/ruff/issues/15522 7 | map(Telnet, []) 8 | foo = Telnet - | ^^^^^^ S312 + | ^^^^^^ 9 | 10 | import telnetlib | -S312.py:11:5: S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. +S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. + --> S312.py:11:5 | 10 | import telnetlib 11 | _ = telnetlib.Telnet - | ^^^^^^^^^^^^^^^^ S312 + | ^^^^^^^^^^^^^^^^ 12 | 13 | from typing import Annotated | -S312.py:14:24: S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. +S312 Telnet is considered insecure. Use SSH or some other encrypted protocol. + --> S312.py:14:24 | 13 | from typing import Annotated 14 | foo: Annotated[Telnet, telnetlib.Telnet()] - | ^^^^^^^^^^^^^^^^^^ S312 + | ^^^^^^^^^^^^^^^^^^ 15 | 16 | def _() -> Telnet: ... | diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__whitelisted_markup_calls__S704_S704_whitelisted_markup_calls.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__whitelisted_markup_calls__S704_S704_whitelisted_markup_calls.py.snap index e326335411..224777670e 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__whitelisted_markup_calls__S704_S704_whitelisted_markup_calls.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__whitelisted_markup_calls__S704_S704_whitelisted_markup_calls.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs --- -S704_whitelisted_markup_calls.py:9:1: S704 Unsafe use of `markupsafe.Markup` detected +S704 Unsafe use of `markupsafe.Markup` detected + --> S704_whitelisted_markup_calls.py:9:1 | 7 | # indirect assignments are currently not supported 8 | cleaned = clean(content) 9 | Markup(cleaned) # S704 - | ^^^^^^^^^^^^^^^ S704 + | ^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_blind_except/snapshots/ruff_linter__rules__flake8_blind_except__tests__BLE001_BLE.py.snap b/crates/ruff_linter/src/rules/flake8_blind_except/snapshots/ruff_linter__rules__flake8_blind_except__tests__BLE001_BLE.py.snap index 8e0f48c034..9c4b219a3b 100644 --- a/crates/ruff_linter/src/rules/flake8_blind_except/snapshots/ruff_linter__rules__flake8_blind_except__tests__BLE001_BLE.py.snap +++ b/crates/ruff_linter/src/rules/flake8_blind_except/snapshots/ruff_linter__rules__flake8_blind_except__tests__BLE001_BLE.py.snap @@ -1,239 +1,265 @@ --- source: crates/ruff_linter/src/rules/flake8_blind_except/mod.rs --- -BLE.py:25:8: BLE001 Do not catch blind exception: `BaseException` +BLE001 Do not catch blind exception: `BaseException` + --> BLE.py:25:8 | 23 | except Exception as e: 24 | raise e 25 | except BaseException: - | ^^^^^^^^^^^^^ BLE001 + | ^^^^^^^^^^^^^ 26 | pass | -BLE.py:31:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:31:8 | 29 | try: 30 | pass 31 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 32 | pass 33 | finally: | -BLE.py:42:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:42:8 | 40 | try: 41 | pass 42 | except Exception as e: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 43 | try: 44 | raise e | -BLE.py:45:12: BLE001 Do not catch blind exception: `BaseException` +BLE001 Do not catch blind exception: `BaseException` + --> BLE.py:45:12 | 43 | try: 44 | raise e 45 | except BaseException: - | ^^^^^^^^^^^^^ BLE001 + | ^^^^^^^^^^^^^ 46 | pass | -BLE.py:54:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:54:8 | 52 | except BaseException as e: 53 | raise e 54 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 55 | pass | -BLE.py:60:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:60:8 | 58 | try: 59 | pass 60 | except Exception as e: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 61 | raise bad 62 | except BaseException: | -BLE.py:62:8: BLE001 Do not catch blind exception: `BaseException` +BLE001 Do not catch blind exception: `BaseException` + --> BLE.py:62:8 | 60 | except Exception as e: 61 | raise bad 62 | except BaseException: - | ^^^^^^^^^^^^^ BLE001 + | ^^^^^^^^^^^^^ 63 | pass | -BLE.py:69:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:69:8 | 67 | try: 68 | pass 69 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 70 | logging.error("...") | -BLE.py:75:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:75:8 | 73 | try: 74 | pass 75 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 76 | logging.error("...", exc_info=False) | -BLE.py:81:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:81:8 | 79 | try: 80 | pass 81 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 82 | logging.error("...", exc_info=None) | -BLE.py:101:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:101:8 | 99 | try: 100 | pass 101 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 102 | error("...") | -BLE.py:107:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:107:8 | 105 | try: 106 | pass 107 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 108 | error("...", exc_info=False) | -BLE.py:113:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:113:8 | 111 | try: 112 | pass 113 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 114 | error("...", exc_info=None) | -BLE.py:119:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:119:8 | 117 | try: 118 | pass 119 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 120 | critical("...") | -BLE.py:125:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:125:8 | 123 | try: 124 | pass 125 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 126 | critical("...", exc_info=False) | -BLE.py:131:8: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:131:8 | 129 | try: 130 | pass 131 | except Exception: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 132 | critical("...", exc_info=None) | -BLE.py:169:9: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:169:9 | 167 | try: 168 | pass 169 | except (Exception,): - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 170 | pass | -BLE.py:174:9: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:174:9 | 172 | try: 173 | pass 174 | except (Exception, ValueError): - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 175 | pass | -BLE.py:179:21: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:179:21 | 177 | try: 178 | pass 179 | except (ValueError, Exception): - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 180 | pass | -BLE.py:184:21: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:184:21 | 182 | try: 183 | pass 184 | except (ValueError, Exception) as e: - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 185 | print(e) | -BLE.py:189:9: BLE001 Do not catch blind exception: `BaseException` +BLE001 Do not catch blind exception: `BaseException` + --> BLE.py:189:9 | 187 | try: 188 | pass 189 | except (BaseException, TypeError): - | ^^^^^^^^^^^^^ BLE001 + | ^^^^^^^^^^^^^ 190 | pass | -BLE.py:194:20: BLE001 Do not catch blind exception: `BaseException` +BLE001 Do not catch blind exception: `BaseException` + --> BLE.py:194:20 | 192 | try: 193 | pass 194 | except (TypeError, BaseException): - | ^^^^^^^^^^^^^ BLE001 + | ^^^^^^^^^^^^^ 195 | pass | -BLE.py:199:9: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:199:9 | 197 | try: 198 | pass 199 | except (Exception, BaseException): - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 200 | pass | -BLE.py:204:9: BLE001 Do not catch blind exception: `BaseException` +BLE001 Do not catch blind exception: `BaseException` + --> BLE.py:204:9 | 202 | try: 203 | pass 204 | except (BaseException, Exception): - | ^^^^^^^^^^^^^ BLE001 + | ^^^^^^^^^^^^^ 205 | pass | -BLE.py:210:10: BLE001 Do not catch blind exception: `Exception` +BLE001 Do not catch blind exception: `Exception` + --> BLE.py:210:10 | 208 | try: 209 | pass 210 | except ((Exception, ValueError), TypeError): - | ^^^^^^^^^ BLE001 + | ^^^^^^^^^ 211 | pass | -BLE.py:215:22: BLE001 Do not catch blind exception: `BaseException` +BLE001 Do not catch blind exception: `BaseException` + --> BLE.py:215:22 | 213 | try: 214 | pass 215 | except (ValueError, (BaseException, TypeError)): - | ^^^^^^^^^^^^^ BLE001 + | ^^^^^^^^^^^^^ 216 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap index ee91fa49f8..2ab5c9ac07 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap @@ -1,104 +1,115 @@ --- source: crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs --- -FBT.py:4:5: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:4:5 | 2 | posonly_nohint, 3 | posonly_nonboolhint: int, 4 | posonly_boolhint: bool, - | ^^^^^^^^^^^^^^^^ FBT001 + | ^^^^^^^^^^^^^^^^ 5 | posonly_boolstrhint: "bool", 6 | /, | -FBT.py:5:5: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:5:5 | 3 | posonly_nonboolhint: int, 4 | posonly_boolhint: bool, 5 | posonly_boolstrhint: "bool", - | ^^^^^^^^^^^^^^^^^^^ FBT001 + | ^^^^^^^^^^^^^^^^^^^ 6 | /, 7 | offset, | -FBT.py:10:5: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:10:5 | 8 | posorkw_nonvalued_nohint, 9 | posorkw_nonvalued_nonboolhint: int, 10 | posorkw_nonvalued_boolhint: bool, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | posorkw_nonvalued_boolstrhint: "bool", 12 | posorkw_boolvalued_nohint=True, | -FBT.py:11:5: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:11:5 | 9 | posorkw_nonvalued_nonboolhint: int, 10 | posorkw_nonvalued_boolhint: bool, 11 | posorkw_nonvalued_boolstrhint: "bool", - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | posorkw_boolvalued_nohint=True, 13 | posorkw_boolvalued_nonboolhint: int = True, | -FBT.py:14:5: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:14:5 | 12 | posorkw_boolvalued_nohint=True, 13 | posorkw_boolvalued_nonboolhint: int = True, 14 | posorkw_boolvalued_boolhint: bool = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | posorkw_boolvalued_boolstrhint: "bool" = True, 16 | posorkw_nonboolvalued_nohint=1, | -FBT.py:15:5: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:15:5 | 13 | posorkw_boolvalued_nonboolhint: int = True, 14 | posorkw_boolvalued_boolhint: bool = True, 15 | posorkw_boolvalued_boolstrhint: "bool" = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | posorkw_nonboolvalued_nohint=1, 17 | posorkw_nonboolvalued_nonboolhint: int = 2, | -FBT.py:18:5: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:18:5 | 16 | posorkw_nonboolvalued_nohint=1, 17 | posorkw_nonboolvalued_nonboolhint: int = 2, 18 | posorkw_nonboolvalued_boolhint: bool = 3, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | posorkw_nonboolvalued_boolstrhint: "bool" = 4, 20 | *, | -FBT.py:19:5: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:19:5 | 17 | posorkw_nonboolvalued_nonboolhint: int = 2, 18 | posorkw_nonboolvalued_boolhint: bool = 3, 19 | posorkw_nonboolvalued_boolstrhint: "bool" = 4, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | *, 21 | kwonly_nonvalued_nohint, | -FBT.py:90:19: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:90:19 | 89 | # FBT001: Boolean positional arg in function definition 90 | def foo(self, value: bool) -> None: - | ^^^^^ FBT001 + | ^^^^^ 91 | pass | -FBT.py:100:10: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:100:10 | 100 | def func(x: Union[list, Optional[int | str | float | bool]]): - | ^ FBT001 + | ^ 101 | pass | -FBT.py:104:10: FBT001 Boolean-typed positional argument in function definition +FBT001 Boolean-typed positional argument in function definition + --> FBT.py:104:10 | 104 | def func(x: bool | str): - | ^ FBT001 + | ^ 105 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap index 1d8ce760c0..b7dcb5d11e 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap @@ -1,43 +1,46 @@ --- source: crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs -snapshot_kind: text --- -FBT.py:12:5: FBT002 Boolean default positional argument in function definition +FBT002 Boolean default positional argument in function definition + --> FBT.py:12:5 | 10 | posorkw_nonvalued_boolhint: bool, 11 | posorkw_nonvalued_boolstrhint: "bool", 12 | posorkw_boolvalued_nohint=True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | posorkw_boolvalued_nonboolhint: int = True, 14 | posorkw_boolvalued_boolhint: bool = True, | -FBT.py:13:5: FBT002 Boolean default positional argument in function definition +FBT002 Boolean default positional argument in function definition + --> FBT.py:13:5 | 11 | posorkw_nonvalued_boolstrhint: "bool", 12 | posorkw_boolvalued_nohint=True, 13 | posorkw_boolvalued_nonboolhint: int = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | posorkw_boolvalued_boolhint: bool = True, 15 | posorkw_boolvalued_boolstrhint: "bool" = True, | -FBT.py:14:5: FBT002 Boolean default positional argument in function definition +FBT002 Boolean default positional argument in function definition + --> FBT.py:14:5 | 12 | posorkw_boolvalued_nohint=True, 13 | posorkw_boolvalued_nonboolhint: int = True, 14 | posorkw_boolvalued_boolhint: bool = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | posorkw_boolvalued_boolstrhint: "bool" = True, 16 | posorkw_nonboolvalued_nohint=1, | -FBT.py:15:5: FBT002 Boolean default positional argument in function definition +FBT002 Boolean default positional argument in function definition + --> FBT.py:15:5 | 13 | posorkw_boolvalued_nonboolhint: int = True, 14 | posorkw_boolvalued_boolhint: bool = True, 15 | posorkw_boolvalued_boolstrhint: "bool" = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | posorkw_nonboolvalued_nohint=1, 17 | posorkw_nonboolvalued_nonboolhint: int = 2, | diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap index 5dc9e2b9db..e056ac76bc 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap @@ -1,62 +1,68 @@ --- source: crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs -snapshot_kind: text --- -FBT.py:41:11: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:41:11 | 41 | used("a", True) - | ^^^^ FBT003 + | ^^^^ 42 | used(do=True) | -FBT.py:56:11: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:56:11 | 54 | {}.pop(True, False) 55 | dict.fromkeys(("world",), True) 56 | {}.deploy(True, False) - | ^^^^ FBT003 + | ^^^^ 57 | getattr(someobj, attrname, False) 58 | mylist.index(True) | -FBT.py:56:17: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:56:17 | 54 | {}.pop(True, False) 55 | dict.fromkeys(("world",), True) 56 | {}.deploy(True, False) - | ^^^^^ FBT003 + | ^^^^^ 57 | getattr(someobj, attrname, False) 58 | mylist.index(True) | -FBT.py:120:10: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:120:10 | 120 | settings(True) - | ^^^^ FBT003 + | ^^^^ | -FBT.py:144:20: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:144:20 | 142 | is_foo_or_bar=Case( 143 | When(Q(is_foo=True) | Q(is_bar=True)), 144 | then=Value(True), - | ^^^^ FBT003 + | ^^^^ 145 | ), 146 | default=Value(False), | -FBT.py:146:19: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:146:19 | 144 | then=Value(True), 145 | ), 146 | default=Value(False), - | ^^^^^ FBT003 + | ^^^^^ 147 | ) | -FBT.py:156:23: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:156:23 | 155 | class Settings(BaseSettings): 156 | foo: bool = Field(True, exclude=True) - | ^^^^ FBT003 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__extend_allowed_callable.snap b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__extend_allowed_callable.snap index 058c871bf1..3630d70274 100644 --- a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__extend_allowed_callable.snap +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__extend_allowed_callable.snap @@ -1,36 +1,39 @@ --- source: crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs -snapshot_kind: text --- -FBT.py:41:11: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:41:11 | 41 | used("a", True) - | ^^^^ FBT003 + | ^^^^ 42 | used(do=True) | -FBT.py:56:11: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:56:11 | 54 | {}.pop(True, False) 55 | dict.fromkeys(("world",), True) 56 | {}.deploy(True, False) - | ^^^^ FBT003 + | ^^^^ 57 | getattr(someobj, attrname, False) 58 | mylist.index(True) | -FBT.py:56:17: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:56:17 | 54 | {}.pop(True, False) 55 | dict.fromkeys(("world",), True) 56 | {}.deploy(True, False) - | ^^^^^ FBT003 + | ^^^^^ 57 | getattr(someobj, attrname, False) 58 | mylist.index(True) | -FBT.py:120:10: FBT003 Boolean positional value in function call +FBT003 Boolean positional value in function call + --> FBT.py:120:10 | 120 | settings(True) - | ^^^^ FBT003 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B002_B002.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B002_B002.py.snap index bac4567388..891ffb6e4f 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B002_B002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B002_B002.py.snap @@ -1,35 +1,38 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B002.py:18:9: B002 Python does not support the unary prefix increment operator (`++`) +B002 Python does not support the unary prefix increment operator (`++`) + --> B002.py:18:9 | 17 | def this_is_buggy(n): 18 | x = ++n - | ^^^ B002 + | ^^^ 19 | y = --n 20 | return x, y | -B002.py:19:9: B002 Python does not support the unary prefix decrement operator (`--`) +B002 Python does not support the unary prefix decrement operator (`--`) + --> B002.py:19:9 | 17 | def this_is_buggy(n): 18 | x = ++n 19 | y = --n - | ^^^ B002 + | ^^^ 20 | return x, y | -B002.py:24:12: B002 Python does not support the unary prefix increment operator (`++`) +B002 Python does not support the unary prefix increment operator (`++`) + --> B002.py:24:12 | 23 | def this_is_buggy_too(n): 24 | return ++n, --n - | ^^^ B002 + | ^^^ | -B002.py:24:17: B002 Python does not support the unary prefix decrement operator (`--`) +B002 Python does not support the unary prefix decrement operator (`--`) + --> B002.py:24:17 | 23 | def this_is_buggy_too(n): 24 | return ++n, --n - | ^^^ B002 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap index 3220d72353..899fcdca28 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B003.py:9:1: B003 Assigning to `os.environ` doesn't clear the environment +B003 Assigning to `os.environ` doesn't clear the environment + --> B003.py:9:1 | 7 | from os import environ 8 | 9 | os.environ = {} - | ^^^^^^^^^^ B003 + | ^^^^^^^^^^ 10 | environ = {} # that's fine, assigning a new meaning to the module-level name | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap index 1ef53a053b..38f99c7fd6 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B004.py:3:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. +B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. + --> B004.py:3:8 | 1 | def this_is_a_bug(): 2 | o = object() 3 | if hasattr(o, "__call__"): - | ^^^^^^^^^^^^^^^^^^^^^^ B004 + | ^^^^^^^^^^^^^^^^^^^^^^ 4 | print("Ooh, callable! Or is it?") 5 | if getattr(o, "__call__", False): | - = help: Replace with `callable()` +help: Replace with `callable()` ℹ Safe fix 1 1 | def this_is_a_bug(): @@ -21,26 +22,28 @@ B004.py:3:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is 5 5 | if getattr(o, "__call__", False): 6 6 | print("Ooh, callable! Or is it?") -B004.py:5:8: B004 Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. +B004 Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. + --> B004.py:5:8 | 3 | if hasattr(o, "__call__"): 4 | print("Ooh, callable! Or is it?") 5 | if getattr(o, "__call__", False): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | print("Ooh, callable! Or is it?") | - = help: Replace with `callable()` +help: Replace with `callable()` -B004.py:12:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. +B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. + --> B004.py:12:8 | 10 | import builtins 11 | o = object() 12 | if builtins.hasattr(o, "__call__"): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | print("B U G") 14 | if builtins.getattr(o, "__call__", False): | - = help: Replace with `callable()` +help: Replace with `callable()` ℹ Safe fix 9 9 | def still_a_bug(): @@ -52,25 +55,27 @@ B004.py:12:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable i 14 14 | if builtins.getattr(o, "__call__", False): 15 15 | print("B U G") -B004.py:14:8: B004 Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. +B004 Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. + --> B004.py:14:8 | 12 | if builtins.hasattr(o, "__call__"): 13 | print("B U G") 14 | if builtins.getattr(o, "__call__", False): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | print("B U G") | - = help: Replace with `callable()` +help: Replace with `callable()` -B004.py:24:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. +B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. + --> B004.py:24:8 | 22 | return True 23 | 24 | if hasattr(o, "__call__"): - | ^^^^^^^^^^^^^^^^^^^^^^ B004 + | ^^^^^^^^^^^^^^^^^^^^^^ 25 | print("STILL a bug!") | - = help: Replace with `callable()` +help: Replace with `callable()` ℹ Safe fix 1 |+import builtins @@ -87,7 +92,8 @@ B004.py:24:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable i 26 27 | 27 28 | -B004.py:35:1: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. +B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. + --> B004.py:35:1 | 33 | # https://github.com/astral-sh/ruff/issues/18741 34 | # The autofix for this is unsafe due to the comments. @@ -98,9 +104,9 @@ B004.py:35:1: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable i 39 | | "__call__", # comment 4 40 | | # comment 5 41 | | ) - | |_^ B004 + | |_^ | - = help: Replace with `callable()` +help: Replace with `callable()` ℹ Unsafe fix 32 32 | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap index 9291a453fa..459b047d40 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap @@ -1,82 +1,90 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B005.py:4:1: B005 Using `.strip()` with multi-character strings is misleading +B005 Using `.strip()` with multi-character strings is misleading + --> B005.py:4:1 | 2 | s.strip(s) # no warning 3 | s.strip("we") # no warning 4 | s.strip(".facebook.com") # warning - | ^^^^^^^^^^^^^^^^^^^^^^^^ B005 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 5 | s.strip("e") # no warning 6 | s.strip("\n\t ") # no warning | -B005.py:7:1: B005 Using `.strip()` with multi-character strings is misleading +B005 Using `.strip()` with multi-character strings is misleading + --> B005.py:7:1 | 5 | s.strip("e") # no warning 6 | s.strip("\n\t ") # no warning 7 | s.strip(r"\n\t ") # warning - | ^^^^^^^^^^^^^^^^^ B005 + | ^^^^^^^^^^^^^^^^^ 8 | s.lstrip(s) # no warning 9 | s.lstrip("we") # no warning | -B005.py:10:1: B005 Using `.strip()` with multi-character strings is misleading +B005 Using `.strip()` with multi-character strings is misleading + --> B005.py:10:1 | 8 | s.lstrip(s) # no warning 9 | s.lstrip("we") # no warning 10 | s.lstrip(".facebook.com") # warning - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | s.lstrip("e") # no warning 12 | s.lstrip("\n\t ") # no warning | -B005.py:13:1: B005 Using `.strip()` with multi-character strings is misleading +B005 Using `.strip()` with multi-character strings is misleading + --> B005.py:13:1 | 11 | s.lstrip("e") # no warning 12 | s.lstrip("\n\t ") # no warning 13 | s.lstrip(r"\n\t ") # warning - | ^^^^^^^^^^^^^^^^^^ B005 + | ^^^^^^^^^^^^^^^^^^ 14 | s.rstrip(s) # no warning 15 | s.rstrip("we") # warning | -B005.py:16:1: B005 Using `.strip()` with multi-character strings is misleading +B005 Using `.strip()` with multi-character strings is misleading + --> B005.py:16:1 | 14 | s.rstrip(s) # no warning 15 | s.rstrip("we") # warning 16 | s.rstrip(".facebook.com") # warning - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | s.rstrip("e") # no warning 18 | s.rstrip("\n\t ") # no warning | -B005.py:19:1: B005 Using `.strip()` with multi-character strings is misleading +B005 Using `.strip()` with multi-character strings is misleading + --> B005.py:19:1 | 17 | s.rstrip("e") # no warning 18 | s.rstrip("\n\t ") # no warning 19 | s.rstrip(r"\n\t ") # warning - | ^^^^^^^^^^^^^^^^^^ B005 + | ^^^^^^^^^^^^^^^^^^ 20 | s.strip("a") # no warning 21 | s.strip("あ") # no warning | -B005.py:22:1: B005 Using `.strip()` with multi-character strings is misleading +B005 Using `.strip()` with multi-character strings is misleading + --> B005.py:22:1 | 20 | s.strip("a") # no warning 21 | s.strip("あ") # no warning 22 | s.strip("ああ") # warning - | ^^^^^^^^^^^^^^^ B005 + | ^^^^^^^^^^^^^^^ 23 | s.strip("\ufeff") # no warning 24 | s.strip("\u0074\u0065\u0073\u0074") # warning | -B005.py:24:1: B005 Using `.strip()` with multi-character strings is misleading +B005 Using `.strip()` with multi-character strings is misleading + --> B005.py:24:1 | 22 | s.strip("ああ") # warning 23 | s.strip("\ufeff") # no warning 24 | s.strip("\u0074\u0065\u0073\u0074") # warning - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | from somewhere import other_type, strip | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap index a14c6205fc..8f30bc0137 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B006_1.py:3:22: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_1.py:3:22 | 1 | # Docstring followed by a newline 2 | 3 | def foobar(foor, bar={}): - | ^^ B006 + | ^^ 4 | """ 5 | """ | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 1 1 | # Docstring followed by a newline diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap index 6148acae1a..0ec81d0153 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B006_2.py:4:22: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_2.py:4:22 | 2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 3 | 4 | def foobar(foor, bar={}): - | ^^ B006 + | ^^ 5 | """ 6 | """ | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 1 1 | # Docstring followed by whitespace with no newline diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap index 8e304f3b25..5887696daa 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B006_3.py:4:22: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_3.py:4:22 | 4 | def foobar(foor, bar={}): - | ^^ B006 + | ^^ 5 | """ 6 | """ | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 1 1 | # Docstring with no newline diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap index 500d1427df..8ba3e00cc1 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B006_4.py:7:26: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_4.py:7:26 | 6 | class FormFeedIndent: 7 | def __init__(self, a=[]): - | ^^ B006 + | ^^ 8 | print(a) | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 4 4 | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_5.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_5.py.snap index 2218f89382..1be1295fe3 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_5.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_5.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B006_5.py:5:49: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:5:49 | 5 | def import_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 6 | import os | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 2 2 | # https://github.com/astral-sh/ruff/issues/7616 @@ -23,13 +23,14 @@ B006_5.py:5:49: B006 [*] Do not use mutable data structures for argument default 8 10 | 9 11 | def import_module_with_values_wrong(value: dict[str, str] = {}): -B006_5.py:9:61: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:9:61 | 9 | def import_module_with_values_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 10 | import os | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 6 6 | import os @@ -45,14 +46,15 @@ B006_5.py:9:61: B006 [*] Do not use mutable data structures for argument default 13 15 | 14 16 | -B006_5.py:15:50: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:15:50 | 15 | def import_modules_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 16 | import os 17 | import sys | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 12 12 | return 2 @@ -69,13 +71,14 @@ B006_5.py:15:50: B006 [*] Do not use mutable data structures for argument defaul 20 22 | 21 23 | def from_import_module_wrong(value: dict[str, str] = {}): -B006_5.py:21:54: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:21:54 | 21 | def from_import_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 22 | from os import path | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 18 18 | import itertools @@ -90,14 +93,15 @@ B006_5.py:21:54: B006 [*] Do not use mutable data structures for argument defaul 24 26 | 25 27 | def from_imports_module_wrong(value: dict[str, str] = {}): -B006_5.py:25:55: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:25:55 | 25 | def from_imports_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 26 | from os import path 27 | from sys import version_info | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 22 22 | from os import path @@ -113,14 +117,15 @@ B006_5.py:25:55: B006 [*] Do not use mutable data structures for argument defaul 29 31 | 30 32 | def import_and_from_imports_module_wrong(value: dict[str, str] = {}): -B006_5.py:30:66: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:30:66 | 30 | def import_and_from_imports_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 31 | import os 32 | from sys import version_info | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 27 27 | from sys import version_info @@ -136,14 +141,15 @@ B006_5.py:30:66: B006 [*] Do not use mutable data structures for argument defaul 34 36 | 35 37 | def import_docstring_module_wrong(value: dict[str, str] = {}): -B006_5.py:35:59: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:35:59 | 35 | def import_docstring_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 36 | """Docstring""" 37 | import os | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 32 32 | from sys import version_info @@ -159,14 +165,15 @@ B006_5.py:35:59: B006 [*] Do not use mutable data structures for argument defaul 39 41 | 40 42 | def import_module_wrong(value: dict[str, str] = {}): -B006_5.py:40:49: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:40:49 | 40 | def import_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 41 | """Docstring""" 42 | import os; import sys | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 37 37 | import os @@ -182,14 +189,15 @@ B006_5.py:40:49: B006 [*] Do not use mutable data structures for argument defaul 44 46 | 45 47 | def import_module_wrong(value: dict[str, str] = {}): -B006_5.py:45:49: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:45:49 | 45 | def import_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 46 | """Docstring""" 47 | import os; import sys; x = 1 | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 42 42 | import os; import sys @@ -204,14 +212,15 @@ B006_5.py:45:49: B006 [*] Do not use mutable data structures for argument defaul 48 50 | 49 51 | -B006_5.py:50:49: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:50:49 | 50 | def import_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 51 | """Docstring""" 52 | import os; import sys | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 47 47 | import os; import sys; x = 1 @@ -227,13 +236,14 @@ B006_5.py:50:49: B006 [*] Do not use mutable data structures for argument defaul 54 56 | 55 57 | def import_module_wrong(value: dict[str, str] = {}): -B006_5.py:55:49: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:55:49 | 55 | def import_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 56 | import os; import sys | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 52 52 | import os; import sys @@ -248,13 +258,14 @@ B006_5.py:55:49: B006 [*] Do not use mutable data structures for argument defaul 58 60 | 59 61 | def import_module_wrong(value: dict[str, str] = {}): -B006_5.py:59:49: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:59:49 | 59 | def import_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 60 | import os; import sys; x = 1 | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 56 56 | import os; import sys @@ -268,13 +279,14 @@ B006_5.py:59:49: B006 [*] Do not use mutable data structures for argument defaul 61 63 | 62 64 | -B006_5.py:63:49: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_5.py:63:49 | 63 | def import_module_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 64 | import os; import sys | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 60 60 | import os; import sys; x = 1 @@ -289,24 +301,27 @@ B006_5.py:63:49: B006 [*] Do not use mutable data structures for argument defaul 66 68 | 67 69 | def import_module_wrong(value: dict[str, str] = {}): import os -B006_5.py:67:49: B006 Do not use mutable data structures for argument defaults +B006 Do not use mutable data structures for argument defaults + --> B006_5.py:67:49 | 67 | def import_module_wrong(value: dict[str, str] = {}): import os - | ^^ B006 + | ^^ | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function -B006_5.py:70:49: B006 Do not use mutable data structures for argument defaults +B006 Do not use mutable data structures for argument defaults + --> B006_5.py:70:49 | 70 | def import_module_wrong(value: dict[str, str] = {}): import os; import sys - | ^^ B006 + | ^^ | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function -B006_5.py:73:49: B006 Do not use mutable data structures for argument defaults +B006 Do not use mutable data structures for argument defaults + --> B006_5.py:73:49 | 73 | def import_module_wrong(value: dict[str, str] = {}): \ - | ^^ B006 + | ^^ 74 | import os | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap index 45040e91fb..0a8c9fc903 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_6.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B006_6.py:4:22: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_6.py:4:22 | 2 | # Same as B006_2.py, but import instead of docstring 3 | 4 | def foobar(foor, bar={}): - | ^^ B006 + | ^^ 5 | import os | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 1 1 | # Import followed by whitespace with no newline diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap index 3e00a26e6f..ab308b3660 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_7.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B006_7.py:4:22: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_7.py:4:22 | 2 | # Same as B006_3.py, but import instead of docstring 3 | 4 | def foobar(foor, bar={}): - | ^^ B006 + | ^^ 5 | import os | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 1 1 | # Import with no newline diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_8.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_8.py.snap index 059fe888d6..7528607254 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_8.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_8.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B006_8.py:1:19: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_8.py:1:19 | 1 | def foo(a: list = []): - | ^^ B006 + | ^^ 2 | raise NotImplementedError("") | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 1 |-def foo(a: list = []): @@ -17,14 +17,15 @@ B006_8.py:1:19: B006 [*] Do not use mutable data structures for argument default 3 3 | 4 4 | -B006_8.py:5:19: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_8.py:5:19 | 5 | def bar(a: dict = {}): - | ^^ B006 + | ^^ 6 | """ This one also has a docstring""" 7 | raise NotImplementedError("and has some text in here") | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 2 2 | raise NotImplementedError("") @@ -36,14 +37,15 @@ B006_8.py:5:19: B006 [*] Do not use mutable data structures for argument default 7 7 | raise NotImplementedError("and has some text in here") 8 8 | -B006_8.py:10:19: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_8.py:10:19 | 10 | def baz(a: list = []): - | ^^ B006 + | ^^ 11 | """This one raises a different exception""" 12 | raise IndexError() | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 7 7 | raise NotImplementedError("and has some text in here") @@ -58,13 +60,14 @@ B006_8.py:10:19: B006 [*] Do not use mutable data structures for argument defaul 13 15 | 14 16 | -B006_8.py:15:19: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_8.py:15:19 | 15 | def qux(a: list = []): - | ^^ B006 + | ^^ 16 | raise NotImplementedError | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 12 12 | raise IndexError() @@ -76,13 +79,14 @@ B006_8.py:15:19: B006 [*] Do not use mutable data structures for argument defaul 17 17 | 18 18 | -B006_8.py:19:20: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_8.py:19:20 | 19 | def quux(a: list = []): - | ^^ B006 + | ^^ 20 | raise NotImplemented | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 16 16 | raise NotImplementedError diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap index 1fa6c1c985..f73a7920c6 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B006_B008.py:63:25: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:63:25 | 63 | def this_is_wrong(value=[1, 2, 3]): - | ^^^^^^^^^ B006 + | ^^^^^^^^^ 64 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 60 60 | # Flag mutable literals/comprehensions @@ -19,13 +20,14 @@ B006_B008.py:63:25: B006 [*] Do not use mutable data structures for argument def 65 65 | 66 66 | -B006_B008.py:67:30: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:67:30 | 67 | def this_is_also_wrong(value={}): - | ^^ B006 + | ^^ 68 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 64 64 | ... @@ -37,15 +39,16 @@ B006_B008.py:67:30: B006 [*] Do not use mutable data structures for argument def 69 69 | 70 70 | -B006_B008.py:73:52: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:73:52 | 71 | class Foo: 72 | @staticmethod 73 | def this_is_also_wrong_and_more_indented(value={}): - | ^^ B006 + | ^^ 74 | pass | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 70 70 | @@ -57,16 +60,17 @@ B006_B008.py:73:52: B006 [*] Do not use mutable data structures for argument def 75 75 | 76 76 | -B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:77:31 | 77 | def multiline_arg_wrong(value={ | _______________________________^ 78 | | 79 | | }): - | |_^ B006 + | |_^ 80 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 74 74 | pass @@ -80,22 +84,24 @@ B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument def 81 79 | 82 80 | def single_line_func_wrong(value = {}): ... -B006_B008.py:82:36: B006 Do not use mutable data structures for argument defaults +B006 Do not use mutable data structures for argument defaults + --> B006_B008.py:82:36 | 80 | ... 81 | 82 | def single_line_func_wrong(value = {}): ... - | ^^ B006 + | ^^ | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function -B006_B008.py:85:20: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:85:20 | 85 | def and_this(value=set()): - | ^^^^^ B006 + | ^^^^^ 86 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 82 82 | def single_line_func_wrong(value = {}): ... @@ -107,13 +113,14 @@ B006_B008.py:85:20: B006 [*] Do not use mutable data structures for argument def 87 87 | 88 88 | -B006_B008.py:89:20: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:89:20 | 89 | def this_too(value=collections.OrderedDict()): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 86 86 | ... @@ -125,13 +132,14 @@ B006_B008.py:89:20: B006 [*] Do not use mutable data structures for argument def 91 91 | 92 92 | -B006_B008.py:93:32: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:93:32 | 93 | async def async_this_too(value=collections.defaultdict()): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 94 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 90 90 | ... @@ -143,13 +151,14 @@ B006_B008.py:93:32: B006 [*] Do not use mutable data structures for argument def 95 95 | 96 96 | -B006_B008.py:97:26: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:97:26 | 97 | def dont_forget_me(value=collections.deque()): - | ^^^^^^^^^^^^^^^^^^^ B006 + | ^^^^^^^^^^^^^^^^^^^ 98 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 94 94 | ... @@ -161,14 +170,15 @@ B006_B008.py:97:26: B006 [*] Do not use mutable data structures for argument def 99 99 | 100 100 | -B006_B008.py:102:46: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:102:46 | 101 | # N.B. we're also flagging the function call in the comprehension 102 | def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B006 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 103 | pass | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 99 99 | @@ -180,13 +190,14 @@ B006_B008.py:102:46: B006 [*] Do not use mutable data structures for argument de 104 104 | 105 105 | -B006_B008.py:106:46: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:106:46 | 106 | def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 107 | pass | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 103 103 | pass @@ -198,13 +209,14 @@ B006_B008.py:106:46: B006 [*] Do not use mutable data structures for argument de 108 108 | 109 109 | -B006_B008.py:110:45: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:110:45 | 110 | def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B006 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 111 | pass | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 107 107 | pass @@ -216,13 +228,14 @@ B006_B008.py:110:45: B006 [*] Do not use mutable data structures for argument de 112 112 | 113 113 | -B006_B008.py:114:33: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:114:33 | 114 | def kwonlyargs_mutable(*, value=[]): - | ^^ B006 + | ^^ 115 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 111 111 | pass @@ -234,15 +247,16 @@ B006_B008.py:114:33: B006 [*] Do not use mutable data structures for argument de 116 116 | 117 117 | -B006_B008.py:239:20: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:239:20 | 237 | # B006 and B008 238 | # We should handle arbitrary nesting of these B008. 239 | def nested_combo(a=[float(3), dt.datetime.now()]): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 240 | pass | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 236 236 | @@ -254,15 +268,16 @@ B006_B008.py:239:20: B006 [*] Do not use mutable data structures for argument de 241 241 | 242 242 | -B006_B008.py:276:27: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:276:27 | 275 | def mutable_annotations( 276 | a: list[int] | None = [], - | ^^ B006 + | ^^ 277 | b: Optional[Dict[int, int]] = {}, 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 273 273 | @@ -274,16 +289,17 @@ B006_B008.py:276:27: B006 [*] Do not use mutable data structures for argument de 278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), 279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -B006_B008.py:277:35: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:277:35 | 275 | def mutable_annotations( 276 | a: list[int] | None = [], 277 | b: Optional[Dict[int, int]] = {}, - | ^^ B006 + | ^^ 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 274 274 | @@ -295,16 +311,17 @@ B006_B008.py:277:35: B006 [*] Do not use mutable data structures for argument de 279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), 280 280 | ): -B006_B008.py:278:62: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:278:62 | 276 | a: list[int] | None = [], 277 | b: Optional[Dict[int, int]] = {}, 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - | ^^^^^ B006 + | ^^^^^ 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), 280 | ): | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 275 275 | def mutable_annotations( @@ -316,16 +333,17 @@ B006_B008.py:278:62: B006 [*] Do not use mutable data structures for argument de 280 280 | ): 281 281 | pass -B006_B008.py:279:80: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:279:80 | 277 | b: Optional[Dict[int, int]] = {}, 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - | ^^^^^ B006 + | ^^^^^ 280 | ): 281 | pass | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 276 276 | a: list[int] | None = [], @@ -337,13 +355,14 @@ B006_B008.py:279:80: B006 [*] Do not use mutable data structures for argument de 281 281 | pass 282 282 | -B006_B008.py:284:52: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:284:52 | 284 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 285 | """Docstring""" | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 281 281 | pass @@ -355,14 +374,15 @@ B006_B008.py:284:52: B006 [*] Do not use mutable data structures for argument de 286 286 | 287 287 | -B006_B008.py:288:52: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:288:52 | 288 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 289 | """Docstring""" 290 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 285 285 | """Docstring""" @@ -374,13 +394,14 @@ B006_B008.py:288:52: B006 [*] Do not use mutable data structures for argument de 290 290 | ... 291 291 | -B006_B008.py:293:52: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:293:52 | 293 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 294 | """Docstring"""; ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 290 290 | ... @@ -392,14 +413,15 @@ B006_B008.py:293:52: B006 [*] Do not use mutable data structures for argument de 295 295 | 296 296 | -B006_B008.py:297:52: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:297:52 | 297 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 298 | """Docstring"""; \ 299 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 294 294 | """Docstring"""; ... @@ -411,16 +433,17 @@ B006_B008.py:297:52: B006 [*] Do not use mutable data structures for argument de 299 299 | ... 300 300 | -B006_B008.py:302:52: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:302:52 | 302 | def single_line_func_wrong(value: dict[str, str] = { | ____________________________________________________^ 303 | | # This is a comment 304 | | }): - | |_^ B006 + | |_^ 305 | """Docstring""" | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 299 299 | ... @@ -434,22 +457,24 @@ B006_B008.py:302:52: B006 [*] Do not use mutable data structures for argument de 306 304 | 307 305 | -B006_B008.py:308:52: B006 Do not use mutable data structures for argument defaults +B006 Do not use mutable data structures for argument defaults + --> B006_B008.py:308:52 | 308 | def single_line_func_wrong(value: dict[str, str] = {}) \ - | ^^ B006 + | ^^ 309 | : \ 310 | """Docstring""" | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function -B006_B008.py:313:52: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_B008.py:313:52 | 313 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 + | ^^ 314 | """Docstring without newline""" | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 310 310 | """Docstring""" diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap index ea5052cf82..3deddf5fb4 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap @@ -1,25 +1,27 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B007.py:6:5: B007 Loop control variable `i` not used within loop body +B007 Loop control variable `i` not used within loop body + --> B007.py:6:5 | 4 | print(i) # name no longer defined on Python 3; no warning yet 5 | 6 | for i in range(10): # name not used within the loop; B007 - | ^ B007 + | ^ 7 | print(10) | - = help: Rename unused `i` to `_i` +help: Rename unused `i` to `_i` -B007.py:18:13: B007 [*] Loop control variable `k` not used within loop body +B007 [*] Loop control variable `k` not used within loop body + --> B007.py:18:13 | 16 | for i in range(10): 17 | for j in range(10): 18 | for k in range(10): # k not used, i and j used transitively - | ^ B007 + | ^ 19 | print(i + j) | - = help: Rename unused `k` to `_k` +help: Rename unused `k` to `_k` ℹ Unsafe fix 15 15 | @@ -31,21 +33,23 @@ B007.py:18:13: B007 [*] Loop control variable `k` not used within loop body 20 20 | 21 21 | -B007.py:30:5: B007 Loop control variable `i` not used within loop body +B007 Loop control variable `i` not used within loop body + --> B007.py:30:5 | 30 | for i, (j, (k, l)) in strange_generator(): # i, k not used - | ^ B007 + | ^ 31 | print(j, l) | - = help: Rename unused `i` to `_i` +help: Rename unused `i` to `_i` -B007.py:30:13: B007 [*] Loop control variable `k` not used within loop body +B007 [*] Loop control variable `k` not used within loop body + --> B007.py:30:13 | 30 | for i, (j, (k, l)) in strange_generator(): # i, k not used - | ^ B007 + | ^ 31 | print(j, l) | - = help: Rename unused `k` to `_k` +help: Rename unused `k` to `_k` ℹ Unsafe fix 27 27 | yield i, (j, (k, l)) @@ -57,58 +61,63 @@ B007.py:30:13: B007 [*] Loop control variable `k` not used within loop body 32 32 | 33 33 | FMT = "{foo} {bar}" -B007.py:34:10: B007 Loop control variable `bar` may not be used within loop body +B007 Loop control variable `bar` may not be used within loop body + --> B007.py:34:10 | 33 | FMT = "{foo} {bar}" 34 | for foo, bar in [(1, 2)]: - | ^^^ B007 + | ^^^ 35 | if foo: 36 | print(FMT.format(**locals())) | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` -B007.py:38:10: B007 Loop control variable `bar` may not be used within loop body +B007 Loop control variable `bar` may not be used within loop body + --> B007.py:38:10 | 36 | print(FMT.format(**locals())) 37 | 38 | for foo, bar in [(1, 2)]: - | ^^^ B007 + | ^^^ 39 | if foo: 40 | print(FMT.format(**globals())) | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` -B007.py:42:10: B007 Loop control variable `bar` may not be used within loop body +B007 Loop control variable `bar` may not be used within loop body + --> B007.py:42:10 | 40 | print(FMT.format(**globals())) 41 | 42 | for foo, bar in [(1, 2)]: - | ^^^ B007 + | ^^^ 43 | if foo: 44 | print(FMT.format(**vars())) | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` -B007.py:46:10: B007 Loop control variable `bar` may not be used within loop body +B007 Loop control variable `bar` may not be used within loop body + --> B007.py:46:10 | 44 | print(FMT.format(**vars())) 45 | 46 | for foo, bar in [(1, 2)]: - | ^^^ B007 + | ^^^ 47 | print(FMT.format(foo=foo, bar=eval("bar"))) | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` -B007.py:52:14: B007 [*] Loop control variable `bar` not used within loop body +B007 [*] Loop control variable `bar` not used within loop body + --> B007.py:52:14 | 50 | def f(): 51 | # Fixable. 52 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 + | ^^^ 53 | if foo or baz: 54 | break | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` ℹ Unsafe fix 49 49 | @@ -120,27 +129,29 @@ B007.py:52:14: B007 [*] Loop control variable `bar` not used within loop body 54 54 | break 55 55 | -B007.py:59:14: B007 Loop control variable `bar` not used within loop body +B007 Loop control variable `bar` not used within loop body + --> B007.py:59:14 | 57 | def f(): 58 | # Unfixable due to usage of `bar` outside of loop. 59 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 + | ^^^ 60 | if foo or baz: 61 | break | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` -B007.py:68:14: B007 [*] Loop control variable `bar` not used within loop body +B007 [*] Loop control variable `bar` not used within loop body + --> B007.py:68:14 | 66 | def f(): 67 | # Fixable. 68 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 + | ^^^ 69 | if foo or baz: 70 | break | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` ℹ Unsafe fix 65 65 | @@ -152,33 +163,36 @@ B007.py:68:14: B007 [*] Loop control variable `bar` not used within loop body 70 70 | break 71 71 | -B007.py:77:14: B007 Loop control variable `bar` not used within loop body +B007 Loop control variable `bar` not used within loop body + --> B007.py:77:14 | 75 | def f(): 76 | # Unfixable. 77 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 + | ^^^ 78 | if foo or baz: 79 | break | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` -B007.py:88:14: B007 Loop control variable `bar` not used within loop body +B007 Loop control variable `bar` not used within loop body + --> B007.py:88:14 | 86 | def f(): 87 | # Unfixable (false negative) due to usage of `bar` outside of loop. 88 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 + | ^^^ 89 | if foo or baz: 90 | break | - = help: Rename unused `bar` to `_bar` +help: Rename unused `bar` to `_bar` -B007.py:98:5: B007 Loop control variable `line_` not used within loop body +B007 Loop control variable `line_` not used within loop body + --> B007.py:98:5 | 96 | # Unfixable due to trailing underscore (`_line_` wouldn't be considered an ignorable 97 | # variable name). 98 | for line_ in range(self.header_lines): - | ^^^^^ B007 + | ^^^^^ 99 | fp.readline() | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B008_B006_B008.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B008_B006_B008.py.snap index b0cd27b530..49da306103 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B008_B006_B008.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B008_B006_B008.py.snap @@ -1,82 +1,91 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B006_B008.py:102:61: B008 Do not perform function call `range` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `range` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:102:61 | 101 | # N.B. we're also flagging the function call in the comprehension 102 | def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): - | ^^^^^^^^ B008 + | ^^^^^^^^ 103 | pass | -B006_B008.py:106:64: B008 Do not perform function call `range` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `range` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:106:64 | 106 | def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): - | ^^^^^^^^ B008 + | ^^^^^^^^ 107 | pass | -B006_B008.py:110:60: B008 Do not perform function call `range` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `range` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:110:60 | 110 | def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): - | ^^^^^^^^ B008 + | ^^^^^^^^ 111 | pass | -B006_B008.py:126:39: B008 Do not perform function call `time.time` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `time.time` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:126:39 | 124 | # B008 125 | # Flag function calls as default args (including if they are part of a sub-expression) 126 | def in_fact_all_calls_are_wrong(value=time.time()): - | ^^^^^^^^^^^ B008 + | ^^^^^^^^^^^ 127 | ... | -B006_B008.py:130:12: B008 Do not perform function call `dt.datetime.now` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `dt.datetime.now` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:130:12 | 130 | def f(when=dt.datetime.now() + dt.timedelta(days=7)): - | ^^^^^^^^^^^^^^^^^ B008 + | ^^^^^^^^^^^^^^^^^ 131 | pass | -B006_B008.py:134:30: B008 Do not perform function call in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:134:30 | 134 | def can_even_catch_lambdas(a=(lambda x: x)()): - | ^^^^^^^^^^^^^^^ B008 + | ^^^^^^^^^^^^^^^ 135 | ... | -B006_B008.py:239:31: B008 Do not perform function call `dt.datetime.now` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `dt.datetime.now` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:239:31 | 237 | # B006 and B008 238 | # We should handle arbitrary nesting of these B008. 239 | def nested_combo(a=[float(3), dt.datetime.now()]): - | ^^^^^^^^^^^^^^^^^ B008 + | ^^^^^^^^^^^^^^^^^ 240 | pass | -B006_B008.py:245:22: B008 Do not perform function call `map` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `map` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:245:22 | 243 | # Don't flag nested B006 since we can't guarantee that 244 | # it isn't made mutable by the outer operation. 245 | def no_nested_b006(a=map(lambda s: s.upper(), ["a", "b", "c"])): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 246 | pass | -B006_B008.py:250:19: B008 Do not perform function call `random.randint` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `random.randint` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:250:19 | 249 | # B008-ception. 250 | def nested_b008(a=random.randint(0, dt.datetime.now().year)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 251 | pass | -B006_B008.py:250:37: B008 Do not perform function call `dt.datetime.now` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `dt.datetime.now` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B006_B008.py:250:37 | 249 | # B008-ception. 250 | def nested_b008(a=random.randint(0, dt.datetime.now().year)): - | ^^^^^^^^^^^^^^^^^ B008 + | ^^^^^^^^^^^^^^^^^ 251 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap index 8bddcba720..e733defa73 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B009_B010.py:19:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:19:1 | 18 | # Invalid usage 19 | getattr(foo, "bar") - | ^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^ 20 | getattr(foo, "_123abc") 21 | getattr(foo, "__123abc__") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 16 16 | getattr(foo, "__123abc") @@ -21,16 +22,17 @@ B009_B010.py:19:1: B009 [*] Do not call `getattr` with a constant attribute valu 21 21 | getattr(foo, "__123abc__") 22 22 | getattr(foo, "abc123") -B009_B010.py:20:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:20:1 | 18 | # Invalid usage 19 | getattr(foo, "bar") 20 | getattr(foo, "_123abc") - | ^^^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^^^ 21 | getattr(foo, "__123abc__") 22 | getattr(foo, "abc123") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 17 17 | @@ -42,16 +44,17 @@ B009_B010.py:20:1: B009 [*] Do not call `getattr` with a constant attribute valu 22 22 | getattr(foo, "abc123") 23 23 | getattr(foo, r"abc123") -B009_B010.py:21:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:21:1 | 19 | getattr(foo, "bar") 20 | getattr(foo, "_123abc") 21 | getattr(foo, "__123abc__") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | getattr(foo, "abc123") 23 | getattr(foo, r"abc123") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 18 18 | # Invalid usage @@ -63,16 +66,17 @@ B009_B010.py:21:1: B009 [*] Do not call `getattr` with a constant attribute valu 23 23 | getattr(foo, r"abc123") 24 24 | _ = lambda x: getattr(x, "bar") -B009_B010.py:22:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:22:1 | 20 | getattr(foo, "_123abc") 21 | getattr(foo, "__123abc__") 22 | getattr(foo, "abc123") - | ^^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^^ 23 | getattr(foo, r"abc123") 24 | _ = lambda x: getattr(x, "bar") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 19 19 | getattr(foo, "bar") @@ -84,16 +88,17 @@ B009_B010.py:22:1: B009 [*] Do not call `getattr` with a constant attribute valu 24 24 | _ = lambda x: getattr(x, "bar") 25 25 | if getattr(x, "bar"): -B009_B010.py:23:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:23:1 | 21 | getattr(foo, "__123abc__") 22 | getattr(foo, "abc123") 23 | getattr(foo, r"abc123") - | ^^^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^^^ 24 | _ = lambda x: getattr(x, "bar") 25 | if getattr(x, "bar"): | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 20 20 | getattr(foo, "_123abc") @@ -105,16 +110,17 @@ B009_B010.py:23:1: B009 [*] Do not call `getattr` with a constant attribute valu 25 25 | if getattr(x, "bar"): 26 26 | pass -B009_B010.py:24:15: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:24:15 | 22 | getattr(foo, "abc123") 23 | getattr(foo, r"abc123") 24 | _ = lambda x: getattr(x, "bar") - | ^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^ 25 | if getattr(x, "bar"): 26 | pass | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 21 21 | getattr(foo, "__123abc__") @@ -126,16 +132,17 @@ B009_B010.py:24:15: B009 [*] Do not call `getattr` with a constant attribute val 26 26 | pass 27 27 | getattr(1, "real") -B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:25:4 | 23 | getattr(foo, r"abc123") 24 | _ = lambda x: getattr(x, "bar") 25 | if getattr(x, "bar"): - | ^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^ 26 | pass 27 | getattr(1, "real") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 22 22 | getattr(foo, "abc123") @@ -147,16 +154,17 @@ B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute valu 27 27 | getattr(1, "real") 28 28 | getattr(1., "real") -B009_B010.py:27:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:27:1 | 25 | if getattr(x, "bar"): 26 | pass 27 | getattr(1, "real") - | ^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^ 28 | getattr(1., "real") 29 | getattr(1.0, "real") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 24 24 | _ = lambda x: getattr(x, "bar") @@ -168,16 +176,17 @@ B009_B010.py:27:1: B009 [*] Do not call `getattr` with a constant attribute valu 29 29 | getattr(1.0, "real") 30 30 | getattr(1j, "real") -B009_B010.py:28:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:28:1 | 26 | pass 27 | getattr(1, "real") 28 | getattr(1., "real") - | ^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^ 29 | getattr(1.0, "real") 30 | getattr(1j, "real") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 25 25 | if getattr(x, "bar"): @@ -189,16 +198,17 @@ B009_B010.py:28:1: B009 [*] Do not call `getattr` with a constant attribute valu 30 30 | getattr(1j, "real") 31 31 | getattr(True, "real") -B009_B010.py:29:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:29:1 | 27 | getattr(1, "real") 28 | getattr(1., "real") 29 | getattr(1.0, "real") - | ^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^ 30 | getattr(1j, "real") 31 | getattr(True, "real") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 26 26 | pass @@ -210,16 +220,17 @@ B009_B010.py:29:1: B009 [*] Do not call `getattr` with a constant attribute valu 31 31 | getattr(True, "real") 32 32 | getattr(x := 1, "real") -B009_B010.py:30:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:30:1 | 28 | getattr(1., "real") 29 | getattr(1.0, "real") 30 | getattr(1j, "real") - | ^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^ 31 | getattr(True, "real") 32 | getattr(x := 1, "real") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 27 27 | getattr(1, "real") @@ -231,16 +242,17 @@ B009_B010.py:30:1: B009 [*] Do not call `getattr` with a constant attribute valu 32 32 | getattr(x := 1, "real") 33 33 | getattr(x + y, "real") -B009_B010.py:31:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:31:1 | 29 | getattr(1.0, "real") 30 | getattr(1j, "real") 31 | getattr(True, "real") - | ^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^ 32 | getattr(x := 1, "real") 33 | getattr(x + y, "real") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 28 28 | getattr(1., "real") @@ -252,16 +264,17 @@ B009_B010.py:31:1: B009 [*] Do not call `getattr` with a constant attribute valu 33 33 | getattr(x + y, "real") 34 34 | getattr("foo" -B009_B010.py:32:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:32:1 | 30 | getattr(1j, "real") 31 | getattr(True, "real") 32 | getattr(x := 1, "real") - | ^^^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^^^ 33 | getattr(x + y, "real") 34 | getattr("foo" | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 29 29 | getattr(1.0, "real") @@ -273,16 +286,17 @@ B009_B010.py:32:1: B009 [*] Do not call `getattr` with a constant attribute valu 34 34 | getattr("foo" 35 35 | "bar", "real") -B009_B010.py:33:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:33:1 | 31 | getattr(True, "real") 32 | getattr(x := 1, "real") 33 | getattr(x + y, "real") - | ^^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^^ 34 | getattr("foo" 35 | "bar", "real") | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 30 30 | getattr(1j, "real") @@ -294,15 +308,16 @@ B009_B010.py:33:1: B009 [*] Do not call `getattr` with a constant attribute valu 35 35 | "bar", "real") 36 36 | -B009_B010.py:34:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:34:1 | 32 | getattr(x := 1, "real") 33 | getattr(x + y, "real") 34 | / getattr("foo" 35 | | "bar", "real") - | |______________________^ B009 + | |______________________^ | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 31 31 | getattr(True, "real") @@ -316,15 +331,16 @@ B009_B010.py:34:1: B009 [*] Do not call `getattr` with a constant attribute valu 37 37 | 38 38 | # Valid setattr usage -B009_B010.py:58:8: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:58:8 | 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 58 | assert getattr(func, '_rpc')is True - | ^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^ 59 | 60 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1732387247 | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 55 55 | setattr(foo.bar, r"baz", None) @@ -336,16 +352,17 @@ B009_B010.py:58:8: B009 [*] Do not call `getattr` with a constant attribute valu 60 60 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1732387247 61 61 | getattr(*foo, "bar") -B009_B010.py:65:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:65:1 | 64 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1739800901 65 | / getattr(self. 66 | | registration.registry, '__name__') - | |_____________________________________^ B009 + | |_____________________________________^ 67 | 68 | import builtins | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 62 62 | setattr(*foo, "bar", None) @@ -359,15 +376,16 @@ B009_B010.py:65:1: B009 [*] Do not call `getattr` with a constant attribute valu 68 68 | import builtins 69 69 | builtins.getattr(foo, "bar") -B009_B010.py:69:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. +B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:69:1 | 68 | import builtins 69 | builtins.getattr(foo, "bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B009 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | 71 | # Regression test for: https://github.com/astral-sh/ruff/issues/18353 | - = help: Replace `getattr` with attribute access +help: Replace `getattr` with attribute access ℹ Safe fix 66 66 | registration.registry, '__name__') diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap index 42a169cb1b..59365d0da4 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B009_B010.py:50:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:50:1 | 49 | # Invalid usage 50 | setattr(foo, "bar", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 51 | setattr(foo, "_123abc", None) 52 | setattr(foo, "__123abc__", None) | - = help: Replace `setattr` with assignment +help: Replace `setattr` with assignment ℹ Safe fix 47 47 | pass @@ -21,16 +22,17 @@ B009_B010.py:50:1: B010 [*] Do not call `setattr` with a constant attribute valu 52 52 | setattr(foo, "__123abc__", None) 53 53 | setattr(foo, "abc123", None) -B009_B010.py:51:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:51:1 | 49 | # Invalid usage 50 | setattr(foo, "bar", None) 51 | setattr(foo, "_123abc", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | setattr(foo, "__123abc__", None) 53 | setattr(foo, "abc123", None) | - = help: Replace `setattr` with assignment +help: Replace `setattr` with assignment ℹ Safe fix 48 48 | @@ -42,16 +44,17 @@ B009_B010.py:51:1: B010 [*] Do not call `setattr` with a constant attribute valu 53 53 | setattr(foo, "abc123", None) 54 54 | setattr(foo, r"abc123", None) -B009_B010.py:52:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:52:1 | 50 | setattr(foo, "bar", None) 51 | setattr(foo, "_123abc", None) 52 | setattr(foo, "__123abc__", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 53 | setattr(foo, "abc123", None) 54 | setattr(foo, r"abc123", None) | - = help: Replace `setattr` with assignment +help: Replace `setattr` with assignment ℹ Safe fix 49 49 | # Invalid usage @@ -63,16 +66,17 @@ B009_B010.py:52:1: B010 [*] Do not call `setattr` with a constant attribute valu 54 54 | setattr(foo, r"abc123", None) 55 55 | setattr(foo.bar, r"baz", None) -B009_B010.py:53:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:53:1 | 51 | setattr(foo, "_123abc", None) 52 | setattr(foo, "__123abc__", None) 53 | setattr(foo, "abc123", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | setattr(foo, r"abc123", None) 55 | setattr(foo.bar, r"baz", None) | - = help: Replace `setattr` with assignment +help: Replace `setattr` with assignment ℹ Safe fix 50 50 | setattr(foo, "bar", None) @@ -84,15 +88,16 @@ B009_B010.py:53:1: B010 [*] Do not call `setattr` with a constant attribute valu 55 55 | setattr(foo.bar, r"baz", None) 56 56 | -B009_B010.py:54:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:54:1 | 52 | setattr(foo, "__123abc__", None) 53 | setattr(foo, "abc123", None) 54 | setattr(foo, r"abc123", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | setattr(foo.bar, r"baz", None) | - = help: Replace `setattr` with assignment +help: Replace `setattr` with assignment ℹ Safe fix 51 51 | setattr(foo, "_123abc", None) @@ -104,16 +109,17 @@ B009_B010.py:54:1: B010 [*] Do not call `setattr` with a constant attribute valu 56 56 | 57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 -B009_B010.py:55:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. +B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + --> B009_B010.py:55:1 | 53 | setattr(foo, "abc123", None) 54 | setattr(foo, r"abc123", None) 55 | setattr(foo.bar, r"baz", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 | - = help: Replace `setattr` with assignment +help: Replace `setattr` with assignment ℹ Safe fix 52 52 | setattr(foo, "__123abc__", None) diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap index b04f7a057a..3af2078bac 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B011.py:8:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` +B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` + --> B011.py:8:8 | 7 | assert 1 != 2 8 | assert False - | ^^^^^ B011 + | ^^^^^ 9 | assert 1 != 2, "message" 10 | assert False, "message" | - = help: Replace `assert False` +help: Replace `assert False` ℹ Unsafe fix 5 5 | """ @@ -21,14 +21,15 @@ B011.py:8:8: B011 [*] Do not `assert False` (`python -O` removes these calls), r 9 9 | assert 1 != 2, "message" 10 10 | assert False, "message" -B011.py:10:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` +B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` + --> B011.py:10:8 | 8 | assert False 9 | assert 1 != 2, "message" 10 | assert False, "message" - | ^^^^^ B011 + | ^^^^^ | - = help: Replace `assert False` +help: Replace `assert False` ℹ Unsafe fix 7 7 | assert 1 != 2 diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap index 5bbd36c330..91083d5070 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap @@ -1,102 +1,113 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B012.py:5:9: B012 `return` inside `finally` blocks cause exceptions to be silenced +B012 `return` inside `finally` blocks cause exceptions to be silenced + --> B012.py:5:9 | 3 | pass 4 | finally: 5 | return # warning - | ^^^^^^ B012 + | ^^^^^^ | -B012.py:13:13: B012 `return` inside `finally` blocks cause exceptions to be silenced +B012 `return` inside `finally` blocks cause exceptions to be silenced + --> B012.py:13:13 | 11 | finally: 12 | if 1 + 0 == 2 - 1: 13 | return # warning - | ^^^^^^ B012 + | ^^^^^^ | -B012.py:21:13: B012 `return` inside `finally` blocks cause exceptions to be silenced +B012 `return` inside `finally` blocks cause exceptions to be silenced + --> B012.py:21:13 | 19 | finally: 20 | try: 21 | return # warning - | ^^^^^^ B012 + | ^^^^^^ 22 | except Exception: 23 | pass | -B012.py:31:13: B012 `return` inside `finally` blocks cause exceptions to be silenced +B012 `return` inside `finally` blocks cause exceptions to be silenced + --> B012.py:31:13 | 29 | pass 30 | finally: 31 | return # warning - | ^^^^^^ B012 + | ^^^^^^ 32 | finally: 33 | pass | -B012.py:44:21: B012 `return` inside `finally` blocks cause exceptions to be silenced +B012 `return` inside `finally` blocks cause exceptions to be silenced + --> B012.py:44:21 | 42 | pass 43 | finally: 44 | return # warning - | ^^^^^^ B012 + | ^^^^^^ 45 | 46 | finally: | -B012.py:66:13: B012 `break` inside `finally` blocks cause exceptions to be silenced +B012 `break` inside `finally` blocks cause exceptions to be silenced + --> B012.py:66:13 | 64 | pass 65 | finally: 66 | break # warning - | ^^^^^ B012 + | ^^^^^ 67 | 68 | def j(): | -B012.py:78:13: B012 `continue` inside `finally` blocks cause exceptions to be silenced +B012 `continue` inside `finally` blocks cause exceptions to be silenced + --> B012.py:78:13 | 76 | pass 77 | finally: 78 | continue # warning - | ^^^^^^^^ B012 + | ^^^^^^^^ 79 | 80 | def j(): | -B012.py:94:13: B012 `return` inside `finally` blocks cause exceptions to be silenced +B012 `return` inside `finally` blocks cause exceptions to be silenced + --> B012.py:94:13 | 92 | continue # no warning 93 | while True: 94 | return # warning - | ^^^^^^ B012 + | ^^^^^^ | -B012.py:101:9: B012 `continue` inside `finally` blocks cause exceptions to be silenced +B012 `continue` inside `finally` blocks cause exceptions to be silenced + --> B012.py:101:9 | 99 | pass 100 | finally: 101 | continue # warning - | ^^^^^^^^ B012 + | ^^^^^^^^ 102 | 103 | while True: | -B012.py:107:9: B012 `break` inside `finally` blocks cause exceptions to be silenced +B012 `break` inside `finally` blocks cause exceptions to be silenced + --> B012.py:107:9 | 105 | pass 106 | finally: 107 | break # warning - | ^^^^^ B012 + | ^^^^^ | -B012.py:118:17: B012 `break` inside `finally` blocks cause exceptions to be silenced +B012 `break` inside `finally` blocks cause exceptions to be silenced + --> B012.py:118:17 | 116 | y = 0 117 | case 0, *x: 118 | break # warning - | ^^^^^ B012 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap index 8dd0604718..a1443d6b03 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B013.py:5:8: B013 [*] A length-one tuple literal is redundant in exception handlers +B013 [*] A length-one tuple literal is redundant in exception handlers + --> B013.py:5:8 | 3 | try: 4 | pass 5 | except (ValueError,): - | ^^^^^^^^^^^^^ B013 + | ^^^^^^^^^^^^^ 6 | pass 7 | except AttributeError: | - = help: Replace with `except ValueError` +help: Replace with `except ValueError` ℹ Safe fix 2 2 | @@ -23,15 +23,16 @@ B013.py:5:8: B013 [*] A length-one tuple literal is redundant in exception handl 7 7 | except AttributeError: 8 8 | pass -B013.py:13:7: B013 [*] A length-one tuple literal is redundant in exception handlers +B013 [*] A length-one tuple literal is redundant in exception handlers + --> B013.py:13:7 | 11 | except (*retriable_exceptions,): 12 | pass 13 | except(ValueError,): - | ^^^^^^^^^^^^^ B013 + | ^^^^^^^^^^^^^ 14 | pass | - = help: Replace with `except ValueError` +help: Replace with `except ValueError` ℹ Safe fix 10 10 | pass diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap index e925e86423..fd18e4d076 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B014.py:17:8: B014 [*] Exception handler with duplicate exception: `OSError` +B014 [*] Exception handler with duplicate exception: `OSError` + --> B014.py:17:8 | 15 | try: 16 | pass 17 | except (OSError, OSError) as err: - | ^^^^^^^^^^^^^^^^^^ B014 + | ^^^^^^^^^^^^^^^^^^ 18 | # Duplicate exception types are useless 19 | pass | - = help: De-duplicate exceptions +help: De-duplicate exceptions ℹ Safe fix 14 14 | @@ -23,16 +23,17 @@ B014.py:17:8: B014 [*] Exception handler with duplicate exception: `OSError` 19 19 | pass 20 20 | -B014.py:28:8: B014 [*] Exception handler with duplicate exception: `MyError` +B014 [*] Exception handler with duplicate exception: `MyError` + --> B014.py:28:8 | 26 | try: 27 | pass 28 | except (MyError, MyError): - | ^^^^^^^^^^^^^^^^^^ B014 + | ^^^^^^^^^^^^^^^^^^ 29 | # Detect duplicate non-builtin errors 30 | pass | - = help: De-duplicate exceptions +help: De-duplicate exceptions ℹ Safe fix 25 25 | @@ -44,16 +45,17 @@ B014.py:28:8: B014 [*] Exception handler with duplicate exception: `MyError` 30 30 | pass 31 31 | -B014.py:49:8: B014 [*] Exception handler with duplicate exception: `re.error` +B014 [*] Exception handler with duplicate exception: `re.error` + --> B014.py:49:8 | 47 | try: 48 | pass 49 | except (re.error, re.error): - | ^^^^^^^^^^^^^^^^^^^^ B014 + | ^^^^^^^^^^^^^^^^^^^^ 50 | # Duplicate exception types as attributes 51 | pass | - = help: De-duplicate exceptions +help: De-duplicate exceptions ℹ Safe fix 46 46 | @@ -65,15 +67,16 @@ B014.py:49:8: B014 [*] Exception handler with duplicate exception: `re.error` 51 51 | pass 52 52 | -B014.py:82:8: B014 [*] Exception handler with duplicate exception: `ValueError` +B014 [*] Exception handler with duplicate exception: `ValueError` + --> B014.py:82:8 | 80 | try: 81 | pass 82 | except (ValueError, ValueError, TypeError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B014 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 83 | pass | - = help: De-duplicate exceptions +help: De-duplicate exceptions ℹ Safe fix 79 79 | # Regression test for: https://github.com/astral-sh/ruff/issues/6412 @@ -85,15 +88,16 @@ B014.py:82:8: B014 [*] Exception handler with duplicate exception: `ValueError` 84 84 | 85 85 | -B014.py:89:7: B014 [*] Exception handler with duplicate exception: `re.error` +B014 [*] Exception handler with duplicate exception: `re.error` + --> B014.py:89:7 | 87 | try: 88 | pas 89 | except(re.error, re.error): - | ^^^^^^^^^^^^^^^^^^^^ B014 + | ^^^^^^^^^^^^^^^^^^^^ 90 | p | - = help: De-duplicate exceptions +help: De-duplicate exceptions ℹ Safe fix 86 86 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1739801758 diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.ipynb.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.ipynb.snap index 96eba32108..ffbffad94d 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.ipynb.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.ipynb.snap @@ -1,33 +1,35 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B015.ipynb:5:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. +B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. + --> B015.ipynb:5:1 | 3 | x == 1 4 | # Only skip the last expression 5 | x == 1 # B018 - | ^^^^^^ B015 + | ^^^^^^ 6 | x == 1 7 | # Nested expressions isn't relevant | -B015.ipynb:9:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. +B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. + --> B015.ipynb:9:5 | 7 | # Nested expressions isn't relevant 8 | if True: 9 | x == 1 - | ^^^^^^ B015 + | ^^^^^^ 10 | # Semicolons shouldn't affect the output 11 | x == 1; | -B015.ipynb:13:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. +B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. + --> B015.ipynb:13:1 | 11 | x == 1; 12 | # Semicolons with multiple expressions 13 | x == 1; x == 1 - | ^^^^^^ B015 + | ^^^^^^ 14 | # Comments, newlines and whitespace 15 | x == 1 # comment | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap index 1fe419d2fd..3c63b71912 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap @@ -1,43 +1,48 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B015.py:3:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. +B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. + --> B015.py:3:1 | 1 | assert 1 == 1 2 | 3 | 1 == 1 - | ^^^^^^ B015 + | ^^^^^^ 4 | 5 | assert 1 in (1, 2) | -B015.py:7:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. +B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. + --> B015.py:7:1 | 5 | assert 1 in (1, 2) 6 | 7 | 1 in (1, 2) - | ^^^^^^^^^^^ B015 + | ^^^^^^^^^^^ | -B015.py:17:5: B015 Pointless comparison at end of function scope. Did you mean to return the expression result? +B015 Pointless comparison at end of function scope. Did you mean to return the expression result? + --> B015.py:17:5 | 15 | assert 1 in (1, 2) 16 | 17 | 1 in (1, 2) - | ^^^^^^^^^^^ B015 + | ^^^^^^^^^^^ | -B015.py:21:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. +B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. + --> B015.py:21:5 | 20 | def test2(): 21 | 1 in (1, 2) - | ^^^^^^^^^^^ B015 + | ^^^^^^^^^^^ 22 | return | -B015.py:29:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. +B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it. + --> B015.py:29:5 | 28 | class TestClass: 29 | 1 == 1 - | ^^^^^^ B015 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap index 1a999923db..8a0000f8bb 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap @@ -1,31 +1,34 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B016.py:6:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? +B016 Cannot raise a literal. Did you intend to return it or raise an Exception? + --> B016.py:6:7 | 4 | """ 5 | 6 | raise False - | ^^^^^ B016 + | ^^^^^ 7 | raise 1 8 | raise "string" | -B016.py:7:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? +B016 Cannot raise a literal. Did you intend to return it or raise an Exception? + --> B016.py:7:7 | 6 | raise False 7 | raise 1 - | ^ B016 + | ^ 8 | raise "string" 9 | raise Exception(False) | -B016.py:8:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? +B016 Cannot raise a literal. Did you intend to return it or raise an Exception? + --> B016.py:8:7 | 6 | raise False 7 | raise 1 8 | raise "string" - | ^^^^^^^^ B016 + | ^^^^^^^^ 9 | raise Exception(False) 10 | raise Exception(1) | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017_0.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017_0.py.snap index 8ba0ecc1b7..4c8bb4e6d6 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017_0.py.snap @@ -1,71 +1,79 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B017_0.py:23:14: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:23:14 | 21 | class Foobar(unittest.TestCase): 22 | def evil_raises(self) -> None: 23 | with self.assertRaises(Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | raise Exception("Evil I say!") | -B017_0.py:27:14: B017 Do not assert blind exception: `BaseException` +B017 Do not assert blind exception: `BaseException` + --> B017_0.py:27:14 | 26 | def also_evil_raises(self) -> None: 27 | with self.assertRaises(BaseException): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | raise Exception("Evil I say!") | -B017_0.py:45:10: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:45:10 | 44 | def test_pytest_raises(): 45 | with pytest.raises(Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 46 | raise ValueError("Hello") | -B017_0.py:48:10: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:48:10 | 46 | raise ValueError("Hello") 47 | 48 | with pytest.raises(Exception), pytest.raises(ValueError): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 49 | raise ValueError("Hello") | -B017_0.py:57:36: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:57:36 | 55 | raise ValueError("This is also fine") 56 | 57 | with contextlib.nullcontext(), pytest.raises(Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 58 | raise ValueError("Multiple context managers") | -B017_0.py:62:10: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:62:10 | 61 | def test_pytest_raises_keyword(): 62 | with pytest.raises(expected_exception=Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | raise ValueError("Should be flagged") | -B017_0.py:68:18: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:68:18 | 66 | class TestKwargs(unittest.TestCase): 67 | def test_method(self): 68 | with self.assertRaises(exception=Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 69 | raise ValueError("Should be flagged") | -B017_0.py:71:18: B017 Do not assert blind exception: `BaseException` +B017 Do not assert blind exception: `BaseException` + --> B017_0.py:71:18 | 69 | raise ValueError("Should be flagged") 70 | 71 | with self.assertRaises(exception=BaseException): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | raise ValueError("Should be flagged") | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.ipynb.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.ipynb.snap index d06676c198..7ce7b96dd3 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.ipynb.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.ipynb.snap @@ -1,33 +1,35 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B018.ipynb:5:1: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.ipynb:5:1 | 3 | x 4 | # Only skip the last expression 5 | x # B018 - | ^ B018 + | ^ 6 | x 7 | # Nested expressions isn't relevant | -B018.ipynb:9:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.ipynb:9:5 | 7 | # Nested expressions isn't relevant 8 | if True: 9 | x - | ^ B018 + | ^ 10 | # Semicolons shouldn't affect the output 11 | x; | -B018.ipynb:13:1: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.ipynb:13:1 | 11 | x; 12 | # Semicolons with multiple expressions 13 | x; x - | ^ B018 + | ^ 14 | # Comments, newlines and whitespace 15 | x # comment | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.py.snap index 5eee755b4a..6013b01e3f 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.py.snap @@ -1,256 +1,283 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B018.py:11:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:11:5 | 9 | "str" # Str (no raise) 10 | f"{int}" # JoinedStr (no raise) 11 | 1j # Number (complex) - | ^^ B018 + | ^^ 12 | 1 # Number (int) 13 | 1.0 # Number (float) | -B018.py:12:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:12:5 | 10 | f"{int}" # JoinedStr (no raise) 11 | 1j # Number (complex) 12 | 1 # Number (int) - | ^ B018 + | ^ 13 | 1.0 # Number (float) 14 | b"foo" # Binary | -B018.py:13:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:13:5 | 11 | 1j # Number (complex) 12 | 1 # Number (int) 13 | 1.0 # Number (float) - | ^^^ B018 + | ^^^ 14 | b"foo" # Binary 15 | True # NameConstant (True) | -B018.py:14:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:14:5 | 12 | 1 # Number (int) 13 | 1.0 # Number (float) 14 | b"foo" # Binary - | ^^^^^^ B018 + | ^^^^^^ 15 | True # NameConstant (True) 16 | False # NameConstant (False) | -B018.py:15:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:15:5 | 13 | 1.0 # Number (float) 14 | b"foo" # Binary 15 | True # NameConstant (True) - | ^^^^ B018 + | ^^^^ 16 | False # NameConstant (False) 17 | None # NameConstant (None) | -B018.py:16:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:16:5 | 14 | b"foo" # Binary 15 | True # NameConstant (True) 16 | False # NameConstant (False) - | ^^^^^ B018 + | ^^^^^ 17 | None # NameConstant (None) 18 | [1, 2] # list | -B018.py:17:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:17:5 | 15 | True # NameConstant (True) 16 | False # NameConstant (False) 17 | None # NameConstant (None) - | ^^^^ B018 + | ^^^^ 18 | [1, 2] # list 19 | {1, 2} # set | -B018.py:18:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:18:5 | 16 | False # NameConstant (False) 17 | None # NameConstant (None) 18 | [1, 2] # list - | ^^^^^^ B018 + | ^^^^^^ 19 | {1, 2} # set 20 | {"foo": "bar"} # dict | -B018.py:19:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:19:5 | 17 | None # NameConstant (None) 18 | [1, 2] # list 19 | {1, 2} # set - | ^^^^^^ B018 + | ^^^^^^ 20 | {"foo": "bar"} # dict | -B018.py:20:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:20:5 | 18 | [1, 2] # list 19 | {1, 2} # set 20 | {"foo": "bar"} # dict - | ^^^^^^^^^^^^^^ B018 + | ^^^^^^^^^^^^^^ | -B018.py:24:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:24:5 | 23 | class Foo3: 24 | 123 - | ^^^ B018 + | ^^^ 25 | a = 2 26 | "str" | -B018.py:27:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:27:5 | 25 | a = 2 26 | "str" 27 | 1 - | ^ B018 + | ^ | -B018.py:39:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:39:5 | 37 | "str" # Str (no raise) 38 | f"{int}" # JoinedStr (no raise) 39 | 1j # Number (complex) - | ^^ B018 + | ^^ 40 | 1 # Number (int) 41 | 1.0 # Number (float) | -B018.py:40:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:40:5 | 38 | f"{int}" # JoinedStr (no raise) 39 | 1j # Number (complex) 40 | 1 # Number (int) - | ^ B018 + | ^ 41 | 1.0 # Number (float) 42 | b"foo" # Binary | -B018.py:41:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:41:5 | 39 | 1j # Number (complex) 40 | 1 # Number (int) 41 | 1.0 # Number (float) - | ^^^ B018 + | ^^^ 42 | b"foo" # Binary 43 | True # NameConstant (True) | -B018.py:42:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:42:5 | 40 | 1 # Number (int) 41 | 1.0 # Number (float) 42 | b"foo" # Binary - | ^^^^^^ B018 + | ^^^^^^ 43 | True # NameConstant (True) 44 | False # NameConstant (False) | -B018.py:43:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:43:5 | 41 | 1.0 # Number (float) 42 | b"foo" # Binary 43 | True # NameConstant (True) - | ^^^^ B018 + | ^^^^ 44 | False # NameConstant (False) 45 | None # NameConstant (None) | -B018.py:44:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:44:5 | 42 | b"foo" # Binary 43 | True # NameConstant (True) 44 | False # NameConstant (False) - | ^^^^^ B018 + | ^^^^^ 45 | None # NameConstant (None) 46 | [1, 2] # list | -B018.py:45:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:45:5 | 43 | True # NameConstant (True) 44 | False # NameConstant (False) 45 | None # NameConstant (None) - | ^^^^ B018 + | ^^^^ 46 | [1, 2] # list 47 | {1, 2} # set | -B018.py:46:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:46:5 | 44 | False # NameConstant (False) 45 | None # NameConstant (None) 46 | [1, 2] # list - | ^^^^^^ B018 + | ^^^^^^ 47 | {1, 2} # set 48 | {"foo": "bar"} # dict | -B018.py:47:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:47:5 | 45 | None # NameConstant (None) 46 | [1, 2] # list 47 | {1, 2} # set - | ^^^^^^ B018 + | ^^^^^^ 48 | {"foo": "bar"} # dict | -B018.py:48:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:48:5 | 46 | [1, 2] # list 47 | {1, 2} # set 48 | {"foo": "bar"} # dict - | ^^^^^^^^^^^^^^ B018 + | ^^^^^^^^^^^^^^ | -B018.py:52:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:52:5 | 51 | def foo3(): 52 | 123 - | ^^^ B018 + | ^^^ 53 | a = 2 54 | "str" | -B018.py:55:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:55:5 | 53 | a = 2 54 | "str" 55 | 3 - | ^ B018 + | ^ | -B018.py:63:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:63:5 | 62 | def foo5(): 63 | foo.bar # Attribute (raise) - | ^^^^^^^ B018 + | ^^^^^^^ 64 | object().__class__ # Attribute (raise) 65 | "foo" + "bar" # BinOp (raise) | -B018.py:64:5: B018 Found useless attribute access. Either assign it to a variable or remove it. +B018 Found useless attribute access. Either assign it to a variable or remove it. + --> B018.py:64:5 | 62 | def foo5(): 63 | foo.bar # Attribute (raise) 64 | object().__class__ # Attribute (raise) - | ^^^^^^^^^^^^^^^^^^ B018 + | ^^^^^^^^^^^^^^^^^^ 65 | "foo" + "bar" # BinOp (raise) | -B018.py:65:5: B018 Found useless expression. Either assign it to a variable or remove it. +B018 Found useless expression. Either assign it to a variable or remove it. + --> B018.py:65:5 | 63 | foo.bar # Attribute (raise) 64 | object().__class__ # Attribute (raise) 65 | "foo" + "bar" # BinOp (raise) - | ^^^^^^^^^^^^^ B018 + | ^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap index dfba309de4..54c945504c 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap @@ -1,90 +1,99 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B019.py:78:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:78:5 | 77 | # Remaining methods should emit B019 78 | @functools.cache - | ^^^^^^^^^^^^^^^^ B019 + | ^^^^^^^^^^^^^^^^ 79 | def cached_instance_method(self, y): 80 | ... | -B019.py:82:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:82:5 | 80 | ... 81 | 82 | @cache - | ^^^^^^ B019 + | ^^^^^^ 83 | def another_cached_instance_method(self, y): 84 | ... | -B019.py:86:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:86:5 | 84 | ... 85 | 86 | @functools.cache() - | ^^^^^^^^^^^^^^^^^^ B019 + | ^^^^^^^^^^^^^^^^^^ 87 | def called_cached_instance_method(self, y): 88 | ... | -B019.py:90:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:90:5 | 88 | ... 89 | 90 | @cache() - | ^^^^^^^^ B019 + | ^^^^^^^^ 91 | def another_called_cached_instance_method(self, y): 92 | ... | -B019.py:94:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:94:5 | 92 | ... 93 | 94 | @functools.lru_cache - | ^^^^^^^^^^^^^^^^^^^^ B019 + | ^^^^^^^^^^^^^^^^^^^^ 95 | def lru_cached_instance_method(self, y): 96 | ... | -B019.py:98:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:98:5 | 96 | ... 97 | 98 | @lru_cache - | ^^^^^^^^^^ B019 + | ^^^^^^^^^^ 99 | def another_lru_cached_instance_method(self, y): 100 | ... | -B019.py:102:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:102:5 | 100 | ... 101 | 102 | @functools.lru_cache() - | ^^^^^^^^^^^^^^^^^^^^^^ B019 + | ^^^^^^^^^^^^^^^^^^^^^^ 103 | def called_lru_cached_instance_method(self, y): 104 | ... | -B019.py:106:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:106:5 | 104 | ... 105 | 106 | @lru_cache() - | ^^^^^^^^^^^^ B019 + | ^^^^^^^^^^^^ 107 | def another_called_lru_cached_instance_method(self, y): 108 | ... | -B019.py:124:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks +B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + --> B019.py:124:5 | 123 | class Metaclass(type): 124 | @functools.lru_cache - | ^^^^^^^^^^^^^^^^^^^^ B019 + | ^^^^^^^^^^^^^^^^^^^^ 125 | def lru_cached_instance_method_on_metaclass(cls, x: int): 126 | ... | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap index b734156c72..02f6719914 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap @@ -1,28 +1,31 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B020.py:8:5: B020 Loop control variable `items` overrides iterable it iterates +B020 Loop control variable `items` overrides iterable it iterates + --> B020.py:8:5 | 6 | items = [1, 2, 3] 7 | 8 | for items in items: - | ^^^^^ B020 + | ^^^^^ 9 | print(items) | -B020.py:21:10: B020 Loop control variable `values` overrides iterable it iterates +B020 Loop control variable `values` overrides iterable it iterates + --> B020.py:21:10 | 19 | print(f"{key}, {value}") 20 | 21 | for key, values in values.items(): - | ^^^^^^ B020 + | ^^^^^^ 22 | print(f"{key}, {values}") | -B020.py:36:5: B020 Loop control variable `vars` overrides iterable it iterates +B020 Loop control variable `vars` overrides iterable it iterates + --> B020.py:36:5 | 35 | # However we still call out reassigning the iterable in the comprehension. 36 | for vars in [i for i in vars]: - | ^^^^ B020 + | ^^^^ 37 | print(vars) | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap index 32c3200f25..fa9f286493 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap @@ -1,78 +1,88 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B021.py:1:1: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:1:1 | 1 | / f""" 2 | | Should emit: 3 | | B021 - on lines 14, 22, 30, 38, 46, 54, 62, 70, 73 4 | | """ - | |___^ B021 + | |___^ 5 | 6 | VARIABLE = "world" | -B021.py:14:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:14:5 | 13 | def foo2(): 14 | f"""hello {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -B021.py:22:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:22:5 | 21 | class bar2: 22 | f"""hello {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -B021.py:30:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:30:5 | 29 | def foo2(): 30 | f"""hello {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -B021.py:38:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:38:5 | 37 | class bar2: 38 | f"""hello {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -B021.py:46:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:46:5 | 45 | def foo2(): 46 | f"hello {VARIABLE}!" - | ^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^ | -B021.py:54:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:54:5 | 53 | class bar2: 54 | f"hello {VARIABLE}!" - | ^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^ | -B021.py:62:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:62:5 | 61 | def foo2(): 62 | f"hello {VARIABLE}!" - | ^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^ | -B021.py:70:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:70:5 | 69 | class bar2: 70 | f"hello {VARIABLE}!" - | ^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^ | -B021.py:74:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. +B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + --> B021.py:74:5 | 73 | def baz(): 74 | f"""I'm probably a docstring: {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | print(f"""I'm a normal string""") 76 | f"""Don't detect me!""" | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap index d5b4902139..65065188cb 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B022.py:9:6: B022 No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant +B022 No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant + --> B022.py:9:6 | 7 | from contextlib import suppress 8 | 9 | with contextlib.suppress(): - | ^^^^^^^^^^^^^^^^^^^^^ B022 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | raise ValueError | -B022.py:12:6: B022 No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant +B022 No arguments passed to `contextlib.suppress`. No exceptions will be suppressed and therefore this context manager is redundant + --> B022.py:12:6 | 10 | raise ValueError 11 | 12 | with suppress(): - | ^^^^^^^^^^ B022 + | ^^^^^^^^^^ 13 | raise ValueError | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap index 0ee9c53938..034c5f4f03 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap @@ -1,222 +1,246 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B023.py:12:30: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:12:30 | 10 | y = x + 1 11 | # Subject to late-binding problems 12 | functions.append(lambda: x) - | ^ B023 + | ^ 13 | functions.append(lambda: y) # not just the loop var | -B023.py:13:30: B023 Function definition does not bind loop variable `y` +B023 Function definition does not bind loop variable `y` + --> B023.py:13:30 | 11 | # Subject to late-binding problems 12 | functions.append(lambda: x) 13 | functions.append(lambda: y) # not just the loop var - | ^ B023 + | ^ 14 | 15 | def f_bad_1(): | -B023.py:16:16: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:16:16 | 15 | def f_bad_1(): 16 | return x - | ^ B023 + | ^ 17 | 18 | # Actually OK | -B023.py:28:19: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:28:19 | 27 | def check_inside_functions_too(): 28 | ls = [lambda: x for x in range(2)] # error - | ^ B023 + | ^ 29 | st = {lambda: x for x in range(2)} # error 30 | gn = (lambda: x for x in range(2)) # error | -B023.py:29:19: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:29:19 | 27 | def check_inside_functions_too(): 28 | ls = [lambda: x for x in range(2)] # error 29 | st = {lambda: x for x in range(2)} # error - | ^ B023 + | ^ 30 | gn = (lambda: x for x in range(2)) # error 31 | dt = {x: lambda: x for x in range(2)} # error | -B023.py:30:19: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:30:19 | 28 | ls = [lambda: x for x in range(2)] # error 29 | st = {lambda: x for x in range(2)} # error 30 | gn = (lambda: x for x in range(2)) # error - | ^ B023 + | ^ 31 | dt = {x: lambda: x for x in range(2)} # error | -B023.py:31:22: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:31:22 | 29 | st = {lambda: x for x in range(2)} # error 30 | gn = (lambda: x for x in range(2)) # error 31 | dt = {x: lambda: x for x in range(2)} # error - | ^ B023 + | ^ | -B023.py:40:34: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:40:34 | 38 | async def container_for_problems(): 39 | async for x in pointless_async_iterable(): 40 | functions.append(lambda: x) # error - | ^ B023 + | ^ 41 | 42 | [lambda: x async for x in pointless_async_iterable()] # error | -B023.py:42:14: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:42:14 | 40 | functions.append(lambda: x) # error 41 | 42 | [lambda: x async for x in pointless_async_iterable()] # error - | ^ B023 + | ^ | -B023.py:50:30: B023 Function definition does not bind loop variable `a` +B023 Function definition does not bind loop variable `a` + --> B023.py:50:30 | 48 | a = a_ = a - 1 49 | b += 1 50 | functions.append(lambda: a) # error - | ^ B023 + | ^ 51 | functions.append(lambda: a_) # error 52 | functions.append(lambda: b) # error | -B023.py:51:30: B023 Function definition does not bind loop variable `a_` +B023 Function definition does not bind loop variable `a_` + --> B023.py:51:30 | 49 | b += 1 50 | functions.append(lambda: a) # error 51 | functions.append(lambda: a_) # error - | ^^ B023 + | ^^ 52 | functions.append(lambda: b) # error 53 | functions.append(lambda: c) # error, but not a name error due to late binding | -B023.py:52:30: B023 Function definition does not bind loop variable `b` +B023 Function definition does not bind loop variable `b` + --> B023.py:52:30 | 50 | functions.append(lambda: a) # error 51 | functions.append(lambda: a_) # error 52 | functions.append(lambda: b) # error - | ^ B023 + | ^ 53 | functions.append(lambda: c) # error, but not a name error due to late binding 54 | c: bool = a > 3 | -B023.py:53:30: B023 Function definition does not bind loop variable `c` +B023 Function definition does not bind loop variable `c` + --> B023.py:53:30 | 51 | functions.append(lambda: a_) # error 52 | functions.append(lambda: b) # error 53 | functions.append(lambda: c) # error, but not a name error due to late binding - | ^ B023 + | ^ 54 | c: bool = a > 3 55 | if not c: | -B023.py:61:17: B023 Function definition does not bind loop variable `j` +B023 Function definition does not bind loop variable `j` + --> B023.py:61:17 | 59 | for j in range(2): 60 | for k in range(3): 61 | lambda: j * k # error - | ^ B023 + | ^ | -B023.py:61:21: B023 Function definition does not bind loop variable `k` +B023 Function definition does not bind loop variable `k` + --> B023.py:61:21 | 59 | for j in range(2): 60 | for k in range(3): 61 | lambda: j * k # error - | ^ B023 + | ^ | -B023.py:68:10: B023 Function definition does not bind loop variable `l` +B023 Function definition does not bind loop variable `l` + --> B023.py:68:10 | 66 | def f(): 67 | j = None # OK because it's an assignment 68 | [l for k in range(2)] # error for l, not for k - | ^ B023 + | ^ 69 | 70 | assert a and functions | -B023.py:82:16: B023 Function definition does not bind loop variable `i` +B023 Function definition does not bind loop variable `i` + --> B023.py:82:16 | 81 | for i in range(3): 82 | lambda: f"{i}" - | ^ B023 + | ^ | -B023.py:117:24: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:117:24 | 115 | for x in range(2): 116 | # It's not a complete get-out-of-linting-free construct - these should fail: 117 | min([None, lambda: x], key=repr) - | ^ B023 + | ^ 118 | sorted([None, lambda: x], key=repr) 119 | any(filter(bool, [None, lambda: x])) | -B023.py:118:27: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:118:27 | 116 | # It's not a complete get-out-of-linting-free construct - these should fail: 117 | min([None, lambda: x], key=repr) 118 | sorted([None, lambda: x], key=repr) - | ^ B023 + | ^ 119 | any(filter(bool, [None, lambda: x])) 120 | list(filter(bool, [None, lambda: x])) | -B023.py:119:37: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:119:37 | 117 | min([None, lambda: x], key=repr) 118 | sorted([None, lambda: x], key=repr) 119 | any(filter(bool, [None, lambda: x])) - | ^ B023 + | ^ 120 | list(filter(bool, [None, lambda: x])) 121 | all(reduce(bool, [None, lambda: x])) | -B023.py:120:38: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:120:38 | 118 | sorted([None, lambda: x], key=repr) 119 | any(filter(bool, [None, lambda: x])) 120 | list(filter(bool, [None, lambda: x])) - | ^ B023 + | ^ 121 | all(reduce(bool, [None, lambda: x])) | -B023.py:121:37: B023 Function definition does not bind loop variable `x` +B023 Function definition does not bind loop variable `x` + --> B023.py:121:37 | 119 | any(filter(bool, [None, lambda: x])) 120 | list(filter(bool, [None, lambda: x])) 121 | all(reduce(bool, [None, lambda: x])) - | ^ B023 + | ^ 122 | 123 | # But all these should be OK: | -B023.py:171:29: B023 Function definition does not bind loop variable `name` +B023 Function definition does not bind loop variable `name` + --> B023.py:171:29 | 170 | if foo(name): 171 | return [lambda: name] # known false alarm - | ^^^^ B023 + | ^^^^ 172 | 173 | if False: | -B023.py:174:29: B023 Function definition does not bind loop variable `i` +B023 Function definition does not bind loop variable `i` + --> B023.py:174:29 | 173 | if False: 174 | return [lambda: i for i in range(3)] # error - | ^ B023 + | ^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B024_B024.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B024_B024.py.snap index fb1957dd24..bda11feea6 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B024_B024.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B024_B024.py.snap @@ -1,65 +1,72 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B024.py:18:7: B024 `Base_1` is an abstract base class, but it has no abstract methods or properties +B024 `Base_1` is an abstract base class, but it has no abstract methods or properties + --> B024.py:18:7 | 18 | class Base_1(ABC): # error - | ^^^^^^ B024 + | ^^^^^^ 19 | def method(self): 20 | foo() | -B024.py:71:7: B024 `MetaBase_1` is an abstract base class, but it has no abstract methods or properties +B024 `MetaBase_1` is an abstract base class, but it has no abstract methods or properties + --> B024.py:71:7 | 71 | class MetaBase_1(metaclass=ABCMeta): # error - | ^^^^^^^^^^ B024 + | ^^^^^^^^^^ 72 | def method(self): 73 | foo() | -B024.py:82:7: B024 `abc_Base_1` is an abstract base class, but it has no abstract methods or properties +B024 `abc_Base_1` is an abstract base class, but it has no abstract methods or properties + --> B024.py:82:7 | 82 | class abc_Base_1(abc.ABC): # error - | ^^^^^^^^^^ B024 + | ^^^^^^^^^^ 83 | def method(self): 84 | foo() | -B024.py:87:7: B024 `abc_Base_2` is an abstract base class, but it has no abstract methods or properties +B024 `abc_Base_2` is an abstract base class, but it has no abstract methods or properties + --> B024.py:87:7 | 87 | class abc_Base_2(metaclass=abc.ABCMeta): # error - | ^^^^^^^^^^ B024 + | ^^^^^^^^^^ 88 | def method(self): 89 | foo() | -B024.py:92:7: B024 `notabc_Base_1` is an abstract base class, but it has no abstract methods or properties +B024 `notabc_Base_1` is an abstract base class, but it has no abstract methods or properties + --> B024.py:92:7 | 92 | class notabc_Base_1(notabc.ABC): # error - | ^^^^^^^^^^^^^ B024 + | ^^^^^^^^^^^^^ 93 | def method(self): 94 | foo() | -B024.py:132:7: B024 `abc_set_class_variable_2` is an abstract base class, but it has no abstract methods or properties +B024 `abc_set_class_variable_2` is an abstract base class, but it has no abstract methods or properties + --> B024.py:132:7 | 132 | class abc_set_class_variable_2(ABC): # error (not an abstract attribute) - | ^^^^^^^^^^^^^^^^^^^^^^^^ B024 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 133 | foo = 2 | -B024.py:136:7: B024 `abc_set_class_variable_3` is an abstract base class, but it has no abstract methods or properties +B024 `abc_set_class_variable_3` is an abstract base class, but it has no abstract methods or properties + --> B024.py:136:7 | 136 | class abc_set_class_variable_3(ABC): # error (not an abstract attribute) - | ^^^^^^^^^^^^^^^^^^^^^^^^ B024 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 137 | foo: int = 2 | -B024.py:141:7: B024 `abc_set_class_variable_4` is an abstract base class, but it has no abstract methods or properties +B024 `abc_set_class_variable_4` is an abstract base class, but it has no abstract methods or properties + --> B024.py:141:7 | 140 | # this doesn't actually declare a class variable, it's just an expression 141 | class abc_set_class_variable_4(ABC): # error - | ^^^^^^^^^^^^^^^^^^^^^^^^ B024 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 142 | foo | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B025_B025.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B025_B025.py.snap index 117f480fc1..b8f7ff921a 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B025_B025.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B025_B025.py.snap @@ -1,77 +1,84 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B025.py:19:8: B025 try-except block with duplicate exception `ValueError` +B025 try-except block with duplicate exception `ValueError` + --> B025.py:19:8 | 17 | except ValueError: 18 | a = 2 19 | except ValueError: - | ^^^^^^^^^^ B025 + | ^^^^^^^^^^ 20 | a = 2 | -B025.py:28:8: B025 try-except block with duplicate exception `pickle.PickleError` +B025 try-except block with duplicate exception `pickle.PickleError` + --> B025.py:28:8 | 26 | except ValueError: 27 | a = 2 28 | except pickle.PickleError: - | ^^^^^^^^^^^^^^^^^^ B025 + | ^^^^^^^^^^^^^^^^^^ 29 | a = 2 | -B025.py:35:8: B025 try-except block with duplicate exception `ValueError` +B025 try-except block with duplicate exception `ValueError` + --> B025.py:35:8 | 33 | except (ValueError, TypeError): 34 | a = 2 35 | except ValueError: - | ^^^^^^^^^^ B025 + | ^^^^^^^^^^ 36 | a = 2 37 | except (OSError, TypeError): | -B025.py:37:18: B025 try-except block with duplicate exception `TypeError` +B025 try-except block with duplicate exception `TypeError` + --> B025.py:37:18 | 35 | except ValueError: 36 | a = 2 37 | except (OSError, TypeError): - | ^^^^^^^^^ B025 + | ^^^^^^^^^ 38 | a = 2 | -B025.py:44:9: B025 try-except* block with duplicate exception `ValueError` +B025 try-except* block with duplicate exception `ValueError` + --> B025.py:44:9 | 42 | except* ValueError: 43 | a = 2 44 | except* ValueError: - | ^^^^^^^^^^ B025 + | ^^^^^^^^^^ 45 | a = 2 | -B025.py:53:9: B025 try-except* block with duplicate exception `pickle.PickleError` +B025 try-except* block with duplicate exception `pickle.PickleError` + --> B025.py:53:9 | 51 | except* ValueError: 52 | a = 2 53 | except* pickle.PickleError: - | ^^^^^^^^^^^^^^^^^^ B025 + | ^^^^^^^^^^^^^^^^^^ 54 | a = 2 | -B025.py:60:9: B025 try-except* block with duplicate exception `ValueError` +B025 try-except* block with duplicate exception `ValueError` + --> B025.py:60:9 | 58 | except* (ValueError, TypeError): 59 | a = 2 60 | except* ValueError: - | ^^^^^^^^^^ B025 + | ^^^^^^^^^^ 61 | a = 2 62 | except* (OSError, TypeError): | -B025.py:62:19: B025 try-except* block with duplicate exception `TypeError` +B025 try-except* block with duplicate exception `TypeError` + --> B025.py:62:19 | 60 | except* ValueError: 61 | a = 2 62 | except* (OSError, TypeError): - | ^^^^^^^^^ B025 + | ^^^^^^^^^ 63 | a = 2 | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B026_B026.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B026_B026.py.snap index f0cae8d021..3acc613e93 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B026_B026.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B026_B026.py.snap @@ -1,69 +1,75 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B026.py:16:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged +B026 Star-arg unpacking after a keyword argument is strongly discouraged + --> B026.py:16:16 | 14 | foo("bar", baz="baz", bam="bam") 15 | foo(bar="bar", baz="baz", bam="bam") 16 | foo(bam="bam", *["bar", "baz"]) - | ^^^^^^^^^^^^^^^ B026 + | ^^^^^^^^^^^^^^^ 17 | foo(bam="bam", *bar_baz) 18 | foo(baz="baz", bam="bam", *["bar"]) | -B026.py:17:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged +B026 Star-arg unpacking after a keyword argument is strongly discouraged + --> B026.py:17:16 | 15 | foo(bar="bar", baz="baz", bam="bam") 16 | foo(bam="bam", *["bar", "baz"]) 17 | foo(bam="bam", *bar_baz) - | ^^^^^^^^ B026 + | ^^^^^^^^ 18 | foo(baz="baz", bam="bam", *["bar"]) 19 | foo(bar="bar", baz="baz", bam="bam", *[]) | -B026.py:18:27: B026 Star-arg unpacking after a keyword argument is strongly discouraged +B026 Star-arg unpacking after a keyword argument is strongly discouraged + --> B026.py:18:27 | 16 | foo(bam="bam", *["bar", "baz"]) 17 | foo(bam="bam", *bar_baz) 18 | foo(baz="baz", bam="bam", *["bar"]) - | ^^^^^^^^ B026 + | ^^^^^^^^ 19 | foo(bar="bar", baz="baz", bam="bam", *[]) 20 | foo(bam="bam", *["bar"], *["baz"]) | -B026.py:19:38: B026 Star-arg unpacking after a keyword argument is strongly discouraged +B026 Star-arg unpacking after a keyword argument is strongly discouraged + --> B026.py:19:38 | 17 | foo(bam="bam", *bar_baz) 18 | foo(baz="baz", bam="bam", *["bar"]) 19 | foo(bar="bar", baz="baz", bam="bam", *[]) - | ^^^ B026 + | ^^^ 20 | foo(bam="bam", *["bar"], *["baz"]) 21 | foo(*["bar"], bam="bam", *["baz"]) | -B026.py:20:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged +B026 Star-arg unpacking after a keyword argument is strongly discouraged + --> B026.py:20:16 | 18 | foo(baz="baz", bam="bam", *["bar"]) 19 | foo(bar="bar", baz="baz", bam="bam", *[]) 20 | foo(bam="bam", *["bar"], *["baz"]) - | ^^^^^^^^ B026 + | ^^^^^^^^ 21 | foo(*["bar"], bam="bam", *["baz"]) | -B026.py:20:26: B026 Star-arg unpacking after a keyword argument is strongly discouraged +B026 Star-arg unpacking after a keyword argument is strongly discouraged + --> B026.py:20:26 | 18 | foo(baz="baz", bam="bam", *["bar"]) 19 | foo(bar="bar", baz="baz", bam="bam", *[]) 20 | foo(bam="bam", *["bar"], *["baz"]) - | ^^^^^^^^ B026 + | ^^^^^^^^ 21 | foo(*["bar"], bam="bam", *["baz"]) | -B026.py:21:26: B026 Star-arg unpacking after a keyword argument is strongly discouraged +B026 Star-arg unpacking after a keyword argument is strongly discouraged + --> B026.py:21:26 | 19 | foo(bar="bar", baz="baz", bam="bam", *[]) 20 | foo(bam="bam", *["bar"], *["baz"]) 21 | foo(*["bar"], bam="bam", *["baz"]) - | ^^^^^^^^ B026 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap index 371a87144b..6960228ced 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B027.py:18:5: B027 `AbstractClass.empty_1` is an empty method in an abstract base class, but has no abstract decorator +B027 `AbstractClass.empty_1` is an empty method in an abstract base class, but has no abstract decorator + --> B027.py:18:5 | 17 | class AbstractClass(ABC): 18 | / def empty_1(self): # error 19 | | ... - | |___________^ B027 + | |___________^ 20 | 21 | def empty_2(self): # error | -B027.py:21:5: B027 `AbstractClass.empty_2` is an empty method in an abstract base class, but has no abstract decorator +B027 `AbstractClass.empty_2` is an empty method in an abstract base class, but has no abstract decorator + --> B027.py:21:5 | 19 | ... 20 | 21 | / def empty_2(self): # error 22 | | pass - | |____________^ B027 + | |____________^ 23 | 24 | def empty_3(self): # error | -B027.py:24:5: B027 `AbstractClass.empty_3` is an empty method in an abstract base class, but has no abstract decorator +B027 `AbstractClass.empty_3` is an empty method in an abstract base class, but has no abstract decorator + --> B027.py:24:5 | 22 | pass 23 | 24 | / def empty_3(self): # error 25 | | """docstring""" 26 | | ... - | |___________^ B027 + | |___________^ 27 | 28 | def empty_4(self): # error | -B027.py:28:5: B027 `AbstractClass.empty_4` is an empty method in an abstract base class, but has no abstract decorator +B027 `AbstractClass.empty_4` is an empty method in an abstract base class, but has no abstract decorator + --> B027.py:28:5 | 26 | ... 27 | @@ -44,7 +48,7 @@ B027.py:28:5: B027 `AbstractClass.empty_4` is an empty method in an abstract bas 31 | | pass 32 | | ... 33 | | pass - | |____________^ B027 + | |____________^ 34 | 35 | @notabstract | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap index ddaf48098f..30b4edf861 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B028.py:8:1: B028 [*] No explicit `stacklevel` keyword argument found +B028 [*] No explicit `stacklevel` keyword argument found + --> B028.py:8:1 | 6 | """ 7 | 8 | warnings.warn("test", DeprecationWarning) - | ^^^^^^^^^^^^^ B028 + | ^^^^^^^^^^^^^ 9 | warnings.warn("test", DeprecationWarning, source=None) 10 | warnings.warn("test", DeprecationWarning, source=None, stacklevel=2) | - = help: Set `stacklevel=2` +help: Set `stacklevel=2` ℹ Unsafe fix 5 5 | B028 - on lines 8 and 9 @@ -22,15 +23,16 @@ B028.py:8:1: B028 [*] No explicit `stacklevel` keyword argument found 10 10 | warnings.warn("test", DeprecationWarning, source=None, stacklevel=2) 11 11 | warnings.warn("test", DeprecationWarning, stacklevel=1) -B028.py:9:1: B028 [*] No explicit `stacklevel` keyword argument found +B028 [*] No explicit `stacklevel` keyword argument found + --> B028.py:9:1 | 8 | warnings.warn("test", DeprecationWarning) 9 | warnings.warn("test", DeprecationWarning, source=None) - | ^^^^^^^^^^^^^ B028 + | ^^^^^^^^^^^^^ 10 | warnings.warn("test", DeprecationWarning, source=None, stacklevel=2) 11 | warnings.warn("test", DeprecationWarning, stacklevel=1) | - = help: Set `stacklevel=2` +help: Set `stacklevel=2` ℹ Unsafe fix 6 6 | """ @@ -42,16 +44,17 @@ B028.py:9:1: B028 [*] No explicit `stacklevel` keyword argument found 11 11 | warnings.warn("test", DeprecationWarning, stacklevel=1) 12 12 | warnings.warn("test", DeprecationWarning, 1) -B028.py:22:1: B028 [*] No explicit `stacklevel` keyword argument found +B028 [*] No explicit `stacklevel` keyword argument found + --> B028.py:22:1 | 20 | warnings.warn(*args, **kwargs) 21 | 22 | warnings.warn( - | ^^^^^^^^^^^^^ B028 + | ^^^^^^^^^^^^^ 23 | "test", 24 | DeprecationWarning, | - = help: Set `stacklevel=2` +help: Set `stacklevel=2` ℹ Unsafe fix 23 23 | "test", @@ -63,16 +66,17 @@ B028.py:22:1: B028 [*] No explicit `stacklevel` keyword argument found 28 28 | 29 29 | # https://github.com/astral-sh/ruff/issues/18011 -B028.py:32:1: B028 [*] No explicit `stacklevel` keyword argument found +B028 [*] No explicit `stacklevel` keyword argument found + --> B028.py:32:1 | 30 | warnings.warn("test", skip_file_prefixes=(os.path.dirname(__file__),)) 31 | # trigger diagnostic if `skip_file_prefixes` is present and set to the default value 32 | warnings.warn("test", skip_file_prefixes=()) - | ^^^^^^^^^^^^^ B028 + | ^^^^^^^^^^^^^ 33 | 34 | _my_prefixes = ("this","that") | - = help: Set `stacklevel=2` +help: Set `stacklevel=2` ℹ Unsafe fix 29 29 | # https://github.com/astral-sh/ruff/issues/18011 diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap index 776d2e3882..2feb56e38b 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap @@ -1,44 +1,48 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B029.py:8:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle +B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle + --> B029.py:8:1 | 6 | try: 7 | pass 8 | / except (): 9 | | pass - | |________^ B029 + | |________^ 10 | 11 | try: | -B029.py:13:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle +B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle + --> B029.py:13:1 | 11 | try: 12 | pass 13 | / except () as e: 14 | | pass - | |________^ B029 + | |________^ 15 | 16 | try: | -B029.py:18:1: B029 Using `except* ():` with an empty tuple does not catch anything; add exceptions to handle +B029 Using `except* ():` with an empty tuple does not catch anything; add exceptions to handle + --> B029.py:18:1 | 16 | try: 17 | pass 18 | / except* (): 19 | | pass - | |________^ B029 + | |________^ 20 | 21 | try: | -B029.py:23:1: B029 Using `except* ():` with an empty tuple does not catch anything; add exceptions to handle +B029 Using `except* ():` with an empty tuple does not catch anything; add exceptions to handle + --> B029.py:23:1 | 21 | try: 22 | pass 23 | / except* () as e: 24 | | pass - | |________^ B029 + | |________^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B030_B030.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B030_B030.py.snap index c105eb23a0..9b0f73540e 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B030_B030.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B030_B030.py.snap @@ -1,102 +1,112 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B030.py:12:8: B030 `except` handlers should only be exception classes or tuples of exception classes +B030 `except` handlers should only be exception classes or tuples of exception classes + --> B030.py:12:8 | 10 | try: 11 | pass 12 | except 1: # Error - | ^ B030 + | ^ 13 | pass | -B030.py:17:9: B030 `except` handlers should only be exception classes or tuples of exception classes +B030 `except` handlers should only be exception classes or tuples of exception classes + --> B030.py:17:9 | 15 | try: 16 | pass 17 | except (1, ValueError): # Error - | ^ B030 + | ^ 18 | pass | -B030.py:22:21: B030 `except` handlers should only be exception classes or tuples of exception classes +B030 `except` handlers should only be exception classes or tuples of exception classes + --> B030.py:22:21 | 20 | try: 21 | pass 22 | except (ValueError, (RuntimeError, (KeyError, TypeError))): # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | pass | -B030.py:27:37: B030 `except` handlers should only be exception classes or tuples of exception classes +B030 `except` handlers should only be exception classes or tuples of exception classes + --> B030.py:27:37 | 25 | try: 26 | pass 27 | except (ValueError, *(RuntimeError, (KeyError, TypeError))): # Error - | ^^^^^^^^^^^^^^^^^^^^^ B030 + | ^^^^^^^^^^^^^^^^^^^^^ 28 | pass | -B030.py:33:29: B030 `except` handlers should only be exception classes or tuples of exception classes +B030 `except` handlers should only be exception classes or tuples of exception classes + --> B030.py:33:29 | 31 | try: 32 | pass 33 | except (*a, *(RuntimeError, (KeyError, TypeError))): # Error - | ^^^^^^^^^^^^^^^^^^^^^ B030 + | ^^^^^^^^^^^^^^^^^^^^^ 34 | pass | -B030.py:39:28: B030 `except*` handlers should only be exception classes or tuples of exception classes +B030 `except*` handlers should only be exception classes or tuples of exception classes + --> B030.py:39:28 | 37 | try: 38 | pass 39 | except* a + (RuntimeError, (KeyError, TypeError)): # Error - | ^^^^^^^^^^^^^^^^^^^^^ B030 + | ^^^^^^^^^^^^^^^^^^^^^ 40 | pass | -B030.py:131:8: B030 `except` handlers should only be exception classes or tuples of exception classes +B030 `except` handlers should only be exception classes or tuples of exception classes + --> B030.py:131:8 | 129 | try: 130 | pass 131 | except (a, b) * (c, d): # B030 - | ^^^^^^^^^^^^^^^ B030 + | ^^^^^^^^^^^^^^^ 132 | pass | -B030.py:136:9: B030 `except*` handlers should only be exception classes or tuples of exception classes +B030 `except*` handlers should only be exception classes or tuples of exception classes + --> B030.py:136:9 | 134 | try: 135 | pass 136 | except* 1: # Error - | ^ B030 + | ^ 137 | pass | -B030.py:141:10: B030 `except*` handlers should only be exception classes or tuples of exception classes +B030 `except*` handlers should only be exception classes or tuples of exception classes + --> B030.py:141:10 | 139 | try: 140 | pass 141 | except* (1, ValueError): # Error - | ^ B030 + | ^ 142 | pass | -B030.py:146:22: B030 `except*` handlers should only be exception classes or tuples of exception classes +B030 `except*` handlers should only be exception classes or tuples of exception classes + --> B030.py:146:22 | 144 | try: 145 | pass 146 | except* (ValueError, (RuntimeError, (KeyError, TypeError))): # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 147 | pass | -B030.py:151:9: B030 `except*` handlers should only be exception classes or tuples of exception classes +B030 `except*` handlers should only be exception classes or tuples of exception classes + --> B030.py:151:9 | 149 | try: 150 | pass 151 | except* (a, b) * (c, d): # B030 - | ^^^^^^^^^^^^^^^ B030 + | ^^^^^^^^^^^^^^^ 152 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap index 7fb26f40a0..50698965e3 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap @@ -1,225 +1,248 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B031.py:27:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:27:37 | 25 | for shopper in shoppers: 26 | shopper = shopper.title() 27 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 28 | # We're outside the nested loop and used the group again. 29 | collect_shop_items(shopper, section_items) # B031 | -B031.py:29:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:29:33 | 27 | collect_shop_items(shopper, section_items) # B031 28 | # We're outside the nested loop and used the group again. 29 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 30 | 31 | for _section, section_items in groupby(items, key=lambda p: p[1]): | -B031.py:33:31: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:33:31 | 31 | for _section, section_items in groupby(items, key=lambda p: p[1]): 32 | collect_shop_items("Jane", section_items) 33 | collect_shop_items("Joe", section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ | -B031.py:40:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:40:37 | 38 | countdown = 3 39 | while countdown > 0: 40 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 41 | countdown -= 1 | -B031.py:46:29: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:46:29 | 44 | collection = [] 45 | for _section, section_items in groupby(items, key=lambda p: p[1]): 46 | collection.append([list(section_items) for _ in range(3)]) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 47 | 48 | unique_items = set() | -B031.py:56:17: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:56:17 | 55 | # But it should be detected when used again 56 | for item in section_items: # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 57 | another_set.add(item) | -B031.py:79:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:79:37 | 77 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): 78 | for shopper in shoppers: 79 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 80 | 81 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | -B031.py:82:38: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:82:38 | 81 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): 82 | _ = [collect_shop_items(shopper, section_items) for shopper in shoppers] # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 83 | 84 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | -B031.py:94:65: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:94:65 | 92 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): 93 | # The iterator is being used for the second time. 94 | _ = [(item1, item2) for item1 in section_items for item2 in section_items] # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 95 | 96 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | -B031.py:101:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:101:37 | 99 | else: 100 | collect_shop_items(shopper, section_items) 101 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 102 | 103 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | -B031.py:108:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:108:41 | 106 | collect_shop_items(shopper, section_items) 107 | if _section == "greens": 108 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 109 | elif _section == "frozen items": 110 | collect_shop_items(shopper, section_items) # B031 | -B031.py:110:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:110:41 | 108 | collect_shop_items(shopper, section_items) # B031 109 | elif _section == "frozen items": 110 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 111 | else: 112 | collect_shop_items(shopper, section_items) # B031 | -B031.py:112:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:112:41 | 110 | collect_shop_items(shopper, section_items) # B031 111 | else: 112 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 113 | collect_shop_items(shopper, section_items) # B031 114 | elif _section == "frozen items": | -B031.py:113:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:113:37 | 111 | else: 112 | collect_shop_items(shopper, section_items) # B031 113 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 114 | elif _section == "frozen items": 115 | # Mix `match` and `if` statements | -B031.py:120:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:120:49 | 118 | collect_shop_items(shopper, section_items) 119 | if _section == "fourth": 120 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 121 | case _: 122 | collect_shop_items(shopper, section_items) | -B031.py:126:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:126:33 | 124 | collect_shop_items(shopper, section_items) 125 | # Now, it should detect 126 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 127 | 128 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): | -B031.py:135:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:135:49 | 133 | match shopper: 134 | case "Jane": 135 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 136 | case _: 137 | collect_shop_items(shopper, section_items) # B031 | -B031.py:137:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:137:49 | 135 | collect_shop_items(shopper, section_items) # B031 136 | case _: 137 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 138 | case "frozen items": 139 | collect_shop_items(shopper, section_items) | -B031.py:140:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:140:41 | 138 | case "frozen items": 139 | collect_shop_items(shopper, section_items) 140 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 141 | case _: 142 | collect_shop_items(shopper, section_items) | -B031.py:144:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:144:33 | 142 | collect_shop_items(shopper, section_items) 143 | # Now, it should detect 144 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 145 | 146 | for group in groupby(items, key=lambda p: p[1]): | -B031.py:203:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:203:41 | 201 | if _section == "greens": 202 | collect_shop_items(shopper, section_items) 203 | collect_shop_items(shopper, section_items) - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 204 | return | -B031.py:215:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:215:41 | 213 | elif _section == "frozen items": 214 | collect_shop_items(shopper, section_items) 215 | collect_shop_items(shopper, section_items) - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 216 | 217 | # Should trigger, since only one branch has a return statement. | -B031.py:226:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage +B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + --> B031.py:226:37 | 224 | elif _section == "frozen items": 225 | collect_shop_items(shopper, section_items) 226 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 + | ^^^^^^^^^^^^^ 227 | 228 | # Let's redefine the `groupby` function to make sure we pick up the correct one. | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap index dd53337080..896a3850b7 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap @@ -1,76 +1,84 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B032.py:9:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? +B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + --> B032.py:9:1 | 7 | dct = {"a": 1} 8 | 9 | dct["b"]: 2 - | ^^^^^^^^^^^ B032 + | ^^^^^^^^^^^ 10 | dct.b: 2 | -B032.py:10:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? +B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + --> B032.py:10:1 | 9 | dct["b"]: 2 10 | dct.b: 2 - | ^^^^^^^^ B032 + | ^^^^^^^^ 11 | 12 | dct["b"]: "test" | -B032.py:12:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? +B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + --> B032.py:12:1 | 10 | dct.b: 2 11 | 12 | dct["b"]: "test" - | ^^^^^^^^^^^^^^^^ B032 + | ^^^^^^^^^^^^^^^^ 13 | dct.b: "test" | -B032.py:13:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? +B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + --> B032.py:13:1 | 12 | dct["b"]: "test" 13 | dct.b: "test" - | ^^^^^^^^^^^^^ B032 + | ^^^^^^^^^^^^^ 14 | 15 | test = "test" | -B032.py:16:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? +B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + --> B032.py:16:1 | 15 | test = "test" 16 | dct["b"]: test - | ^^^^^^^^^^^^^^ B032 + | ^^^^^^^^^^^^^^ 17 | dct["b"]: test.lower() 18 | dct.b: test | -B032.py:17:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? +B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + --> B032.py:17:1 | 15 | test = "test" 16 | dct["b"]: test 17 | dct["b"]: test.lower() - | ^^^^^^^^^^^^^^^^^^^^^^ B032 + | ^^^^^^^^^^^^^^^^^^^^^^ 18 | dct.b: test 19 | dct.b: test.lower() | -B032.py:18:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? +B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + --> B032.py:18:1 | 16 | dct["b"]: test 17 | dct["b"]: test.lower() 18 | dct.b: test - | ^^^^^^^^^^^ B032 + | ^^^^^^^^^^^ 19 | dct.b: test.lower() | -B032.py:19:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? +B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + --> B032.py:19:1 | 17 | dct["b"]: test.lower() 18 | dct.b: test 19 | dct.b: test.lower() - | ^^^^^^^^^^^^^^^^^^^ B032 + | ^^^^^^^^^^^^^^^^^^^ 20 | 21 | # Do not flag below | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap index d04d48aa93..78dde5f27a 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B033.py:4:35: B033 [*] Sets should not contain duplicate item `"value1"` +B033 [*] Sets should not contain duplicate item `"value1"` + --> B033.py:4:35 | 2 | # Errors. 3 | ### 4 | incorrect_set = {"value1", 23, 5, "value1"} - | ^^^^^^^^ B033 + | ^^^^^^^^ 5 | incorrect_set = {1, 1, 2} 6 | incorrect_set_multiline = { | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 1 1 | ### @@ -22,16 +23,17 @@ B033.py:4:35: B033 [*] Sets should not contain duplicate item `"value1"` 6 6 | incorrect_set_multiline = { 7 7 | "value1", -B033.py:5:21: B033 [*] Sets should not contain duplicate item `1` +B033 [*] Sets should not contain duplicate item `1` + --> B033.py:5:21 | 3 | ### 4 | incorrect_set = {"value1", 23, 5, "value1"} 5 | incorrect_set = {1, 1, 2} - | ^ B033 + | ^ 6 | incorrect_set_multiline = { 7 | "value1", | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 2 2 | # Errors. @@ -43,16 +45,17 @@ B033.py:5:21: B033 [*] Sets should not contain duplicate item `1` 7 7 | "value1", 8 8 | 23, -B033.py:10:5: B033 [*] Sets should not contain duplicate item `"value1"` +B033 [*] Sets should not contain duplicate item `"value1"` + --> B033.py:10:5 | 8 | 23, 9 | 5, 10 | "value1", - | ^^^^^^^^ B033 + | ^^^^^^^^ 11 | # B033 12 | } | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 7 7 | "value1", @@ -63,16 +66,17 @@ B033.py:10:5: B033 [*] Sets should not contain duplicate item `"value1"` 12 11 | } 13 12 | incorrect_set = {1, 1} -B033.py:13:21: B033 [*] Sets should not contain duplicate item `1` +B033 [*] Sets should not contain duplicate item `1` + --> B033.py:13:21 | 11 | # B033 12 | } 13 | incorrect_set = {1, 1} - | ^ B033 + | ^ 14 | incorrect_set = {1, 1,} 15 | incorrect_set = {0, 1, 1,} | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 10 10 | "value1", @@ -84,16 +88,17 @@ B033.py:13:21: B033 [*] Sets should not contain duplicate item `1` 15 15 | incorrect_set = {0, 1, 1,} 16 16 | incorrect_set = {0, 1, 1} -B033.py:14:21: B033 [*] Sets should not contain duplicate item `1` +B033 [*] Sets should not contain duplicate item `1` + --> B033.py:14:21 | 12 | } 13 | incorrect_set = {1, 1} 14 | incorrect_set = {1, 1,} - | ^ B033 + | ^ 15 | incorrect_set = {0, 1, 1,} 16 | incorrect_set = {0, 1, 1} | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 11 11 | # B033 @@ -105,16 +110,17 @@ B033.py:14:21: B033 [*] Sets should not contain duplicate item `1` 16 16 | incorrect_set = {0, 1, 1} 17 17 | incorrect_set = { -B033.py:15:24: B033 [*] Sets should not contain duplicate item `1` +B033 [*] Sets should not contain duplicate item `1` + --> B033.py:15:24 | 13 | incorrect_set = {1, 1} 14 | incorrect_set = {1, 1,} 15 | incorrect_set = {0, 1, 1,} - | ^ B033 + | ^ 16 | incorrect_set = {0, 1, 1} 17 | incorrect_set = { | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 12 12 | } @@ -126,16 +132,17 @@ B033.py:15:24: B033 [*] Sets should not contain duplicate item `1` 17 17 | incorrect_set = { 18 18 | 0, -B033.py:16:24: B033 [*] Sets should not contain duplicate item `1` +B033 [*] Sets should not contain duplicate item `1` + --> B033.py:16:24 | 14 | incorrect_set = {1, 1,} 15 | incorrect_set = {0, 1, 1,} 16 | incorrect_set = {0, 1, 1} - | ^ B033 + | ^ 17 | incorrect_set = { 18 | 0, | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 13 13 | incorrect_set = {1, 1} @@ -147,16 +154,17 @@ B033.py:16:24: B033 [*] Sets should not contain duplicate item `1` 18 18 | 0, 19 19 | 1, -B033.py:20:5: B033 [*] Sets should not contain duplicate item `1` +B033 [*] Sets should not contain duplicate item `1` + --> B033.py:20:5 | 18 | 0, 19 | 1, 20 | 1, - | ^ B033 + | ^ 21 | } 22 | incorrect_set = {False, 1, 0} | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 17 17 | incorrect_set = { @@ -167,16 +175,17 @@ B033.py:20:5: B033 [*] Sets should not contain duplicate item `1` 22 21 | incorrect_set = {False, 1, 0} 23 22 | -B033.py:22:28: B033 [*] Sets should not contain duplicate items, but `False` and `0` has the same value +B033 [*] Sets should not contain duplicate items, but `False` and `0` has the same value + --> B033.py:22:28 | 20 | 1, 21 | } 22 | incorrect_set = {False, 1, 0} - | ^ B033 + | ^ 23 | 24 | ### | - = help: Remove duplicate item +help: Remove duplicate item ℹ Safe fix 19 19 | 1, diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap index c92b98b7d5..76d5afa56c 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap @@ -1,100 +1,110 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B034.py:5:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:5:1 | 4 | # B034 5 | re.sub("a", "b", "aaa", re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | re.sub("a", "b", "aaa", 5) 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) | -B034.py:6:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:6:1 | 4 | # B034 5 | re.sub("a", "b", "aaa", re.IGNORECASE) 6 | re.sub("a", "b", "aaa", 5) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) 8 | re.subn("a", "b", "aaa", re.IGNORECASE) | -B034.py:7:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:7:1 | 5 | re.sub("a", "b", "aaa", re.IGNORECASE) 6 | re.sub("a", "b", "aaa", 5) 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | re.subn("a", "b", "aaa", re.IGNORECASE) 9 | re.subn("a", "b", "aaa", 5) | -B034.py:8:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:8:1 | 6 | re.sub("a", "b", "aaa", 5) 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) 8 | re.subn("a", "b", "aaa", re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | re.subn("a", "b", "aaa", 5) 10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) | -B034.py:9:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:9:1 | 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) 8 | re.subn("a", "b", "aaa", re.IGNORECASE) 9 | re.subn("a", "b", "aaa", 5) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) 11 | re.split(" ", "a a a a", re.I) | -B034.py:10:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:10:1 | 8 | re.subn("a", "b", "aaa", re.IGNORECASE) 9 | re.subn("a", "b", "aaa", 5) 10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | re.split(" ", "a a a a", re.I) 12 | re.split(" ", "a a a a", 2) | -B034.py:11:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:11:1 | 9 | re.subn("a", "b", "aaa", 5) 10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) 11 | re.split(" ", "a a a a", re.I) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | re.split(" ", "a a a a", 2) 13 | re.split(" ", "a a a a", 2, re.I) | -B034.py:12:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:12:1 | 10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) 11 | re.split(" ", "a a a a", re.I) 12 | re.split(" ", "a a a a", 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | re.split(" ", "a a a a", 2, re.I) 14 | sub("a", "b", "aaa", re.IGNORECASE) | -B034.py:13:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:13:1 | 11 | re.split(" ", "a a a a", re.I) 12 | re.split(" ", "a a a a", 2) 13 | re.split(" ", "a a a a", 2, re.I) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | sub("a", "b", "aaa", re.IGNORECASE) | -B034.py:14:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions +B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + --> B034.py:14:1 | 12 | re.split(" ", "a a a a", 2) 13 | re.split(" ", "a a a a", 2, re.I) 14 | sub("a", "b", "aaa", re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B035_B035.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B035_B035.py.snap index dd3e169639..9d25a4c1b6 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B035_B035.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B035_B035.py.snap @@ -1,89 +1,97 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B035.py:17:2: B035 Dictionary comprehension uses static key: `"key"` +B035 Dictionary comprehension uses static key: `"key"` + --> B035.py:17:2 | 16 | # Errors 17 | {"key": value.upper() for value in data} - | ^^^^^ B035 + | ^^^^^ 18 | {True: value.upper() for value in data} 19 | {0: value.upper() for value in data} | -B035.py:18:2: B035 Dictionary comprehension uses static key: `True` +B035 Dictionary comprehension uses static key: `True` + --> B035.py:18:2 | 16 | # Errors 17 | {"key": value.upper() for value in data} 18 | {True: value.upper() for value in data} - | ^^^^ B035 + | ^^^^ 19 | {0: value.upper() for value in data} 20 | {(1, "a"): value.upper() for value in data} # Constant tuple | -B035.py:19:2: B035 Dictionary comprehension uses static key: `0` +B035 Dictionary comprehension uses static key: `0` + --> B035.py:19:2 | 17 | {"key": value.upper() for value in data} 18 | {True: value.upper() for value in data} 19 | {0: value.upper() for value in data} - | ^ B035 + | ^ 20 | {(1, "a"): value.upper() for value in data} # Constant tuple 21 | {constant: value.upper() for value in data} | -B035.py:20:2: B035 Dictionary comprehension uses static key: `(1, "a")` +B035 Dictionary comprehension uses static key: `(1, "a")` + --> B035.py:20:2 | 18 | {True: value.upper() for value in data} 19 | {0: value.upper() for value in data} 20 | {(1, "a"): value.upper() for value in data} # Constant tuple - | ^^^^^^^^ B035 + | ^^^^^^^^ 21 | {constant: value.upper() for value in data} 22 | {constant + constant: value.upper() for value in data} | -B035.py:21:2: B035 Dictionary comprehension uses static key: `constant` +B035 Dictionary comprehension uses static key: `constant` + --> B035.py:21:2 | 19 | {0: value.upper() for value in data} 20 | {(1, "a"): value.upper() for value in data} # Constant tuple 21 | {constant: value.upper() for value in data} - | ^^^^^^^^ B035 + | ^^^^^^^^ 22 | {constant + constant: value.upper() for value in data} 23 | {constant.attribute: value.upper() for value in data} | -B035.py:22:2: B035 Dictionary comprehension uses static key: `constant + constant` +B035 Dictionary comprehension uses static key: `constant + constant` + --> B035.py:22:2 | 20 | {(1, "a"): value.upper() for value in data} # Constant tuple 21 | {constant: value.upper() for value in data} 22 | {constant + constant: value.upper() for value in data} - | ^^^^^^^^^^^^^^^^^^^ B035 + | ^^^^^^^^^^^^^^^^^^^ 23 | {constant.attribute: value.upper() for value in data} 24 | {constant[0]: value.upper() for value in data} | -B035.py:23:2: B035 Dictionary comprehension uses static key: `constant.attribute` +B035 Dictionary comprehension uses static key: `constant.attribute` + --> B035.py:23:2 | 21 | {constant: value.upper() for value in data} 22 | {constant + constant: value.upper() for value in data} 23 | {constant.attribute: value.upper() for value in data} - | ^^^^^^^^^^^^^^^^^^ B035 + | ^^^^^^^^^^^^^^^^^^ 24 | {constant[0]: value.upper() for value in data} 25 | {tokens: token for token in tokens} | -B035.py:24:2: B035 Dictionary comprehension uses static key: `constant[0]` +B035 Dictionary comprehension uses static key: `constant[0]` + --> B035.py:24:2 | 22 | {constant + constant: value.upper() for value in data} 23 | {constant.attribute: value.upper() for value in data} 24 | {constant[0]: value.upper() for value in data} - | ^^^^^^^^^^^ B035 + | ^^^^^^^^^^^ 25 | {tokens: token for token in tokens} | -B035.py:25:2: B035 Dictionary comprehension uses static key: `tokens` +B035 Dictionary comprehension uses static key: `tokens` + --> B035.py:25:2 | 23 | {constant.attribute: value.upper() for value in data} 24 | {constant[0]: value.upper() for value in data} 25 | {tokens: token for token in tokens} - | ^^^^^^ B035 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B039_B039.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B039_B039.py.snap index 8b7b9add10..07fdb4b2a7 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B039_B039.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B039_B039.py.snap @@ -1,149 +1,163 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B039.py:21:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:21:26 | 20 | # Bad 21 | ContextVar("cv", default=[]) - | ^^ B039 + | ^^ 22 | ContextVar("cv", default={}) 23 | ContextVar("cv", default=list()) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:22:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:22:26 | 20 | # Bad 21 | ContextVar("cv", default=[]) 22 | ContextVar("cv", default={}) - | ^^ B039 + | ^^ 23 | ContextVar("cv", default=list()) 24 | ContextVar("cv", default=set()) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:23:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:23:26 | 21 | ContextVar("cv", default=[]) 22 | ContextVar("cv", default={}) 23 | ContextVar("cv", default=list()) - | ^^^^^^ B039 + | ^^^^^^ 24 | ContextVar("cv", default=set()) 25 | ContextVar("cv", default=dict()) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:24:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:24:26 | 22 | ContextVar("cv", default={}) 23 | ContextVar("cv", default=list()) 24 | ContextVar("cv", default=set()) - | ^^^^^ B039 + | ^^^^^ 25 | ContextVar("cv", default=dict()) 26 | ContextVar("cv", default=[char for char in "foo"]) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:25:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:25:26 | 23 | ContextVar("cv", default=list()) 24 | ContextVar("cv", default=set()) 25 | ContextVar("cv", default=dict()) - | ^^^^^^ B039 + | ^^^^^^ 26 | ContextVar("cv", default=[char for char in "foo"]) 27 | ContextVar("cv", default={char for char in "foo"}) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:26:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:26:26 | 24 | ContextVar("cv", default=set()) 25 | ContextVar("cv", default=dict()) 26 | ContextVar("cv", default=[char for char in "foo"]) - | ^^^^^^^^^^^^^^^^^^^^^^^^ B039 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 27 | ContextVar("cv", default={char for char in "foo"}) 28 | ContextVar("cv", default={char: idx for idx, char in enumerate("foo")}) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:27:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:27:26 | 25 | ContextVar("cv", default=dict()) 26 | ContextVar("cv", default=[char for char in "foo"]) 27 | ContextVar("cv", default={char for char in "foo"}) - | ^^^^^^^^^^^^^^^^^^^^^^^^ B039 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 28 | ContextVar("cv", default={char: idx for idx, char in enumerate("foo")}) 29 | ContextVar("cv", default=collections.deque()) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:28:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:28:26 | 26 | ContextVar("cv", default=[char for char in "foo"]) 27 | ContextVar("cv", default={char for char in "foo"}) 28 | ContextVar("cv", default={char: idx for idx, char in enumerate("foo")}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B039 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | ContextVar("cv", default=collections.deque()) 30 | ContextVar("cv", default=set[str]()) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:29:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:29:26 | 27 | ContextVar("cv", default={char for char in "foo"}) 28 | ContextVar("cv", default={char: idx for idx, char in enumerate("foo")}) 29 | ContextVar("cv", default=collections.deque()) - | ^^^^^^^^^^^^^^^^^^^ B039 + | ^^^^^^^^^^^^^^^^^^^ 30 | ContextVar("cv", default=set[str]()) 31 | ContextVar[set[str]]("cv", default=set[str]()) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:30:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:30:26 | 28 | ContextVar("cv", default={char: idx for idx, char in enumerate("foo")}) 29 | ContextVar("cv", default=collections.deque()) 30 | ContextVar("cv", default=set[str]()) - | ^^^^^^^^^^ B039 + | ^^^^^^^^^^ 31 | ContextVar[set[str]]("cv", default=set[str]()) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:31:36: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:31:36 | 29 | ContextVar("cv", default=collections.deque()) 30 | ContextVar("cv", default=set[str]()) 31 | ContextVar[set[str]]("cv", default=set[str]()) - | ^^^^^^^^^^ B039 + | ^^^^^^^^^^ 32 | 33 | def bar() -> list[int]: | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:36:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:36:26 | 34 | return [1, 2, 3] 35 | 36 | ContextVar("cv", default=bar()) - | ^^^^^ B039 + | ^^^^^ 37 | ContextVar("cv", default=time.time()) | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:37:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:37:26 | 36 | ContextVar("cv", default=bar()) 37 | ContextVar("cv", default=time.time()) - | ^^^^^^^^^^^ B039 + | ^^^^^^^^^^^ 38 | 39 | def baz(): ... | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` -B039.py:40:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039.py:40:26 | 39 | def baz(): ... 40 | ContextVar("cv", default=baz()) - | ^^^^^ B039 + | ^^^^^ | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B901_B901.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B901_B901.py.snap index 8d98e5fcd4..951860f81e 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B901_B901.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B901_B901.py.snap @@ -1,21 +1,23 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B901.py:9:9: B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior +B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior + --> B901.py:9:9 | 7 | def broken(): 8 | if True: 9 | return [1, 2, 3] - | ^^^^^^^^^^^^^^^^ B901 + | ^^^^^^^^^^^^^^^^ 10 | 11 | yield 3 | -B901.py:36:5: B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior +B901 Using `yield` and `return {value}` in a generator function can lead to confusing behavior + --> B901.py:36:5 | 35 | def broken2(): 36 | return [3, 2, 1] - | ^^^^^^^^^^^^^^^^ B901 + | ^^^^^^^^^^^^^^^^ 37 | 38 | yield from not_broken() | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_class_as_data_structure.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_class_as_data_structure.py.snap index 961e89f613..6c5e006f18 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_class_as_data_structure.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_class_as_data_structure.py.snap @@ -1,16 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -class_as_data_structure.py:6:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:6:1 | 6 | / class Point: # B903 7 | | def __init__(self, x: float, y: float) -> None: 8 | | self.x = x 9 | | self.y = y - | |__________________^ B903 + | |__________________^ | -class_as_data_structure.py:40:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:40:1 | 38 | ... 39 | @@ -18,12 +20,13 @@ class_as_data_structure.py:40:1: B903 Class could be dataclass or namedtuple 41 | | c: int 42 | | def __init__(self,d:list): 43 | | self.d = d - | |__________________^ B903 + | |__________________^ 44 | 45 | class D: # B903 | -class_as_data_structure.py:45:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:45:1 | 43 | self.d = d 44 | @@ -32,12 +35,13 @@ class_as_data_structure.py:45:1: B903 Class could be dataclass or namedtuple 47 | | # this next method is an init 48 | | def __init__(self,e:dict): 49 | | self.e = e - | |__________________^ B903 + | |__________________^ 50 | 51 | # <--- begin flake8-bugbear tests below | -class_as_data_structure.py:63:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:63:1 | 63 | / class NoWarningsClassAttributes: 64 | | spam = "ham" @@ -45,19 +49,21 @@ class_as_data_structure.py:63:1: B903 Class could be dataclass or namedtuple 66 | | def __init__(self, foo:int, bar:list): 67 | | self.foo = foo 68 | | self.bar = bar - | |______________________^ B903 + | |______________________^ | -class_as_data_structure.py:85:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:85:1 | 85 | / class Warnings: 86 | | def __init__(self, foo:int, bar:list): 87 | | self.foo = foo 88 | | self.bar = bar - | |______________________^ B903 + | |______________________^ | -class_as_data_structure.py:91:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:91:1 | 91 | / class WarningsWithDocstring: 92 | | """A docstring should not be an impediment to a warning""" @@ -65,16 +71,17 @@ class_as_data_structure.py:91:1: B903 Class could be dataclass or namedtuple 94 | | def __init__(self, foo:int, bar:list): 95 | | self.foo = foo 96 | | self.bar = bar - | |______________________^ B903 + | |______________________^ | -class_as_data_structure.py:99:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:99:1 | 99 | / class KeywordOnly: # OK with python3.9 or less, not OK starting python3.10 100 | | def __init__(self, *, foo: int, bar: int): 101 | | self.foo = foo 102 | | self.bar = bar - | |______________________^ B903 + | |______________________^ 103 | 104 | # <-- end flake8-bugbear tests | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_py39_class_as_data_structure.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_py39_class_as_data_structure.py.snap index d801e29068..57347eeb2f 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_py39_class_as_data_structure.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B903_py39_class_as_data_structure.py.snap @@ -1,16 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -class_as_data_structure.py:6:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:6:1 | 6 | / class Point: # B903 7 | | def __init__(self, x: float, y: float) -> None: 8 | | self.x = x 9 | | self.y = y - | |__________________^ B903 + | |__________________^ | -class_as_data_structure.py:40:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:40:1 | 38 | ... 39 | @@ -18,12 +20,13 @@ class_as_data_structure.py:40:1: B903 Class could be dataclass or namedtuple 41 | | c: int 42 | | def __init__(self,d:list): 43 | | self.d = d - | |__________________^ B903 + | |__________________^ 44 | 45 | class D: # B903 | -class_as_data_structure.py:45:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:45:1 | 43 | self.d = d 44 | @@ -32,12 +35,13 @@ class_as_data_structure.py:45:1: B903 Class could be dataclass or namedtuple 47 | | # this next method is an init 48 | | def __init__(self,e:dict): 49 | | self.e = e - | |__________________^ B903 + | |__________________^ 50 | 51 | # <--- begin flake8-bugbear tests below | -class_as_data_structure.py:63:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:63:1 | 63 | / class NoWarningsClassAttributes: 64 | | spam = "ham" @@ -45,19 +49,21 @@ class_as_data_structure.py:63:1: B903 Class could be dataclass or namedtuple 66 | | def __init__(self, foo:int, bar:list): 67 | | self.foo = foo 68 | | self.bar = bar - | |______________________^ B903 + | |______________________^ | -class_as_data_structure.py:85:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:85:1 | 85 | / class Warnings: 86 | | def __init__(self, foo:int, bar:list): 87 | | self.foo = foo 88 | | self.bar = bar - | |______________________^ B903 + | |______________________^ | -class_as_data_structure.py:91:1: B903 Class could be dataclass or namedtuple +B903 Class could be dataclass or namedtuple + --> class_as_data_structure.py:91:1 | 91 | / class WarningsWithDocstring: 92 | | """A docstring should not be an impediment to a warning""" @@ -65,5 +71,5 @@ class_as_data_structure.py:91:1: B903 Class could be dataclass or namedtuple 94 | | def __init__(self, foo:int, bar:list): 95 | | self.foo = foo 96 | | self.bar = bar - | |______________________^ B903 + | |______________________^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap index 1d7390ce04..19d7b0c5bb 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap @@ -1,130 +1,143 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B904.py:10:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:10:9 | 8 | except ValueError: 9 | if "abc": 10 | raise TypeError - | ^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^ 11 | raise UserWarning 12 | except AssertionError: | -B904.py:11:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:11:5 | 9 | if "abc": 10 | raise TypeError 11 | raise UserWarning - | ^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^ 12 | except AssertionError: 13 | raise # Bare `raise` should not be an error | -B904.py:16:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:16:5 | 14 | except Exception as err: 15 | assert err 16 | raise Exception("No cause here...") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | except BaseException as err: 18 | raise err | -B904.py:20:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:20:5 | 18 | raise err 19 | except BaseException as err: 20 | raise some_other_err - | ^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^ 21 | finally: 22 | raise Exception("Nothing to chain from, so no warning here") | -B904.py:63:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:63:9 | 61 | except Exception as e: 62 | if ...: 63 | raise RuntimeError("boom!") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | else: 65 | raise RuntimeError("bang!") | -B904.py:65:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:65:9 | 63 | raise RuntimeError("boom!") 64 | else: 65 | raise RuntimeError("bang!") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -B904.py:73:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:73:13 | 71 | match 0: 72 | case 0: 73 | raise RuntimeError("boom!") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 74 | 75 | try: | -B904.py:79:9: B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:79:9 | 77 | except* Exception as e: 78 | if ...: 79 | raise RuntimeError("boom!") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 80 | else: 81 | raise RuntimeError("bang!") | -B904.py:81:9: B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:81:9 | 79 | raise RuntimeError("boom!") 80 | else: 81 | raise RuntimeError("bang!") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 82 | 83 | try: | -B904.py:87:9: B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:87:9 | 85 | except* ValueError: 86 | if "abc": 87 | raise TypeError - | ^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^ 88 | raise UserWarning 89 | except* AssertionError: | -B904.py:88:5: B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:88:5 | 86 | if "abc": 87 | raise TypeError 88 | raise UserWarning - | ^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^ 89 | except* AssertionError: 90 | raise # Bare `raise` should not be an error | -B904.py:93:5: B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:93:5 | 91 | except* Exception as err: 92 | assert err 93 | raise Exception("No cause here...") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 94 | except* BaseException as err: 95 | raise err | -B904.py:97:5: B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling +B904 Within an `except*` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + --> B904.py:97:5 | 95 | raise err 96 | except* BaseException as err: 97 | raise some_other_err - | ^^^^^^^^^^^^^^^^^^^^ B904 + | ^^^^^^^^^^^^^^^^^^^^ 98 | finally: 99 | raise Exception("Nothing to chain from, so no warning here") | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap index 4628deaeec..c3b396af36 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B905.py:4:1: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:4:1 | 3 | # Errors 4 | zip() - | ^^^^^ B905 + | ^^^^^ 5 | zip(range(3)) 6 | zip("a", "b") | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 1 1 | from itertools import count, cycle, repeat @@ -21,16 +22,17 @@ B905.py:4:1: B905 [*] `zip()` without an explicit `strict=` parameter 6 6 | zip("a", "b") 7 7 | zip("a", "b", *zip("c")) -B905.py:5:1: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:5:1 | 3 | # Errors 4 | zip() 5 | zip(range(3)) - | ^^^^^^^^^^^^^ B905 + | ^^^^^^^^^^^^^ 6 | zip("a", "b") 7 | zip("a", "b", *zip("c")) | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 2 2 | @@ -42,16 +44,17 @@ B905.py:5:1: B905 [*] `zip()` without an explicit `strict=` parameter 7 7 | zip("a", "b", *zip("c")) 8 8 | zip(zip("a"), strict=False) -B905.py:6:1: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:6:1 | 4 | zip() 5 | zip(range(3)) 6 | zip("a", "b") - | ^^^^^^^^^^^^^ B905 + | ^^^^^^^^^^^^^ 7 | zip("a", "b", *zip("c")) 8 | zip(zip("a"), strict=False) | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 3 3 | # Errors @@ -63,16 +66,17 @@ B905.py:6:1: B905 [*] `zip()` without an explicit `strict=` parameter 8 8 | zip(zip("a"), strict=False) 9 9 | zip(zip("a", strict=True)) -B905.py:7:1: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:7:1 | 5 | zip(range(3)) 6 | zip("a", "b") 7 | zip("a", "b", *zip("c")) - | ^^^^^^^^^^^^^^^^^^^^^^^^ B905 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 8 | zip(zip("a"), strict=False) 9 | zip(zip("a", strict=True)) | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 4 4 | zip() @@ -84,16 +88,17 @@ B905.py:7:1: B905 [*] `zip()` without an explicit `strict=` parameter 9 9 | zip(zip("a", strict=True)) 10 10 | -B905.py:7:16: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:7:16 | 5 | zip(range(3)) 6 | zip("a", "b") 7 | zip("a", "b", *zip("c")) - | ^^^^^^^^ B905 + | ^^^^^^^^ 8 | zip(zip("a"), strict=False) 9 | zip(zip("a", strict=True)) | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 4 4 | zip() @@ -105,15 +110,16 @@ B905.py:7:16: B905 [*] `zip()` without an explicit `strict=` parameter 9 9 | zip(zip("a", strict=True)) 10 10 | -B905.py:8:5: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:8:5 | 6 | zip("a", "b") 7 | zip("a", "b", *zip("c")) 8 | zip(zip("a"), strict=False) - | ^^^^^^^^ B905 + | ^^^^^^^^ 9 | zip(zip("a", strict=True)) | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 5 5 | zip(range(3)) @@ -125,16 +131,17 @@ B905.py:8:5: B905 [*] `zip()` without an explicit `strict=` parameter 10 10 | 11 11 | # OK -B905.py:9:1: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:9:1 | 7 | zip("a", "b", *zip("c")) 8 | zip(zip("a"), strict=False) 9 | zip(zip("a", strict=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # OK | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 6 6 | zip("a", "b") @@ -146,14 +153,15 @@ B905.py:9:1: B905 [*] `zip()` without an explicit `strict=` parameter 11 11 | # OK 12 12 | zip(range(3), strict=True) -B905.py:24:1: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:24:1 | 23 | # Errors (limited iterators). 24 | zip([1, 2, 3], repeat(1, 1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | zip([1, 2, 3], repeat(1, times=4)) | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 21 21 | zip([1, 2, 3], repeat(1, times=None)) @@ -165,16 +173,17 @@ B905.py:24:1: B905 [*] `zip()` without an explicit `strict=` parameter 26 26 | 27 27 | import builtins -B905.py:25:1: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:25:1 | 23 | # Errors (limited iterators). 24 | zip([1, 2, 3], repeat(1, 1)) 25 | zip([1, 2, 3], repeat(1, times=4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | import builtins | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 22 22 | @@ -186,14 +195,15 @@ B905.py:25:1: B905 [*] `zip()` without an explicit `strict=` parameter 27 27 | import builtins 28 28 | # Still an error even though it uses the qualified name -B905.py:29:1: B905 [*] `zip()` without an explicit `strict=` parameter +B905 [*] `zip()` without an explicit `strict=` parameter + --> B905.py:29:1 | 27 | import builtins 28 | # Still an error even though it uses the qualified name 29 | builtins.zip([1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^^^ B905 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add explicit value for parameter `strict=` +help: Add explicit value for parameter `strict=` ℹ Safe fix 26 26 | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B909_B909.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B909_B909.py.snap index c7385dec29..94d81abc41 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B909_B909.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B909_B909.py.snap @@ -1,380 +1,419 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B909.py:12:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:12:5 | 10 | for elem in some_list: 11 | # errors 12 | some_list.remove(0) - | ^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^ 13 | del some_list[2] 14 | some_list.append(elem) | -B909.py:13:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:13:5 | 11 | # errors 12 | some_list.remove(0) 13 | del some_list[2] - | ^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^ 14 | some_list.append(elem) 15 | some_list.sort() | -B909.py:14:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:14:5 | 12 | some_list.remove(0) 13 | del some_list[2] 14 | some_list.append(elem) - | ^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^ 15 | some_list.sort() 16 | some_list.reverse() | -B909.py:15:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:15:5 | 13 | del some_list[2] 14 | some_list.append(elem) 15 | some_list.sort() - | ^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^ 16 | some_list.reverse() 17 | some_list.clear() | -B909.py:16:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:16:5 | 14 | some_list.append(elem) 15 | some_list.sort() 16 | some_list.reverse() - | ^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^ 17 | some_list.clear() 18 | some_list.extend([1, 2]) | -B909.py:17:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:17:5 | 15 | some_list.sort() 16 | some_list.reverse() 17 | some_list.clear() - | ^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^ 18 | some_list.extend([1, 2]) 19 | some_list.insert(1, 1) | -B909.py:18:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:18:5 | 16 | some_list.reverse() 17 | some_list.clear() 18 | some_list.extend([1, 2]) - | ^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^ 19 | some_list.insert(1, 1) 20 | some_list.pop(1) | -B909.py:19:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:19:5 | 17 | some_list.clear() 18 | some_list.extend([1, 2]) 19 | some_list.insert(1, 1) - | ^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^ 20 | some_list.pop(1) 21 | some_list.pop() | -B909.py:20:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:20:5 | 18 | some_list.extend([1, 2]) 19 | some_list.insert(1, 1) 20 | some_list.pop(1) - | ^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^ 21 | some_list.pop() | -B909.py:21:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:21:5 | 19 | some_list.insert(1, 1) 20 | some_list.pop(1) 21 | some_list.pop() - | ^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^ 22 | 23 | # conditional break should error | -B909.py:25:9: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:25:9 | 23 | # conditional break should error 24 | if elem == 2: 25 | some_list.remove(0) - | ^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^ 26 | if elem == 3: 27 | break | -B909.py:47:5: B909 Mutation to loop iterable `mydicts` during iteration +B909 Mutation to loop iterable `mydicts` during iteration + --> B909.py:47:5 | 45 | for elem in mydicts: 46 | # errors 47 | mydicts.popitem() - | ^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^ 48 | mydicts.setdefault("foo", 1) 49 | mydicts.update({"foo": "bar"}) | -B909.py:48:5: B909 Mutation to loop iterable `mydicts` during iteration +B909 Mutation to loop iterable `mydicts` during iteration + --> B909.py:48:5 | 46 | # errors 47 | mydicts.popitem() 48 | mydicts.setdefault("foo", 1) - | ^^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^^ 49 | mydicts.update({"foo": "bar"}) | -B909.py:49:5: B909 Mutation to loop iterable `mydicts` during iteration +B909 Mutation to loop iterable `mydicts` during iteration + --> B909.py:49:5 | 47 | mydicts.popitem() 48 | mydicts.setdefault("foo", 1) 49 | mydicts.update({"foo": "bar"}) - | ^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^ 50 | 51 | # no errors | -B909.py:62:5: B909 Mutation to loop iterable `myset` during iteration +B909 Mutation to loop iterable `myset` during iteration + --> B909.py:62:5 | 60 | for _ in myset: 61 | # errors 62 | myset.update({4, 5}) - | ^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^ 63 | myset.intersection_update({4, 5}) 64 | myset.difference_update({4, 5}) | -B909.py:63:5: B909 Mutation to loop iterable `myset` during iteration +B909 Mutation to loop iterable `myset` during iteration + --> B909.py:63:5 | 61 | # errors 62 | myset.update({4, 5}) 63 | myset.intersection_update({4, 5}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | myset.difference_update({4, 5}) 65 | myset.symmetric_difference_update({4, 5}) | -B909.py:64:5: B909 Mutation to loop iterable `myset` during iteration +B909 Mutation to loop iterable `myset` during iteration + --> B909.py:64:5 | 62 | myset.update({4, 5}) 63 | myset.intersection_update({4, 5}) 64 | myset.difference_update({4, 5}) - | ^^^^^^^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^^^^^^^ 65 | myset.symmetric_difference_update({4, 5}) 66 | myset.add(4) | -B909.py:65:5: B909 Mutation to loop iterable `myset` during iteration +B909 Mutation to loop iterable `myset` during iteration + --> B909.py:65:5 | 63 | myset.intersection_update({4, 5}) 64 | myset.difference_update({4, 5}) 65 | myset.symmetric_difference_update({4, 5}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | myset.add(4) 67 | myset.discard(3) | -B909.py:66:5: B909 Mutation to loop iterable `myset` during iteration +B909 Mutation to loop iterable `myset` during iteration + --> B909.py:66:5 | 64 | myset.difference_update({4, 5}) 65 | myset.symmetric_difference_update({4, 5}) 66 | myset.add(4) - | ^^^^^^^^^ B909 + | ^^^^^^^^^ 67 | myset.discard(3) | -B909.py:67:5: B909 Mutation to loop iterable `myset` during iteration +B909 Mutation to loop iterable `myset` during iteration + --> B909.py:67:5 | 65 | myset.symmetric_difference_update({4, 5}) 66 | myset.add(4) 67 | myset.discard(3) - | ^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^ 68 | 69 | # no errors | -B909.py:84:5: B909 Mutation to loop iterable `a.some_list` during iteration +B909 Mutation to loop iterable `a.some_list` during iteration + --> B909.py:84:5 | 82 | # ensure member accesses are handled as errors 83 | for elem in a.some_list: 84 | a.some_list.remove(0) - | ^^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^^ 85 | del a.some_list[2] | -B909.py:85:5: B909 Mutation to loop iterable `a.some_list` during iteration +B909 Mutation to loop iterable `a.some_list` during iteration + --> B909.py:85:5 | 83 | for elem in a.some_list: 84 | a.some_list.remove(0) 85 | del a.some_list[2] - | ^^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^^ | -B909.py:93:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:93:5 | 91 | bar = [4, 5, 6] 92 | for _ in foo: 93 | foo *= 2 - | ^^^^^^^^ B909 + | ^^^^^^^^ 94 | foo += bar 95 | foo[1] = 9 | -B909.py:94:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:94:5 | 92 | for _ in foo: 93 | foo *= 2 94 | foo += bar - | ^^^^^^^^^^ B909 + | ^^^^^^^^^^ 95 | foo[1] = 9 96 | foo[1:2] = bar | -B909.py:95:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:95:5 | 93 | foo *= 2 94 | foo += bar 95 | foo[1] = 9 - | ^^^^^^^^^^ B909 + | ^^^^^^^^^^ 96 | foo[1:2] = bar 97 | foo[1:2:3] = bar | -B909.py:96:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:96:5 | 94 | foo += bar 95 | foo[1] = 9 96 | foo[1:2] = bar - | ^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^ 97 | foo[1:2:3] = bar | -B909.py:97:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:97:5 | 95 | foo[1] = 9 96 | foo[1:2] = bar 97 | foo[1:2:3] = bar - | ^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^ 98 | 99 | foo = {1, 2, 3} | -B909.py:102:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:102:5 | 100 | bar = {4, 5, 6} 101 | for _ in foo: # should error 102 | foo |= bar - | ^^^^^^^^^^ B909 + | ^^^^^^^^^^ 103 | foo &= bar 104 | foo -= bar | -B909.py:103:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:103:5 | 101 | for _ in foo: # should error 102 | foo |= bar 103 | foo &= bar - | ^^^^^^^^^^ B909 + | ^^^^^^^^^^ 104 | foo -= bar 105 | foo ^= bar | -B909.py:104:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:104:5 | 102 | foo |= bar 103 | foo &= bar 104 | foo -= bar - | ^^^^^^^^^^ B909 + | ^^^^^^^^^^ 105 | foo ^= bar | -B909.py:105:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:105:5 | 103 | foo &= bar 104 | foo -= bar 105 | foo ^= bar - | ^^^^^^^^^^ B909 + | ^^^^^^^^^^ | -B909.py:125:5: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:125:5 | 123 | # should error (?) 124 | for _ in foo: 125 | foo.remove(1) - | ^^^^^^^^^^ B909 + | ^^^^^^^^^^ 126 | if bar: 127 | bar.remove(1) | -B909.py:136:9: B909 Mutation to loop iterable `foo` during iteration +B909 Mutation to loop iterable `foo` during iteration + --> B909.py:136:9 | 134 | pass 135 | else: 136 | foo.remove(1) - | ^^^^^^^^^^ B909 + | ^^^^^^^^^^ 137 | 138 | # should error | -B909.py:140:8: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:140:8 | 138 | # should error 139 | for elem in some_list: 140 | if some_list.pop() == 2: - | ^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^ 141 | pass | -B909.py:150:8: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:150:8 | 148 | # should error 149 | for elem in some_list: 150 | if some_list.pop() == 2: - | ^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^ 151 | pass 152 | else: | -B909.py:157:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:157:5 | 155 | # should error 156 | for elem in some_list: 157 | del some_list[elem] - | ^^^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^^^ 158 | some_list.remove(elem) 159 | some_list.discard(elem) | -B909.py:158:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:158:5 | 156 | for elem in some_list: 157 | del some_list[elem] 158 | some_list.remove(elem) - | ^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^ 159 | some_list.discard(elem) | -B909.py:159:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:159:5 | 157 | del some_list[elem] 158 | some_list.remove(elem) 159 | some_list.discard(elem) - | ^^^^^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^^^^^ 160 | 161 | # should not error | -B909.py:167:5: B909 Mutation to loop iterable `some_list` during iteration +B909 Mutation to loop iterable `some_list` during iteration + --> B909.py:167:5 | 165 | # should error 166 | for i, elem in enumerate(some_list): 167 | some_list.pop(0) - | ^^^^^^^^^^^^^ B909 + | ^^^^^^^^^^^^^ 168 | 169 | # should not error (list) | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B911_B911.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B911_B911.py.snap index 1ce2005be7..4a295abd8a 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B911_B911.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B911_B911.py.snap @@ -1,168 +1,184 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B911.py:5:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:5:1 | 4 | # Errors 5 | batched(range(3), 1) - | ^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^ 6 | batched("abc", 2) 7 | batched([i for i in range(42)], some_n) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:6:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:6:1 | 4 | # Errors 5 | batched(range(3), 1) 6 | batched("abc", 2) - | ^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^ 7 | batched([i for i in range(42)], some_n) 8 | batched((foo for foo in cycle())) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:7:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:7:1 | 5 | batched(range(3), 1) 6 | batched("abc", 2) 7 | batched([i for i in range(42)], some_n) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | batched((foo for foo in cycle())) 9 | batched(itertools.batched([1, 2, 3], strict=True)) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:8:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:8:1 | 6 | batched("abc", 2) 7 | batched([i for i in range(42)], some_n) 8 | batched((foo for foo in cycle())) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | batched(itertools.batched([1, 2, 3], strict=True)) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:9:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:9:1 | 7 | batched([i for i in range(42)], some_n) 8 | batched((foo for foo in cycle())) 9 | batched(itertools.batched([1, 2, 3], strict=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # Errors (limited iterators). | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:12:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:12:1 | 11 | # Errors (limited iterators). 12 | batched(repeat(1, 1)) - | ^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^ 13 | batched(repeat(1, times=4)) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:13:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:13:1 | 11 | # Errors (limited iterators). 12 | batched(repeat(1, 1)) 13 | batched(repeat(1, times=4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # No fix | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:16:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:16:1 | 15 | # No fix 16 | batched([], **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | # No errors | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:35:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:35:1 | 34 | # Errors 35 | itertools.batched(range(3), 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | itertools.batched("abc", 2) 37 | itertools.batched([i for i in range(42)], some_n) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:36:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:36:1 | 34 | # Errors 35 | itertools.batched(range(3), 1) 36 | itertools.batched("abc", 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | itertools.batched([i for i in range(42)], some_n) 38 | itertools.batched((foo for foo in cycle())) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:37:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:37:1 | 35 | itertools.batched(range(3), 1) 36 | itertools.batched("abc", 2) 37 | itertools.batched([i for i in range(42)], some_n) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | itertools.batched((foo for foo in cycle())) 39 | itertools.batched(itertools.batched([1, 2, 3], strict=True)) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:38:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:38:1 | 36 | itertools.batched("abc", 2) 37 | itertools.batched([i for i in range(42)], some_n) 38 | itertools.batched((foo for foo in cycle())) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | itertools.batched(itertools.batched([1, 2, 3], strict=True)) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:39:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:39:1 | 37 | itertools.batched([i for i in range(42)], some_n) 38 | itertools.batched((foo for foo in cycle())) 39 | itertools.batched(itertools.batched([1, 2, 3], strict=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | 41 | # Errors (limited iterators). | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:42:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:42:1 | 41 | # Errors (limited iterators). 42 | itertools.batched(repeat(1, 1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | itertools.batched(repeat(1, times=4)) | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:43:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:43:1 | 41 | # Errors (limited iterators). 42 | itertools.batched(repeat(1, 1)) 43 | itertools.batched(repeat(1, times=4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | # No fix | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter -B911.py:46:1: B911 `itertools.batched()` without an explicit `strict` parameter +B911 `itertools.batched()` without an explicit `strict` parameter + --> B911.py:46:1 | 45 | # No fix 46 | itertools.batched([], **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | 48 | # No errors | - = help: Add an explicit `strict` parameter +help: Add an explicit `strict` parameter diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap index eaa057448f..9de5085c02 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B006_extended.py:17:55: B006 [*] Do not use mutable data structures for argument defaults +B006 [*] Do not use mutable data structures for argument defaults + --> B006_extended.py:17:55 | 17 | def error_due_to_missing_import(foo: ImmutableTypeA = []): - | ^^ B006 + | ^^ 18 | ... | - = help: Replace with `None`; initialize within function +help: Replace with `None`; initialize within function ℹ Unsafe fix 14 14 | ... diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap index 611467e0f2..5d5317e0a7 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap @@ -1,23 +1,26 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B008_extended.py:24:51: B008 Do not perform function call `Depends` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `Depends` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B008_extended.py:24:51 | 24 | def error_due_to_missing_import(data: List[str] = Depends(None)): - | ^^^^^^^^^^^^^ B008 + | ^^^^^^^^^^^^^ 25 | ... | -B008_extended.py:36:15: B008 Do not perform function call `OtherClass` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `OtherClass` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B008_extended.py:36:15 | 36 | def error(obj=OtherClass()): - | ^^^^^^^^^^^^ B008 + | ^^^^^^^^^^^^ 37 | ... | -B008_extended.py:48:17: B008 Do not perform function call `L` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable +B008 Do not perform function call `L` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable + --> B008_extended.py:48:17 | 47 | def okay(obj = N()): ... 48 | def error(obj = L()): ... - | ^^^ B008 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_mutable_contextvar_default.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_mutable_contextvar_default.snap index f2dc889ba3..9988069bd2 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_mutable_contextvar_default.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_mutable_contextvar_default.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs -snapshot_kind: text --- -B039_extended.py:7:26: B039 Do not use mutable data structures for `ContextVar` defaults +B039 Do not use mutable data structures for `ContextVar` defaults + --> B039_extended.py:7:26 | 6 | from something_else import Depends 7 | ContextVar("cv", default=Depends()) - | ^^^^^^^^^ B039 + | ^^^^^^^^^ | - = help: Replace with `None`; initialize with `.set()`` +help: Replace with `None`; initialize with `.set()`` diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B017_B017_0.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B017_B017_0.py.snap index 8ba0ecc1b7..4c8bb4e6d6 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B017_B017_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B017_B017_0.py.snap @@ -1,71 +1,79 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B017_0.py:23:14: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:23:14 | 21 | class Foobar(unittest.TestCase): 22 | def evil_raises(self) -> None: 23 | with self.assertRaises(Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | raise Exception("Evil I say!") | -B017_0.py:27:14: B017 Do not assert blind exception: `BaseException` +B017 Do not assert blind exception: `BaseException` + --> B017_0.py:27:14 | 26 | def also_evil_raises(self) -> None: 27 | with self.assertRaises(BaseException): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | raise Exception("Evil I say!") | -B017_0.py:45:10: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:45:10 | 44 | def test_pytest_raises(): 45 | with pytest.raises(Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 46 | raise ValueError("Hello") | -B017_0.py:48:10: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:48:10 | 46 | raise ValueError("Hello") 47 | 48 | with pytest.raises(Exception), pytest.raises(ValueError): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 49 | raise ValueError("Hello") | -B017_0.py:57:36: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:57:36 | 55 | raise ValueError("This is also fine") 56 | 57 | with contextlib.nullcontext(), pytest.raises(Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 58 | raise ValueError("Multiple context managers") | -B017_0.py:62:10: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:62:10 | 61 | def test_pytest_raises_keyword(): 62 | with pytest.raises(expected_exception=Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | raise ValueError("Should be flagged") | -B017_0.py:68:18: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_0.py:68:18 | 66 | class TestKwargs(unittest.TestCase): 67 | def test_method(self): 68 | with self.assertRaises(exception=Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 69 | raise ValueError("Should be flagged") | -B017_0.py:71:18: B017 Do not assert blind exception: `BaseException` +B017 Do not assert blind exception: `BaseException` + --> B017_0.py:71:18 | 69 | raise ValueError("Should be flagged") 70 | 71 | with self.assertRaises(exception=BaseException): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | raise ValueError("Should be flagged") | diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B017_B017_1.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B017_B017_1.py.snap index ee9aadeedd..5b0767019c 100644 --- a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B017_B017_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__preview__B017_B017_1.py.snap @@ -1,37 +1,41 @@ --- source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs --- -B017_1.py:20:9: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_1.py:20:9 | 18 | class Foobar(unittest.TestCase): 19 | def call_form_raises(self) -> None: 20 | self.assertRaises(Exception, something_else) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | self.assertRaises(BaseException, something_else) | -B017_1.py:21:9: B017 Do not assert blind exception: `BaseException` +B017 Do not assert blind exception: `BaseException` + --> B017_1.py:21:9 | 19 | def call_form_raises(self) -> None: 20 | self.assertRaises(Exception, something_else) 21 | self.assertRaises(BaseException, something_else) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -B017_1.py:25:5: B017 Do not assert blind exception: `Exception` +B017 Do not assert blind exception: `Exception` + --> B017_1.py:25:5 | 24 | def test_pytest_call_form() -> None: 25 | pytest.raises(Exception, something_else) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | pytest.raises(BaseException, something_else) | -B017_1.py:26:5: B017 Do not assert blind exception: `BaseException` +B017 Do not assert blind exception: `BaseException` + --> B017_1.py:26:5 | 24 | def test_pytest_call_form() -> None: 25 | pytest.raises(Exception, something_else) 26 | pytest.raises(BaseException, something_else) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | pytest.raises(Exception, something_else, match="hello") | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap index 9baa2d0270..e220c41130 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap @@ -1,159 +1,176 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -A001.py:5:1: A001 Variable `print` is shadowing a Python builtin +A001 Variable `print` is shadowing a Python builtin + --> A001.py:5:1 | 3 | from directory import new as dir 4 | 5 | print = 1 - | ^^^^^ A001 + | ^^^^^ 6 | copyright: 'annotation' = 2 7 | (complex := 3) | -A001.py:6:1: A001 Variable `copyright` is shadowing a Python builtin +A001 Variable `copyright` is shadowing a Python builtin + --> A001.py:6:1 | 5 | print = 1 6 | copyright: 'annotation' = 2 - | ^^^^^^^^^ A001 + | ^^^^^^^^^ 7 | (complex := 3) 8 | float = object = 4 | -A001.py:7:2: A001 Variable `complex` is shadowing a Python builtin +A001 Variable `complex` is shadowing a Python builtin + --> A001.py:7:2 | 5 | print = 1 6 | copyright: 'annotation' = 2 7 | (complex := 3) - | ^^^^^^^ A001 + | ^^^^^^^ 8 | float = object = 4 9 | min, max = 5, 6 | -A001.py:8:1: A001 Variable `float` is shadowing a Python builtin +A001 Variable `float` is shadowing a Python builtin + --> A001.py:8:1 | 6 | copyright: 'annotation' = 2 7 | (complex := 3) 8 | float = object = 4 - | ^^^^^ A001 + | ^^^^^ 9 | min, max = 5, 6 | -A001.py:8:9: A001 Variable `object` is shadowing a Python builtin +A001 Variable `object` is shadowing a Python builtin + --> A001.py:8:9 | 6 | copyright: 'annotation' = 2 7 | (complex := 3) 8 | float = object = 4 - | ^^^^^^ A001 + | ^^^^^^ 9 | min, max = 5, 6 | -A001.py:9:1: A001 Variable `min` is shadowing a Python builtin +A001 Variable `min` is shadowing a Python builtin + --> A001.py:9:1 | 7 | (complex := 3) 8 | float = object = 4 9 | min, max = 5, 6 - | ^^^ A001 + | ^^^ 10 | 11 | id = 4 | -A001.py:9:6: A001 Variable `max` is shadowing a Python builtin +A001 Variable `max` is shadowing a Python builtin + --> A001.py:9:6 | 7 | (complex := 3) 8 | float = object = 4 9 | min, max = 5, 6 - | ^^^ A001 + | ^^^ 10 | 11 | id = 4 | -A001.py:11:1: A001 Variable `id` is shadowing a Python builtin +A001 Variable `id` is shadowing a Python builtin + --> A001.py:11:1 | 9 | min, max = 5, 6 10 | 11 | id = 4 - | ^^ A001 + | ^^ 12 | 13 | def bytes(): | -A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin +A001 Variable `bytes` is shadowing a Python builtin + --> A001.py:13:5 | 11 | id = 4 12 | 13 | def bytes(): - | ^^^^^ A001 + | ^^^^^ 14 | pass | -A001.py:16:7: A001 Variable `slice` is shadowing a Python builtin +A001 Variable `slice` is shadowing a Python builtin + --> A001.py:16:7 | 14 | pass 15 | 16 | class slice: - | ^^^^^ A001 + | ^^^^^ 17 | pass | -A001.py:21:23: A001 Variable `ValueError` is shadowing a Python builtin +A001 Variable `ValueError` is shadowing a Python builtin + --> A001.py:21:23 | 19 | try: 20 | ... 21 | except ImportError as ValueError: - | ^^^^^^^^^^ A001 + | ^^^^^^^^^^ 22 | ... | -A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin +A001 Variable `memoryview` is shadowing a Python builtin + --> A001.py:24:5 | 22 | ... 23 | 24 | for memoryview, *bytearray in []: - | ^^^^^^^^^^ A001 + | ^^^^^^^^^^ 25 | pass | -A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin +A001 Variable `bytearray` is shadowing a Python builtin + --> A001.py:24:18 | 22 | ... 23 | 24 | for memoryview, *bytearray in []: - | ^^^^^^^^^ A001 + | ^^^^^^^^^ 25 | pass | -A001.py:27:22: A001 Variable `str` is shadowing a Python builtin +A001 Variable `str` is shadowing a Python builtin + --> A001.py:27:22 | 25 | pass 26 | 27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 + | ^^^ 28 | pass | -A001.py:27:45: A001 Variable `all` is shadowing a Python builtin +A001 Variable `all` is shadowing a Python builtin + --> A001.py:27:45 | 25 | pass 26 | 27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 + | ^^^ 28 | pass | -A001.py:27:50: A001 Variable `any` is shadowing a Python builtin +A001 Variable `any` is shadowing a Python builtin + --> A001.py:27:50 | 25 | pass 26 | 27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 + | ^^^ 28 | pass | -A001.py:30:8: A001 Variable `sum` is shadowing a Python builtin +A001 Variable `sum` is shadowing a Python builtin + --> A001.py:30:8 | 28 | pass 29 | 30 | [0 for sum in ()] - | ^^^ A001 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap index 10d6961236..c14d834004 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap @@ -1,149 +1,165 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -A001.py:5:1: A001 Variable `print` is shadowing a Python builtin +A001 Variable `print` is shadowing a Python builtin + --> A001.py:5:1 | 3 | from directory import new as dir 4 | 5 | print = 1 - | ^^^^^ A001 + | ^^^^^ 6 | copyright: 'annotation' = 2 7 | (complex := 3) | -A001.py:6:1: A001 Variable `copyright` is shadowing a Python builtin +A001 Variable `copyright` is shadowing a Python builtin + --> A001.py:6:1 | 5 | print = 1 6 | copyright: 'annotation' = 2 - | ^^^^^^^^^ A001 + | ^^^^^^^^^ 7 | (complex := 3) 8 | float = object = 4 | -A001.py:7:2: A001 Variable `complex` is shadowing a Python builtin +A001 Variable `complex` is shadowing a Python builtin + --> A001.py:7:2 | 5 | print = 1 6 | copyright: 'annotation' = 2 7 | (complex := 3) - | ^^^^^^^ A001 + | ^^^^^^^ 8 | float = object = 4 9 | min, max = 5, 6 | -A001.py:8:1: A001 Variable `float` is shadowing a Python builtin +A001 Variable `float` is shadowing a Python builtin + --> A001.py:8:1 | 6 | copyright: 'annotation' = 2 7 | (complex := 3) 8 | float = object = 4 - | ^^^^^ A001 + | ^^^^^ 9 | min, max = 5, 6 | -A001.py:8:9: A001 Variable `object` is shadowing a Python builtin +A001 Variable `object` is shadowing a Python builtin + --> A001.py:8:9 | 6 | copyright: 'annotation' = 2 7 | (complex := 3) 8 | float = object = 4 - | ^^^^^^ A001 + | ^^^^^^ 9 | min, max = 5, 6 | -A001.py:9:1: A001 Variable `min` is shadowing a Python builtin +A001 Variable `min` is shadowing a Python builtin + --> A001.py:9:1 | 7 | (complex := 3) 8 | float = object = 4 9 | min, max = 5, 6 - | ^^^ A001 + | ^^^ 10 | 11 | id = 4 | -A001.py:9:6: A001 Variable `max` is shadowing a Python builtin +A001 Variable `max` is shadowing a Python builtin + --> A001.py:9:6 | 7 | (complex := 3) 8 | float = object = 4 9 | min, max = 5, 6 - | ^^^ A001 + | ^^^ 10 | 11 | id = 4 | -A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin +A001 Variable `bytes` is shadowing a Python builtin + --> A001.py:13:5 | 11 | id = 4 12 | 13 | def bytes(): - | ^^^^^ A001 + | ^^^^^ 14 | pass | -A001.py:16:7: A001 Variable `slice` is shadowing a Python builtin +A001 Variable `slice` is shadowing a Python builtin + --> A001.py:16:7 | 14 | pass 15 | 16 | class slice: - | ^^^^^ A001 + | ^^^^^ 17 | pass | -A001.py:21:23: A001 Variable `ValueError` is shadowing a Python builtin +A001 Variable `ValueError` is shadowing a Python builtin + --> A001.py:21:23 | 19 | try: 20 | ... 21 | except ImportError as ValueError: - | ^^^^^^^^^^ A001 + | ^^^^^^^^^^ 22 | ... | -A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin +A001 Variable `memoryview` is shadowing a Python builtin + --> A001.py:24:5 | 22 | ... 23 | 24 | for memoryview, *bytearray in []: - | ^^^^^^^^^^ A001 + | ^^^^^^^^^^ 25 | pass | -A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin +A001 Variable `bytearray` is shadowing a Python builtin + --> A001.py:24:18 | 22 | ... 23 | 24 | for memoryview, *bytearray in []: - | ^^^^^^^^^ A001 + | ^^^^^^^^^ 25 | pass | -A001.py:27:22: A001 Variable `str` is shadowing a Python builtin +A001 Variable `str` is shadowing a Python builtin + --> A001.py:27:22 | 25 | pass 26 | 27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 + | ^^^ 28 | pass | -A001.py:27:45: A001 Variable `all` is shadowing a Python builtin +A001 Variable `all` is shadowing a Python builtin + --> A001.py:27:45 | 25 | pass 26 | 27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 + | ^^^ 28 | pass | -A001.py:27:50: A001 Variable `any` is shadowing a Python builtin +A001 Variable `any` is shadowing a Python builtin + --> A001.py:27:50 | 25 | pass 26 | 27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 + | ^^^ 28 | pass | -A001.py:30:8: A001 Variable `sum` is shadowing a Python builtin +A001 Variable `sum` is shadowing a Python builtin + --> A001.py:30:8 | 28 | pass 29 | 30 | [0 for sum in ()] - | ^^^ A001 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py.snap index d427062979..9641c7a2f0 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py.snap @@ -1,59 +1,66 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- -A002.py:1:11: A002 Function argument `str` is shadowing a Python builtin +A002 Function argument `str` is shadowing a Python builtin + --> A002.py:1:11 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^ A002 + | ^^^ 2 | pass | -A002.py:1:19: A002 Function argument `type` is shadowing a Python builtin +A002 Function argument `type` is shadowing a Python builtin + --> A002.py:1:19 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^ A002 + | ^^^^ 2 | pass | -A002.py:1:26: A002 Function argument `complex` is shadowing a Python builtin +A002 Function argument `complex` is shadowing a Python builtin + --> A002.py:1:26 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^ A002 + | ^^^^^^^ 2 | pass | -A002.py:1:35: A002 Function argument `Exception` is shadowing a Python builtin +A002 Function argument `Exception` is shadowing a Python builtin + --> A002.py:1:35 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^^^ A002 + | ^^^^^^^^^ 2 | pass | -A002.py:1:48: A002 Function argument `getattr` is shadowing a Python builtin +A002 Function argument `getattr` is shadowing a Python builtin + --> A002.py:1:48 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^ A002 + | ^^^^^^^ 2 | pass | -A002.py:5:17: A002 Function argument `bytes` is shadowing a Python builtin +A002 Function argument `bytes` is shadowing a Python builtin + --> A002.py:5:17 | 5 | async def func2(bytes): - | ^^^^^ A002 + | ^^^^^ 6 | pass | -A002.py:9:17: A002 Function argument `id` is shadowing a Python builtin +A002 Function argument `id` is shadowing a Python builtin + --> A002.py:9:17 | 9 | async def func3(id, dir): - | ^^ A002 + | ^^ 10 | pass | -A002.py:9:21: A002 Function argument `dir` is shadowing a Python builtin +A002 Function argument `dir` is shadowing a Python builtin + --> A002.py:9:21 | 9 | async def func3(id, dir): - | ^^^ A002 + | ^^^ 10 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap index 3ed8f71870..f3d4236060 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap @@ -1,45 +1,50 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- -A002.py:1:11: A002 Function argument `str` is shadowing a Python builtin +A002 Function argument `str` is shadowing a Python builtin + --> A002.py:1:11 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^ A002 + | ^^^ 2 | pass | -A002.py:1:19: A002 Function argument `type` is shadowing a Python builtin +A002 Function argument `type` is shadowing a Python builtin + --> A002.py:1:19 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^ A002 + | ^^^^ 2 | pass | -A002.py:1:26: A002 Function argument `complex` is shadowing a Python builtin +A002 Function argument `complex` is shadowing a Python builtin + --> A002.py:1:26 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^ A002 + | ^^^^^^^ 2 | pass | -A002.py:1:35: A002 Function argument `Exception` is shadowing a Python builtin +A002 Function argument `Exception` is shadowing a Python builtin + --> A002.py:1:35 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^^^ A002 + | ^^^^^^^^^ 2 | pass | -A002.py:1:48: A002 Function argument `getattr` is shadowing a Python builtin +A002 Function argument `getattr` is shadowing a Python builtin + --> A002.py:1:48 | 1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^ A002 + | ^^^^^^^ 2 | pass | -A002.py:5:17: A002 Function argument `bytes` is shadowing a Python builtin +A002 Function argument `bytes` is shadowing a Python builtin + --> A002.py:5:17 | 5 | async def func2(bytes): - | ^^^^^ A002 + | ^^^^^ 6 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap index 082f3e3d5c..1444cc7d6a 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -A003.py:17:31: A003 Python builtin is shadowed by method `str` from line 14 +A003 Python builtin is shadowed by method `str` from line 14 + --> A003.py:17:31 | 15 | pass 16 | 17 | def method_usage(self) -> str: - | ^^^ A003 + | ^^^ 18 | pass | -A003.py:20:34: A003 Python builtin is shadowed by class attribute `id` from line 3 +A003 Python builtin is shadowed by class attribute `id` from line 3 + --> A003.py:20:34 | 18 | pass 19 | 20 | def attribute_usage(self) -> id: - | ^^ A003 + | ^^ 21 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap index 85f5360b44..ad43e1b0fc 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -A003.py:17:31: A003 Python builtin is shadowed by method `str` from line 14 +A003 Python builtin is shadowed by method `str` from line 14 + --> A003.py:17:31 | 15 | pass 16 | 17 | def method_usage(self) -> str: - | ^^^ A003 + | ^^^ 18 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py.snap index 6c8386ed14..9df8672c5e 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py.snap @@ -1,71 +1,79 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -A004.py:1:16: A004 Import `sum` is shadowing a Python builtin +A004 Import `sum` is shadowing a Python builtin + --> A004.py:1:16 | 1 | import some as sum - | ^^^ A004 + | ^^^ 2 | import float 3 | from some import other as int | -A004.py:2:8: A004 Import `float` is shadowing a Python builtin +A004 Import `float` is shadowing a Python builtin + --> A004.py:2:8 | 1 | import some as sum 2 | import float - | ^^^^^ A004 + | ^^^^^ 3 | from some import other as int 4 | from some import input, exec | -A004.py:3:27: A004 Import `int` is shadowing a Python builtin +A004 Import `int` is shadowing a Python builtin + --> A004.py:3:27 | 1 | import some as sum 2 | import float 3 | from some import other as int - | ^^^ A004 + | ^^^ 4 | from some import input, exec 5 | from directory import new as dir | -A004.py:4:18: A004 Import `input` is shadowing a Python builtin +A004 Import `input` is shadowing a Python builtin + --> A004.py:4:18 | 2 | import float 3 | from some import other as int 4 | from some import input, exec - | ^^^^^ A004 + | ^^^^^ 5 | from directory import new as dir | -A004.py:4:25: A004 Import `exec` is shadowing a Python builtin +A004 Import `exec` is shadowing a Python builtin + --> A004.py:4:25 | 2 | import float 3 | from some import other as int 4 | from some import input, exec - | ^^^^ A004 + | ^^^^ 5 | from directory import new as dir | -A004.py:5:30: A004 Import `dir` is shadowing a Python builtin +A004 Import `dir` is shadowing a Python builtin + --> A004.py:5:30 | 3 | from some import other as int 4 | from some import input, exec 5 | from directory import new as dir - | ^^^ A004 + | ^^^ 6 | 7 | # See: https://github.com/astral-sh/ruff/issues/13037 | -A004.py:11:32: A004 Import `BaseExceptionGroup` is shadowing a Python builtin +A004 Import `BaseExceptionGroup` is shadowing a Python builtin + --> A004.py:11:32 | 10 | if sys.version_info < (3, 11): 11 | from exceptiongroup import BaseExceptionGroup, ExceptionGroup - | ^^^^^^^^^^^^^^^^^^ A004 + | ^^^^^^^^^^^^^^^^^^ | -A004.py:11:52: A004 Import `ExceptionGroup` is shadowing a Python builtin +A004 Import `ExceptionGroup` is shadowing a Python builtin + --> A004.py:11:52 | 10 | if sys.version_info < (3, 11): 11 | from exceptiongroup import BaseExceptionGroup, ExceptionGroup - | ^^^^^^^^^^^^^^ A004 + | ^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_builtins_ignorelist.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_builtins_ignorelist.snap index 94ff184b18..b5381b7f41 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_builtins_ignorelist.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_builtins_ignorelist.snap @@ -1,62 +1,68 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- -A004.py:1:16: A004 Import `sum` is shadowing a Python builtin +A004 Import `sum` is shadowing a Python builtin + --> A004.py:1:16 | 1 | import some as sum - | ^^^ A004 + | ^^^ 2 | import float 3 | from some import other as int | -A004.py:2:8: A004 Import `float` is shadowing a Python builtin +A004 Import `float` is shadowing a Python builtin + --> A004.py:2:8 | 1 | import some as sum 2 | import float - | ^^^^^ A004 + | ^^^^^ 3 | from some import other as int 4 | from some import input, exec | -A004.py:3:27: A004 Import `int` is shadowing a Python builtin +A004 Import `int` is shadowing a Python builtin + --> A004.py:3:27 | 1 | import some as sum 2 | import float 3 | from some import other as int - | ^^^ A004 + | ^^^ 4 | from some import input, exec 5 | from directory import new as dir | -A004.py:4:18: A004 Import `input` is shadowing a Python builtin +A004 Import `input` is shadowing a Python builtin + --> A004.py:4:18 | 2 | import float 3 | from some import other as int 4 | from some import input, exec - | ^^^^^ A004 + | ^^^^^ 5 | from directory import new as dir | -A004.py:4:25: A004 Import `exec` is shadowing a Python builtin +A004 Import `exec` is shadowing a Python builtin + --> A004.py:4:25 | 2 | import float 3 | from some import other as int 4 | from some import input, exec - | ^^^^ A004 + | ^^^^ 5 | from directory import new as dir | -A004.py:11:32: A004 Import `BaseExceptionGroup` is shadowing a Python builtin +A004 Import `BaseExceptionGroup` is shadowing a Python builtin + --> A004.py:11:32 | 10 | if sys.version_info < (3, 11): 11 | from exceptiongroup import BaseExceptionGroup, ExceptionGroup - | ^^^^^^^^^^^^^^^^^^ A004 + | ^^^^^^^^^^^^^^^^^^ | -A004.py:11:52: A004 Import `ExceptionGroup` is shadowing a Python builtin +A004 Import `ExceptionGroup` is shadowing a Python builtin + --> A004.py:11:52 | 10 | if sys.version_info < (3, 11): 11 | from exceptiongroup import BaseExceptionGroup, ExceptionGroup - | ^^^^^^^^^^^^^^ A004 + | ^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap index b8389e0889..fbc96a0b14 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A004_A004.py_py38.snap @@ -1,57 +1,63 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -A004.py:1:16: A004 Import `sum` is shadowing a Python builtin +A004 Import `sum` is shadowing a Python builtin + --> A004.py:1:16 | 1 | import some as sum - | ^^^ A004 + | ^^^ 2 | import float 3 | from some import other as int | -A004.py:2:8: A004 Import `float` is shadowing a Python builtin +A004 Import `float` is shadowing a Python builtin + --> A004.py:2:8 | 1 | import some as sum 2 | import float - | ^^^^^ A004 + | ^^^^^ 3 | from some import other as int 4 | from some import input, exec | -A004.py:3:27: A004 Import `int` is shadowing a Python builtin +A004 Import `int` is shadowing a Python builtin + --> A004.py:3:27 | 1 | import some as sum 2 | import float 3 | from some import other as int - | ^^^ A004 + | ^^^ 4 | from some import input, exec 5 | from directory import new as dir | -A004.py:4:18: A004 Import `input` is shadowing a Python builtin +A004 Import `input` is shadowing a Python builtin + --> A004.py:4:18 | 2 | import float 3 | from some import other as int 4 | from some import input, exec - | ^^^^^ A004 + | ^^^^^ 5 | from directory import new as dir | -A004.py:4:25: A004 Import `exec` is shadowing a Python builtin +A004 Import `exec` is shadowing a Python builtin + --> A004.py:4:25 | 2 | import float 3 | from some import other as int 4 | from some import input, exec - | ^^^^ A004 + | ^^^^ 5 | from directory import new as dir | -A004.py:5:30: A004 Import `dir` is shadowing a Python builtin +A004 Import `dir` is shadowing a Python builtin + --> A004.py:5:30 | 3 | from some import other as int 4 | from some import input, exec 5 | from directory import new as dir - | ^^^ A004 + | ^^^ 6 | 7 | # See: https://github.com/astral-sh/ruff/issues/13037 | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__logging____init__.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__logging____init__.py.snap index 1e4858a65e..6d20503cf1 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__logging____init__.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__logging____init__.py.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -__init__.py:1:1: A005 Module `logging` shadows a Python standard-library module +A005 Module `logging` shadows a Python standard-library module +--> __init__.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__bisect.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__bisect.py.snap index 573d2f7e85..6a6b9d5a14 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__bisect.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__bisect.py.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -bisect.py:1:1: A005 Module `bisect` shadows a Python standard-library module +A005 Module `bisect` shadows a Python standard-library module +--> bisect.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__bisect.py_builtins_allowed_modules.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__bisect.py_builtins_allowed_modules.snap index 573d2f7e85..6a6b9d5a14 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__bisect.py_builtins_allowed_modules.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__bisect.py_builtins_allowed_modules.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -bisect.py:1:1: A005 Module `bisect` shadows a Python standard-library module +A005 Module `bisect` shadows a Python standard-library module +--> bisect.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__xml.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__xml.py.snap index 9e70b02ef5..94b177c2b5 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__xml.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__package__xml.py.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -xml.py:1:1: A005 Module `xml` shadows a Python standard-library module +A005 Module `xml` shadows a Python standard-library module +--> xml.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__string____init__.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__string____init__.py.snap index 1bfc390c9e..3d7077ce07 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__string____init__.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__string____init__.py.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -__init__.py:1:1: A005 Module `string` shadows a Python standard-library module +A005 Module `string` shadows a Python standard-library module +--> __init__.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__string____init__.py_builtins_allowed_modules.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__string____init__.py_builtins_allowed_modules.snap index 1bfc390c9e..3d7077ce07 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__string____init__.py_builtins_allowed_modules.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__string____init__.py_builtins_allowed_modules.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -__init__.py:1:1: A005 Module `string` shadows a Python standard-library module +A005 Module `string` shadows a Python standard-library module +--> __init__.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_root.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_root.snap index 2154e51466..d137ab684e 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_root.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_root.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -logging.py:1:1: A005 Module `logging` shadows a Python standard-library module +A005 Module `logging` shadows a Python standard-library module +--> logging.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_src.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_src.snap index 2154e51466..d137ab684e 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_src.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_src.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -logging.py:1:1: A005 Module `logging` shadows a Python standard-library module +A005 Module `logging` shadows a Python standard-library module +--> logging.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_true.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_true.snap index 2154e51466..d137ab684e 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_true.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A005_A005__modules__utils__logging.py_true.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -logging.py:1:1: A005 Module `logging` shadows a Python standard-library module +A005 Module `logging` shadows a Python standard-library module +--> logging.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py.snap index 9c968e14f7..148ad6ed2a 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py.snap @@ -1,66 +1,73 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs --- -A006.py:1:8: A006 Lambda argument `print` is shadowing a Python builtin +A006 Lambda argument `print` is shadowing a Python builtin + --> A006.py:1:8 | 1 | lambda print, copyright: print - | ^^^^^ A006 + | ^^^^^ 2 | lambda x, float, y: x + y 3 | lambda min, max: min | -A006.py:1:15: A006 Lambda argument `copyright` is shadowing a Python builtin +A006 Lambda argument `copyright` is shadowing a Python builtin + --> A006.py:1:15 | 1 | lambda print, copyright: print - | ^^^^^^^^^ A006 + | ^^^^^^^^^ 2 | lambda x, float, y: x + y 3 | lambda min, max: min | -A006.py:2:11: A006 Lambda argument `float` is shadowing a Python builtin +A006 Lambda argument `float` is shadowing a Python builtin + --> A006.py:2:11 | 1 | lambda print, copyright: print 2 | lambda x, float, y: x + y - | ^^^^^ A006 + | ^^^^^ 3 | lambda min, max: min 4 | lambda id: id | -A006.py:3:8: A006 Lambda argument `min` is shadowing a Python builtin +A006 Lambda argument `min` is shadowing a Python builtin + --> A006.py:3:8 | 1 | lambda print, copyright: print 2 | lambda x, float, y: x + y 3 | lambda min, max: min - | ^^^ A006 + | ^^^ 4 | lambda id: id 5 | lambda dir: dir | -A006.py:3:13: A006 Lambda argument `max` is shadowing a Python builtin +A006 Lambda argument `max` is shadowing a Python builtin + --> A006.py:3:13 | 1 | lambda print, copyright: print 2 | lambda x, float, y: x + y 3 | lambda min, max: min - | ^^^ A006 + | ^^^ 4 | lambda id: id 5 | lambda dir: dir | -A006.py:4:8: A006 Lambda argument `id` is shadowing a Python builtin +A006 Lambda argument `id` is shadowing a Python builtin + --> A006.py:4:8 | 2 | lambda x, float, y: x + y 3 | lambda min, max: min 4 | lambda id: id - | ^^ A006 + | ^^ 5 | lambda dir: dir | -A006.py:5:8: A006 Lambda argument `dir` is shadowing a Python builtin +A006 Lambda argument `dir` is shadowing a Python builtin + --> A006.py:5:8 | 3 | lambda min, max: min 4 | lambda id: id 5 | lambda dir: dir - | ^^^ A006 + | ^^^ 6 | 7 | # Ok for A006 - should trigger A002 instead | diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py_builtins_ignorelist.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py_builtins_ignorelist.snap index 3b7a28a634..0cc105472e 100644 --- a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py_builtins_ignorelist.snap +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A006_A006.py_builtins_ignorelist.snap @@ -1,48 +1,52 @@ --- source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs -snapshot_kind: text --- -A006.py:1:8: A006 Lambda argument `print` is shadowing a Python builtin +A006 Lambda argument `print` is shadowing a Python builtin + --> A006.py:1:8 | 1 | lambda print, copyright: print - | ^^^^^ A006 + | ^^^^^ 2 | lambda x, float, y: x + y 3 | lambda min, max: min | -A006.py:1:15: A006 Lambda argument `copyright` is shadowing a Python builtin +A006 Lambda argument `copyright` is shadowing a Python builtin + --> A006.py:1:15 | 1 | lambda print, copyright: print - | ^^^^^^^^^ A006 + | ^^^^^^^^^ 2 | lambda x, float, y: x + y 3 | lambda min, max: min | -A006.py:2:11: A006 Lambda argument `float` is shadowing a Python builtin +A006 Lambda argument `float` is shadowing a Python builtin + --> A006.py:2:11 | 1 | lambda print, copyright: print 2 | lambda x, float, y: x + y - | ^^^^^ A006 + | ^^^^^ 3 | lambda min, max: min 4 | lambda id: id | -A006.py:3:8: A006 Lambda argument `min` is shadowing a Python builtin +A006 Lambda argument `min` is shadowing a Python builtin + --> A006.py:3:8 | 1 | lambda print, copyright: print 2 | lambda x, float, y: x + y 3 | lambda min, max: min - | ^^^ A006 + | ^^^ 4 | lambda id: id 5 | lambda dir: dir | -A006.py:3:13: A006 Lambda argument `max` is shadowing a Python builtin +A006 Lambda argument `max` is shadowing a Python builtin + --> A006.py:3:13 | 1 | lambda print, copyright: print 2 | lambda x, float, y: x + y 3 | lambda min, max: min - | ^^^ A006 + | ^^^ 4 | lambda id: id 5 | lambda dir: dir | diff --git a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap index 56628a26d8..f34fdab573 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap +++ b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_commas/mod.rs --- -COM81.py:4:18: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:4:18 | 2 | bad_function_call( 3 | param1='test', 4 | param2='test' - | ^ COM812 + | ^ 5 | ) 6 | # ==> bad_list.py <== | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 1 1 | # ==> bad_function_call.py <== @@ -22,15 +23,16 @@ COM81.py:4:18: COM812 [*] Trailing comma missing 6 6 | # ==> bad_list.py <== 7 7 | bad_list = [ -COM81.py:10:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:10:6 | 8 | 1, 9 | 2, 10 | 3 - | ^ COM812 + | ^ 11 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 7 7 | bad_list = [ @@ -42,16 +44,17 @@ COM81.py:10:6: COM812 [*] Trailing comma missing 12 12 | 13 13 | bad_list_with_comment = [ -COM81.py:16:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:16:6 | 14 | 1, 15 | 2, 16 | 3 - | ^ COM812 + | ^ 17 | # still needs a comma! 18 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 13 13 | bad_list_with_comment = [ @@ -63,14 +66,15 @@ COM81.py:16:6: COM812 [*] Trailing comma missing 18 18 | ] 19 19 | -COM81.py:23:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:23:6 | 21 | 1, 22 | 2, 23 | 3 - | ^ COM812 + | ^ | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 20 20 | bad_list_with_extra_empty = [ @@ -82,82 +86,90 @@ COM81.py:23:6: COM812 [*] Trailing comma missing 25 25 | 26 26 | -COM81.py:36:8: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:36:8 | 34 | foo = (1,) 35 | 36 | foo = 1, - | ^ COM818 + | ^ 37 | 38 | bar = 1; foo = bar, | -COM81.py:38:19: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:38:19 | 36 | foo = 1, 37 | 38 | bar = 1; foo = bar, - | ^ COM818 + | ^ 39 | 40 | foo = ( | -COM81.py:45:8: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:45:8 | 43 | ) 44 | 45 | foo = 3, - | ^ COM818 + | ^ 46 | 47 | class A(object): | -COM81.py:49:10: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:49:10 | 47 | class A(object): 48 | foo = 3 49 | bar = 10, - | ^ COM818 + | ^ 50 | foo_bar = 2 | -COM81.py:56:32: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:56:32 | 54 | from foo import bar, baz 55 | 56 | group_by = function_call('arg'), - | ^ COM818 + | ^ 57 | 58 | group_by = ('foobar' * 3), | -COM81.py:58:26: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:58:26 | 56 | group_by = function_call('arg'), 57 | 58 | group_by = ('foobar' * 3), - | ^ COM818 + | ^ 59 | 60 | def foo(): | -COM81.py:61:17: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:61:17 | 60 | def foo(): 61 | return False, - | ^ COM818 + | ^ 62 | 63 | # ==> callable_before_parenth_form.py <== | -COM81.py:70:8: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:70:8 | 69 | {'foo': foo}['foo']( 70 | bar - | ^ COM812 + | ^ 71 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 67 67 | pass @@ -169,14 +181,15 @@ COM81.py:70:8: COM812 [*] Trailing comma missing 72 72 | 73 73 | {'foo': foo}['foo']( -COM81.py:78:8: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:78:8 | 77 | (foo)( 78 | bar - | ^ COM812 + | ^ 79 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 75 75 | ) @@ -188,14 +201,15 @@ COM81.py:78:8: COM812 [*] Trailing comma missing 80 80 | 81 81 | (foo)[0]( -COM81.py:86:8: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:86:8 | 85 | [foo][0]( 86 | bar - | ^ COM812 + | ^ 87 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 83 83 | ) @@ -207,15 +221,16 @@ COM81.py:86:8: COM812 [*] Trailing comma missing 88 88 | 89 89 | [foo][0]( -COM81.py:152:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:152:6 | 150 | # ==> keyword_before_parenth_form/base_bad.py <== 151 | from x import ( 152 | y - | ^ COM812 + | ^ 153 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 149 149 | @@ -227,15 +242,16 @@ COM81.py:152:6: COM812 [*] Trailing comma missing 154 154 | 155 155 | assert( -COM81.py:158:11: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:158:11 | 156 | SyntaxWarning, 157 | ThrownHere, 158 | Anyway - | ^ COM812 + | ^ 159 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 155 155 | assert( @@ -247,16 +263,17 @@ COM81.py:158:11: COM812 [*] Trailing comma missing 160 160 | 161 161 | # async await is fine outside an async def -COM81.py:293:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:293:15 | 291 | # ==> multiline_bad_dict.py <== 292 | multiline_bad_dict = { 293 | "bad": 123 - | ^ COM812 + | ^ 294 | } 295 | # ==> multiline_bad_function_def.py <== | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 290 290 | @@ -268,16 +285,17 @@ COM81.py:293:15: COM812 [*] Trailing comma missing 295 295 | # ==> multiline_bad_function_def.py <== 296 296 | def func_good( -COM81.py:304:14: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:304:14 | 302 | def func_bad( 303 | a = 3, 304 | b = 2 - | ^ COM812 + | ^ 305 | ): 306 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 301 301 | @@ -289,16 +307,17 @@ COM81.py:304:14: COM812 [*] Trailing comma missing 306 306 | pass 307 307 | -COM81.py:310:14: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:310:14 | 308 | # ==> multiline_bad_function_one_param.py <== 309 | def func( 310 | a = 3 - | ^ COM812 + | ^ 311 | ): 312 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 307 307 | @@ -310,14 +329,15 @@ COM81.py:310:14: COM812 [*] Trailing comma missing 312 312 | pass 313 313 | -COM81.py:316:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:316:10 | 315 | func( 316 | a = 3 - | ^ COM812 + | ^ 317 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 313 313 | @@ -329,15 +349,16 @@ COM81.py:316:10: COM812 [*] Trailing comma missing 318 318 | 319 319 | # ==> multiline_bad_or_dict.py <== -COM81.py:322:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:322:15 | 320 | multiline_bad_or_dict = { 321 | "good": True or False, 322 | "bad": 123 - | ^ COM812 + | ^ 323 | } | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 319 319 | # ==> multiline_bad_or_dict.py <== @@ -349,15 +370,16 @@ COM81.py:322:15: COM812 [*] Trailing comma missing 324 324 | 325 325 | # ==> multiline_good_dict.py <== -COM81.py:368:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:368:15 | 366 | multiline_index_access[ 367 | "probably fine", 368 | "not good" - | ^ COM812 + | ^ 369 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 365 365 | @@ -369,15 +391,16 @@ COM81.py:368:15: COM812 [*] Trailing comma missing 370 370 | 371 371 | multiline_index_access[ -COM81.py:375:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:375:15 | 373 | "fine", 374 | : 375 | "not good" - | ^ COM812 + | ^ 376 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 372 372 | "fine", @@ -389,15 +412,16 @@ COM81.py:375:15: COM812 [*] Trailing comma missing 377 377 | 378 378 | # ==> multiline_string.py <== -COM81.py:404:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:404:15 | 402 | "fine" 403 | : 404 | "not fine" - | ^ COM812 + | ^ 405 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 401 401 | "fine", @@ -409,15 +433,16 @@ COM81.py:404:15: COM812 [*] Trailing comma missing 406 406 | 407 407 | multiline_index_access[ -COM81.py:432:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:432:15 | 430 | : 431 | "fine", 432 | "not fine" - | ^ COM812 + | ^ 433 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 429 429 | "fine" @@ -429,15 +454,16 @@ COM81.py:432:15: COM812 [*] Trailing comma missing 434 434 | 435 435 | multiline_index_access[ -COM81.py:485:21: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:485:21 | 484 | # ==> prohibited.py <== 485 | foo = ['a', 'b', 'c',] - | ^ COM819 + | ^ 486 | 487 | bar = { a: b,} | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 482 482 | ) @@ -449,16 +475,17 @@ COM81.py:485:21: COM819 [*] Trailing comma prohibited 487 487 | bar = { a: b,} 488 488 | -COM81.py:487:13: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:487:13 | 485 | foo = ['a', 'b', 'c',] 486 | 487 | bar = { a: b,} - | ^ COM819 + | ^ 488 | 489 | def bah(ham, spam,): | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 484 484 | # ==> prohibited.py <== @@ -470,15 +497,16 @@ COM81.py:487:13: COM819 [*] Trailing comma prohibited 489 489 | def bah(ham, spam,): 490 490 | pass -COM81.py:489:18: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:489:18 | 487 | bar = { a: b,} 488 | 489 | def bah(ham, spam,): - | ^ COM819 + | ^ 490 | pass | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 486 486 | @@ -490,16 +518,17 @@ COM81.py:489:18: COM819 [*] Trailing comma prohibited 491 491 | 492 492 | (0,) -COM81.py:494:6: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:494:6 | 492 | (0,) 493 | 494 | (0, 1,) - | ^ COM819 + | ^ 495 | 496 | foo = ['a', 'b', 'c', ] | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 491 491 | @@ -511,16 +540,17 @@ COM81.py:494:6: COM819 [*] Trailing comma prohibited 496 496 | foo = ['a', 'b', 'c', ] 497 497 | -COM81.py:496:21: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:496:21 | 494 | (0, 1,) 495 | 496 | foo = ['a', 'b', 'c', ] - | ^ COM819 + | ^ 497 | 498 | bar = { a: b, } | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 493 493 | @@ -532,16 +562,17 @@ COM81.py:496:21: COM819 [*] Trailing comma prohibited 498 498 | bar = { a: b, } 499 499 | -COM81.py:498:13: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:498:13 | 496 | foo = ['a', 'b', 'c', ] 497 | 498 | bar = { a: b, } - | ^ COM819 + | ^ 499 | 500 | def bah(ham, spam, ): | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 495 495 | @@ -553,15 +584,16 @@ COM81.py:498:13: COM819 [*] Trailing comma prohibited 500 500 | def bah(ham, spam, ): 501 501 | pass -COM81.py:500:18: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:500:18 | 498 | bar = { a: b, } 499 | 500 | def bah(ham, spam, ): - | ^ COM819 + | ^ 501 | pass | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 497 497 | @@ -573,16 +605,17 @@ COM81.py:500:18: COM819 [*] Trailing comma prohibited 502 502 | 503 503 | (0, ) -COM81.py:505:6: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:505:6 | 503 | (0, ) 504 | 505 | (0, 1, ) - | ^ COM819 + | ^ 506 | 507 | image[:, :, 0] | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 502 502 | @@ -594,16 +627,17 @@ COM81.py:505:6: COM819 [*] Trailing comma prohibited 507 507 | image[:, :, 0] 508 508 | -COM81.py:511:10: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:511:10 | 509 | image[:,] 510 | 511 | image[:,:,] - | ^ COM819 + | ^ 512 | 513 | lambda x, : x | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 508 508 | @@ -615,16 +649,17 @@ COM81.py:511:10: COM819 [*] Trailing comma prohibited 513 513 | lambda x, : x 514 514 | -COM81.py:513:9: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:513:9 | 511 | image[:,:,] 512 | 513 | lambda x, : x - | ^ COM819 + | ^ 514 | 515 | # ==> unpack.py <== | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 510 510 | @@ -636,16 +671,17 @@ COM81.py:513:9: COM819 [*] Trailing comma prohibited 515 515 | # ==> unpack.py <== 516 516 | def function( -COM81.py:519:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:519:13 | 517 | foo, 518 | bar, 519 | **kwargs - | ^ COM812 + | ^ 520 | ): 521 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 516 516 | def function( @@ -657,16 +693,17 @@ COM81.py:519:13: COM812 [*] Trailing comma missing 521 521 | pass 522 522 | -COM81.py:526:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:526:10 | 524 | foo, 525 | bar, 526 | *args - | ^ COM812 + | ^ 527 | ): 528 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 523 523 | def function( @@ -678,16 +715,17 @@ COM81.py:526:10: COM812 [*] Trailing comma missing 528 528 | pass 529 529 | -COM81.py:534:16: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:534:16 | 532 | bar, 533 | *args, 534 | extra_kwarg - | ^ COM812 + | ^ 535 | ): 536 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 531 531 | foo, @@ -699,15 +737,16 @@ COM81.py:534:16: COM812 [*] Trailing comma missing 536 536 | pass 537 537 | -COM81.py:541:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:541:13 | 539 | foo, 540 | bar, 541 | **kwargs - | ^ COM812 + | ^ 542 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 538 538 | result = function( @@ -719,15 +758,16 @@ COM81.py:541:13: COM812 [*] Trailing comma missing 543 543 | 544 544 | result = function( -COM81.py:547:24: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:547:24 | 545 | foo, 546 | bar, 547 | **not_called_kwargs - | ^ COM812 + | ^ 548 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 544 544 | result = function( @@ -739,16 +779,17 @@ COM81.py:547:24: COM812 [*] Trailing comma missing 549 549 | 550 550 | def foo( -COM81.py:554:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:554:15 | 552 | spam, 553 | *args, 554 | kwarg_only - | ^ COM812 + | ^ 555 | ): 556 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 551 551 | ham, @@ -760,14 +801,15 @@ COM81.py:554:15: COM812 [*] Trailing comma missing 556 556 | pass 557 557 | -COM81.py:561:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:561:13 | 560 | foo( 561 | **kwargs - | ^ COM812 + | ^ 562 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 558 558 | # In python 3.5 if it's not a function def, commas are mandatory. @@ -779,14 +821,15 @@ COM81.py:561:13: COM812 [*] Trailing comma missing 563 563 | 564 564 | { -COM81.py:565:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:565:13 | 564 | { 565 | **kwargs - | ^ COM812 + | ^ 566 | } | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 562 562 | ) @@ -798,14 +841,15 @@ COM81.py:565:13: COM812 [*] Trailing comma missing 567 567 | 568 568 | { -COM81.py:569:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:569:10 | 568 | { 569 | *args - | ^ COM812 + | ^ 570 | } | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 566 566 | } @@ -817,14 +861,15 @@ COM81.py:569:10: COM812 [*] Trailing comma missing 571 571 | 572 572 | [ -COM81.py:573:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:573:10 | 572 | [ 573 | *args - | ^ COM812 + | ^ 574 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 570 570 | } @@ -836,16 +881,17 @@ COM81.py:573:10: COM812 [*] Trailing comma missing 575 575 | 576 576 | def foo( -COM81.py:579:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:579:10 | 577 | ham, 578 | spam, 579 | *args - | ^ COM812 + | ^ 580 | ): 581 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 576 576 | def foo( @@ -857,16 +903,17 @@ COM81.py:579:10: COM812 [*] Trailing comma missing 581 581 | pass 582 582 | -COM81.py:586:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:586:13 | 584 | ham, 585 | spam, 586 | **kwargs - | ^ COM812 + | ^ 587 | ): 588 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 583 583 | def foo( @@ -878,16 +925,17 @@ COM81.py:586:13: COM812 [*] Trailing comma missing 588 588 | pass 589 589 | -COM81.py:594:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:594:15 | 592 | spam, 593 | *args, 594 | kwarg_only - | ^ COM812 + | ^ 595 | ): 596 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 591 591 | ham, @@ -899,15 +947,16 @@ COM81.py:594:15: COM812 [*] Trailing comma missing 596 596 | pass 597 597 | -COM81.py:623:20: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:623:20 | 621 | foo, 622 | bar, 623 | **{'ham': spam} - | ^ COM812 + | ^ 624 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 620 620 | result = function( @@ -919,15 +968,16 @@ COM81.py:623:20: COM812 [*] Trailing comma missing 625 625 | 626 626 | # Make sure the COM812 and UP034 rules don't fix simultaneously and cause a syntax error. -COM81.py:628:42: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:628:42 | 626 | # Make sure the COM812 and UP034 rules don't fix simultaneously and cause a syntax error. 627 | the_first_one = next( 628 | (i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket - | ^ COM812 + | ^ 629 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 625 625 | @@ -939,15 +989,16 @@ COM81.py:628:42: COM812 [*] Trailing comma missing 630 630 | 631 631 | foo = namedtuple( -COM81.py:640:46: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:640:46 | 639 | # F-strings 640 | kwargs.pop("remove", f"this {trailing_comma}",) - | ^ COM819 + | ^ 641 | 642 | raise Exception( | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 637 637 | ) @@ -959,14 +1010,15 @@ COM81.py:640:46: COM819 [*] Trailing comma prohibited 642 642 | raise Exception( 643 643 | "first", extra=f"Add trailing comma here ->" -COM81.py:643:49: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:643:49 | 642 | raise Exception( 643 | "first", extra=f"Add trailing comma here ->" - | ^ COM812 + | ^ 644 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 640 640 | kwargs.pop("remove", f"this {trailing_comma}",) diff --git a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap index f6be9a1954..be64c5452f 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_commas/mod.rs --- -COM81_syntax_error.py:3:5: invalid-syntax: Starred expression cannot be used here +invalid-syntax: Starred expression cannot be used here + --> COM81_syntax_error.py:3:5 | 1 | # Check for `flake8-commas` violation for a file containing syntax errors. 2 | ( @@ -10,7 +11,8 @@ COM81_syntax_error.py:3:5: invalid-syntax: Starred expression cannot be used her 4 | ) | -COM81_syntax_error.py:6:9: invalid-syntax: Type parameter list cannot be empty +invalid-syntax: Type parameter list cannot be empty + --> COM81_syntax_error.py:6:9 | 4 | ) 5 | @@ -19,12 +21,13 @@ COM81_syntax_error.py:6:9: invalid-syntax: Type parameter list cannot be empty 7 | pass | -COM81_syntax_error.py:6:38: COM819 Trailing comma prohibited +COM819 Trailing comma prohibited + --> COM81_syntax_error.py:6:38 | 4 | ) 5 | 6 | def foo[(param1='test', param2='test',): - | ^ COM819 + | ^ 7 | pass | - = help: Remove trailing comma +help: Remove trailing comma diff --git a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81.py.snap b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81.py.snap index a927d1ccf2..209e784a94 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81.py.snap +++ b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_commas/mod.rs --- -COM81.py:4:18: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:4:18 | 2 | bad_function_call( 3 | param1='test', 4 | param2='test' - | ^ COM812 + | ^ 5 | ) 6 | # ==> bad_list.py <== | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 1 1 | # ==> bad_function_call.py <== @@ -22,15 +23,16 @@ COM81.py:4:18: COM812 [*] Trailing comma missing 6 6 | # ==> bad_list.py <== 7 7 | bad_list = [ -COM81.py:10:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:10:6 | 8 | 1, 9 | 2, 10 | 3 - | ^ COM812 + | ^ 11 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 7 7 | bad_list = [ @@ -42,16 +44,17 @@ COM81.py:10:6: COM812 [*] Trailing comma missing 12 12 | 13 13 | bad_list_with_comment = [ -COM81.py:16:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:16:6 | 14 | 1, 15 | 2, 16 | 3 - | ^ COM812 + | ^ 17 | # still needs a comma! 18 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 13 13 | bad_list_with_comment = [ @@ -63,14 +66,15 @@ COM81.py:16:6: COM812 [*] Trailing comma missing 18 18 | ] 19 19 | -COM81.py:23:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:23:6 | 21 | 1, 22 | 2, 23 | 3 - | ^ COM812 + | ^ | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 20 20 | bad_list_with_extra_empty = [ @@ -82,82 +86,90 @@ COM81.py:23:6: COM812 [*] Trailing comma missing 25 25 | 26 26 | -COM81.py:36:8: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:36:8 | 34 | foo = (1,) 35 | 36 | foo = 1, - | ^ COM818 + | ^ 37 | 38 | bar = 1; foo = bar, | -COM81.py:38:19: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:38:19 | 36 | foo = 1, 37 | 38 | bar = 1; foo = bar, - | ^ COM818 + | ^ 39 | 40 | foo = ( | -COM81.py:45:8: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:45:8 | 43 | ) 44 | 45 | foo = 3, - | ^ COM818 + | ^ 46 | 47 | class A(object): | -COM81.py:49:10: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:49:10 | 47 | class A(object): 48 | foo = 3 49 | bar = 10, - | ^ COM818 + | ^ 50 | foo_bar = 2 | -COM81.py:56:32: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:56:32 | 54 | from foo import bar, baz 55 | 56 | group_by = function_call('arg'), - | ^ COM818 + | ^ 57 | 58 | group_by = ('foobar' * 3), | -COM81.py:58:26: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:58:26 | 56 | group_by = function_call('arg'), 57 | 58 | group_by = ('foobar' * 3), - | ^ COM818 + | ^ 59 | 60 | def foo(): | -COM81.py:61:17: COM818 Trailing comma on bare tuple prohibited +COM818 Trailing comma on bare tuple prohibited + --> COM81.py:61:17 | 60 | def foo(): 61 | return False, - | ^ COM818 + | ^ 62 | 63 | # ==> callable_before_parenth_form.py <== | -COM81.py:70:8: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:70:8 | 69 | {'foo': foo}['foo']( 70 | bar - | ^ COM812 + | ^ 71 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 67 67 | pass @@ -169,14 +181,15 @@ COM81.py:70:8: COM812 [*] Trailing comma missing 72 72 | 73 73 | {'foo': foo}['foo']( -COM81.py:78:8: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:78:8 | 77 | (foo)( 78 | bar - | ^ COM812 + | ^ 79 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 75 75 | ) @@ -188,14 +201,15 @@ COM81.py:78:8: COM812 [*] Trailing comma missing 80 80 | 81 81 | (foo)[0]( -COM81.py:86:8: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:86:8 | 85 | [foo][0]( 86 | bar - | ^ COM812 + | ^ 87 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 83 83 | ) @@ -207,15 +221,16 @@ COM81.py:86:8: COM812 [*] Trailing comma missing 88 88 | 89 89 | [foo][0]( -COM81.py:152:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:152:6 | 150 | # ==> keyword_before_parenth_form/base_bad.py <== 151 | from x import ( 152 | y - | ^ COM812 + | ^ 153 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 149 149 | @@ -227,15 +242,16 @@ COM81.py:152:6: COM812 [*] Trailing comma missing 154 154 | 155 155 | assert( -COM81.py:158:11: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:158:11 | 156 | SyntaxWarning, 157 | ThrownHere, 158 | Anyway - | ^ COM812 + | ^ 159 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 155 155 | assert( @@ -247,16 +263,17 @@ COM81.py:158:11: COM812 [*] Trailing comma missing 160 160 | 161 161 | # async await is fine outside an async def -COM81.py:293:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:293:15 | 291 | # ==> multiline_bad_dict.py <== 292 | multiline_bad_dict = { 293 | "bad": 123 - | ^ COM812 + | ^ 294 | } 295 | # ==> multiline_bad_function_def.py <== | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 290 290 | @@ -268,16 +285,17 @@ COM81.py:293:15: COM812 [*] Trailing comma missing 295 295 | # ==> multiline_bad_function_def.py <== 296 296 | def func_good( -COM81.py:304:14: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:304:14 | 302 | def func_bad( 303 | a = 3, 304 | b = 2 - | ^ COM812 + | ^ 305 | ): 306 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 301 301 | @@ -289,16 +307,17 @@ COM81.py:304:14: COM812 [*] Trailing comma missing 306 306 | pass 307 307 | -COM81.py:310:14: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:310:14 | 308 | # ==> multiline_bad_function_one_param.py <== 309 | def func( 310 | a = 3 - | ^ COM812 + | ^ 311 | ): 312 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 307 307 | @@ -310,14 +329,15 @@ COM81.py:310:14: COM812 [*] Trailing comma missing 312 312 | pass 313 313 | -COM81.py:316:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:316:10 | 315 | func( 316 | a = 3 - | ^ COM812 + | ^ 317 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 313 313 | @@ -329,15 +349,16 @@ COM81.py:316:10: COM812 [*] Trailing comma missing 318 318 | 319 319 | # ==> multiline_bad_or_dict.py <== -COM81.py:322:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:322:15 | 320 | multiline_bad_or_dict = { 321 | "good": True or False, 322 | "bad": 123 - | ^ COM812 + | ^ 323 | } | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 319 319 | # ==> multiline_bad_or_dict.py <== @@ -349,15 +370,16 @@ COM81.py:322:15: COM812 [*] Trailing comma missing 324 324 | 325 325 | # ==> multiline_good_dict.py <== -COM81.py:368:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:368:15 | 366 | multiline_index_access[ 367 | "probably fine", 368 | "not good" - | ^ COM812 + | ^ 369 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 365 365 | @@ -369,15 +391,16 @@ COM81.py:368:15: COM812 [*] Trailing comma missing 370 370 | 371 371 | multiline_index_access[ -COM81.py:375:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:375:15 | 373 | "fine", 374 | : 375 | "not good" - | ^ COM812 + | ^ 376 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 372 372 | "fine", @@ -389,15 +412,16 @@ COM81.py:375:15: COM812 [*] Trailing comma missing 377 377 | 378 378 | # ==> multiline_string.py <== -COM81.py:404:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:404:15 | 402 | "fine" 403 | : 404 | "not fine" - | ^ COM812 + | ^ 405 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 401 401 | "fine", @@ -409,15 +433,16 @@ COM81.py:404:15: COM812 [*] Trailing comma missing 406 406 | 407 407 | multiline_index_access[ -COM81.py:432:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:432:15 | 430 | : 431 | "fine", 432 | "not fine" - | ^ COM812 + | ^ 433 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 429 429 | "fine" @@ -429,15 +454,16 @@ COM81.py:432:15: COM812 [*] Trailing comma missing 434 434 | 435 435 | multiline_index_access[ -COM81.py:485:21: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:485:21 | 484 | # ==> prohibited.py <== 485 | foo = ['a', 'b', 'c',] - | ^ COM819 + | ^ 486 | 487 | bar = { a: b,} | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 482 482 | ) @@ -449,16 +475,17 @@ COM81.py:485:21: COM819 [*] Trailing comma prohibited 487 487 | bar = { a: b,} 488 488 | -COM81.py:487:13: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:487:13 | 485 | foo = ['a', 'b', 'c',] 486 | 487 | bar = { a: b,} - | ^ COM819 + | ^ 488 | 489 | def bah(ham, spam,): | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 484 484 | # ==> prohibited.py <== @@ -470,15 +497,16 @@ COM81.py:487:13: COM819 [*] Trailing comma prohibited 489 489 | def bah(ham, spam,): 490 490 | pass -COM81.py:489:18: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:489:18 | 487 | bar = { a: b,} 488 | 489 | def bah(ham, spam,): - | ^ COM819 + | ^ 490 | pass | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 486 486 | @@ -490,16 +518,17 @@ COM81.py:489:18: COM819 [*] Trailing comma prohibited 491 491 | 492 492 | (0,) -COM81.py:494:6: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:494:6 | 492 | (0,) 493 | 494 | (0, 1,) - | ^ COM819 + | ^ 495 | 496 | foo = ['a', 'b', 'c', ] | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 491 491 | @@ -511,16 +540,17 @@ COM81.py:494:6: COM819 [*] Trailing comma prohibited 496 496 | foo = ['a', 'b', 'c', ] 497 497 | -COM81.py:496:21: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:496:21 | 494 | (0, 1,) 495 | 496 | foo = ['a', 'b', 'c', ] - | ^ COM819 + | ^ 497 | 498 | bar = { a: b, } | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 493 493 | @@ -532,16 +562,17 @@ COM81.py:496:21: COM819 [*] Trailing comma prohibited 498 498 | bar = { a: b, } 499 499 | -COM81.py:498:13: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:498:13 | 496 | foo = ['a', 'b', 'c', ] 497 | 498 | bar = { a: b, } - | ^ COM819 + | ^ 499 | 500 | def bah(ham, spam, ): | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 495 495 | @@ -553,15 +584,16 @@ COM81.py:498:13: COM819 [*] Trailing comma prohibited 500 500 | def bah(ham, spam, ): 501 501 | pass -COM81.py:500:18: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:500:18 | 498 | bar = { a: b, } 499 | 500 | def bah(ham, spam, ): - | ^ COM819 + | ^ 501 | pass | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 497 497 | @@ -573,16 +605,17 @@ COM81.py:500:18: COM819 [*] Trailing comma prohibited 502 502 | 503 503 | (0, ) -COM81.py:505:6: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:505:6 | 503 | (0, ) 504 | 505 | (0, 1, ) - | ^ COM819 + | ^ 506 | 507 | image[:, :, 0] | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 502 502 | @@ -594,16 +627,17 @@ COM81.py:505:6: COM819 [*] Trailing comma prohibited 507 507 | image[:, :, 0] 508 508 | -COM81.py:511:10: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:511:10 | 509 | image[:,] 510 | 511 | image[:,:,] - | ^ COM819 + | ^ 512 | 513 | lambda x, : x | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 508 508 | @@ -615,16 +649,17 @@ COM81.py:511:10: COM819 [*] Trailing comma prohibited 513 513 | lambda x, : x 514 514 | -COM81.py:513:9: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:513:9 | 511 | image[:,:,] 512 | 513 | lambda x, : x - | ^ COM819 + | ^ 514 | 515 | # ==> unpack.py <== | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 510 510 | @@ -636,16 +671,17 @@ COM81.py:513:9: COM819 [*] Trailing comma prohibited 515 515 | # ==> unpack.py <== 516 516 | def function( -COM81.py:519:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:519:13 | 517 | foo, 518 | bar, 519 | **kwargs - | ^ COM812 + | ^ 520 | ): 521 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 516 516 | def function( @@ -657,16 +693,17 @@ COM81.py:519:13: COM812 [*] Trailing comma missing 521 521 | pass 522 522 | -COM81.py:526:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:526:10 | 524 | foo, 525 | bar, 526 | *args - | ^ COM812 + | ^ 527 | ): 528 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 523 523 | def function( @@ -678,16 +715,17 @@ COM81.py:526:10: COM812 [*] Trailing comma missing 528 528 | pass 529 529 | -COM81.py:534:16: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:534:16 | 532 | bar, 533 | *args, 534 | extra_kwarg - | ^ COM812 + | ^ 535 | ): 536 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 531 531 | foo, @@ -699,15 +737,16 @@ COM81.py:534:16: COM812 [*] Trailing comma missing 536 536 | pass 537 537 | -COM81.py:541:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:541:13 | 539 | foo, 540 | bar, 541 | **kwargs - | ^ COM812 + | ^ 542 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 538 538 | result = function( @@ -719,15 +758,16 @@ COM81.py:541:13: COM812 [*] Trailing comma missing 543 543 | 544 544 | result = function( -COM81.py:547:24: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:547:24 | 545 | foo, 546 | bar, 547 | **not_called_kwargs - | ^ COM812 + | ^ 548 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 544 544 | result = function( @@ -739,16 +779,17 @@ COM81.py:547:24: COM812 [*] Trailing comma missing 549 549 | 550 550 | def foo( -COM81.py:554:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:554:15 | 552 | spam, 553 | *args, 554 | kwarg_only - | ^ COM812 + | ^ 555 | ): 556 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 551 551 | ham, @@ -760,14 +801,15 @@ COM81.py:554:15: COM812 [*] Trailing comma missing 556 556 | pass 557 557 | -COM81.py:561:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:561:13 | 560 | foo( 561 | **kwargs - | ^ COM812 + | ^ 562 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 558 558 | # In python 3.5 if it's not a function def, commas are mandatory. @@ -779,14 +821,15 @@ COM81.py:561:13: COM812 [*] Trailing comma missing 563 563 | 564 564 | { -COM81.py:565:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:565:13 | 564 | { 565 | **kwargs - | ^ COM812 + | ^ 566 | } | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 562 562 | ) @@ -798,14 +841,15 @@ COM81.py:565:13: COM812 [*] Trailing comma missing 567 567 | 568 568 | { -COM81.py:569:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:569:10 | 568 | { 569 | *args - | ^ COM812 + | ^ 570 | } | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 566 566 | } @@ -817,14 +861,15 @@ COM81.py:569:10: COM812 [*] Trailing comma missing 571 571 | 572 572 | [ -COM81.py:573:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:573:10 | 572 | [ 573 | *args - | ^ COM812 + | ^ 574 | ] | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 570 570 | } @@ -836,16 +881,17 @@ COM81.py:573:10: COM812 [*] Trailing comma missing 575 575 | 576 576 | def foo( -COM81.py:579:10: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:579:10 | 577 | ham, 578 | spam, 579 | *args - | ^ COM812 + | ^ 580 | ): 581 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 576 576 | def foo( @@ -857,16 +903,17 @@ COM81.py:579:10: COM812 [*] Trailing comma missing 581 581 | pass 582 582 | -COM81.py:586:13: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:586:13 | 584 | ham, 585 | spam, 586 | **kwargs - | ^ COM812 + | ^ 587 | ): 588 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 583 583 | def foo( @@ -878,16 +925,17 @@ COM81.py:586:13: COM812 [*] Trailing comma missing 588 588 | pass 589 589 | -COM81.py:594:15: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:594:15 | 592 | spam, 593 | *args, 594 | kwarg_only - | ^ COM812 + | ^ 595 | ): 596 | pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 591 591 | ham, @@ -899,15 +947,16 @@ COM81.py:594:15: COM812 [*] Trailing comma missing 596 596 | pass 597 597 | -COM81.py:623:20: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:623:20 | 621 | foo, 622 | bar, 623 | **{'ham': spam} - | ^ COM812 + | ^ 624 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 620 620 | result = function( @@ -919,15 +968,16 @@ COM81.py:623:20: COM812 [*] Trailing comma missing 625 625 | 626 626 | # Make sure the COM812 and UP034 rules don't fix simultaneously and cause a syntax error. -COM81.py:628:42: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:628:42 | 626 | # Make sure the COM812 and UP034 rules don't fix simultaneously and cause a syntax error. 627 | the_first_one = next( 628 | (i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket - | ^ COM812 + | ^ 629 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 625 625 | @@ -939,15 +989,16 @@ COM81.py:628:42: COM812 [*] Trailing comma missing 630 630 | 631 631 | foo = namedtuple( -COM81.py:640:46: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:640:46 | 639 | # F-strings 640 | kwargs.pop("remove", f"this {trailing_comma}",) - | ^ COM819 + | ^ 641 | 642 | raise Exception( | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 637 637 | ) @@ -959,14 +1010,15 @@ COM81.py:640:46: COM819 [*] Trailing comma prohibited 642 642 | raise Exception( 643 643 | "first", extra=f"Add trailing comma here ->" -COM81.py:643:49: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:643:49 | 642 | raise Exception( 643 | "first", extra=f"Add trailing comma here ->" - | ^ COM812 + | ^ 644 | ) | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 640 640 | kwargs.pop("remove", f"this {trailing_comma}",) @@ -978,15 +1030,16 @@ COM81.py:643:49: COM812 [*] Trailing comma missing 645 645 | 646 646 | assert False, f"<- This is not a trailing comma" -COM81.py:655:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:655:6 | 654 | type X[ 655 | T - | ^ COM812 + | ^ 656 | ] = T 657 | def f[ | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 652 652 | }""" @@ -998,16 +1051,17 @@ COM81.py:655:6: COM812 [*] Trailing comma missing 657 657 | def f[ 658 658 | T -COM81.py:658:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:658:6 | 656 | ] = T 657 | def f[ 658 | T - | ^ COM812 + | ^ 659 | ](): pass 660 | class C[ | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 655 655 | T @@ -1019,15 +1073,16 @@ COM81.py:658:6: COM812 [*] Trailing comma missing 660 660 | class C[ 661 661 | T -COM81.py:661:6: COM812 [*] Trailing comma missing +COM812 [*] Trailing comma missing + --> COM81.py:661:6 | 659 | ](): pass 660 | class C[ 661 | T - | ^ COM812 + | ^ 662 | ]: pass | - = help: Add trailing comma +help: Add trailing comma ℹ Safe fix 658 658 | T @@ -1039,16 +1094,17 @@ COM81.py:661:6: COM812 [*] Trailing comma missing 663 663 | 664 664 | type X[T,] = T -COM81.py:664:9: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:664:9 | 662 | ]: pass 663 | 664 | type X[T,] = T - | ^ COM819 + | ^ 665 | def f[T,](): pass 666 | class C[T,]: pass | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 661 661 | T @@ -1059,14 +1115,15 @@ COM81.py:664:9: COM819 [*] Trailing comma prohibited 665 665 | def f[T,](): pass 666 666 | class C[T,]: pass -COM81.py:665:8: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:665:8 | 664 | type X[T,] = T 665 | def f[T,](): pass - | ^ COM819 + | ^ 666 | class C[T,]: pass | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 662 662 | ]: pass @@ -1076,14 +1133,15 @@ COM81.py:665:8: COM819 [*] Trailing comma prohibited 665 |+def f[T](): pass 666 666 | class C[T,]: pass -COM81.py:666:10: COM819 [*] Trailing comma prohibited +COM819 [*] Trailing comma prohibited + --> COM81.py:666:10 | 664 | type X[T,] = T 665 | def f[T,](): pass 666 | class C[T,]: pass - | ^ COM819 + | ^ | - = help: Remove trailing comma +help: Remove trailing comma ℹ Safe fix 663 663 | diff --git a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81_syntax_error.py.snap index f6be9a1954..be64c5452f 100644 --- a/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__preview__COM81_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_commas/mod.rs --- -COM81_syntax_error.py:3:5: invalid-syntax: Starred expression cannot be used here +invalid-syntax: Starred expression cannot be used here + --> COM81_syntax_error.py:3:5 | 1 | # Check for `flake8-commas` violation for a file containing syntax errors. 2 | ( @@ -10,7 +11,8 @@ COM81_syntax_error.py:3:5: invalid-syntax: Starred expression cannot be used her 4 | ) | -COM81_syntax_error.py:6:9: invalid-syntax: Type parameter list cannot be empty +invalid-syntax: Type parameter list cannot be empty + --> COM81_syntax_error.py:6:9 | 4 | ) 5 | @@ -19,12 +21,13 @@ COM81_syntax_error.py:6:9: invalid-syntax: Type parameter list cannot be empty 7 | pass | -COM81_syntax_error.py:6:38: COM819 Trailing comma prohibited +COM819 Trailing comma prohibited + --> COM81_syntax_error.py:6:38 | 4 | ) 5 | 6 | def foo[(param1='test', param2='test',): - | ^ COM819 + | ^ 7 | pass | - = help: Remove trailing comma +help: Remove trailing comma diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap index fac96417f0..1be1ac0752 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C400.py:2:13: C400 [*] Unnecessary generator (rewrite as a list comprehension) +C400 [*] Unnecessary generator (rewrite as a list comprehension) + --> C400.py:2:13 | 1 | # Cannot combine with C416. Should use list comprehension here. 2 | even_nums = list(2 * x for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | odd_nums = list( 4 | 2 * x + 1 for x in range(3) | - = help: Rewrite as a list comprehension +help: Rewrite as a list comprehension ℹ Unsafe fix 1 1 | # Cannot combine with C416. Should use list comprehension here. @@ -19,7 +20,8 @@ C400.py:2:13: C400 [*] Unnecessary generator (rewrite as a list comprehension) 4 4 | 2 * x + 1 for x in range(3) 5 5 | ) -C400.py:3:12: C400 [*] Unnecessary generator (rewrite as a list comprehension) +C400 [*] Unnecessary generator (rewrite as a list comprehension) + --> C400.py:3:12 | 1 | # Cannot combine with C416. Should use list comprehension here. 2 | even_nums = list(2 * x for x in range(3)) @@ -27,9 +29,9 @@ C400.py:3:12: C400 [*] Unnecessary generator (rewrite as a list comprehension) | ____________^ 4 | | 2 * x + 1 for x in range(3) 5 | | ) - | |_^ C400 + | |_^ | - = help: Rewrite as a list comprehension +help: Rewrite as a list comprehension ℹ Unsafe fix 1 1 | # Cannot combine with C416. Should use list comprehension here. @@ -43,15 +45,16 @@ C400.py:3:12: C400 [*] Unnecessary generator (rewrite as a list comprehension) 7 7 | 8 8 | # Short-circuit case, combine with C416 and should produce x = list(range(3)) -C400.py:9:5: C400 [*] Unnecessary generator (rewrite using `list()`) +C400 [*] Unnecessary generator (rewrite using `list()`) + --> C400.py:9:5 | 8 | # Short-circuit case, combine with C416 and should produce x = list(range(3)) 9 | x = list(x for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ C400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | x = list( 11 | x for x in range(3) | - = help: Rewrite using `list()` +help: Rewrite using `list()` ℹ Unsafe fix 6 6 | @@ -63,7 +66,8 @@ C400.py:9:5: C400 [*] Unnecessary generator (rewrite using `list()`) 11 11 | x for x in range(3) 12 12 | ) -C400.py:10:5: C400 [*] Unnecessary generator (rewrite using `list()`) +C400 [*] Unnecessary generator (rewrite using `list()`) + --> C400.py:10:5 | 8 | # Short-circuit case, combine with C416 and should produce x = list(range(3)) 9 | x = list(x for x in range(3)) @@ -71,11 +75,11 @@ C400.py:10:5: C400 [*] Unnecessary generator (rewrite using `list()`) | _____^ 11 | | x for x in range(3) 12 | | ) - | |_^ C400 + | |_^ 13 | 14 | # Strip parentheses from inner generators. | - = help: Rewrite using `list()` +help: Rewrite using `list()` ℹ Unsafe fix 7 7 | @@ -89,15 +93,16 @@ C400.py:10:5: C400 [*] Unnecessary generator (rewrite using `list()`) 14 12 | # Strip parentheses from inner generators. 15 13 | list((2 * x for x in range(3))) -C400.py:15:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) +C400 [*] Unnecessary generator (rewrite as a list comprehension) + --> C400.py:15:1 | 14 | # Strip parentheses from inner generators. 15 | list((2 * x for x in range(3))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | list(((2 * x for x in range(3)))) 17 | list((((2 * x for x in range(3))))) | - = help: Rewrite as a list comprehension +help: Rewrite as a list comprehension ℹ Unsafe fix 12 12 | ) @@ -109,15 +114,16 @@ C400.py:15:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) 17 17 | list((((2 * x for x in range(3))))) 18 18 | -C400.py:16:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) +C400 [*] Unnecessary generator (rewrite as a list comprehension) + --> C400.py:16:1 | 14 | # Strip parentheses from inner generators. 15 | list((2 * x for x in range(3))) 16 | list(((2 * x for x in range(3)))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | list((((2 * x for x in range(3))))) | - = help: Rewrite as a list comprehension +help: Rewrite as a list comprehension ℹ Unsafe fix 13 13 | @@ -129,16 +135,17 @@ C400.py:16:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) 18 18 | 19 19 | # Account for trailing comma in fix -C400.py:17:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) +C400 [*] Unnecessary generator (rewrite as a list comprehension) + --> C400.py:17:1 | 15 | list((2 * x for x in range(3))) 16 | list(((2 * x for x in range(3)))) 17 | list((((2 * x for x in range(3))))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | # Account for trailing comma in fix | - = help: Rewrite as a list comprehension +help: Rewrite as a list comprehension ℹ Unsafe fix 14 14 | # Strip parentheses from inner generators. @@ -150,16 +157,17 @@ C400.py:17:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) 19 19 | # Account for trailing comma in fix 20 20 | # See https://github.com/astral-sh/ruff/issues/15852 -C400.py:21:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) +C400 [*] Unnecessary generator (rewrite as a list comprehension) + --> C400.py:21:1 | 19 | # Account for trailing comma in fix 20 | # See https://github.com/astral-sh/ruff/issues/15852 21 | list((0 for _ in []),) - | ^^^^^^^^^^^^^^^^^^^^^^ C400 + | ^^^^^^^^^^^^^^^^^^^^^^ 22 | list( 23 | (0 for _ in []) | - = help: Rewrite as a list comprehension +help: Rewrite as a list comprehension ℹ Unsafe fix 18 18 | @@ -171,7 +179,8 @@ C400.py:21:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) 23 23 | (0 for _ in []) 24 24 | # some comments -C400.py:22:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) +C400 [*] Unnecessary generator (rewrite as a list comprehension) + --> C400.py:22:1 | 20 | # See https://github.com/astral-sh/ruff/issues/15852 21 | list((0 for _ in []),) @@ -181,9 +190,9 @@ C400.py:22:1: C400 [*] Unnecessary generator (rewrite as a list comprehension) 25 | | , 26 | | # some more 27 | | ) - | |__^ C400 + | |__^ | - = help: Rewrite as a list comprehension +help: Rewrite as a list comprehension ℹ Unsafe fix 19 19 | # Account for trailing comma in fix diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap index c2af13db5e..32db38fff8 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C401.py:2:13: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:2:13 | 1 | # Cannot combine with C416. Should use set comprehension here. 2 | even_nums = set(2 * x for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | odd_nums = set( 4 | 2 * x + 1 for x in range(3) | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 1 1 | # Cannot combine with C416. Should use set comprehension here. @@ -19,7 +20,8 @@ C401.py:2:13: C401 [*] Unnecessary generator (rewrite as a set comprehension) 4 4 | 2 * x + 1 for x in range(3) 5 5 | ) -C401.py:3:12: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:3:12 | 1 | # Cannot combine with C416. Should use set comprehension here. 2 | even_nums = set(2 * x for x in range(3)) @@ -27,10 +29,10 @@ C401.py:3:12: C401 [*] Unnecessary generator (rewrite as a set comprehension) | ____________^ 4 | | 2 * x + 1 for x in range(3) 5 | | ) - | |_^ C401 + | |_^ 6 | small_nums = f"{set(a if a < 6 else 0 for a in range(3))}" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 1 1 | # Cannot combine with C416. Should use set comprehension here. @@ -44,16 +46,17 @@ C401.py:3:12: C401 [*] Unnecessary generator (rewrite as a set comprehension) 7 7 | 8 8 | def f(x): -C401.py:6:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:6:17 | 4 | 2 * x + 1 for x in range(3) 5 | ) 6 | small_nums = f"{set(a if a < 6 else 0 for a in range(3))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | def f(x): | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 3 3 | odd_nums = set( @@ -65,15 +68,16 @@ C401.py:6:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) 8 8 | def f(x): 9 9 | return x -C401.py:11:16: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:11:16 | 9 | return x 10 | 11 | print(f"Hello {set(f(a) for a in 'abc')} World") - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 12 | print(f"Hello { set(f(a) for a in 'abc') } World") | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 8 8 | def f(x): @@ -85,13 +89,14 @@ C401.py:11:16: C401 [*] Unnecessary generator (rewrite as a set comprehension) 13 13 | 14 14 | -C401.py:12:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:12:17 | 11 | print(f"Hello {set(f(a) for a in 'abc')} World") 12 | print(f"Hello { set(f(a) for a in 'abc') } World") - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 9 9 | return x @@ -103,15 +108,16 @@ C401.py:12:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) 14 14 | 15 15 | # Short-circuit case, combine with C416 and should produce x = set(range(3)) -C401.py:16:5: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:16:5 | 15 | # Short-circuit case, combine with C416 and should produce x = set(range(3)) 16 | x = set(x for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 17 | x = set( 18 | x for x in range(3) | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 13 13 | @@ -123,7 +129,8 @@ C401.py:16:5: C401 [*] Unnecessary generator (rewrite using `set()`) 18 18 | x for x in range(3) 19 19 | ) -C401.py:17:5: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:17:5 | 15 | # Short-circuit case, combine with C416 and should produce x = set(range(3)) 16 | x = set(x for x in range(3)) @@ -131,11 +138,11 @@ C401.py:17:5: C401 [*] Unnecessary generator (rewrite using `set()`) | _____^ 18 | | x for x in range(3) 19 | | ) - | |_^ C401 + | |_^ 20 | print(f"Hello {set(a for a in range(3))} World") 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 14 14 | @@ -149,16 +156,17 @@ C401.py:17:5: C401 [*] Unnecessary generator (rewrite using `set()`) 21 19 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") 22 20 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") -C401.py:20:16: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:20:16 | 18 | x for x in range(3) 19 | ) 20 | print(f"Hello {set(a for a in range(3))} World") - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 17 17 | x = set( @@ -170,15 +178,16 @@ C401.py:20:16: C401 [*] Unnecessary generator (rewrite using `set()`) 22 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") 23 23 | -C401.py:21:10: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:21:10 | 19 | ) 20 | print(f"Hello {set(a for a in range(3))} World") 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - | ^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^ 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 18 18 | x for x in range(3) @@ -190,15 +199,16 @@ C401.py:21:10: C401 [*] Unnecessary generator (rewrite using `set()`) 23 23 | 24 24 | # Strip parentheses from inner generators. -C401.py:21:34: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:21:34 | 19 | ) 20 | print(f"Hello {set(a for a in range(3))} World") 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - | ^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^ 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 18 18 | x for x in range(3) @@ -210,16 +220,17 @@ C401.py:21:34: C401 [*] Unnecessary generator (rewrite using `set()`) 23 23 | 24 24 | # Strip parentheses from inner generators. -C401.py:22:11: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:22:11 | 20 | print(f"Hello {set(a for a in range(3))} World") 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | ^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | # Strip parentheses from inner generators. | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 19 19 | ) @@ -231,16 +242,17 @@ C401.py:22:11: C401 [*] Unnecessary generator (rewrite using `set()`) 24 24 | # Strip parentheses from inner generators. 25 25 | set((2 * x for x in range(3))) -C401.py:22:35: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:22:35 | 20 | print(f"Hello {set(a for a in range(3))} World") 21 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | ^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^ 23 | 24 | # Strip parentheses from inner generators. | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 19 19 | ) @@ -252,15 +264,16 @@ C401.py:22:35: C401 [*] Unnecessary generator (rewrite using `set()`) 24 24 | # Strip parentheses from inner generators. 25 25 | set((2 * x for x in range(3))) -C401.py:25:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:25:1 | 24 | # Strip parentheses from inner generators. 25 | set((2 * x for x in range(3))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | set(((2 * x for x in range(3)))) 27 | set((((2 * x for x in range(3))))) | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 22 22 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") @@ -272,15 +285,16 @@ C401.py:25:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) 27 27 | set((((2 * x for x in range(3))))) 28 28 | -C401.py:26:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:26:1 | 24 | # Strip parentheses from inner generators. 25 | set((2 * x for x in range(3))) 26 | set(((2 * x for x in range(3)))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | set((((2 * x for x in range(3))))) | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 23 23 | @@ -292,16 +306,17 @@ C401.py:26:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) 28 28 | 29 29 | # Account for trailing comma in fix -C401.py:27:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:27:1 | 25 | set((2 * x for x in range(3))) 26 | set(((2 * x for x in range(3)))) 27 | set((((2 * x for x in range(3))))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | # Account for trailing comma in fix | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 24 24 | # Strip parentheses from inner generators. @@ -313,16 +328,17 @@ C401.py:27:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) 29 29 | # Account for trailing comma in fix 30 30 | # See https://github.com/astral-sh/ruff/issues/15852 -C401.py:31:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:31:1 | 29 | # Account for trailing comma in fix 30 | # See https://github.com/astral-sh/ruff/issues/15852 31 | set((0 for _ in []),) - | ^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^ 32 | set( 33 | (0 for _ in []) | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 28 28 | @@ -334,7 +350,8 @@ C401.py:31:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) 33 33 | (0 for _ in []) 34 34 | # some comments -C401.py:32:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:32:1 | 30 | # See https://github.com/astral-sh/ruff/issues/15852 31 | set((0 for _ in []),) @@ -344,11 +361,11 @@ C401.py:32:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) 35 | | , 36 | | # some more 37 | | ) - | |_^ C401 + | |_^ 38 | 39 | # t-strings | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 29 29 | # Account for trailing comma in fix @@ -367,15 +384,16 @@ C401.py:32:1: C401 [*] Unnecessary generator (rewrite as a set comprehension) 39 37 | # t-strings 40 38 | print(t"Hello {set(f(a) for a in 'abc')} World") -C401.py:40:16: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:40:16 | 39 | # t-strings 40 | print(t"Hello {set(f(a) for a in 'abc')} World") - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 41 | print(t"Hello { set(f(a) for a in 'abc') } World") 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 37 37 | ) @@ -387,16 +405,17 @@ C401.py:40:16: C401 [*] Unnecessary generator (rewrite as a set comprehension) 42 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" 43 43 | print(t"Hello {set(a for a in range(3))} World") -C401.py:41:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:41:17 | 39 | # t-strings 40 | print(t"Hello {set(f(a) for a in 'abc')} World") 41 | print(t"Hello { set(f(a) for a in 'abc') } World") - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" 43 | print(t"Hello {set(a for a in range(3))} World") | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 38 38 | @@ -408,16 +427,17 @@ C401.py:41:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) 43 43 | print(t"Hello {set(a for a in range(3))} World") 44 44 | print(t"{set(a for a in 'abc') - set(a for a in 'ab')}") -C401.py:42:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) +C401 [*] Unnecessary generator (rewrite as a set comprehension) + --> C401.py:42:17 | 40 | print(t"Hello {set(f(a) for a in 'abc')} World") 41 | print(t"Hello { set(f(a) for a in 'abc') } World") 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | print(t"Hello {set(a for a in range(3))} World") 44 | print(t"{set(a for a in 'abc') - set(a for a in 'ab')}") | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 39 39 | # t-strings @@ -429,16 +449,17 @@ C401.py:42:17: C401 [*] Unnecessary generator (rewrite as a set comprehension) 44 44 | print(t"{set(a for a in 'abc') - set(a for a in 'ab')}") 45 45 | print(t"{ set(a for a in 'abc') - set(a for a in 'ab') }") -C401.py:43:16: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:43:16 | 41 | print(t"Hello { set(f(a) for a in 'abc') } World") 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" 43 | print(t"Hello {set(a for a in range(3))} World") - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 44 | print(t"{set(a for a in 'abc') - set(a for a in 'ab')}") 45 | print(t"{ set(a for a in 'abc') - set(a for a in 'ab') }") | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 40 40 | print(t"Hello {set(f(a) for a in 'abc')} World") @@ -450,15 +471,16 @@ C401.py:43:16: C401 [*] Unnecessary generator (rewrite using `set()`) 45 45 | print(t"{ set(a for a in 'abc') - set(a for a in 'ab') }") 46 46 | -C401.py:44:10: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:44:10 | 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" 43 | print(t"Hello {set(a for a in range(3))} World") 44 | print(t"{set(a for a in 'abc') - set(a for a in 'ab')}") - | ^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^ 45 | print(t"{ set(a for a in 'abc') - set(a for a in 'ab') }") | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 41 41 | print(t"Hello { set(f(a) for a in 'abc') } World") @@ -470,15 +492,16 @@ C401.py:44:10: C401 [*] Unnecessary generator (rewrite using `set()`) 46 46 | 47 47 | -C401.py:44:34: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:44:34 | 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" 43 | print(t"Hello {set(a for a in range(3))} World") 44 | print(t"{set(a for a in 'abc') - set(a for a in 'ab')}") - | ^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^ 45 | print(t"{ set(a for a in 'abc') - set(a for a in 'ab') }") | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 41 41 | print(t"Hello { set(f(a) for a in 'abc') } World") @@ -490,14 +513,15 @@ C401.py:44:34: C401 [*] Unnecessary generator (rewrite using `set()`) 46 46 | 47 47 | -C401.py:45:11: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:45:11 | 43 | print(t"Hello {set(a for a in range(3))} World") 44 | print(t"{set(a for a in 'abc') - set(a for a in 'ab')}") 45 | print(t"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | ^^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 42 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" @@ -509,14 +533,15 @@ C401.py:45:11: C401 [*] Unnecessary generator (rewrite using `set()`) 47 47 | 48 48 | # Not built-in set. -C401.py:45:35: C401 [*] Unnecessary generator (rewrite using `set()`) +C401 [*] Unnecessary generator (rewrite using `set()`) + --> C401.py:45:35 | 43 | print(t"Hello {set(a for a in range(3))} World") 44 | print(t"{set(a for a in 'abc') - set(a for a in 'ab')}") 45 | print(t"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | ^^^^^^^^^^^^^^^^^^^^ C401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 42 42 | small_nums = t"{set(a if a < 6 else 0 for a in range(3))}" diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap index 12c426627a..749545c7fc 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C402.py:1:1: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:1:1 | 1 | dict((x, x) for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | dict( 3 | (x, x) for x in range(3) | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 1 |-dict((x, x) for x in range(3)) @@ -17,17 +18,18 @@ C402.py:1:1: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 3 3 | (x, x) for x in range(3) 4 4 | ) -C402.py:2:1: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:2:1 | 1 | dict((x, x) for x in range(3)) 2 | / dict( 3 | | (x, x) for x in range(3) 4 | | ) - | |_^ C402 + | |_^ 5 | dict(((x, x) for x in range(3)), z=3) 6 | y = f'{dict((x, x) for x in range(3))}' | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 1 1 | dict((x, x) for x in range(3)) @@ -41,16 +43,17 @@ C402.py:2:1: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 6 6 | y = f'{dict((x, x) for x in range(3))}' 7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -C402.py:6:8: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:6:8 | 4 | ) 5 | dict(((x, x) for x in range(3)), z=3) 6 | y = f'{dict((x, x) for x in range(3))}' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | print(f'Hello {dict((x, x) for x in range(3))} World') 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 3 3 | (x, x) for x in range(3) @@ -62,16 +65,17 @@ C402.py:6:8: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") 9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -C402.py:7:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:7:16 | 5 | dict(((x, x) for x in range(3)), z=3) 6 | y = f'{dict((x, x) for x in range(3))}' 7 | print(f'Hello {dict((x, x) for x in range(3))} World') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") 9 | print(f'Hello {dict((x, x) for x in "abc")} World') | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 4 4 | ) @@ -83,16 +87,17 @@ C402.py:7:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') 10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -C402.py:8:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:8:16 | 6 | y = f'{dict((x, x) for x in range(3))}' 7 | print(f'Hello {dict((x, x) for x in range(3))} World') 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | print(f'Hello {dict((x, x) for x in "abc")} World') 10 | print(f'Hello {dict((x,x) for x in "abc")} World') | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 5 5 | dict(((x, x) for x in range(3)), z=3) @@ -104,15 +109,16 @@ C402.py:8:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') 11 11 | -C402.py:9:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:9:16 | 7 | print(f'Hello {dict((x, x) for x in range(3))} World') 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") 9 | print(f'Hello {dict((x, x) for x in "abc")} World') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | print(f'Hello {dict((x,x) for x in "abc")} World') | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 6 6 | y = f'{dict((x, x) for x in range(3))}' @@ -124,16 +130,17 @@ C402.py:9:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 11 11 | 12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' -C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:10:16 | 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") 9 | print(f'Hello {dict((x, x) for x in "abc")} World') 10 | print(f'Hello {dict((x,x) for x in "abc")} World') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') @@ -145,15 +152,16 @@ C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' 13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' -C402.py:12:4: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:12:4 | 10 | print(f'Hello {dict((x,x) for x in "abc")} World') 11 | 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') @@ -165,15 +173,16 @@ C402.py:12:4: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 14 14 | 15 15 | def f(x): -C402.py:12:37: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:12:37 | 10 | print(f'Hello {dict((x,x) for x in "abc")} World') 11 | 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') @@ -185,15 +194,16 @@ C402.py:12:37: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 14 14 | 15 15 | def f(x): -C402.py:13:5: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:13:5 | 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | def f(x): | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') @@ -205,15 +215,16 @@ C402.py:13:5: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 15 15 | def f(x): 16 16 | return x -C402.py:13:38: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:13:38 | 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | def f(x): | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') @@ -225,16 +236,17 @@ C402.py:13:38: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 15 15 | def f(x): 16 16 | return x -C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:18:16 | 16 | return x 17 | 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 15 15 | def f(x): @@ -246,15 +258,16 @@ C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a dict comprehension) 20 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 21 21 | dict((k,v)for k,v in d.iteritems() if k in only_args) -C402.py:21:1: C402 [*] Unnecessary generator (rewrite as a dict comprehension) +C402 [*] Unnecessary generator (rewrite as a dict comprehension) + --> C402.py:21:1 | 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 21 | dict((k,v)for k,v in d.iteritems() if k in only_args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458940 | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 18 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap index df5f910c3a..531b3168cf 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C403.py:1:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:1:5 | 1 | s = set([x for x in range(3)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | s = set( 3 | [x for x in range(3)] | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 1 |-s = set([x for x in range(3)]) @@ -17,18 +18,19 @@ C403.py:1:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehen 3 3 | [x for x in range(3)] 4 4 | ) -C403.py:2:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:2:5 | 1 | s = set([x for x in range(3)]) 2 | s = set( | _____^ 3 | | [x for x in range(3)] 4 | | ) - | |_^ C403 + | |_^ 5 | 6 | s = f"{set([x for x in 'ab'])}" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 1 1 | s = set([x for x in range(3)]) @@ -42,15 +44,16 @@ C403.py:2:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehen 6 6 | s = f"{set([x for x in 'ab'])}" 7 7 | s = f'{set([x for x in "ab"])}' -C403.py:6:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:6:8 | 4 | ) 5 | 6 | s = f"{set([x for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 7 | s = f'{set([x for x in "ab"])}' | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 3 3 | [x for x in range(3)] @@ -62,15 +65,16 @@ C403.py:6:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehen 8 8 | 9 9 | def f(x): -C403.py:7:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:7:8 | 6 | s = f"{set([x for x in 'ab'])}" 7 | s = f'{set([x for x in "ab"])}' - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | def f(x): | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 4 4 | ) @@ -82,16 +86,17 @@ C403.py:7:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehen 9 9 | def f(x): 10 10 | return x -C403.py:12:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:12:8 | 10 | return x 11 | 12 | s = f"{set([f(x) for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 9 9 | def f(x): @@ -103,15 +108,16 @@ C403.py:12:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" 15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" -C403.py:14:9: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:14:9 | 12 | s = f"{set([f(x) for x in 'ab'])}" 13 | 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 11 11 | @@ -123,15 +129,16 @@ C403.py:14:9: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 16 16 | 17 17 | s = set( # comment -C403.py:14:34: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:14:34 | 12 | s = f"{set([f(x) for x in 'ab'])}" 13 | 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 11 11 | @@ -143,15 +150,16 @@ C403.py:14:34: C403 [*] Unnecessary list comprehension (rewrite as a set compreh 16 16 | 17 17 | s = set( # comment -C403.py:15:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:15:8 | 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | s = set( # comment | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 12 12 | s = f"{set([f(x) for x in 'ab'])}" @@ -163,15 +171,16 @@ C403.py:15:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 17 17 | s = set( # comment 18 18 | [x for x in range(3)] -C403.py:15:33: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:15:33 | 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | s = set( # comment | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 12 12 | s = f"{set([f(x) for x in 'ab'])}" @@ -183,7 +192,8 @@ C403.py:15:33: C403 [*] Unnecessary list comprehension (rewrite as a set compreh 17 17 | s = set( # comment 18 18 | [x for x in range(3)] -C403.py:17:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:17:5 | 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" 16 | @@ -191,11 +201,11 @@ C403.py:17:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe | _____^ 18 | | [x for x in range(3)] 19 | | ) - | |_^ C403 + | |_^ 20 | 21 | s = set([ # comment | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" @@ -211,7 +221,8 @@ C403.py:17:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 21 21 | s = set([ # comment 22 22 | x for x in range(3) -C403.py:21:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:21:5 | 19 | ) 20 | @@ -219,11 +230,11 @@ C403.py:21:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe | _____^ 22 | | x for x in range(3) 23 | | ]) - | |__^ C403 + | |__^ 24 | 25 | s = set(([x for x in range(3)])) | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 18 18 | [x for x in range(3)] @@ -238,16 +249,17 @@ C403.py:21:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 25 25 | s = set(([x for x in range(3)])) 26 26 | -C403.py:25:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:25:5 | 23 | ]) 24 | 25 | s = set(([x for x in range(3)])) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | s = set(((([x for x in range(3)])))) | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 22 22 | x for x in range(3) @@ -259,16 +271,17 @@ C403.py:25:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 27 27 | s = set(((([x for x in range(3)])))) 28 28 | -C403.py:27:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:27:5 | 25 | s = set(([x for x in range(3)])) 26 | 27 | s = set(((([x for x in range(3)])))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | s = set( # outer set comment | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 24 24 | @@ -280,7 +293,8 @@ C403.py:27:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 29 29 | s = set( # outer set comment 30 30 | ( # inner paren comment - not preserved -C403.py:29:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:29:5 | 27 | s = set(((([x for x in range(3)])))) 28 | @@ -291,11 +305,11 @@ C403.py:29:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 32 | | [ # comprehension comment 33 | | x for x in range(3)] 34 | | )))) - | |_____^ C403 + | |_____^ 35 | 36 | # Test trailing comma case | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 26 26 | @@ -314,15 +328,16 @@ C403.py:29:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 36 33 | # Test trailing comma case 37 34 | s = set([x for x in range(3)],) -C403.py:37:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:37:5 | 36 | # Test trailing comma case 37 | s = set([x for x in range(3)],) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | 39 | s = t"{set([x for x in 'ab'])}" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 34 34 | )))) @@ -334,15 +349,16 @@ C403.py:37:5: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 39 39 | s = t"{set([x for x in 'ab'])}" 40 40 | s = t'{set([x for x in "ab"])}' -C403.py:39:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:39:8 | 37 | s = set([x for x in range(3)],) 38 | 39 | s = t"{set([x for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 40 | s = t'{set([x for x in "ab"])}' | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 36 36 | # Test trailing comma case @@ -354,15 +370,16 @@ C403.py:39:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 41 41 | 42 42 | def f(x): -C403.py:40:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:40:8 | 39 | s = t"{set([x for x in 'ab'])}" 40 | s = t'{set([x for x in "ab"])}' - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 41 | 42 | def f(x): | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 37 37 | s = set([x for x in range(3)],) @@ -374,16 +391,17 @@ C403.py:40:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 42 42 | def f(x): 43 43 | return x -C403.py:45:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:45:8 | 43 | return x 44 | 45 | s = t"{set([f(x) for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | 47 | s = t"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 42 42 | def f(x): @@ -395,15 +413,16 @@ C403.py:45:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 47 47 | s = t"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" 48 48 | s = t"{set([x for x in 'ab']) | set([x for x in 'ab'])}" -C403.py:47:9: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:47:9 | 45 | s = t"{set([f(x) for x in 'ab'])}" 46 | 47 | s = t"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 48 | s = t"{set([x for x in 'ab']) | set([x for x in 'ab'])}" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 44 44 | @@ -414,15 +433,16 @@ C403.py:47:9: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 48 48 | s = t"{set([x for x in 'ab']) | set([x for x in 'ab'])}" 49 49 | -C403.py:47:34: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:47:34 | 45 | s = t"{set([f(x) for x in 'ab'])}" 46 | 47 | s = t"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ 48 | s = t"{set([x for x in 'ab']) | set([x for x in 'ab'])}" | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 44 44 | @@ -433,13 +453,14 @@ C403.py:47:34: C403 [*] Unnecessary list comprehension (rewrite as a set compreh 48 48 | s = t"{set([x for x in 'ab']) | set([x for x in 'ab'])}" 49 49 | -C403.py:48:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:48:8 | 47 | s = t"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" 48 | s = t"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 45 45 | s = t"{set([f(x) for x in 'ab'])}" @@ -449,13 +470,14 @@ C403.py:48:8: C403 [*] Unnecessary list comprehension (rewrite as a set comprehe 48 |+s = t"{ {x for x in 'ab'} | set([x for x in 'ab'])}" 49 49 | -C403.py:48:33: C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) +C403 [*] Unnecessary list comprehension (rewrite as a set comprehension) + --> C403.py:48:33 | 47 | s = t"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" 48 | s = t"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite as a set comprehension +help: Rewrite as a set comprehension ℹ Unsafe fix 45 45 | s = t"{set([f(x) for x in 'ab'])}" diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap index 1267401cfd..efc2bb6328 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C404.py:1:1: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:1:1 | 1 | dict([(i, i) for i in range(3)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | dict([(i, i) for i in range(3)], z=4) | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 1 |-dict([(i, i) for i in range(3)]) @@ -16,16 +17,17 @@ C404.py:1:1: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehe 3 3 | 4 4 | def f(x): -C404.py:7:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:7:4 | 5 | return x 6 | 7 | f'{dict([(s,s) for s in "ab"])}' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | f"{dict([(s,s) for s in 'ab'])}" 9 | f"{dict([(s, s) for s in 'ab'])}" | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 4 4 | def f(x): @@ -37,15 +39,16 @@ C404.py:7:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehe 9 9 | f"{dict([(s, s) for s in 'ab'])}" 10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -C404.py:8:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:8:4 | 7 | f'{dict([(s,s) for s in "ab"])}' 8 | f"{dict([(s,s) for s in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | f"{dict([(s, s) for s in 'ab'])}" 10 | f"{dict([(s,f(s)) for s in 'ab'])}" | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 5 5 | return x @@ -57,15 +60,16 @@ C404.py:8:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehe 10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" 11 11 | -C404.py:9:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:9:4 | 7 | f'{dict([(s,s) for s in "ab"])}' 8 | f"{dict([(s,s) for s in 'ab'])}" 9 | f"{dict([(s, s) for s in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | f"{dict([(s,f(s)) for s in 'ab'])}" | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 6 6 | @@ -77,16 +81,17 @@ C404.py:9:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehe 11 11 | 12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' -C404.py:10:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:10:4 | 8 | f"{dict([(s,s) for s in 'ab'])}" 9 | f"{dict([(s, s) for s in 'ab'])}" 10 | f"{dict([(s,f(s)) for s in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 7 7 | f'{dict([(s,s) for s in "ab"])}' @@ -98,15 +103,16 @@ C404.py:10:4: C404 [*] Unnecessary list comprehension (rewrite as a dict compreh 12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' -C404.py:12:4: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:12:4 | 10 | f"{dict([(s,f(s)) for s in 'ab'])}" 11 | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 9 9 | f"{dict([(s, s) for s in 'ab'])}" @@ -118,15 +124,16 @@ C404.py:12:4: C404 [*] Unnecessary list comprehension (rewrite as a dict compreh 14 14 | 15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -C404.py:12:34: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:12:34 | 10 | f"{dict([(s,f(s)) for s in 'ab'])}" 11 | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 9 9 | f"{dict([(s, s) for s in 'ab'])}" @@ -138,15 +145,16 @@ C404.py:12:34: C404 [*] Unnecessary list comprehension (rewrite as a dict compre 14 14 | 15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -C404.py:13:5: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:13:5 | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" @@ -158,15 +166,16 @@ C404.py:13:5: C404 [*] Unnecessary list comprehension (rewrite as a dict compreh 15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) -C404.py:13:35: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:13:35 | 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" @@ -178,13 +187,14 @@ C404.py:13:35: C404 [*] Unnecessary list comprehension (rewrite as a dict compre 15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) -C404.py:16:14: C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) +C404 [*] Unnecessary list comprehension (rewrite as a dict comprehension) + --> C404.py:16:14 | 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite as a dict comprehension +help: Rewrite as a dict comprehension ℹ Unsafe fix 13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap index b8df7cf5b0..5dbd827589 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C405.py:1:1: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:1:1 | 1 | set([1, 2]) - | ^^^^^^^^^^^ C405 + | ^^^^^^^^^^^ 2 | set((1, 2)) 3 | set([]) | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 1 |-set([1, 2]) @@ -17,15 +18,16 @@ C405.py:1:1: C405 [*] Unnecessary list literal (rewrite as a set literal) 3 3 | set([]) 4 4 | set(()) -C405.py:2:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) +C405 [*] Unnecessary tuple literal (rewrite as a set literal) + --> C405.py:2:1 | 1 | set([1, 2]) 2 | set((1, 2)) - | ^^^^^^^^^^^ C405 + | ^^^^^^^^^^^ 3 | set([]) 4 | set(()) | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 1 1 | set([1, 2]) @@ -35,16 +37,17 @@ C405.py:2:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) 4 4 | set(()) 5 5 | set() -C405.py:3:1: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:3:1 | 1 | set([1, 2]) 2 | set((1, 2)) 3 | set([]) - | ^^^^^^^ C405 + | ^^^^^^^ 4 | set(()) 5 | set() | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 1 1 | set([1, 2]) @@ -55,16 +58,17 @@ C405.py:3:1: C405 [*] Unnecessary list literal (rewrite as a set literal) 5 5 | set() 6 6 | set((1,)) -C405.py:4:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) +C405 [*] Unnecessary tuple literal (rewrite as a set literal) + --> C405.py:4:1 | 2 | set((1, 2)) 3 | set([]) 4 | set(()) - | ^^^^^^^ C405 + | ^^^^^^^ 5 | set() 6 | set((1,)) | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 1 1 | set([1, 2]) @@ -77,16 +81,17 @@ C405.py:4:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) 7 7 | set(( 8 8 | 1, -C405.py:6:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) +C405 [*] Unnecessary tuple literal (rewrite as a set literal) + --> C405.py:6:1 | 4 | set(()) 5 | set() 6 | set((1,)) - | ^^^^^^^^^ C405 + | ^^^^^^^^^ 7 | set(( 8 | 1, | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 3 3 | set([]) @@ -98,18 +103,19 @@ C405.py:6:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) 8 8 | 1, 9 9 | )) -C405.py:7:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) +C405 [*] Unnecessary tuple literal (rewrite as a set literal) + --> C405.py:7:1 | 5 | set() 6 | set((1,)) 7 | / set(( 8 | | 1, 9 | | )) - | |__^ C405 + | |__^ 10 | set([ 11 | 1, | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 4 4 | set(()) @@ -124,18 +130,19 @@ C405.py:7:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) 11 11 | 1, 12 12 | ]) -C405.py:10:1: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:10:1 | 8 | 1, 9 | )) 10 | / set([ 11 | | 1, 12 | | ]) - | |__^ C405 + | |__^ 13 | set( 14 | (1,) | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 7 7 | set(( @@ -150,18 +157,19 @@ C405.py:10:1: C405 [*] Unnecessary list literal (rewrite as a set literal) 14 14 | (1,) 15 15 | ) -C405.py:13:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) +C405 [*] Unnecessary tuple literal (rewrite as a set literal) + --> C405.py:13:1 | 11 | 1, 12 | ]) 13 | / set( 14 | | (1,) 15 | | ) - | |_^ C405 + | |_^ 16 | set( 17 | [1,] | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 10 10 | set([ @@ -175,18 +183,19 @@ C405.py:13:1: C405 [*] Unnecessary tuple literal (rewrite as a set literal) 17 15 | [1,] 18 16 | ) -C405.py:16:1: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:16:1 | 14 | (1,) 15 | ) 16 | / set( 17 | | [1,] 18 | | ) - | |_^ C405 + | |_^ 19 | f"{set([1,2,3])}" 20 | f"{set(['a', 'b'])}" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 13 13 | set( @@ -200,16 +209,17 @@ C405.py:16:1: C405 [*] Unnecessary list literal (rewrite as a set literal) 20 18 | f"{set(['a', 'b'])}" 21 19 | f'{set(["a", "b"])}' -C405.py:19:4: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:19:4 | 17 | [1,] 18 | ) 19 | f"{set([1,2,3])}" - | ^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^ 20 | f"{set(['a', 'b'])}" 21 | f'{set(["a", "b"])}' | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 16 16 | set( @@ -221,15 +231,16 @@ C405.py:19:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 21 21 | f'{set(["a", "b"])}' 22 22 | -C405.py:20:4: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:20:4 | 18 | ) 19 | f"{set([1,2,3])}" 20 | f"{set(['a', 'b'])}" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 21 | f'{set(["a", "b"])}' | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 17 17 | [1,] @@ -241,16 +252,17 @@ C405.py:20:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 22 22 | 23 23 | f"{set(['a', 'b']) - set(['a'])}" -C405.py:21:4: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:21:4 | 19 | f"{set([1,2,3])}" 20 | f"{set(['a', 'b'])}" 21 | f'{set(["a", "b"])}' - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 22 | 23 | f"{set(['a', 'b']) - set(['a'])}" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 18 18 | ) @@ -262,16 +274,17 @@ C405.py:21:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 23 23 | f"{set(['a', 'b']) - set(['a'])}" 24 24 | f"{ set(['a', 'b']) - set(['a']) }" -C405.py:23:4: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:23:4 | 21 | f'{set(["a", "b"])}' 22 | 23 | f"{set(['a', 'b']) - set(['a'])}" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 24 | f"{ set(['a', 'b']) - set(['a']) }" 25 | f"a {set(['a', 'b']) - set(['a'])} b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 20 20 | f"{set(['a', 'b'])}" @@ -283,16 +296,17 @@ C405.py:23:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 25 25 | f"a {set(['a', 'b']) - set(['a'])} b" 26 26 | f"a { set(['a', 'b']) - set(['a']) } b" -C405.py:23:22: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:23:22 | 21 | f'{set(["a", "b"])}' 22 | 23 | f"{set(['a', 'b']) - set(['a'])}" - | ^^^^^^^^^^ C405 + | ^^^^^^^^^^ 24 | f"{ set(['a', 'b']) - set(['a']) }" 25 | f"a {set(['a', 'b']) - set(['a'])} b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 20 20 | f"{set(['a', 'b'])}" @@ -304,15 +318,16 @@ C405.py:23:22: C405 [*] Unnecessary list literal (rewrite as a set literal) 25 25 | f"a {set(['a', 'b']) - set(['a'])} b" 26 26 | f"a { set(['a', 'b']) - set(['a']) } b" -C405.py:24:5: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:24:5 | 23 | f"{set(['a', 'b']) - set(['a'])}" 24 | f"{ set(['a', 'b']) - set(['a']) }" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 25 | f"a {set(['a', 'b']) - set(['a'])} b" 26 | f"a { set(['a', 'b']) - set(['a']) } b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 21 21 | f'{set(["a", "b"])}' @@ -324,15 +339,16 @@ C405.py:24:5: C405 [*] Unnecessary list literal (rewrite as a set literal) 26 26 | f"a { set(['a', 'b']) - set(['a']) } b" 27 27 | -C405.py:24:23: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:24:23 | 23 | f"{set(['a', 'b']) - set(['a'])}" 24 | f"{ set(['a', 'b']) - set(['a']) }" - | ^^^^^^^^^^ C405 + | ^^^^^^^^^^ 25 | f"a {set(['a', 'b']) - set(['a'])} b" 26 | f"a { set(['a', 'b']) - set(['a']) } b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 21 21 | f'{set(["a", "b"])}' @@ -344,15 +360,16 @@ C405.py:24:23: C405 [*] Unnecessary list literal (rewrite as a set literal) 26 26 | f"a { set(['a', 'b']) - set(['a']) } b" 27 27 | -C405.py:25:6: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:25:6 | 23 | f"{set(['a', 'b']) - set(['a'])}" 24 | f"{ set(['a', 'b']) - set(['a']) }" 25 | f"a {set(['a', 'b']) - set(['a'])} b" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 26 | f"a { set(['a', 'b']) - set(['a']) } b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 22 22 | @@ -364,15 +381,16 @@ C405.py:25:6: C405 [*] Unnecessary list literal (rewrite as a set literal) 27 27 | 28 28 | t"{set([1,2,3])}" -C405.py:25:24: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:25:24 | 23 | f"{set(['a', 'b']) - set(['a'])}" 24 | f"{ set(['a', 'b']) - set(['a']) }" 25 | f"a {set(['a', 'b']) - set(['a'])} b" - | ^^^^^^^^^^ C405 + | ^^^^^^^^^^ 26 | f"a { set(['a', 'b']) - set(['a']) } b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 22 22 | @@ -384,16 +402,17 @@ C405.py:25:24: C405 [*] Unnecessary list literal (rewrite as a set literal) 27 27 | 28 28 | t"{set([1,2,3])}" -C405.py:26:7: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:26:7 | 24 | f"{ set(['a', 'b']) - set(['a']) }" 25 | f"a {set(['a', 'b']) - set(['a'])} b" 26 | f"a { set(['a', 'b']) - set(['a']) } b" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 27 | 28 | t"{set([1,2,3])}" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 23 23 | f"{set(['a', 'b']) - set(['a'])}" @@ -405,16 +424,17 @@ C405.py:26:7: C405 [*] Unnecessary list literal (rewrite as a set literal) 28 28 | t"{set([1,2,3])}" 29 29 | t"{set(['a', 'b'])}" -C405.py:26:25: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:26:25 | 24 | f"{ set(['a', 'b']) - set(['a']) }" 25 | f"a {set(['a', 'b']) - set(['a'])} b" 26 | f"a { set(['a', 'b']) - set(['a']) } b" - | ^^^^^^^^^^ C405 + | ^^^^^^^^^^ 27 | 28 | t"{set([1,2,3])}" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 23 23 | f"{set(['a', 'b']) - set(['a'])}" @@ -426,16 +446,17 @@ C405.py:26:25: C405 [*] Unnecessary list literal (rewrite as a set literal) 28 28 | t"{set([1,2,3])}" 29 29 | t"{set(['a', 'b'])}" -C405.py:28:4: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:28:4 | 26 | f"a { set(['a', 'b']) - set(['a']) } b" 27 | 28 | t"{set([1,2,3])}" - | ^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^ 29 | t"{set(['a', 'b'])}" 30 | t'{set(["a", "b"])}' | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 25 25 | f"a {set(['a', 'b']) - set(['a'])} b" @@ -447,14 +468,15 @@ C405.py:28:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 30 30 | t'{set(["a", "b"])}' 31 31 | -C405.py:29:4: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:29:4 | 28 | t"{set([1,2,3])}" 29 | t"{set(['a', 'b'])}" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 30 | t'{set(["a", "b"])}' | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 26 26 | f"a { set(['a', 'b']) - set(['a']) } b" @@ -466,16 +488,17 @@ C405.py:29:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 31 31 | 32 32 | t"{set(['a', 'b']) - set(['a'])}" -C405.py:30:4: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:30:4 | 28 | t"{set([1,2,3])}" 29 | t"{set(['a', 'b'])}" 30 | t'{set(["a", "b"])}' - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 31 | 32 | t"{set(['a', 'b']) - set(['a'])}" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 27 27 | @@ -487,16 +510,17 @@ C405.py:30:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 32 32 | t"{set(['a', 'b']) - set(['a'])}" 33 33 | t"{ set(['a', 'b']) - set(['a']) }" -C405.py:32:4: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:32:4 | 30 | t'{set(["a", "b"])}' 31 | 32 | t"{set(['a', 'b']) - set(['a'])}" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 33 | t"{ set(['a', 'b']) - set(['a']) }" 34 | t"a {set(['a', 'b']) - set(['a'])} b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 29 29 | t"{set(['a', 'b'])}" @@ -508,16 +532,17 @@ C405.py:32:4: C405 [*] Unnecessary list literal (rewrite as a set literal) 34 34 | t"a {set(['a', 'b']) - set(['a'])} b" 35 35 | t"a { set(['a', 'b']) - set(['a']) } b" -C405.py:32:22: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:32:22 | 30 | t'{set(["a", "b"])}' 31 | 32 | t"{set(['a', 'b']) - set(['a'])}" - | ^^^^^^^^^^ C405 + | ^^^^^^^^^^ 33 | t"{ set(['a', 'b']) - set(['a']) }" 34 | t"a {set(['a', 'b']) - set(['a'])} b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 29 29 | t"{set(['a', 'b'])}" @@ -529,15 +554,16 @@ C405.py:32:22: C405 [*] Unnecessary list literal (rewrite as a set literal) 34 34 | t"a {set(['a', 'b']) - set(['a'])} b" 35 35 | t"a { set(['a', 'b']) - set(['a']) } b" -C405.py:33:5: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:33:5 | 32 | t"{set(['a', 'b']) - set(['a'])}" 33 | t"{ set(['a', 'b']) - set(['a']) }" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 34 | t"a {set(['a', 'b']) - set(['a'])} b" 35 | t"a { set(['a', 'b']) - set(['a']) } b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 30 30 | t'{set(["a", "b"])}' @@ -548,15 +574,16 @@ C405.py:33:5: C405 [*] Unnecessary list literal (rewrite as a set literal) 34 34 | t"a {set(['a', 'b']) - set(['a'])} b" 35 35 | t"a { set(['a', 'b']) - set(['a']) } b" -C405.py:33:23: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:33:23 | 32 | t"{set(['a', 'b']) - set(['a'])}" 33 | t"{ set(['a', 'b']) - set(['a']) }" - | ^^^^^^^^^^ C405 + | ^^^^^^^^^^ 34 | t"a {set(['a', 'b']) - set(['a'])} b" 35 | t"a { set(['a', 'b']) - set(['a']) } b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 30 30 | t'{set(["a", "b"])}' @@ -567,15 +594,16 @@ C405.py:33:23: C405 [*] Unnecessary list literal (rewrite as a set literal) 34 34 | t"a {set(['a', 'b']) - set(['a'])} b" 35 35 | t"a { set(['a', 'b']) - set(['a']) } b" -C405.py:34:6: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:34:6 | 32 | t"{set(['a', 'b']) - set(['a'])}" 33 | t"{ set(['a', 'b']) - set(['a']) }" 34 | t"a {set(['a', 'b']) - set(['a'])} b" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ 35 | t"a { set(['a', 'b']) - set(['a']) } b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 31 31 | @@ -585,15 +613,16 @@ C405.py:34:6: C405 [*] Unnecessary list literal (rewrite as a set literal) 34 |+t"a { {'a', 'b'} - set(['a'])} b" 35 35 | t"a { set(['a', 'b']) - set(['a']) } b" -C405.py:34:24: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:34:24 | 32 | t"{set(['a', 'b']) - set(['a'])}" 33 | t"{ set(['a', 'b']) - set(['a']) }" 34 | t"a {set(['a', 'b']) - set(['a'])} b" - | ^^^^^^^^^^ C405 + | ^^^^^^^^^^ 35 | t"a { set(['a', 'b']) - set(['a']) } b" | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 31 31 | @@ -603,14 +632,15 @@ C405.py:34:24: C405 [*] Unnecessary list literal (rewrite as a set literal) 34 |+t"a {set(['a', 'b']) - {'a'} } b" 35 35 | t"a { set(['a', 'b']) - set(['a']) } b" -C405.py:35:7: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:35:7 | 33 | t"{ set(['a', 'b']) - set(['a']) }" 34 | t"a {set(['a', 'b']) - set(['a'])} b" 35 | t"a { set(['a', 'b']) - set(['a']) } b" - | ^^^^^^^^^^^^^^^ C405 + | ^^^^^^^^^^^^^^^ | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 32 32 | t"{set(['a', 'b']) - set(['a'])}" @@ -619,14 +649,15 @@ C405.py:35:7: C405 [*] Unnecessary list literal (rewrite as a set literal) 35 |-t"a { set(['a', 'b']) - set(['a']) } b" 35 |+t"a { {'a', 'b'} - set(['a']) } b" -C405.py:35:25: C405 [*] Unnecessary list literal (rewrite as a set literal) +C405 [*] Unnecessary list literal (rewrite as a set literal) + --> C405.py:35:25 | 33 | t"{ set(['a', 'b']) - set(['a']) }" 34 | t"a {set(['a', 'b']) - set(['a'])} b" 35 | t"a { set(['a', 'b']) - set(['a']) } b" - | ^^^^^^^^^^ C405 + | ^^^^^^^^^^ | - = help: Rewrite as a set literal +help: Rewrite as a set literal ℹ Unsafe fix 32 32 | t"{set(['a', 'b']) - set(['a'])}" diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap index c8a3853bc1..f5bbcf7cab 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C406.py:1:6: C406 [*] Unnecessary list literal (rewrite as a dict literal) +C406 [*] Unnecessary list literal (rewrite as a dict literal) + --> C406.py:1:6 | 1 | d1 = dict([(1, 2)]) - | ^^^^^^^^^^^^^^ C406 + | ^^^^^^^^^^^^^^ 2 | d2 = dict(((1, 2),)) 3 | d3 = dict([]) | - = help: Rewrite as a dict literal +help: Rewrite as a dict literal ℹ Unsafe fix 1 |-d1 = dict([(1, 2)]) @@ -17,15 +18,16 @@ C406.py:1:6: C406 [*] Unnecessary list literal (rewrite as a dict literal) 3 3 | d3 = dict([]) 4 4 | d4 = dict(()) -C406.py:2:6: C406 [*] Unnecessary tuple literal (rewrite as a dict literal) +C406 [*] Unnecessary tuple literal (rewrite as a dict literal) + --> C406.py:2:6 | 1 | d1 = dict([(1, 2)]) 2 | d2 = dict(((1, 2),)) - | ^^^^^^^^^^^^^^^ C406 + | ^^^^^^^^^^^^^^^ 3 | d3 = dict([]) 4 | d4 = dict(()) | - = help: Rewrite as a dict literal +help: Rewrite as a dict literal ℹ Unsafe fix 1 1 | d1 = dict([(1, 2)]) @@ -35,16 +37,17 @@ C406.py:2:6: C406 [*] Unnecessary tuple literal (rewrite as a dict literal) 4 4 | d4 = dict(()) 5 5 | d5 = dict() -C406.py:3:6: C406 [*] Unnecessary list literal (rewrite as a dict literal) +C406 [*] Unnecessary list literal (rewrite as a dict literal) + --> C406.py:3:6 | 1 | d1 = dict([(1, 2)]) 2 | d2 = dict(((1, 2),)) 3 | d3 = dict([]) - | ^^^^^^^^ C406 + | ^^^^^^^^ 4 | d4 = dict(()) 5 | d5 = dict() | - = help: Rewrite as a dict literal +help: Rewrite as a dict literal ℹ Unsafe fix 1 1 | d1 = dict([(1, 2)]) @@ -54,15 +57,16 @@ C406.py:3:6: C406 [*] Unnecessary list literal (rewrite as a dict literal) 4 4 | d4 = dict(()) 5 5 | d5 = dict() -C406.py:4:6: C406 [*] Unnecessary tuple literal (rewrite as a dict literal) +C406 [*] Unnecessary tuple literal (rewrite as a dict literal) + --> C406.py:4:6 | 2 | d2 = dict(((1, 2),)) 3 | d3 = dict([]) 4 | d4 = dict(()) - | ^^^^^^^^ C406 + | ^^^^^^^^ 5 | d5 = dict() | - = help: Rewrite as a dict literal +help: Rewrite as a dict literal ℹ Unsafe fix 1 1 | d1 = dict([(1, 2)]) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap index e9519927ac..7b3de16c91 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C408.py:1:5: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) +C408 [*] Unnecessary `tuple()` call (rewrite as a literal) + --> C408.py:1:5 | 1 | t = tuple() - | ^^^^^^^ C408 + | ^^^^^^^ 2 | l = list() 3 | d1 = dict() | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 1 |-t = tuple() @@ -17,15 +18,16 @@ C408.py:1:5: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) 3 3 | d1 = dict() 4 4 | d2 = dict(a=1) -C408.py:2:5: C408 [*] Unnecessary `list()` call (rewrite as a literal) +C408 [*] Unnecessary `list()` call (rewrite as a literal) + --> C408.py:2:5 | 1 | t = tuple() 2 | l = list() - | ^^^^^^ C408 + | ^^^^^^ 3 | d1 = dict() 4 | d2 = dict(a=1) | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 1 1 | t = tuple() @@ -35,16 +37,17 @@ C408.py:2:5: C408 [*] Unnecessary `list()` call (rewrite as a literal) 4 4 | d2 = dict(a=1) 5 5 | d3 = dict(**d2) -C408.py:3:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:3:6 | 1 | t = tuple() 2 | l = list() 3 | d1 = dict() - | ^^^^^^ C408 + | ^^^^^^ 4 | d2 = dict(a=1) 5 | d3 = dict(**d2) | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 1 1 | t = tuple() @@ -55,15 +58,16 @@ C408.py:3:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 5 5 | d3 = dict(**d2) 6 6 | -C408.py:4:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:4:6 | 2 | l = list() 3 | d1 = dict() 4 | d2 = dict(a=1) - | ^^^^^^^^^ C408 + | ^^^^^^^^^ 5 | d3 = dict(**d2) | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 1 1 | t = tuple() @@ -75,16 +79,17 @@ C408.py:4:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 6 6 | 7 7 | -C408.py:14:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:14:4 | 12 | a = list() 13 | 14 | f"{dict(x='y')}" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 15 | f'{dict(x="y")}' 16 | f"{dict()}" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 11 11 | @@ -96,15 +101,16 @@ C408.py:14:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 16 16 | f"{dict()}" 17 17 | f"a {dict()} b" -C408.py:15:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:15:4 | 14 | f"{dict(x='y')}" 15 | f'{dict(x="y")}' - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 16 | f"{dict()}" 17 | f"a {dict()} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 12 12 | a = list() @@ -116,15 +122,16 @@ C408.py:15:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 17 17 | f"a {dict()} b" 18 18 | -C408.py:16:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:16:4 | 14 | f"{dict(x='y')}" 15 | f'{dict(x="y")}' 16 | f"{dict()}" - | ^^^^^^ C408 + | ^^^^^^ 17 | f"a {dict()} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 13 13 | @@ -136,16 +143,17 @@ C408.py:16:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 18 18 | 19 19 | f"{dict(x='y') | dict(y='z')}" -C408.py:17:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:17:6 | 15 | f'{dict(x="y")}' 16 | f"{dict()}" 17 | f"a {dict()} b" - | ^^^^^^ C408 + | ^^^^^^ 18 | 19 | f"{dict(x='y') | dict(y='z')}" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 14 14 | f"{dict(x='y')}" @@ -157,16 +165,17 @@ C408.py:17:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 19 19 | f"{dict(x='y') | dict(y='z')}" 20 20 | f"{ dict(x='y') | dict(y='z') }" -C408.py:19:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:19:4 | 17 | f"a {dict()} b" 18 | 19 | f"{dict(x='y') | dict(y='z')}" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 20 | f"{ dict(x='y') | dict(y='z') }" 21 | f"a {dict(x='y') | dict(y='z')} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 16 16 | f"{dict()}" @@ -178,16 +187,17 @@ C408.py:19:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 21 21 | f"a {dict(x='y') | dict(y='z')} b" 22 22 | f"a { dict(x='y') | dict(y='z') } b" -C408.py:19:18: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:19:18 | 17 | f"a {dict()} b" 18 | 19 | f"{dict(x='y') | dict(y='z')}" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 20 | f"{ dict(x='y') | dict(y='z') }" 21 | f"a {dict(x='y') | dict(y='z')} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 16 16 | f"{dict()}" @@ -199,15 +209,16 @@ C408.py:19:18: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 21 21 | f"a {dict(x='y') | dict(y='z')} b" 22 22 | f"a { dict(x='y') | dict(y='z') } b" -C408.py:20:5: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:20:5 | 19 | f"{dict(x='y') | dict(y='z')}" 20 | f"{ dict(x='y') | dict(y='z') }" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 21 | f"a {dict(x='y') | dict(y='z')} b" 22 | f"a { dict(x='y') | dict(y='z') } b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 17 17 | f"a {dict()} b" @@ -219,15 +230,16 @@ C408.py:20:5: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 22 22 | f"a { dict(x='y') | dict(y='z') } b" 23 23 | -C408.py:20:19: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:20:19 | 19 | f"{dict(x='y') | dict(y='z')}" 20 | f"{ dict(x='y') | dict(y='z') }" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 21 | f"a {dict(x='y') | dict(y='z')} b" 22 | f"a { dict(x='y') | dict(y='z') } b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 17 17 | f"a {dict()} b" @@ -239,15 +251,16 @@ C408.py:20:19: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 22 22 | f"a { dict(x='y') | dict(y='z') } b" 23 23 | -C408.py:21:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:21:6 | 19 | f"{dict(x='y') | dict(y='z')}" 20 | f"{ dict(x='y') | dict(y='z') }" 21 | f"a {dict(x='y') | dict(y='z')} b" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 22 | f"a { dict(x='y') | dict(y='z') } b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 18 18 | @@ -259,15 +272,16 @@ C408.py:21:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 23 23 | 24 24 | dict( -C408.py:21:20: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:21:20 | 19 | f"{dict(x='y') | dict(y='z')}" 20 | f"{ dict(x='y') | dict(y='z') }" 21 | f"a {dict(x='y') | dict(y='z')} b" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 22 | f"a { dict(x='y') | dict(y='z') } b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 18 18 | @@ -279,16 +293,17 @@ C408.py:21:20: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 23 23 | 24 24 | dict( -C408.py:22:7: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:22:7 | 20 | f"{ dict(x='y') | dict(y='z') }" 21 | f"a {dict(x='y') | dict(y='z')} b" 22 | f"a { dict(x='y') | dict(y='z') } b" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 23 | 24 | dict( | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 19 19 | f"{dict(x='y') | dict(y='z')}" @@ -300,16 +315,17 @@ C408.py:22:7: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 24 24 | dict( 25 25 | # comment -C408.py:22:21: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:22:21 | 20 | f"{ dict(x='y') | dict(y='z') }" 21 | f"a {dict(x='y') | dict(y='z')} b" 22 | f"a { dict(x='y') | dict(y='z') } b" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 23 | 24 | dict( | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 19 19 | f"{dict(x='y') | dict(y='z')}" @@ -321,18 +337,19 @@ C408.py:22:21: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 24 24 | dict( 25 25 | # comment -C408.py:24:1: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:24:1 | 22 | f"a { dict(x='y') | dict(y='z') } b" 23 | 24 | / dict( 25 | | # comment 26 | | ) - | |_^ C408 + | |_^ 27 | 28 | tuple( # comment | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 21 21 | f"a {dict(x='y') | dict(y='z')} b" @@ -347,17 +364,18 @@ C408.py:24:1: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 28 28 | tuple( # comment 29 29 | ) -C408.py:28:1: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) +C408 [*] Unnecessary `tuple()` call (rewrite as a literal) + --> C408.py:28:1 | 26 | ) 27 | 28 | / tuple( # comment 29 | | ) - | |_^ C408 + | |_^ 30 | 31 | t"{dict(x='y')}" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 25 25 | # comment @@ -369,16 +387,17 @@ C408.py:28:1: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) 30 30 | 31 31 | t"{dict(x='y')}" -C408.py:31:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:31:4 | 29 | ) 30 | 31 | t"{dict(x='y')}" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 32 | t'{dict(x="y")}' 33 | t"{dict()}" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 28 28 | tuple( # comment @@ -390,15 +409,16 @@ C408.py:31:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 33 33 | t"{dict()}" 34 34 | t"a {dict()} b" -C408.py:32:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:32:4 | 31 | t"{dict(x='y')}" 32 | t'{dict(x="y")}' - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 33 | t"{dict()}" 34 | t"a {dict()} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 29 29 | ) @@ -410,15 +430,16 @@ C408.py:32:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 34 34 | t"a {dict()} b" 35 35 | -C408.py:33:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:33:4 | 31 | t"{dict(x='y')}" 32 | t'{dict(x="y")}' 33 | t"{dict()}" - | ^^^^^^ C408 + | ^^^^^^ 34 | t"a {dict()} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 30 30 | @@ -430,16 +451,17 @@ C408.py:33:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 35 35 | 36 36 | t"{dict(x='y') | dict(y='z')}" -C408.py:34:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:34:6 | 32 | t'{dict(x="y")}' 33 | t"{dict()}" 34 | t"a {dict()} b" - | ^^^^^^ C408 + | ^^^^^^ 35 | 36 | t"{dict(x='y') | dict(y='z')}" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 31 31 | t"{dict(x='y')}" @@ -451,16 +473,17 @@ C408.py:34:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 36 36 | t"{dict(x='y') | dict(y='z')}" 37 37 | t"{ dict(x='y') | dict(y='z') }" -C408.py:36:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:36:4 | 34 | t"a {dict()} b" 35 | 36 | t"{dict(x='y') | dict(y='z')}" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 37 | t"{ dict(x='y') | dict(y='z') }" 38 | t"a {dict(x='y') | dict(y='z')} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 33 33 | t"{dict()}" @@ -472,16 +495,17 @@ C408.py:36:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 38 38 | t"a {dict(x='y') | dict(y='z')} b" 39 39 | t"a { dict(x='y') | dict(y='z') } b" -C408.py:36:18: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:36:18 | 34 | t"a {dict()} b" 35 | 36 | t"{dict(x='y') | dict(y='z')}" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 37 | t"{ dict(x='y') | dict(y='z') }" 38 | t"a {dict(x='y') | dict(y='z')} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 33 33 | t"{dict()}" @@ -493,15 +517,16 @@ C408.py:36:18: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 38 38 | t"a {dict(x='y') | dict(y='z')} b" 39 39 | t"a { dict(x='y') | dict(y='z') } b" -C408.py:37:5: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:37:5 | 36 | t"{dict(x='y') | dict(y='z')}" 37 | t"{ dict(x='y') | dict(y='z') }" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 38 | t"a {dict(x='y') | dict(y='z')} b" 39 | t"a { dict(x='y') | dict(y='z') } b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 34 34 | t"a {dict()} b" @@ -512,15 +537,16 @@ C408.py:37:5: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 38 38 | t"a {dict(x='y') | dict(y='z')} b" 39 39 | t"a { dict(x='y') | dict(y='z') } b" -C408.py:37:19: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:37:19 | 36 | t"{dict(x='y') | dict(y='z')}" 37 | t"{ dict(x='y') | dict(y='z') }" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 38 | t"a {dict(x='y') | dict(y='z')} b" 39 | t"a { dict(x='y') | dict(y='z') } b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 34 34 | t"a {dict()} b" @@ -531,15 +557,16 @@ C408.py:37:19: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 38 38 | t"a {dict(x='y') | dict(y='z')} b" 39 39 | t"a { dict(x='y') | dict(y='z') } b" -C408.py:38:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:38:6 | 36 | t"{dict(x='y') | dict(y='z')}" 37 | t"{ dict(x='y') | dict(y='z') }" 38 | t"a {dict(x='y') | dict(y='z')} b" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 39 | t"a { dict(x='y') | dict(y='z') } b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 35 35 | @@ -549,15 +576,16 @@ C408.py:38:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 38 |+t"a { {'x': 'y'} | dict(y='z')} b" 39 39 | t"a { dict(x='y') | dict(y='z') } b" -C408.py:38:20: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:38:20 | 36 | t"{dict(x='y') | dict(y='z')}" 37 | t"{ dict(x='y') | dict(y='z') }" 38 | t"a {dict(x='y') | dict(y='z')} b" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ 39 | t"a { dict(x='y') | dict(y='z') } b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 35 35 | @@ -567,14 +595,15 @@ C408.py:38:20: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 38 |+t"a {dict(x='y') | {'y': 'z'} } b" 39 39 | t"a { dict(x='y') | dict(y='z') } b" -C408.py:39:7: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:39:7 | 37 | t"{ dict(x='y') | dict(y='z') }" 38 | t"a {dict(x='y') | dict(y='z')} b" 39 | t"a { dict(x='y') | dict(y='z') } b" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 36 36 | t"{dict(x='y') | dict(y='z')}" @@ -583,14 +612,15 @@ C408.py:39:7: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 39 |-t"a { dict(x='y') | dict(y='z') } b" 39 |+t"a { {'x': 'y'} | dict(y='z') } b" -C408.py:39:21: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:39:21 | 37 | t"{ dict(x='y') | dict(y='z') }" 38 | t"a {dict(x='y') | dict(y='z')} b" 39 | t"a { dict(x='y') | dict(y='z') } b" - | ^^^^^^^^^^^ C408 + | ^^^^^^^^^^^ | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 36 36 | t"{dict(x='y') | dict(y='z')}" diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap index 9e7e51df20..463e737348 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C408.py:1:5: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) +C408 [*] Unnecessary `tuple()` call (rewrite as a literal) + --> C408.py:1:5 | 1 | t = tuple() - | ^^^^^^^ C408 + | ^^^^^^^ 2 | l = list() 3 | d1 = dict() | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 1 |-t = tuple() @@ -17,15 +18,16 @@ C408.py:1:5: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) 3 3 | d1 = dict() 4 4 | d2 = dict(a=1) -C408.py:2:5: C408 [*] Unnecessary `list()` call (rewrite as a literal) +C408 [*] Unnecessary `list()` call (rewrite as a literal) + --> C408.py:2:5 | 1 | t = tuple() 2 | l = list() - | ^^^^^^ C408 + | ^^^^^^ 3 | d1 = dict() 4 | d2 = dict(a=1) | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 1 1 | t = tuple() @@ -35,16 +37,17 @@ C408.py:2:5: C408 [*] Unnecessary `list()` call (rewrite as a literal) 4 4 | d2 = dict(a=1) 5 5 | d3 = dict(**d2) -C408.py:3:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:3:6 | 1 | t = tuple() 2 | l = list() 3 | d1 = dict() - | ^^^^^^ C408 + | ^^^^^^ 4 | d2 = dict(a=1) 5 | d3 = dict(**d2) | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 1 1 | t = tuple() @@ -55,15 +58,16 @@ C408.py:3:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 5 5 | d3 = dict(**d2) 6 6 | -C408.py:16:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:16:4 | 14 | f"{dict(x='y')}" 15 | f'{dict(x="y")}' 16 | f"{dict()}" - | ^^^^^^ C408 + | ^^^^^^ 17 | f"a {dict()} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 13 13 | @@ -75,16 +79,17 @@ C408.py:16:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 18 18 | 19 19 | f"{dict(x='y') | dict(y='z')}" -C408.py:17:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:17:6 | 15 | f'{dict(x="y")}' 16 | f"{dict()}" 17 | f"a {dict()} b" - | ^^^^^^ C408 + | ^^^^^^ 18 | 19 | f"{dict(x='y') | dict(y='z')}" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 14 14 | f"{dict(x='y')}" @@ -96,18 +101,19 @@ C408.py:17:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 19 19 | f"{dict(x='y') | dict(y='z')}" 20 20 | f"{ dict(x='y') | dict(y='z') }" -C408.py:24:1: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:24:1 | 22 | f"a { dict(x='y') | dict(y='z') } b" 23 | 24 | / dict( 25 | | # comment 26 | | ) - | |_^ C408 + | |_^ 27 | 28 | tuple( # comment | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 21 21 | f"a {dict(x='y') | dict(y='z')} b" @@ -122,17 +128,18 @@ C408.py:24:1: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 28 28 | tuple( # comment 29 29 | ) -C408.py:28:1: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) +C408 [*] Unnecessary `tuple()` call (rewrite as a literal) + --> C408.py:28:1 | 26 | ) 27 | 28 | / tuple( # comment 29 | | ) - | |_^ C408 + | |_^ 30 | 31 | t"{dict(x='y')}" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 25 25 | # comment @@ -144,15 +151,16 @@ C408.py:28:1: C408 [*] Unnecessary `tuple()` call (rewrite as a literal) 30 30 | 31 31 | t"{dict(x='y')}" -C408.py:33:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:33:4 | 31 | t"{dict(x='y')}" 32 | t'{dict(x="y")}' 33 | t"{dict()}" - | ^^^^^^ C408 + | ^^^^^^ 34 | t"a {dict()} b" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 30 30 | @@ -164,16 +172,17 @@ C408.py:33:4: C408 [*] Unnecessary `dict()` call (rewrite as a literal) 35 35 | 36 36 | t"{dict(x='y') | dict(y='z')}" -C408.py:34:6: C408 [*] Unnecessary `dict()` call (rewrite as a literal) +C408 [*] Unnecessary `dict()` call (rewrite as a literal) + --> C408.py:34:6 | 32 | t'{dict(x="y")}' 33 | t"{dict()}" 34 | t"a {dict()} b" - | ^^^^^^ C408 + | ^^^^^^ 35 | 36 | t"{dict(x='y') | dict(y='z')}" | - = help: Rewrite as a literal +help: Rewrite as a literal ℹ Unsafe fix 31 31 | t"{dict(x='y')}" diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap index 3b2fd728cc..c4b3f267d2 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C409.py:1:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:1:6 | 1 | t1 = tuple([]) - | ^^^^^^^^^ C409 + | ^^^^^^^^^ 2 | t2 = tuple([1, 2]) 3 | t3 = tuple((1, 2)) | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 1 |-t1 = tuple([]) @@ -17,15 +18,16 @@ C409.py:1:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a 3 3 | t3 = tuple((1, 2)) 4 4 | t4 = tuple([ -C409.py:2:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:2:6 | 1 | t1 = tuple([]) 2 | t2 = tuple([1, 2]) - | ^^^^^^^^^^^^^ C409 + | ^^^^^^^^^^^^^ 3 | t3 = tuple((1, 2)) 4 | t4 = tuple([ | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 1 1 | t1 = tuple([]) @@ -35,16 +37,17 @@ C409.py:2:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a 4 4 | t4 = tuple([ 5 5 | 1, -C409.py:3:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) +C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) + --> C409.py:3:6 | 1 | t1 = tuple([]) 2 | t2 = tuple([1, 2]) 3 | t3 = tuple((1, 2)) - | ^^^^^^^^^^^^^ C409 + | ^^^^^^^^^^^^^ 4 | t4 = tuple([ 5 | 1, | - = help: Remove the outer call to `tuple()` +help: Remove the outer call to `tuple()` ℹ Unsafe fix 1 1 | t1 = tuple([]) @@ -55,7 +58,8 @@ C409.py:3:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 5 5 | 1, 6 6 | 2 -C409.py:4:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:4:6 | 2 | t2 = tuple([1, 2]) 3 | t3 = tuple((1, 2)) @@ -64,11 +68,11 @@ C409.py:4:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a 5 | | 1, 6 | | 2 7 | | ]) - | |__^ C409 + | |__^ 8 | t5 = tuple( 9 | (1, 2) | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 1 1 | t1 = tuple([]) @@ -84,7 +88,8 @@ C409.py:4:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a 9 9 | (1, 2) 10 10 | ) -C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) +C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) + --> C409.py:8:6 | 6 | 2 7 | ]) @@ -92,11 +97,11 @@ C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the | ______^ 9 | | (1, 2) 10 | | ) - | |_^ C409 + | |_^ 11 | 12 | tuple( # comment | - = help: Remove the outer call to `tuple()` +help: Remove the outer call to `tuple()` ℹ Unsafe fix 5 5 | 1, @@ -110,18 +115,19 @@ C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 12 10 | tuple( # comment 13 11 | [1, 2] -C409.py:12:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:12:1 | 10 | ) 11 | 12 | / tuple( # comment 13 | | [1, 2] 14 | | ) - | |_^ C409 + | |_^ 15 | 16 | tuple([ # comment | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 9 9 | (1, 2) @@ -135,18 +141,19 @@ C409.py:12:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 16 14 | tuple([ # comment 17 15 | 1, 2 -C409.py:16:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:16:1 | 14 | ) 15 | 16 | / tuple([ # comment 17 | | 1, 2 18 | | ]) - | |__^ C409 + | |__^ 19 | 20 | tuple(( | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 13 13 | [1, 2] @@ -161,18 +168,19 @@ C409.py:16:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 20 20 | tuple(( 21 21 | 1, -C409.py:20:1: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) +C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) + --> C409.py:20:1 | 18 | ]) 19 | 20 | / tuple(( 21 | | 1, 22 | | )) - | |__^ C409 + | |__^ 23 | 24 | t6 = tuple([1]) | - = help: Remove the outer call to `tuple()` +help: Remove the outer call to `tuple()` ℹ Unsafe fix 17 17 | 1, 2 @@ -187,16 +195,17 @@ C409.py:20:1: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 24 24 | t6 = tuple([1]) 25 25 | t7 = tuple((1,)) -C409.py:24:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:24:6 | 22 | )) 23 | 24 | t6 = tuple([1]) - | ^^^^^^^^^^ C409 + | ^^^^^^^^^^ 25 | t7 = tuple((1,)) 26 | t8 = tuple([1,]) | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 21 21 | 1, @@ -208,14 +217,15 @@ C409.py:24:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 26 26 | t8 = tuple([1,]) 27 27 | -C409.py:25:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) +C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) + --> C409.py:25:6 | 24 | t6 = tuple([1]) 25 | t7 = tuple((1,)) - | ^^^^^^^^^^^ C409 + | ^^^^^^^^^^^ 26 | t8 = tuple([1,]) | - = help: Remove the outer call to `tuple()` +help: Remove the outer call to `tuple()` ℹ Unsafe fix 22 22 | )) @@ -227,16 +237,17 @@ C409.py:25:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 27 27 | 28 28 | tuple([x for x in range(5)]) -C409.py:26:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:26:6 | 24 | t6 = tuple([1]) 25 | t7 = tuple((1,)) 26 | t8 = tuple([1,]) - | ^^^^^^^^^^^ C409 + | ^^^^^^^^^^^ 27 | 28 | tuple([x for x in range(5)]) | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 23 23 | diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap index 35dd289c78..007c0a28f3 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C410.py:1:6: C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) +C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) + --> C410.py:1:6 | 1 | l1 = list([1, 2]) - | ^^^^^^^^^^^^ C410 + | ^^^^^^^^^^^^ 2 | l2 = list((1, 2)) 3 | l3 = list([]) | - = help: Remove outer `list()` call +help: Remove outer `list()` call ℹ Unsafe fix 1 |-l1 = list([1, 2]) @@ -17,15 +18,16 @@ C410.py:1:6: C410 [*] Unnecessary list literal passed to `list()` (remove the ou 3 3 | l3 = list([]) 4 4 | l4 = list(()) -C410.py:2:6: C410 [*] Unnecessary tuple literal passed to `list()` (rewrite as a single list literal) +C410 [*] Unnecessary tuple literal passed to `list()` (rewrite as a single list literal) + --> C410.py:2:6 | 1 | l1 = list([1, 2]) 2 | l2 = list((1, 2)) - | ^^^^^^^^^^^^ C410 + | ^^^^^^^^^^^^ 3 | l3 = list([]) 4 | l4 = list(()) | - = help: Rewrite as a single list literal +help: Rewrite as a single list literal ℹ Unsafe fix 1 1 | l1 = list([1, 2]) @@ -35,15 +37,16 @@ C410.py:2:6: C410 [*] Unnecessary tuple literal passed to `list()` (rewrite as a 4 4 | l4 = list(()) 5 5 | -C410.py:3:6: C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) +C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) + --> C410.py:3:6 | 1 | l1 = list([1, 2]) 2 | l2 = list((1, 2)) 3 | l3 = list([]) - | ^^^^^^^^ C410 + | ^^^^^^^^ 4 | l4 = list(()) | - = help: Remove outer `list()` call +help: Remove outer `list()` call ℹ Unsafe fix 1 1 | l1 = list([1, 2]) @@ -54,14 +57,15 @@ C410.py:3:6: C410 [*] Unnecessary list literal passed to `list()` (remove the ou 5 5 | 6 6 | -C410.py:4:6: C410 [*] Unnecessary tuple literal passed to `list()` (rewrite as a single list literal) +C410 [*] Unnecessary tuple literal passed to `list()` (rewrite as a single list literal) + --> C410.py:4:6 | 2 | l2 = list((1, 2)) 3 | l3 = list([]) 4 | l4 = list(()) - | ^^^^^^^^ C410 + | ^^^^^^^^ | - = help: Rewrite as a single list literal +help: Rewrite as a single list literal ℹ Unsafe fix 1 1 | l1 = list([1, 2]) @@ -73,16 +77,17 @@ C410.py:4:6: C410 [*] Unnecessary tuple literal passed to `list()` (rewrite as a 6 6 | 7 7 | list( # comment -C410.py:7:1: C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) +C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) + --> C410.py:7:1 | 7 | / list( # comment 8 | | [1, 2] 9 | | ) - | |_^ C410 + | |_^ 10 | 11 | list([ # comment | - = help: Remove outer `list()` call +help: Remove outer `list()` call ℹ Unsafe fix 4 4 | l4 = list(()) @@ -96,18 +101,19 @@ C410.py:7:1: C410 [*] Unnecessary list literal passed to `list()` (remove the ou 11 9 | list([ # comment 12 10 | 1, 2 -C410.py:11:1: C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) +C410 [*] Unnecessary list literal passed to `list()` (remove the outer call to `list()`) + --> C410.py:11:1 | 9 | ) 10 | 11 | / list([ # comment 12 | | 1, 2 13 | | ]) - | |__^ C410 + | |__^ 14 | 15 | # Skip when too many positional arguments | - = help: Remove outer `list()` call +help: Remove outer `list()` call ℹ Unsafe fix 8 8 | [1, 2] diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap index 84882a4674..97a9e26e57 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C411.py:2:1: C411 [*] Unnecessary `list()` call (remove the outer call to `list()`) +C411 [*] Unnecessary `list()` call (remove the outer call to `list()`) + --> C411.py:2:1 | 1 | x = [1, 2, 3] 2 | list([i for i in x]) - | ^^^^^^^^^^^^^^^^^^^^ C411 + | ^^^^^^^^^^^^^^^^^^^^ 3 | 4 | # Skip when too many positional arguments | - = help: Remove outer `list()` call +help: Remove outer `list()` call ℹ Unsafe fix 1 1 | x = [1, 2, 3] diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap index 5b131c59f2..ac89c788b0 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C413.py:3:1: C413 [*] Unnecessary `list()` call around `sorted()` +C413 [*] Unnecessary `list()` call around `sorted()` + --> C413.py:3:1 | 1 | x = [2, 3, 1] 2 | list(x) 3 | list(sorted(x)) - | ^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^ 4 | reversed(sorted(x)) 5 | reversed(sorted(x, key=lambda e: e)) | - = help: Remove unnecessary `list()` call +help: Remove unnecessary `list()` call ℹ Safe fix 1 1 | x = [2, 3, 1] @@ -21,16 +22,17 @@ C413.py:3:1: C413 [*] Unnecessary `list()` call around `sorted()` 5 5 | reversed(sorted(x, key=lambda e: e)) 6 6 | reversed(sorted(x, reverse=True)) -C413.py:4:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:4:1 | 2 | list(x) 3 | list(sorted(x)) 4 | reversed(sorted(x)) - | ^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^ 5 | reversed(sorted(x, key=lambda e: e)) 6 | reversed(sorted(x, reverse=True)) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 1 1 | x = [2, 3, 1] @@ -42,16 +44,17 @@ C413.py:4:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 6 6 | reversed(sorted(x, reverse=True)) 7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -C413.py:5:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:5:1 | 3 | list(sorted(x)) 4 | reversed(sorted(x)) 5 | reversed(sorted(x, key=lambda e: e)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | reversed(sorted(x, reverse=True)) 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 2 2 | list(x) @@ -63,16 +66,17 @@ C413.py:5:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) 8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -C413.py:6:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:6:1 | 4 | reversed(sorted(x)) 5 | reversed(sorted(x, key=lambda e: e)) 6 | reversed(sorted(x, reverse=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 3 3 | list(sorted(x)) @@ -84,16 +88,17 @@ C413.py:6:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) 9 9 | reversed(sorted(x, reverse=False)) -C413.py:7:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:7:1 | 5 | reversed(sorted(x, key=lambda e: e)) 6 | reversed(sorted(x, reverse=True)) 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) 9 | reversed(sorted(x, reverse=False)) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 4 4 | reversed(sorted(x)) @@ -105,16 +110,17 @@ C413.py:7:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 9 9 | reversed(sorted(x, reverse=False)) 10 10 | reversed(sorted(x, reverse=x)) -C413.py:8:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:8:1 | 6 | reversed(sorted(x, reverse=True)) 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | reversed(sorted(x, reverse=False)) 10 | reversed(sorted(x, reverse=x)) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 5 5 | reversed(sorted(x, key=lambda e: e)) @@ -126,16 +132,17 @@ C413.py:8:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 10 10 | reversed(sorted(x, reverse=x)) 11 11 | reversed(sorted(x, reverse=not x)) -C413.py:9:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:9:1 | 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) 9 | reversed(sorted(x, reverse=False)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | reversed(sorted(x, reverse=x)) 11 | reversed(sorted(x, reverse=not x)) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 6 6 | reversed(sorted(x, reverse=True)) @@ -147,15 +154,16 @@ C413.py:9:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 11 11 | reversed(sorted(x, reverse=not x)) 12 12 | -C413.py:10:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:10:1 | 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) 9 | reversed(sorted(x, reverse=False)) 10 | reversed(sorted(x, reverse=x)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | reversed(sorted(x, reverse=not x)) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) @@ -167,16 +175,17 @@ C413.py:10:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 12 12 | 13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -C413.py:11:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:11:1 | 9 | reversed(sorted(x, reverse=False)) 10 | reversed(sorted(x, reverse=x)) 11 | reversed(sorted(x, reverse=not x)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) @@ -188,14 +197,15 @@ C413.py:11:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 14 14 | reversed(sorted(i for i in range(42))) -C413.py:14:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:14:1 | 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 14 | reversed(sorted(i for i in range(42))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | reversed(sorted((i for i in range(42)), reverse=True)) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 11 11 | reversed(sorted(x, reverse=not x)) @@ -207,16 +217,17 @@ C413.py:14:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 16 16 | 17 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 -C413.py:15:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:15:1 | 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 14 | reversed(sorted(i for i in range(42))) 15 | reversed(sorted((i for i in range(42)), reverse=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 12 12 | @@ -228,14 +239,15 @@ C413.py:15:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 17 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 18 18 | reversed(sorted([1, 2, 3], reverse=False or True)) -C413.py:18:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:18:1 | 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 18 | reversed(sorted([1, 2, 3], reverse=False or True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | reversed(sorted([1, 2, 3], reverse=(False or True))) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 15 15 | reversed(sorted((i for i in range(42)), reverse=True)) @@ -247,16 +259,17 @@ C413.py:18:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 20 20 | 21 21 | # These fixes need to be parenthesized to avoid syntax errors and behavior -C413.py:19:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:19:1 | 17 | # Regression test for: https://github.com/astral-sh/ruff/issues/10335 18 | reversed(sorted([1, 2, 3], reverse=False or True)) 19 | reversed(sorted([1, 2, 3], reverse=(False or True))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | # These fixes need to be parenthesized to avoid syntax errors and behavior | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 16 16 | @@ -268,17 +281,18 @@ C413.py:19:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 21 21 | # These fixes need to be parenthesized to avoid syntax errors and behavior 22 22 | # changes. -C413.py:24:1: C413 [*] Unnecessary `reversed()` call around `sorted()` +C413 [*] Unnecessary `reversed()` call around `sorted()` + --> C413.py:24:1 | 22 | # changes. 23 | # See https://github.com/astral-sh/ruff/issues/15789 24 | / reversed(sorted 25 | | ("")) - | |_____^ C413 + | |_____^ 26 | list(sorted 27 | ("")) | - = help: Remove unnecessary `reversed()` call +help: Remove unnecessary `reversed()` call ℹ Unsafe fix 21 21 | # These fixes need to be parenthesized to avoid syntax errors and behavior @@ -292,17 +306,18 @@ C413.py:24:1: C413 [*] Unnecessary `reversed()` call around `sorted()` 27 27 | ("")) 28 28 | list(sorted -C413.py:26:1: C413 [*] Unnecessary `list()` call around `sorted()` +C413 [*] Unnecessary `list()` call around `sorted()` + --> C413.py:26:1 | 24 | reversed(sorted 25 | ("")) 26 | / list(sorted 27 | | ("")) - | |_________^ C413 + | |_________^ 28 | list(sorted 29 | ("xy")) | - = help: Remove unnecessary `list()` call +help: Remove unnecessary `list()` call ℹ Safe fix 23 23 | # See https://github.com/astral-sh/ruff/issues/15789 @@ -314,15 +329,16 @@ C413.py:26:1: C413 [*] Unnecessary `list()` call around `sorted()` 28 28 | list(sorted 29 29 | ("xy")) -C413.py:28:1: C413 [*] Unnecessary `list()` call around `sorted()` +C413 [*] Unnecessary `list()` call around `sorted()` + --> C413.py:28:1 | 26 | list(sorted 27 | ("")) 28 | / list(sorted 29 | | ("xy")) - | |_______^ C413 + | |_______^ | - = help: Remove unnecessary `list()` call +help: Remove unnecessary `list()` call ℹ Safe fix 25 25 | ("")) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap index af3a238f64..322fd197f9 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C414.py:2:1: C414 [*] Unnecessary `list()` call within `list()` +C414 [*] Unnecessary `list()` call within `list()` + --> C414.py:2:1 | 1 | x = [1, 2, 3] 2 | list(list(x)) - | ^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^ 3 | list(tuple(x)) 4 | tuple(list(x)) | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 1 1 | x = [1, 2, 3] @@ -19,16 +20,17 @@ C414.py:2:1: C414 [*] Unnecessary `list()` call within `list()` 4 4 | tuple(list(x)) 5 5 | tuple(tuple(x)) -C414.py:3:1: C414 [*] Unnecessary `tuple()` call within `list()` +C414 [*] Unnecessary `tuple()` call within `list()` + --> C414.py:3:1 | 1 | x = [1, 2, 3] 2 | list(list(x)) 3 | list(tuple(x)) - | ^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^ 4 | tuple(list(x)) 5 | tuple(tuple(x)) | - = help: Remove the inner `tuple()` call +help: Remove the inner `tuple()` call ℹ Unsafe fix 1 1 | x = [1, 2, 3] @@ -39,16 +41,17 @@ C414.py:3:1: C414 [*] Unnecessary `tuple()` call within `list()` 5 5 | tuple(tuple(x)) 6 6 | set(set(x)) -C414.py:4:1: C414 [*] Unnecessary `list()` call within `tuple()` +C414 [*] Unnecessary `list()` call within `tuple()` + --> C414.py:4:1 | 2 | list(list(x)) 3 | list(tuple(x)) 4 | tuple(list(x)) - | ^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^ 5 | tuple(tuple(x)) 6 | set(set(x)) | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 1 1 | x = [1, 2, 3] @@ -60,16 +63,17 @@ C414.py:4:1: C414 [*] Unnecessary `list()` call within `tuple()` 6 6 | set(set(x)) 7 7 | set(list(x)) -C414.py:5:1: C414 [*] Unnecessary `tuple()` call within `tuple()` +C414 [*] Unnecessary `tuple()` call within `tuple()` + --> C414.py:5:1 | 3 | list(tuple(x)) 4 | tuple(list(x)) 5 | tuple(tuple(x)) - | ^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^ 6 | set(set(x)) 7 | set(list(x)) | - = help: Remove the inner `tuple()` call +help: Remove the inner `tuple()` call ℹ Unsafe fix 2 2 | list(list(x)) @@ -81,16 +85,17 @@ C414.py:5:1: C414 [*] Unnecessary `tuple()` call within `tuple()` 7 7 | set(list(x)) 8 8 | set(tuple(x)) -C414.py:6:1: C414 [*] Unnecessary `set()` call within `set()` +C414 [*] Unnecessary `set()` call within `set()` + --> C414.py:6:1 | 4 | tuple(list(x)) 5 | tuple(tuple(x)) 6 | set(set(x)) - | ^^^^^^^^^^^ C414 + | ^^^^^^^^^^^ 7 | set(list(x)) 8 | set(tuple(x)) | - = help: Remove the inner `set()` call +help: Remove the inner `set()` call ℹ Unsafe fix 3 3 | list(tuple(x)) @@ -102,16 +107,17 @@ C414.py:6:1: C414 [*] Unnecessary `set()` call within `set()` 8 8 | set(tuple(x)) 9 9 | set(sorted(x)) -C414.py:7:1: C414 [*] Unnecessary `list()` call within `set()` +C414 [*] Unnecessary `list()` call within `set()` + --> C414.py:7:1 | 5 | tuple(tuple(x)) 6 | set(set(x)) 7 | set(list(x)) - | ^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^ 8 | set(tuple(x)) 9 | set(sorted(x)) | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 4 4 | tuple(list(x)) @@ -123,16 +129,17 @@ C414.py:7:1: C414 [*] Unnecessary `list()` call within `set()` 9 9 | set(sorted(x)) 10 10 | set(sorted(x, key=lambda y: y)) -C414.py:8:1: C414 [*] Unnecessary `tuple()` call within `set()` +C414 [*] Unnecessary `tuple()` call within `set()` + --> C414.py:8:1 | 6 | set(set(x)) 7 | set(list(x)) 8 | set(tuple(x)) - | ^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^ 9 | set(sorted(x)) 10 | set(sorted(x, key=lambda y: y)) | - = help: Remove the inner `tuple()` call +help: Remove the inner `tuple()` call ℹ Unsafe fix 5 5 | tuple(tuple(x)) @@ -144,16 +151,17 @@ C414.py:8:1: C414 [*] Unnecessary `tuple()` call within `set()` 10 10 | set(sorted(x, key=lambda y: y)) 11 11 | set(reversed(x)) -C414.py:9:1: C414 [*] Unnecessary `sorted()` call within `set()` +C414 [*] Unnecessary `sorted()` call within `set()` + --> C414.py:9:1 | 7 | set(list(x)) 8 | set(tuple(x)) 9 | set(sorted(x)) - | ^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^ 10 | set(sorted(x, key=lambda y: y)) 11 | set(reversed(x)) | - = help: Remove the inner `sorted()` call +help: Remove the inner `sorted()` call ℹ Unsafe fix 6 6 | set(set(x)) @@ -165,16 +173,17 @@ C414.py:9:1: C414 [*] Unnecessary `sorted()` call within `set()` 11 11 | set(reversed(x)) 12 12 | sorted(list(x)) -C414.py:10:1: C414 [*] Unnecessary `sorted()` call within `set()` +C414 [*] Unnecessary `sorted()` call within `set()` + --> C414.py:10:1 | 8 | set(tuple(x)) 9 | set(sorted(x)) 10 | set(sorted(x, key=lambda y: y)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | set(reversed(x)) 12 | sorted(list(x)) | - = help: Remove the inner `sorted()` call +help: Remove the inner `sorted()` call ℹ Unsafe fix 7 7 | set(list(x)) @@ -186,16 +195,17 @@ C414.py:10:1: C414 [*] Unnecessary `sorted()` call within `set()` 12 12 | sorted(list(x)) 13 13 | sorted(tuple(x)) -C414.py:11:1: C414 [*] Unnecessary `reversed()` call within `set()` +C414 [*] Unnecessary `reversed()` call within `set()` + --> C414.py:11:1 | 9 | set(sorted(x)) 10 | set(sorted(x, key=lambda y: y)) 11 | set(reversed(x)) - | ^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^ 12 | sorted(list(x)) 13 | sorted(tuple(x)) | - = help: Remove the inner `reversed()` call +help: Remove the inner `reversed()` call ℹ Unsafe fix 8 8 | set(tuple(x)) @@ -207,16 +217,17 @@ C414.py:11:1: C414 [*] Unnecessary `reversed()` call within `set()` 13 13 | sorted(tuple(x)) 14 14 | sorted(sorted(x)) -C414.py:12:1: C414 [*] Unnecessary `list()` call within `sorted()` +C414 [*] Unnecessary `list()` call within `sorted()` + --> C414.py:12:1 | 10 | set(sorted(x, key=lambda y: y)) 11 | set(reversed(x)) 12 | sorted(list(x)) - | ^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^ 13 | sorted(tuple(x)) 14 | sorted(sorted(x)) | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 9 9 | set(sorted(x)) @@ -228,16 +239,17 @@ C414.py:12:1: C414 [*] Unnecessary `list()` call within `sorted()` 14 14 | sorted(sorted(x)) 15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -C414.py:13:1: C414 [*] Unnecessary `tuple()` call within `sorted()` +C414 [*] Unnecessary `tuple()` call within `sorted()` + --> C414.py:13:1 | 11 | set(reversed(x)) 12 | sorted(list(x)) 13 | sorted(tuple(x)) - | ^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^ 14 | sorted(sorted(x)) 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) | - = help: Remove the inner `tuple()` call +help: Remove the inner `tuple()` call ℹ Unsafe fix 10 10 | set(sorted(x, key=lambda y: y)) @@ -249,16 +261,17 @@ C414.py:13:1: C414 [*] Unnecessary `tuple()` call within `sorted()` 15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) 16 16 | sorted(sorted(x, reverse=True), reverse=True) -C414.py:14:1: C414 [*] Unnecessary `sorted()` call within `sorted()` +C414 [*] Unnecessary `sorted()` call within `sorted()` + --> C414.py:14:1 | 12 | sorted(list(x)) 13 | sorted(tuple(x)) 14 | sorted(sorted(x)) - | ^^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^^ 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) 16 | sorted(sorted(x, reverse=True), reverse=True) | - = help: Remove the inner `sorted()` call +help: Remove the inner `sorted()` call ℹ Unsafe fix 11 11 | set(reversed(x)) @@ -270,16 +283,17 @@ C414.py:14:1: C414 [*] Unnecessary `sorted()` call within `sorted()` 16 16 | sorted(sorted(x, reverse=True), reverse=True) 17 17 | sorted(reversed(x)) -C414.py:15:1: C414 [*] Unnecessary `sorted()` call within `sorted()` +C414 [*] Unnecessary `sorted()` call within `sorted()` + --> C414.py:15:1 | 13 | sorted(tuple(x)) 14 | sorted(sorted(x)) 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | sorted(sorted(x, reverse=True), reverse=True) 17 | sorted(reversed(x)) | - = help: Remove the inner `sorted()` call +help: Remove the inner `sorted()` call ℹ Unsafe fix 12 12 | sorted(list(x)) @@ -291,16 +305,17 @@ C414.py:15:1: C414 [*] Unnecessary `sorted()` call within `sorted()` 17 17 | sorted(reversed(x)) 18 18 | sorted(list(x), key=lambda y: y) -C414.py:16:1: C414 [*] Unnecessary `sorted()` call within `sorted()` +C414 [*] Unnecessary `sorted()` call within `sorted()` + --> C414.py:16:1 | 14 | sorted(sorted(x)) 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) 16 | sorted(sorted(x, reverse=True), reverse=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | sorted(reversed(x)) 18 | sorted(list(x), key=lambda y: y) | - = help: Remove the inner `sorted()` call +help: Remove the inner `sorted()` call ℹ Unsafe fix 13 13 | sorted(tuple(x)) @@ -312,16 +327,17 @@ C414.py:16:1: C414 [*] Unnecessary `sorted()` call within `sorted()` 18 18 | sorted(list(x), key=lambda y: y) 19 19 | tuple( -C414.py:17:1: C414 [*] Unnecessary `reversed()` call within `sorted()` +C414 [*] Unnecessary `reversed()` call within `sorted()` + --> C414.py:17:1 | 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) 16 | sorted(sorted(x, reverse=True), reverse=True) 17 | sorted(reversed(x)) - | ^^^^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^^^^ 18 | sorted(list(x), key=lambda y: y) 19 | tuple( | - = help: Remove the inner `reversed()` call +help: Remove the inner `reversed()` call ℹ Unsafe fix 14 14 | sorted(sorted(x)) @@ -333,16 +349,17 @@ C414.py:17:1: C414 [*] Unnecessary `reversed()` call within `sorted()` 19 19 | tuple( 20 20 | list( -C414.py:18:1: C414 [*] Unnecessary `list()` call within `sorted()` +C414 [*] Unnecessary `list()` call within `sorted()` + --> C414.py:18:1 | 16 | sorted(sorted(x, reverse=True), reverse=True) 17 | sorted(reversed(x)) 18 | sorted(list(x), key=lambda y: y) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | tuple( 20 | list( | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) @@ -354,7 +371,8 @@ C414.py:18:1: C414 [*] Unnecessary `list()` call within `sorted()` 20 20 | list( 21 21 | [x, 3, "hell"\ -C414.py:19:1: C414 [*] Unnecessary `list()` call within `tuple()` +C414 [*] Unnecessary `list()` call within `tuple()` + --> C414.py:19:1 | 17 | sorted(reversed(x)) 18 | sorted(list(x), key=lambda y: y) @@ -364,11 +382,11 @@ C414.py:19:1: C414 [*] Unnecessary `list()` call within `tuple()` 22 | | "o"] 23 | | ) 24 | | ) - | |_^ C414 + | |_^ 25 | set(set()) 26 | set(list()) | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 17 17 | sorted(reversed(x)) @@ -383,16 +401,17 @@ C414.py:19:1: C414 [*] Unnecessary `list()` call within `tuple()` 25 23 | set(set()) 26 24 | set(list()) -C414.py:25:1: C414 [*] Unnecessary `set()` call within `set()` +C414 [*] Unnecessary `set()` call within `set()` + --> C414.py:25:1 | 23 | ) 24 | ) 25 | set(set()) - | ^^^^^^^^^^ C414 + | ^^^^^^^^^^ 26 | set(list()) 27 | set(tuple()) | - = help: Remove the inner `set()` call +help: Remove the inner `set()` call ℹ Unsafe fix 22 22 | "o"] @@ -404,16 +423,17 @@ C414.py:25:1: C414 [*] Unnecessary `set()` call within `set()` 27 27 | set(tuple()) 28 28 | sorted(reversed()) -C414.py:26:1: C414 [*] Unnecessary `list()` call within `set()` +C414 [*] Unnecessary `list()` call within `set()` + --> C414.py:26:1 | 24 | ) 25 | set(set()) 26 | set(list()) - | ^^^^^^^^^^^ C414 + | ^^^^^^^^^^^ 27 | set(tuple()) 28 | sorted(reversed()) | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 23 23 | ) @@ -425,15 +445,16 @@ C414.py:26:1: C414 [*] Unnecessary `list()` call within `set()` 28 28 | sorted(reversed()) 29 29 | -C414.py:27:1: C414 [*] Unnecessary `tuple()` call within `set()` +C414 [*] Unnecessary `tuple()` call within `set()` + --> C414.py:27:1 | 25 | set(set()) 26 | set(list()) 27 | set(tuple()) - | ^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^ 28 | sorted(reversed()) | - = help: Remove the inner `tuple()` call +help: Remove the inner `tuple()` call ℹ Unsafe fix 24 24 | ) @@ -445,16 +466,17 @@ C414.py:27:1: C414 [*] Unnecessary `tuple()` call within `set()` 29 29 | 30 30 | # Nested sorts with differing keyword arguments. Not flagged. -C414.py:28:1: C414 [*] Unnecessary `reversed()` call within `sorted()` +C414 [*] Unnecessary `reversed()` call within `sorted()` + --> C414.py:28:1 | 26 | set(list()) 27 | set(tuple()) 28 | sorted(reversed()) - | ^^^^^^^^^^^^^^^^^^ C414 + | ^^^^^^^^^^^^^^^^^^ 29 | 30 | # Nested sorts with differing keyword arguments. Not flagged. | - = help: Remove the inner `reversed()` call +help: Remove the inner `reversed()` call ℹ Unsafe fix 25 25 | set(set()) @@ -466,7 +488,8 @@ C414.py:28:1: C414 [*] Unnecessary `reversed()` call within `sorted()` 30 30 | # Nested sorts with differing keyword arguments. Not flagged. 31 31 | sorted(sorted(x, key=lambda y: y)) -C414.py:37:27: C414 [*] Unnecessary `list()` call within `sorted()` +C414 [*] Unnecessary `list()` call within `sorted()` + --> C414.py:37:27 | 36 | # Preserve trailing comments. 37 | xxxxxxxxxxx_xxxxx_xxxxx = sorted( @@ -476,11 +499,11 @@ C414.py:37:27: C414 [*] Unnecessary `list()` call within `sorted()` 40 | | # xx xxxx xxxxxxx xxxx xxx xxxxxxxx Nxxx 41 | | key=lambda xxxxx: xxxxx or "", 42 | | ) - | |_^ C414 + | |_^ 43 | 44 | xxxxxxxxxxx_xxxxx_xxxxx = sorted( | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 35 35 | @@ -492,7 +515,8 @@ C414.py:37:27: C414 [*] Unnecessary `list()` call within `sorted()` 40 40 | # xx xxxx xxxxxxx xxxx xxx xxxxxxxx Nxxx 41 41 | key=lambda xxxxx: xxxxx or "", -C414.py:44:27: C414 [*] Unnecessary `list()` call within `sorted()` +C414 [*] Unnecessary `list()` call within `sorted()` + --> C414.py:44:27 | 42 | ) 43 | @@ -501,9 +525,9 @@ C414.py:44:27: C414 [*] Unnecessary `list()` call within `sorted()` 45 | | list(x_xxxx_xxxxxxxxxxx_xxxxx.xxxx()), # xxxxxxxxxxx xxxxx xxxx xxx xx Nxxx 46 | | key=lambda xxxxx: xxxxx or "", 47 | | ) - | |_^ C414 + | |_^ | - = help: Remove the inner `list()` call +help: Remove the inner `list()` call ℹ Unsafe fix 42 42 | ) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C415_C415.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C415_C415.py.snap index 670e9a76fc..129a4e8988 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C415_C415.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C415_C415.py.snap @@ -1,42 +1,45 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs -snapshot_kind: text --- -C415.py:2:5: C415 Unnecessary subscript reversal of iterable within `set()` +C415 Unnecessary subscript reversal of iterable within `set()` + --> C415.py:2:5 | 1 | lst = [2, 1, 3] 2 | a = set(lst[::-1]) - | ^^^^^^^^^^^^^^ C415 + | ^^^^^^^^^^^^^^ 3 | b = reversed(lst[::-1]) 4 | c = sorted(lst[::-1]) | -C415.py:3:5: C415 Unnecessary subscript reversal of iterable within `reversed()` +C415 Unnecessary subscript reversal of iterable within `reversed()` + --> C415.py:3:5 | 1 | lst = [2, 1, 3] 2 | a = set(lst[::-1]) 3 | b = reversed(lst[::-1]) - | ^^^^^^^^^^^^^^^^^^^ C415 + | ^^^^^^^^^^^^^^^^^^^ 4 | c = sorted(lst[::-1]) 5 | d = sorted(lst[::-1], reverse=True) | -C415.py:4:5: C415 Unnecessary subscript reversal of iterable within `sorted()` +C415 Unnecessary subscript reversal of iterable within `sorted()` + --> C415.py:4:5 | 2 | a = set(lst[::-1]) 3 | b = reversed(lst[::-1]) 4 | c = sorted(lst[::-1]) - | ^^^^^^^^^^^^^^^^^ C415 + | ^^^^^^^^^^^^^^^^^ 5 | d = sorted(lst[::-1], reverse=True) 6 | e = set(lst[2:-1]) | -C415.py:5:5: C415 Unnecessary subscript reversal of iterable within `sorted()` +C415 Unnecessary subscript reversal of iterable within `sorted()` + --> C415.py:5:5 | 3 | b = reversed(lst[::-1]) 4 | c = sorted(lst[::-1]) 5 | d = sorted(lst[::-1], reverse=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | e = set(lst[2:-1]) 7 | f = set(lst[:1:-1]) | diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap index 7266e76c5e..71cbe567e4 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C416.py:6:1: C416 [*] Unnecessary list comprehension (rewrite using `list()`) +C416 [*] Unnecessary list comprehension (rewrite using `list()`) + --> C416.py:6:1 | 4 | d = {"a": 1, "b": 2, "c": 3} 5 | 6 | [i for i in x] - | ^^^^^^^^^^^^^^ C416 + | ^^^^^^^^^^^^^^ 7 | {i for i in x} 8 | {k: v for k, v in y} | - = help: Rewrite using `list()` +help: Rewrite using `list()` ℹ Unsafe fix 3 3 | z = [(1,), (2,), (3,)] @@ -22,15 +23,16 @@ C416.py:6:1: C416 [*] Unnecessary list comprehension (rewrite using `list()`) 8 8 | {k: v for k, v in y} 9 9 | {k: v for k, v in d.items()} -C416.py:7:1: C416 [*] Unnecessary set comprehension (rewrite using `set()`) +C416 [*] Unnecessary set comprehension (rewrite using `set()`) + --> C416.py:7:1 | 6 | [i for i in x] 7 | {i for i in x} - | ^^^^^^^^^^^^^^ C416 + | ^^^^^^^^^^^^^^ 8 | {k: v for k, v in y} 9 | {k: v for k, v in d.items()} | - = help: Rewrite using `set()` +help: Rewrite using `set()` ℹ Unsafe fix 4 4 | d = {"a": 1, "b": 2, "c": 3} @@ -42,16 +44,17 @@ C416.py:7:1: C416 [*] Unnecessary set comprehension (rewrite using `set()`) 9 9 | {k: v for k, v in d.items()} 10 10 | [(k, v) for k, v in d.items()] -C416.py:8:1: C416 [*] Unnecessary dict comprehension (rewrite using `dict()`) +C416 [*] Unnecessary dict comprehension (rewrite using `dict()`) + --> C416.py:8:1 | 6 | [i for i in x] 7 | {i for i in x} 8 | {k: v for k, v in y} - | ^^^^^^^^^^^^^^^^^^^^ C416 + | ^^^^^^^^^^^^^^^^^^^^ 9 | {k: v for k, v in d.items()} 10 | [(k, v) for k, v in d.items()] | - = help: Rewrite using `dict()` +help: Rewrite using `dict()` ℹ Unsafe fix 5 5 | @@ -63,16 +66,17 @@ C416.py:8:1: C416 [*] Unnecessary dict comprehension (rewrite using `dict()`) 10 10 | [(k, v) for k, v in d.items()] 11 11 | [(k, v) for [k, v] in d.items()] -C416.py:9:1: C416 [*] Unnecessary dict comprehension (rewrite using `dict()`) +C416 [*] Unnecessary dict comprehension (rewrite using `dict()`) + --> C416.py:9:1 | 7 | {i for i in x} 8 | {k: v for k, v in y} 9 | {k: v for k, v in d.items()} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | [(k, v) for k, v in d.items()] 11 | [(k, v) for [k, v] in d.items()] | - = help: Rewrite using `dict()` +help: Rewrite using `dict()` ℹ Unsafe fix 6 6 | [i for i in x] @@ -84,16 +88,17 @@ C416.py:9:1: C416 [*] Unnecessary dict comprehension (rewrite using `dict()`) 11 11 | [(k, v) for [k, v] in d.items()] 12 12 | {k: (a, b) for k, (a, b) in d.items()} -C416.py:10:1: C416 [*] Unnecessary list comprehension (rewrite using `list()`) +C416 [*] Unnecessary list comprehension (rewrite using `list()`) + --> C416.py:10:1 | 8 | {k: v for k, v in y} 9 | {k: v for k, v in d.items()} 10 | [(k, v) for k, v in d.items()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | [(k, v) for [k, v] in d.items()] 12 | {k: (a, b) for k, (a, b) in d.items()} | - = help: Rewrite using `list()` +help: Rewrite using `list()` ℹ Unsafe fix 7 7 | {i for i in x} @@ -105,15 +110,16 @@ C416.py:10:1: C416 [*] Unnecessary list comprehension (rewrite using `list()`) 12 12 | {k: (a, b) for k, (a, b) in d.items()} 13 13 | -C416.py:11:1: C416 [*] Unnecessary list comprehension (rewrite using `list()`) +C416 [*] Unnecessary list comprehension (rewrite using `list()`) + --> C416.py:11:1 | 9 | {k: v for k, v in d.items()} 10 | [(k, v) for k, v in d.items()] 11 | [(k, v) for [k, v] in d.items()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | {k: (a, b) for k, (a, b) in d.items()} | - = help: Rewrite using `list()` +help: Rewrite using `list()` ℹ Unsafe fix 8 8 | {k: v for k, v in y} @@ -125,15 +131,16 @@ C416.py:11:1: C416 [*] Unnecessary list comprehension (rewrite using `list()`) 13 13 | 14 14 | [i for i, in z] -C416.py:25:70: C416 [*] Unnecessary list comprehension (rewrite using `list()`) +C416 [*] Unnecessary list comprehension (rewrite using `list()`) + --> C416.py:25:70 | 24 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 25 | any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) - | ^^^^^^^^^^^^^^^^^^^^^^^ C416 + | ^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | zz = [[1], [2], [3]] | - = help: Rewrite using `list()` +help: Rewrite using `list()` ℹ Unsafe fix 22 22 | {k: v if v else None for k, v in y} diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap index 3a8148e299..a8bb7cfc8c 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C417.py:3:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:3:1 | 1 | # Errors. 2 | nums = [1, 2, 3] 3 | map(lambda x: x + 1, nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | map(lambda x: str(x), nums) 5 | list(map(lambda x: x * 2, nums)) | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 1 1 | # Errors. @@ -21,16 +22,17 @@ C417.py:3:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expre 5 5 | list(map(lambda x: x * 2, nums)) 6 6 | set(map(lambda x: x % 2 == 0, nums)) -C417.py:4:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:4:1 | 2 | nums = [1, 2, 3] 3 | map(lambda x: x + 1, nums) 4 | map(lambda x: str(x), nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | list(map(lambda x: x * 2, nums)) 6 | set(map(lambda x: x % 2 == 0, nums)) | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 1 1 | # Errors. @@ -42,16 +44,17 @@ C417.py:4:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expre 6 6 | set(map(lambda x: x % 2 == 0, nums)) 7 7 | dict(map(lambda v: (v, v**2), nums)) -C417.py:5:1: C417 [*] Unnecessary `map()` usage (rewrite using a list comprehension) +C417 [*] Unnecessary `map()` usage (rewrite using a list comprehension) + --> C417.py:5:1 | 3 | map(lambda x: x + 1, nums) 4 | map(lambda x: str(x), nums) 5 | list(map(lambda x: x * 2, nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | set(map(lambda x: x % 2 == 0, nums)) 7 | dict(map(lambda v: (v, v**2), nums)) | - = help: Replace `map()` with a list comprehension +help: Replace `map()` with a list comprehension ℹ Unsafe fix 2 2 | nums = [1, 2, 3] @@ -63,16 +66,17 @@ C417.py:5:1: C417 [*] Unnecessary `map()` usage (rewrite using a list comprehens 7 7 | dict(map(lambda v: (v, v**2), nums)) 8 8 | dict(map(lambda v: [v, v**2], nums)) -C417.py:6:1: C417 [*] Unnecessary `map()` usage (rewrite using a set comprehension) +C417 [*] Unnecessary `map()` usage (rewrite using a set comprehension) + --> C417.py:6:1 | 4 | map(lambda x: str(x), nums) 5 | list(map(lambda x: x * 2, nums)) 6 | set(map(lambda x: x % 2 == 0, nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | dict(map(lambda v: (v, v**2), nums)) 8 | dict(map(lambda v: [v, v**2], nums)) | - = help: Replace `map()` with a set comprehension +help: Replace `map()` with a set comprehension ℹ Unsafe fix 3 3 | map(lambda x: x + 1, nums) @@ -84,15 +88,16 @@ C417.py:6:1: C417 [*] Unnecessary `map()` usage (rewrite using a set comprehensi 8 8 | dict(map(lambda v: [v, v**2], nums)) 9 9 | -C417.py:7:1: C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehension) +C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehension) + --> C417.py:7:1 | 5 | list(map(lambda x: x * 2, nums)) 6 | set(map(lambda x: x % 2 == 0, nums)) 7 | dict(map(lambda v: (v, v**2), nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | dict(map(lambda v: [v, v**2], nums)) | - = help: Replace `map()` with a dict comprehension +help: Replace `map()` with a dict comprehension ℹ Unsafe fix 4 4 | map(lambda x: str(x), nums) @@ -104,16 +109,17 @@ C417.py:7:1: C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehens 9 9 | 10 10 | map(lambda _: 3.0, nums) -C417.py:8:1: C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehension) +C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehension) + --> C417.py:8:1 | 6 | set(map(lambda x: x % 2 == 0, nums)) 7 | dict(map(lambda v: (v, v**2), nums)) 8 | dict(map(lambda v: [v, v**2], nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | map(lambda _: 3.0, nums) | - = help: Replace `map()` with a dict comprehension +help: Replace `map()` with a dict comprehension ℹ Unsafe fix 5 5 | list(map(lambda x: x * 2, nums)) @@ -125,16 +131,17 @@ C417.py:8:1: C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehens 10 10 | map(lambda _: 3.0, nums) 11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -C417.py:10:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:10:1 | 8 | dict(map(lambda v: [v, v**2], nums)) 9 | 10 | map(lambda _: 3.0, nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) 12 | all(map(lambda v: isinstance(v, dict), nums)) | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 7 7 | dict(map(lambda v: (v, v**2), nums)) @@ -146,15 +153,16 @@ C417.py:10:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expr 12 12 | all(map(lambda v: isinstance(v, dict), nums)) 13 13 | filter(func, map(lambda v: v, nums)) -C417.py:11:13: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:11:13 | 10 | map(lambda _: 3.0, nums) 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | all(map(lambda v: isinstance(v, dict), nums)) 13 | filter(func, map(lambda v: v, nums)) | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 8 8 | dict(map(lambda v: [v, v**2], nums)) @@ -166,15 +174,16 @@ C417.py:11:13: C417 [*] Unnecessary `map()` usage (rewrite using a generator exp 13 13 | filter(func, map(lambda v: v, nums)) 14 14 | -C417.py:12:5: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:12:5 | 10 | map(lambda _: 3.0, nums) 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) 12 | all(map(lambda v: isinstance(v, dict), nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | filter(func, map(lambda v: v, nums)) | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 9 9 | @@ -186,14 +195,15 @@ C417.py:12:5: C417 [*] Unnecessary `map()` usage (rewrite using a generator expr 14 14 | 15 15 | -C417.py:13:14: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:13:14 | 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) 12 | all(map(lambda v: isinstance(v, dict), nums)) 13 | filter(func, map(lambda v: v, nums)) - | ^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 10 10 | map(lambda _: 3.0, nums) @@ -205,14 +215,15 @@ C417.py:13:14: C417 [*] Unnecessary `map()` usage (rewrite using a generator exp 15 15 | 16 16 | # When inside f-string, then the fix should be surrounded by whitespace -C417.py:17:8: C417 [*] Unnecessary `map()` usage (rewrite using a set comprehension) +C417 [*] Unnecessary `map()` usage (rewrite using a set comprehension) + --> C417.py:17:8 | 16 | # When inside f-string, then the fix should be surrounded by whitespace 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" | - = help: Replace `map()` with a set comprehension +help: Replace `map()` with a set comprehension ℹ Unsafe fix 14 14 | @@ -224,16 +235,17 @@ C417.py:17:8: C417 [*] Unnecessary `map()` usage (rewrite using a set comprehens 19 19 | 20 20 | # False negatives. -C417.py:18:8: C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehension) +C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehension) + --> C417.py:18:8 | 16 | # When inside f-string, then the fix should be surrounded by whitespace 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" 18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # False negatives. | - = help: Replace `map()` with a dict comprehension +help: Replace `map()` with a dict comprehension ℹ Unsafe fix 15 15 | @@ -245,15 +257,16 @@ C417.py:18:8: C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehen 20 20 | # False negatives. 21 21 | map(lambda x=2, y=1: x + y, nums, nums) -C417.py:36:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:36:1 | 35 | # Error: the `x` is overridden by the inner lambda. 36 | map(lambda x: lambda x: x, range(4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | 38 | # Ok because of the default parameters, and variadic arguments. | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 33 33 | map(lambda x: lambda: x, range(4)) @@ -265,15 +278,16 @@ C417.py:36:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expr 38 38 | # Ok because of the default parameters, and variadic arguments. 39 39 | map(lambda x=1: x, nums) -C417.py:47:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:47:1 | 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 47 | map(lambda x: x, y if y else z) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | map(lambda x: x, (y if y else z)) 49 | map(lambda x: x, (x, y, z)) | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 44 44 | dict(map(lambda k, v: (k, v), keys, values)) @@ -285,15 +299,16 @@ C417.py:47:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expr 49 49 | map(lambda x: x, (x, y, z)) 50 50 | -C417.py:48:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:48:1 | 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 47 | map(lambda x: x, y if y else z) 48 | map(lambda x: x, (y if y else z)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 49 | map(lambda x: x, (x, y, z)) | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 45 45 | @@ -305,16 +320,17 @@ C417.py:48:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expr 50 50 | 51 51 | # See https://github.com/astral-sh/ruff/issues/14808 -C417.py:49:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417.py:49:1 | 47 | map(lambda x: x, y if y else z) 48 | map(lambda x: x, (y if y else z)) 49 | map(lambda x: x, (x, y, z)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | # See https://github.com/astral-sh/ruff/issues/14808 | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 @@ -326,14 +342,15 @@ C417.py:49:1: C417 [*] Unnecessary `map()` usage (rewrite using a generator expr 51 51 | # See https://github.com/astral-sh/ruff/issues/14808 52 52 | # The following should be Ok since -C417.py:75:8: C417 [*] Unnecessary `map()` usage (rewrite using a set comprehension) +C417 [*] Unnecessary `map()` usage (rewrite using a set comprehension) + --> C417.py:75:8 | 74 | # When inside t-string, then the fix should be surrounded by whitespace 75 | _ = t"{set(map(lambda x: x % 2 == 0, nums))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 76 | _ = t"{dict(map(lambda v: (v, v**2), nums))}" | - = help: Replace `map()` with a set comprehension +help: Replace `map()` with a set comprehension ℹ Unsafe fix 72 72 | list(map(lambda x, y: x, [(1, 2), (3, 4)])) @@ -344,14 +361,15 @@ C417.py:75:8: C417 [*] Unnecessary `map()` usage (rewrite using a set comprehens 76 76 | _ = t"{dict(map(lambda v: (v, v**2), nums))}" 77 77 | -C417.py:76:8: C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehension) +C417 [*] Unnecessary `map()` usage (rewrite using a dict comprehension) + --> C417.py:76:8 | 74 | # When inside t-string, then the fix should be surrounded by whitespace 75 | _ = t"{set(map(lambda x: x % 2 == 0, nums))}" 76 | _ = t"{dict(map(lambda v: (v, v**2), nums))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace `map()` with a dict comprehension +help: Replace `map()` with a dict comprehension ℹ Unsafe fix 73 73 | diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417_1.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417_1.py.snap index 82312e83fc..1861b55ba8 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417_1.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C417_1.py:7:10: C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) +C417 [*] Unnecessary `map()` usage (rewrite using a generator expression) + --> C417_1.py:7:10 | 5 | def overshadowed_list(): 6 | list = ... 7 | list(map(lambda x: x, [])) - | ^^^^^^^^^^^^^^^^^^^^ C417 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace `map()` with a generator expression +help: Replace `map()` with a generator expression ℹ Unsafe fix 4 4 | diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap index 0a90ca25db..48178c70e9 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C418.py:1:1: C418 [*] Unnecessary dict literal passed to `dict()` (remove the outer call to `dict()`) +C418 [*] Unnecessary dict literal passed to `dict()` (remove the outer call to `dict()`) + --> C418.py:1:1 | 1 | dict({}) - | ^^^^^^^^ C418 + | ^^^^^^^^ 2 | dict({'a': 1}) 3 | dict({'x': 1 for x in range(10)}) | - = help: Remove outer `dict()` call +help: Remove outer `dict()` call ℹ Unsafe fix 1 |-dict({}) @@ -17,15 +18,16 @@ C418.py:1:1: C418 [*] Unnecessary dict literal passed to `dict()` (remove the ou 3 3 | dict({'x': 1 for x in range(10)}) 4 4 | dict( -C418.py:2:1: C418 [*] Unnecessary dict literal passed to `dict()` (remove the outer call to `dict()`) +C418 [*] Unnecessary dict literal passed to `dict()` (remove the outer call to `dict()`) + --> C418.py:2:1 | 1 | dict({}) 2 | dict({'a': 1}) - | ^^^^^^^^^^^^^^ C418 + | ^^^^^^^^^^^^^^ 3 | dict({'x': 1 for x in range(10)}) 4 | dict( | - = help: Remove outer `dict()` call +help: Remove outer `dict()` call ℹ Unsafe fix 1 1 | dict({}) @@ -35,16 +37,17 @@ C418.py:2:1: C418 [*] Unnecessary dict literal passed to `dict()` (remove the ou 4 4 | dict( 5 5 | {'x': 1 for x in range(10)} -C418.py:3:1: C418 [*] Unnecessary dict comprehension passed to `dict()` (remove the outer call to `dict()`) +C418 [*] Unnecessary dict comprehension passed to `dict()` (remove the outer call to `dict()`) + --> C418.py:3:1 | 1 | dict({}) 2 | dict({'a': 1}) 3 | dict({'x': 1 for x in range(10)}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C418 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | dict( 5 | {'x': 1 for x in range(10)} | - = help: Remove outer `dict()` call +help: Remove outer `dict()` call ℹ Unsafe fix 1 1 | dict({}) @@ -55,18 +58,19 @@ C418.py:3:1: C418 [*] Unnecessary dict comprehension passed to `dict()` (remove 5 5 | {'x': 1 for x in range(10)} 6 6 | ) -C418.py:4:1: C418 [*] Unnecessary dict comprehension passed to `dict()` (remove the outer call to `dict()`) +C418 [*] Unnecessary dict comprehension passed to `dict()` (remove the outer call to `dict()`) + --> C418.py:4:1 | 2 | dict({'a': 1}) 3 | dict({'x': 1 for x in range(10)}) 4 | / dict( 5 | | {'x': 1 for x in range(10)} 6 | | ) - | |_^ C418 + | |_^ 7 | 8 | dict({}, a=1) | - = help: Remove outer `dict()` call +help: Remove outer `dict()` call ℹ Unsafe fix 1 1 | dict({}) diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap index 25ff5019b4..e6e08ba2c4 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C419.py:1:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419.py:1:5 | 1 | any([x.id for x in bar]) - | ^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^ 2 | all([x.id for x in bar]) 3 | any( # first comment | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 1 |-any([x.id for x in bar]) @@ -17,15 +18,16 @@ C419.py:1:5: C419 [*] Unnecessary list comprehension 3 3 | any( # first comment 4 4 | [x.id for x in bar], # second comment -C419.py:2:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419.py:2:5 | 1 | any([x.id for x in bar]) 2 | all([x.id for x in bar]) - | ^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^ 3 | any( # first comment 4 | [x.id for x in bar], # second comment | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 1 1 | any([x.id for x in bar]) @@ -35,16 +37,17 @@ C419.py:2:5: C419 [*] Unnecessary list comprehension 4 4 | [x.id for x in bar], # second comment 5 5 | ) # third comment -C419.py:4:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419.py:4:5 | 2 | all([x.id for x in bar]) 3 | any( # first comment 4 | [x.id for x in bar], # second comment - | ^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^ 5 | ) # third comment 6 | all( # first comment | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 1 1 | any([x.id for x in bar]) @@ -56,16 +59,17 @@ C419.py:4:5: C419 [*] Unnecessary list comprehension 6 6 | all( # first comment 7 7 | [x.id for x in bar], # second comment -C419.py:7:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419.py:7:5 | 5 | ) # third comment 6 | all( # first comment 7 | [x.id for x in bar], # second comment - | ^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^ 8 | ) # third comment 9 | any({x.id for x in bar}) | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 4 4 | [x.id for x in bar], # second comment @@ -77,16 +81,17 @@ C419.py:7:5: C419 [*] Unnecessary list comprehension 9 9 | any({x.id for x in bar}) 10 10 | -C419.py:9:5: C419 [*] Unnecessary set comprehension +C419 [*] Unnecessary set comprehension + --> C419.py:9:5 | 7 | [x.id for x in bar], # second comment 8 | ) # third comment 9 | any({x.id for x in bar}) - | ^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^ 10 | 11 | # OK | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 6 6 | all( # first comment @@ -98,7 +103,8 @@ C419.py:9:5: C419 [*] Unnecessary set comprehension 11 11 | # OK 12 12 | all(x.id for x in bar) -C419.py:28:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419.py:28:5 | 26 | # Special comment handling 27 | any( @@ -108,11 +114,11 @@ C419.py:28:5: C419 [*] Unnecessary list comprehension 31 | | # random middle comment 32 | | for i in range(5) # rbracket comment 33 | | ] # rpar comment - | |_____^ C419 + | |_____^ 34 | # trailing comment 35 | ) | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 25 25 | @@ -132,7 +138,8 @@ C419.py:28:5: C419 [*] Unnecessary list comprehension 35 34 | ) 36 35 | -C419.py:39:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419.py:39:5 | 37 | # Weird case where the function call, opening bracket, and comment are all 38 | # on the same line. @@ -141,10 +148,10 @@ C419.py:39:5: C419 [*] Unnecessary list comprehension 40 | | # second line comment 41 | | i.bit_count() for i in range(5) # rbracket comment 42 | | ] # rpar comment - | |_____^ C419 + | |_____^ 43 | ) | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 36 36 | @@ -162,14 +169,15 @@ C419.py:39:5: C419 [*] Unnecessary list comprehension 44 44 | 45 45 | ## Set comprehensions should only be linted -C419.py:49:5: C419 [*] Unnecessary set comprehension +C419 [*] Unnecessary set comprehension + --> C419.py:49:5 | 48 | # should be linted... 49 | any({x.id for x in bar}) - | ^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^ 50 | all({x.id for x in bar}) | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 46 46 | ## when function is invariant under duplication of inputs @@ -181,16 +189,17 @@ C419.py:49:5: C419 [*] Unnecessary set comprehension 51 51 | 52 52 | # should be linted in preview... -C419.py:50:5: C419 [*] Unnecessary set comprehension +C419 [*] Unnecessary set comprehension + --> C419.py:50:5 | 48 | # should be linted... 49 | any({x.id for x in bar}) 50 | all({x.id for x in bar}) - | ^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^ 51 | 52 | # should be linted in preview... | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 47 47 | diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420.py.snap index 0914f762bf..1fd0017534 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C420.py:6:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:6:5 | 4 | def func(): 5 | numbers = [1, 2, 3] 6 | {n: None for n in numbers} # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable, value)`) +help: Replace with `dict.fromkeys(iterable, value)`) ℹ Safe fix 3 3 | @@ -20,14 +21,15 @@ C420.py:6:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fro 8 8 | 9 9 | def func(): -C420.py:10:23: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:10:23 | 9 | def func(): 10 | for key, value in {n: 1 for n in [1, 2, 3]}.items(): # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | pass | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 7 7 | @@ -39,13 +41,14 @@ C420.py:10:23: C420 [*] Unnecessary dict comprehension for iterable; use `dict.f 12 12 | 13 13 | -C420.py:15:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:15:5 | 14 | def func(): 15 | {n: 1.1 for n in [1, 2, 3]} # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 12 12 | @@ -57,14 +60,15 @@ C420.py:15:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 17 17 | 18 18 | def func(): -C420.py:26:7: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:26:7 | 24 | return data 25 | 26 | f({c: "a" for c in "12345"}) # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 23 23 | def f(data): @@ -76,13 +80,14 @@ C420.py:26:7: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 28 28 | 29 29 | def func(): -C420.py:30:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:30:5 | 29 | def func(): 30 | {n: True for n in [1, 2, 2]} # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 27 27 | @@ -94,13 +99,14 @@ C420.py:30:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 32 32 | 33 33 | def func(): -C420.py:34:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:34:5 | 33 | def func(): 34 | {n: b"hello" for n in (1, 2, 2)} # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 31 31 | @@ -112,13 +118,14 @@ C420.py:34:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 36 36 | 37 37 | def func(): -C420.py:38:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:38:5 | 37 | def func(): 38 | {n: ... for n in [1, 2, 3]} # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 35 35 | @@ -130,13 +137,14 @@ C420.py:38:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 40 40 | 41 41 | def func(): -C420.py:42:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:42:5 | 41 | def func(): 42 | {n: False for n in {1: "a", 2: "b"}} # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 39 39 | @@ -148,13 +156,14 @@ C420.py:42:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 44 44 | 45 45 | def func(): -C420.py:46:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:46:5 | 45 | def func(): 46 | {(a, b): 1 for (a, b) in [(1, 2), (3, 4)]} # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 43 43 | @@ -166,13 +175,14 @@ C420.py:46:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 48 48 | 49 49 | def func(): -C420.py:54:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:54:5 | 53 | a = f() 54 | {n: a for n in [1, 2, 3]} # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 51 51 | return 1 @@ -184,14 +194,15 @@ C420.py:54:5: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 56 56 | 57 57 | def func(): -C420.py:59:6: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:59:6 | 57 | def func(): 58 | values = ["a", "b", "c"] 59 | [{n: values for n in [1, 2, 3]}] # RUF025 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 56 56 | @@ -203,7 +214,8 @@ C420.py:59:6: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 61 61 | 62 62 | # Non-violation cases: RUF025 -C420.py:95:1: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420.py:95:1 | 94 | # https://github.com/astral-sh/ruff/issues/18764 95 | / { # 1 @@ -215,9 +227,9 @@ C420.py:95:1: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fr 101 | | in # 7 102 | | iterable # 8 103 | | } # 9 - | |_^ C420 + | |_^ | - = help: Replace with `dict.fromkeys(iterable, value)`) +help: Replace with `dict.fromkeys(iterable, value)`) ℹ Unsafe fix 92 92 | {(a, b): a + b for (a, b) in [(1, 2), (3, 4)]} # OK diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420_1.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420_1.py.snap index 9551c10fde..e8287c0ae1 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420_1.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C420_1.py:1:1: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420_1.py:1:1 | 1 | {x: NotImplemented for x in "XY"} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable)`) +help: Replace with `dict.fromkeys(iterable)`) ℹ Safe fix 1 |-{x: NotImplemented for x in "XY"} diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420_2.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420_2.py.snap index c0f88083fa..0ff4e0d6ac 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C420_C420_2.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C420_2.py:1:7: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead +C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + --> C420_2.py:1:7 | 1 | foo or{x: None for x in bar} - | ^^^^^^^^^^^^^^^^^^^^^^ C420 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `dict.fromkeys(iterable, value)`) +help: Replace with `dict.fromkeys(iterable, value)`) ℹ Safe fix 1 |-foo or{x: None for x in bar} diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C409_C409.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C409_C409.py.snap index cdbe3af0c1..68bb872982 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C409_C409.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C409_C409.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C409.py:1:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:1:6 | 1 | t1 = tuple([]) - | ^^^^^^^^^ C409 + | ^^^^^^^^^ 2 | t2 = tuple([1, 2]) 3 | t3 = tuple((1, 2)) | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 1 |-t1 = tuple([]) @@ -17,15 +18,16 @@ C409.py:1:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a 3 3 | t3 = tuple((1, 2)) 4 4 | t4 = tuple([ -C409.py:2:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:2:6 | 1 | t1 = tuple([]) 2 | t2 = tuple([1, 2]) - | ^^^^^^^^^^^^^ C409 + | ^^^^^^^^^^^^^ 3 | t3 = tuple((1, 2)) 4 | t4 = tuple([ | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 1 1 | t1 = tuple([]) @@ -35,16 +37,17 @@ C409.py:2:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a 4 4 | t4 = tuple([ 5 5 | 1, -C409.py:3:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) +C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) + --> C409.py:3:6 | 1 | t1 = tuple([]) 2 | t2 = tuple([1, 2]) 3 | t3 = tuple((1, 2)) - | ^^^^^^^^^^^^^ C409 + | ^^^^^^^^^^^^^ 4 | t4 = tuple([ 5 | 1, | - = help: Remove the outer call to `tuple()` +help: Remove the outer call to `tuple()` ℹ Unsafe fix 1 1 | t1 = tuple([]) @@ -55,7 +58,8 @@ C409.py:3:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 5 5 | 1, 6 6 | 2 -C409.py:4:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:4:6 | 2 | t2 = tuple([1, 2]) 3 | t3 = tuple((1, 2)) @@ -64,11 +68,11 @@ C409.py:4:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a 5 | | 1, 6 | | 2 7 | | ]) - | |__^ C409 + | |__^ 8 | t5 = tuple( 9 | (1, 2) | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 1 1 | t1 = tuple([]) @@ -84,7 +88,8 @@ C409.py:4:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a 9 9 | (1, 2) 10 10 | ) -C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) +C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) + --> C409.py:8:6 | 6 | 2 7 | ]) @@ -92,11 +97,11 @@ C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the | ______^ 9 | | (1, 2) 10 | | ) - | |_^ C409 + | |_^ 11 | 12 | tuple( # comment | - = help: Remove the outer call to `tuple()` +help: Remove the outer call to `tuple()` ℹ Unsafe fix 5 5 | 1, @@ -110,18 +115,19 @@ C409.py:8:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 12 10 | tuple( # comment 13 11 | [1, 2] -C409.py:12:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:12:1 | 10 | ) 11 | 12 | / tuple( # comment 13 | | [1, 2] 14 | | ) - | |_^ C409 + | |_^ 15 | 16 | tuple([ # comment | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 9 9 | (1, 2) @@ -135,18 +141,19 @@ C409.py:12:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 16 14 | tuple([ # comment 17 15 | 1, 2 -C409.py:16:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:16:1 | 14 | ) 15 | 16 | / tuple([ # comment 17 | | 1, 2 18 | | ]) - | |__^ C409 + | |__^ 19 | 20 | tuple(( | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 13 13 | [1, 2] @@ -161,18 +168,19 @@ C409.py:16:1: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 20 20 | tuple(( 21 21 | 1, -C409.py:20:1: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) +C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) + --> C409.py:20:1 | 18 | ]) 19 | 20 | / tuple(( 21 | | 1, 22 | | )) - | |__^ C409 + | |__^ 23 | 24 | t6 = tuple([1]) | - = help: Remove the outer call to `tuple()` +help: Remove the outer call to `tuple()` ℹ Unsafe fix 17 17 | 1, 2 @@ -187,16 +195,17 @@ C409.py:20:1: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 24 24 | t6 = tuple([1]) 25 25 | t7 = tuple((1,)) -C409.py:24:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:24:6 | 22 | )) 23 | 24 | t6 = tuple([1]) - | ^^^^^^^^^^ C409 + | ^^^^^^^^^^ 25 | t7 = tuple((1,)) 26 | t8 = tuple([1,]) | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 21 21 | 1, @@ -208,14 +217,15 @@ C409.py:24:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 26 26 | t8 = tuple([1,]) 27 27 | -C409.py:25:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) +C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the outer call to `tuple()`) + --> C409.py:25:6 | 24 | t6 = tuple([1]) 25 | t7 = tuple((1,)) - | ^^^^^^^^^^^ C409 + | ^^^^^^^^^^^ 26 | t8 = tuple([1,]) | - = help: Remove the outer call to `tuple()` +help: Remove the outer call to `tuple()` ℹ Unsafe fix 22 22 | )) @@ -227,16 +237,17 @@ C409.py:25:6: C409 [*] Unnecessary tuple literal passed to `tuple()` (remove the 27 27 | 28 28 | tuple([x for x in range(5)]) -C409.py:26:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) +C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as a tuple literal) + --> C409.py:26:6 | 24 | t6 = tuple([1]) 25 | t7 = tuple((1,)) 26 | t8 = tuple([1,]) - | ^^^^^^^^^^^ C409 + | ^^^^^^^^^^^ 27 | 28 | tuple([x for x in range(5)]) | - = help: Rewrite as a tuple literal +help: Rewrite as a tuple literal ℹ Unsafe fix 23 23 | @@ -248,16 +259,17 @@ C409.py:26:6: C409 [*] Unnecessary list literal passed to `tuple()` (rewrite as 28 28 | tuple([x for x in range(5)]) 29 29 | tuple({x for x in range(10)}) -C409.py:28:1: C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) +C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) + --> C409.py:28:1 | 26 | t8 = tuple([1,]) 27 | 28 | tuple([x for x in range(5)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C409 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | tuple({x for x in range(10)}) 30 | tuple(x for x in range(5)) | - = help: Rewrite as a generator +help: Rewrite as a generator ℹ Unsafe fix 25 25 | t7 = tuple((1,)) @@ -269,18 +281,19 @@ C409.py:28:1: C409 [*] Unnecessary list comprehension passed to `tuple()` (rewri 30 30 | tuple(x for x in range(5)) 31 31 | tuple([ -C409.py:31:1: C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) +C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) + --> C409.py:31:1 | 29 | tuple({x for x in range(10)}) 30 | tuple(x for x in range(5)) 31 | / tuple([ 32 | | x for x in [1,2,3] 33 | | ]) - | |__^ C409 + | |__^ 34 | tuple( # comment 35 | [x for x in [1,2,3]] | - = help: Rewrite as a generator +help: Rewrite as a generator ℹ Unsafe fix 28 28 | tuple([x for x in range(5)]) @@ -294,18 +307,19 @@ C409.py:31:1: C409 [*] Unnecessary list comprehension passed to `tuple()` (rewri 35 33 | [x for x in [1,2,3]] 36 34 | ) -C409.py:34:1: C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) +C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) + --> C409.py:34:1 | 32 | x for x in [1,2,3] 33 | ]) 34 | / tuple( # comment 35 | | [x for x in [1,2,3]] 36 | | ) - | |_^ C409 + | |_^ 37 | tuple([ # comment 38 | x for x in range(10) | - = help: Rewrite as a generator +help: Rewrite as a generator ℹ Unsafe fix 32 32 | x for x in [1,2,3] @@ -317,18 +331,19 @@ C409.py:34:1: C409 [*] Unnecessary list comprehension passed to `tuple()` (rewri 37 37 | tuple([ # comment 38 38 | x for x in range(10) -C409.py:37:1: C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) +C409 [*] Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) + --> C409.py:37:1 | 35 | [x for x in [1,2,3]] 36 | ) 37 | / tuple([ # comment 38 | | x for x in range(10) 39 | | ]) - | |__^ C409 + | |__^ 40 | tuple( 41 | { | - = help: Rewrite as a generator +help: Rewrite as a generator ℹ Unsafe fix 34 34 | tuple( # comment diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap index c3433692fe..33b991397a 100644 --- a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__preview__C419_C419_1.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs --- -C419_1.py:1:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419_1.py:1:5 | 1 | sum([x.val for x in bar]) - | ^^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^^ 2 | min([x.val for x in bar]) 3 | max([x.val for x in bar]) | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 1 |-sum([x.val for x in bar]) @@ -17,15 +18,16 @@ C419_1.py:1:5: C419 [*] Unnecessary list comprehension 3 3 | max([x.val for x in bar]) 4 4 | sum([x.val for x in bar], 0) -C419_1.py:2:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419_1.py:2:5 | 1 | sum([x.val for x in bar]) 2 | min([x.val for x in bar]) - | ^^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^^ 3 | max([x.val for x in bar]) 4 | sum([x.val for x in bar], 0) | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 1 1 | sum([x.val for x in bar]) @@ -35,15 +37,16 @@ C419_1.py:2:5: C419 [*] Unnecessary list comprehension 4 4 | sum([x.val for x in bar], 0) 5 5 | -C419_1.py:3:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419_1.py:3:5 | 1 | sum([x.val for x in bar]) 2 | min([x.val for x in bar]) 3 | max([x.val for x in bar]) - | ^^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^^ 4 | sum([x.val for x in bar], 0) | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 1 1 | sum([x.val for x in bar]) @@ -54,16 +57,17 @@ C419_1.py:3:5: C419 [*] Unnecessary list comprehension 5 5 | 6 6 | # OK -C419_1.py:4:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419_1.py:4:5 | 2 | min([x.val for x in bar]) 3 | max([x.val for x in bar]) 4 | sum([x.val for x in bar], 0) - | ^^^^^^^^^^^^^^^^^^^^ C419 + | ^^^^^^^^^^^^^^^^^^^^ 5 | 6 | # OK | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 1 1 | sum([x.val for x in bar]) @@ -75,7 +79,8 @@ C419_1.py:4:5: C419 [*] Unnecessary list comprehension 6 6 | # OK 7 7 | sum(x.val for x in bar) -C419_1.py:14:5: C419 [*] Unnecessary list comprehension +C419 [*] Unnecessary list comprehension + --> C419_1.py:14:5 | 12 | # Multi-line 13 | sum( @@ -84,11 +89,11 @@ C419_1.py:14:5: C419 [*] Unnecessary list comprehension 16 | | for delta in timedelta_list 17 | | if delta 18 | | ], - | |_____^ C419 + | |_____^ 19 | dt.timedelta(), 20 | ) | - = help: Remove unnecessary comprehension +help: Remove unnecessary comprehension ℹ Unsafe fix 11 11 | diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__char_boundary.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__char_boundary.snap index 4a99d41b49..422b418321 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__char_boundary.snap +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__char_boundary.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs -snapshot_kind: text --- -:1:1: CPY001 Missing copyright notice at top of file +CPY001 Missing copyright notice at top of file +--> :1:1 diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__invalid_author.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__invalid_author.snap index 4a99d41b49..422b418321 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__invalid_author.snap +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__invalid_author.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs -snapshot_kind: text --- -:1:1: CPY001 Missing copyright notice at top of file +CPY001 Missing copyright notice at top of file +--> :1:1 diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__late_notice.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__late_notice.snap index 4a99d41b49..422b418321 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__late_notice.snap +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__late_notice.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs -snapshot_kind: text --- -:1:1: CPY001 Missing copyright notice at top of file +CPY001 Missing copyright notice at top of file +--> :1:1 diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_comma_invalid_no_space.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_comma_invalid_no_space.snap index 4a99d41b49..422b418321 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_comma_invalid_no_space.snap +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_comma_invalid_no_space.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs -snapshot_kind: text --- -:1:1: CPY001 Missing copyright notice at top of file +CPY001 Missing copyright notice at top of file +--> :1:1 diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_comma_invalid_spaces.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_comma_invalid_spaces.snap index 4a99d41b49..422b418321 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_comma_invalid_spaces.snap +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_comma_invalid_spaces.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs -snapshot_kind: text --- -:1:1: CPY001 Missing copyright notice at top of file +CPY001 Missing copyright notice at top of file +--> :1:1 diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_dash_invalid_space.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_dash_invalid_space.snap index 4a99d41b49..422b418321 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_dash_invalid_space.snap +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_dash_invalid_space.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs -snapshot_kind: text --- -:1:1: CPY001 Missing copyright notice at top of file +CPY001 Missing copyright notice at top of file +--> :1:1 diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_dash_invalid_spaces.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_dash_invalid_spaces.snap index 4a99d41b49..422b418321 100644 --- a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_dash_invalid_spaces.snap +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author_with_dash_invalid_spaces.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs -snapshot_kind: text --- -:1:1: CPY001 Missing copyright notice at top of file +CPY001 Missing copyright notice at top of file +--> :1:1 diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap index 05999334ca..2f7b926349 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap @@ -1,52 +1,57 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ001.py:4:1: DTZ001 `datetime.datetime()` called without a `tzinfo` argument +DTZ001 `datetime.datetime()` called without a `tzinfo` argument + --> DTZ001.py:4:1 | 3 | # no args 4 | datetime.datetime(2000, 1, 1, 0, 0, 0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | # none args | - = help: Pass a `datetime.timezone` object to the `tzinfo` parameter +help: Pass a `datetime.timezone` object to the `tzinfo` parameter -DTZ001.py:7:1: DTZ001 `tzinfo=None` passed to `datetime.datetime()` +DTZ001 `tzinfo=None` passed to `datetime.datetime()` + --> DTZ001.py:7:1 | 6 | # none args 7 | datetime.datetime(2000, 1, 1, 0, 0, 0, 0, None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # not none arg | - = help: Pass a `datetime.timezone` object to the `tzinfo` parameter +help: Pass a `datetime.timezone` object to the `tzinfo` parameter -DTZ001.py:13:1: DTZ001 `datetime.datetime()` called without a `tzinfo` argument +DTZ001 `datetime.datetime()` called without a `tzinfo` argument + --> DTZ001.py:13:1 | 12 | # no kwargs 13 | datetime.datetime(2000, 1, 1, fold=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # none kwargs | - = help: Pass a `datetime.timezone` object to the `tzinfo` parameter +help: Pass a `datetime.timezone` object to the `tzinfo` parameter -DTZ001.py:16:1: DTZ001 `tzinfo=None` passed to `datetime.datetime()` +DTZ001 `tzinfo=None` passed to `datetime.datetime()` + --> DTZ001.py:16:1 | 15 | # none kwargs 16 | datetime.datetime(2000, 1, 1, tzinfo=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | from datetime import datetime | - = help: Pass a `datetime.timezone` object to the `tzinfo` parameter +help: Pass a `datetime.timezone` object to the `tzinfo` parameter -DTZ001.py:21:1: DTZ001 `datetime.datetime()` called without a `tzinfo` argument +DTZ001 `datetime.datetime()` called without a `tzinfo` argument + --> DTZ001.py:21:1 | 20 | # no args unqualified 21 | datetime(2000, 1, 1, 0, 0, 0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | # uses `astimezone` method | - = help: Pass a `datetime.timezone` object to the `tzinfo` parameter +help: Pass a `datetime.timezone` object to the `tzinfo` parameter diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap index 34a34d1d83..d76d27659c 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap @@ -1,22 +1,24 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ002.py:4:1: DTZ002 `datetime.datetime.today()` used +DTZ002 `datetime.datetime.today()` used + --> DTZ002.py:4:1 | 3 | # qualified 4 | datetime.datetime.today() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | from datetime import datetime | - = help: Use `datetime.datetime.now(tz=...)` instead +help: Use `datetime.datetime.now(tz=...)` instead -DTZ002.py:9:1: DTZ002 `datetime.datetime.today()` used +DTZ002 `datetime.datetime.today()` used + --> DTZ002.py:9:1 | 8 | # unqualified 9 | datetime.today() - | ^^^^^^^^^^^^^^^^ DTZ002 + | ^^^^^^^^^^^^^^^^ 10 | 11 | # uses `astimezone` method | - = help: Use `datetime.datetime.now(tz=...)` instead +help: Use `datetime.datetime.now(tz=...)` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap index b436bff261..0e5944b2ed 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap @@ -1,22 +1,24 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ003.py:4:1: DTZ003 `datetime.datetime.utcnow()` used +DTZ003 `datetime.datetime.utcnow()` used + --> DTZ003.py:4:1 | 3 | # qualified 4 | datetime.datetime.utcnow() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | from datetime import datetime | - = help: Use `datetime.datetime.now(tz=...)` instead +help: Use `datetime.datetime.now(tz=...)` instead -DTZ003.py:9:1: DTZ003 `datetime.datetime.utcnow()` used +DTZ003 `datetime.datetime.utcnow()` used + --> DTZ003.py:9:1 | 8 | # unqualified 9 | datetime.utcnow() - | ^^^^^^^^^^^^^^^^^ DTZ003 + | ^^^^^^^^^^^^^^^^^ 10 | 11 | # uses `astimezone` method | - = help: Use `datetime.datetime.now(tz=...)` instead +help: Use `datetime.datetime.now(tz=...)` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap index 41c2b782a9..d5666f4264 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap @@ -1,22 +1,24 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ004.py:4:1: DTZ004 `datetime.datetime.utcfromtimestamp()` used +DTZ004 `datetime.datetime.utcfromtimestamp()` used + --> DTZ004.py:4:1 | 3 | # qualified 4 | datetime.datetime.utcfromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | from datetime import datetime | - = help: Use `datetime.datetime.fromtimestamp(ts, tz=...)` instead +help: Use `datetime.datetime.fromtimestamp(ts, tz=...)` instead -DTZ004.py:9:1: DTZ004 `datetime.datetime.utcfromtimestamp()` used +DTZ004 `datetime.datetime.utcfromtimestamp()` used + --> DTZ004.py:9:1 | 8 | # unqualified 9 | datetime.utcfromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # uses `astimezone` method | - = help: Use `datetime.datetime.fromtimestamp(ts, tz=...)` instead +help: Use `datetime.datetime.fromtimestamp(ts, tz=...)` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap index 33ac751e3a..b004d89412 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap @@ -1,105 +1,115 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ005.py:4:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument +DTZ005 `datetime.datetime.now()` called without a `tz` argument + --> DTZ005.py:4:1 | 3 | # no args 4 | datetime.datetime.now() - | ^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | # wrong keywords | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:7:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument +DTZ005 `datetime.datetime.now()` called without a `tz` argument + --> DTZ005.py:7:1 | 6 | # wrong keywords 7 | datetime.datetime.now(bad=datetime.timezone.utc) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # none args | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:10:1: DTZ005 `tz=None` passed to `datetime.datetime.now()` +DTZ005 `tz=None` passed to `datetime.datetime.now()` + --> DTZ005.py:10:1 | 9 | # none args 10 | datetime.datetime.now(None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | # none keywords | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:13:1: DTZ005 `tz=None` passed to `datetime.datetime.now()` +DTZ005 `tz=None` passed to `datetime.datetime.now()` + --> DTZ005.py:13:1 | 12 | # none keywords 13 | datetime.datetime.now(tz=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | from datetime import datetime | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:18:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument +DTZ005 `datetime.datetime.now()` called without a `tz` argument + --> DTZ005.py:18:1 | 17 | # no args unqualified 18 | datetime.now() - | ^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^ 19 | 20 | # uses `astimezone` method | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:28:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument +DTZ005 `datetime.datetime.now()` called without a `tz` argument + --> DTZ005.py:28:1 | 27 | ## Errors 28 | datetime.now().replace.astimezone() - | ^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^ 29 | datetime.now().replace[0].astimezone() 30 | datetime.now()().astimezone() | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:29:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument +DTZ005 `datetime.datetime.now()` called without a `tz` argument + --> DTZ005.py:29:1 | 27 | ## Errors 28 | datetime.now().replace.astimezone() 29 | datetime.now().replace[0].astimezone() - | ^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^ 30 | datetime.now()().astimezone() 31 | datetime.now().replace(datetime.now()).astimezone() | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:30:1: DTZ005 `datetime.datetime.now()` called without a `tz` argument +DTZ005 `datetime.datetime.now()` called without a `tz` argument + --> DTZ005.py:30:1 | 28 | datetime.now().replace.astimezone() 29 | datetime.now().replace[0].astimezone() 30 | datetime.now()().astimezone() - | ^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^ 31 | datetime.now().replace(datetime.now()).astimezone() | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:31:24: DTZ005 `datetime.datetime.now()` called without a `tz` argument +DTZ005 `datetime.datetime.now()` called without a `tz` argument + --> DTZ005.py:31:24 | 29 | datetime.now().replace[0].astimezone() 30 | datetime.now()().astimezone() 31 | datetime.now().replace(datetime.now()).astimezone() - | ^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^ 32 | 33 | foo.replace(datetime.now().replace).astimezone() | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ005.py:33:13: DTZ005 `datetime.datetime.now()` called without a `tz` argument +DTZ005 `datetime.datetime.now()` called without a `tz` argument + --> DTZ005.py:33:13 | 31 | datetime.now().replace(datetime.now()).astimezone() 32 | 33 | foo.replace(datetime.now().replace).astimezone() - | ^^^^^^^^^^^^^^ DTZ005 + | ^^^^^^^^^^^^^^ 34 | 35 | ## No errors | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap index 7ce79909c4..e7446bfcbd 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap @@ -1,52 +1,57 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ006.py:4:1: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument +DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument + --> DTZ006.py:4:1 | 3 | # no args 4 | datetime.datetime.fromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | # wrong keywords | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ006.py:7:1: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument +DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument + --> DTZ006.py:7:1 | 6 | # wrong keywords 7 | datetime.datetime.fromtimestamp(1234, bad=datetime.timezone.utc) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # none args | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ006.py:10:1: DTZ006 `tz=None` passed to `datetime.datetime.fromtimestamp()` +DTZ006 `tz=None` passed to `datetime.datetime.fromtimestamp()` + --> DTZ006.py:10:1 | 9 | # none args 10 | datetime.datetime.fromtimestamp(1234, None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | # none keywords | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ006.py:13:1: DTZ006 `tz=None` passed to `datetime.datetime.fromtimestamp()` +DTZ006 `tz=None` passed to `datetime.datetime.fromtimestamp()` + --> DTZ006.py:13:1 | 12 | # none keywords 13 | datetime.datetime.fromtimestamp(1234, tz=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | from datetime import datetime | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter -DTZ006.py:18:1: DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument +DTZ006 `datetime.datetime.fromtimestamp()` called without a `tz` argument + --> DTZ006.py:18:1 | 17 | # no args unqualified 18 | datetime.fromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # uses `astimezone` method | - = help: Pass a `datetime.timezone` object to the `tz` parameter +help: Pass a `datetime.timezone` object to the `tz` parameter diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap index 06b7452962..710c5c9780 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap @@ -1,52 +1,57 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ007.py:4:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z +DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z + --> DTZ007.py:4:1 | 3 | # bad format 4 | datetime.datetime.strptime("something", "%H:%M:%S%Z") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | # no replace or astimezone | - = help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime +help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime -DTZ007.py:7:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z +DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z + --> DTZ007.py:7:1 | 6 | # no replace or astimezone 7 | datetime.datetime.strptime("something", "something") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # wrong replace | - = help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime +help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime -DTZ007.py:10:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z +DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z + --> DTZ007.py:10:1 | 9 | # wrong replace 10 | datetime.datetime.strptime("something", "something").replace(hour=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | # none replace | - = help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime +help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime -DTZ007.py:13:1: DTZ007 `datetime.datetime.strptime(...).replace(tz=None)` used +DTZ007 `datetime.datetime.strptime(...).replace(tz=None)` used + --> DTZ007.py:13:1 | 12 | # none replace 13 | datetime.datetime.strptime("something", "something").replace(tzinfo=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # OK | - = help: Pass a `datetime.timezone` object to the `tzinfo` parameter +help: Pass a `datetime.timezone` object to the `tzinfo` parameter -DTZ007.py:35:1: DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z +DTZ007 Naive datetime constructed using `datetime.datetime.strptime()` without %z + --> DTZ007.py:35:1 | 34 | # no replace orastimezone unqualified 35 | datetime.strptime("something", "something") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | 37 | # F-strings | - = help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime +help: Call `.replace(tzinfo=)` or `.astimezone()` to convert to an aware datetime diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap index b15b8f9266..3168567485 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ011.py:4:1: DTZ011 `datetime.date.today()` used +DTZ011 `datetime.date.today()` used + --> DTZ011.py:4:1 | 3 | # qualified 4 | datetime.date.today() - | ^^^^^^^^^^^^^^^^^^^^^ DTZ011 + | ^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | from datetime import date | - = help: Use `datetime.datetime.now(tz=...).date()` instead +help: Use `datetime.datetime.now(tz=...).date()` instead -DTZ011.py:9:1: DTZ011 `datetime.date.today()` used +DTZ011 `datetime.date.today()` used + --> DTZ011.py:9:1 | 8 | # unqualified 9 | date.today() - | ^^^^^^^^^^^^ DTZ011 + | ^^^^^^^^^^^^ | - = help: Use `datetime.datetime.now(tz=...).date()` instead +help: Use `datetime.datetime.now(tz=...).date()` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap index 2c8ab9d321..9160496ea6 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ012.py:4:1: DTZ012 `datetime.date.fromtimestamp()` used +DTZ012 `datetime.date.fromtimestamp()` used + --> DTZ012.py:4:1 | 3 | # qualified 4 | datetime.date.fromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | from datetime import date | - = help: Use `datetime.datetime.fromtimestamp(ts, tz=...).date()` instead +help: Use `datetime.datetime.fromtimestamp(ts, tz=...).date()` instead -DTZ012.py:9:1: DTZ012 `datetime.date.fromtimestamp()` used +DTZ012 `datetime.date.fromtimestamp()` used + --> DTZ012.py:9:1 | 8 | # unqualified 9 | date.fromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^ DTZ012 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `datetime.datetime.fromtimestamp(ts, tz=...).date()` instead +help: Use `datetime.datetime.fromtimestamp(ts, tz=...).date()` instead diff --git a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ901_DTZ901.py.snap b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ901_DTZ901.py.snap index 87a4d1a557..193014c717 100644 --- a/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ901_DTZ901.py.snap +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ901_DTZ901.py.snap @@ -1,78 +1,86 @@ --- source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs --- -DTZ901.py:5:1: DTZ901 Use of `datetime.datetime.max` without timezone information +DTZ901 Use of `datetime.datetime.max` without timezone information + --> DTZ901.py:5:1 | 4 | # Error 5 | datetime.datetime.max - | ^^^^^^^^^^^^^^^^^^^^^ DTZ901 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | datetime.datetime.min | - = help: Replace with `datetime.datetime.max.replace(tzinfo=...)` +help: Replace with `datetime.datetime.max.replace(tzinfo=...)` -DTZ901.py:6:1: DTZ901 Use of `datetime.datetime.min` without timezone information +DTZ901 Use of `datetime.datetime.min` without timezone information + --> DTZ901.py:6:1 | 4 | # Error 5 | datetime.datetime.max 6 | datetime.datetime.min - | ^^^^^^^^^^^^^^^^^^^^^ DTZ901 + | ^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | datetime.datetime.max.replace(year=...) | - = help: Replace with `datetime.datetime.min.replace(tzinfo=...)` +help: Replace with `datetime.datetime.min.replace(tzinfo=...)` -DTZ901.py:8:1: DTZ901 Use of `datetime.datetime.max` without timezone information +DTZ901 Use of `datetime.datetime.max` without timezone information + --> DTZ901.py:8:1 | 6 | datetime.datetime.min 7 | 8 | datetime.datetime.max.replace(year=...) - | ^^^^^^^^^^^^^^^^^^^^^ DTZ901 + | ^^^^^^^^^^^^^^^^^^^^^ 9 | datetime.datetime.min.replace(hour=...) | - = help: Replace with `datetime.datetime.max.replace(tzinfo=...)` +help: Replace with `datetime.datetime.max.replace(tzinfo=...)` -DTZ901.py:9:1: DTZ901 Use of `datetime.datetime.min` without timezone information +DTZ901 Use of `datetime.datetime.min` without timezone information + --> DTZ901.py:9:1 | 8 | datetime.datetime.max.replace(year=...) 9 | datetime.datetime.min.replace(hour=...) - | ^^^^^^^^^^^^^^^^^^^^^ DTZ901 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `datetime.datetime.min.replace(tzinfo=...)` +help: Replace with `datetime.datetime.min.replace(tzinfo=...)` -DTZ901.py:27:1: DTZ901 Use of `datetime.datetime.max` without timezone information +DTZ901 Use of `datetime.datetime.max` without timezone information + --> DTZ901.py:27:1 | 26 | # Error 27 | datetime.max - | ^^^^^^^^^^^^ DTZ901 + | ^^^^^^^^^^^^ 28 | datetime.min | - = help: Replace with `datetime.datetime.max.replace(tzinfo=...)` +help: Replace with `datetime.datetime.max.replace(tzinfo=...)` -DTZ901.py:28:1: DTZ901 Use of `datetime.datetime.min` without timezone information +DTZ901 Use of `datetime.datetime.min` without timezone information + --> DTZ901.py:28:1 | 26 | # Error 27 | datetime.max 28 | datetime.min - | ^^^^^^^^^^^^ DTZ901 + | ^^^^^^^^^^^^ 29 | 30 | datetime.max.replace(year=...) | - = help: Replace with `datetime.datetime.min.replace(tzinfo=...)` +help: Replace with `datetime.datetime.min.replace(tzinfo=...)` -DTZ901.py:30:1: DTZ901 Use of `datetime.datetime.max` without timezone information +DTZ901 Use of `datetime.datetime.max` without timezone information + --> DTZ901.py:30:1 | 28 | datetime.min 29 | 30 | datetime.max.replace(year=...) - | ^^^^^^^^^^^^ DTZ901 + | ^^^^^^^^^^^^ 31 | datetime.min.replace(hour=...) | - = help: Replace with `datetime.datetime.max.replace(tzinfo=...)` +help: Replace with `datetime.datetime.max.replace(tzinfo=...)` -DTZ901.py:31:1: DTZ901 Use of `datetime.datetime.min` without timezone information +DTZ901 Use of `datetime.datetime.min` without timezone information + --> DTZ901.py:31:1 | 30 | datetime.max.replace(year=...) 31 | datetime.min.replace(hour=...) - | ^^^^^^^^^^^^ DTZ901 + | ^^^^^^^^^^^^ | - = help: Replace with `datetime.datetime.min.replace(tzinfo=...)` +help: Replace with `datetime.datetime.min.replace(tzinfo=...)` diff --git a/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap b/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap index 75baaa0379..e8b2f2a1fa 100644 --- a/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap +++ b/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap @@ -1,239 +1,264 @@ --- source: crates/ruff_linter/src/rules/flake8_debugger/mod.rs --- -T100.py:1:1: T100 Trace found: `breakpoint` used +T100 Trace found: `breakpoint` used + --> T100.py:1:1 | 1 | breakpoint() - | ^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^ 2 | 3 | import pdb | -T100.py:3:1: T100 Import for `pdb` found +T100 Import for `pdb` found + --> T100.py:3:1 | 1 | breakpoint() 2 | 3 | import pdb - | ^^^^^^^^^^ T100 + | ^^^^^^^^^^ 4 | import builtins 5 | from builtins import breakpoint | -T100.py:5:1: T100 Import for `builtins.breakpoint` found +T100 Import for `builtins.breakpoint` found + --> T100.py:5:1 | 3 | import pdb 4 | import builtins 5 | from builtins import breakpoint - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | from pdb import set_trace as st 7 | from celery.contrib.rdb import set_trace | -T100.py:6:1: T100 Import for `pdb.set_trace` found +T100 Import for `pdb.set_trace` found + --> T100.py:6:1 | 4 | import builtins 5 | from builtins import breakpoint 6 | from pdb import set_trace as st - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | from celery.contrib.rdb import set_trace 8 | from celery.contrib import rdb | -T100.py:7:1: T100 Import for `celery.contrib.rdb.set_trace` found +T100 Import for `celery.contrib.rdb.set_trace` found + --> T100.py:7:1 | 5 | from builtins import breakpoint 6 | from pdb import set_trace as st 7 | from celery.contrib.rdb import set_trace - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | from celery.contrib import rdb 9 | import celery.contrib.rdb | -T100.py:9:1: T100 Import for `celery.contrib.rdb` found +T100 Import for `celery.contrib.rdb` found + --> T100.py:9:1 | 7 | from celery.contrib.rdb import set_trace 8 | from celery.contrib import rdb 9 | import celery.contrib.rdb - | ^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | from debugpy import wait_for_client 11 | import debugpy | -T100.py:10:1: T100 Import for `debugpy.wait_for_client` found +T100 Import for `debugpy.wait_for_client` found + --> T100.py:10:1 | 8 | from celery.contrib import rdb 9 | import celery.contrib.rdb 10 | from debugpy import wait_for_client - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | import debugpy 12 | from ptvsd import break_into_debugger | -T100.py:11:1: T100 Import for `debugpy` found +T100 Import for `debugpy` found + --> T100.py:11:1 | 9 | import celery.contrib.rdb 10 | from debugpy import wait_for_client 11 | import debugpy - | ^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^ 12 | from ptvsd import break_into_debugger 13 | from ptvsd import enable_attach | -T100.py:12:1: T100 Import for `ptvsd.break_into_debugger` found +T100 Import for `ptvsd.break_into_debugger` found + --> T100.py:12:1 | 10 | from debugpy import wait_for_client 11 | import debugpy 12 | from ptvsd import break_into_debugger - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | from ptvsd import enable_attach 14 | from ptvsd import wait_for_attach | -T100.py:14:1: T100 Import for `ptvsd.wait_for_attach` found +T100 Import for `ptvsd.wait_for_attach` found + --> T100.py:14:1 | 12 | from ptvsd import break_into_debugger 13 | from ptvsd import enable_attach 14 | from ptvsd import wait_for_attach - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | import ptvsd | -T100.py:15:1: T100 Import for `ptvsd` found +T100 Import for `ptvsd` found + --> T100.py:15:1 | 13 | from ptvsd import enable_attach 14 | from ptvsd import wait_for_attach 15 | import ptvsd - | ^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^ 16 | 17 | breakpoint() | -T100.py:17:1: T100 Trace found: `builtins.breakpoint` used +T100 Trace found: `builtins.breakpoint` used + --> T100.py:17:1 | 15 | import ptvsd 16 | 17 | breakpoint() - | ^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^ 18 | st() 19 | set_trace() | -T100.py:18:1: T100 Trace found: `pdb.set_trace` used +T100 Trace found: `pdb.set_trace` used + --> T100.py:18:1 | 17 | breakpoint() 18 | st() - | ^^^^ T100 + | ^^^^ 19 | set_trace() 20 | debugpy.breakpoint() | -T100.py:19:1: T100 Trace found: `celery.contrib.rdb.set_trace` used +T100 Trace found: `celery.contrib.rdb.set_trace` used + --> T100.py:19:1 | 17 | breakpoint() 18 | st() 19 | set_trace() - | ^^^^^^^^^^^ T100 + | ^^^^^^^^^^^ 20 | debugpy.breakpoint() 21 | wait_for_client() | -T100.py:20:1: T100 Trace found: `debugpy.breakpoint` used +T100 Trace found: `debugpy.breakpoint` used + --> T100.py:20:1 | 18 | st() 19 | set_trace() 20 | debugpy.breakpoint() - | ^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^ 21 | wait_for_client() 22 | debugpy.listen(1234) | -T100.py:21:1: T100 Trace found: `debugpy.wait_for_client` used +T100 Trace found: `debugpy.wait_for_client` used + --> T100.py:21:1 | 19 | set_trace() 20 | debugpy.breakpoint() 21 | wait_for_client() - | ^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^ 22 | debugpy.listen(1234) 23 | enable_attach() | -T100.py:22:1: T100 Trace found: `debugpy.listen` used +T100 Trace found: `debugpy.listen` used + --> T100.py:22:1 | 20 | debugpy.breakpoint() 21 | wait_for_client() 22 | debugpy.listen(1234) - | ^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^ 23 | enable_attach() 24 | break_into_debugger() | -T100.py:24:1: T100 Trace found: `ptvsd.break_into_debugger` used +T100 Trace found: `ptvsd.break_into_debugger` used + --> T100.py:24:1 | 22 | debugpy.listen(1234) 23 | enable_attach() 24 | break_into_debugger() - | ^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^ 25 | wait_for_attach() | -T100.py:25:1: T100 Trace found: `ptvsd.wait_for_attach` used +T100 Trace found: `ptvsd.wait_for_attach` used + --> T100.py:25:1 | 23 | enable_attach() 24 | break_into_debugger() 25 | wait_for_attach() - | ^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^ | -T100.py:33:5: T100 Import for `sys.breakpointhook` found +T100 Import for `sys.breakpointhook` found + --> T100.py:33:5 | 32 | def scope(): 33 | from sys import breakpointhook # error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | 35 | breakpointhook() # error | -T100.py:35:5: T100 Trace found: `sys.breakpointhook` used +T100 Trace found: `sys.breakpointhook` used + --> T100.py:35:5 | 33 | from sys import breakpointhook # error 34 | 35 | breakpointhook() # error - | ^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^ 36 | 37 | def scope(): | -T100.py:38:5: T100 Import for `sys.__breakpointhook__` found +T100 Import for `sys.__breakpointhook__` found + --> T100.py:38:5 | 37 | def scope(): 38 | from sys import __breakpointhook__ # error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | 40 | __breakpointhook__() # error | -T100.py:40:5: T100 Trace found: `sys.__breakpointhook__` used +T100 Trace found: `sys.__breakpointhook__` used + --> T100.py:40:5 | 38 | from sys import __breakpointhook__ # error 39 | 40 | __breakpointhook__() # error - | ^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^ 41 | 42 | sys.breakpointhook() # error | -T100.py:42:1: T100 Trace found: `sys.breakpointhook` used +T100 Trace found: `sys.breakpointhook` used + --> T100.py:42:1 | 40 | __breakpointhook__() # error 41 | 42 | sys.breakpointhook() # error - | ^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^ 43 | sys.__breakpointhook__() # error | -T100.py:43:1: T100 Trace found: `sys.__breakpointhook__` used +T100 Trace found: `sys.__breakpointhook__` used + --> T100.py:43:1 | 42 | sys.breakpointhook() # error 43 | sys.__breakpointhook__() # error - | ^^^^^^^^^^^^^^^^^^^^^^^^ T100 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ001_DJ001.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ001_DJ001.py.snap index cbb03a4067..dccc159fa5 100644 --- a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ001_DJ001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ001_DJ001.py.snap @@ -1,171 +1,188 @@ --- source: crates/ruff_linter/src/rules/flake8_django/mod.rs -snapshot_kind: text --- -DJ001.py:7:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField` +DJ001 Avoid using `null=True` on string-based fields such as `CharField` + --> DJ001.py:7:17 | 6 | class IncorrectModel(models.Model): 7 | charfield = models.CharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | textfield = models.TextField(max_length=255, null=True) 9 | slugfield = models.SlugField(max_length=255, null=True) | -DJ001.py:8:17: DJ001 Avoid using `null=True` on string-based fields such as `TextField` +DJ001 Avoid using `null=True` on string-based fields such as `TextField` + --> DJ001.py:8:17 | 6 | class IncorrectModel(models.Model): 7 | charfield = models.CharField(max_length=255, null=True) 8 | textfield = models.TextField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | slugfield = models.SlugField(max_length=255, null=True) 10 | emailfield = models.EmailField(max_length=255, null=True) | -DJ001.py:9:17: DJ001 Avoid using `null=True` on string-based fields such as `SlugField` +DJ001 Avoid using `null=True` on string-based fields such as `SlugField` + --> DJ001.py:9:17 | 7 | charfield = models.CharField(max_length=255, null=True) 8 | textfield = models.TextField(max_length=255, null=True) 9 | slugfield = models.SlugField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | emailfield = models.EmailField(max_length=255, null=True) 11 | filepathfield = models.FilePathField(max_length=255, null=True) | -DJ001.py:10:18: DJ001 Avoid using `null=True` on string-based fields such as `EmailField` +DJ001 Avoid using `null=True` on string-based fields such as `EmailField` + --> DJ001.py:10:18 | 8 | textfield = models.TextField(max_length=255, null=True) 9 | slugfield = models.SlugField(max_length=255, null=True) 10 | emailfield = models.EmailField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | filepathfield = models.FilePathField(max_length=255, null=True) 12 | urlfield = models.URLField(max_length=255, null=True) | -DJ001.py:11:21: DJ001 Avoid using `null=True` on string-based fields such as `FilePathField` +DJ001 Avoid using `null=True` on string-based fields such as `FilePathField` + --> DJ001.py:11:21 | 9 | slugfield = models.SlugField(max_length=255, null=True) 10 | emailfield = models.EmailField(max_length=255, null=True) 11 | filepathfield = models.FilePathField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | urlfield = models.URLField(max_length=255, null=True) | -DJ001.py:12:16: DJ001 Avoid using `null=True` on string-based fields such as `URLField` +DJ001 Avoid using `null=True` on string-based fields such as `URLField` + --> DJ001.py:12:16 | 10 | emailfield = models.EmailField(max_length=255, null=True) 11 | filepathfield = models.FilePathField(max_length=255, null=True) 12 | urlfield = models.URLField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -DJ001.py:16:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField` +DJ001 Avoid using `null=True` on string-based fields such as `CharField` + --> DJ001.py:16:17 | 15 | class IncorrectModelWithAlias(DjangoModel): 16 | charfield = DjangoModel.CharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | textfield = SmthCharField(max_length=255, null=True) 18 | slugfield = models.SlugField(max_length=255, null=True) | -DJ001.py:17:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField` +DJ001 Avoid using `null=True` on string-based fields such as `CharField` + --> DJ001.py:17:17 | 15 | class IncorrectModelWithAlias(DjangoModel): 16 | charfield = DjangoModel.CharField(max_length=255, null=True) 17 | textfield = SmthCharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | slugfield = models.SlugField(max_length=255, null=True) 19 | emailfield = models.EmailField(max_length=255, null=True) | -DJ001.py:18:17: DJ001 Avoid using `null=True` on string-based fields such as `SlugField` +DJ001 Avoid using `null=True` on string-based fields such as `SlugField` + --> DJ001.py:18:17 | 16 | charfield = DjangoModel.CharField(max_length=255, null=True) 17 | textfield = SmthCharField(max_length=255, null=True) 18 | slugfield = models.SlugField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | emailfield = models.EmailField(max_length=255, null=True) 20 | filepathfield = models.FilePathField(max_length=255, null=True) | -DJ001.py:19:18: DJ001 Avoid using `null=True` on string-based fields such as `EmailField` +DJ001 Avoid using `null=True` on string-based fields such as `EmailField` + --> DJ001.py:19:18 | 17 | textfield = SmthCharField(max_length=255, null=True) 18 | slugfield = models.SlugField(max_length=255, null=True) 19 | emailfield = models.EmailField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | filepathfield = models.FilePathField(max_length=255, null=True) 21 | urlfield = models.URLField(max_length=255, null=True) | -DJ001.py:20:21: DJ001 Avoid using `null=True` on string-based fields such as `FilePathField` +DJ001 Avoid using `null=True` on string-based fields such as `FilePathField` + --> DJ001.py:20:21 | 18 | slugfield = models.SlugField(max_length=255, null=True) 19 | emailfield = models.EmailField(max_length=255, null=True) 20 | filepathfield = models.FilePathField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | urlfield = models.URLField(max_length=255, null=True) | -DJ001.py:21:16: DJ001 Avoid using `null=True` on string-based fields such as `URLField` +DJ001 Avoid using `null=True` on string-based fields such as `URLField` + --> DJ001.py:21:16 | 19 | emailfield = models.EmailField(max_length=255, null=True) 20 | filepathfield = models.FilePathField(max_length=255, null=True) 21 | urlfield = models.URLField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -DJ001.py:25:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField` +DJ001 Avoid using `null=True` on string-based fields such as `CharField` + --> DJ001.py:25:17 | 24 | class IncorrectModelWithoutSuperclass: 25 | charfield = DjangoModel.CharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | textfield = SmthCharField(max_length=255, null=True) 27 | slugfield = models.SlugField(max_length=255, null=True) | -DJ001.py:26:17: DJ001 Avoid using `null=True` on string-based fields such as `CharField` +DJ001 Avoid using `null=True` on string-based fields such as `CharField` + --> DJ001.py:26:17 | 24 | class IncorrectModelWithoutSuperclass: 25 | charfield = DjangoModel.CharField(max_length=255, null=True) 26 | textfield = SmthCharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | slugfield = models.SlugField(max_length=255, null=True) 28 | emailfield = models.EmailField(max_length=255, null=True) | -DJ001.py:27:17: DJ001 Avoid using `null=True` on string-based fields such as `SlugField` +DJ001 Avoid using `null=True` on string-based fields such as `SlugField` + --> DJ001.py:27:17 | 25 | charfield = DjangoModel.CharField(max_length=255, null=True) 26 | textfield = SmthCharField(max_length=255, null=True) 27 | slugfield = models.SlugField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | emailfield = models.EmailField(max_length=255, null=True) 29 | filepathfield = models.FilePathField(max_length=255, null=True) | -DJ001.py:28:18: DJ001 Avoid using `null=True` on string-based fields such as `EmailField` +DJ001 Avoid using `null=True` on string-based fields such as `EmailField` + --> DJ001.py:28:18 | 26 | textfield = SmthCharField(max_length=255, null=True) 27 | slugfield = models.SlugField(max_length=255, null=True) 28 | emailfield = models.EmailField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | filepathfield = models.FilePathField(max_length=255, null=True) 30 | urlfield = models.URLField(max_length=255, null=True) | -DJ001.py:29:21: DJ001 Avoid using `null=True` on string-based fields such as `FilePathField` +DJ001 Avoid using `null=True` on string-based fields such as `FilePathField` + --> DJ001.py:29:21 | 27 | slugfield = models.SlugField(max_length=255, null=True) 28 | emailfield = models.EmailField(max_length=255, null=True) 29 | filepathfield = models.FilePathField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | urlfield = models.URLField(max_length=255, null=True) | -DJ001.py:30:16: DJ001 Avoid using `null=True` on string-based fields such as `URLField` +DJ001 Avoid using `null=True` on string-based fields such as `URLField` + --> DJ001.py:30:16 | 28 | emailfield = models.EmailField(max_length=255, null=True) 29 | filepathfield = models.FilePathField(max_length=255, null=True) 30 | urlfield = models.URLField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ003_DJ003.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ003_DJ003.py.snap index 9dad4f65f4..e07b14604c 100644 --- a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ003_DJ003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ003_DJ003.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_django/mod.rs -snapshot_kind: text --- -DJ003.py:5:42: DJ003 Avoid passing `locals()` as context to a `render` function +DJ003 Avoid passing `locals()` as context to a `render` function + --> DJ003.py:5:42 | 4 | def test_view1(request): 5 | return render(request, "index.html", locals()) - | ^^^^^^^^ DJ003 + | ^^^^^^^^ | -DJ003.py:9:50: DJ003 Avoid passing `locals()` as context to a `render` function +DJ003 Avoid passing `locals()` as context to a `render` function + --> DJ003.py:9:50 | 8 | def test_view2(request): 9 | return render(request, "index.html", context=locals()) - | ^^^^^^^^ DJ003 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ006_DJ006.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ006_DJ006.py.snap index 206c703559..a78edbc248 100644 --- a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ006_DJ006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ006_DJ006.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_django/mod.rs -snapshot_kind: text --- -DJ006.py:6:9: DJ006 Do not use `exclude` with `ModelForm`, use `fields` instead +DJ006 Do not use `exclude` with `ModelForm`, use `fields` instead + --> DJ006.py:6:9 | 4 | class TestModelForm1(forms.ModelForm): 5 | class Meta: 6 | exclude = ["bar"] - | ^^^^^^^ DJ006 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ007_DJ007.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ007_DJ007.py.snap index c7ad057ae8..6220696a2d 100644 --- a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ007_DJ007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ007_DJ007.py.snap @@ -1,19 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_django/mod.rs -snapshot_kind: text --- -DJ007.py:6:9: DJ007 Do not use `__all__` with `ModelForm`, use `fields` instead +DJ007 Do not use `__all__` with `ModelForm`, use `fields` instead + --> DJ007.py:6:9 | 4 | class TestModelForm1(forms.ModelForm): 5 | class Meta: 6 | fields = "__all__" - | ^^^^^^^^^^^^^^^^^^ DJ007 + | ^^^^^^^^^^^^^^^^^^ | -DJ007.py:11:9: DJ007 Do not use `__all__` with `ModelForm`, use `fields` instead +DJ007 Do not use `__all__` with `ModelForm`, use `fields` instead + --> DJ007.py:11:9 | 9 | class TestModelForm2(forms.ModelForm): 10 | class Meta: 11 | fields = b"__all__" - | ^^^^^^^^^^^^^^^^^^^ DJ007 + | ^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ008_DJ008.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ008_DJ008.py.snap index 5a6f1e4c9d..904c81d533 100644 --- a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ008_DJ008.py.snap +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ008_DJ008.py.snap @@ -1,40 +1,45 @@ --- source: crates/ruff_linter/src/rules/flake8_django/mod.rs --- -DJ008.py:6:7: DJ008 Model does not define `__str__` method +DJ008 Model does not define `__str__` method + --> DJ008.py:6:7 | 5 | # Models without __str__ 6 | class TestModel1(models.Model): - | ^^^^^^^^^^ DJ008 + | ^^^^^^^^^^ 7 | new_field = models.CharField(max_length=10) | -DJ008.py:21:7: DJ008 Model does not define `__str__` method +DJ008 Model does not define `__str__` method + --> DJ008.py:21:7 | 21 | class TestModel2(Model): - | ^^^^^^^^^^ DJ008 + | ^^^^^^^^^^ 22 | new_field = models.CharField(max_length=10) | -DJ008.py:36:7: DJ008 Model does not define `__str__` method +DJ008 Model does not define `__str__` method + --> DJ008.py:36:7 | 36 | class TestModel3(Model): - | ^^^^^^^^^^ DJ008 + | ^^^^^^^^^^ 37 | new_field = models.CharField(max_length=10) | -DJ008.py:182:7: DJ008 Model does not define `__str__` method +DJ008 Model does not define `__str__` method + --> DJ008.py:182:7 | 181 | # Subclass without __str__ 182 | class SubclassTestModel3(TestModel1): - | ^^^^^^^^^^^^^^^^^^ DJ008 + | ^^^^^^^^^^^^^^^^^^ 183 | pass | -DJ008.py:215:7: DJ008 Model does not define `__str__` method +DJ008 Model does not define `__str__` method + --> DJ008.py:215:7 | 215 | class TypeAnnotatedNonAbstractModel(models.Model): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 216 | """Model with type-annotated abstract = False - should trigger DJ008""" 217 | new_field = models.CharField(max_length=10) | diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap index 8b124c4474..14cd967f3c 100644 --- a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap @@ -1,61 +1,68 @@ --- source: crates/ruff_linter/src/rules/flake8_django/mod.rs --- -DJ012.py:28:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class +DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class + --> DJ012.py:28:5 | 26 | return "foobar" 27 | 28 | first_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -DJ012.py:43:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before manager declaration +DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before manager declaration + --> DJ012.py:43:5 | 41 | return "foobar" 42 | 43 | first_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -DJ012.py:56:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: Magic method should come before custom method +DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: Magic method should come before custom method + --> DJ012.py:56:5 | 54 | pass 55 | 56 | / def __str__(self): 57 | | return "foobar" - | |_______________________^ DJ012 + | |_______________________^ | -DJ012.py:69:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: `save` method should come before `get_absolute_url` method +DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: `save` method should come before `get_absolute_url` method + --> DJ012.py:69:5 | 67 | pass 68 | 69 | / def save(self): 70 | | pass - | |____________^ DJ012 + | |____________^ | -DJ012.py:123:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class +DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class + --> DJ012.py:123:5 | 121 | verbose_name = "test" 122 | 123 | first_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 124 | last_name = models.CharField(max_length=32) | -DJ012.py:129:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class +DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class + --> DJ012.py:129:5 | 127 | pass 128 | 129 | middle_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -DJ012.py:146:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class +DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: field declaration should come before `Meta` class + --> DJ012.py:146:5 | 144 | return "foobar" 145 | 146 | first_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ013_DJ013.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ013_DJ013.py.snap index 27a74d79be..7cfe44c16b 100644 --- a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ013_DJ013.py.snap +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ013_DJ013.py.snap @@ -1,22 +1,23 @@ --- source: crates/ruff_linter/src/rules/flake8_django/mod.rs -snapshot_kind: text --- -DJ013.py:15:1: DJ013 `@receiver` decorator must be on top of all the other decorators +DJ013 `@receiver` decorator must be on top of all the other decorators + --> DJ013.py:15:1 | 14 | @test_decorator 15 | @receiver(pre_save, sender=MyModel) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | def incorrect_pre_save_handler(): 17 | pass | -DJ013.py:35:1: DJ013 `@receiver` decorator must be on top of all the other decorators +DJ013 `@receiver` decorator must be on top of all the other decorators + --> DJ013.py:35:1 | 33 | @receiver(pre_save, sender=MyModel) 34 | @test_decorator 35 | @receiver(pre_save, sender=MyModel) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | def incorrect_multiple(): 37 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap index ca47a2e7f7..0f3efc172f 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_errmsg/mod.rs --- -EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:5:24 | 4 | def f_a(): 5 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 2 2 | @@ -20,14 +21,15 @@ EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variabl 7 8 | 8 9 | def f_a_short(): -EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to variable first +EM102 [*] Exception must not use an f-string literal, assign to variable first + --> EM.py:18:24 | 16 | def f_b(): 17 | example = "example" 18 | raise RuntimeError(f"This is an {example} exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove f-string literal +help: Assign to variable; remove f-string literal ℹ Unsafe fix 15 15 | @@ -40,13 +42,14 @@ EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to var 20 21 | 21 22 | def f_c(): -EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first +EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + --> EM.py:22:24 | 21 | def f_c(): 22 | raise RuntimeError("This is an {example} exception".format(example="example")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove `.format()` string +help: Assign to variable; remove `.format()` string ℹ Unsafe fix 19 19 | @@ -59,14 +62,15 @@ EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, ass 24 25 | 25 26 | def f_ok(): -EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:32:24 | 30 | def f_msg_defined(): 31 | msg = "hello" 32 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 29 29 | @@ -79,14 +83,15 @@ EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variab 34 35 | 35 36 | def f_msg_in_nested_scope(): -EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:39:24 | 37 | msg = "hello" 38 | 39 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 36 36 | def nested(): @@ -99,13 +104,14 @@ EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variab 41 42 | 42 43 | def f_msg_in_parent_scope(): -EM.py:46:28: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:46:28 | 45 | def nested(): 46 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 43 43 | msg = "hello" @@ -118,16 +124,17 @@ EM.py:46:28: EM101 [*] Exception must not use a string literal, assign to variab 48 49 | 49 50 | def f_fix_indentation_check(foo): -EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:51:28 | 49 | def f_fix_indentation_check(foo): 50 | if foo: 51 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | else: 53 | if foo == "foo": | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 48 48 | @@ -140,15 +147,16 @@ EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variab 53 54 | if foo == "foo": 54 55 | raise RuntimeError(f"This is an exception: {foo}") -EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to variable first +EM102 [*] Exception must not use an f-string literal, assign to variable first + --> EM.py:54:32 | 52 | else: 53 | if foo == "foo": 54 | raise RuntimeError(f"This is an exception: {foo}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | raise RuntimeError("This is an exception: {}".format(foo)) | - = help: Assign to variable; remove f-string literal +help: Assign to variable; remove f-string literal ℹ Unsafe fix 51 51 | raise RuntimeError("This is an example exception") @@ -161,14 +169,15 @@ EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to var 56 57 | 57 58 | -EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first +EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + --> EM.py:55:24 | 53 | if foo == "foo": 54 | raise RuntimeError(f"This is an exception: {foo}") 55 | raise RuntimeError("This is an exception: {}".format(foo)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove `.format()` string +help: Assign to variable; remove `.format()` string ℹ Unsafe fix 52 52 | else: @@ -181,31 +190,34 @@ EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, ass 57 58 | 58 59 | # Report these, but don't fix them -EM.py:59:28: EM101 Exception must not use a string literal, assign to variable first +EM101 Exception must not use a string literal, assign to variable first + --> EM.py:59:28 | 58 | # Report these, but don't fix them 59 | if foo: raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | if foo: x = 1; raise RuntimeError("This is an example exception") | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal -EM.py:60:35: EM101 Exception must not use a string literal, assign to variable first +EM101 Exception must not use a string literal, assign to variable first + --> EM.py:60:35 | 58 | # Report these, but don't fix them 59 | if foo: raise RuntimeError("This is an example exception") 60 | if foo: x = 1; raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal -EM.py:64:24: EM102 [*] Exception must not use an f-string literal, assign to variable first +EM102 [*] Exception must not use an f-string literal, assign to variable first + --> EM.py:64:24 | 63 | def f_triple_quoted_string(): 64 | raise RuntimeError(f"""This is an {"example"} exception""") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove f-string literal +help: Assign to variable; remove f-string literal ℹ Unsafe fix 61 61 | @@ -218,17 +230,18 @@ EM.py:64:24: EM102 [*] Exception must not use an f-string literal, assign to var 66 67 | 67 68 | def f_multi_line_string(): -EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first +EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + --> EM.py:76:9 | 74 | def f_multi_line_string2(): 75 | raise RuntimeError( 76 | / "This is an {example} exception".format( 77 | | example="example" 78 | | ) - | |_________^ EM103 + | |_________^ 79 | ) | - = help: Assign to variable; remove `.format()` string +help: Assign to variable; remove `.format()` string ℹ Unsafe fix 72 72 | @@ -247,7 +260,8 @@ EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assi 81 84 | 82 85 | def f_multi_line_string2(): -EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first +EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + --> EM.py:84:9 | 82 | def f_multi_line_string2(): 83 | raise RuntimeError( @@ -257,10 +271,10 @@ EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assi 87 | | ).format( 88 | | example="example" 89 | | ) - | |_________^ EM103 + | |_________^ 90 | ) | - = help: Assign to variable; remove `.format()` string +help: Assign to variable; remove `.format()` string ℹ Unsafe fix 80 80 | diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap index 07fece4a7f..d470bd5028 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_errmsg/mod.rs --- -EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:5:24 | 4 | def f_a(): 5 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 2 2 | @@ -20,13 +21,14 @@ EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variabl 7 8 | 8 9 | def f_a_short(): -EM.py:9:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:9:24 | 8 | def f_a_short(): 9 | raise RuntimeError("Error") - | ^^^^^^^ EM101 + | ^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 6 6 | @@ -39,13 +41,14 @@ EM.py:9:24: EM101 [*] Exception must not use a string literal, assign to variabl 11 12 | 12 13 | def f_a_empty(): -EM.py:13:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:13:24 | 12 | def f_a_empty(): 13 | raise RuntimeError("") - | ^^ EM101 + | ^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 10 10 | @@ -58,14 +61,15 @@ EM.py:13:24: EM101 [*] Exception must not use a string literal, assign to variab 15 16 | 16 17 | def f_b(): -EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to variable first +EM102 [*] Exception must not use an f-string literal, assign to variable first + --> EM.py:18:24 | 16 | def f_b(): 17 | example = "example" 18 | raise RuntimeError(f"This is an {example} exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove f-string literal +help: Assign to variable; remove f-string literal ℹ Unsafe fix 15 15 | @@ -78,13 +82,14 @@ EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to var 20 21 | 21 22 | def f_c(): -EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first +EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + --> EM.py:22:24 | 21 | def f_c(): 22 | raise RuntimeError("This is an {example} exception".format(example="example")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove `.format()` string +help: Assign to variable; remove `.format()` string ℹ Unsafe fix 19 19 | @@ -97,14 +102,15 @@ EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, ass 24 25 | 25 26 | def f_ok(): -EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:32:24 | 30 | def f_msg_defined(): 31 | msg = "hello" 32 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 29 29 | @@ -117,14 +123,15 @@ EM.py:32:24: EM101 [*] Exception must not use a string literal, assign to variab 34 35 | 35 36 | def f_msg_in_nested_scope(): -EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:39:24 | 37 | msg = "hello" 38 | 39 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 36 36 | def nested(): @@ -137,13 +144,14 @@ EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variab 41 42 | 42 43 | def f_msg_in_parent_scope(): -EM.py:46:28: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:46:28 | 45 | def nested(): 46 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 43 43 | msg = "hello" @@ -156,16 +164,17 @@ EM.py:46:28: EM101 [*] Exception must not use a string literal, assign to variab 48 49 | 49 50 | def f_fix_indentation_check(foo): -EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:51:28 | 49 | def f_fix_indentation_check(foo): 50 | if foo: 51 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | else: 53 | if foo == "foo": | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 48 48 | @@ -178,15 +187,16 @@ EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variab 53 54 | if foo == "foo": 54 55 | raise RuntimeError(f"This is an exception: {foo}") -EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to variable first +EM102 [*] Exception must not use an f-string literal, assign to variable first + --> EM.py:54:32 | 52 | else: 53 | if foo == "foo": 54 | raise RuntimeError(f"This is an exception: {foo}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | raise RuntimeError("This is an exception: {}".format(foo)) | - = help: Assign to variable; remove f-string literal +help: Assign to variable; remove f-string literal ℹ Unsafe fix 51 51 | raise RuntimeError("This is an example exception") @@ -199,14 +209,15 @@ EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to var 56 57 | 57 58 | -EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first +EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + --> EM.py:55:24 | 53 | if foo == "foo": 54 | raise RuntimeError(f"This is an exception: {foo}") 55 | raise RuntimeError("This is an exception: {}".format(foo)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove `.format()` string +help: Assign to variable; remove `.format()` string ℹ Unsafe fix 52 52 | else: @@ -219,31 +230,34 @@ EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, ass 57 58 | 58 59 | # Report these, but don't fix them -EM.py:59:28: EM101 Exception must not use a string literal, assign to variable first +EM101 Exception must not use a string literal, assign to variable first + --> EM.py:59:28 | 58 | # Report these, but don't fix them 59 | if foo: raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | if foo: x = 1; raise RuntimeError("This is an example exception") | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal -EM.py:60:35: EM101 Exception must not use a string literal, assign to variable first +EM101 Exception must not use a string literal, assign to variable first + --> EM.py:60:35 | 58 | # Report these, but don't fix them 59 | if foo: raise RuntimeError("This is an example exception") 60 | if foo: x = 1; raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal -EM.py:64:24: EM102 [*] Exception must not use an f-string literal, assign to variable first +EM102 [*] Exception must not use an f-string literal, assign to variable first + --> EM.py:64:24 | 63 | def f_triple_quoted_string(): 64 | raise RuntimeError(f"""This is an {"example"} exception""") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove f-string literal +help: Assign to variable; remove f-string literal ℹ Unsafe fix 61 61 | @@ -256,16 +270,17 @@ EM.py:64:24: EM102 [*] Exception must not use an f-string literal, assign to var 66 67 | 67 68 | def f_multi_line_string(): -EM.py:69:9: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM.py:69:9 | 67 | def f_multi_line_string(): 68 | raise RuntimeError( 69 | / "first" 70 | | "second" - | |________________^ EM101 + | |________________^ 71 | ) | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 65 65 | @@ -283,17 +298,18 @@ EM.py:69:9: EM101 [*] Exception must not use a string literal, assign to variabl 73 76 | 74 77 | def f_multi_line_string2(): -EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first +EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + --> EM.py:76:9 | 74 | def f_multi_line_string2(): 75 | raise RuntimeError( 76 | / "This is an {example} exception".format( 77 | | example="example" 78 | | ) - | |_________^ EM103 + | |_________^ 79 | ) | - = help: Assign to variable; remove `.format()` string +help: Assign to variable; remove `.format()` string ℹ Unsafe fix 72 72 | @@ -312,7 +328,8 @@ EM.py:76:9: EM103 [*] Exception must not use a `.format()` string directly, assi 81 84 | 82 85 | def f_multi_line_string2(): -EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first +EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + --> EM.py:84:9 | 82 | def f_multi_line_string2(): 83 | raise RuntimeError( @@ -322,10 +339,10 @@ EM.py:84:9: EM103 [*] Exception must not use a `.format()` string directly, assi 87 | | ).format( 88 | | example="example" 89 | | ) - | |_________^ EM103 + | |_________^ 90 | ) | - = help: Assign to variable; remove `.format()` string +help: Assign to variable; remove `.format()` string ℹ Unsafe fix 80 80 | diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__preview.snap b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__preview.snap index f3dbda9bfd..56a0a67bce 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__preview.snap +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__preview.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_errmsg/mod.rs --- -EM101_byte_string.py:2:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM101_byte_string.py:2:24 | 1 | def f_byte(): 2 | raise RuntimeError(b"This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 1 1 | def f_byte(): @@ -18,13 +19,14 @@ EM101_byte_string.py:2:24: EM101 [*] Exception must not use a string literal, as 4 5 | 5 6 | def f_byte_empty(): -EM101_byte_string.py:6:24: EM101 [*] Exception must not use a string literal, assign to variable first +EM101 [*] Exception must not use a string literal, assign to variable first + --> EM101_byte_string.py:6:24 | 5 | def f_byte_empty(): 6 | raise RuntimeError(b"") - | ^^^ EM101 + | ^^^ | - = help: Assign to variable; remove string literal +help: Assign to variable; remove string literal ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap index 3ebc57f8bb..2db3077674 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE001_1.py:1:1: EXE001 Shebang is present but file is not executable +EXE001 Shebang is present but file is not executable + --> EXE001_1.py:1:1 | 1 | #!/usr/bin/python - | ^^^^^^^^^^^^^^^^^ EXE001 + | ^^^^^^^^^^^^^^^^^ 2 | 3 | if __name__ == '__main__': | diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_1.py.snap index 122fcb2656..f2423b7ff2 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_1.py.snap @@ -1,4 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE002_1.py:1:1: EXE002 The file is executable but no shebang is present +EXE002 The file is executable but no shebang is present +--> EXE002_1.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE003.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE003.py.snap index d5dab03c6e..2eaa9f1e07 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE003.py.snap @@ -1,9 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE003.py:1:1: EXE003 Shebang should contain `python`, `pytest`, or `uv run` +EXE003 Shebang should contain `python`, `pytest`, or `uv run` + --> EXE003.py:1:1 | 1 | #!/usr/bin/bash - | ^^^^^^^^^^^^^^^ EXE003 + | ^^^^^^^^^^^^^^^ 2 | print("hello world") | diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap index 1c613ab1b1..df337e1b7a 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap @@ -1,15 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE004_1.py:1:1: EXE004 [*] Avoid whitespace before shebang +EXE004 [*] Avoid whitespace before shebang + --> EXE004_1.py:1:1 | 1 | #!/usr/bin/python - | ^^^^ EXE004 + | ^^^^ | - = help: Remove whitespace before shebang +help: Remove whitespace before shebang ℹ Safe fix 1 |- #!/usr/bin/python 1 |+#!/usr/bin/python - - diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_3.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_3.py.snap index 0a919de422..14bb184162 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_3.py.snap @@ -1,10 +1,9 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE004_3.py:2:7: EXE005 Shebang should be at the beginning of the file +EXE005 Shebang should be at the beginning of the file + --> EXE004_3.py:2:7 | 2 | pass #!/usr/bin/env python - | ^^^^^^^^^^^^^^^^^^^^^ EXE005 + | ^^^^^^^^^^^^^^^^^^^^^ | - - diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap index 5cd13ffc04..08eb0fdf1d 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE004_4.py:1:1: EXE004 [*] Avoid whitespace before shebang +EXE004 [*] Avoid whitespace before shebang + --> EXE004_4.py:1:1 | 1 | / 2 | | #!/usr/bin/env python - | |____^ EXE004 + | |____^ | - = help: Remove whitespace before shebang +help: Remove whitespace before shebang ℹ Safe fix 1 |- diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_1.py.snap index d19aa7a32f..c0adb495ed 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_1.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE005_1.py:3:1: EXE005 Shebang should be at the beginning of the file +EXE005 Shebang should be at the beginning of the file + --> EXE005_1.py:3:1 | 2 | # A python comment 3 | #!/usr/bin/python - | ^^^^^^^^^^^^^^^^^ EXE005 + | ^^^^^^^^^^^^^^^^^ | - - diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_2.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_2.py.snap index fb99a0db01..9cea26ce62 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_2.py.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE005_2.py:4:1: EXE005 Shebang should be at the beginning of the file +EXE005 Shebang should be at the beginning of the file + --> EXE005_2.py:4:1 | 3 | # A python comment 4 | #!/usr/bin/python - | ^^^^^^^^^^^^^^^^^ EXE005 + | ^^^^^^^^^^^^^^^^^ | - - diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_3.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_3.py.snap index 9e0e16200c..bd861dada8 100644 --- a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_3.py.snap @@ -1,12 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_executable/mod.rs --- -EXE005_3.py:6:1: EXE005 Shebang should be at the beginning of the file +EXE005 Shebang should be at the beginning of the file + --> EXE005_3.py:6:1 | 4 | """ 5 | # A python comment 6 | #!/usr/bin/python - | ^^^^^^^^^^^^^^^^^ EXE005 + | ^^^^^^^^^^^^^^^^^ | - - diff --git a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap index a127236782..9ff2b280c8 100644 --- a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap @@ -1,21 +1,23 @@ --- source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs --- -T00.py:7:3: FIX001 Line contains FIXME, consider resolving the issue +FIX001 Line contains FIXME, consider resolving the issue + --> T00.py:7:3 | 5 | # HACK: hack 6 | # hack: hack 7 | # FIXME: fixme - | ^^^^^ FIX001 + | ^^^^^ 8 | # fixme: fixme | -T00.py:8:3: FIX001 Line contains FIXME, consider resolving the issue +FIX001 Line contains FIXME, consider resolving the issue + --> T00.py:8:3 | 6 | # hack: hack 7 | # FIXME: fixme 8 | # fixme: fixme - | ^^^^^ FIX001 + | ^^^^^ 9 | 10 | # test # TODO: todo | diff --git a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap index be827ead17..90f7826bb1 100644 --- a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap @@ -1,23 +1,24 @@ --- source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs -snapshot_kind: text --- -T00.py:5:3: FIX004 Line contains HACK, consider resolving the issue +FIX004 Line contains HACK, consider resolving the issue + --> T00.py:5:3 | 3 | # XXX: xxx 4 | # xxx: xxx 5 | # HACK: hack - | ^^^^ FIX004 + | ^^^^ 6 | # hack: hack 7 | # FIXME: fixme | -T00.py:6:3: FIX004 Line contains HACK, consider resolving the issue +FIX004 Line contains HACK, consider resolving the issue + --> T00.py:6:3 | 4 | # xxx: xxx 5 | # HACK: hack 6 | # hack: hack - | ^^^^ FIX004 + | ^^^^ 7 | # FIXME: fixme 8 | # fixme: fixme | diff --git a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap index b447735675..4e5e4c0a79 100644 --- a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap @@ -1,27 +1,30 @@ --- source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs --- -T00.py:1:3: FIX002 Line contains TODO, consider resolving the issue +FIX002 Line contains TODO, consider resolving the issue + --> T00.py:1:3 | 1 | # TODO: todo - | ^^^^ FIX002 + | ^^^^ 2 | # todo: todo 3 | # XXX: xxx | -T00.py:2:3: FIX002 Line contains TODO, consider resolving the issue +FIX002 Line contains TODO, consider resolving the issue + --> T00.py:2:3 | 1 | # TODO: todo 2 | # todo: todo - | ^^^^ FIX002 + | ^^^^ 3 | # XXX: xxx 4 | # xxx: xxx | -T00.py:10:10: FIX002 Line contains TODO, consider resolving the issue +FIX002 Line contains TODO, consider resolving the issue + --> T00.py:10:10 | 8 | # fixme: fixme 9 | 10 | # test # TODO: todo - | ^^^^ FIX002 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap index d4218aca27..5562b8b35f 100644 --- a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap @@ -1,23 +1,24 @@ --- source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs -snapshot_kind: text --- -T00.py:3:3: FIX003 Line contains XXX, consider resolving the issue +FIX003 Line contains XXX, consider resolving the issue + --> T00.py:3:3 | 1 | # TODO: todo 2 | # todo: todo 3 | # XXX: xxx - | ^^^ FIX003 + | ^^^ 4 | # xxx: xxx 5 | # HACK: hack | -T00.py:4:3: FIX003 Line contains XXX, consider resolving the issue +FIX003 Line contains XXX, consider resolving the issue + --> T00.py:4:3 | 2 | # todo: todo 3 | # XXX: xxx 4 | # xxx: xxx - | ^^^ FIX003 + | ^^^ 5 | # HACK: hack 6 | # hack: hack | diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__edge_case.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__edge_case.py.snap index 5f668c4700..9e5186ee8d 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__edge_case.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__edge_case.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs --- -edge_case.py:5:13: FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` +FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` + --> edge_case.py:5:13 | 5 | def main(_: List[int]) -> None: - | ^^^^ FA100 + | ^^^^ 6 | a_list: t.List[str] = [] 7 | a_list.append("hello") | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -16,14 +17,15 @@ edge_case.py:5:13: FA100 [*] Add `from __future__ import annotations` to simplif 2 3 | import typing as t 3 4 | -edge_case.py:6:13: FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` +FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` + --> edge_case.py:6:13 | 5 | def main(_: List[int]) -> None: 6 | a_list: t.List[str] = [] - | ^^^^^^ FA100 + | ^^^^^^ 7 | a_list.append("hello") | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap index 9db68140a4..da4fb7fd56 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs -snapshot_kind: text --- -no_future_import_uses_lowercase.py:6:14: FA102 [*] Missing `from __future__ import annotations`, but uses PEP 585 collection +FA102 [*] Missing `from __future__ import annotations`, but uses PEP 585 collection + --> no_future_import_uses_lowercase.py:6:14 | 6 | def hello(y: dict[str, int]) -> None: - | ^^^^^^^^^^^^^^ FA102 + | ^^^^^^^^^^^^^^ 7 | del y | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap index 4f8b2b5dd2..d6bc243ef3 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs -snapshot_kind: text --- -no_future_import_uses_union.py:6:14: FA102 [*] Missing `from __future__ import annotations`, but uses PEP 585 collection +FA102 [*] Missing `from __future__ import annotations`, but uses PEP 585 collection + --> no_future_import_uses_union.py:6:14 | 6 | def hello(y: dict[str, int] | None) -> None: - | ^^^^^^^^^^^^^^ FA102 + | ^^^^^^^^^^^^^^ 7 | del y | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -16,13 +16,14 @@ no_future_import_uses_union.py:6:14: FA102 [*] Missing `from __future__ import a 2 3 | a_list: list[str] | None = [] 3 4 | a_list.append("hello") -no_future_import_uses_union.py:6:14: FA102 [*] Missing `from __future__ import annotations`, but uses PEP 604 union +FA102 [*] Missing `from __future__ import annotations`, but uses PEP 604 union + --> no_future_import_uses_union.py:6:14 | 6 | def hello(y: dict[str, int] | None) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ FA102 + | ^^^^^^^^^^^^^^^^^^^^^ 7 | del y | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap index bd011e0327..a50c50085c 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs -snapshot_kind: text --- -no_future_import_uses_union_inner.py:6:14: FA102 [*] Missing `from __future__ import annotations`, but uses PEP 585 collection +FA102 [*] Missing `from __future__ import annotations`, but uses PEP 585 collection + --> no_future_import_uses_union_inner.py:6:14 | 6 | def hello(y: dict[str | None, int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ FA102 + | ^^^^^^^^^^^^^^^^^^^^^ 7 | z: tuple[str, str | None, str] = tuple(y) 8 | del z | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -17,14 +17,15 @@ no_future_import_uses_union_inner.py:6:14: FA102 [*] Missing `from __future__ im 2 3 | a_list: list[str | None] = [] 3 4 | a_list.append("hello") -no_future_import_uses_union_inner.py:6:19: FA102 [*] Missing `from __future__ import annotations`, but uses PEP 604 union +FA102 [*] Missing `from __future__ import annotations`, but uses PEP 604 union + --> no_future_import_uses_union_inner.py:6:19 | 6 | def hello(y: dict[str | None, int]) -> None: - | ^^^^^^^^^^ FA102 + | ^^^^^^^^^^ 7 | z: tuple[str, str | None, str] = tuple(y) 8 | del z | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import.py.snap index 9a32b4d1c9..7e9efe8130 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs --- -from_typing_import.py:5:13: FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` +FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` + --> from_typing_import.py:5:13 | 4 | def main() -> None: 5 | a_list: List[str] = [] - | ^^^^ FA100 + | ^^^^ 6 | a_list.append("hello") | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap index b2ae15f027..7eac7667be 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs --- -from_typing_import_many.py:5:13: FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` +FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` + --> from_typing_import_many.py:5:13 | 4 | def main() -> None: 5 | a_list: List[Optional[str]] = [] - | ^^^^ FA100 + | ^^^^ 6 | a_list.append("hello") 7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {}) | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -17,15 +18,16 @@ from_typing_import_many.py:5:13: FA100 [*] Add `from __future__ import annotatio 2 3 | 3 4 | -from_typing_import_many.py:5:18: FA100 [*] Add `from __future__ import annotations` to simplify `typing.Optional` +FA100 [*] Add `from __future__ import annotations` to simplify `typing.Optional` + --> from_typing_import_many.py:5:18 | 4 | def main() -> None: 5 | a_list: List[Optional[str]] = [] - | ^^^^^^^^ FA100 + | ^^^^^^^^ 6 | a_list.append("hello") 7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {}) | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing.py.snap index b42449261f..d0fb70fded 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs --- -import_typing.py:5:13: FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` +FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` + --> import_typing.py:5:13 | 4 | def main() -> None: 5 | a_list: typing.List[str] = [] - | ^^^^^^^^^^^ FA100 + | ^^^^^^^^^^^ 6 | a_list.append("hello") | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing_as.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing_as.py.snap index 231038c3c4..4de6371b70 100644 --- a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing_as.py.snap +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing_as.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs --- -import_typing_as.py:5:13: FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` +FA100 [*] Add `from __future__ import annotations` to simplify `typing.List` + --> import_typing_as.py:5:13 | 4 | def main() -> None: 5 | a_list: t.List[str] = [] - | ^^^^^^ FA100 + | ^^^^^^ 6 | a_list.append("hello") | - = help: Add `from __future__ import annotations` +help: Add `from __future__ import annotations` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap index 81d2c6b328..c4da6ace3c 100644 --- a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_gettext/mod.rs --- -INT001.py:1:3: INT001 f-string is resolved before function call; consider `_("string %s") % arg` +INT001 f-string is resolved before function call; consider `_("string %s") % arg` + --> INT001.py:1:3 | 1 | _(f"{'value'}") - | ^^^^^^^^^^^^ INT001 + | ^^^^^^^^^^^^ 2 | 3 | # Don't trigger for t-strings | diff --git a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap index 99e0cc7e46..d029e52667 100644 --- a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap @@ -1,9 +1,9 @@ --- source: crates/ruff_linter/src/rules/flake8_gettext/mod.rs -snapshot_kind: text --- -INT002.py:1:3: INT002 `format` method argument is resolved before function call; consider `_("string %s") % arg` +INT002 `format` method argument is resolved before function call; consider `_("string %s") % arg` + --> INT002.py:1:3 | 1 | _("{}".format("line")) - | ^^^^^^^^^^^^^^^^^^^ INT002 + | ^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap index 69a768d943..51a29c1734 100644 --- a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap @@ -1,9 +1,9 @@ --- source: crates/ruff_linter/src/rules/flake8_gettext/mod.rs -snapshot_kind: text --- -INT003.py:1:3: INT003 printf-style format is resolved before function call; consider `_("string %s") % arg` +INT003 printf-style format is resolved before function call; consider `_("string %s") % arg` + --> INT003.py:1:3 | 1 | _("%s" % "line") - | ^^^^^^^^^^^^^ INT003 + | ^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap index e6cfb14078..f6a411fcb3 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- -ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:1:5 | 1 | _ = "a" "b" "c" - | ^^^^^^^ ISC001 + | ^^^^^^^ 2 | 3 | _ = "abc" + "def" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 1 |-_ = "a" "b" "c" @@ -17,14 +18,15 @@ ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line 3 3 | _ = "abc" + "def" 4 4 | -ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:1:9 | 1 | _ = "a" "b" "c" - | ^^^^^^^ ISC001 + | ^^^^^^^ 2 | 3 | _ = "abc" + "def" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 1 |-_ = "a" "b" "c" @@ -33,16 +35,17 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line 3 3 | _ = "abc" + "def" 4 4 | -ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:38:5 | 36 | ) 37 | 38 | _ = """a""" """b""" - | ^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^ 39 | 40 | _ = """a | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 35 35 | b"def" @@ -54,7 +57,8 @@ ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line 40 40 | _ = """a 41 41 | b""" """c -ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:40:5 | 38 | _ = """a""" """b""" 39 | @@ -62,11 +66,11 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line | _____^ 41 | | b""" """c 42 | | d""" - | |____^ ISC001 + | |____^ 43 | 44 | _ = f"""a""" f"""b""" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 38 38 | _ = """a""" """b""" @@ -78,16 +82,17 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line 43 43 | 44 44 | _ = f"""a""" f"""b""" -ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:44:5 | 42 | d""" 43 | 44 | _ = f"""a""" f"""b""" - | ^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^ 45 | 46 | _ = f"a" "b" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 41 41 | b""" """c @@ -99,49 +104,53 @@ ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line 46 46 | _ = f"a" "b" 47 47 | -ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:46:5 | 44 | _ = f"""a""" f"""b""" 45 | 46 | _ = f"a" "b" - | ^^^^^^^^ ISC001 + | ^^^^^^^^ 47 | 48 | _ = """a""" "b" | - = help: Combine string literals +help: Combine string literals -ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:48:5 | 46 | _ = f"a" "b" 47 | 48 | _ = """a""" "b" - | ^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^ 49 | 50 | _ = 'a' "b" | - = help: Combine string literals +help: Combine string literals -ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:50:5 | 48 | _ = """a""" "b" 49 | 50 | _ = 'a' "b" - | ^^^^^^^ ISC001 + | ^^^^^^^ 51 | 52 | _ = rf"a" rf"b" | - = help: Combine string literals +help: Combine string literals -ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:52:5 | 50 | _ = 'a' "b" 51 | 52 | _ = rf"a" rf"b" - | ^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^ 53 | 54 | # Single-line explicit concatenation should be ignored. | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 49 49 | @@ -153,15 +162,16 @@ ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line 54 54 | # Single-line explicit concatenation should be ignored. 55 55 | _ = "abc" + "def" + "ghi" -ISC.py:64:10: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:64:10 | 63 | # Multiple strings nested inside a f-string 64 | _ = f"a {'b' 'c' 'd'} e" - | ^^^^^^^ ISC001 + | ^^^^^^^ 65 | _ = f"""abc {"def" "ghi"} jkl""" 66 | _ = f"""abc { | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 61 61 | _ = foo + "abc" + bar @@ -173,15 +183,16 @@ ISC.py:64:10: ISC001 [*] Implicitly concatenated string literals on one line 66 66 | _ = f"""abc { 67 67 | "def" -ISC.py:64:14: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:64:14 | 63 | # Multiple strings nested inside a f-string 64 | _ = f"a {'b' 'c' 'd'} e" - | ^^^^^^^ ISC001 + | ^^^^^^^ 65 | _ = f"""abc {"def" "ghi"} jkl""" 66 | _ = f"""abc { | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 61 61 | _ = foo + "abc" + bar @@ -193,16 +204,17 @@ ISC.py:64:14: ISC001 [*] Implicitly concatenated string literals on one line 66 66 | _ = f"""abc { 67 67 | "def" -ISC.py:65:14: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:65:14 | 63 | # Multiple strings nested inside a f-string 64 | _ = f"a {'b' 'c' 'd'} e" 65 | _ = f"""abc {"def" "ghi"} jkl""" - | ^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^ 66 | _ = f"""abc { 67 | "def" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 62 62 | @@ -214,35 +226,38 @@ ISC.py:65:14: ISC001 [*] Implicitly concatenated string literals on one line 67 67 | "def" 68 68 | "ghi" -ISC.py:72:5: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:72:5 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" - | ^^^^^^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^^^^^^ 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" 74 | _ = f"b {f"abc" \ | - = help: Combine string literals +help: Combine string literals -ISC.py:72:9: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:72:9 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" - | ^^^^^^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^^^^^^ 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" 74 | _ = f"b {f"abc" \ | - = help: Combine string literals +help: Combine string literals -ISC.py:72:14: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:72:14 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" - | ^^^^^^^^^ ISC001 + | ^^^^^^^^^ 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" 74 | _ = f"b {f"abc" \ | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 69 69 | } jkl""" @@ -254,16 +269,17 @@ ISC.py:72:14: ISC001 [*] Implicitly concatenated string literals on one line 74 74 | _ = f"b {f"abc" \ 75 75 | f"def"} g" -ISC.py:73:10: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:73:10 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" - | ^^^^^^^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^^^^^^^ 74 | _ = f"b {f"abc" \ 75 | f"def"} g" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 70 70 | @@ -275,16 +291,17 @@ ISC.py:73:10: ISC001 [*] Implicitly concatenated string literals on one line 75 75 | f"def"} g" 76 76 | -ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:73:20 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" - | ^^^^^^^^^ ISC001 + | ^^^^^^^^^ 74 | _ = f"b {f"abc" \ 75 | f"def"} g" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 70 70 | @@ -296,15 +313,16 @@ ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line 75 75 | f"def"} g" 76 76 | -ISC.py:84:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:84:5 | 83 | # See https://github.com/astral-sh/ruff/issues/12936 84 | _ = "\12""0" # fix should be "\0120" - | ^^^^^^^^ ISC001 + | ^^^^^^^^ 85 | _ = "\\12""0" # fix should be "\\120" 86 | _ = "\\\12""0" # fix should be "\\\0120" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 81 81 | + f"second"} d" @@ -316,16 +334,17 @@ ISC.py:84:5: ISC001 [*] Implicitly concatenated string literals on one line 86 86 | _ = "\\\12""0" # fix should be "\\\0120" 87 87 | _ = "\12 0""0" # fix should be "\12 00" -ISC.py:85:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:85:5 | 83 | # See https://github.com/astral-sh/ruff/issues/12936 84 | _ = "\12""0" # fix should be "\0120" 85 | _ = "\\12""0" # fix should be "\\120" - | ^^^^^^^^^ ISC001 + | ^^^^^^^^^ 86 | _ = "\\\12""0" # fix should be "\\\0120" 87 | _ = "\12 0""0" # fix should be "\12 00" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 82 82 | @@ -337,16 +356,17 @@ ISC.py:85:5: ISC001 [*] Implicitly concatenated string literals on one line 87 87 | _ = "\12 0""0" # fix should be "\12 00" 88 88 | _ = r"\12"r"0" # fix should be r"\120" -ISC.py:86:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:86:5 | 84 | _ = "\12""0" # fix should be "\0120" 85 | _ = "\\12""0" # fix should be "\\120" 86 | _ = "\\\12""0" # fix should be "\\\0120" - | ^^^^^^^^^^ ISC001 + | ^^^^^^^^^^ 87 | _ = "\12 0""0" # fix should be "\12 00" 88 | _ = r"\12"r"0" # fix should be r"\120" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 83 83 | # See https://github.com/astral-sh/ruff/issues/12936 @@ -358,16 +378,17 @@ ISC.py:86:5: ISC001 [*] Implicitly concatenated string literals on one line 88 88 | _ = r"\12"r"0" # fix should be r"\120" 89 89 | _ = "\12 and more""0" # fix should be "\12 and more0" -ISC.py:87:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:87:5 | 85 | _ = "\\12""0" # fix should be "\\120" 86 | _ = "\\\12""0" # fix should be "\\\0120" 87 | _ = "\12 0""0" # fix should be "\12 00" - | ^^^^^^^^^^ ISC001 + | ^^^^^^^^^^ 88 | _ = r"\12"r"0" # fix should be r"\120" 89 | _ = "\12 and more""0" # fix should be "\12 and more0" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 84 84 | _ = "\12""0" # fix should be "\0120" @@ -379,16 +400,17 @@ ISC.py:87:5: ISC001 [*] Implicitly concatenated string literals on one line 89 89 | _ = "\12 and more""0" # fix should be "\12 and more0" 90 90 | _ = "\8""0" # fix should be "\80" -ISC.py:88:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:88:5 | 86 | _ = "\\\12""0" # fix should be "\\\0120" 87 | _ = "\12 0""0" # fix should be "\12 00" 88 | _ = r"\12"r"0" # fix should be r"\120" - | ^^^^^^^^^^ ISC001 + | ^^^^^^^^^^ 89 | _ = "\12 and more""0" # fix should be "\12 and more0" 90 | _ = "\8""0" # fix should be "\80" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 85 85 | _ = "\\12""0" # fix should be "\\120" @@ -400,16 +422,17 @@ ISC.py:88:5: ISC001 [*] Implicitly concatenated string literals on one line 90 90 | _ = "\8""0" # fix should be "\80" 91 91 | _ = "\12""8" # fix should be "\128" -ISC.py:89:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:89:5 | 87 | _ = "\12 0""0" # fix should be "\12 00" 88 | _ = r"\12"r"0" # fix should be r"\120" 89 | _ = "\12 and more""0" # fix should be "\12 and more0" - | ^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^ 90 | _ = "\8""0" # fix should be "\80" 91 | _ = "\12""8" # fix should be "\128" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 86 86 | _ = "\\\12""0" # fix should be "\\\0120" @@ -421,16 +444,17 @@ ISC.py:89:5: ISC001 [*] Implicitly concatenated string literals on one line 91 91 | _ = "\12""8" # fix should be "\128" 92 92 | _ = "\12""foo" # fix should be "\12foo" -ISC.py:90:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:90:5 | 88 | _ = r"\12"r"0" # fix should be r"\120" 89 | _ = "\12 and more""0" # fix should be "\12 and more0" 90 | _ = "\8""0" # fix should be "\80" - | ^^^^^^^ ISC001 + | ^^^^^^^ 91 | _ = "\12""8" # fix should be "\128" 92 | _ = "\12""foo" # fix should be "\12foo" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 87 87 | _ = "\12 0""0" # fix should be "\12 00" @@ -442,16 +466,17 @@ ISC.py:90:5: ISC001 [*] Implicitly concatenated string literals on one line 92 92 | _ = "\12""foo" # fix should be "\12foo" 93 93 | _ = "\12" "" # fix should be "\12" -ISC.py:91:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:91:5 | 89 | _ = "\12 and more""0" # fix should be "\12 and more0" 90 | _ = "\8""0" # fix should be "\80" 91 | _ = "\12""8" # fix should be "\128" - | ^^^^^^^^ ISC001 + | ^^^^^^^^ 92 | _ = "\12""foo" # fix should be "\12foo" 93 | _ = "\12" "" # fix should be "\12" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 88 88 | _ = r"\12"r"0" # fix should be r"\120" @@ -463,15 +488,16 @@ ISC.py:91:5: ISC001 [*] Implicitly concatenated string literals on one line 93 93 | _ = "\12" "" # fix should be "\12" 94 94 | -ISC.py:92:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:92:5 | 90 | _ = "\8""0" # fix should be "\80" 91 | _ = "\12""8" # fix should be "\128" 92 | _ = "\12""foo" # fix should be "\12foo" - | ^^^^^^^^^^ ISC001 + | ^^^^^^^^^^ 93 | _ = "\12" "" # fix should be "\12" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 89 89 | _ = "\12 and more""0" # fix should be "\12 and more0" @@ -483,14 +509,15 @@ ISC.py:92:5: ISC001 [*] Implicitly concatenated string literals on one line 94 94 | 95 95 | -ISC.py:93:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:93:5 | 91 | _ = "\12""8" # fix should be "\128" 92 | _ = "\12""foo" # fix should be "\12foo" 93 | _ = "\12" "" # fix should be "\12" - | ^^^^^^^^ ISC001 + | ^^^^^^^^ | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 90 90 | _ = "\8""0" # fix should be "\80" diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap index 8449cc6015..0b61838958 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- -ISC_syntax_error.py:2:5: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> ISC_syntax_error.py:2:5 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b @@ -10,28 +11,30 @@ ISC_syntax_error.py:2:5: invalid-syntax: missing closing quote in string literal 4 | "a" """b | -ISC_syntax_error.py:2:7: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> ISC_syntax_error.py:2:7 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b | ^ 3 | "a" "b" "c 4 | "a" """b -5 | c""" "d | -ISC_syntax_error.py:3:1: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC_syntax_error.py:3:1 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b 3 | "a" "b" "c - | ^^^^^^^ ISC001 + | ^^^^^^^ 4 | "a" """b 5 | c""" "d | - = help: Combine string literals +help: Combine string literals -ISC_syntax_error.py:3:9: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> ISC_syntax_error.py:3:9 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b @@ -41,7 +44,8 @@ ISC_syntax_error.py:3:9: invalid-syntax: missing closing quote in string literal 5 | c""" "d | -ISC_syntax_error.py:3:11: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> ISC_syntax_error.py:3:11 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b @@ -51,19 +55,21 @@ ISC_syntax_error.py:3:11: invalid-syntax: Expected a statement 5 | c""" "d | -ISC_syntax_error.py:4:1: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC_syntax_error.py:4:1 | 2 | "a" "b 3 | "a" "b" "c 4 | / "a" """b 5 | | c""" "d - | |____^ ISC001 + | |____^ 6 | 7 | # For f-strings, the `FStringRanges` won't contain the range for | - = help: Combine string literals +help: Combine string literals -ISC_syntax_error.py:5:6: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> ISC_syntax_error.py:5:6 | 3 | "a" "b" "c 4 | "a" """b @@ -73,7 +79,8 @@ ISC_syntax_error.py:5:6: invalid-syntax: missing closing quote in string literal 7 | # For f-strings, the `FStringRanges` won't contain the range for | -ISC_syntax_error.py:5:8: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> ISC_syntax_error.py:5:8 | 3 | "a" "b" "c 4 | "a" """b @@ -81,10 +88,10 @@ ISC_syntax_error.py:5:8: invalid-syntax: Expected a statement | ^ 6 | 7 | # For f-strings, the `FStringRanges` won't contain the range for -8 | # unterminated f-strings. | -ISC_syntax_error.py:9:8: invalid-syntax: f-string: unterminated string +invalid-syntax: f-string: unterminated string + --> ISC_syntax_error.py:9:8 | 7 | # For f-strings, the `FStringRanges` won't contain the range for 8 | # unterminated f-strings. @@ -94,7 +101,8 @@ ISC_syntax_error.py:9:8: invalid-syntax: f-string: unterminated string 11 | f"a" f"""b | -ISC_syntax_error.py:9:9: invalid-syntax: Expected FStringEnd, found newline +invalid-syntax: Expected FStringEnd, found newline + --> ISC_syntax_error.py:9:9 | 7 | # For f-strings, the `FStringRanges` won't contain the range for 8 | # unterminated f-strings. @@ -102,21 +110,22 @@ ISC_syntax_error.py:9:9: invalid-syntax: Expected FStringEnd, found newline | ^ 10 | f"a" f"b" f"c 11 | f"a" f"""b -12 | c""" f"d {e | -ISC_syntax_error.py:10:1: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC_syntax_error.py:10:1 | 8 | # unterminated f-strings. 9 | f"a" f"b 10 | f"a" f"b" f"c - | ^^^^^^^^^ ISC001 + | ^^^^^^^^^ 11 | f"a" f"""b 12 | c""" f"d {e | - = help: Combine string literals +help: Combine string literals -ISC_syntax_error.py:10:13: invalid-syntax: f-string: unterminated string +invalid-syntax: f-string: unterminated string + --> ISC_syntax_error.py:10:13 | 8 | # unterminated f-strings. 9 | f"a" f"b @@ -126,7 +135,8 @@ ISC_syntax_error.py:10:13: invalid-syntax: f-string: unterminated string 12 | c""" f"d {e | -ISC_syntax_error.py:10:14: invalid-syntax: Expected FStringEnd, found newline +invalid-syntax: Expected FStringEnd, found newline + --> ISC_syntax_error.py:10:14 | 8 | # unterminated f-strings. 9 | f"a" f"b @@ -136,19 +146,21 @@ ISC_syntax_error.py:10:14: invalid-syntax: Expected FStringEnd, found newline 12 | c""" f"d {e | -ISC_syntax_error.py:11:1: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC_syntax_error.py:11:1 | 9 | f"a" f"b 10 | f"a" f"b" f"c 11 | / f"a" f"""b 12 | | c""" f"d {e - | |____^ ISC001 + | |____^ 13 | 14 | ( | - = help: Combine string literals +help: Combine string literals -ISC_syntax_error.py:16:5: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> ISC_syntax_error.py:16:5 | 14 | ( 15 | "a" @@ -158,7 +170,8 @@ ISC_syntax_error.py:16:5: invalid-syntax: missing closing quote in string litera 18 | "d" | -ISC_syntax_error.py:26:9: invalid-syntax: f-string: unterminated triple-quoted string +invalid-syntax: f-string: unterminated triple-quoted string + --> ISC_syntax_error.py:26:9 | 24 | ( 25 | """abc""" @@ -170,14 +183,16 @@ ISC_syntax_error.py:26:9: invalid-syntax: f-string: unterminated triple-quoted s | |__^ | -ISC_syntax_error.py:30:1: invalid-syntax: unexpected EOF while parsing +invalid-syntax: unexpected EOF while parsing + --> ISC_syntax_error.py:30:1 | 28 | "i" "j" 29 | ) | ^ | -ISC_syntax_error.py:30:1: invalid-syntax: f-string: unterminated string +invalid-syntax: f-string: unterminated string + --> ISC_syntax_error.py:30:1 | 28 | "i" "j" 29 | ) diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap index 42e5ca2717..fc84adef37 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap @@ -1,26 +1,28 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- -ISC.py:5:5: ISC002 Implicitly concatenated string literals over multiple lines +ISC002 Implicitly concatenated string literals over multiple lines + --> ISC.py:5:5 | 3 | _ = "abc" + "def" 4 | 5 | _ = "abc" \ | _____^ 6 | | "def" - | |_________^ ISC002 + | |_________^ 7 | 8 | _ = ( | -ISC.py:74:10: ISC002 Implicitly concatenated string literals over multiple lines +ISC002 Implicitly concatenated string literals over multiple lines + --> ISC.py:74:10 | 72 | _ = "a" f"b {f"c" f"d"} e" "f" 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" 74 | _ = f"b {f"abc" \ | __________^ 75 | | f"def"} g" - | |__________^ ISC002 + | |__________^ 76 | 77 | # Explicitly concatenated nested f-strings | diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap index 4f200eb841..1cbcf596b3 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- -ISC_syntax_error.py:2:5: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> ISC_syntax_error.py:2:5 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b @@ -10,17 +11,18 @@ ISC_syntax_error.py:2:5: invalid-syntax: missing closing quote in string literal 4 | "a" """b | -ISC_syntax_error.py:2:7: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> ISC_syntax_error.py:2:7 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b | ^ 3 | "a" "b" "c 4 | "a" """b -5 | c""" "d | -ISC_syntax_error.py:3:9: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> ISC_syntax_error.py:3:9 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b @@ -30,7 +32,8 @@ ISC_syntax_error.py:3:9: invalid-syntax: missing closing quote in string literal 5 | c""" "d | -ISC_syntax_error.py:3:11: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> ISC_syntax_error.py:3:11 | 1 | # The lexer doesn't emit a string token if it's unterminated 2 | "a" "b @@ -40,7 +43,8 @@ ISC_syntax_error.py:3:11: invalid-syntax: Expected a statement 5 | c""" "d | -ISC_syntax_error.py:5:6: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> ISC_syntax_error.py:5:6 | 3 | "a" "b" "c 4 | "a" """b @@ -50,7 +54,8 @@ ISC_syntax_error.py:5:6: invalid-syntax: missing closing quote in string literal 7 | # For f-strings, the `FStringRanges` won't contain the range for | -ISC_syntax_error.py:5:8: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> ISC_syntax_error.py:5:8 | 3 | "a" "b" "c 4 | "a" """b @@ -58,10 +63,10 @@ ISC_syntax_error.py:5:8: invalid-syntax: Expected a statement | ^ 6 | 7 | # For f-strings, the `FStringRanges` won't contain the range for -8 | # unterminated f-strings. | -ISC_syntax_error.py:9:8: invalid-syntax: f-string: unterminated string +invalid-syntax: f-string: unterminated string + --> ISC_syntax_error.py:9:8 | 7 | # For f-strings, the `FStringRanges` won't contain the range for 8 | # unterminated f-strings. @@ -71,7 +76,8 @@ ISC_syntax_error.py:9:8: invalid-syntax: f-string: unterminated string 11 | f"a" f"""b | -ISC_syntax_error.py:9:9: invalid-syntax: Expected FStringEnd, found newline +invalid-syntax: Expected FStringEnd, found newline + --> ISC_syntax_error.py:9:9 | 7 | # For f-strings, the `FStringRanges` won't contain the range for 8 | # unterminated f-strings. @@ -79,10 +85,10 @@ ISC_syntax_error.py:9:9: invalid-syntax: Expected FStringEnd, found newline | ^ 10 | f"a" f"b" f"c 11 | f"a" f"""b -12 | c""" f"d {e | -ISC_syntax_error.py:10:13: invalid-syntax: f-string: unterminated string +invalid-syntax: f-string: unterminated string + --> ISC_syntax_error.py:10:13 | 8 | # unterminated f-strings. 9 | f"a" f"b @@ -92,7 +98,8 @@ ISC_syntax_error.py:10:13: invalid-syntax: f-string: unterminated string 12 | c""" f"d {e | -ISC_syntax_error.py:10:14: invalid-syntax: Expected FStringEnd, found newline +invalid-syntax: Expected FStringEnd, found newline + --> ISC_syntax_error.py:10:14 | 8 | # unterminated f-strings. 9 | f"a" f"b @@ -102,7 +109,8 @@ ISC_syntax_error.py:10:14: invalid-syntax: Expected FStringEnd, found newline 12 | c""" f"d {e | -ISC_syntax_error.py:16:5: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> ISC_syntax_error.py:16:5 | 14 | ( 15 | "a" @@ -112,7 +120,8 @@ ISC_syntax_error.py:16:5: invalid-syntax: missing closing quote in string litera 18 | "d" | -ISC_syntax_error.py:26:9: invalid-syntax: f-string: unterminated triple-quoted string +invalid-syntax: f-string: unterminated triple-quoted string + --> ISC_syntax_error.py:26:9 | 24 | ( 25 | """abc""" @@ -124,14 +133,16 @@ ISC_syntax_error.py:26:9: invalid-syntax: f-string: unterminated triple-quoted s | |__^ | -ISC_syntax_error.py:30:1: invalid-syntax: unexpected EOF while parsing +invalid-syntax: unexpected EOF while parsing + --> ISC_syntax_error.py:30:1 | 28 | "i" "j" 29 | ) | ^ | -ISC_syntax_error.py:30:1: invalid-syntax: f-string: unterminated string +invalid-syntax: f-string: unterminated string + --> ISC_syntax_error.py:30:1 | 28 | "i" "j" 29 | ) diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap index 6ce1e6eee6..795ab86e8a 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- -ISC.py:9:3: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:9:3 | 8 | _ = ( 9 | / "abc" + 10 | | "def" - | |_______^ ISC003 + | |_______^ 11 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 6 6 | "def" @@ -21,15 +22,16 @@ ISC.py:9:3: ISC003 [*] Explicitly concatenated string should be implicitly conca 11 11 | ) 12 12 | -ISC.py:14:3: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:14:3 | 13 | _ = ( 14 | / f"abc" + 15 | | "def" - | |_______^ ISC003 + | |_______^ 16 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 11 11 | ) @@ -41,15 +43,16 @@ ISC.py:14:3: ISC003 [*] Explicitly concatenated string should be implicitly conc 16 16 | ) 17 17 | -ISC.py:19:3: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:19:3 | 18 | _ = ( 19 | / b"abc" + 20 | | b"def" - | |________^ ISC003 + | |________^ 21 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 16 16 | ) @@ -61,17 +64,18 @@ ISC.py:19:3: ISC003 [*] Explicitly concatenated string should be implicitly conc 21 21 | ) 22 22 | -ISC.py:78:10: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:78:10 | 77 | # Explicitly concatenated nested f-strings 78 | _ = f"a {f"first" | __________^ 79 | | + f"second"} d" - | |_______________^ ISC003 + | |_______________^ 80 | _ = f"a {f"first {f"middle"}" 81 | + f"second"} d" | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 76 76 | @@ -83,18 +87,19 @@ ISC.py:78:10: ISC003 [*] Explicitly concatenated string should be implicitly con 81 81 | + f"second"} d" 82 82 | -ISC.py:80:10: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:80:10 | 78 | _ = f"a {f"first" 79 | + f"second"} d" 80 | _ = f"a {f"first {f"middle"}" | __________^ 81 | | + f"second"} d" - | |_______________^ ISC003 + | |_______________^ 82 | 83 | # See https://github.com/astral-sh/ruff/issues/12936 | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 78 78 | _ = f"a {f"first" @@ -106,15 +111,16 @@ ISC.py:80:10: ISC003 [*] Explicitly concatenated string should be implicitly con 83 83 | # See https://github.com/astral-sh/ruff/issues/12936 84 84 | _ = "\12""0" # fix should be "\0120" -ISC.py:110:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:110:5 | 109 | _ = ( 110 | / rf"raw_f{x}" + 111 | | r"raw_normal" - | |_________________^ ISC003 + | |_________________^ 112 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 107 107 | ) @@ -126,16 +132,17 @@ ISC.py:110:5: ISC003 [*] Explicitly concatenated string should be implicitly con 112 112 | ) 113 113 | -ISC.py:117:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:117:5 | 115 | # Different prefix combinations 116 | _ = ( 117 | / u"unicode" + 118 | | r"raw" - | |__________^ ISC003 + | |__________^ 119 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 114 114 | @@ -147,15 +154,16 @@ ISC.py:117:5: ISC003 [*] Explicitly concatenated string should be implicitly con 119 119 | ) 120 120 | -ISC.py:122:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:122:5 | 121 | _ = ( 122 | / rb"raw_bytes" + 123 | | b"normal_bytes" - | |___________________^ ISC003 + | |___________________^ 124 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 119 119 | ) @@ -167,15 +175,16 @@ ISC.py:122:5: ISC003 [*] Explicitly concatenated string should be implicitly con 124 124 | ) 125 125 | -ISC.py:127:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:127:5 | 126 | _ = ( 127 | / b"bytes" + 128 | | b"with_bytes" - | |_________________^ ISC003 + | |_________________^ 129 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 124 124 | ) @@ -187,18 +196,19 @@ ISC.py:127:5: ISC003 [*] Explicitly concatenated string should be implicitly con 129 129 | ) 130 130 | -ISC.py:133:6: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:133:6 | 131 | # Repeated concatenation 132 | 133 | _ = ("a" + | ______^ 134 | | "b" + - | |_______^ ISC003 + | |_______^ 135 | "c" + 136 | "d" + "e" | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 130 130 | @@ -210,18 +220,19 @@ ISC.py:133:6: ISC003 [*] Explicitly concatenated string should be implicitly con 135 135 | "c" + 136 136 | "d" + "e" -ISC.py:139:6: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:139:6 | 137 | ) 138 | 139 | _ = ("a" | ______^ 140 | | + "b" - | |_________^ ISC003 + | |_________^ 141 | + "c" 142 | + "d" | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 137 137 | ) @@ -233,15 +244,16 @@ ISC.py:139:6: ISC003 [*] Explicitly concatenated string should be implicitly con 142 142 | + "d" 143 143 | + "e" -ISC.py:160:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:160:5 | 159 | _ = ( 160 | / "first" 161 | | + "second" # extra spaces around + - | |_________________^ ISC003 + | |_________________^ 162 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 158 158 | @@ -253,15 +265,16 @@ ISC.py:160:5: ISC003 [*] Explicitly concatenated string should be implicitly con 163 163 | 164 164 | _ = ( -ISC.py:165:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:165:5 | 164 | _ = ( 165 | / "first" + # trailing spaces before + 166 | | "second" - | |____________^ ISC003 + | |____________^ 167 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 162 162 | ) @@ -273,15 +286,16 @@ ISC.py:165:5: ISC003 [*] Explicitly concatenated string should be implicitly con 167 167 | ) 168 168 | -ISC.py:170:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:170:5 | 169 | _ = (( 170 | / "deep" + 171 | | "nesting" - | |_____________^ ISC003 + | |_____________^ 172 | )) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 167 167 | ) @@ -293,15 +307,16 @@ ISC.py:170:5: ISC003 [*] Explicitly concatenated string should be implicitly con 172 172 | )) 173 173 | -ISC.py:175:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:175:5 | 174 | _ = ( 175 | / "contains + plus" + 176 | | "another string" - | |____________________^ ISC003 + | |____________________^ 177 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 172 172 | )) @@ -313,16 +328,17 @@ ISC.py:175:5: ISC003 [*] Explicitly concatenated string should be implicitly con 177 177 | ) 178 178 | -ISC.py:180:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:180:5 | 179 | _ = ( 180 | / "start" 181 | | # leading comment 182 | | + "end" - | |___________^ ISC003 + | |___________^ 183 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 179 179 | _ = ( @@ -334,16 +350,17 @@ ISC.py:180:5: ISC003 [*] Explicitly concatenated string should be implicitly con 184 184 | 185 185 | _ = ( -ISC.py:186:5: ISC003 [*] Explicitly concatenated string should be implicitly concatenated +ISC003 [*] Explicitly concatenated string should be implicitly concatenated + --> ISC.py:186:5 | 185 | _ = ( 186 | / "start" + 187 | | # leading comment 188 | | "end" - | |_________^ ISC003 + | |_________^ 189 | ) | - = help: Remove redundant '+' operator to implicitly concatenate +help: Remove redundant '+' operator to implicitly concatenate ℹ Safe fix 183 183 | ) diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap index e6cfb14078..f6a411fcb3 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- -ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:1:5 | 1 | _ = "a" "b" "c" - | ^^^^^^^ ISC001 + | ^^^^^^^ 2 | 3 | _ = "abc" + "def" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 1 |-_ = "a" "b" "c" @@ -17,14 +18,15 @@ ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line 3 3 | _ = "abc" + "def" 4 4 | -ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:1:9 | 1 | _ = "a" "b" "c" - | ^^^^^^^ ISC001 + | ^^^^^^^ 2 | 3 | _ = "abc" + "def" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 1 |-_ = "a" "b" "c" @@ -33,16 +35,17 @@ ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line 3 3 | _ = "abc" + "def" 4 4 | -ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:38:5 | 36 | ) 37 | 38 | _ = """a""" """b""" - | ^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^ 39 | 40 | _ = """a | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 35 35 | b"def" @@ -54,7 +57,8 @@ ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line 40 40 | _ = """a 41 41 | b""" """c -ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:40:5 | 38 | _ = """a""" """b""" 39 | @@ -62,11 +66,11 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line | _____^ 41 | | b""" """c 42 | | d""" - | |____^ ISC001 + | |____^ 43 | 44 | _ = f"""a""" f"""b""" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 38 38 | _ = """a""" """b""" @@ -78,16 +82,17 @@ ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line 43 43 | 44 44 | _ = f"""a""" f"""b""" -ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:44:5 | 42 | d""" 43 | 44 | _ = f"""a""" f"""b""" - | ^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^ 45 | 46 | _ = f"a" "b" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 41 41 | b""" """c @@ -99,49 +104,53 @@ ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line 46 46 | _ = f"a" "b" 47 47 | -ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:46:5 | 44 | _ = f"""a""" f"""b""" 45 | 46 | _ = f"a" "b" - | ^^^^^^^^ ISC001 + | ^^^^^^^^ 47 | 48 | _ = """a""" "b" | - = help: Combine string literals +help: Combine string literals -ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:48:5 | 46 | _ = f"a" "b" 47 | 48 | _ = """a""" "b" - | ^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^ 49 | 50 | _ = 'a' "b" | - = help: Combine string literals +help: Combine string literals -ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:50:5 | 48 | _ = """a""" "b" 49 | 50 | _ = 'a' "b" - | ^^^^^^^ ISC001 + | ^^^^^^^ 51 | 52 | _ = rf"a" rf"b" | - = help: Combine string literals +help: Combine string literals -ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:52:5 | 50 | _ = 'a' "b" 51 | 52 | _ = rf"a" rf"b" - | ^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^ 53 | 54 | # Single-line explicit concatenation should be ignored. | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 49 49 | @@ -153,15 +162,16 @@ ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line 54 54 | # Single-line explicit concatenation should be ignored. 55 55 | _ = "abc" + "def" + "ghi" -ISC.py:64:10: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:64:10 | 63 | # Multiple strings nested inside a f-string 64 | _ = f"a {'b' 'c' 'd'} e" - | ^^^^^^^ ISC001 + | ^^^^^^^ 65 | _ = f"""abc {"def" "ghi"} jkl""" 66 | _ = f"""abc { | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 61 61 | _ = foo + "abc" + bar @@ -173,15 +183,16 @@ ISC.py:64:10: ISC001 [*] Implicitly concatenated string literals on one line 66 66 | _ = f"""abc { 67 67 | "def" -ISC.py:64:14: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:64:14 | 63 | # Multiple strings nested inside a f-string 64 | _ = f"a {'b' 'c' 'd'} e" - | ^^^^^^^ ISC001 + | ^^^^^^^ 65 | _ = f"""abc {"def" "ghi"} jkl""" 66 | _ = f"""abc { | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 61 61 | _ = foo + "abc" + bar @@ -193,16 +204,17 @@ ISC.py:64:14: ISC001 [*] Implicitly concatenated string literals on one line 66 66 | _ = f"""abc { 67 67 | "def" -ISC.py:65:14: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:65:14 | 63 | # Multiple strings nested inside a f-string 64 | _ = f"a {'b' 'c' 'd'} e" 65 | _ = f"""abc {"def" "ghi"} jkl""" - | ^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^ 66 | _ = f"""abc { 67 | "def" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 62 62 | @@ -214,35 +226,38 @@ ISC.py:65:14: ISC001 [*] Implicitly concatenated string literals on one line 67 67 | "def" 68 68 | "ghi" -ISC.py:72:5: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:72:5 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" - | ^^^^^^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^^^^^^ 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" 74 | _ = f"b {f"abc" \ | - = help: Combine string literals +help: Combine string literals -ISC.py:72:9: ISC001 Implicitly concatenated string literals on one line +ISC001 Implicitly concatenated string literals on one line + --> ISC.py:72:9 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" - | ^^^^^^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^^^^^^ 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" 74 | _ = f"b {f"abc" \ | - = help: Combine string literals +help: Combine string literals -ISC.py:72:14: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:72:14 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" - | ^^^^^^^^^ ISC001 + | ^^^^^^^^^ 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" 74 | _ = f"b {f"abc" \ | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 69 69 | } jkl""" @@ -254,16 +269,17 @@ ISC.py:72:14: ISC001 [*] Implicitly concatenated string literals on one line 74 74 | _ = f"b {f"abc" \ 75 75 | f"def"} g" -ISC.py:73:10: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:73:10 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" - | ^^^^^^^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^^^^^^^ 74 | _ = f"b {f"abc" \ 75 | f"def"} g" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 70 70 | @@ -275,16 +291,17 @@ ISC.py:73:10: ISC001 [*] Implicitly concatenated string literals on one line 75 75 | f"def"} g" 76 76 | -ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:73:20 | 71 | # Nested f-strings 72 | _ = "a" f"b {f"c" f"d"} e" "f" 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" - | ^^^^^^^^^ ISC001 + | ^^^^^^^^^ 74 | _ = f"b {f"abc" \ 75 | f"def"} g" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 70 70 | @@ -296,15 +313,16 @@ ISC.py:73:20: ISC001 [*] Implicitly concatenated string literals on one line 75 75 | f"def"} g" 76 76 | -ISC.py:84:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:84:5 | 83 | # See https://github.com/astral-sh/ruff/issues/12936 84 | _ = "\12""0" # fix should be "\0120" - | ^^^^^^^^ ISC001 + | ^^^^^^^^ 85 | _ = "\\12""0" # fix should be "\\120" 86 | _ = "\\\12""0" # fix should be "\\\0120" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 81 81 | + f"second"} d" @@ -316,16 +334,17 @@ ISC.py:84:5: ISC001 [*] Implicitly concatenated string literals on one line 86 86 | _ = "\\\12""0" # fix should be "\\\0120" 87 87 | _ = "\12 0""0" # fix should be "\12 00" -ISC.py:85:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:85:5 | 83 | # See https://github.com/astral-sh/ruff/issues/12936 84 | _ = "\12""0" # fix should be "\0120" 85 | _ = "\\12""0" # fix should be "\\120" - | ^^^^^^^^^ ISC001 + | ^^^^^^^^^ 86 | _ = "\\\12""0" # fix should be "\\\0120" 87 | _ = "\12 0""0" # fix should be "\12 00" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 82 82 | @@ -337,16 +356,17 @@ ISC.py:85:5: ISC001 [*] Implicitly concatenated string literals on one line 87 87 | _ = "\12 0""0" # fix should be "\12 00" 88 88 | _ = r"\12"r"0" # fix should be r"\120" -ISC.py:86:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:86:5 | 84 | _ = "\12""0" # fix should be "\0120" 85 | _ = "\\12""0" # fix should be "\\120" 86 | _ = "\\\12""0" # fix should be "\\\0120" - | ^^^^^^^^^^ ISC001 + | ^^^^^^^^^^ 87 | _ = "\12 0""0" # fix should be "\12 00" 88 | _ = r"\12"r"0" # fix should be r"\120" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 83 83 | # See https://github.com/astral-sh/ruff/issues/12936 @@ -358,16 +378,17 @@ ISC.py:86:5: ISC001 [*] Implicitly concatenated string literals on one line 88 88 | _ = r"\12"r"0" # fix should be r"\120" 89 89 | _ = "\12 and more""0" # fix should be "\12 and more0" -ISC.py:87:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:87:5 | 85 | _ = "\\12""0" # fix should be "\\120" 86 | _ = "\\\12""0" # fix should be "\\\0120" 87 | _ = "\12 0""0" # fix should be "\12 00" - | ^^^^^^^^^^ ISC001 + | ^^^^^^^^^^ 88 | _ = r"\12"r"0" # fix should be r"\120" 89 | _ = "\12 and more""0" # fix should be "\12 and more0" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 84 84 | _ = "\12""0" # fix should be "\0120" @@ -379,16 +400,17 @@ ISC.py:87:5: ISC001 [*] Implicitly concatenated string literals on one line 89 89 | _ = "\12 and more""0" # fix should be "\12 and more0" 90 90 | _ = "\8""0" # fix should be "\80" -ISC.py:88:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:88:5 | 86 | _ = "\\\12""0" # fix should be "\\\0120" 87 | _ = "\12 0""0" # fix should be "\12 00" 88 | _ = r"\12"r"0" # fix should be r"\120" - | ^^^^^^^^^^ ISC001 + | ^^^^^^^^^^ 89 | _ = "\12 and more""0" # fix should be "\12 and more0" 90 | _ = "\8""0" # fix should be "\80" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 85 85 | _ = "\\12""0" # fix should be "\\120" @@ -400,16 +422,17 @@ ISC.py:88:5: ISC001 [*] Implicitly concatenated string literals on one line 90 90 | _ = "\8""0" # fix should be "\80" 91 91 | _ = "\12""8" # fix should be "\128" -ISC.py:89:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:89:5 | 87 | _ = "\12 0""0" # fix should be "\12 00" 88 | _ = r"\12"r"0" # fix should be r"\120" 89 | _ = "\12 and more""0" # fix should be "\12 and more0" - | ^^^^^^^^^^^^^^^^^ ISC001 + | ^^^^^^^^^^^^^^^^^ 90 | _ = "\8""0" # fix should be "\80" 91 | _ = "\12""8" # fix should be "\128" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 86 86 | _ = "\\\12""0" # fix should be "\\\0120" @@ -421,16 +444,17 @@ ISC.py:89:5: ISC001 [*] Implicitly concatenated string literals on one line 91 91 | _ = "\12""8" # fix should be "\128" 92 92 | _ = "\12""foo" # fix should be "\12foo" -ISC.py:90:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:90:5 | 88 | _ = r"\12"r"0" # fix should be r"\120" 89 | _ = "\12 and more""0" # fix should be "\12 and more0" 90 | _ = "\8""0" # fix should be "\80" - | ^^^^^^^ ISC001 + | ^^^^^^^ 91 | _ = "\12""8" # fix should be "\128" 92 | _ = "\12""foo" # fix should be "\12foo" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 87 87 | _ = "\12 0""0" # fix should be "\12 00" @@ -442,16 +466,17 @@ ISC.py:90:5: ISC001 [*] Implicitly concatenated string literals on one line 92 92 | _ = "\12""foo" # fix should be "\12foo" 93 93 | _ = "\12" "" # fix should be "\12" -ISC.py:91:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:91:5 | 89 | _ = "\12 and more""0" # fix should be "\12 and more0" 90 | _ = "\8""0" # fix should be "\80" 91 | _ = "\12""8" # fix should be "\128" - | ^^^^^^^^ ISC001 + | ^^^^^^^^ 92 | _ = "\12""foo" # fix should be "\12foo" 93 | _ = "\12" "" # fix should be "\12" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 88 88 | _ = r"\12"r"0" # fix should be r"\120" @@ -463,15 +488,16 @@ ISC.py:91:5: ISC001 [*] Implicitly concatenated string literals on one line 93 93 | _ = "\12" "" # fix should be "\12" 94 94 | -ISC.py:92:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:92:5 | 90 | _ = "\8""0" # fix should be "\80" 91 | _ = "\12""8" # fix should be "\128" 92 | _ = "\12""foo" # fix should be "\12foo" - | ^^^^^^^^^^ ISC001 + | ^^^^^^^^^^ 93 | _ = "\12" "" # fix should be "\12" | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 89 89 | _ = "\12 and more""0" # fix should be "\12 and more0" @@ -483,14 +509,15 @@ ISC.py:92:5: ISC001 [*] Implicitly concatenated string literals on one line 94 94 | 95 95 | -ISC.py:93:5: ISC001 [*] Implicitly concatenated string literals on one line +ISC001 [*] Implicitly concatenated string literals on one line + --> ISC.py:93:5 | 91 | _ = "\12""8" # fix should be "\128" 92 | _ = "\12""foo" # fix should be "\12foo" 93 | _ = "\12" "" # fix should be "\12" - | ^^^^^^^^ ISC001 + | ^^^^^^^^ | - = help: Combine string literals +help: Combine string literals ℹ Safe fix 90 90 | _ = "\8""0" # fix should be "\80" diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap index a468ebd279..c0a1f8995f 100644 --- a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap @@ -1,63 +1,69 @@ --- source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs --- -ISC.py:5:5: ISC002 Implicitly concatenated string literals over multiple lines +ISC002 Implicitly concatenated string literals over multiple lines + --> ISC.py:5:5 | 3 | _ = "abc" + "def" 4 | 5 | _ = "abc" \ | _____^ 6 | | "def" - | |_________^ ISC002 + | |_________^ 7 | 8 | _ = ( | -ISC.py:24:3: ISC002 Implicitly concatenated string literals over multiple lines +ISC002 Implicitly concatenated string literals over multiple lines + --> ISC.py:24:3 | 23 | _ = ( 24 | / "abc" 25 | | "def" - | |_______^ ISC002 + | |_______^ 26 | ) | -ISC.py:29:3: ISC002 Implicitly concatenated string literals over multiple lines +ISC002 Implicitly concatenated string literals over multiple lines + --> ISC.py:29:3 | 28 | _ = ( 29 | / f"abc" 30 | | "def" - | |_______^ ISC002 + | |_______^ 31 | ) | -ISC.py:34:3: ISC002 Implicitly concatenated string literals over multiple lines +ISC002 Implicitly concatenated string literals over multiple lines + --> ISC.py:34:3 | 33 | _ = ( 34 | / b"abc" 35 | | b"def" - | |________^ ISC002 + | |________^ 36 | ) | -ISC.py:67:5: ISC002 Implicitly concatenated string literals over multiple lines +ISC002 Implicitly concatenated string literals over multiple lines + --> ISC.py:67:5 | 65 | _ = f"""abc {"def" "ghi"} jkl""" 66 | _ = f"""abc { 67 | / "def" 68 | | "ghi" - | |_________^ ISC002 + | |_________^ 69 | } jkl""" | -ISC.py:74:10: ISC002 Implicitly concatenated string literals over multiple lines +ISC002 Implicitly concatenated string literals over multiple lines + --> ISC.py:74:10 | 72 | _ = "a" f"b {f"c" f"d"} e" "f" 73 | _ = f"b {f"c" f"d {f"e" f"f"} g"} h" 74 | _ = f"b {f"abc" \ | __________^ 75 | | f"def"} g" - | |__________^ ISC002 + | |__________^ 76 | 77 | # Explicitly concatenated nested f-strings | diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap index bae5ffd77e..b328d7be06 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap @@ -1,326 +1,356 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs --- -custom.py:3:8: ICN001 `altair` should be imported as `alt` +ICN001 `altair` should be imported as `alt` + --> custom.py:3:8 | 1 | import math # not checked 2 | 3 | import altair # unconventional - | ^^^^^^ ICN001 + | ^^^^^^ 4 | import dask.array # unconventional 5 | import dask.dataframe # unconventional | - = help: Alias `altair` to `alt` +help: Alias `altair` to `alt` -custom.py:4:8: ICN001 `dask.array` should be imported as `da` +ICN001 `dask.array` should be imported as `da` + --> custom.py:4:8 | 3 | import altair # unconventional 4 | import dask.array # unconventional - | ^^^^^^^^^^ ICN001 + | ^^^^^^^^^^ 5 | import dask.dataframe # unconventional 6 | import matplotlib.pyplot # unconventional | - = help: Alias `dask.array` to `da` +help: Alias `dask.array` to `da` -custom.py:5:8: ICN001 `dask.dataframe` should be imported as `dd` +ICN001 `dask.dataframe` should be imported as `dd` + --> custom.py:5:8 | 3 | import altair # unconventional 4 | import dask.array # unconventional 5 | import dask.dataframe # unconventional - | ^^^^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^^^^ 6 | import matplotlib.pyplot # unconventional 7 | import numpy # unconventional | - = help: Alias `dask.dataframe` to `dd` +help: Alias `dask.dataframe` to `dd` -custom.py:6:8: ICN001 `matplotlib.pyplot` should be imported as `plt` +ICN001 `matplotlib.pyplot` should be imported as `plt` + --> custom.py:6:8 | 4 | import dask.array # unconventional 5 | import dask.dataframe # unconventional 6 | import matplotlib.pyplot # unconventional - | ^^^^^^^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^^^^^^^ 7 | import numpy # unconventional 8 | import pandas # unconventional | - = help: Alias `matplotlib.pyplot` to `plt` +help: Alias `matplotlib.pyplot` to `plt` -custom.py:7:8: ICN001 `numpy` should be imported as `np` +ICN001 `numpy` should be imported as `np` + --> custom.py:7:8 | 5 | import dask.dataframe # unconventional 6 | import matplotlib.pyplot # unconventional 7 | import numpy # unconventional - | ^^^^^ ICN001 + | ^^^^^ 8 | import pandas # unconventional 9 | import seaborn # unconventional | - = help: Alias `numpy` to `np` +help: Alias `numpy` to `np` -custom.py:8:8: ICN001 `pandas` should be imported as `pd` +ICN001 `pandas` should be imported as `pd` + --> custom.py:8:8 | 6 | import matplotlib.pyplot # unconventional 7 | import numpy # unconventional 8 | import pandas # unconventional - | ^^^^^^ ICN001 + | ^^^^^^ 9 | import seaborn # unconventional 10 | import tensorflow # unconventional | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` -custom.py:9:8: ICN001 `seaborn` should be imported as `sns` +ICN001 `seaborn` should be imported as `sns` + --> custom.py:9:8 | 7 | import numpy # unconventional 8 | import pandas # unconventional 9 | import seaborn # unconventional - | ^^^^^^^ ICN001 + | ^^^^^^^ 10 | import tensorflow # unconventional 11 | import holoviews # unconventional | - = help: Alias `seaborn` to `sns` +help: Alias `seaborn` to `sns` -custom.py:10:8: ICN001 `tensorflow` should be imported as `tf` +ICN001 `tensorflow` should be imported as `tf` + --> custom.py:10:8 | 8 | import pandas # unconventional 9 | import seaborn # unconventional 10 | import tensorflow # unconventional - | ^^^^^^^^^^ ICN001 + | ^^^^^^^^^^ 11 | import holoviews # unconventional 12 | import panel # unconventional | - = help: Alias `tensorflow` to `tf` +help: Alias `tensorflow` to `tf` -custom.py:11:8: ICN001 `holoviews` should be imported as `hv` +ICN001 `holoviews` should be imported as `hv` + --> custom.py:11:8 | 9 | import seaborn # unconventional 10 | import tensorflow # unconventional 11 | import holoviews # unconventional - | ^^^^^^^^^ ICN001 + | ^^^^^^^^^ 12 | import panel # unconventional 13 | import plotly.express # unconventional | - = help: Alias `holoviews` to `hv` +help: Alias `holoviews` to `hv` -custom.py:12:8: ICN001 `panel` should be imported as `pn` +ICN001 `panel` should be imported as `pn` + --> custom.py:12:8 | 10 | import tensorflow # unconventional 11 | import holoviews # unconventional 12 | import panel # unconventional - | ^^^^^ ICN001 + | ^^^^^ 13 | import plotly.express # unconventional 14 | import matplotlib # unconventional | - = help: Alias `panel` to `pn` +help: Alias `panel` to `pn` -custom.py:13:8: ICN001 `plotly.express` should be imported as `px` +ICN001 `plotly.express` should be imported as `px` + --> custom.py:13:8 | 11 | import holoviews # unconventional 12 | import panel # unconventional 13 | import plotly.express # unconventional - | ^^^^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^^^^ 14 | import matplotlib # unconventional 15 | import polars # unconventional | - = help: Alias `plotly.express` to `px` +help: Alias `plotly.express` to `px` -custom.py:14:8: ICN001 `matplotlib` should be imported as `mpl` +ICN001 `matplotlib` should be imported as `mpl` + --> custom.py:14:8 | 12 | import panel # unconventional 13 | import plotly.express # unconventional 14 | import matplotlib # unconventional - | ^^^^^^^^^^ ICN001 + | ^^^^^^^^^^ 15 | import polars # unconventional 16 | import pyarrow # unconventional | - = help: Alias `matplotlib` to `mpl` +help: Alias `matplotlib` to `mpl` -custom.py:15:8: ICN001 `polars` should be imported as `pl` +ICN001 `polars` should be imported as `pl` + --> custom.py:15:8 | 13 | import plotly.express # unconventional 14 | import matplotlib # unconventional 15 | import polars # unconventional - | ^^^^^^ ICN001 + | ^^^^^^ 16 | import pyarrow # unconventional | - = help: Alias `polars` to `pl` +help: Alias `polars` to `pl` -custom.py:16:8: ICN001 `pyarrow` should be imported as `pa` +ICN001 `pyarrow` should be imported as `pa` + --> custom.py:16:8 | 14 | import matplotlib # unconventional 15 | import polars # unconventional 16 | import pyarrow # unconventional - | ^^^^^^^ ICN001 + | ^^^^^^^ 17 | 18 | import altair as altr # unconventional | - = help: Alias `pyarrow` to `pa` +help: Alias `pyarrow` to `pa` -custom.py:18:18: ICN001 `altair` should be imported as `alt` +ICN001 `altair` should be imported as `alt` + --> custom.py:18:18 | 16 | import pyarrow # unconventional 17 | 18 | import altair as altr # unconventional - | ^^^^ ICN001 + | ^^^^ 19 | import matplotlib.pyplot as plot # unconventional 20 | import dask.array as darray # unconventional | - = help: Alias `altair` to `alt` +help: Alias `altair` to `alt` -custom.py:19:29: ICN001 `matplotlib.pyplot` should be imported as `plt` +ICN001 `matplotlib.pyplot` should be imported as `plt` + --> custom.py:19:29 | 18 | import altair as altr # unconventional 19 | import matplotlib.pyplot as plot # unconventional - | ^^^^ ICN001 + | ^^^^ 20 | import dask.array as darray # unconventional 21 | import dask.dataframe as ddf # unconventional | - = help: Alias `matplotlib.pyplot` to `plt` +help: Alias `matplotlib.pyplot` to `plt` -custom.py:20:22: ICN001 `dask.array` should be imported as `da` +ICN001 `dask.array` should be imported as `da` + --> custom.py:20:22 | 18 | import altair as altr # unconventional 19 | import matplotlib.pyplot as plot # unconventional 20 | import dask.array as darray # unconventional - | ^^^^^^ ICN001 + | ^^^^^^ 21 | import dask.dataframe as ddf # unconventional 22 | import numpy as nmp # unconventional | - = help: Alias `dask.array` to `da` +help: Alias `dask.array` to `da` -custom.py:21:26: ICN001 `dask.dataframe` should be imported as `dd` +ICN001 `dask.dataframe` should be imported as `dd` + --> custom.py:21:26 | 19 | import matplotlib.pyplot as plot # unconventional 20 | import dask.array as darray # unconventional 21 | import dask.dataframe as ddf # unconventional - | ^^^ ICN001 + | ^^^ 22 | import numpy as nmp # unconventional 23 | import pandas as pdas # unconventional | - = help: Alias `dask.dataframe` to `dd` +help: Alias `dask.dataframe` to `dd` -custom.py:22:17: ICN001 `numpy` should be imported as `np` +ICN001 `numpy` should be imported as `np` + --> custom.py:22:17 | 20 | import dask.array as darray # unconventional 21 | import dask.dataframe as ddf # unconventional 22 | import numpy as nmp # unconventional - | ^^^ ICN001 + | ^^^ 23 | import pandas as pdas # unconventional 24 | import seaborn as sbrn # unconventional | - = help: Alias `numpy` to `np` +help: Alias `numpy` to `np` -custom.py:23:18: ICN001 `pandas` should be imported as `pd` +ICN001 `pandas` should be imported as `pd` + --> custom.py:23:18 | 21 | import dask.dataframe as ddf # unconventional 22 | import numpy as nmp # unconventional 23 | import pandas as pdas # unconventional - | ^^^^ ICN001 + | ^^^^ 24 | import seaborn as sbrn # unconventional 25 | import tensorflow as tfz # unconventional | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` -custom.py:24:19: ICN001 `seaborn` should be imported as `sns` +ICN001 `seaborn` should be imported as `sns` + --> custom.py:24:19 | 22 | import numpy as nmp # unconventional 23 | import pandas as pdas # unconventional 24 | import seaborn as sbrn # unconventional - | ^^^^ ICN001 + | ^^^^ 25 | import tensorflow as tfz # unconventional 26 | import holoviews as hsv # unconventional | - = help: Alias `seaborn` to `sns` +help: Alias `seaborn` to `sns` -custom.py:25:22: ICN001 `tensorflow` should be imported as `tf` +ICN001 `tensorflow` should be imported as `tf` + --> custom.py:25:22 | 23 | import pandas as pdas # unconventional 24 | import seaborn as sbrn # unconventional 25 | import tensorflow as tfz # unconventional - | ^^^ ICN001 + | ^^^ 26 | import holoviews as hsv # unconventional 27 | import panel as pns # unconventional | - = help: Alias `tensorflow` to `tf` +help: Alias `tensorflow` to `tf` -custom.py:26:21: ICN001 `holoviews` should be imported as `hv` +ICN001 `holoviews` should be imported as `hv` + --> custom.py:26:21 | 24 | import seaborn as sbrn # unconventional 25 | import tensorflow as tfz # unconventional 26 | import holoviews as hsv # unconventional - | ^^^ ICN001 + | ^^^ 27 | import panel as pns # unconventional 28 | import plotly.express as pltx # unconventional | - = help: Alias `holoviews` to `hv` +help: Alias `holoviews` to `hv` -custom.py:27:17: ICN001 `panel` should be imported as `pn` +ICN001 `panel` should be imported as `pn` + --> custom.py:27:17 | 25 | import tensorflow as tfz # unconventional 26 | import holoviews as hsv # unconventional 27 | import panel as pns # unconventional - | ^^^ ICN001 + | ^^^ 28 | import plotly.express as pltx # unconventional 29 | import matplotlib as ml # unconventional | - = help: Alias `panel` to `pn` +help: Alias `panel` to `pn` -custom.py:28:26: ICN001 `plotly.express` should be imported as `px` +ICN001 `plotly.express` should be imported as `px` + --> custom.py:28:26 | 26 | import holoviews as hsv # unconventional 27 | import panel as pns # unconventional 28 | import plotly.express as pltx # unconventional - | ^^^^ ICN001 + | ^^^^ 29 | import matplotlib as ml # unconventional 30 | import polars as ps # unconventional | - = help: Alias `plotly.express` to `px` +help: Alias `plotly.express` to `px` -custom.py:29:22: ICN001 `matplotlib` should be imported as `mpl` +ICN001 `matplotlib` should be imported as `mpl` + --> custom.py:29:22 | 27 | import panel as pns # unconventional 28 | import plotly.express as pltx # unconventional 29 | import matplotlib as ml # unconventional - | ^^ ICN001 + | ^^ 30 | import polars as ps # unconventional 31 | import pyarrow as arr # unconventional | - = help: Alias `matplotlib` to `mpl` +help: Alias `matplotlib` to `mpl` -custom.py:30:18: ICN001 `polars` should be imported as `pl` +ICN001 `polars` should be imported as `pl` + --> custom.py:30:18 | 28 | import plotly.express as pltx # unconventional 29 | import matplotlib as ml # unconventional 30 | import polars as ps # unconventional - | ^^ ICN001 + | ^^ 31 | import pyarrow as arr # unconventional | - = help: Alias `polars` to `pl` +help: Alias `polars` to `pl` -custom.py:31:19: ICN001 `pyarrow` should be imported as `pa` +ICN001 `pyarrow` should be imported as `pa` + --> custom.py:31:19 | 29 | import matplotlib as ml # unconventional 30 | import polars as ps # unconventional 31 | import pyarrow as arr # unconventional - | ^^^ ICN001 + | ^^^ 32 | 33 | import altair as alt # conventional | - = help: Alias `pyarrow` to `pa` +help: Alias `pyarrow` to `pa` -custom.py:50:8: ICN001 `numpy.typing` should be imported as `npt` +ICN001 `numpy.typing` should be imported as `npt` + --> custom.py:50:8 | 48 | from tensorflow.keras import Model # conventional 49 | 50 | import numpy.typing # unconventional - | ^^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^^ 51 | import numpy.typing as nt # unconventional 52 | import numpy.typing as npt # conventional | - = help: Alias `numpy.typing` to `npt` +help: Alias `numpy.typing` to `npt` -custom.py:51:24: ICN001 `numpy.typing` should be imported as `npt` +ICN001 `numpy.typing` should be imported as `npt` + --> custom.py:51:24 | 50 | import numpy.typing # unconventional 51 | import numpy.typing as nt # unconventional - | ^^ ICN001 + | ^^ 52 | import numpy.typing as npt # conventional | - = help: Alias `numpy.typing` to `npt` +help: Alias `numpy.typing` to `npt` diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap index 7559c70440..84f4c9b9b6 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap @@ -1,76 +1,84 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs --- -custom_banned.py:1:1: ICN002 `typing` should not be imported as `t` +ICN002 `typing` should not be imported as `t` + --> custom_banned.py:1:1 | 1 | import typing as t # banned - | ^^^^^^^^^^^^^^^^^^ ICN002 + | ^^^^^^^^^^^^^^^^^^ 2 | import typing as ty # banned | -custom_banned.py:2:1: ICN002 `typing` should not be imported as `ty` +ICN002 `typing` should not be imported as `ty` + --> custom_banned.py:2:1 | 1 | import typing as t # banned 2 | import typing as ty # banned - | ^^^^^^^^^^^^^^^^^^^ ICN002 + | ^^^^^^^^^^^^^^^^^^^ 3 | 4 | import numpy as nmp # banned | -custom_banned.py:4:1: ICN002 `numpy` should not be imported as `nmp` +ICN002 `numpy` should not be imported as `nmp` + --> custom_banned.py:4:1 | 2 | import typing as ty # banned 3 | 4 | import numpy as nmp # banned - | ^^^^^^^^^^^^^^^^^^^ ICN002 + | ^^^^^^^^^^^^^^^^^^^ 5 | import numpy as npy # banned 6 | import tensorflow.keras.backend as K # banned | -custom_banned.py:5:1: ICN002 `numpy` should not be imported as `npy` +ICN002 `numpy` should not be imported as `npy` + --> custom_banned.py:5:1 | 4 | import numpy as nmp # banned 5 | import numpy as npy # banned - | ^^^^^^^^^^^^^^^^^^^ ICN002 + | ^^^^^^^^^^^^^^^^^^^ 6 | import tensorflow.keras.backend as K # banned 7 | import torch.nn.functional as F # banned | -custom_banned.py:6:1: ICN002 `tensorflow.keras.backend` should not be imported as `K` +ICN002 `tensorflow.keras.backend` should not be imported as `K` + --> custom_banned.py:6:1 | 4 | import numpy as nmp # banned 5 | import numpy as npy # banned 6 | import tensorflow.keras.backend as K # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | import torch.nn.functional as F # banned 8 | from tensorflow.keras import backend as K # banned | -custom_banned.py:7:1: ICN002 `torch.nn.functional` should not be imported as `F` +ICN002 `torch.nn.functional` should not be imported as `F` + --> custom_banned.py:7:1 | 5 | import numpy as npy # banned 6 | import tensorflow.keras.backend as K # banned 7 | import torch.nn.functional as F # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | from tensorflow.keras import backend as K # banned 9 | from torch.nn import functional as F # banned | -custom_banned.py:8:1: ICN002 `tensorflow.keras.backend` should not be imported as `K` +ICN002 `tensorflow.keras.backend` should not be imported as `K` + --> custom_banned.py:8:1 | 6 | import tensorflow.keras.backend as K # banned 7 | import torch.nn.functional as F # banned 8 | from tensorflow.keras import backend as K # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | from torch.nn import functional as F # banned | -custom_banned.py:9:1: ICN002 `torch.nn.functional` should not be imported as `F` +ICN002 `torch.nn.functional` should not be imported as `F` + --> custom_banned.py:9:1 | 7 | import torch.nn.functional as F # banned 8 | from tensorflow.keras import backend as K # banned 9 | from torch.nn import functional as F # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | from typing import Any # ok | diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap index f40db3b4c0..34d2037176 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap @@ -1,46 +1,51 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs --- -custom_banned_from.py:1:1: ICN003 Members of `logging.config` should not be imported explicitly +ICN003 Members of `logging.config` should not be imported explicitly + --> custom_banned_from.py:1:1 | 1 | from logging.config import BaseConfigurator # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | from typing import Any, Dict # banned 3 | from typing import * # banned | -custom_banned_from.py:2:1: ICN003 Members of `typing` should not be imported explicitly +ICN003 Members of `typing` should not be imported explicitly + --> custom_banned_from.py:2:1 | 1 | from logging.config import BaseConfigurator # banned 2 | from typing import Any, Dict # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | from typing import * # banned | -custom_banned_from.py:3:1: ICN003 Members of `typing` should not be imported explicitly +ICN003 Members of `typing` should not be imported explicitly + --> custom_banned_from.py:3:1 | 1 | from logging.config import BaseConfigurator # banned 2 | from typing import Any, Dict # banned 3 | from typing import * # banned - | ^^^^^^^^^^^^^^^^^^^^ ICN003 + | ^^^^^^^^^^^^^^^^^^^^ 4 | 5 | from pandas import DataFrame # banned | -custom_banned_from.py:5:1: ICN003 Members of `pandas` should not be imported explicitly +ICN003 Members of `pandas` should not be imported explicitly + --> custom_banned_from.py:5:1 | 3 | from typing import * # banned 4 | 5 | from pandas import DataFrame # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | from pandas import * # banned | -custom_banned_from.py:6:1: ICN003 Members of `pandas` should not be imported explicitly +ICN003 Members of `pandas` should not be imported explicitly + --> custom_banned_from.py:6:1 | 5 | from pandas import DataFrame # banned 6 | from pandas import * # banned - | ^^^^^^^^^^^^^^^^^^^^ ICN003 + | ^^^^^^^^^^^^^^^^^^^^ 7 | 8 | import logging.config # ok | diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap index ee7582135f..acd73a4fd1 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- -defaults.py:6:12: ICN001 [*] `altair` should be imported as `alt` +ICN001 [*] `altair` should be imported as `alt` + --> defaults.py:6:12 | 5 | def unconventional(): 6 | import altair - | ^^^^^^ ICN001 + | ^^^^^^ 7 | import matplotlib.pyplot 8 | import numpy | - = help: Alias `altair` to `alt` +help: Alias `altair` to `alt` ℹ Unsafe fix 3 3 | @@ -22,27 +22,29 @@ defaults.py:6:12: ICN001 [*] `altair` should be imported as `alt` 8 8 | import numpy 9 9 | import pandas -defaults.py:7:12: ICN001 `matplotlib.pyplot` should be imported as `plt` +ICN001 `matplotlib.pyplot` should be imported as `plt` + --> defaults.py:7:12 | 5 | def unconventional(): 6 | import altair 7 | import matplotlib.pyplot - | ^^^^^^^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^^^^^^^ 8 | import numpy 9 | import pandas | - = help: Alias `matplotlib.pyplot` to `plt` +help: Alias `matplotlib.pyplot` to `plt` -defaults.py:8:12: ICN001 [*] `numpy` should be imported as `np` +ICN001 [*] `numpy` should be imported as `np` + --> defaults.py:8:12 | 6 | import altair 7 | import matplotlib.pyplot 8 | import numpy - | ^^^^^ ICN001 + | ^^^^^ 9 | import pandas 10 | import seaborn | - = help: Alias `numpy` to `np` +help: Alias `numpy` to `np` ℹ Unsafe fix 5 5 | def unconventional(): @@ -54,16 +56,17 @@ defaults.py:8:12: ICN001 [*] `numpy` should be imported as `np` 10 10 | import seaborn 11 11 | import tkinter -defaults.py:9:12: ICN001 [*] `pandas` should be imported as `pd` +ICN001 [*] `pandas` should be imported as `pd` + --> defaults.py:9:12 | 7 | import matplotlib.pyplot 8 | import numpy 9 | import pandas - | ^^^^^^ ICN001 + | ^^^^^^ 10 | import seaborn 11 | import tkinter | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` ℹ Unsafe fix 6 6 | import altair @@ -75,16 +78,17 @@ defaults.py:9:12: ICN001 [*] `pandas` should be imported as `pd` 11 11 | import tkinter 12 12 | import networkx -defaults.py:10:12: ICN001 [*] `seaborn` should be imported as `sns` +ICN001 [*] `seaborn` should be imported as `sns` + --> defaults.py:10:12 | 8 | import numpy 9 | import pandas 10 | import seaborn - | ^^^^^^^ ICN001 + | ^^^^^^^ 11 | import tkinter 12 | import networkx | - = help: Alias `seaborn` to `sns` +help: Alias `seaborn` to `sns` ℹ Unsafe fix 7 7 | import matplotlib.pyplot @@ -96,15 +100,16 @@ defaults.py:10:12: ICN001 [*] `seaborn` should be imported as `sns` 12 12 | import networkx 13 13 | -defaults.py:11:12: ICN001 [*] `tkinter` should be imported as `tk` +ICN001 [*] `tkinter` should be imported as `tk` + --> defaults.py:11:12 | 9 | import pandas 10 | import seaborn 11 | import tkinter - | ^^^^^^^ ICN001 + | ^^^^^^^ 12 | import networkx | - = help: Alias `tkinter` to `tk` +help: Alias `tkinter` to `tk` ℹ Unsafe fix 8 8 | import numpy @@ -116,14 +121,15 @@ defaults.py:11:12: ICN001 [*] `tkinter` should be imported as `tk` 13 13 | 14 14 | -defaults.py:12:12: ICN001 [*] `networkx` should be imported as `nx` +ICN001 [*] `networkx` should be imported as `nx` + --> defaults.py:12:12 | 10 | import seaborn 11 | import tkinter 12 | import networkx - | ^^^^^^^^ ICN001 + | ^^^^^^^^ | - = help: Alias `networkx` to `nx` +help: Alias `networkx` to `nx` ℹ Unsafe fix 9 9 | import pandas @@ -135,15 +141,16 @@ defaults.py:12:12: ICN001 [*] `networkx` should be imported as `nx` 14 14 | 15 15 | def unconventional_aliases(): -defaults.py:16:22: ICN001 [*] `altair` should be imported as `alt` +ICN001 [*] `altair` should be imported as `alt` + --> defaults.py:16:22 | 15 | def unconventional_aliases(): 16 | import altair as altr - | ^^^^ ICN001 + | ^^^^ 17 | import matplotlib.pyplot as plot 18 | import numpy as nmp | - = help: Alias `altair` to `alt` +help: Alias `altair` to `alt` ℹ Unsafe fix 13 13 | @@ -155,16 +162,17 @@ defaults.py:16:22: ICN001 [*] `altair` should be imported as `alt` 18 18 | import numpy as nmp 19 19 | import pandas as pdas -defaults.py:17:33: ICN001 [*] `matplotlib.pyplot` should be imported as `plt` +ICN001 [*] `matplotlib.pyplot` should be imported as `plt` + --> defaults.py:17:33 | 15 | def unconventional_aliases(): 16 | import altair as altr 17 | import matplotlib.pyplot as plot - | ^^^^ ICN001 + | ^^^^ 18 | import numpy as nmp 19 | import pandas as pdas | - = help: Alias `matplotlib.pyplot` to `plt` +help: Alias `matplotlib.pyplot` to `plt` ℹ Unsafe fix 14 14 | @@ -176,16 +184,17 @@ defaults.py:17:33: ICN001 [*] `matplotlib.pyplot` should be imported as `plt` 19 19 | import pandas as pdas 20 20 | import seaborn as sbrn -defaults.py:18:21: ICN001 [*] `numpy` should be imported as `np` +ICN001 [*] `numpy` should be imported as `np` + --> defaults.py:18:21 | 16 | import altair as altr 17 | import matplotlib.pyplot as plot 18 | import numpy as nmp - | ^^^ ICN001 + | ^^^ 19 | import pandas as pdas 20 | import seaborn as sbrn | - = help: Alias `numpy` to `np` +help: Alias `numpy` to `np` ℹ Unsafe fix 15 15 | def unconventional_aliases(): @@ -197,16 +206,17 @@ defaults.py:18:21: ICN001 [*] `numpy` should be imported as `np` 20 20 | import seaborn as sbrn 21 21 | import tkinter as tkr -defaults.py:19:22: ICN001 [*] `pandas` should be imported as `pd` +ICN001 [*] `pandas` should be imported as `pd` + --> defaults.py:19:22 | 17 | import matplotlib.pyplot as plot 18 | import numpy as nmp 19 | import pandas as pdas - | ^^^^ ICN001 + | ^^^^ 20 | import seaborn as sbrn 21 | import tkinter as tkr | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` ℹ Unsafe fix 16 16 | import altair as altr @@ -218,16 +228,17 @@ defaults.py:19:22: ICN001 [*] `pandas` should be imported as `pd` 21 21 | import tkinter as tkr 22 22 | import networkx as nxy -defaults.py:20:23: ICN001 [*] `seaborn` should be imported as `sns` +ICN001 [*] `seaborn` should be imported as `sns` + --> defaults.py:20:23 | 18 | import numpy as nmp 19 | import pandas as pdas 20 | import seaborn as sbrn - | ^^^^ ICN001 + | ^^^^ 21 | import tkinter as tkr 22 | import networkx as nxy | - = help: Alias `seaborn` to `sns` +help: Alias `seaborn` to `sns` ℹ Unsafe fix 17 17 | import matplotlib.pyplot as plot @@ -239,15 +250,16 @@ defaults.py:20:23: ICN001 [*] `seaborn` should be imported as `sns` 22 22 | import networkx as nxy 23 23 | -defaults.py:21:23: ICN001 [*] `tkinter` should be imported as `tk` +ICN001 [*] `tkinter` should be imported as `tk` + --> defaults.py:21:23 | 19 | import pandas as pdas 20 | import seaborn as sbrn 21 | import tkinter as tkr - | ^^^ ICN001 + | ^^^ 22 | import networkx as nxy | - = help: Alias `tkinter` to `tk` +help: Alias `tkinter` to `tk` ℹ Unsafe fix 18 18 | import numpy as nmp @@ -259,14 +271,15 @@ defaults.py:21:23: ICN001 [*] `tkinter` should be imported as `tk` 23 23 | 24 24 | -defaults.py:22:24: ICN001 [*] `networkx` should be imported as `nx` +ICN001 [*] `networkx` should be imported as `nx` + --> defaults.py:22:24 | 20 | import seaborn as sbrn 21 | import tkinter as tkr 22 | import networkx as nxy - | ^^^ ICN001 + | ^^^ | - = help: Alias `networkx` to `nx` +help: Alias `networkx` to `nx` ℹ Unsafe fix 19 19 | import pandas as pdas diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap index 3cafb07489..0b28e56513 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap @@ -1,89 +1,97 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs --- -from_imports.py:3:8: ICN001 `xml.dom.minidom` should be imported as `md` +ICN001 `xml.dom.minidom` should be imported as `md` + --> from_imports.py:3:8 | 1 | # Test absolute imports 2 | # Violation cases 3 | import xml.dom.minidom - | ^^^^^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^^^^^ 4 | import xml.dom.minidom as wrong 5 | from xml.dom import minidom as wrong | - = help: Alias `xml.dom.minidom` to `md` +help: Alias `xml.dom.minidom` to `md` -from_imports.py:4:27: ICN001 `xml.dom.minidom` should be imported as `md` +ICN001 `xml.dom.minidom` should be imported as `md` + --> from_imports.py:4:27 | 2 | # Violation cases 3 | import xml.dom.minidom 4 | import xml.dom.minidom as wrong - | ^^^^^ ICN001 + | ^^^^^ 5 | from xml.dom import minidom as wrong 6 | from xml.dom import minidom | - = help: Alias `xml.dom.minidom` to `md` +help: Alias `xml.dom.minidom` to `md` -from_imports.py:5:32: ICN001 `xml.dom.minidom` should be imported as `md` +ICN001 `xml.dom.minidom` should be imported as `md` + --> from_imports.py:5:32 | 3 | import xml.dom.minidom 4 | import xml.dom.minidom as wrong 5 | from xml.dom import minidom as wrong - | ^^^^^ ICN001 + | ^^^^^ 6 | from xml.dom import minidom 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. | - = help: Alias `xml.dom.minidom` to `md` +help: Alias `xml.dom.minidom` to `md` -from_imports.py:6:21: ICN001 `xml.dom.minidom` should be imported as `md` +ICN001 `xml.dom.minidom` should be imported as `md` + --> from_imports.py:6:21 | 4 | import xml.dom.minidom as wrong 5 | from xml.dom import minidom as wrong 6 | from xml.dom import minidom - | ^^^^^^^ ICN001 + | ^^^^^^^ 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. 8 | from xml.dom.minidom import parseString | - = help: Alias `xml.dom.minidom` to `md` +help: Alias `xml.dom.minidom` to `md` -from_imports.py:7:44: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` +ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` + --> from_imports.py:7:44 | 5 | from xml.dom import minidom as wrong 6 | from xml.dom import minidom 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. - | ^^^^^ ICN001 + | ^^^^^ 8 | from xml.dom.minidom import parseString 9 | from xml.dom.minidom import parse, parseString | - = help: Alias `xml.dom.minidom.parseString` to `pstr` +help: Alias `xml.dom.minidom.parseString` to `pstr` -from_imports.py:8:29: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` +ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` + --> from_imports.py:8:29 | 6 | from xml.dom import minidom 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. 8 | from xml.dom.minidom import parseString - | ^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^ 9 | from xml.dom.minidom import parse, parseString 10 | from xml.dom.minidom import parse as ps, parseString as wrong | - = help: Alias `xml.dom.minidom.parseString` to `pstr` +help: Alias `xml.dom.minidom.parseString` to `pstr` -from_imports.py:9:36: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` +ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` + --> from_imports.py:9:36 | 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. 8 | from xml.dom.minidom import parseString 9 | from xml.dom.minidom import parse, parseString - | ^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^ 10 | from xml.dom.minidom import parse as ps, parseString as wrong | - = help: Alias `xml.dom.minidom.parseString` to `pstr` +help: Alias `xml.dom.minidom.parseString` to `pstr` -from_imports.py:10:57: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` +ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` + --> from_imports.py:10:57 | 8 | from xml.dom.minidom import parseString 9 | from xml.dom.minidom import parse, parseString 10 | from xml.dom.minidom import parse as ps, parseString as wrong - | ^^^^^ ICN001 + | ^^^^^ 11 | 12 | # No ICN001 violations | - = help: Alias `xml.dom.minidom.parseString` to `pstr` +help: Alias `xml.dom.minidom.parseString` to `pstr` diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap index 16911e7f22..3e174c4e4c 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap @@ -1,108 +1,118 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs --- -override_default.py:3:8: ICN001 `altair` should be imported as `alt` +ICN001 `altair` should be imported as `alt` + --> override_default.py:3:8 | 1 | import math # not checked 2 | 3 | import altair # unconventional - | ^^^^^^ ICN001 + | ^^^^^^ 4 | import matplotlib.pyplot # unconventional 5 | import numpy # unconventional | - = help: Alias `altair` to `alt` +help: Alias `altair` to `alt` -override_default.py:4:8: ICN001 `matplotlib.pyplot` should be imported as `plt` +ICN001 `matplotlib.pyplot` should be imported as `plt` + --> override_default.py:4:8 | 3 | import altair # unconventional 4 | import matplotlib.pyplot # unconventional - | ^^^^^^^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^^^^^^^ 5 | import numpy # unconventional 6 | import pandas # unconventional | - = help: Alias `matplotlib.pyplot` to `plt` +help: Alias `matplotlib.pyplot` to `plt` -override_default.py:5:8: ICN001 `numpy` should be imported as `nmp` +ICN001 `numpy` should be imported as `nmp` + --> override_default.py:5:8 | 3 | import altair # unconventional 4 | import matplotlib.pyplot # unconventional 5 | import numpy # unconventional - | ^^^^^ ICN001 + | ^^^^^ 6 | import pandas # unconventional 7 | import seaborn # unconventional | - = help: Alias `numpy` to `nmp` +help: Alias `numpy` to `nmp` -override_default.py:6:8: ICN001 `pandas` should be imported as `pd` +ICN001 `pandas` should be imported as `pd` + --> override_default.py:6:8 | 4 | import matplotlib.pyplot # unconventional 5 | import numpy # unconventional 6 | import pandas # unconventional - | ^^^^^^ ICN001 + | ^^^^^^ 7 | import seaborn # unconventional | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` -override_default.py:7:8: ICN001 `seaborn` should be imported as `sns` +ICN001 `seaborn` should be imported as `sns` + --> override_default.py:7:8 | 5 | import numpy # unconventional 6 | import pandas # unconventional 7 | import seaborn # unconventional - | ^^^^^^^ ICN001 + | ^^^^^^^ 8 | 9 | import altair as altr # unconventional | - = help: Alias `seaborn` to `sns` +help: Alias `seaborn` to `sns` -override_default.py:9:18: ICN001 `altair` should be imported as `alt` +ICN001 `altair` should be imported as `alt` + --> override_default.py:9:18 | 7 | import seaborn # unconventional 8 | 9 | import altair as altr # unconventional - | ^^^^ ICN001 + | ^^^^ 10 | import matplotlib.pyplot as plot # unconventional 11 | import numpy as np # unconventional | - = help: Alias `altair` to `alt` +help: Alias `altair` to `alt` -override_default.py:10:29: ICN001 `matplotlib.pyplot` should be imported as `plt` +ICN001 `matplotlib.pyplot` should be imported as `plt` + --> override_default.py:10:29 | 9 | import altair as altr # unconventional 10 | import matplotlib.pyplot as plot # unconventional - | ^^^^ ICN001 + | ^^^^ 11 | import numpy as np # unconventional 12 | import pandas as pdas # unconventional | - = help: Alias `matplotlib.pyplot` to `plt` +help: Alias `matplotlib.pyplot` to `plt` -override_default.py:11:17: ICN001 `numpy` should be imported as `nmp` +ICN001 `numpy` should be imported as `nmp` + --> override_default.py:11:17 | 9 | import altair as altr # unconventional 10 | import matplotlib.pyplot as plot # unconventional 11 | import numpy as np # unconventional - | ^^ ICN001 + | ^^ 12 | import pandas as pdas # unconventional 13 | import seaborn as sbrn # unconventional | - = help: Alias `numpy` to `nmp` +help: Alias `numpy` to `nmp` -override_default.py:12:18: ICN001 `pandas` should be imported as `pd` +ICN001 `pandas` should be imported as `pd` + --> override_default.py:12:18 | 10 | import matplotlib.pyplot as plot # unconventional 11 | import numpy as np # unconventional 12 | import pandas as pdas # unconventional - | ^^^^ ICN001 + | ^^^^ 13 | import seaborn as sbrn # unconventional | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` -override_default.py:13:19: ICN001 `seaborn` should be imported as `sns` +ICN001 `seaborn` should be imported as `sns` + --> override_default.py:13:19 | 11 | import numpy as np # unconventional 12 | import pandas as pdas # unconventional 13 | import seaborn as sbrn # unconventional - | ^^^^ ICN001 + | ^^^^ 14 | 15 | import altair as alt # conventional | - = help: Alias `seaborn` to `sns` +help: Alias `seaborn` to `sns` diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap index daf24699fc..ea4395f436 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap @@ -1,86 +1,94 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs --- -remove_default.py:3:8: ICN001 `altair` should be imported as `alt` +ICN001 `altair` should be imported as `alt` + --> remove_default.py:3:8 | 1 | import math # not checked 2 | 3 | import altair # unconventional - | ^^^^^^ ICN001 + | ^^^^^^ 4 | import matplotlib.pyplot # unconventional 5 | import numpy # not checked | - = help: Alias `altair` to `alt` +help: Alias `altair` to `alt` -remove_default.py:4:8: ICN001 `matplotlib.pyplot` should be imported as `plt` +ICN001 `matplotlib.pyplot` should be imported as `plt` + --> remove_default.py:4:8 | 3 | import altair # unconventional 4 | import matplotlib.pyplot # unconventional - | ^^^^^^^^^^^^^^^^^ ICN001 + | ^^^^^^^^^^^^^^^^^ 5 | import numpy # not checked 6 | import pandas # unconventional | - = help: Alias `matplotlib.pyplot` to `plt` +help: Alias `matplotlib.pyplot` to `plt` -remove_default.py:6:8: ICN001 `pandas` should be imported as `pd` +ICN001 `pandas` should be imported as `pd` + --> remove_default.py:6:8 | 4 | import matplotlib.pyplot # unconventional 5 | import numpy # not checked 6 | import pandas # unconventional - | ^^^^^^ ICN001 + | ^^^^^^ 7 | import seaborn # unconventional | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` -remove_default.py:7:8: ICN001 `seaborn` should be imported as `sns` +ICN001 `seaborn` should be imported as `sns` + --> remove_default.py:7:8 | 5 | import numpy # not checked 6 | import pandas # unconventional 7 | import seaborn # unconventional - | ^^^^^^^ ICN001 + | ^^^^^^^ 8 | 9 | import altair as altr # unconventional | - = help: Alias `seaborn` to `sns` +help: Alias `seaborn` to `sns` -remove_default.py:9:18: ICN001 `altair` should be imported as `alt` +ICN001 `altair` should be imported as `alt` + --> remove_default.py:9:18 | 7 | import seaborn # unconventional 8 | 9 | import altair as altr # unconventional - | ^^^^ ICN001 + | ^^^^ 10 | import matplotlib.pyplot as plot # unconventional 11 | import numpy as nmp # not checked | - = help: Alias `altair` to `alt` +help: Alias `altair` to `alt` -remove_default.py:10:29: ICN001 `matplotlib.pyplot` should be imported as `plt` +ICN001 `matplotlib.pyplot` should be imported as `plt` + --> remove_default.py:10:29 | 9 | import altair as altr # unconventional 10 | import matplotlib.pyplot as plot # unconventional - | ^^^^ ICN001 + | ^^^^ 11 | import numpy as nmp # not checked 12 | import pandas as pdas # unconventional | - = help: Alias `matplotlib.pyplot` to `plt` +help: Alias `matplotlib.pyplot` to `plt` -remove_default.py:12:18: ICN001 `pandas` should be imported as `pd` +ICN001 `pandas` should be imported as `pd` + --> remove_default.py:12:18 | 10 | import matplotlib.pyplot as plot # unconventional 11 | import numpy as nmp # not checked 12 | import pandas as pdas # unconventional - | ^^^^ ICN001 + | ^^^^ 13 | import seaborn as sbrn # unconventional | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` -remove_default.py:13:19: ICN001 `seaborn` should be imported as `sns` +ICN001 `seaborn` should be imported as `sns` + --> remove_default.py:13:19 | 11 | import numpy as nmp # not checked 12 | import pandas as pdas # unconventional 13 | import seaborn as sbrn # unconventional - | ^^^^ ICN001 + | ^^^^ 14 | 15 | import altair as alt # conventional | - = help: Alias `seaborn` to `sns` +help: Alias `seaborn` to `sns` diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.snap index 0fa59ef67a..8d7e143a25 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__same_name.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- -same_name.py:10:41: ICN001 [*] `django.conf.settings` should be imported as `settings` +ICN001 [*] `django.conf.settings` should be imported as `settings` + --> same_name.py:10:41 | 9 | def unconventional_alias(): 10 | from django.conf import settings as s - | ^ ICN001 + | ^ | - = help: Alias `django.conf.settings` to `settings` +help: Alias `django.conf.settings` to `settings` ℹ Unsafe fix 7 7 | diff --git a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap index f2f4f18825..620a9275cc 100644 --- a/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs -snapshot_kind: text --- -tricky.py:7:16: ICN001 [*] `pandas` should be imported as `pd` +ICN001 [*] `pandas` should be imported as `pd` + --> tricky.py:7:16 | 5 | try: 6 | global pandas 7 | import pandas - | ^^^^^^ ICN001 + | ^^^^^^ 8 | except ImportError: 9 | return False | - = help: Alias `pandas` to `pd` +help: Alias `pandas` to `pd` ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap index c46ebbc1e5..dd0717c4e4 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG001.py:3:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers +LOG001 [*] Use `logging.getLogger()` to instantiate loggers + --> LOG001.py:3:1 | 1 | import logging 2 | 3 | logging.Logger(__name__) - | ^^^^^^^^^^^^^^ LOG001 + | ^^^^^^^^^^^^^^ 4 | logging.Logger() 5 | logging.getLogger(__name__) | - = help: Replace with `logging.getLogger()` +help: Replace with `logging.getLogger()` ℹ Unsafe fix 1 1 | import logging @@ -20,14 +21,15 @@ LOG001.py:3:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers 4 4 | logging.Logger() 5 5 | logging.getLogger(__name__) -LOG001.py:4:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers +LOG001 [*] Use `logging.getLogger()` to instantiate loggers + --> LOG001.py:4:1 | 3 | logging.Logger(__name__) 4 | logging.Logger() - | ^^^^^^^^^^^^^^ LOG001 + | ^^^^^^^^^^^^^^ 5 | logging.getLogger(__name__) | - = help: Replace with `logging.getLogger()` +help: Replace with `logging.getLogger()` ℹ Unsafe fix 1 1 | import logging diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap index 25a78dfdb0..d1ef1cb3af 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG002.py:11:11: LOG002 [*] Use `__name__` with `logging.getLogger()` +LOG002 [*] Use `__name__` with `logging.getLogger()` + --> LOG002.py:11:11 | 10 | # LOG002 11 | getLogger(__file__) - | ^^^^^^^^ LOG002 + | ^^^^^^^^ 12 | logging.getLogger(name=__file__) | - = help: Replace with `__name__` +help: Replace with `__name__` ℹ Unsafe fix 8 8 | logging.getLogger(name="custom") @@ -20,16 +21,17 @@ LOG002.py:11:11: LOG002 [*] Use `__name__` with `logging.getLogger()` 13 13 | 14 14 | logging.getLogger(__cached__) -LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()` +LOG002 [*] Use `__name__` with `logging.getLogger()` + --> LOG002.py:12:24 | 10 | # LOG002 11 | getLogger(__file__) 12 | logging.getLogger(name=__file__) - | ^^^^^^^^ LOG002 + | ^^^^^^^^ 13 | 14 | logging.getLogger(__cached__) | - = help: Replace with `__name__` +help: Replace with `__name__` ℹ Unsafe fix 9 9 | @@ -41,15 +43,16 @@ LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()` 14 14 | logging.getLogger(__cached__) 15 15 | getLogger(name=__cached__) -LOG002.py:14:19: LOG002 [*] Use `__name__` with `logging.getLogger()` +LOG002 [*] Use `__name__` with `logging.getLogger()` + --> LOG002.py:14:19 | 12 | logging.getLogger(name=__file__) 13 | 14 | logging.getLogger(__cached__) - | ^^^^^^^^^^ LOG002 + | ^^^^^^^^^^ 15 | getLogger(name=__cached__) | - = help: Replace with `__name__` +help: Replace with `__name__` ℹ Unsafe fix 11 11 | getLogger(__file__) @@ -61,13 +64,14 @@ LOG002.py:14:19: LOG002 [*] Use `__name__` with `logging.getLogger()` 16 16 | 17 17 | -LOG002.py:15:16: LOG002 [*] Use `__name__` with `logging.getLogger()` +LOG002 [*] Use `__name__` with `logging.getLogger()` + --> LOG002.py:15:16 | 14 | logging.getLogger(__cached__) 15 | getLogger(name=__cached__) - | ^^^^^^^^^^ LOG002 + | ^^^^^^^^^^ | - = help: Replace with `__name__` +help: Replace with `__name__` ℹ Unsafe fix 12 12 | logging.getLogger(name=__file__) diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG004_LOG004_0.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG004_LOG004_0.py.snap index 7a69b894f0..7bc2eb098a 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG004_LOG004_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG004_LOG004_0.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG004_0.py:13:1: LOG004 [*] `.exception()` call outside exception handlers +LOG004 [*] `.exception()` call outside exception handlers + --> LOG004_0.py:13:1 | 11 | ### Errors 12 | 13 | logging.exception("") - | ^^^^^^^^^^^^^^^^^^^^^ LOG004 + | ^^^^^^^^^^^^^^^^^^^^^ 14 | logger.exception("") 15 | exc("") | - = help: Replace with `.error()` +help: Replace with `.error()` ℹ Unsafe fix 10 10 | @@ -22,14 +23,15 @@ LOG004_0.py:13:1: LOG004 [*] `.exception()` call outside exception handlers 15 15 | exc("") 16 16 | -LOG004_0.py:14:1: LOG004 [*] `.exception()` call outside exception handlers +LOG004 [*] `.exception()` call outside exception handlers + --> LOG004_0.py:14:1 | 13 | logging.exception("") 14 | logger.exception("") - | ^^^^^^^^^^^^^^^^^^^^ LOG004 + | ^^^^^^^^^^^^^^^^^^^^ 15 | exc("") | - = help: Replace with `.error()` +help: Replace with `.error()` ℹ Unsafe fix 11 11 | ### Errors @@ -41,24 +43,26 @@ LOG004_0.py:14:1: LOG004 [*] `.exception()` call outside exception handlers 16 16 | 17 17 | -LOG004_0.py:15:1: LOG004 `.exception()` call outside exception handlers +LOG004 `.exception()` call outside exception handlers + --> LOG004_0.py:15:1 | 13 | logging.exception("") 14 | logger.exception("") 15 | exc("") - | ^^^^^^^ LOG004 + | ^^^^^^^ | - = help: Replace with `.error()` +help: Replace with `.error()` -LOG004_0.py:19:5: LOG004 [*] `.exception()` call outside exception handlers +LOG004 [*] `.exception()` call outside exception handlers + --> LOG004_0.py:19:5 | 18 | def _(): 19 | logging.exception("") - | ^^^^^^^^^^^^^^^^^^^^^ LOG004 + | ^^^^^^^^^^^^^^^^^^^^^ 20 | logger.exception("") 21 | exc("") | - = help: Replace with `.error()` +help: Replace with `.error()` ℹ Unsafe fix 16 16 | @@ -70,15 +74,16 @@ LOG004_0.py:19:5: LOG004 [*] `.exception()` call outside exception handlers 21 21 | exc("") 22 22 | -LOG004_0.py:20:5: LOG004 [*] `.exception()` call outside exception handlers +LOG004 [*] `.exception()` call outside exception handlers + --> LOG004_0.py:20:5 | 18 | def _(): 19 | logging.exception("") 20 | logger.exception("") - | ^^^^^^^^^^^^^^^^^^^^ LOG004 + | ^^^^^^^^^^^^^^^^^^^^ 21 | exc("") | - = help: Replace with `.error()` +help: Replace with `.error()` ℹ Unsafe fix 17 17 | @@ -90,25 +95,27 @@ LOG004_0.py:20:5: LOG004 [*] `.exception()` call outside exception handlers 22 22 | 23 23 | -LOG004_0.py:21:5: LOG004 `.exception()` call outside exception handlers +LOG004 `.exception()` call outside exception handlers + --> LOG004_0.py:21:5 | 19 | logging.exception("") 20 | logger.exception("") 21 | exc("") - | ^^^^^^^ LOG004 + | ^^^^^^^ | - = help: Replace with `.error()` +help: Replace with `.error()` -LOG004_0.py:28:9: LOG004 [*] `.exception()` call outside exception handlers +LOG004 [*] `.exception()` call outside exception handlers + --> LOG004_0.py:28:9 | 26 | except ...: 27 | def _(): 28 | logging.exception("") - | ^^^^^^^^^^^^^^^^^^^^^ LOG004 + | ^^^^^^^^^^^^^^^^^^^^^ 29 | logger.exception("") 30 | exc("") | - = help: Replace with `.error()` +help: Replace with `.error()` ℹ Unsafe fix 25 25 | ... @@ -120,15 +127,16 @@ LOG004_0.py:28:9: LOG004 [*] `.exception()` call outside exception handlers 30 30 | exc("") 31 31 | -LOG004_0.py:29:9: LOG004 [*] `.exception()` call outside exception handlers +LOG004 [*] `.exception()` call outside exception handlers + --> LOG004_0.py:29:9 | 27 | def _(): 28 | logging.exception("") 29 | logger.exception("") - | ^^^^^^^^^^^^^^^^^^^^ LOG004 + | ^^^^^^^^^^^^^^^^^^^^ 30 | exc("") | - = help: Replace with `.error()` +help: Replace with `.error()` ℹ Unsafe fix 26 26 | except ...: @@ -140,11 +148,12 @@ LOG004_0.py:29:9: LOG004 [*] `.exception()` call outside exception handlers 31 31 | 32 32 | -LOG004_0.py:30:9: LOG004 `.exception()` call outside exception handlers +LOG004 `.exception()` call outside exception handlers + --> LOG004_0.py:30:9 | 28 | logging.exception("") 29 | logger.exception("") 30 | exc("") - | ^^^^^^^ LOG004 + | ^^^^^^^ | - = help: Replace with `.error()` +help: Replace with `.error()` diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG004_LOG004_1.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG004_LOG004_1.py.snap index 988004f794..758e9a1eac 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG004_LOG004_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG004_LOG004_1.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG004_1.py:4:1: LOG004 [*] `.exception()` call outside exception handlers +LOG004 [*] `.exception()` call outside exception handlers + --> LOG004_1.py:4:1 | 4 | logger.exception("") - | ^^^^^^^^^^^^^^^^^^^^ LOG004 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `.error()` +help: Replace with `.error()` ℹ Unsafe fix 1 1 | _ = (logger := __import__("somewhere").logger) diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap index b98d744c20..ceac936c17 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap @@ -1,50 +1,55 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG007.py:6:1: LOG007 Use of `logging.exception` with falsy `exc_info` +LOG007 Use of `logging.exception` with falsy `exc_info` + --> LOG007.py:6:1 | 5 | logging.exception("foo") # OK 6 | logging.exception("foo", exc_info=False) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | logging.exception("foo", exc_info=[]) # LOG007 8 | logger.exception("foo") # OK | -LOG007.py:7:1: LOG007 Use of `logging.exception` with falsy `exc_info` +LOG007 Use of `logging.exception` with falsy `exc_info` + --> LOG007.py:7:1 | 5 | logging.exception("foo") # OK 6 | logging.exception("foo", exc_info=False) # LOG007 7 | logging.exception("foo", exc_info=[]) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | logger.exception("foo") # OK 9 | logger.exception("foo", exc_info=False) # LOG007 | -LOG007.py:9:1: LOG007 Use of `logging.exception` with falsy `exc_info` +LOG007 Use of `logging.exception` with falsy `exc_info` + --> LOG007.py:9:1 | 7 | logging.exception("foo", exc_info=[]) # LOG007 8 | logger.exception("foo") # OK 9 | logger.exception("foo", exc_info=False) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | logger.exception("foo", exc_info=[]) # LOG007 11 | logger.error("foo", exc_info=False) # OK | -LOG007.py:10:1: LOG007 Use of `logging.exception` with falsy `exc_info` +LOG007 Use of `logging.exception` with falsy `exc_info` + --> LOG007.py:10:1 | 8 | logger.exception("foo") # OK 9 | logger.exception("foo", exc_info=False) # LOG007 10 | logger.exception("foo", exc_info=[]) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | logger.error("foo", exc_info=False) # OK 12 | logger.info("foo", exc_info=False) # OK | -LOG007.py:17:1: LOG007 Use of `logging.exception` with falsy `exc_info` +LOG007 Use of `logging.exception` with falsy `exc_info` + --> LOG007.py:17:1 | 15 | from logging import exception 16 | 17 | exception("foo", exc_info=False) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | exception("foo", exc_info=True) # OK | diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap index 7d18aeb14e..0fcadb03cc 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG009.py:4:5: LOG009 [*] Use of undocumented `logging.WARN` constant +LOG009 [*] Use of undocumented `logging.WARN` constant + --> LOG009.py:4:5 | 2 | import logging 3 | 4 | logging.WARN # LOG009 - | ^^^^^^^^^^^^ LOG009 + | ^^^^^^^^^^^^ 5 | logging.WARNING # OK | - = help: Replace `logging.WARN` with `logging.WARNING` +help: Replace `logging.WARN` with `logging.WARNING` ℹ Safe fix 1 1 | def func(): @@ -21,15 +22,16 @@ LOG009.py:4:5: LOG009 [*] Use of undocumented `logging.WARN` constant 6 6 | 7 7 | -LOG009.py:11:5: LOG009 [*] Use of undocumented `logging.WARN` constant +LOG009 [*] Use of undocumented `logging.WARN` constant + --> LOG009.py:11:5 | 9 | from logging import WARN, WARNING 10 | 11 | WARN # LOG009 - | ^^^^ LOG009 + | ^^^^ 12 | WARNING # OK | - = help: Replace `logging.WARN` with `logging.WARNING` +help: Replace `logging.WARN` with `logging.WARNING` ℹ Safe fix 8 8 | def func(): diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG014_LOG014_0.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG014_LOG014_0.py.snap index 47e25d39b3..873b766eb9 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG014_LOG014_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG014_LOG014_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG014_0.py:12:18: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_0.py:12:18 | 10 | ### Errors 11 | 12 | logging.info("", exc_info=True) - | ^^^^^^^^^^^^^ LOG014 + | ^^^^^^^^^^^^^ 13 | logger.info("", exc_info=True) | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 9 9 | @@ -21,13 +22,14 @@ LOG014_0.py:12:18: LOG014 [*] `exc_info=` outside exception handlers 14 14 | 15 15 | -LOG014_0.py:13:17: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_0.py:13:17 | 12 | logging.info("", exc_info=True) 13 | logger.info("", exc_info=True) - | ^^^^^^^^^^^^^ LOG014 + | ^^^^^^^^^^^^^ | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 10 10 | ### Errors @@ -39,13 +41,14 @@ LOG014_0.py:13:17: LOG014 [*] `exc_info=` outside exception handlers 15 15 | 16 16 | logging.info("", exc_info=1) -LOG014_0.py:16:18: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_0.py:16:18 | 16 | logging.info("", exc_info=1) - | ^^^^^^^^^^ LOG014 + | ^^^^^^^^^^ 17 | logger.info("", exc_info=1) | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 13 13 | logger.info("", exc_info=True) @@ -57,13 +60,14 @@ LOG014_0.py:16:18: LOG014 [*] `exc_info=` outside exception handlers 18 18 | 19 19 | -LOG014_0.py:17:17: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_0.py:17:17 | 16 | logging.info("", exc_info=1) 17 | logger.info("", exc_info=1) - | ^^^^^^^^^^ LOG014 + | ^^^^^^^^^^ | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 14 14 | @@ -75,14 +79,15 @@ LOG014_0.py:17:17: LOG014 [*] `exc_info=` outside exception handlers 19 19 | 20 20 | def _(): -LOG014_0.py:21:22: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_0.py:21:22 | 20 | def _(): 21 | logging.info("", exc_info=True) - | ^^^^^^^^^^^^^ LOG014 + | ^^^^^^^^^^^^^ 22 | logger.info("", exc_info=True) | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 18 18 | @@ -94,14 +99,15 @@ LOG014_0.py:21:22: LOG014 [*] `exc_info=` outside exception handlers 23 23 | 24 24 | -LOG014_0.py:22:21: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_0.py:22:21 | 20 | def _(): 21 | logging.info("", exc_info=True) 22 | logger.info("", exc_info=True) - | ^^^^^^^^^^^^^ LOG014 + | ^^^^^^^^^^^^^ | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 19 19 | @@ -113,15 +119,16 @@ LOG014_0.py:22:21: LOG014 [*] `exc_info=` outside exception handlers 24 24 | 25 25 | try: -LOG014_0.py:29:26: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_0.py:29:26 | 27 | except ...: 28 | def _(): 29 | logging.info("", exc_info=True) - | ^^^^^^^^^^^^^ LOG014 + | ^^^^^^^^^^^^^ 30 | logger.info("", exc_info=True) | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 26 26 | ... @@ -133,14 +140,15 @@ LOG014_0.py:29:26: LOG014 [*] `exc_info=` outside exception handlers 31 31 | 32 32 | -LOG014_0.py:30:25: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_0.py:30:25 | 28 | def _(): 29 | logging.info("", exc_info=True) 30 | logger.info("", exc_info=True) - | ^^^^^^^^^^^^^ LOG014 + | ^^^^^^^^^^^^^ | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 27 27 | except ...: diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG014_LOG014_1.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG014_LOG014_1.py.snap index 0144629b87..95284f7c23 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG014_LOG014_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG014_LOG014_1.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG014_1.py:4:17: LOG014 [*] `exc_info=` outside exception handlers +LOG014 [*] `exc_info=` outside exception handlers + --> LOG014_1.py:4:17 | 4 | logger.info("", exc_info=True) - | ^^^^^^^^^^^^^ LOG014 + | ^^^^^^^^^^^^^ | - = help: Remove `exc_info=` +help: Remove `exc_info=` ℹ Unsafe fix 1 1 | _ = (logger := __import__("somewhere").logger) diff --git a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG015_LOG015.py.snap b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG015_LOG015.py.snap index 6c22e8d998..27a0e6d28e 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG015_LOG015.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG015_LOG015.py.snap @@ -1,170 +1,186 @@ --- source: crates/ruff_linter/src/rules/flake8_logging/mod.rs --- -LOG015.py:4:1: LOG015 `debug()` call on root logger +LOG015 `debug()` call on root logger + --> LOG015.py:4:1 | 2 | import logging 3 | 4 | logging.debug("Lorem") - | ^^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^^ 5 | logging.info("ipsum") 6 | logging.warn("dolor") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:5:1: LOG015 `info()` call on root logger +LOG015 `info()` call on root logger + --> LOG015.py:5:1 | 4 | logging.debug("Lorem") 5 | logging.info("ipsum") - | ^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | logging.warn("dolor") 7 | logging.warning("sit") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:6:1: LOG015 `warn()` call on root logger +LOG015 `warn()` call on root logger + --> LOG015.py:6:1 | 4 | logging.debug("Lorem") 5 | logging.info("ipsum") 6 | logging.warn("dolor") - | ^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^ 7 | logging.warning("sit") 8 | logging.error("amet") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:7:1: LOG015 `warning()` call on root logger +LOG015 `warning()` call on root logger + --> LOG015.py:7:1 | 5 | logging.info("ipsum") 6 | logging.warn("dolor") 7 | logging.warning("sit") - | ^^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^^ 8 | logging.error("amet") 9 | logging.critical("consectetur") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:8:1: LOG015 `error()` call on root logger +LOG015 `error()` call on root logger + --> LOG015.py:8:1 | 6 | logging.warn("dolor") 7 | logging.warning("sit") 8 | logging.error("amet") - | ^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^ 9 | logging.critical("consectetur") 10 | logging.log("adipiscing") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:9:1: LOG015 `critical()` call on root logger +LOG015 `critical()` call on root logger + --> LOG015.py:9:1 | 7 | logging.warning("sit") 8 | logging.error("amet") 9 | logging.critical("consectetur") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | logging.log("adipiscing") 11 | logging.exception("elit.") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:10:1: LOG015 `log()` call on root logger +LOG015 `log()` call on root logger + --> LOG015.py:10:1 | 8 | logging.error("amet") 9 | logging.critical("consectetur") 10 | logging.log("adipiscing") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | logging.exception("elit.") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:11:1: LOG015 `exception()` call on root logger +LOG015 `exception()` call on root logger + --> LOG015.py:11:1 | 9 | logging.critical("consectetur") 10 | logging.log("adipiscing") 11 | logging.exception("elit.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:26:1: LOG015 `debug()` call on root logger +LOG015 `debug()` call on root logger + --> LOG015.py:26:1 | 24 | ) 25 | 26 | debug("Lorem") - | ^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^ 27 | info("ipsum") 28 | warn("dolor") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:27:1: LOG015 `info()` call on root logger +LOG015 `info()` call on root logger + --> LOG015.py:27:1 | 26 | debug("Lorem") 27 | info("ipsum") - | ^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^ 28 | warn("dolor") 29 | warning("sit") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:28:1: LOG015 `warn()` call on root logger +LOG015 `warn()` call on root logger + --> LOG015.py:28:1 | 26 | debug("Lorem") 27 | info("ipsum") 28 | warn("dolor") - | ^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^ 29 | warning("sit") 30 | error("amet") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:29:1: LOG015 `warning()` call on root logger +LOG015 `warning()` call on root logger + --> LOG015.py:29:1 | 27 | info("ipsum") 28 | warn("dolor") 29 | warning("sit") - | ^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^ 30 | error("amet") 31 | critical("consectetur") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:30:1: LOG015 `error()` call on root logger +LOG015 `error()` call on root logger + --> LOG015.py:30:1 | 28 | warn("dolor") 29 | warning("sit") 30 | error("amet") - | ^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^ 31 | critical("consectetur") 32 | log("adipiscing") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:31:1: LOG015 `critical()` call on root logger +LOG015 `critical()` call on root logger + --> LOG015.py:31:1 | 29 | warning("sit") 30 | error("amet") 31 | critical("consectetur") - | ^^^^^^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^^^^^^ 32 | log("adipiscing") 33 | exception("elit.") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:32:1: LOG015 `log()` call on root logger +LOG015 `log()` call on root logger + --> LOG015.py:32:1 | 30 | error("amet") 31 | critical("consectetur") 32 | log("adipiscing") - | ^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^ 33 | exception("elit.") | - = help: Use own logger instead +help: Use own logger instead -LOG015.py:33:1: LOG015 `exception()` call on root logger +LOG015 `exception()` call on root logger + --> LOG015.py:33:1 | 31 | critical("consectetur") 32 | log("adipiscing") 33 | exception("elit.") - | ^^^^^^^^^^^^^^^^^^ LOG015 + | ^^^^^^^^^^^^^^^^^^ | - = help: Use own logger instead +help: Use own logger instead diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap index a872a12c9d..f12fb47ed8 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap @@ -1,144 +1,159 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs --- -G001.py:4:14: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:4:14 | 2 | import logging as foo 3 | 4 | logging.info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | logging.log(logging.INFO, "Hello {}".format("World!")) 6 | foo.info("Hello {}".format("World!")) | -G001.py:5:27: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:5:27 | 4 | logging.info("Hello {}".format("World!")) 5 | logging.log(logging.INFO, "Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | foo.info("Hello {}".format("World!")) 7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) | -G001.py:6:10: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:6:10 | 4 | logging.info("Hello {}".format("World!")) 5 | logging.log(logging.INFO, "Hello {}".format("World!")) 6 | foo.info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) 8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) | -G001.py:7:31: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:7:31 | 5 | logging.log(logging.INFO, "Hello {}".format("World!")) 6 | foo.info("Hello {}".format("World!")) 7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) 9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) | -G001.py:8:37: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:8:37 | 6 | foo.info("Hello {}".format("World!")) 7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) 8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) | -G001.py:9:17: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:9:17 | 7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) 8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) 9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # Flask support | -G001.py:16:31: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:16:31 | 14 | from flask import current_app as app 15 | 16 | flask.current_app.logger.info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | current_app.logger.info("Hello {}".format("World!")) 18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) | -G001.py:17:25: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:17:25 | 16 | flask.current_app.logger.info("Hello {}".format("World!")) 17 | current_app.logger.info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) | -G001.py:18:30: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:18:30 | 16 | flask.current_app.logger.info("Hello {}".format("World!")) 17 | current_app.logger.info("Hello {}".format("World!")) 18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | from logging import info, log | -G001.py:22:6: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:22:6 | 20 | from logging import info, log 21 | 22 | info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | log(logging.INFO, "Hello {}".format("World!")) 24 | info("Hello {}".format("World!")) | -G001.py:23:19: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:23:19 | 22 | info("Hello {}".format("World!")) 23 | log(logging.INFO, "Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | info("Hello {}".format("World!")) 25 | log(logging.INFO, msg="Hello {}".format("World!")) | -G001.py:24:6: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:24:6 | 22 | info("Hello {}".format("World!")) 23 | log(logging.INFO, "Hello {}".format("World!")) 24 | info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | log(logging.INFO, msg="Hello {}".format("World!")) 26 | log(level=logging.INFO, msg="Hello {}".format("World!")) | -G001.py:25:23: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:25:23 | 23 | log(logging.INFO, "Hello {}".format("World!")) 24 | info("Hello {}".format("World!")) 25 | log(logging.INFO, msg="Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | log(level=logging.INFO, msg="Hello {}".format("World!")) 27 | log(msg="Hello {}".format("World!"), level=logging.INFO) | -G001.py:26:29: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:26:29 | 24 | info("Hello {}".format("World!")) 25 | log(logging.INFO, msg="Hello {}".format("World!")) 26 | log(level=logging.INFO, msg="Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | log(msg="Hello {}".format("World!"), level=logging.INFO) | -G001.py:27:9: G001 Logging statement uses `str.format` +G001 Logging statement uses `str.format` + --> G001.py:27:9 | 25 | log(logging.INFO, msg="Hello {}".format("World!")) 26 | log(level=logging.INFO, msg="Hello {}".format("World!")) 27 | log(msg="Hello {}".format("World!"), level=logging.INFO) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap index ac9571bbc3..dab094f006 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap @@ -1,36 +1,40 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs --- -G002.py:3:14: G002 Logging statement uses `%` +G002 Logging statement uses `%` + --> G002.py:3:14 | 1 | import logging 2 | 3 | logging.info("Hello %s" % "World!") - | ^^^^^^^^^^^^^^^^^^^^^ G002 + | ^^^^^^^^^^^^^^^^^^^^^ 4 | logging.log(logging.INFO, "Hello %s" % "World!") | -G002.py:4:27: G002 Logging statement uses `%` +G002 Logging statement uses `%` + --> G002.py:4:27 | 3 | logging.info("Hello %s" % "World!") 4 | logging.log(logging.INFO, "Hello %s" % "World!") - | ^^^^^^^^^^^^^^^^^^^^^ G002 + | ^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | from logging import info, log | -G002.py:8:6: G002 Logging statement uses `%` +G002 Logging statement uses `%` + --> G002.py:8:6 | 6 | from logging import info, log 7 | 8 | info("Hello %s" % "World!") - | ^^^^^^^^^^^^^^^^^^^^^ G002 + | ^^^^^^^^^^^^^^^^^^^^^ 9 | log(logging.INFO, "Hello %s" % "World!") | -G002.py:9:19: G002 Logging statement uses `%` +G002 Logging statement uses `%` + --> G002.py:9:19 | 8 | info("Hello %s" % "World!") 9 | log(logging.INFO, "Hello %s" % "World!") - | ^^^^^^^^^^^^^^^^^^^^^ G002 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap index 431d5dbf32..5e17edd42c 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap @@ -1,36 +1,40 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs --- -G003.py:3:14: G003 Logging statement uses `+` +G003 Logging statement uses `+` + --> G003.py:3:14 | 1 | import logging 2 | 3 | logging.info("Hello" + " " + "World!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 4 | logging.log(logging.INFO, "Hello" + " " + "World!") | -G003.py:4:27: G003 Logging statement uses `+` +G003 Logging statement uses `+` + --> G003.py:4:27 | 3 | logging.info("Hello" + " " + "World!") 4 | logging.log(logging.INFO, "Hello" + " " + "World!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | from logging import info, log | -G003.py:8:6: G003 Logging statement uses `+` +G003 Logging statement uses `+` + --> G003.py:8:6 | 6 | from logging import info, log 7 | 8 | info("Hello" + " " + "World!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 9 | log(logging.INFO, "Hello" + " " + "World!") | -G003.py:9:19: G003 Logging statement uses `+` +G003 Logging statement uses `+` + --> G003.py:9:19 | 8 | info("Hello" + " " + "World!") 9 | log(logging.INFO, "Hello" + " " + "World!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap index bb51dc65f4..10a31007b8 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap @@ -1,57 +1,63 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs --- -G004.py:4:14: G004 Logging statement uses f-string +G004 Logging statement uses f-string + --> G004.py:4:14 | 3 | name = "world" 4 | logging.info(f"Hello {name}") - | ^^^^^^^^^^^^^^^ G004 + | ^^^^^^^^^^^^^^^ 5 | logging.log(logging.INFO, f"Hello {name}") | -G004.py:5:27: G004 Logging statement uses f-string +G004 Logging statement uses f-string + --> G004.py:5:27 | 3 | name = "world" 4 | logging.info(f"Hello {name}") 5 | logging.log(logging.INFO, f"Hello {name}") - | ^^^^^^^^^^^^^^^ G004 + | ^^^^^^^^^^^^^^^ 6 | 7 | _LOGGER = logging.getLogger() | -G004.py:8:14: G004 Logging statement uses f-string +G004 Logging statement uses f-string + --> G004.py:8:14 | 7 | _LOGGER = logging.getLogger() 8 | _LOGGER.info(f"{__name__}") - | ^^^^^^^^^^^^^ G004 + | ^^^^^^^^^^^^^ 9 | 10 | logging.getLogger().info(f"{name}") | -G004.py:10:26: G004 Logging statement uses f-string +G004 Logging statement uses f-string + --> G004.py:10:26 | 8 | _LOGGER.info(f"{__name__}") 9 | 10 | logging.getLogger().info(f"{name}") - | ^^^^^^^^^ G004 + | ^^^^^^^^^ 11 | 12 | from logging import info | -G004.py:14:6: G004 Logging statement uses f-string +G004 Logging statement uses f-string + --> G004.py:14:6 | 12 | from logging import info 13 | 14 | info(f"{name}") - | ^^^^^^^^^ G004 + | ^^^^^^^^^ 15 | info(f"{__name__}") | -G004.py:15:6: G004 Logging statement uses f-string +G004 Logging statement uses f-string + --> G004.py:15:6 | 14 | info(f"{name}") 15 | info(f"{__name__}") - | ^^^^^^^^^^^^^ G004 + | ^^^^^^^^^^^^^ 16 | 17 | # Don't trigger for t-strings | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap index f746582a16..af3076efbd 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs --- -G010.py:6:9: G010 [*] Logging statement uses `warn` instead of `warning` +G010 [*] Logging statement uses `warn` instead of `warning` + --> G010.py:6:9 | 4 | from logging_setup import logger 5 | 6 | logging.warn("Hello World!") - | ^^^^ G010 + | ^^^^ 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate 8 | logger.warn("Hello world!") | - = help: Convert to `warning` +help: Convert to `warning` ℹ Safe fix 3 3 | @@ -22,16 +23,17 @@ G010.py:6:9: G010 [*] Logging statement uses `warn` instead of `warning` 8 8 | logger.warn("Hello world!") 9 9 | -G010.py:8:8: G010 [*] Logging statement uses `warn` instead of `warning` +G010 [*] Logging statement uses `warn` instead of `warning` + --> G010.py:8:8 | 6 | logging.warn("Hello World!") 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate 8 | logger.warn("Hello world!") - | ^^^^ G010 + | ^^^^ 9 | 10 | logging . warn("Hello World!") | - = help: Convert to `warning` +help: Convert to `warning` ℹ Safe fix 5 5 | @@ -43,16 +45,17 @@ G010.py:8:8: G010 [*] Logging statement uses `warn` instead of `warning` 10 10 | logging . warn("Hello World!") 11 11 | -G010.py:10:11: G010 [*] Logging statement uses `warn` instead of `warning` +G010 [*] Logging statement uses `warn` instead of `warning` + --> G010.py:10:11 | 8 | logger.warn("Hello world!") 9 | 10 | logging . warn("Hello World!") - | ^^^^ G010 + | ^^^^ 11 | 12 | from logging import warn, warning, exception | - = help: Convert to `warning` +help: Convert to `warning` ℹ Safe fix 7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate @@ -64,15 +67,16 @@ G010.py:10:11: G010 [*] Logging statement uses `warn` instead of `warning` 12 12 | from logging import warn, warning, exception 13 13 | warn("foo") -G010.py:13:1: G010 [*] Logging statement uses `warn` instead of `warning` +G010 [*] Logging statement uses `warn` instead of `warning` + --> G010.py:13:1 | 12 | from logging import warn, warning, exception 13 | warn("foo") - | ^^^^ G010 + | ^^^^ 14 | warning("foo") 15 | exception("foo") | - = help: Convert to `warning` +help: Convert to `warning` ℹ Safe fix 10 10 | logging . warn("Hello World!") diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_1.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_1.py.snap index cc1f53e735..1114fd0326 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_1.py.snap @@ -1,23 +1,24 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- -G101_1.py:6:9: G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` +G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` + --> G101_1.py:6:9 | 4 | "Hello world!", 5 | extra={ 6 | "name": "foobar", - | ^^^^^^ G101 + | ^^^^^^ 7 | }, 8 | ) | -G101_1.py:15:9: G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` +G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` + --> G101_1.py:15:9 | 13 | "Hello world!", 14 | extra={ 15 | "name": "foobar", - | ^^^^^^ G101 + | ^^^^^^ 16 | }, 17 | ) | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_2.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_2.py.snap index e121d570ab..94f2821a55 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_2.py.snap @@ -1,23 +1,24 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs -snapshot_kind: text --- -G101_2.py:6:9: G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` +G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` + --> G101_2.py:6:9 | 4 | "Hello world!", 5 | extra=dict( 6 | name="foobar", - | ^^^^^^^^^^^^^ G101 + | ^^^^^^^^^^^^^ 7 | ), 8 | ) | -G101_2.py:15:9: G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` +G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` + --> G101_2.py:15:9 | 13 | "Hello world!", 14 | extra=dict( 15 | name="foobar", - | ^^^^^^^^^^^^^ G101 + | ^^^^^^^^^^^^^ 16 | ), 17 | ) | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap index 62ce1845b6..94bcf78a52 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap @@ -1,42 +1,46 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs --- -G201.py:8:13: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` +G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` + --> G201.py:8:13 | 6 | pass 7 | except: 8 | logging.error("Hello World", exc_info=True) - | ^^^^^ G201 + | ^^^^^ 9 | 10 | try: | -G201.py:13:13: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` +G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` + --> G201.py:13:13 | 11 | pass 12 | except: 13 | logging.error("Hello World", exc_info=sys.exc_info()) - | ^^^^^ G201 + | ^^^^^ 14 | 15 | # OK | -G201.py:28:5: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` +G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` + --> G201.py:28:5 | 26 | pass 27 | except: 28 | error("Hello World", exc_info=True) - | ^^^^^ G201 + | ^^^^^ 29 | 30 | try: | -G201.py:33:5: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` +G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` + --> G201.py:33:5 | 31 | pass 32 | except: 33 | error("Hello World", exc_info=sys.exc_info()) - | ^^^^^ G201 + | ^^^^^ 34 | 35 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap index fa50225852..54ee474f31 100644 --- a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap @@ -1,42 +1,46 @@ --- source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs --- -G202.py:8:38: G202 Logging statement has redundant `exc_info` +G202 Logging statement has redundant `exc_info` + --> G202.py:8:38 | 6 | pass 7 | except: 8 | logging.exception("Hello World", exc_info=True) - | ^^^^^^^^^^^^^ G202 + | ^^^^^^^^^^^^^ 9 | 10 | try: | -G202.py:13:38: G202 Logging statement has redundant `exc_info` +G202 Logging statement has redundant `exc_info` + --> G202.py:13:38 | 11 | pass 12 | except: 13 | logging.exception("Hello World", exc_info=sys.exc_info()) - | ^^^^^^^^^^^^^^^^^^^^^^^ G202 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # OK | -G202.py:28:30: G202 Logging statement has redundant `exc_info` +G202 Logging statement has redundant `exc_info` + --> G202.py:28:30 | 26 | pass 27 | except: 28 | exception("Hello World", exc_info=True) - | ^^^^^^^^^^^^^ G202 + | ^^^^^^^^^^^^^ 29 | 30 | try: | -G202.py:33:30: G202 Logging statement has redundant `exc_info` +G202 Logging statement has redundant `exc_info` + --> G202.py:33:30 | 31 | pass 32 | except: 33 | exception("Hello World", exc_info=sys.exc_info()) - | ^^^^^^^^^^^^^^^^^^^^^^^ G202 + | ^^^^^^^^^^^^^^^^^^^^^^^ 34 | 35 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_empty.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_empty.snap index 9daebc7a6d..9fb34cbec6 100644 --- a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_empty.snap +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_empty.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs -snapshot_kind: text --- -example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py` is part of an implicit namespace package. Add an `__init__.py`. +INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py` is part of an implicit namespace package. Add an `__init__.py`. +--> example.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_nonempty.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_nonempty.snap index 075a6bad1f..d2fd31b5bc 100644 --- a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_nonempty.snap +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_nonempty.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs -snapshot_kind: text --- -example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py` is part of an implicit namespace package. Add an `__init__.py`. +INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py` is part of an implicit namespace package. Add an `__init__.py`. +--> example.py:1:1 diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap index 8fcca36699..69d5e5041f 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs --- -PIE790.py:4:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:4:5 | 2 | """buzz""" 3 | 4 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 1 1 | class Foo: @@ -19,14 +20,15 @@ PIE790.py:4:5: PIE790 [*] Unnecessary `pass` statement 6 5 | 7 6 | if foo: -PIE790.py:9:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:9:5 | 7 | if foo: 8 | """foo""" 9 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 6 6 | @@ -37,14 +39,15 @@ PIE790.py:9:5: PIE790 [*] Unnecessary `pass` statement 11 10 | 12 11 | def multi_statement() -> None: -PIE790.py:14:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:14:5 | 12 | def multi_statement() -> None: 13 | """This is a function.""" 14 | pass; print("hello") - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 11 11 | @@ -56,14 +59,15 @@ PIE790.py:14:5: PIE790 [*] Unnecessary `pass` statement 16 16 | 17 17 | if foo: -PIE790.py:21:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:21:5 | 19 | else: 20 | """bar""" 21 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 18 18 | pass @@ -74,14 +78,15 @@ PIE790.py:21:5: PIE790 [*] Unnecessary `pass` statement 23 22 | 24 23 | while True: -PIE790.py:28:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:28:5 | 26 | else: 27 | """bar""" 28 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 25 25 | pass @@ -92,14 +97,15 @@ PIE790.py:28:5: PIE790 [*] Unnecessary `pass` statement 30 29 | 31 30 | for _ in range(10): -PIE790.py:35:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:35:5 | 33 | else: 34 | """bar""" 35 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 32 32 | pass @@ -110,14 +116,15 @@ PIE790.py:35:5: PIE790 [*] Unnecessary `pass` statement 37 36 | 38 37 | async for _ in range(10): -PIE790.py:42:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:42:5 | 40 | else: 41 | """bar""" 42 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 39 39 | pass @@ -128,14 +135,15 @@ PIE790.py:42:5: PIE790 [*] Unnecessary `pass` statement 44 43 | 45 44 | def foo() -> None: -PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:50:5 | 48 | """ 49 | 50 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 47 47 | buzz @@ -146,14 +154,15 @@ PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement 52 51 | 53 52 | async def foo(): -PIE790.py:58:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:58:5 | 56 | """ 57 | 58 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 55 55 | buzz @@ -164,16 +173,17 @@ PIE790.py:58:5: PIE790 [*] Unnecessary `pass` statement 60 59 | 61 60 | try: -PIE790.py:65:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:65:5 | 63 | buzz 64 | """ 65 | pass - | ^^^^ PIE790 + | ^^^^ 66 | except ValueError: 67 | pass | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 62 62 | """ @@ -184,14 +194,15 @@ PIE790.py:65:5: PIE790 [*] Unnecessary `pass` statement 67 66 | pass 68 67 | -PIE790.py:74:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:74:5 | 72 | except ValueError: 73 | """bar""" 74 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 71 71 | bar() @@ -202,16 +213,17 @@ PIE790.py:74:5: PIE790 [*] Unnecessary `pass` statement 76 75 | 77 76 | for _ in range(10): -PIE790.py:79:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:79:5 | 77 | for _ in range(10): 78 | """buzz""" 79 | pass - | ^^^^ PIE790 + | ^^^^ 80 | 81 | async for _ in range(10): | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 76 76 | @@ -222,16 +234,17 @@ PIE790.py:79:5: PIE790 [*] Unnecessary `pass` statement 81 80 | async for _ in range(10): 82 81 | """buzz""" -PIE790.py:83:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:83:5 | 81 | async for _ in range(10): 82 | """buzz""" 83 | pass - | ^^^^ PIE790 + | ^^^^ 84 | 85 | while cond: | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 80 80 | @@ -242,14 +255,15 @@ PIE790.py:83:5: PIE790 [*] Unnecessary `pass` statement 85 84 | while cond: 86 85 | """buzz""" -PIE790.py:87:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:87:5 | 85 | while cond: 86 | """buzz""" 87 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 84 84 | @@ -260,16 +274,17 @@ PIE790.py:87:5: PIE790 [*] Unnecessary `pass` statement 89 88 | 90 89 | with bar: -PIE790.py:92:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:92:5 | 90 | with bar: 91 | """buzz""" 92 | pass - | ^^^^ PIE790 + | ^^^^ 93 | 94 | async with bar: | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 89 89 | @@ -280,14 +295,15 @@ PIE790.py:92:5: PIE790 [*] Unnecessary `pass` statement 94 93 | async with bar: 95 94 | """buzz""" -PIE790.py:96:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:96:5 | 94 | async with bar: 95 | """buzz""" 96 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 93 93 | @@ -298,14 +314,15 @@ PIE790.py:96:5: PIE790 [*] Unnecessary `pass` statement 98 97 | 99 98 | def foo() -> None: -PIE790.py:101:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:101:5 | 99 | def foo() -> None: 100 | """buzz""" 101 | pass # bar - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 98 98 | @@ -317,14 +334,15 @@ PIE790.py:101:5: PIE790 [*] Unnecessary `pass` statement 103 103 | 104 104 | class Foo: -PIE790.py:130:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:130:5 | 128 | def foo(): 129 | print("foo") 130 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 127 127 | @@ -335,14 +353,15 @@ PIE790.py:130:5: PIE790 [*] Unnecessary `pass` statement 132 131 | 133 132 | def foo(): -PIE790.py:136:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:136:5 | 134 | """A docstring.""" 135 | print("foo") 136 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 133 133 | def foo(): @@ -353,14 +372,15 @@ PIE790.py:136:5: PIE790 [*] Unnecessary `pass` statement 138 137 | 139 138 | for i in range(10): -PIE790.py:140:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:140:5 | 139 | for i in range(10): 140 | pass - | ^^^^ PIE790 + | ^^^^ 141 | pass | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 138 138 | @@ -371,16 +391,17 @@ PIE790.py:140:5: PIE790 [*] Unnecessary `pass` statement 143 142 | for i in range(10): 144 143 | pass -PIE790.py:141:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:141:5 | 139 | for i in range(10): 140 | pass 141 | pass - | ^^^^ PIE790 + | ^^^^ 142 | 143 | for i in range(10): | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 138 138 | @@ -391,15 +412,16 @@ PIE790.py:141:5: PIE790 [*] Unnecessary `pass` statement 143 142 | for i in range(10): 144 143 | pass -PIE790.py:144:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:144:5 | 143 | for i in range(10): 144 | pass - | ^^^^ PIE790 + | ^^^^ 145 | 146 | pass | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 141 141 | pass @@ -410,16 +432,17 @@ PIE790.py:144:5: PIE790 [*] Unnecessary `pass` statement 146 145 | pass 147 146 | -PIE790.py:146:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:146:5 | 144 | pass 145 | 146 | pass - | ^^^^ PIE790 + | ^^^^ 147 | 148 | for i in range(10): | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 143 143 | for i in range(10): @@ -430,14 +453,15 @@ PIE790.py:146:5: PIE790 [*] Unnecessary `pass` statement 148 147 | for i in range(10): 149 148 | pass # comment -PIE790.py:149:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:149:5 | 148 | for i in range(10): 149 | pass # comment - | ^^^^ PIE790 + | ^^^^ 150 | pass | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 146 146 | pass @@ -449,14 +473,15 @@ PIE790.py:149:5: PIE790 [*] Unnecessary `pass` statement 151 151 | 152 152 | -PIE790.py:150:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:150:5 | 148 | for i in range(10): 149 | pass # comment 150 | pass - | ^^^^ PIE790 + | ^^^^ | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 147 147 | @@ -467,14 +492,15 @@ PIE790.py:150:5: PIE790 [*] Unnecessary `pass` statement 152 151 | 153 152 | def foo(): -PIE790.py:155:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:155:5 | 153 | def foo(): 154 | print("foo") 155 | ... - | ^^^ PIE790 + | ^^^ | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 152 152 | @@ -485,14 +511,15 @@ PIE790.py:155:5: PIE790 [*] Unnecessary `...` literal 157 156 | 158 157 | def foo(): -PIE790.py:161:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:161:5 | 159 | """A docstring.""" 160 | print("foo") 161 | ... - | ^^^ PIE790 + | ^^^ | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 158 158 | def foo(): @@ -503,14 +530,15 @@ PIE790.py:161:5: PIE790 [*] Unnecessary `...` literal 163 162 | 164 163 | for i in range(10): -PIE790.py:165:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:165:5 | 164 | for i in range(10): 165 | ... - | ^^^ PIE790 + | ^^^ 166 | ... | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 163 163 | @@ -521,16 +549,17 @@ PIE790.py:165:5: PIE790 [*] Unnecessary `...` literal 168 167 | for i in range(10): 169 168 | ... -PIE790.py:166:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:166:5 | 164 | for i in range(10): 165 | ... 166 | ... - | ^^^ PIE790 + | ^^^ 167 | 168 | for i in range(10): | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 163 163 | @@ -541,15 +570,16 @@ PIE790.py:166:5: PIE790 [*] Unnecessary `...` literal 168 167 | for i in range(10): 169 168 | ... -PIE790.py:169:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:169:5 | 168 | for i in range(10): 169 | ... - | ^^^ PIE790 + | ^^^ 170 | 171 | ... | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 166 166 | ... @@ -560,16 +590,17 @@ PIE790.py:169:5: PIE790 [*] Unnecessary `...` literal 171 170 | ... 172 171 | -PIE790.py:171:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:171:5 | 169 | ... 170 | 171 | ... - | ^^^ PIE790 + | ^^^ 172 | 173 | for i in range(10): | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 168 168 | for i in range(10): @@ -580,14 +611,15 @@ PIE790.py:171:5: PIE790 [*] Unnecessary `...` literal 173 172 | for i in range(10): 174 173 | ... # comment -PIE790.py:174:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:174:5 | 173 | for i in range(10): 174 | ... # comment - | ^^^ PIE790 + | ^^^ 175 | ... | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 171 171 | ... @@ -599,16 +631,17 @@ PIE790.py:174:5: PIE790 [*] Unnecessary `...` literal 176 176 | 177 177 | for i in range(10): -PIE790.py:175:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:175:5 | 173 | for i in range(10): 174 | ... # comment 175 | ... - | ^^^ PIE790 + | ^^^ 176 | 177 | for i in range(10): | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 172 172 | @@ -619,14 +652,15 @@ PIE790.py:175:5: PIE790 [*] Unnecessary `...` literal 177 176 | for i in range(10): 178 177 | ... -PIE790.py:178:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:178:5 | 177 | for i in range(10): 178 | ... - | ^^^ PIE790 + | ^^^ 179 | pass | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 175 175 | ... @@ -637,16 +671,17 @@ PIE790.py:178:5: PIE790 [*] Unnecessary `...` literal 180 179 | 181 180 | from typing import Protocol -PIE790.py:179:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:179:5 | 177 | for i in range(10): 178 | ... 179 | pass - | ^^^^ PIE790 + | ^^^^ 180 | 181 | from typing import Protocol | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 176 176 | @@ -657,14 +692,15 @@ PIE790.py:179:5: PIE790 [*] Unnecessary `pass` statement 181 180 | from typing import Protocol 182 181 | -PIE790.py:209:9: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:209:9 | 207 | def stub(self) -> str: 208 | """Docstring""" 209 | ... - | ^^^ PIE790 + | ^^^ | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 206 206 | @@ -675,16 +711,17 @@ PIE790.py:209:9: PIE790 [*] Unnecessary `...` literal 211 210 | 212 211 | class Repro(Protocol[int]): -PIE790.py:241:5: PIE790 [*] Unnecessary `pass` statement +PIE790 [*] Unnecessary `pass` statement + --> PIE790.py:241:5 | 239 | # https://github.com/astral-sh/ruff/issues/12616 240 | class PotentialDocstring1: 241 | pass - | ^^^^ PIE790 + | ^^^^ 242 | """ 243 | Lorem ipsum dolor sit amet. | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Unsafe fix 238 238 | @@ -695,14 +732,15 @@ PIE790.py:241:5: PIE790 [*] Unnecessary `pass` statement 243 242 | Lorem ipsum dolor sit amet. 244 243 | """ -PIE790.py:248:5: PIE790 [*] Unnecessary `...` literal +PIE790 [*] Unnecessary `...` literal + --> PIE790.py:248:5 | 247 | class PotentialDocstring2: 248 | ... - | ^^^ PIE790 + | ^^^ 249 | 'Lorem ipsum dolor sit amet.' | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Unsafe fix 245 245 | diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap index 3e6e4df3d5..0988b138f7 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs --- -PIE794.py:4:5: PIE794 [*] Class field `name` is defined multiple times +PIE794 [*] Class field `name` is defined multiple times + --> PIE794.py:4:5 | 2 | name = StringField() 3 | # .... 4 | name = StringField() # PIE794 - | ^^^^^^^^^^^^^^^^^^^^ PIE794 + | ^^^^^^^^^^^^^^^^^^^^ 5 | 6 | def remove(self) -> None: | - = help: Remove duplicate field definition for `name` +help: Remove duplicate field definition for `name` ℹ Unsafe fix 1 1 | class Foo(BaseModel): @@ -21,16 +22,17 @@ PIE794.py:4:5: PIE794 [*] Class field `name` is defined multiple times 6 5 | def remove(self) -> None: 7 6 | ... -PIE794.py:13:5: PIE794 [*] Class field `name` is defined multiple times +PIE794 [*] Class field `name` is defined multiple times + --> PIE794.py:13:5 | 11 | name: str = StringField() 12 | # .... 13 | name = StringField() # PIE794 - | ^^^^^^^^^^^^^^^^^^^^ PIE794 + | ^^^^^^^^^^^^^^^^^^^^ 14 | 15 | def foo(self) -> None: | - = help: Remove duplicate field definition for `name` +help: Remove duplicate field definition for `name` ℹ Unsafe fix 10 10 | class Foo(BaseModel): @@ -41,14 +43,15 @@ PIE794.py:13:5: PIE794 [*] Class field `name` is defined multiple times 15 14 | def foo(self) -> None: 16 15 | ... -PIE794.py:23:5: PIE794 [*] Class field `bar` is defined multiple times +PIE794 [*] Class field `bar` is defined multiple times + --> PIE794.py:23:5 | 21 | foo: bool = BooleanField() 22 | # ... 23 | bar = StringField() # PIE794 - | ^^^^^^^^^^^^^^^^^^^ PIE794 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Remove duplicate field definition for `bar` +help: Remove duplicate field definition for `bar` ℹ Unsafe fix 20 20 | bar: str = StringField() @@ -59,14 +62,15 @@ PIE794.py:23:5: PIE794 [*] Class field `bar` is defined multiple times 25 24 | 26 25 | class User(BaseModel): -PIE794.py:40:5: PIE794 [*] Class field `bar` is defined multiple times +PIE794 [*] Class field `bar` is defined multiple times + --> PIE794.py:40:5 | 38 | foo: bool = BooleanField() 39 | # ... 40 | bar = StringField() # PIE794 - | ^^^^^^^^^^^^^^^^^^^ PIE794 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Remove duplicate field definition for `bar` +help: Remove duplicate field definition for `bar` ℹ Unsafe fix 37 37 | bar: str = StringField() @@ -77,14 +81,15 @@ PIE794.py:40:5: PIE794 [*] Class field `bar` is defined multiple times 42 41 | 43 42 | class Person: -PIE794.py:46:5: PIE794 [*] Class field `name` is defined multiple times +PIE794 [*] Class field `name` is defined multiple times + --> PIE794.py:46:5 | 44 | name = "Foo" 45 | name = name + " Bar" 46 | name = "Bar" # PIE794 - | ^^^^^^^^^^^^ PIE794 + | ^^^^^^^^^^^^ | - = help: Remove duplicate field definition for `name` +help: Remove duplicate field definition for `name` ℹ Unsafe fix 43 43 | class Person: @@ -95,14 +100,15 @@ PIE794.py:46:5: PIE794 [*] Class field `name` is defined multiple times 48 47 | 49 48 | class Person: -PIE794.py:52:5: PIE794 [*] Class field `name` is defined multiple times +PIE794 [*] Class field `name` is defined multiple times + --> PIE794.py:52:5 | 50 | name: str = "Foo" 51 | name: str = name + " Bar" 52 | name: str = "Bar" # PIE794 - | ^^^^^^^^^^^^^^^^^ PIE794 + | ^^^^^^^^^^^^^^^^^ | - = help: Remove duplicate field definition for `name` +help: Remove duplicate field definition for `name` ℹ Unsafe fix 49 49 | class Person: diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE796_PIE796.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE796_PIE796.py.snap index cad6da6d9d..e164e69c5c 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE796_PIE796.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE796_PIE796.py.snap @@ -1,93 +1,103 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs -snapshot_kind: text --- -PIE796.py:8:5: PIE796 Enum contains duplicate value: `"B"` +PIE796 Enum contains duplicate value: `"B"` + --> PIE796.py:8:5 | 6 | A = "A" 7 | B = "B" 8 | C = "B" # PIE796 - | ^^^^^^^ PIE796 + | ^^^^^^^ | -PIE796.py:14:5: PIE796 Enum contains duplicate value: `2` +PIE796 Enum contains duplicate value: `2` + --> PIE796.py:14:5 | 12 | A = 1 13 | B = 2 14 | C = 2 # PIE796 - | ^^^^^ PIE796 + | ^^^^^ | -PIE796.py:20:5: PIE796 Enum contains duplicate value: `"2"` +PIE796 Enum contains duplicate value: `"2"` + --> PIE796.py:20:5 | 18 | A = "1" 19 | B = "2" 20 | C = "2" # PIE796 - | ^^^^^^^ PIE796 + | ^^^^^^^ | -PIE796.py:26:5: PIE796 Enum contains duplicate value: `2.5` +PIE796 Enum contains duplicate value: `2.5` + --> PIE796.py:26:5 | 24 | A = 1.0 25 | B = 2.5 26 | C = 2.5 # PIE796 - | ^^^^^^^ PIE796 + | ^^^^^^^ | -PIE796.py:33:5: PIE796 Enum contains duplicate value: `False` +PIE796 Enum contains duplicate value: `False` + --> PIE796.py:33:5 | 31 | B = True 32 | C = False 33 | D = False # PIE796 - | ^^^^^^^^^ PIE796 + | ^^^^^^^^^ | -PIE796.py:40:5: PIE796 Enum contains duplicate value: `None` +PIE796 Enum contains duplicate value: `None` + --> PIE796.py:40:5 | 38 | B = 2 39 | C = None 40 | D = None # PIE796 - | ^^^^^^^^ PIE796 + | ^^^^^^^^ | -PIE796.py:54:5: PIE796 Enum contains duplicate value: `2` +PIE796 Enum contains duplicate value: `2` + --> PIE796.py:54:5 | 52 | A = 1 53 | B = 2 54 | C = 2 # PIE796 - | ^^^^^ PIE796 + | ^^^^^ | -PIE796.py:71:5: PIE796 Enum contains duplicate value: `...` +PIE796 Enum contains duplicate value: `...` + --> PIE796.py:71:5 | 69 | class FakeEnum10(enum.Enum): 70 | A = ... 71 | B = ... # PIE796 - | ^^^^^^^ PIE796 + | ^^^^^^^ 72 | C = ... # PIE796 | -PIE796.py:72:5: PIE796 Enum contains duplicate value: `...` +PIE796 Enum contains duplicate value: `...` + --> PIE796.py:72:5 | 70 | A = ... 71 | B = ... # PIE796 72 | C = ... # PIE796 - | ^^^^^^^ PIE796 + | ^^^^^^^ | -PIE796.py:79:5: PIE796 Enum contains duplicate value: `cast(SomeType, ...)` +PIE796 Enum contains duplicate value: `cast(SomeType, ...)` + --> PIE796.py:79:5 | 77 | class FakeEnum11(enum.Enum): 78 | A = cast(SomeType, ...) 79 | B = cast(SomeType, ...) # PIE796 - | ^^^^^^^^^^^^^^^^^^^^^^^ PIE796 + | ^^^^^^^^^^^^^^^^^^^^^^^ 80 | C = cast(SomeType, ...) # PIE796 | -PIE796.py:80:5: PIE796 Enum contains duplicate value: `cast(SomeType, ...)` +PIE796 Enum contains duplicate value: `cast(SomeType, ...)` + --> PIE796.py:80:5 | 78 | A = cast(SomeType, ...) 79 | B = cast(SomeType, ...) # PIE796 80 | C = cast(SomeType, ...) # PIE796 - | ^^^^^^^^^^^^^^^^^^^^^^^ PIE796 + | ^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap index 6eb78b21f6..9d522c0a7c 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs --- -PIE800.py:1:14: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:1:14 | 1 | {"foo": 1, **{"bar": 1}} # PIE800 - | ^^^^^^^^^^ PIE800 + | ^^^^^^^^^^ 2 | 3 | {**{"bar": 10}, "a": "b"} # PIE800 | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 1 |-{"foo": 1, **{"bar": 1}} # PIE800 @@ -17,16 +18,17 @@ PIE800.py:1:14: PIE800 [*] Unnecessary spread `**` 3 3 | {**{"bar": 10}, "a": "b"} # PIE800 4 4 | -PIE800.py:3:4: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:3:4 | 1 | {"foo": 1, **{"bar": 1}} # PIE800 2 | 3 | {**{"bar": 10}, "a": "b"} # PIE800 - | ^^^^^^^^^^^ PIE800 + | ^^^^^^^^^^^ 4 | 5 | foo({**foo, **{"bar": True}}) # PIE800 | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 1 1 | {"foo": 1, **{"bar": 1}} # PIE800 @@ -37,16 +39,17 @@ PIE800.py:3:4: PIE800 [*] Unnecessary spread `**` 5 5 | foo({**foo, **{"bar": True}}) # PIE800 6 6 | -PIE800.py:5:15: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:5:15 | 3 | {**{"bar": 10}, "a": "b"} # PIE800 4 | 5 | foo({**foo, **{"bar": True}}) # PIE800 - | ^^^^^^^^^^^^^ PIE800 + | ^^^^^^^^^^^^^ 6 | 7 | {**foo, **{"bar": 10}} # PIE800 | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 2 2 | @@ -58,16 +61,17 @@ PIE800.py:5:15: PIE800 [*] Unnecessary spread `**` 7 7 | {**foo, **{"bar": 10}} # PIE800 8 8 | -PIE800.py:7:11: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:7:11 | 5 | foo({**foo, **{"bar": True}}) # PIE800 6 | 7 | {**foo, **{"bar": 10}} # PIE800 - | ^^^^^^^^^^^ PIE800 + | ^^^^^^^^^^^ 8 | 9 | { # PIE800 | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 4 4 | @@ -79,7 +83,8 @@ PIE800.py:7:11: PIE800 [*] Unnecessary spread `**` 9 9 | { # PIE800 10 10 | "a": "b", -PIE800.py:12:7: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:12:7 | 10 | "a": "b", 11 | # Preserve @@ -89,10 +94,10 @@ PIE800.py:12:7: PIE800 [*] Unnecessary spread `**` 14 | | "bar": 10, # the 15 | | # comments 16 | | }, - | |_____^ PIE800 + | |_____^ 17 | } | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 9 9 | { # PIE800 @@ -110,16 +115,17 @@ PIE800.py:12:7: PIE800 [*] Unnecessary spread `**` 18 18 | 19 19 | {**foo, **buzz, **{bar: 10}} # PIE800 -PIE800.py:19:19: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:19:19 | 17 | } 18 | 19 | {**foo, **buzz, **{bar: 10}} # PIE800 - | ^^^^^^^^^ PIE800 + | ^^^^^^^^^ 20 | 21 | # https://github.com/astral-sh/ruff/issues/15366 | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 16 16 | }, @@ -131,15 +137,16 @@ PIE800.py:19:19: PIE800 [*] Unnecessary spread `**` 21 21 | # https://github.com/astral-sh/ruff/issues/15366 22 22 | { -PIE800.py:24:8: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:24:8 | 22 | { 23 | "data": [], 24 | **({"count": 1 if include_count else {}}), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE800 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | } | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 21 21 | # https://github.com/astral-sh/ruff/issues/15366 @@ -151,16 +158,17 @@ PIE800.py:24:8: PIE800 [*] Unnecessary spread `**` 26 26 | 27 27 | { -PIE800.py:30:9: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:30:9 | 28 | "data": [], 29 | **( # Comment 30 | / { # Comment 31 | | "count": 1 if include_count else {}}), - | |________________________________________________^ PIE800 + | |________________________________________________^ 32 | } | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 26 26 | @@ -176,16 +184,17 @@ PIE800.py:30:9: PIE800 [*] Unnecessary spread `**` 33 33 | 34 34 | { -PIE800.py:37:9: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:37:9 | 35 | "data": [], 36 | **( 37 | / { 38 | | "count": (a := 1),}), - | |_______________________________^ PIE800 + | |_______________________________^ 39 | } | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 33 33 | @@ -201,18 +210,19 @@ PIE800.py:37:9: PIE800 [*] Unnecessary spread `**` 40 40 | 41 41 | { -PIE800.py:44:9: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:44:9 | 42 | "data": [], 43 | **( 44 | / { 45 | | "count": (a := 1) 46 | | } - | |_____________^ PIE800 + | |_____________^ 47 | ) 48 | , | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 40 40 | @@ -231,18 +241,19 @@ PIE800.py:44:9: PIE800 [*] Unnecessary spread `**` 49 49 | } 50 50 | -PIE800.py:54:9: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:54:9 | 52 | "data": [], 53 | **( 54 | / { 55 | | "count": (a := 1), # Comment 56 | | } # Comment - | |_____________^ PIE800 + | |_____________^ 57 | ) # Comment 58 | , | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 50 50 | @@ -262,18 +273,19 @@ PIE800.py:54:9: PIE800 [*] Unnecessary spread `**` 59 59 | } 60 60 | -PIE800.py:65:1: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:65:1 | 63 | **( # Comment 64 | ( # Comment 65 | / { # Comment 66 | | "count": (a := 1), # Comment 67 | | } # Comment - | |_________^ PIE800 + | |_________^ 68 | ) 69 | ) # Comment | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 60 60 | @@ -297,18 +309,19 @@ PIE800.py:65:1: PIE800 [*] Unnecessary spread `**` 71 71 | }) 72 72 | -PIE800.py:77:9: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:77:9 | 75 | ** # Foo 76 | ( # Comment 77 | / { "a": b, 78 | | # Comment 79 | | } - | |___________^ PIE800 + | |___________^ 80 | ) , 81 | c: 9, | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 72 72 | @@ -329,14 +342,15 @@ PIE800.py:77:9: PIE800 [*] Unnecessary spread `**` 82 82 | } 83 83 | -PIE800.py:86:13: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:86:13 | 85 | # https://github.com/astral-sh/ruff/issues/15997 86 | {"a": [], **{},} - | ^^ PIE800 + | ^^ 87 | {"a": [], **({}),} | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 83 83 | @@ -348,16 +362,17 @@ PIE800.py:86:13: PIE800 [*] Unnecessary spread `**` 88 88 | 89 89 | {"a": [], **{}, 6: 3} -PIE800.py:87:14: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:87:14 | 85 | # https://github.com/astral-sh/ruff/issues/15997 86 | {"a": [], **{},} 87 | {"a": [], **({}),} - | ^^ PIE800 + | ^^ 88 | 89 | {"a": [], **{}, 6: 3} | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 84 84 | @@ -369,15 +384,16 @@ PIE800.py:87:14: PIE800 [*] Unnecessary spread `**` 89 89 | {"a": [], **{}, 6: 3} 90 90 | {"a": [], **({}), 6: 3} -PIE800.py:89:13: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:89:13 | 87 | {"a": [], **({}),} 88 | 89 | {"a": [], **{}, 6: 3} - | ^^ PIE800 + | ^^ 90 | {"a": [], **({}), 6: 3} | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 86 86 | {"a": [], **{},} @@ -389,15 +405,16 @@ PIE800.py:89:13: PIE800 [*] Unnecessary spread `**` 91 91 | 92 92 | {"a": [], **{ -PIE800.py:90:14: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:90:14 | 89 | {"a": [], **{}, 6: 3} 90 | {"a": [], **({}), 6: 3} - | ^^ PIE800 + | ^^ 91 | 92 | {"a": [], **{ | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 87 87 | {"a": [], **({}),} @@ -409,7 +426,8 @@ PIE800.py:90:14: PIE800 [*] Unnecessary spread `**` 92 92 | {"a": [], **{ 93 93 | # Comment -PIE800.py:92:13: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:92:13 | 90 | {"a": [], **({}), 6: 3} 91 | @@ -417,11 +435,11 @@ PIE800.py:92:13: PIE800 [*] Unnecessary spread `**` | _____________^ 93 | | # Comment 94 | | }, 6: 3} - | |_^ PIE800 + | |_^ 95 | {"a": [], **({ 96 | # Comment | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 89 89 | {"a": [], **{}, 6: 3} @@ -436,7 +454,8 @@ PIE800.py:92:13: PIE800 [*] Unnecessary spread `**` 96 96 | # Comment 97 97 | }), 6: 3} -PIE800.py:95:14: PIE800 [*] Unnecessary spread `**` +PIE800 [*] Unnecessary spread `**` + --> PIE800.py:95:14 | 93 | # Comment 94 | }, 6: 3} @@ -444,9 +463,9 @@ PIE800.py:95:14: PIE800 [*] Unnecessary spread `**` | ______________^ 96 | | # Comment 97 | | }), 6: 3} - | |_^ PIE800 + | |_^ | - = help: Remove unnecessary dict +help: Remove unnecessary dict ℹ Safe fix 92 92 | {"a": [], **{ diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap index f06e91e71a..6b0e88fd27 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs --- -PIE804.py:1:5: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:1:5 | 1 | foo(**{"bar": True}) # PIE804 - | ^^^^^^^^^^^^^^^ PIE804 + | ^^^^^^^^^^^^^^^ 2 | 3 | foo(**{"r2d2": True}) # PIE804 | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 1 |-foo(**{"bar": True}) # PIE804 @@ -17,16 +18,17 @@ PIE804.py:1:5: PIE804 [*] Unnecessary `dict` kwargs 3 3 | foo(**{"r2d2": True}) # PIE804 4 4 | -PIE804.py:3:5: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:3:5 | 1 | foo(**{"bar": True}) # PIE804 2 | 3 | foo(**{"r2d2": True}) # PIE804 - | ^^^^^^^^^^^^^^^^ PIE804 + | ^^^^^^^^^^^^^^^^ 4 | 5 | Foo.objects.create(**{"bar": True}) # PIE804 | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 1 1 | foo(**{"bar": True}) # PIE804 @@ -37,16 +39,17 @@ PIE804.py:3:5: PIE804 [*] Unnecessary `dict` kwargs 5 5 | Foo.objects.create(**{"bar": True}) # PIE804 6 6 | -PIE804.py:5:20: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:5:20 | 3 | foo(**{"r2d2": True}) # PIE804 4 | 5 | Foo.objects.create(**{"bar": True}) # PIE804 - | ^^^^^^^^^^^^^^^ PIE804 + | ^^^^^^^^^^^^^^^ 6 | 7 | Foo.objects.create(**{"_id": some_id}) # PIE804 | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 2 2 | @@ -58,16 +61,17 @@ PIE804.py:5:20: PIE804 [*] Unnecessary `dict` kwargs 7 7 | Foo.objects.create(**{"_id": some_id}) # PIE804 8 8 | -PIE804.py:7:20: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:7:20 | 5 | Foo.objects.create(**{"bar": True}) # PIE804 6 | 7 | Foo.objects.create(**{"_id": some_id}) # PIE804 - | ^^^^^^^^^^^^^^^^^^ PIE804 + | ^^^^^^^^^^^^^^^^^^ 8 | 9 | Foo.objects.create(**{**bar}) # PIE804 | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 4 4 | @@ -79,16 +83,17 @@ PIE804.py:7:20: PIE804 [*] Unnecessary `dict` kwargs 9 9 | Foo.objects.create(**{**bar}) # PIE804 10 10 | -PIE804.py:9:20: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:9:20 | 7 | Foo.objects.create(**{"_id": some_id}) # PIE804 8 | 9 | Foo.objects.create(**{**bar}) # PIE804 - | ^^^^^^^^^ PIE804 + | ^^^^^^^^^ 10 | 11 | foo(**{}) | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 6 6 | @@ -100,16 +105,17 @@ PIE804.py:9:20: PIE804 [*] Unnecessary `dict` kwargs 11 11 | foo(**{}) 12 12 | -PIE804.py:11:5: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:11:5 | 9 | Foo.objects.create(**{**bar}) # PIE804 10 | 11 | foo(**{}) - | ^^^^ PIE804 + | ^^^^ 12 | 13 | foo(**{**data, "foo": "buzz"}) | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 8 8 | @@ -121,16 +127,17 @@ PIE804.py:11:5: PIE804 [*] Unnecessary `dict` kwargs 13 13 | foo(**{**data, "foo": "buzz"}) 14 14 | foo(**buzz) -PIE804.py:22:5: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:22:5 | 20 | foo(**{f"buzz__{bar}": True}) 21 | abc(**{"for": 3}) 22 | foo(**{},) - | ^^^^ PIE804 + | ^^^^ 23 | 24 | # Duplicated key names won't be fixed, to avoid syntax errors. | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 19 19 | foo(**{"": True}) @@ -142,45 +149,49 @@ PIE804.py:22:5: PIE804 [*] Unnecessary `dict` kwargs 24 24 | # Duplicated key names won't be fixed, to avoid syntax errors. 25 25 | abc(**{'a': b}, **{'a': c}) # PIE804 -PIE804.py:25:5: PIE804 Unnecessary `dict` kwargs +PIE804 Unnecessary `dict` kwargs + --> PIE804.py:25:5 | 24 | # Duplicated key names won't be fixed, to avoid syntax errors. 25 | abc(**{'a': b}, **{'a': c}) # PIE804 - | ^^^^^^^^^^ PIE804 + | ^^^^^^^^^^ 26 | abc(a=1, **{'a': c}, **{'b': c}) # PIE804 | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs -PIE804.py:25:17: PIE804 Unnecessary `dict` kwargs +PIE804 Unnecessary `dict` kwargs + --> PIE804.py:25:17 | 24 | # Duplicated key names won't be fixed, to avoid syntax errors. 25 | abc(**{'a': b}, **{'a': c}) # PIE804 - | ^^^^^^^^^^ PIE804 + | ^^^^^^^^^^ 26 | abc(a=1, **{'a': c}, **{'b': c}) # PIE804 | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs -PIE804.py:26:10: PIE804 Unnecessary `dict` kwargs +PIE804 Unnecessary `dict` kwargs + --> PIE804.py:26:10 | 24 | # Duplicated key names won't be fixed, to avoid syntax errors. 25 | abc(**{'a': b}, **{'a': c}) # PIE804 26 | abc(a=1, **{'a': c}, **{'b': c}) # PIE804 - | ^^^^^^^^^^ PIE804 + | ^^^^^^^^^^ 27 | 28 | # Some values need to be parenthesized. | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs -PIE804.py:26:22: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:26:22 | 24 | # Duplicated key names won't be fixed, to avoid syntax errors. 25 | abc(**{'a': b}, **{'a': c}) # PIE804 26 | abc(a=1, **{'a': c}, **{'b': c}) # PIE804 - | ^^^^^^^^^^ PIE804 + | ^^^^^^^^^^ 27 | 28 | # Some values need to be parenthesized. | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 23 23 | @@ -192,15 +203,16 @@ PIE804.py:26:22: PIE804 [*] Unnecessary `dict` kwargs 28 28 | # Some values need to be parenthesized. 29 29 | def foo(): -PIE804.py:30:16: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:30:16 | 28 | # Some values need to be parenthesized. 29 | def foo(): 30 | abc(foo=1, **{'bar': (bar := 1)}) # PIE804 - | ^^^^^^^^^^^^^^^^^^^^^ PIE804 + | ^^^^^^^^^^^^^^^^^^^^^ 31 | abc(foo=1, **{'bar': (yield 1)}) # PIE804 | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 27 27 | @@ -212,16 +224,17 @@ PIE804.py:30:16: PIE804 [*] Unnecessary `dict` kwargs 32 32 | 33 33 | # https://github.com/astral-sh/ruff/issues/18036 -PIE804.py:31:16: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:31:16 | 29 | def foo(): 30 | abc(foo=1, **{'bar': (bar := 1)}) # PIE804 31 | abc(foo=1, **{'bar': (yield 1)}) # PIE804 - | ^^^^^^^^^^^^^^^^^^^^ PIE804 + | ^^^^^^^^^^^^^^^^^^^^ 32 | 33 | # https://github.com/astral-sh/ruff/issues/18036 | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Safe fix 28 28 | # Some values need to be parenthesized. @@ -233,7 +246,8 @@ PIE804.py:31:16: PIE804 [*] Unnecessary `dict` kwargs 33 33 | # https://github.com/astral-sh/ruff/issues/18036 34 34 | # The autofix for this is unsafe due to the comments inside the dictionary. -PIE804.py:36:5: PIE804 [*] Unnecessary `dict` kwargs +PIE804 [*] Unnecessary `dict` kwargs + --> PIE804.py:36:5 | 34 | # The autofix for this is unsafe due to the comments inside the dictionary. 35 | foo( @@ -243,10 +257,10 @@ PIE804.py:36:5: PIE804 [*] Unnecessary `dict` kwargs 39 | | # Comment 2 40 | | "y": 2.0, 41 | | } - | |_____^ PIE804 + | |_____^ 42 | ) | - = help: Remove unnecessary kwargs +help: Remove unnecessary kwargs ℹ Unsafe fix 33 33 | # https://github.com/astral-sh/ruff/issues/18036 diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap index dac3e255b8..38cb78b806 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs -snapshot_kind: text --- -PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda +PIE807 [*] Prefer `list` over useless lambda + --> PIE807.py:3:44 | 1 | @dataclass 2 | class Foo: 3 | foo: List[str] = field(default_factory=lambda: []) # PIE807 - | ^^^^^^^^^^ PIE807 + | ^^^^^^^^^^ 4 | bar: Dict[str, int] = field(default_factory=lambda: {}) # PIE807 | - = help: Replace with `lambda` with `list` +help: Replace with `lambda` with `list` ℹ Safe fix 1 1 | @dataclass @@ -21,14 +21,15 @@ PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda 5 5 | 6 6 | -PIE807.py:4:49: PIE807 [*] Prefer `dict` over useless lambda +PIE807 [*] Prefer `dict` over useless lambda + --> PIE807.py:4:49 | 2 | class Foo: 3 | foo: List[str] = field(default_factory=lambda: []) # PIE807 4 | bar: Dict[str, int] = field(default_factory=lambda: {}) # PIE807 - | ^^^^^^^^^^ PIE807 + | ^^^^^^^^^^ | - = help: Replace with `lambda` with `dict` +help: Replace with `lambda` with `dict` ℹ Safe fix 1 1 | @dataclass @@ -40,14 +41,15 @@ PIE807.py:4:49: PIE807 [*] Prefer `dict` over useless lambda 6 6 | 7 7 | class FooTable(BaseTable): -PIE807.py:8:36: PIE807 [*] Prefer `list` over useless lambda +PIE807 [*] Prefer `list` over useless lambda + --> PIE807.py:8:36 | 7 | class FooTable(BaseTable): 8 | foo = fields.ListField(default=lambda: []) # PIE807 - | ^^^^^^^^^^ PIE807 + | ^^^^^^^^^^ 9 | bar = fields.ListField(default=lambda: {}) # PIE807 | - = help: Replace with `lambda` with `list` +help: Replace with `lambda` with `list` ℹ Safe fix 5 5 | @@ -59,14 +61,15 @@ PIE807.py:8:36: PIE807 [*] Prefer `list` over useless lambda 10 10 | 11 11 | -PIE807.py:9:36: PIE807 [*] Prefer `dict` over useless lambda +PIE807 [*] Prefer `dict` over useless lambda + --> PIE807.py:9:36 | 7 | class FooTable(BaseTable): 8 | foo = fields.ListField(default=lambda: []) # PIE807 9 | bar = fields.ListField(default=lambda: {}) # PIE807 - | ^^^^^^^^^^ PIE807 + | ^^^^^^^^^^ | - = help: Replace with `lambda` with `dict` +help: Replace with `lambda` with `dict` ℹ Safe fix 6 6 | @@ -78,14 +81,15 @@ PIE807.py:9:36: PIE807 [*] Prefer `dict` over useless lambda 11 11 | 12 12 | class FooTable(BaseTable): -PIE807.py:13:28: PIE807 [*] Prefer `list` over useless lambda +PIE807 [*] Prefer `list` over useless lambda + --> PIE807.py:13:28 | 12 | class FooTable(BaseTable): 13 | foo = fields.ListField(lambda: []) # PIE807 - | ^^^^^^^^^^ PIE807 + | ^^^^^^^^^^ 14 | bar = fields.ListField(default=lambda: {}) # PIE807 | - = help: Replace with `lambda` with `list` +help: Replace with `lambda` with `list` ℹ Safe fix 10 10 | @@ -97,14 +101,15 @@ PIE807.py:13:28: PIE807 [*] Prefer `list` over useless lambda 15 15 | 16 16 | -PIE807.py:14:36: PIE807 [*] Prefer `dict` over useless lambda +PIE807 [*] Prefer `dict` over useless lambda + --> PIE807.py:14:36 | 12 | class FooTable(BaseTable): 13 | foo = fields.ListField(lambda: []) # PIE807 14 | bar = fields.ListField(default=lambda: {}) # PIE807 - | ^^^^^^^^^^ PIE807 + | ^^^^^^^^^^ | - = help: Replace with `lambda` with `dict` +help: Replace with `lambda` with `dict` ℹ Safe fix 11 11 | diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap index 7423a0fcc9..1ac8dcf635 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs --- -PIE808.py:2:7: PIE808 [*] Unnecessary `start` argument in `range` +PIE808 [*] Unnecessary `start` argument in `range` + --> PIE808.py:2:7 | 1 | # PIE808 2 | range(0, 10) - | ^ PIE808 + | ^ 3 | 4 | import builtins | - = help: Remove `start` argument +help: Remove `start` argument ℹ Safe fix 1 1 | # PIE808 @@ -19,15 +20,16 @@ PIE808.py:2:7: PIE808 [*] Unnecessary `start` argument in `range` 4 4 | import builtins 5 5 | builtins.range(0, 10) -PIE808.py:5:16: PIE808 [*] Unnecessary `start` argument in `range` +PIE808 [*] Unnecessary `start` argument in `range` + --> PIE808.py:5:16 | 4 | import builtins 5 | builtins.range(0, 10) - | ^ PIE808 + | ^ 6 | 7 | # OK | - = help: Remove `start` argument +help: Remove `start` argument ℹ Safe fix 2 2 | range(0, 10) @@ -39,13 +41,14 @@ PIE808.py:5:16: PIE808 [*] Unnecessary `start` argument in `range` 7 7 | # OK 8 8 | range(x, 10) -PIE808.py:19:8: PIE808 [*] Unnecessary `start` argument in `range` +PIE808 [*] Unnecessary `start` argument in `range` + --> PIE808.py:19:8 | 18 | # regression test for https://github.com/astral-sh/ruff/pull/18805 19 | range((0), 42) - | ^ PIE808 + | ^ | - = help: Remove `start` argument +help: Remove `start` argument ℹ Safe fix 16 16 | range(0, stop=10) diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap index 929042cc47..3fe1aacb7d 100644 --- a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pie/mod.rs --- -PIE810.py:2:1: PIE810 [*] Call `startswith` once with a `tuple` +PIE810 [*] Call `startswith` once with a `tuple` + --> PIE810.py:2:1 | 1 | # error 2 | obj.startswith("foo") or obj.startswith("bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | # error 4 | obj.endswith("foo") or obj.endswith("bar") | - = help: Merge into a single `startswith` call +help: Merge into a single `startswith` call ℹ Unsafe fix 1 1 | # error @@ -19,16 +20,17 @@ PIE810.py:2:1: PIE810 [*] Call `startswith` once with a `tuple` 4 4 | obj.endswith("foo") or obj.endswith("bar") 5 5 | # error -PIE810.py:4:1: PIE810 [*] Call `endswith` once with a `tuple` +PIE810 [*] Call `endswith` once with a `tuple` + --> PIE810.py:4:1 | 2 | obj.startswith("foo") or obj.startswith("bar") 3 | # error 4 | obj.endswith("foo") or obj.endswith("bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | # error 6 | obj.startswith(foo) or obj.startswith(bar) | - = help: Merge into a single `endswith` call +help: Merge into a single `endswith` call ℹ Unsafe fix 1 1 | # error @@ -40,16 +42,17 @@ PIE810.py:4:1: PIE810 [*] Call `endswith` once with a `tuple` 6 6 | obj.startswith(foo) or obj.startswith(bar) 7 7 | # error -PIE810.py:6:1: PIE810 [*] Call `startswith` once with a `tuple` +PIE810 [*] Call `startswith` once with a `tuple` + --> PIE810.py:6:1 | 4 | obj.endswith("foo") or obj.endswith("bar") 5 | # error 6 | obj.startswith(foo) or obj.startswith(bar) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | # error 8 | obj.startswith(foo) or obj.startswith("foo") | - = help: Merge into a single `startswith` call +help: Merge into a single `startswith` call ℹ Unsafe fix 3 3 | # error @@ -61,16 +64,17 @@ PIE810.py:6:1: PIE810 [*] Call `startswith` once with a `tuple` 8 8 | obj.startswith(foo) or obj.startswith("foo") 9 9 | # error -PIE810.py:8:1: PIE810 [*] Call `startswith` once with a `tuple` +PIE810 [*] Call `startswith` once with a `tuple` + --> PIE810.py:8:1 | 6 | obj.startswith(foo) or obj.startswith(bar) 7 | # error 8 | obj.startswith(foo) or obj.startswith("foo") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | # error 10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") | - = help: Merge into a single `startswith` call +help: Merge into a single `startswith` call ℹ Unsafe fix 5 5 | # error @@ -82,16 +86,17 @@ PIE810.py:8:1: PIE810 [*] Call `startswith` once with a `tuple` 10 10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") 11 11 | -PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple` +PIE810 [*] Call `startswith` once with a `tuple` + --> PIE810.py:10:1 | 8 | obj.startswith(foo) or obj.startswith("foo") 9 | # error 10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | def func(): | - = help: Merge into a single `startswith` call +help: Merge into a single `startswith` call ℹ Unsafe fix 7 7 | # error @@ -103,15 +108,16 @@ PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple` 12 12 | def func(): 13 13 | msg = "hello world" -PIE810.py:19:8: PIE810 [*] Call `startswith` once with a `tuple` +PIE810 [*] Call `startswith` once with a `tuple` + --> PIE810.py:19:8 | 17 | z = "w" 18 | 19 | if msg.startswith(x) or msg.startswith(y) or msg.startswith(z): # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | print("yes") | - = help: Merge into a single `startswith` call +help: Merge into a single `startswith` call ℹ Unsafe fix 16 16 | y = ("h", "e", "l", "l", "o") @@ -123,15 +129,16 @@ PIE810.py:19:8: PIE810 [*] Call `startswith` once with a `tuple` 21 21 | 22 22 | def func(): -PIE810.py:25:8: PIE810 [*] Call `startswith` once with a `tuple` +PIE810 [*] Call `startswith` once with a `tuple` + --> PIE810.py:25:8 | 23 | msg = "hello world" 24 | 25 | if msg.startswith(("h", "e", "l", "l", "o")) or msg.startswith("h") or msg.startswith("w"): # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | print("yes") | - = help: Merge into a single `startswith` call +help: Merge into a single `startswith` call ℹ Unsafe fix 22 22 | def func(): @@ -143,15 +150,16 @@ PIE810.py:25:8: PIE810 [*] Call `startswith` once with a `tuple` 27 27 | 28 28 | # ok -PIE810.py:83:8: PIE810 [*] Call `startswith` once with a `tuple` +PIE810 [*] Call `startswith` once with a `tuple` + --> PIE810.py:83:8 | 81 | def func(): 82 | "Regression test for https://github.com/astral-sh/ruff/issues/9663" 83 | if x.startswith("a") or x.startswith("b") or re.match(r"a\.b", x): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | print("yes") | - = help: Merge into a single `startswith` call +help: Merge into a single `startswith` call ℹ Unsafe fix 80 80 | diff --git a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap index 3177ee0830..62d5112a6a 100644 --- a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_print/mod.rs --- -T201.py:4:1: T201 [*] `print` found +T201 [*] `print` found + --> T201.py:4:1 | 2 | import tempfile 3 | 4 | print("Hello, world!") # T201 - | ^^^^^ T201 + | ^^^^^ 5 | print("Hello, world!", file=None) # T201 6 | print("Hello, world!", file=sys.stdout) # T201 | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 1 1 | import sys @@ -21,15 +22,16 @@ T201.py:4:1: T201 [*] `print` found 6 5 | print("Hello, world!", file=sys.stdout) # T201 7 6 | print("Hello, world!", file=sys.stderr) # T201 -T201.py:5:1: T201 [*] `print` found +T201 [*] `print` found + --> T201.py:5:1 | 4 | print("Hello, world!") # T201 5 | print("Hello, world!", file=None) # T201 - | ^^^^^ T201 + | ^^^^^ 6 | print("Hello, world!", file=sys.stdout) # T201 7 | print("Hello, world!", file=sys.stderr) # T201 | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 2 2 | import tempfile @@ -40,15 +42,16 @@ T201.py:5:1: T201 [*] `print` found 7 6 | print("Hello, world!", file=sys.stderr) # T201 8 7 | -T201.py:6:1: T201 [*] `print` found +T201 [*] `print` found + --> T201.py:6:1 | 4 | print("Hello, world!") # T201 5 | print("Hello, world!", file=None) # T201 6 | print("Hello, world!", file=sys.stdout) # T201 - | ^^^^^ T201 + | ^^^^^ 7 | print("Hello, world!", file=sys.stderr) # T201 | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 3 3 | @@ -59,16 +62,17 @@ T201.py:6:1: T201 [*] `print` found 8 7 | 9 8 | with tempfile.NamedTemporaryFile() as fp: -T201.py:7:1: T201 [*] `print` found +T201 [*] `print` found + --> T201.py:7:1 | 5 | print("Hello, world!", file=None) # T201 6 | print("Hello, world!", file=sys.stdout) # T201 7 | print("Hello, world!", file=sys.stderr) # T201 - | ^^^^^ T201 + | ^^^^^ 8 | 9 | with tempfile.NamedTemporaryFile() as fp: | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 4 4 | print("Hello, world!") # T201 diff --git a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap index 24d4d7193d..04e2c9fd2e 100644 --- a/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap +++ b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_print/mod.rs --- -T203.py:3:1: T203 [*] `pprint` found +T203 [*] `pprint` found + --> T203.py:3:1 | 1 | from pprint import pprint 2 | 3 | pprint("Hello, world!") # T203 - | ^^^^^^ T203 + | ^^^^^^ 4 | 5 | import pprint | - = help: Remove `pprint` +help: Remove `pprint` ℹ Unsafe fix 1 1 | from pprint import pprint @@ -20,16 +21,17 @@ T203.py:3:1: T203 [*] `pprint` found 5 4 | import pprint 6 5 | -T203.py:7:1: T203 [*] `pprint` found +T203 [*] `pprint` found + --> T203.py:7:1 | 5 | import pprint 6 | 7 | pprint.pprint("Hello, world!") # T203 - | ^^^^^^^^^^^^^ T203 + | ^^^^^^^^^^^^^ 8 | 9 | pprint.pformat("Hello, world!") | - = help: Remove `pprint` +help: Remove `pprint` ℹ Unsafe fix 4 4 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap index d612aa2103..7927169d34 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap @@ -1,32 +1,35 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI001.pyi:3:5: PYI001 Name of private `TypeVar` must start with `_` +PYI001 Name of private `TypeVar` must start with `_` + --> PYI001.pyi:3:5 | 1 | from typing import ParamSpec, TypeVar, TypeVarTuple 2 | 3 | T = TypeVar("T") # Error: TypeVars in stubs must start with _ - | ^^^^^^^^^^^^ PYI001 + | ^^^^^^^^^^^^ 4 | 5 | TTuple = TypeVarTuple("TTuple") # Error: TypeVarTuples must also start with _ | -PYI001.pyi:5:10: PYI001 Name of private `TypeVarTuple` must start with `_` +PYI001 Name of private `TypeVarTuple` must start with `_` + --> PYI001.pyi:5:10 | 3 | T = TypeVar("T") # Error: TypeVars in stubs must start with _ 4 | 5 | TTuple = TypeVarTuple("TTuple") # Error: TypeVarTuples must also start with _ - | ^^^^^^^^^^^^^^^^^^^^^^ PYI001 + | ^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | P = ParamSpec("P") # Error: ParamSpecs must start with _ | -PYI001.pyi:7:5: PYI001 Name of private `ParamSpec` must start with `_` +PYI001 Name of private `ParamSpec` must start with `_` + --> PYI001.pyi:7:5 | 5 | TTuple = TypeVarTuple("TTuple") # Error: TypeVarTuples must also start with _ 6 | 7 | P = ParamSpec("P") # Error: ParamSpecs must start with _ - | ^^^^^^^^^^^^^^ PYI001 + | ^^^^^^^^^^^^^^ 8 | 9 | _T = TypeVar("_T") # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap index 7b018399ca..744b2850cf 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI002.pyi:3:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` +PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` + --> PYI002.pyi:3:4 | 1 | import sys 2 | 3 | if sys.version == 'Python 2.7.10': ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info 5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info | -PYI002.pyi:4:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` +PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` + --> PYI002.pyi:4:4 | 3 | if sys.version == 'Python 2.7.10': ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info 4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI002 + | ^^^^^^^^^^^^^^^^^^^^^^^ 5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info 6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info | -PYI002.pyi:5:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` +PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` + --> PYI002.pyi:5:4 | 3 | if sys.version == 'Python 2.7.10': ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info 4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info 5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | ^^^^^^^^^^^^^^^^^^^^^^ PYI002 + | ^^^^^^^^^^^^^^^^^^^^^^ 6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info | -PYI002.pyi:6:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` +PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` + --> PYI002.pyi:6:4 | 4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info 5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info 6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | ^^^^^^^^^^^^^^^^^ PYI002 + | ^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap index 99096e74e8..7ea696622e 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap @@ -1,171 +1,188 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI003.pyi:4:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:4:4 | 3 | if sys.version_info[0] == 2: ... 4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:'… - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | if sys.version_info[0.0] == 2: ... # Y003 Unrecognized sys.version_info check 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:5:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:5:4 | 3 | if sys.version_info[0] == 2: ... 4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:'… 5 | if sys.version_info[0.0] == 2: ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:6:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:6:4 | 4 | if sys.version_info[0] == True: ... # Y003 Unrecognized sys.version_info check # E712 comparison to True should be 'if cond is True:'… 5 | if sys.version_info[0.0] == 2: ... # Y003 Unrecognized sys.version_info check 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:7:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:7:4 | 5 | if sys.version_info[0.0] == 2: ... # Y003 Unrecognized sys.version_info check 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:8:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:8:4 | 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check 10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:9:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:9:4 | 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check 11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:10:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:10:4 | 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check 10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check 12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:11:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:11:4 | 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check 10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check 11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check 13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:12:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:12:4 | 10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check 11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check 12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check 14 | if sys.version_info[:1] == (2,): ... | -PYI003.pyi:13:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:13:4 | 11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check 12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check 13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | if sys.version_info[:1] == (2,): ... 15 | if sys.version_info[:1] == (True,): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:15:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:15:4 | 13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check 14 | if sys.version_info[:1] == (2,): ... 15 | if sys.version_info[:1] == (True,): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | if sys.version_info[:1] == (2, 7): ... # Y005 Version comparison must be against a length-1 tuple 17 | if sys.version_info[:2] == (2, 7): ... | -PYI003.pyi:19:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:19:4 | 17 | if sys.version_info[:2] == (2, 7): ... 18 | if sys.version_info[:2] == (2,): ... # Y005 Version comparison must be against a length-2 tuple 19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check 21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:20:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:20:4 | 18 | if sys.version_info[:2] == (2,): ... # Y005 Version comparison must be against a length-2 tuple 19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check 20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check 22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:21:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:21:4 | 19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check 20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check 21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check 23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:22:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:22:4 | 20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check 21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check 22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check 24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check | -PYI003.pyi:23:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:23:4 | 21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check 22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check 23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check 25 | if sys.version_info >= (3, 4, 3): ... # Y004 Version comparison must use only major and minor version | -PYI003.pyi:24:4: PYI003 Unrecognized `sys.version_info` check +PYI003 Unrecognized `sys.version_info` check + --> PYI003.pyi:24:4 | 22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check 23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check 24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | if sys.version_info >= (3, 4, 3): ... # Y004 Version comparison must use only major and minor version 26 | if sys.version_info == (3, 4): ... # Y006 Use only < and >= for version comparisons | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap index 81182425c2..835d1017c0 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI004.pyi:4:4: PYI004 Version comparison must use only major and minor version +PYI004 Version comparison must use only major and minor version + --> PYI004.pyi:4:4 | 2 | from sys import version_info 3 | 4 | if sys.version_info >= (3, 4, 3): ... # PYI004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | if sys.version_info < (3, 4, 3): ... # PYI004 6 | if sys.version_info == (3, 4, 3): ... # PYI004 | -PYI004.pyi:5:4: PYI004 Version comparison must use only major and minor version +PYI004 Version comparison must use only major and minor version + --> PYI004.pyi:5:4 | 4 | if sys.version_info >= (3, 4, 3): ... # PYI004 5 | if sys.version_info < (3, 4, 3): ... # PYI004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | if sys.version_info == (3, 4, 3): ... # PYI004 7 | if sys.version_info != (3, 4, 3): ... # PYI004 | -PYI004.pyi:6:4: PYI004 Version comparison must use only major and minor version +PYI004 Version comparison must use only major and minor version + --> PYI004.pyi:6:4 | 4 | if sys.version_info >= (3, 4, 3): ... # PYI004 5 | if sys.version_info < (3, 4, 3): ... # PYI004 6 | if sys.version_info == (3, 4, 3): ... # PYI004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | if sys.version_info != (3, 4, 3): ... # PYI004 | -PYI004.pyi:7:4: PYI004 Version comparison must use only major and minor version +PYI004 Version comparison must use only major and minor version + --> PYI004.pyi:7:4 | 5 | if sys.version_info < (3, 4, 3): ... # PYI004 6 | if sys.version_info == (3, 4, 3): ... # PYI004 7 | if sys.version_info != (3, 4, 3): ... # PYI004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | if sys.version_info[0] == 2: ... | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap index 117c684948..1dfd4b7b55 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI005.pyi:4:4: PYI005 Version comparison must be against a length-1 tuple +PYI005 Version comparison must be against a length-1 tuple + --> PYI005.pyi:4:4 | 2 | from sys import platform, version_info 3 | 4 | if sys.version_info[:1] == (2, 7): ... # Y005 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | if sys.version_info[:2] == (2,): ... # Y005 | -PYI005.pyi:5:4: PYI005 Version comparison must be against a length-2 tuple +PYI005 Version comparison must be against a length-2 tuple + --> PYI005.pyi:5:4 | 4 | if sys.version_info[:1] == (2, 7): ... # Y005 5 | if sys.version_info[:2] == (2,): ... # Y005 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap index 93cd183f24..a7ed2ffa50 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap @@ -1,76 +1,84 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI006.py:8:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.py:8:4 | 6 | if sys.version_info >= (3, 9): ... # OK 7 | 8 | if sys.version_info == (3, 9): ... # OK - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.py:10:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.py:10:4 | 8 | if sys.version_info == (3, 9): ... # OK 9 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.py:12:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.py:12:4 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 11 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.py:14:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.py:14:4 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 13 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.py:16:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.py:16:4 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 15 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.py:17:6: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.py:17:6 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.py:19:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.py:19:4 | 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 18 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 20 | elif python_version == (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.py:20:6: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.py:20:6 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 20 | elif python_version == (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap index afe447cc76..8db85b25ce 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap @@ -1,76 +1,84 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI006.pyi:8:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.pyi:8:4 | 6 | if sys.version_info >= (3, 9): ... # OK 7 | 8 | if sys.version_info == (3, 9): ... # OK - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.pyi:10:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.pyi:10:4 | 8 | if sys.version_info == (3, 9): ... # OK 9 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.pyi:12:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.pyi:12:4 | 10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 11 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.pyi:14:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.pyi:14:4 | 12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 13 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.pyi:16:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.pyi:16:4 | 14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 15 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.pyi:17:6: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.pyi:17:6 | 16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.pyi:19:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.pyi:19:4 | 17 | elif sys.version_info > (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 18 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 20 | elif python_version == (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons | -PYI006.pyi:20:6: PYI006 Use `<` or `>=` for `sys.version_info` comparisons +PYI006 Use `<` or `>=` for `sys.version_info` comparisons + --> PYI006.pyi:20:6 | 19 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons 20 | elif python_version == (3, 11): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap index bb46b48b79..6e444fcbc6 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI007.pyi:7:4: PYI007 Unrecognized `sys.platform` check +PYI007 Unrecognized `sys.platform` check + --> PYI007.pyi:7:4 | 5 | if sys.platform != "platform_name_2": ... # OK 6 | 7 | if sys.platform in ["linux"]: ... # Error: PYI007 Unrecognized sys.platform check - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | if sys.platform > 3: ... # Error: PYI007 Unrecognized sys.platform check | -PYI007.pyi:9:4: PYI007 Unrecognized `sys.platform` check +PYI007 Unrecognized `sys.platform` check + --> PYI007.pyi:9:4 | 7 | if sys.platform in ["linux"]: ... # Error: PYI007 Unrecognized sys.platform check 8 | 9 | if sys.platform > 3: ... # Error: PYI007 Unrecognized sys.platform check - | ^^^^^^^^^^^^^^^^ PYI007 + | ^^^^^^^^^^^^^^^^ 10 | 11 | if sys.platform == 10.12: ... # Error: PYI007 Unrecognized sys.platform check | -PYI007.pyi:11:4: PYI007 Unrecognized `sys.platform` check +PYI007 Unrecognized `sys.platform` check + --> PYI007.pyi:11:4 | 9 | if sys.platform > 3: ... # Error: PYI007 Unrecognized sys.platform check 10 | 11 | if sys.platform == 10.12: ... # Error: PYI007 Unrecognized sys.platform check - | ^^^^^^^^^^^^^^^^^^^^^ PYI007 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap index 4e8588c7a3..238c4c75ee 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI008.pyi:3:20: PYI008 Unrecognized platform `linus` +PYI008 Unrecognized platform `linus` + --> PYI008.pyi:3:20 | 1 | import sys 2 | 3 | if sys.platform == "linus": ... # Error: PYI008 Unrecognized platform `linus` - | ^^^^^^^ PYI008 + | ^^^^^^^ 4 | 5 | if sys.platform != "linux": ... # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap index 48db875d89..4f421dfbec 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI009.pyi:3:5: PYI009 [*] Empty body should contain `...`, not `pass` +PYI009 [*] Empty body should contain `...`, not `pass` + --> PYI009.pyi:3:5 | 1 | def bar(): ... # OK 2 | def foo(): 3 | pass # ERROR PYI009, since we're in a stub file - | ^^^^ PYI009 + | ^^^^ 4 | 5 | class Bar: ... # OK | - = help: Replace `pass` with `...` +help: Replace `pass` with `...` ℹ Safe fix 1 1 | def bar(): ... # OK @@ -21,13 +22,14 @@ PYI009.pyi:3:5: PYI009 [*] Empty body should contain `...`, not `pass` 5 5 | class Bar: ... # OK 6 6 | -PYI009.pyi:8:5: PYI009 [*] Empty body should contain `...`, not `pass` +PYI009 [*] Empty body should contain `...`, not `pass` + --> PYI009.pyi:8:5 | 7 | class Foo: 8 | pass # ERROR PYI009, since we're in a stub file - | ^^^^ PYI009 + | ^^^^ | - = help: Replace `pass` with `...` +help: Replace `pass` with `...` ℹ Safe fix 5 5 | class Bar: ... # OK diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap index a24482573d..cbee721ffd 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI010.pyi:6:5: PYI010 [*] Function body must contain only `...` +PYI010 [*] Function body must contain only `...` + --> PYI010.pyi:6:5 | 5 | def buzz(): 6 | print("buzz") # ERROR PYI010 - | ^^^^^^^^^^^^^ PYI010 + | ^^^^^^^^^^^^^ 7 | 8 | def foo2(): | - = help: Replace function body with `...` +help: Replace function body with `...` ℹ Safe fix 3 3 | """foo""" # OK, docstrings are handled by another rule @@ -21,15 +22,16 @@ PYI010.pyi:6:5: PYI010 [*] Function body must contain only `...` 8 8 | def foo2(): 9 9 | 123 # ERROR PYI010 -PYI010.pyi:9:5: PYI010 [*] Function body must contain only `...` +PYI010 [*] Function body must contain only `...` + --> PYI010.pyi:9:5 | 8 | def foo2(): 9 | 123 # ERROR PYI010 - | ^^^ PYI010 + | ^^^ 10 | 11 | def bizz(): | - = help: Replace function body with `...` +help: Replace function body with `...` ℹ Safe fix 6 6 | print("buzz") # ERROR PYI010 @@ -41,15 +43,16 @@ PYI010.pyi:9:5: PYI010 [*] Function body must contain only `...` 11 11 | def bizz(): 12 12 | x = 123 # ERROR PYI010 -PYI010.pyi:12:5: PYI010 [*] Function body must contain only `...` +PYI010 [*] Function body must contain only `...` + --> PYI010.pyi:12:5 | 11 | def bizz(): 12 | x = 123 # ERROR PYI010 - | ^^^^^^^ PYI010 + | ^^^^^^^ 13 | 14 | def foo3(): | - = help: Replace function body with `...` +help: Replace function body with `...` ℹ Safe fix 9 9 | 123 # ERROR PYI010 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap index e8e0429c3a..010b4f26d8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI011.pyi:10:14: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:10:14 | 8 | def f12( 9 | x, 10 | y: str = os.pathsep, # Error PYI011 Only simple default values allowed for typed arguments - | ^^^^^^^^^^ PYI011 + | ^^^^^^^^^^ 11 | ) -> None: ... 12 | def f11(*, x: str = "x") -> None: ... # OK | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 7 7 | @@ -23,7 +23,8 @@ PYI011.pyi:10:14: PYI011 [*] Only simple default values allowed for typed argume 12 12 | def f11(*, x: str = "x") -> None: ... # OK 13 13 | def f13( -PYI011.pyi:38:9: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:38:9 | 36 | x: dict[ 37 | int, int @@ -32,11 +33,11 @@ PYI011.pyi:38:9: PYI011 [*] Only simple default values allowed for typed argumen 39 | | 1: 2, 40 | | **{3: 4}, 41 | | } - | |_____^ PYI011 + | |_____^ 42 | ) -> None: ... 43 | def f153( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 35 35 | def f152( @@ -51,7 +52,8 @@ PYI011.pyi:38:9: PYI011 [*] Only simple default values allowed for typed argumen 43 40 | def f153( 44 41 | x: list[ -PYI011.pyi:46:9: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:46:9 | 44 | x: list[ 45 | int @@ -69,11 +71,11 @@ PYI011.pyi:46:9: PYI011 [*] Only simple default values allowed for typed argumen 56 | | 10, 57 | | 11, 58 | | ] - | |_____^ PYI011 + | |_____^ 59 | ) -> None: ... 60 | def f154( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 43 43 | def f153( @@ -97,7 +99,8 @@ PYI011.pyi:46:9: PYI011 [*] Only simple default values allowed for typed argumen 60 48 | def f154( 61 49 | x: tuple[ -PYI011.pyi:63:9: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:63:9 | 61 | x: tuple[ 62 | str, tuple[str, ...] @@ -106,11 +109,11 @@ PYI011.pyi:63:9: PYI011 [*] Only simple default values allowed for typed argumen 64 | | "foo", 65 | | ("bar", "baz"), 66 | | ) - | |_____^ PYI011 + | |_____^ 67 | ) -> None: ... 68 | def f141( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 60 60 | def f154( @@ -125,7 +128,8 @@ PYI011.pyi:63:9: PYI011 [*] Only simple default values allowed for typed argumen 68 65 | def f141( 69 66 | x: list[ -PYI011.pyi:71:9: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:71:9 | 69 | x: list[ 70 | int @@ -133,11 +137,11 @@ PYI011.pyi:71:9: PYI011 [*] Only simple default values allowed for typed argumen | _________^ 72 | | *range(10) 73 | | ], - | |_____^ PYI011 + | |_____^ 74 | ) -> None: ... 75 | def f142( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 68 68 | def f141( @@ -151,7 +155,8 @@ PYI011.pyi:71:9: PYI011 [*] Only simple default values allowed for typed argumen 75 73 | def f142( 76 74 | x: list[ -PYI011.pyi:78:9: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:78:9 | 76 | x: list[ 77 | int @@ -159,11 +164,11 @@ PYI011.pyi:78:9: PYI011 [*] Only simple default values allowed for typed argumen | _________^ 79 | | range(10) 80 | | ), - | |_____^ PYI011 + | |_____^ 81 | ) -> None: ... 82 | def f16( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 75 75 | def f142( @@ -177,7 +182,8 @@ PYI011.pyi:78:9: PYI011 [*] Only simple default values allowed for typed argumen 82 80 | def f16( 83 81 | x: frozenset[ -PYI011.pyi:85:9: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:85:9 | 83 | x: frozenset[ 84 | bytes @@ -185,11 +191,11 @@ PYI011.pyi:85:9: PYI011 [*] Only simple default values allowed for typed argumen | _________^ 86 | | {b"foo", b"bar", b"baz"} 87 | | ) - | |_____^ PYI011 + | |_____^ 88 | ) -> None: ... 89 | def f17( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 82 82 | def f16( @@ -203,18 +209,19 @@ PYI011.pyi:85:9: PYI011 [*] Only simple default values allowed for typed argumen 89 87 | def f17( 90 88 | x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments -PYI011.pyi:90:14: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:90:14 | 88 | ) -> None: ... 89 | def f17( 90 | x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments | ______________^ 91 | | + "bar", - | |___________^ PYI011 + | |___________^ 92 | ) -> None: ... 93 | def f18( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 87 87 | ) @@ -227,18 +234,19 @@ PYI011.pyi:90:14: PYI011 [*] Only simple default values allowed for typed argume 93 92 | def f18( 94 93 | x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments -PYI011.pyi:94:14: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:94:14 | 92 | ) -> None: ... 93 | def f18( 94 | x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments | ______________^ 95 | | + b"bar", - | |____________^ PYI011 + | |____________^ 96 | ) -> None: ... 97 | def f19( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 91 91 | + "bar", @@ -251,18 +259,19 @@ PYI011.pyi:94:14: PYI011 [*] Only simple default values allowed for typed argume 97 96 | def f19( 98 97 | x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments -PYI011.pyi:98:17: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:98:17 | 96 | ) -> None: ... 97 | def f19( 98 | x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments | _________________^ 99 | | + 4, - | |_______^ PYI011 + | |_______^ 100 | ) -> None: ... 101 | def f20( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 95 95 | + b"bar", @@ -275,18 +284,19 @@ PYI011.pyi:98:17: PYI011 [*] Only simple default values allowed for typed argume 101 100 | def f20( 102 101 | x: int = 5 -PYI011.pyi:102:14: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:102:14 | 100 | ) -> None: ... 101 | def f20( 102 | x: int = 5 | ______________^ 103 | | + 5, # Error PYI011 Only simple default values allowed for typed arguments - | |_______^ PYI011 + | |_______^ 104 | ) -> None: ... 105 | def f21( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 99 99 | + 4, @@ -299,18 +309,19 @@ PYI011.pyi:102:14: PYI011 [*] Only simple default values allowed for typed argum 105 104 | def f21( 106 105 | x: complex = 3j -PYI011.pyi:106:18: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:106:18 | 104 | ) -> None: ... 105 | def f21( 106 | x: complex = 3j | __________________^ 107 | | - 3j, # Error PYI011 Only simple default values allowed for typed arguments - | |________^ PYI011 + | |________^ 108 | ) -> None: ... 109 | def f22( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 103 103 | + 5, # Error PYI011 Only simple default values allowed for typed arguments @@ -323,18 +334,19 @@ PYI011.pyi:106:18: PYI011 [*] Only simple default values allowed for typed argum 109 108 | def f22( 110 109 | x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments -PYI011.pyi:110:18: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:110:18 | 108 | ) -> None: ... 109 | def f22( 110 | x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments | __________________^ 111 | | + 4.3j, - | |__________^ PYI011 + | |__________^ 112 | ) -> None: ... 113 | def f23( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 107 107 | - 3j, # Error PYI011 Only simple default values allowed for typed arguments @@ -347,16 +359,17 @@ PYI011.pyi:110:18: PYI011 [*] Only simple default values allowed for typed argum 113 112 | def f23( 114 113 | x: bool = True, # OK -PYI011.pyi:138:16: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:138:16 | 136 | ) -> None: ... 137 | def f31( 138 | x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments - | ^^^ PYI011 + | ^^^ 139 | ) -> None: ... 140 | def f32( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 135 135 | x: float = -math.inf, # OK @@ -368,16 +381,17 @@ PYI011.pyi:138:16: PYI011 [*] Only simple default values allowed for typed argum 140 140 | def f32( 141 141 | x: float = np.inf, # Error PYI011 Only simple default values allowed for typed arguments -PYI011.pyi:141:16: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:141:16 | 139 | ) -> None: ... 140 | def f32( 141 | x: float = np.inf, # Error PYI011 Only simple default values allowed for typed arguments - | ^^^^^^ PYI011 + | ^^^^^^ 142 | ) -> None: ... 143 | def f33( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 138 138 | x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments @@ -389,16 +403,17 @@ PYI011.pyi:141:16: PYI011 [*] Only simple default values allowed for typed argum 143 143 | def f33( 144 144 | x: float = math.nan, # OK -PYI011.pyi:147:16: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:147:16 | 145 | ) -> None: ... 146 | def f34( 147 | x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments - | ^^^^^^^^^ PYI011 + | ^^^^^^^^^ 148 | ) -> None: ... 149 | def f35( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 144 144 | x: float = math.nan, # OK @@ -410,18 +425,19 @@ PYI011.pyi:147:16: PYI011 [*] Only simple default values allowed for typed argum 149 149 | def f35( 150 150 | x: complex = math.inf # Error PYI011 Only simple default values allowed for typed arguments -PYI011.pyi:150:18: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:150:18 | 148 | ) -> None: ... 149 | def f35( 150 | x: complex = math.inf # Error PYI011 Only simple default values allowed for typed arguments | __________________^ 151 | | + 1j, - | |________^ PYI011 + | |________^ 152 | ) -> None: ... 153 | def f36( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 147 147 | x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments @@ -434,17 +450,18 @@ PYI011.pyi:150:18: PYI011 [*] Only simple default values allowed for typed argum 153 152 | def f36( 154 153 | *, -PYI011.pyi:159:14: PYI011 [*] Only simple default values allowed for typed arguments +PYI011 [*] Only simple default values allowed for typed arguments + --> PYI011.pyi:159:14 | 157 | def f37( 158 | *, 159 | x: str = "" # Error PYI011 Only simple default values allowed for typed arguments | ______________^ 160 | | + "", - | |________^ PYI011 + | |________^ 161 | ) -> None: ... | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 156 156 | ) -> None: ... diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap index 580d853e1f..874cc0c640 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI012.pyi:5:5: PYI012 [*] Class body must not contain `pass` +PYI012 [*] Class body must not contain `pass` + --> PYI012.pyi:5:5 | 3 | class OneAttributeClass: 4 | value: int 5 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 + | ^^^^ 6 | 7 | class OneAttributeClassRev: | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 2 2 | @@ -21,14 +22,15 @@ PYI012.pyi:5:5: PYI012 [*] Class body must not contain `pass` 7 6 | class OneAttributeClassRev: 8 7 | pass # PYI012 Class body must not contain `pass` -PYI012.pyi:8:5: PYI012 [*] Class body must not contain `pass` +PYI012 [*] Class body must not contain `pass` + --> PYI012.pyi:8:5 | 7 | class OneAttributeClassRev: 8 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 + | ^^^^ 9 | value: int | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 5 5 | pass # PYI012 Class body must not contain `pass` @@ -39,16 +41,17 @@ PYI012.pyi:8:5: PYI012 [*] Class body must not contain `pass` 10 9 | 11 10 | class DocstringClass: -PYI012.pyi:16:5: PYI012 [*] Class body must not contain `pass` +PYI012 [*] Class body must not contain `pass` + --> PYI012.pyi:16:5 | 14 | """ 15 | 16 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 + | ^^^^ 17 | 18 | class NonEmptyChild(Exception): | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 13 13 | My body only contains pass. @@ -59,16 +62,17 @@ PYI012.pyi:16:5: PYI012 [*] Class body must not contain `pass` 18 17 | class NonEmptyChild(Exception): 19 18 | value: int -PYI012.pyi:20:5: PYI012 [*] Class body must not contain `pass` +PYI012 [*] Class body must not contain `pass` + --> PYI012.pyi:20:5 | 18 | class NonEmptyChild(Exception): 19 | value: int 20 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 + | ^^^^ 21 | 22 | class NonEmptyChild2(Exception): | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 17 17 | @@ -79,14 +83,15 @@ PYI012.pyi:20:5: PYI012 [*] Class body must not contain `pass` 22 21 | class NonEmptyChild2(Exception): 23 22 | pass # PYI012 Class body must not contain `pass` -PYI012.pyi:23:5: PYI012 [*] Class body must not contain `pass` +PYI012 [*] Class body must not contain `pass` + --> PYI012.pyi:23:5 | 22 | class NonEmptyChild2(Exception): 23 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 + | ^^^^ 24 | value: int | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 20 20 | pass # PYI012 Class body must not contain `pass` @@ -97,16 +102,17 @@ PYI012.pyi:23:5: PYI012 [*] Class body must not contain `pass` 25 24 | 26 25 | class NonEmptyWithInit: -PYI012.pyi:28:5: PYI012 [*] Class body must not contain `pass` +PYI012 [*] Class body must not contain `pass` + --> PYI012.pyi:28:5 | 26 | class NonEmptyWithInit: 27 | value: int 28 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 + | ^^^^ 29 | 30 | def __init__(): | - = help: Remove unnecessary `pass` +help: Remove unnecessary `pass` ℹ Safe fix 25 25 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap index 67c3e98e37..c9e96ca5b3 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI013.py:3:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:3:5 | 1 | class OneAttributeClass: 2 | value: int 3 | ... - | ^^^ PYI013 + | ^^^ | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 1 1 | class OneAttributeClass: @@ -18,14 +19,15 @@ PYI013.py:3:5: PYI013 [*] Non-empty class body must not contain `...` 5 4 | 6 5 | class OneAttributeClass2: -PYI013.py:7:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:7:5 | 6 | class OneAttributeClass2: 7 | ... - | ^^^ PYI013 + | ^^^ 8 | value: int | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 4 4 | @@ -36,14 +38,15 @@ PYI013.py:7:5: PYI013 [*] Non-empty class body must not contain `...` 9 8 | 10 9 | -PYI013.py:12:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:12:5 | 11 | class TwoEllipsesClass: 12 | ... - | ^^^ PYI013 + | ^^^ 13 | ... | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 10 10 | @@ -54,14 +57,15 @@ PYI013.py:12:5: PYI013 [*] Non-empty class body must not contain `...` 15 14 | 16 15 | class DocstringClass: -PYI013.py:13:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:13:5 | 11 | class TwoEllipsesClass: 12 | ... 13 | ... - | ^^^ PYI013 + | ^^^ | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 10 10 | @@ -72,14 +76,15 @@ PYI013.py:13:5: PYI013 [*] Non-empty class body must not contain `...` 15 14 | 16 15 | class DocstringClass: -PYI013.py:21:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:21:5 | 19 | """ 20 | 21 | ... - | ^^^ PYI013 + | ^^^ | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 18 18 | My body only contains an ellipsis. @@ -90,14 +95,15 @@ PYI013.py:21:5: PYI013 [*] Non-empty class body must not contain `...` 23 22 | 24 23 | class NonEmptyChild(Exception): -PYI013.py:26:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:26:5 | 24 | class NonEmptyChild(Exception): 25 | value: int 26 | ... - | ^^^ PYI013 + | ^^^ | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 23 23 | @@ -108,14 +114,15 @@ PYI013.py:26:5: PYI013 [*] Non-empty class body must not contain `...` 28 27 | 29 28 | class NonEmptyChild2(Exception): -PYI013.py:30:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:30:5 | 29 | class NonEmptyChild2(Exception): 30 | ... - | ^^^ PYI013 + | ^^^ 31 | value: int | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 27 27 | @@ -126,16 +133,17 @@ PYI013.py:30:5: PYI013 [*] Non-empty class body must not contain `...` 32 31 | 33 32 | -PYI013.py:36:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:36:5 | 34 | class NonEmptyWithInit: 35 | value: int 36 | ... - | ^^^ PYI013 + | ^^^ 37 | 38 | def __init__(): | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 33 33 | @@ -146,14 +154,15 @@ PYI013.py:36:5: PYI013 [*] Non-empty class body must not contain `...` 38 37 | def __init__(): 39 38 | pass -PYI013.py:44:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.py:44:5 | 42 | class NonEmptyChildWithInlineComment: 43 | value: int 44 | ... # preserve me - | ^^^ PYI013 + | ^^^ | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 41 41 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap index b897ba3d20..0c8e65f7bf 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI013.pyi:5:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:5:5 | 3 | class OneAttributeClass: 4 | value: int 5 | ... # Error - | ^^^ PYI013 + | ^^^ 6 | 7 | class OneAttributeClass2: | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 2 2 | @@ -22,14 +23,15 @@ PYI013.pyi:5:5: PYI013 [*] Non-empty class body must not contain `...` 7 7 | class OneAttributeClass2: 8 8 | ... # Error -PYI013.pyi:8:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:8:5 | 7 | class OneAttributeClass2: 8 | ... # Error - | ^^^ PYI013 + | ^^^ 9 | value: int | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 5 5 | ... # Error @@ -41,14 +43,15 @@ PYI013.pyi:8:5: PYI013 [*] Non-empty class body must not contain `...` 10 10 | 11 11 | class MyClass: -PYI013.pyi:12:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:12:5 | 11 | class MyClass: 12 | ... - | ^^^ PYI013 + | ^^^ 13 | value: int | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 9 9 | value: int @@ -59,14 +62,15 @@ PYI013.pyi:12:5: PYI013 [*] Non-empty class body must not contain `...` 14 13 | 15 14 | class TwoEllipsesClass: -PYI013.pyi:16:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:16:5 | 15 | class TwoEllipsesClass: 16 | ... - | ^^^ PYI013 + | ^^^ 17 | ... # Error | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 13 13 | value: int @@ -77,16 +81,17 @@ PYI013.pyi:16:5: PYI013 [*] Non-empty class body must not contain `...` 18 17 | 19 18 | class DocstringClass: -PYI013.pyi:17:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:17:5 | 15 | class TwoEllipsesClass: 16 | ... 17 | ... # Error - | ^^^ PYI013 + | ^^^ 18 | 19 | class DocstringClass: | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 14 14 | @@ -98,16 +103,17 @@ PYI013.pyi:17:5: PYI013 [*] Non-empty class body must not contain `...` 19 19 | class DocstringClass: 20 20 | """ -PYI013.pyi:24:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:24:5 | 22 | """ 23 | 24 | ... # Error - | ^^^ PYI013 + | ^^^ 25 | 26 | class NonEmptyChild(Exception): | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 21 21 | My body only contains an ellipsis. @@ -119,16 +125,17 @@ PYI013.pyi:24:5: PYI013 [*] Non-empty class body must not contain `...` 26 26 | class NonEmptyChild(Exception): 27 27 | value: int -PYI013.pyi:28:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:28:5 | 26 | class NonEmptyChild(Exception): 27 | value: int 28 | ... # Error - | ^^^ PYI013 + | ^^^ 29 | 30 | class NonEmptyChild2(Exception): | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 25 25 | @@ -140,14 +147,15 @@ PYI013.pyi:28:5: PYI013 [*] Non-empty class body must not contain `...` 30 30 | class NonEmptyChild2(Exception): 31 31 | ... # Error -PYI013.pyi:31:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:31:5 | 30 | class NonEmptyChild2(Exception): 31 | ... # Error - | ^^^ PYI013 + | ^^^ 32 | value: int | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 28 28 | ... # Error @@ -159,16 +167,17 @@ PYI013.pyi:31:5: PYI013 [*] Non-empty class body must not contain `...` 33 33 | 34 34 | class NonEmptyWithInit: -PYI013.pyi:36:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:36:5 | 34 | class NonEmptyWithInit: 35 | value: int 36 | ... # Error - | ^^^ PYI013 + | ^^^ 37 | 38 | def __init__(): | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 33 33 | @@ -180,16 +189,17 @@ PYI013.pyi:36:5: PYI013 [*] Non-empty class body must not contain `...` 38 38 | def __init__(): 39 39 | pass -PYI013.pyi:43:5: PYI013 [*] Non-empty class body must not contain `...` +PYI013 [*] Non-empty class body must not contain `...` + --> PYI013.pyi:43:5 | 41 | class NonEmptyChildWithInlineComment: 42 | value: int 43 | ... # preserve me - | ^^^ PYI013 + | ^^^ 44 | 45 | # Not violations | - = help: Remove unnecessary `...` +help: Remove unnecessary `...` ℹ Safe fix 40 40 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap index fdba744bde..d236b3a61a 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI014.pyi:3:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:3:7 | 1 | def f12( 2 | x, 3 | y=os.pathsep, # Error PYI014 - | ^^^^^^^^^^ PYI014 + | ^^^^^^^^^^ 4 | ) -> None: ... 5 | def f11(*, x="x") -> None: ... # OK | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 1 1 | def f12( @@ -22,7 +22,8 @@ PYI014.pyi:3:7: PYI014 [*] Only simple default values allowed for arguments 5 5 | def f11(*, x="x") -> None: ... # OK 6 6 | def f13( -PYI014.pyi:29:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:29:7 | 27 | def f151(x={1: 2}) -> None: ... 28 | def f152( @@ -31,11 +32,11 @@ PYI014.pyi:29:7: PYI014 [*] Only simple default values allowed for arguments 30 | | 1: 2, 31 | | **{3: 4}, 32 | | } - | |_____^ PYI014 + | |_____^ 33 | ) -> None: ... 34 | def f153( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 26 26 | ) -> None: ... @@ -50,7 +51,8 @@ PYI014.pyi:29:7: PYI014 [*] Only simple default values allowed for arguments 34 31 | def f153( 35 32 | x=[ # Error PYI014 -PYI014.pyi:35:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:35:7 | 33 | ) -> None: ... 34 | def f153( @@ -68,11 +70,11 @@ PYI014.pyi:35:7: PYI014 [*] Only simple default values allowed for arguments 45 | | 10, 46 | | 11, 47 | | ] - | |_____^ PYI014 + | |_____^ 48 | ) -> None: ... 49 | def f154( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 32 32 | } @@ -96,7 +98,8 @@ PYI014.pyi:35:7: PYI014 [*] Only simple default values allowed for arguments 49 37 | def f154( 50 38 | x=( # Error PYI014 -PYI014.pyi:50:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:50:7 | 48 | ) -> None: ... 49 | def f154( @@ -105,11 +108,11 @@ PYI014.pyi:50:7: PYI014 [*] Only simple default values allowed for arguments 51 | | "foo", 52 | | ("bar", "baz"), 53 | | ) - | |_____^ PYI014 + | |_____^ 54 | ) -> None: ... 55 | def f141( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 47 47 | ] @@ -124,16 +127,17 @@ PYI014.pyi:50:7: PYI014 [*] Only simple default values allowed for arguments 55 52 | def f141( 56 53 | x=[*range(10)], # Error PYI014 -PYI014.pyi:56:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:56:7 | 54 | ) -> None: ... 55 | def f141( 56 | x=[*range(10)], # Error PYI014 - | ^^^^^^^^^^^^ PYI014 + | ^^^^^^^^^^^^ 57 | ) -> None: ... 58 | def f142( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 53 53 | ) @@ -145,16 +149,17 @@ PYI014.pyi:56:7: PYI014 [*] Only simple default values allowed for arguments 58 58 | def f142( 59 59 | x=list(range(10)), # Error PYI014 -PYI014.pyi:59:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:59:7 | 57 | ) -> None: ... 58 | def f142( 59 | x=list(range(10)), # Error PYI014 - | ^^^^^^^^^^^^^^^ PYI014 + | ^^^^^^^^^^^^^^^ 60 | ) -> None: ... 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 56 56 | x=[*range(10)], # Error PYI014 @@ -166,16 +171,17 @@ PYI014.pyi:59:7: PYI014 [*] Only simple default values allowed for arguments 61 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 62 62 | def f17( -PYI014.pyi:61:11: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:61:11 | 59 | x=list(range(10)), # Error PYI014 60 | ) -> None: ... 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI014 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 62 | def f17( 63 | x="foo" + "bar", # Error PYI014 | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 58 58 | def f142( @@ -187,16 +193,17 @@ PYI014.pyi:61:11: PYI014 [*] Only simple default values allowed for arguments 63 63 | x="foo" + "bar", # Error PYI014 64 64 | ) -> None: ... -PYI014.pyi:63:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:63:7 | 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 62 | def f17( 63 | x="foo" + "bar", # Error PYI014 - | ^^^^^^^^^^^^^ PYI014 + | ^^^^^^^^^^^^^ 64 | ) -> None: ... 65 | def f18( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 60 60 | ) -> None: ... @@ -208,16 +215,17 @@ PYI014.pyi:63:7: PYI014 [*] Only simple default values allowed for arguments 65 65 | def f18( 66 66 | x=b"foo" + b"bar", # Error PYI014 -PYI014.pyi:66:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:66:7 | 64 | ) -> None: ... 65 | def f18( 66 | x=b"foo" + b"bar", # Error PYI014 - | ^^^^^^^^^^^^^^^ PYI014 + | ^^^^^^^^^^^^^^^ 67 | ) -> None: ... 68 | def f19( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 63 63 | x="foo" + "bar", # Error PYI014 @@ -229,16 +237,17 @@ PYI014.pyi:66:7: PYI014 [*] Only simple default values allowed for arguments 68 68 | def f19( 69 69 | x="foo" + 4, # Error PYI014 -PYI014.pyi:69:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:69:7 | 67 | ) -> None: ... 68 | def f19( 69 | x="foo" + 4, # Error PYI014 - | ^^^^^^^^^ PYI014 + | ^^^^^^^^^ 70 | ) -> None: ... 71 | def f20( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 66 66 | x=b"foo" + b"bar", # Error PYI014 @@ -250,16 +259,17 @@ PYI014.pyi:69:7: PYI014 [*] Only simple default values allowed for arguments 71 71 | def f20( 72 72 | x=5 + 5, # Error PYI014 -PYI014.pyi:72:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:72:7 | 70 | ) -> None: ... 71 | def f20( 72 | x=5 + 5, # Error PYI014 - | ^^^^^ PYI014 + | ^^^^^ 73 | ) -> None: ... 74 | def f21( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 69 69 | x="foo" + 4, # Error PYI014 @@ -271,16 +281,17 @@ PYI014.pyi:72:7: PYI014 [*] Only simple default values allowed for arguments 74 74 | def f21( 75 75 | x=3j - 3j, # Error PYI014 -PYI014.pyi:75:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:75:7 | 73 | ) -> None: ... 74 | def f21( 75 | x=3j - 3j, # Error PYI014 - | ^^^^^^^ PYI014 + | ^^^^^^^ 76 | ) -> None: ... 77 | def f22( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 72 72 | x=5 + 5, # Error PYI014 @@ -292,16 +303,17 @@ PYI014.pyi:75:7: PYI014 [*] Only simple default values allowed for arguments 77 77 | def f22( 78 78 | x=-42.5j + 4.3j, # Error PYI014 -PYI014.pyi:78:7: PYI014 [*] Only simple default values allowed for arguments +PYI014 [*] Only simple default values allowed for arguments + --> PYI014.pyi:78:7 | 76 | ) -> None: ... 77 | def f22( 78 | x=-42.5j + 4.3j, # Error PYI014 - | ^^^^^^^^^^^^^ PYI014 + | ^^^^^^^^^^^^^ 79 | ) -> None: ... 80 | def f23( | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 75 75 | x=3j - 3j, # Error PYI014 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap index 120743179f..6bdd007b88 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI015.pyi:44:23: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:44:23 | 43 | # We *should* emit Y015 for more complex default values 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 41 41 | field22: Final = {"foo": 5} @@ -21,16 +22,17 @@ PYI015.pyi:44:23: PYI015 [*] Only simple default values allowed for assignments 46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments 47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -PYI015.pyi:45:23: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:45:23 | 43 | # We *should* emit Y015 for more complex default values 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^^ 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 42 42 | @@ -42,16 +44,17 @@ PYI015.pyi:45:23: PYI015 [*] Only simple default values allowed for assignments 47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments 48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments -PYI015.pyi:46:23: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:46:23 | 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^^^^^ 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 43 43 | # We *should* emit Y015 for more complex default values @@ -63,16 +66,17 @@ PYI015.pyi:46:23: PYI015 [*] Only simple default values allowed for assignments 48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments 49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments -PYI015.pyi:47:26: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:47:26 | 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^ PYI015 + | ^^^^^^^^^^ 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments @@ -84,16 +88,17 @@ PYI015.pyi:47:26: PYI015 [*] Only simple default values allowed for assignments 49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments 50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments -PYI015.pyi:48:47: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:48:47 | 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^^^^^^^^^^^^^ 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments @@ -105,16 +110,17 @@ PYI015.pyi:48:47: PYI015 [*] Only simple default values allowed for assignments 50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments 51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -PYI015.pyi:49:31: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:49:31 | 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^^^^^^^^^^^^^ 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments @@ -126,16 +132,17 @@ PYI015.pyi:49:31: PYI015 [*] Only simple default values allowed for assignments 51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node 52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments -PYI015.pyi:50:37: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:50:37 | 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^ 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments @@ -147,16 +154,17 @@ PYI015.pyi:50:37: PYI015 [*] Only simple default values allowed for assignments 52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments 53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments -PYI015.pyi:52:28: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:52:28 | 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^^^^^^ 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments @@ -168,16 +176,17 @@ PYI015.pyi:52:28: PYI015 [*] Only simple default values allowed for assignments 54 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments 55 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments -PYI015.pyi:53:11: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:53:11 | 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^^^ 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments @@ -189,15 +198,16 @@ PYI015.pyi:53:11: PYI015 [*] Only simple default values allowed for assignments 55 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments 56 56 | -PYI015.pyi:54:11: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:54:11 | 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^ PYI015 + | ^^^^^^^^^^^^^^^ 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node @@ -209,16 +219,17 @@ PYI015.pyi:54:11: PYI015 [*] Only simple default values allowed for assignments 56 56 | 57 57 | # We shouldn't emit Y015 within functions -PYI015.pyi:55:11: PYI015 [*] Only simple default values allowed for assignments +PYI015 [*] Only simple default values allowed for assignments + --> PYI015.pyi:55:11 | 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments - | ^^^^^ PYI015 + | ^^^^^ 56 | 57 | # We shouldn't emit Y015 within functions | - = help: Replace default value with `...` +help: Replace default value with `...` ℹ Safe fix 52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap index 62c0d69f78..ad83ac3daa 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI016.py:7:15: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:7:15 | 6 | # Should emit for duplicate field types. 7 | field2: str | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 8 | 9 | # Should emit for union types in arguments. | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 4 4 | field1: str @@ -21,14 +22,15 @@ PYI016.py:7:15: PYI016 [*] Duplicate union member `str` 9 9 | # Should emit for union types in arguments. 10 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` -PYI016.py:10:23: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:10:23 | 9 | # Should emit for union types in arguments. 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 11 | print(arg1) | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 7 7 | field2: str | str # PYI016: Duplicate union member `str` @@ -40,14 +42,15 @@ PYI016.py:10:23: PYI016 [*] Duplicate union member `int` 12 12 | 13 13 | # Should emit for unions in return types. -PYI016.py:14:22: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:14:22 | 13 | # Should emit for unions in return types. 14 | def func2() -> str | str: # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 15 | return "my string" | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 11 11 | print(arg1) @@ -59,15 +62,16 @@ PYI016.py:14:22: PYI016 [*] Duplicate union member `str` 16 16 | 17 17 | # Should emit in longer unions, even if not directly adjacent. -PYI016.py:18:15: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:18:15 | 17 | # Should emit in longer unions, even if not directly adjacent. 18 | field3: str | str | int # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 15 15 | return "my string" @@ -79,16 +83,17 @@ PYI016.py:18:15: PYI016 [*] Duplicate union member `str` 20 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` -PYI016.py:19:15: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:19:15 | 17 | # Should emit in longer unions, even if not directly adjacent. 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 | field4: int | int | str # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 16 16 | @@ -100,15 +105,16 @@ PYI016.py:19:15: PYI016 [*] Duplicate union member `int` 21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` 22 22 | -PYI016.py:20:21: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:20:21 | 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 17 17 | # Should emit in longer unions, even if not directly adjacent. @@ -120,16 +126,17 @@ PYI016.py:20:21: PYI016 [*] Duplicate union member `str` 22 22 | 23 23 | # Shouldn't emit for non-type unions. -PYI016.py:21:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:21:28 | 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 22 | 23 | # Shouldn't emit for non-type unions. | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` @@ -141,15 +148,16 @@ PYI016.py:21:28: PYI016 [*] Duplicate union member `int` 23 23 | # Shouldn't emit for non-type unions. 24 24 | field7 = str | str -PYI016.py:27:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:27:22 | 26 | # Should emit for strangely-bracketed unions. 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 28 | 29 | # Should handle user brackets when fixing. | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 24 24 | field7 = str | str @@ -161,14 +169,15 @@ PYI016.py:27:22: PYI016 [*] Duplicate union member `int` 29 29 | # Should handle user brackets when fixing. 30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` -PYI016.py:30:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:30:16 | 29 | # Should handle user brackets when fixing. 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` @@ -180,16 +189,17 @@ PYI016.py:30:16: PYI016 [*] Duplicate union member `int` 32 32 | 33 33 | # Should emit for nested unions. -PYI016.py:31:24: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:31:24 | 29 | # Should handle user brackets when fixing. 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 32 | 33 | # Should emit for nested unions. | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 28 28 | @@ -201,15 +211,16 @@ PYI016.py:31:24: PYI016 [*] Duplicate union member `str` 33 33 | # Should emit for nested unions. 34 34 | field11: dict[int | int, str] -PYI016.py:34:21: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:34:21 | 33 | # Should emit for nested unions. 34 | field11: dict[int | int, str] - | ^^^ PYI016 + | ^^^ 35 | 36 | # Should emit for unions with more than two cases | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` @@ -221,14 +232,15 @@ PYI016.py:34:21: PYI016 [*] Duplicate union member `int` 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error -PYI016.py:37:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:37:16 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error - | ^^^ PYI016 + | ^^^ 38 | field13: int | int | int | int # Error | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 34 34 | field11: dict[int | int, str] @@ -240,14 +252,15 @@ PYI016.py:37:16: PYI016 [*] Duplicate union member `int` 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI016.py:37:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:37:22 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error - | ^^^ PYI016 + | ^^^ 38 | field13: int | int | int | int # Error | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 34 34 | field11: dict[int | int, str] @@ -259,16 +272,17 @@ PYI016.py:37:22: PYI016 [*] Duplicate union member `int` 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI016.py:38:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:38:16 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -280,16 +294,17 @@ PYI016.py:38:16: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.py:38:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:38:22 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -301,16 +316,17 @@ PYI016.py:38:22: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.py:38:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:38:28 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -322,15 +338,16 @@ PYI016.py:38:28: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.py:41:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:41:16 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error - | ^^^ PYI016 + | ^^^ 42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 38 38 | field13: int | int | int | int # Error @@ -342,15 +359,16 @@ PYI016.py:41:16: PYI016 [*] Duplicate union member `int` 43 43 | # Should emit for duplicate literal types; also covered by PYI030 44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error -PYI016.py:41:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:41:28 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error - | ^^^ PYI016 + | ^^^ 42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 38 38 | field13: int | int | int | int # Error @@ -362,15 +380,16 @@ PYI016.py:41:28: PYI016 [*] Duplicate union member `int` 43 43 | # Should emit for duplicate literal types; also covered by PYI030 44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error -PYI016.py:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` +PYI016 [*] Duplicate union member `typing.Literal[1]` + --> PYI016.py:44:30 | 43 | # Should emit for duplicate literal types; also covered by PYI030 44 | field15: typing.Literal[1] | typing.Literal[1] # Error - | ^^^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^^^ 45 | 46 | # Shouldn't emit if in new parent type | - = help: Remove duplicate union member `typing.Literal[1]` +help: Remove duplicate union member `typing.Literal[1]` ℹ Safe fix 41 41 | field14: int | int | str | int # Error @@ -382,17 +401,18 @@ PYI016.py:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` 46 46 | # Shouldn't emit if in new parent type 47 47 | field16: int | dict[int, str] # OK -PYI016.py:57:5: PYI016 [*] Duplicate union member `set[int]` +PYI016 [*] Duplicate union member `set[int]` + --> PYI016.py:57:5 | 55 | int # foo 56 | ], 57 | / set[ 58 | | int # bar 59 | | ], - | |_____^ PYI016 + | |_____^ 60 | ] # Error, newline and comment will not be emitted in message | - = help: Remove duplicate union member `set[int]` +help: Remove duplicate union member `set[int]` ℹ Unsafe fix 50 50 | field17: dict[int, int] # OK @@ -411,15 +431,16 @@ PYI016.py:57:5: PYI016 [*] Duplicate union member `set[int]` 62 55 | # Should emit in cases with `typing.Union` instead of `|` 63 56 | field19: typing.Union[int, int] # Error -PYI016.py:63:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:63:28 | 62 | # Should emit in cases with `typing.Union` instead of `|` 63 | field19: typing.Union[int, int] # Error - | ^^^ PYI016 + | ^^^ 64 | 65 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 60 60 | ] # Error, newline and comment will not be emitted in message @@ -431,15 +452,16 @@ PYI016.py:63:28: PYI016 [*] Duplicate union member `int` 65 65 | # Should emit in cases with nested `typing.Union` 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error -PYI016.py:66:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:66:41 | 65 | # Should emit in cases with nested `typing.Union` 66 | field20: typing.Union[int, typing.Union[int, str]] # Error - | ^^^ PYI016 + | ^^^ 67 | 68 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 63 63 | field19: typing.Union[int, int] # Error @@ -451,15 +473,16 @@ PYI016.py:66:41: PYI016 [*] Duplicate union member `int` 68 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 69 | field21: typing.Union[int, int | str] # Error -PYI016.py:69:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:69:28 | 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 | field21: typing.Union[int, int | str] # Error - | ^^^ PYI016 + | ^^^ 70 | 71 | # Should emit only once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error @@ -471,15 +494,16 @@ PYI016.py:69:28: PYI016 [*] Duplicate union member `int` 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error -PYI016.py:72:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:72:41 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -491,15 +515,16 @@ PYI016.py:72:41: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.py:72:59: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:72:59 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -511,15 +536,16 @@ PYI016.py:72:59: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.py:72:64: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:72:64 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -531,16 +557,17 @@ PYI016.py:72:64: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]` +PYI016 [*] Duplicate union member `set[int]` + --> PYI016.py:76:12 | 74 | # Should emit in cases with newlines 75 | field23: set[ # foo 76 | int] | set[int] - | ^^^^^^^^ PYI016 + | ^^^^^^^^ 77 | 78 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `set[int]` +help: Remove duplicate union member `set[int]` ℹ Unsafe fix 72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error @@ -553,16 +580,17 @@ PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]` 78 77 | # Should emit twice (once for each `int` in the nested union, both of which are 79 78 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.py:81:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:81:41 | 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 78 78 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -574,16 +602,17 @@ PYI016.py:81:41: PYI016 [*] Duplicate union member `int` 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.py:81:46: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:81:46 | 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 78 78 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -595,16 +624,17 @@ PYI016.py:81:46: PYI016 [*] Duplicate union member `int` 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.py:86:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:86:28 | 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 87 | 88 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -616,16 +646,17 @@ PYI016.py:86:28: PYI016 [*] Duplicate union member `int` 88 88 | # Should emit in cases with nested `typing.Union` 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` -PYI016.py:86:34: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:86:34 | 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 87 | 88 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -637,15 +668,16 @@ PYI016.py:86:34: PYI016 [*] Duplicate union member `int` 88 88 | # Should emit in cases with nested `typing.Union` 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` -PYI016.py:89:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:89:41 | 88 | # Should emit in cases with nested `typing.Union` 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 90 | 91 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 86 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` @@ -657,15 +689,16 @@ PYI016.py:89:41: PYI016 [*] Duplicate union member `int` 91 91 | # Should emit in cases with nested `typing.Union` 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` -PYI016.py:92:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:92:54 | 91 | # Should emit in cases with nested `typing.Union` 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 93 | 94 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` @@ -677,15 +710,16 @@ PYI016.py:92:54: PYI016 [*] Duplicate union member `int` 94 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 95 | field28: typing.Union[int | int] # Error -PYI016.py:95:29: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:95:29 | 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 | field28: typing.Union[int | int] # Error - | ^^^ PYI016 + | ^^^ 96 | 97 | # Should emit twice in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` @@ -697,15 +731,16 @@ PYI016.py:95:29: PYI016 [*] Duplicate union member `int` 97 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error -PYI016.py:98:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:98:54 | 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 95 95 | field28: typing.Union[int | int] # Error @@ -717,15 +752,16 @@ PYI016.py:98:54: PYI016 [*] Duplicate union member `int` 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error -PYI016.py:98:59: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:98:59 | 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 95 95 | field28: typing.Union[int | int] # Error @@ -737,15 +773,16 @@ PYI016.py:98:59: PYI016 [*] Duplicate union member `int` 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error -PYI016.py:101:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:101:54 | 100 | # Should emit once in cases with multiple nested `typing.Union` 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error - | ^^^ PYI016 + | ^^^ 102 | 103 | # Should emit once, and fix to `typing.Union[float, int]` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error @@ -757,15 +794,16 @@ PYI016.py:101:54: PYI016 [*] Duplicate union member `int` 103 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error -PYI016.py:104:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:104:49 | 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 | field31: typing.Union[float, typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 105 | 106 | # Should emit once, and fix to `typing.Union[float, int]` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error @@ -777,15 +815,16 @@ PYI016.py:104:49: PYI016 [*] Duplicate union member `int` 106 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error -PYI016.py:107:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:107:49 | 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error - | ^^^ PYI016 + | ^^^ 108 | 109 | # Test case for mixed union type fix | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error @@ -797,15 +836,16 @@ PYI016.py:107:49: PYI016 [*] Duplicate union member `int` 109 109 | # Test case for mixed union type fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error -PYI016.py:107:55: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:107:55 | 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error - | ^^^ PYI016 + | ^^^ 108 | 109 | # Test case for mixed union type fix | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error @@ -817,15 +857,16 @@ PYI016.py:107:55: PYI016 [*] Duplicate union member `int` 109 109 | # Test case for mixed union type fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error -PYI016.py:110:42: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:110:42 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -837,15 +878,16 @@ PYI016.py:110:42: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.py:110:62: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:110:62 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -857,15 +899,16 @@ PYI016.py:110:62: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.py:110:68: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:110:68 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -877,15 +920,16 @@ PYI016.py:110:68: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.py:113:61: PYI016 [*] Duplicate union member `list[int]` +PYI016 [*] Duplicate union member `list[int]` + --> PYI016.py:113:61 | 112 | # Test case for mixed union type 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error - | ^^^^^^^^^ PYI016 + | ^^^^^^^^^ 114 | 115 | field35: "int | str | int" # Error | - = help: Remove duplicate union member `list[int]` +help: Remove duplicate union member `list[int]` ℹ Safe fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error @@ -897,14 +941,15 @@ PYI016.py:113:61: PYI016 [*] Duplicate union member `list[int]` 115 115 | field35: "int | str | int" # Error 116 116 | -PYI016.py:115:23: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:115:23 | 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error 114 | 115 | field35: "int | str | int" # Error - | ^^^ PYI016 + | ^^^ | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 112 112 | # Test case for mixed union type @@ -916,16 +961,17 @@ PYI016.py:115:23: PYI016 [*] Duplicate union member `int` 117 117 | 118 118 | -PYI016.py:134:45: PYI016 [*] Duplicate union member `typing.Optional[int]` +PYI016 [*] Duplicate union member `typing.Optional[int]` + --> PYI016.py:134:45 | 132 | field40: typing.Union[typing.Optional[int], None] 133 | field41: typing.Optional[typing.Union[int, None]] 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] - | ^^^^^^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^^^^^^ 135 | field43: typing.Optional[int] | None 136 | field44: typing.Optional[int | None] | - = help: Remove duplicate union member `typing.Optional[int]` +help: Remove duplicate union member `typing.Optional[int]` ℹ Safe fix 131 131 | # equivalent to int | None @@ -937,16 +983,17 @@ PYI016.py:134:45: PYI016 [*] Duplicate union member `typing.Optional[int]` 136 136 | field44: typing.Optional[int | None] 137 137 | field45: typing.Optional[int] | typing.Optional[int] -PYI016.py:137:33: PYI016 [*] Duplicate union member `typing.Optional[int]` +PYI016 [*] Duplicate union member `typing.Optional[int]` + --> PYI016.py:137:33 | 135 | field43: typing.Optional[int] | None 136 | field44: typing.Optional[int | None] 137 | field45: typing.Optional[int] | typing.Optional[int] - | ^^^^^^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^^^^^^ 138 | # equivalent to int | dict | None 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] | - = help: Remove duplicate union member `typing.Optional[int]` +help: Remove duplicate union member `typing.Optional[int]` ℹ Safe fix 134 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] @@ -958,14 +1005,15 @@ PYI016.py:137:33: PYI016 [*] Duplicate union member `typing.Optional[int]` 139 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] 140 140 | field47: typing.Optional[int] | typing.Optional[dict] -PYI016.py:143:61: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.py:143:61 | 142 | # avoid reporting twice 143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] - | ^^^^^^^ PYI016 + | ^^^^^^^ 144 | field49: typing.Optional[complex | complex] | complex | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 140 140 | field47: typing.Optional[int] | typing.Optional[dict] @@ -977,16 +1025,17 @@ PYI016.py:143:61: PYI016 [*] Duplicate union member `complex` 145 145 | 146 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 -PYI016.py:144:36: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.py:144:36 | 142 | # avoid reporting twice 143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] 144 | field49: typing.Optional[complex | complex] | complex - | ^^^^^^^ PYI016 + | ^^^^^^^ 145 | 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 141 141 | @@ -998,11 +1047,12 @@ PYI016.py:144:36: PYI016 [*] Duplicate union member `complex` 146 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 147 147 | # Should throw duplicate union member but not fix -PYI016.py:148:37: PYI016 Duplicate union member `None` +PYI016 Duplicate union member `None` + --> PYI016.py:148:37 | 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 147 | # Should throw duplicate union member but not fix 148 | isinstance(None, typing.Union[None, None]) - | ^^^^ PYI016 + | ^^^^ | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap index cd37334068..a90d84ca63 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI016.pyi:7:15: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:7:15 | 6 | # Should emit for duplicate field types. 7 | field2: str | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 8 | 9 | # Should emit for union types in arguments. | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 4 4 | field1: str @@ -21,14 +22,15 @@ PYI016.pyi:7:15: PYI016 [*] Duplicate union member `str` 9 9 | # Should emit for union types in arguments. 10 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` -PYI016.pyi:10:23: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:10:23 | 9 | # Should emit for union types in arguments. 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 11 | print(arg1) | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 7 7 | field2: str | str # PYI016: Duplicate union member `str` @@ -40,14 +42,15 @@ PYI016.pyi:10:23: PYI016 [*] Duplicate union member `int` 12 12 | 13 13 | # Should emit for unions in return types. -PYI016.pyi:14:22: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:14:22 | 13 | # Should emit for unions in return types. 14 | def func2() -> str | str: # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 15 | return "my string" | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 11 11 | print(arg1) @@ -59,15 +62,16 @@ PYI016.pyi:14:22: PYI016 [*] Duplicate union member `str` 16 16 | 17 17 | # Should emit in longer unions, even if not directly adjacent. -PYI016.pyi:18:15: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:18:15 | 17 | # Should emit in longer unions, even if not directly adjacent. 18 | field3: str | str | int # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 15 15 | return "my string" @@ -79,16 +83,17 @@ PYI016.pyi:18:15: PYI016 [*] Duplicate union member `str` 20 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` -PYI016.pyi:19:15: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:19:15 | 17 | # Should emit in longer unions, even if not directly adjacent. 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 | field4: int | int | str # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 16 16 | @@ -100,15 +105,16 @@ PYI016.pyi:19:15: PYI016 [*] Duplicate union member `int` 21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` 22 22 | -PYI016.pyi:20:21: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:20:21 | 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 17 17 | # Should emit in longer unions, even if not directly adjacent. @@ -120,16 +126,17 @@ PYI016.pyi:20:21: PYI016 [*] Duplicate union member `str` 22 22 | 23 23 | # Shouldn't emit for non-type unions. -PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:21:28 | 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 22 | 23 | # Shouldn't emit for non-type unions. | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` @@ -141,15 +148,16 @@ PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int` 23 23 | # Shouldn't emit for non-type unions. 24 24 | field7 = str | str -PYI016.pyi:27:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:27:22 | 26 | # Should emit for strangely-bracketed unions. 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 28 | 29 | # Should handle user brackets when fixing. | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 24 24 | field7 = str | str @@ -161,14 +169,15 @@ PYI016.pyi:27:22: PYI016 [*] Duplicate union member `int` 29 29 | # Should handle user brackets when fixing. 30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` -PYI016.pyi:30:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:30:16 | 29 | # Should handle user brackets when fixing. 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` @@ -180,16 +189,17 @@ PYI016.pyi:30:16: PYI016 [*] Duplicate union member `int` 32 32 | 33 33 | # Should emit for nested unions. -PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:31:24 | 29 | # Should handle user brackets when fixing. 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 32 | 33 | # Should emit for nested unions. | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 28 28 | @@ -201,15 +211,16 @@ PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str` 33 33 | # Should emit for nested unions. 34 34 | field11: dict[int | int, str] -PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:34:21 | 33 | # Should emit for nested unions. 34 | field11: dict[int | int, str] - | ^^^ PYI016 + | ^^^ 35 | 36 | # Should emit for unions with more than two cases | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` @@ -221,14 +232,15 @@ PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int` 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error -PYI016.pyi:37:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:37:16 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error - | ^^^ PYI016 + | ^^^ 38 | field13: int | int | int | int # Error | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 34 34 | field11: dict[int | int, str] @@ -240,14 +252,15 @@ PYI016.pyi:37:16: PYI016 [*] Duplicate union member `int` 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI016.pyi:37:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:37:22 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error - | ^^^ PYI016 + | ^^^ 38 | field13: int | int | int | int # Error | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 34 34 | field11: dict[int | int, str] @@ -259,16 +272,17 @@ PYI016.pyi:37:22: PYI016 [*] Duplicate union member `int` 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:38:16 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -280,16 +294,17 @@ PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:38:22 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -301,16 +316,17 @@ PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:38:28 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -322,15 +338,16 @@ PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.pyi:41:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:41:16 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error - | ^^^ PYI016 + | ^^^ 42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 38 38 | field13: int | int | int | int # Error @@ -342,15 +359,16 @@ PYI016.pyi:41:16: PYI016 [*] Duplicate union member `int` 43 43 | # Should emit for duplicate literal types; also covered by PYI030 44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error -PYI016.pyi:41:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:41:28 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error - | ^^^ PYI016 + | ^^^ 42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 38 38 | field13: int | int | int | int # Error @@ -362,15 +380,16 @@ PYI016.pyi:41:28: PYI016 [*] Duplicate union member `int` 43 43 | # Should emit for duplicate literal types; also covered by PYI030 44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error -PYI016.pyi:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` +PYI016 [*] Duplicate union member `typing.Literal[1]` + --> PYI016.pyi:44:30 | 43 | # Should emit for duplicate literal types; also covered by PYI030 44 | field15: typing.Literal[1] | typing.Literal[1] # Error - | ^^^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^^^ 45 | 46 | # Shouldn't emit if in new parent type | - = help: Remove duplicate union member `typing.Literal[1]` +help: Remove duplicate union member `typing.Literal[1]` ℹ Safe fix 41 41 | field14: int | int | str | int # Error @@ -382,17 +401,18 @@ PYI016.pyi:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` 46 46 | # Shouldn't emit if in new parent type 47 47 | field16: int | dict[int, str] # OK -PYI016.pyi:57:5: PYI016 [*] Duplicate union member `set[int]` +PYI016 [*] Duplicate union member `set[int]` + --> PYI016.pyi:57:5 | 55 | int # foo 56 | ], 57 | / set[ 58 | | int # bar 59 | | ], - | |_____^ PYI016 + | |_____^ 60 | ] # Error, newline and comment will not be emitted in message | - = help: Remove duplicate union member `set[int]` +help: Remove duplicate union member `set[int]` ℹ Unsafe fix 50 50 | field17: dict[int, int] # OK @@ -411,15 +431,16 @@ PYI016.pyi:57:5: PYI016 [*] Duplicate union member `set[int]` 62 55 | # Should emit in cases with `typing.Union` instead of `|` 63 56 | field19: typing.Union[int, int] # Error -PYI016.pyi:63:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:63:28 | 62 | # Should emit in cases with `typing.Union` instead of `|` 63 | field19: typing.Union[int, int] # Error - | ^^^ PYI016 + | ^^^ 64 | 65 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 60 60 | ] # Error, newline and comment will not be emitted in message @@ -431,15 +452,16 @@ PYI016.pyi:63:28: PYI016 [*] Duplicate union member `int` 65 65 | # Should emit in cases with nested `typing.Union` 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error -PYI016.pyi:66:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:66:41 | 65 | # Should emit in cases with nested `typing.Union` 66 | field20: typing.Union[int, typing.Union[int, str]] # Error - | ^^^ PYI016 + | ^^^ 67 | 68 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 63 63 | field19: typing.Union[int, int] # Error @@ -451,15 +473,16 @@ PYI016.pyi:66:41: PYI016 [*] Duplicate union member `int` 68 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 69 | field21: typing.Union[int, int | str] # Error -PYI016.pyi:69:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:69:28 | 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 | field21: typing.Union[int, int | str] # Error - | ^^^ PYI016 + | ^^^ 70 | 71 | # Should emit only once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error @@ -471,15 +494,16 @@ PYI016.pyi:69:28: PYI016 [*] Duplicate union member `int` 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error -PYI016.pyi:72:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:72:41 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -491,15 +515,16 @@ PYI016.pyi:72:41: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.pyi:72:59: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:72:59 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -511,15 +536,16 @@ PYI016.pyi:72:59: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.pyi:72:64: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:72:64 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -531,16 +557,17 @@ PYI016.pyi:72:64: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]` +PYI016 [*] Duplicate union member `set[int]` + --> PYI016.pyi:76:12 | 74 | # Should emit in cases with newlines 75 | field23: set[ # foo 76 | int] | set[int] - | ^^^^^^^^ PYI016 + | ^^^^^^^^ 77 | 78 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `set[int]` +help: Remove duplicate union member `set[int]` ℹ Unsafe fix 72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error @@ -553,16 +580,17 @@ PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]` 78 77 | # Should emit twice (once for each `int` in the nested union, both of which are 79 78 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.pyi:81:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:81:41 | 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 78 78 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -574,16 +602,17 @@ PYI016.pyi:81:41: PYI016 [*] Duplicate union member `int` 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.pyi:81:46: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:81:46 | 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 78 78 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -595,16 +624,17 @@ PYI016.pyi:81:46: PYI016 [*] Duplicate union member `int` 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:86:28 | 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 87 | 88 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -616,16 +646,17 @@ PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int` 88 88 | # Should emit in cases with nested `typing.Union` 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` -PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:86:34 | 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 87 | 88 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -637,15 +668,16 @@ PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int` 88 88 | # Should emit in cases with nested `typing.Union` 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` -PYI016.pyi:89:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:89:41 | 88 | # Should emit in cases with nested `typing.Union` 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 90 | 91 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 86 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` @@ -657,15 +689,16 @@ PYI016.pyi:89:41: PYI016 [*] Duplicate union member `int` 91 91 | # Should emit in cases with nested `typing.Union` 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` -PYI016.pyi:92:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:92:54 | 91 | # Should emit in cases with nested `typing.Union` 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 93 | 94 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` @@ -677,15 +710,16 @@ PYI016.pyi:92:54: PYI016 [*] Duplicate union member `int` 94 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 95 | field28: typing.Union[int | int] # Error -PYI016.pyi:95:29: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:95:29 | 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 | field28: typing.Union[int | int] # Error - | ^^^ PYI016 + | ^^^ 96 | 97 | # Should emit twice in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` @@ -697,15 +731,16 @@ PYI016.pyi:95:29: PYI016 [*] Duplicate union member `int` 97 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error -PYI016.pyi:98:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:98:54 | 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 95 95 | field28: typing.Union[int | int] # Error @@ -717,15 +752,16 @@ PYI016.pyi:98:54: PYI016 [*] Duplicate union member `int` 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error -PYI016.pyi:98:59: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:98:59 | 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 95 95 | field28: typing.Union[int | int] # Error @@ -737,15 +773,16 @@ PYI016.pyi:98:59: PYI016 [*] Duplicate union member `int` 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error -PYI016.pyi:101:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:101:54 | 100 | # Should emit once in cases with multiple nested `typing.Union` 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error - | ^^^ PYI016 + | ^^^ 102 | 103 | # Should emit once, and fix to `typing.Union[float, int]` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error @@ -757,15 +794,16 @@ PYI016.pyi:101:54: PYI016 [*] Duplicate union member `int` 103 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error -PYI016.pyi:104:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:104:49 | 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 | field31: typing.Union[float, typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 105 | 106 | # Should emit once, and fix to `typing.Union[float, int]` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error @@ -777,15 +815,16 @@ PYI016.pyi:104:49: PYI016 [*] Duplicate union member `int` 106 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error -PYI016.pyi:107:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:107:49 | 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error - | ^^^ PYI016 + | ^^^ 108 | 109 | # Test case for mixed union type fix | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error @@ -797,15 +836,16 @@ PYI016.pyi:107:49: PYI016 [*] Duplicate union member `int` 109 109 | # Test case for mixed union type fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error -PYI016.pyi:107:55: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:107:55 | 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error - | ^^^ PYI016 + | ^^^ 108 | 109 | # Test case for mixed union type fix | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error @@ -817,15 +857,16 @@ PYI016.pyi:107:55: PYI016 [*] Duplicate union member `int` 109 109 | # Test case for mixed union type fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error -PYI016.pyi:110:42: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:110:42 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -837,15 +878,16 @@ PYI016.pyi:110:42: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.pyi:110:62: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:110:62 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -857,15 +899,16 @@ PYI016.pyi:110:62: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.pyi:110:68: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:110:68 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -877,15 +920,16 @@ PYI016.pyi:110:68: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.pyi:113:61: PYI016 [*] Duplicate union member `list[int]` +PYI016 [*] Duplicate union member `list[int]` + --> PYI016.pyi:113:61 | 112 | # Test case for mixed union type 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error - | ^^^^^^^^^ PYI016 + | ^^^^^^^^^ 114 | 115 | # https://github.com/astral-sh/ruff/issues/18546 | - = help: Remove duplicate union member `list[int]` +help: Remove duplicate union member `list[int]` ℹ Safe fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error @@ -897,16 +941,17 @@ PYI016.pyi:113:61: PYI016 [*] Duplicate union member `list[int]` 115 115 | # https://github.com/astral-sh/ruff/issues/18546 116 116 | # Expand Optional[T] to Union[T, None] -PYI016.pyi:125:45: PYI016 [*] Duplicate union member `typing.Optional[int]` +PYI016 [*] Duplicate union member `typing.Optional[int]` + --> PYI016.pyi:125:45 | 123 | field40: typing.Union[typing.Optional[int], None] 124 | field41: typing.Optional[typing.Union[int, None]] 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] - | ^^^^^^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^^^^^^ 126 | field43: typing.Optional[int] | None 127 | field44: typing.Optional[int | None] | - = help: Remove duplicate union member `typing.Optional[int]` +help: Remove duplicate union member `typing.Optional[int]` ℹ Safe fix 122 122 | # equivalent to int | None @@ -918,16 +963,17 @@ PYI016.pyi:125:45: PYI016 [*] Duplicate union member `typing.Optional[int]` 127 127 | field44: typing.Optional[int | None] 128 128 | field45: typing.Optional[int] | typing.Optional[int] -PYI016.pyi:128:33: PYI016 [*] Duplicate union member `typing.Optional[int]` +PYI016 [*] Duplicate union member `typing.Optional[int]` + --> PYI016.pyi:128:33 | 126 | field43: typing.Optional[int] | None 127 | field44: typing.Optional[int | None] 128 | field45: typing.Optional[int] | typing.Optional[int] - | ^^^^^^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^^^^^^ 129 | # equivalent to int | dict | None 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] | - = help: Remove duplicate union member `typing.Optional[int]` +help: Remove duplicate union member `typing.Optional[int]` ℹ Safe fix 125 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] @@ -939,14 +985,15 @@ PYI016.pyi:128:33: PYI016 [*] Duplicate union member `typing.Optional[int]` 130 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] 131 131 | field47: typing.Optional[int] | typing.Optional[dict] -PYI016.pyi:134:61: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.pyi:134:61 | 133 | # avoid reporting twice 134 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] - | ^^^^^^^ PYI016 + | ^^^^^^^ 135 | field49: typing.Optional[complex | complex] | complex | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 131 131 | field47: typing.Optional[int] | typing.Optional[dict] @@ -956,14 +1003,15 @@ PYI016.pyi:134:61: PYI016 [*] Duplicate union member `complex` 134 |+field48: typing.Union[typing.Optional[complex], complex] 135 135 | field49: typing.Optional[complex | complex] | complex -PYI016.pyi:135:36: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.pyi:135:36 | 133 | # avoid reporting twice 134 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] 135 | field49: typing.Optional[complex | complex] | complex - | ^^^^^^^ PYI016 + | ^^^^^^^ | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 132 132 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap index 5bc3532bab..1490e8462c 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap @@ -1,42 +1,46 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI017.pyi:4:1: PYI017 Stubs should not contain assignments to attributes or multiple targets +PYI017 Stubs should not contain assignments to attributes or multiple targets + --> PYI017.pyi:4:1 | 2 | a = var # OK 3 | 4 | b = c = int # PYI017 - | ^^^^^^^^^^^ PYI017 + | ^^^^^^^^^^^ 5 | 6 | a.b = int # PYI017 | -PYI017.pyi:6:1: PYI017 Stubs should not contain assignments to attributes or multiple targets +PYI017 Stubs should not contain assignments to attributes or multiple targets + --> PYI017.pyi:6:1 | 4 | b = c = int # PYI017 5 | 6 | a.b = int # PYI017 - | ^^^^^^^^^ PYI017 + | ^^^^^^^^^ 7 | 8 | d, e = int, str # PYI017 | -PYI017.pyi:8:1: PYI017 Stubs should not contain assignments to attributes or multiple targets +PYI017 Stubs should not contain assignments to attributes or multiple targets + --> PYI017.pyi:8:1 | 6 | a.b = int # PYI017 7 | 8 | d, e = int, str # PYI017 - | ^^^^^^^^^^^^^^^ PYI017 + | ^^^^^^^^^^^^^^^ 9 | 10 | f, g, h = int, str, TypeVar("T") # PYI017 | -PYI017.pyi:10:1: PYI017 Stubs should not contain assignments to attributes or multiple targets +PYI017 Stubs should not contain assignments to attributes or multiple targets + --> PYI017.pyi:10:1 | 8 | d, e = int, str # PYI017 9 | 10 | f, g, h = int, str, TypeVar("T") # PYI017 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | i: TypeAlias = int | str # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap index 19ab987883..df9aec8da1 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI018.py:6:1: PYI018 [*] Private TypeVar `_T` is never used +PYI018 [*] Private TypeVar `_T` is never used + --> PYI018.py:6:1 | 4 | from typing_extensions import ParamSpec, TypeVarTuple 5 | 6 | _T = typing.TypeVar("_T") - | ^^ PYI018 + | ^^ 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") 8 | _P = ParamSpec("_P") | - = help: Remove unused private TypeVar `_T` +help: Remove unused private TypeVar `_T` ℹ Unsafe fix 3 3 | from typing import TypeVar @@ -21,15 +22,16 @@ PYI018.py:6:1: PYI018 [*] Private TypeVar `_T` is never used 8 7 | _P = ParamSpec("_P") 9 8 | _P2 = typing.ParamSpec("_P2") -PYI018.py:7:1: PYI018 [*] Private TypeVarTuple `_Ts` is never used +PYI018 [*] Private TypeVarTuple `_Ts` is never used + --> PYI018.py:7:1 | 6 | _T = typing.TypeVar("_T") 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") - | ^^^ PYI018 + | ^^^ 8 | _P = ParamSpec("_P") 9 | _P2 = typing.ParamSpec("_P2") | - = help: Remove unused private TypeVarTuple `_Ts` +help: Remove unused private TypeVarTuple `_Ts` ℹ Unsafe fix 4 4 | from typing_extensions import ParamSpec, TypeVarTuple @@ -40,16 +42,17 @@ PYI018.py:7:1: PYI018 [*] Private TypeVarTuple `_Ts` is never used 9 8 | _P2 = typing.ParamSpec("_P2") 10 9 | _Ts2 = TypeVarTuple("_Ts2") -PYI018.py:8:1: PYI018 [*] Private ParamSpec `_P` is never used +PYI018 [*] Private ParamSpec `_P` is never used + --> PYI018.py:8:1 | 6 | _T = typing.TypeVar("_T") 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") 8 | _P = ParamSpec("_P") - | ^^ PYI018 + | ^^ 9 | _P2 = typing.ParamSpec("_P2") 10 | _Ts2 = TypeVarTuple("_Ts2") | - = help: Remove unused private ParamSpec `_P` +help: Remove unused private ParamSpec `_P` ℹ Unsafe fix 5 5 | @@ -60,15 +63,16 @@ PYI018.py:8:1: PYI018 [*] Private ParamSpec `_P` is never used 10 9 | _Ts2 = TypeVarTuple("_Ts2") 11 10 | -PYI018.py:9:1: PYI018 [*] Private ParamSpec `_P2` is never used +PYI018 [*] Private ParamSpec `_P2` is never used + --> PYI018.py:9:1 | 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") 8 | _P = ParamSpec("_P") 9 | _P2 = typing.ParamSpec("_P2") - | ^^^ PYI018 + | ^^^ 10 | _Ts2 = TypeVarTuple("_Ts2") | - = help: Remove unused private ParamSpec `_P2` +help: Remove unused private ParamSpec `_P2` ℹ Unsafe fix 6 6 | _T = typing.TypeVar("_T") @@ -79,16 +83,17 @@ PYI018.py:9:1: PYI018 [*] Private ParamSpec `_P2` is never used 11 10 | 12 11 | # OK -PYI018.py:10:1: PYI018 [*] Private TypeVarTuple `_Ts2` is never used +PYI018 [*] Private TypeVarTuple `_Ts2` is never used + --> PYI018.py:10:1 | 8 | _P = ParamSpec("_P") 9 | _P2 = typing.ParamSpec("_P2") 10 | _Ts2 = TypeVarTuple("_Ts2") - | ^^^^ PYI018 + | ^^^^ 11 | 12 | # OK | - = help: Remove unused private TypeVarTuple `_Ts2` +help: Remove unused private TypeVarTuple `_Ts2` ℹ Unsafe fix 7 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap index a7913fbfa8..48d81cf3cd 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI018.pyi:6:1: PYI018 [*] Private TypeVar `_T` is never used +PYI018 [*] Private TypeVar `_T` is never used + --> PYI018.pyi:6:1 | 4 | from typing_extensions import ParamSpec, TypeVarTuple 5 | 6 | _T = typing.TypeVar("_T") - | ^^ PYI018 + | ^^ 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") 8 | _P = ParamSpec("_P") | - = help: Remove unused private TypeVar `_T` +help: Remove unused private TypeVar `_T` ℹ Unsafe fix 3 3 | from typing import TypeVar @@ -21,15 +22,16 @@ PYI018.pyi:6:1: PYI018 [*] Private TypeVar `_T` is never used 8 7 | _P = ParamSpec("_P") 9 8 | _P2 = typing.ParamSpec("_P2") -PYI018.pyi:7:1: PYI018 [*] Private TypeVarTuple `_Ts` is never used +PYI018 [*] Private TypeVarTuple `_Ts` is never used + --> PYI018.pyi:7:1 | 6 | _T = typing.TypeVar("_T") 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") - | ^^^ PYI018 + | ^^^ 8 | _P = ParamSpec("_P") 9 | _P2 = typing.ParamSpec("_P2") | - = help: Remove unused private TypeVarTuple `_Ts` +help: Remove unused private TypeVarTuple `_Ts` ℹ Unsafe fix 4 4 | from typing_extensions import ParamSpec, TypeVarTuple @@ -40,16 +42,17 @@ PYI018.pyi:7:1: PYI018 [*] Private TypeVarTuple `_Ts` is never used 9 8 | _P2 = typing.ParamSpec("_P2") 10 9 | _Ts2 = TypeVarTuple("_Ts2") -PYI018.pyi:8:1: PYI018 [*] Private ParamSpec `_P` is never used +PYI018 [*] Private ParamSpec `_P` is never used + --> PYI018.pyi:8:1 | 6 | _T = typing.TypeVar("_T") 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") 8 | _P = ParamSpec("_P") - | ^^ PYI018 + | ^^ 9 | _P2 = typing.ParamSpec("_P2") 10 | _Ts2 = TypeVarTuple("_Ts2") | - = help: Remove unused private ParamSpec `_P` +help: Remove unused private ParamSpec `_P` ℹ Unsafe fix 5 5 | @@ -60,15 +63,16 @@ PYI018.pyi:8:1: PYI018 [*] Private ParamSpec `_P` is never used 10 9 | _Ts2 = TypeVarTuple("_Ts2") 11 10 | -PYI018.pyi:9:1: PYI018 [*] Private ParamSpec `_P2` is never used +PYI018 [*] Private ParamSpec `_P2` is never used + --> PYI018.pyi:9:1 | 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") 8 | _P = ParamSpec("_P") 9 | _P2 = typing.ParamSpec("_P2") - | ^^^ PYI018 + | ^^^ 10 | _Ts2 = TypeVarTuple("_Ts2") | - = help: Remove unused private ParamSpec `_P2` +help: Remove unused private ParamSpec `_P2` ℹ Unsafe fix 6 6 | _T = typing.TypeVar("_T") @@ -79,16 +83,17 @@ PYI018.pyi:9:1: PYI018 [*] Private ParamSpec `_P2` is never used 11 10 | 12 11 | # OK -PYI018.pyi:10:1: PYI018 [*] Private TypeVarTuple `_Ts2` is never used +PYI018 [*] Private TypeVarTuple `_Ts2` is never used + --> PYI018.pyi:10:1 | 8 | _P = ParamSpec("_P") 9 | _P2 = typing.ParamSpec("_P2") 10 | _Ts2 = TypeVarTuple("_Ts2") - | ^^^^ PYI018 + | ^^^^ 11 | 12 | # OK | - = help: Remove unused private TypeVarTuple `_Ts2` +help: Remove unused private TypeVarTuple `_Ts2` ℹ Unsafe fix 7 7 | _Ts = typing_extensions.TypeVarTuple("_Ts") diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_0.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_0.py.snap index 4071c9595f..5c3f8a0e18 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_0.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI019_0.py:7:16: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.py:7:16 | 6 | class BadClass: 7 | def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 4 4 | _S2 = TypeVar("_S2", BadClass, GoodClass) @@ -19,12 +20,13 @@ PYI019_0.py:7:16: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 9 9 | 10 10 | def bad_instance_method(self: _S, arg: bytes) -> _S: ... # PYI019 -PYI019_0.py:10:28: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.py:10:28 | 10 | def bad_instance_method(self: _S, arg: bytes) -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 7 7 | def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... # PYI019 @@ -36,13 +38,14 @@ PYI019_0.py:10:28: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 12 12 | 13 13 | @classmethod -PYI019_0.py:14:25: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.py:14:25 | 13 | @classmethod 14 | def bad_class_method(cls: type[_S], arg: int) -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 11 11 | @@ -54,13 +57,14 @@ PYI019_0.py:14:25: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 16 16 | 17 17 | @classmethod -PYI019_0.py:18:33: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.py:18:33 | 17 | @classmethod 18 | def bad_posonly_class_method(cls: type[_S], /) -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 15 15 | @@ -72,14 +76,15 @@ PYI019_0.py:18:33: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 20 20 | 21 21 | @classmethod -PYI019_0.py:39:14: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:39:14 | 37 | # Python > 3.12 38 | class PEP695BadDunderNew[T]: 39 | def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 36 36 | @@ -91,12 +96,13 @@ PYI019_0.py:39:14: PYI019 [*] Use `Self` instead of custom TypeVar `S` 41 41 | 42 42 | def generic_instance_method[S](self: S) -> S: ... # PYI019 -PYI019_0.py:42:30: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:42:30 | 42 | def generic_instance_method[S](self: S) -> S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 39 39 | def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ... # PYI019 @@ -108,14 +114,15 @@ PYI019_0.py:42:30: PYI019 [*] Use `Self` instead of custom TypeVar `S` 44 44 | 45 45 | class PEP695GoodDunderNew[T]: -PYI019_0.py:54:11: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:54:11 | 52 | # in the settings for this test: 53 | @foo_classmethod 54 | def foo[S](cls: type[S]) -> S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 51 51 | # due to `foo_classmethod being listed in `pep8_naming.classmethod-decorators` @@ -127,15 +134,16 @@ PYI019_0.py:54:11: PYI019 [*] Use `Self` instead of custom TypeVar `S` 56 56 | 57 57 | _S695 = TypeVar("_S695", bound="PEP695Fix") -PYI019_0.py:61:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:61:16 | 60 | class PEP695Fix: 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 58 58 | @@ -147,16 +155,17 @@ PYI019_0.py:61:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 63 63 | def __init_subclass__[S](cls: type[S]) -> S: ... 64 64 | -PYI019_0.py:63:26: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:63:26 | 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... 62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^ 64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 60 60 | class PEP695Fix: @@ -168,16 +177,17 @@ PYI019_0.py:63:26: PYI019 [*] Use `Self` instead of custom TypeVar `S` 65 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... 66 66 | -PYI019_0.py:65:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:65:16 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... 64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | 67 | def __pos__[S](self: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 62 62 | @@ -189,16 +199,17 @@ PYI019_0.py:65:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 67 67 | def __pos__[S](self: S) -> S: ... 68 68 | -PYI019_0.py:67:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:67:16 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... 66 | 67 | def __pos__[S](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ 68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 64 64 | @@ -210,16 +221,17 @@ PYI019_0.py:67:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 69 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... 70 70 | -PYI019_0.py:69:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:69:16 | 67 | def __pos__[S](self: S) -> S: ... 68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | 71 | def __sub__[S](self: S, other: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 66 66 | @@ -231,16 +243,17 @@ PYI019_0.py:69:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 71 71 | def __sub__[S](self: S, other: S) -> S: ... 72 72 | -PYI019_0.py:71:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:71:16 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... 70 | 71 | def __sub__[S](self: S, other: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | @classmethod | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 68 68 | @@ -252,15 +265,16 @@ PYI019_0.py:71:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 73 73 | @classmethod 74 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... -PYI019_0.py:74:27: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:74:27 | 73 | @classmethod 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | 76 | @classmethod | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 71 71 | def __sub__[S](self: S, other: S) -> S: ... @@ -272,15 +286,16 @@ PYI019_0.py:74:27: PYI019 [*] Use `Self` instead of custom TypeVar `S` 76 76 | @classmethod 77 77 | def class_method_unbound[S](cls: type[S]) -> S: ... -PYI019_0.py:77:29: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:77:29 | 76 | @classmethod 77 | def class_method_unbound[S](cls: type[S]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^ 78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 74 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... @@ -292,16 +307,17 @@ PYI019_0.py:77:29: PYI019 [*] Use `Self` instead of custom TypeVar `S` 79 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... 80 80 | -PYI019_0.py:79:30: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:79:30 | 77 | def class_method_unbound[S](cls: type[S]) -> S: ... 78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 80 | 81 | def instance_method_unbound[S](self: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 76 76 | @classmethod @@ -313,16 +329,17 @@ PYI019_0.py:79:30: PYI019 [*] Use `Self` instead of custom TypeVar `S` 81 81 | def instance_method_unbound[S](self: S) -> S: ... 82 82 | -PYI019_0.py:81:32: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:81:32 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... 80 | 81 | def instance_method_unbound[S](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ 82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 78 78 | @@ -334,16 +351,17 @@ PYI019_0.py:81:32: PYI019 [*] Use `Self` instead of custom TypeVar `S` 83 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... 84 84 | -PYI019_0.py:83:53: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:83:53 | 81 | def instance_method_unbound[S](self: S) -> S: ... 82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 80 80 | @@ -355,16 +373,17 @@ PYI019_0.py:83:53: PYI019 [*] Use `Self` instead of custom TypeVar `S` 85 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... 86 86 | -PYI019_0.py:85:55: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:85:55 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... 84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 82 82 | @@ -376,16 +395,17 @@ PYI019_0.py:85:55: PYI019 [*] Use `Self` instead of custom TypeVar `S` 87 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... 88 88 | -PYI019_0.py:87:27: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:87:27 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... 86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 84 84 | @@ -397,14 +417,15 @@ PYI019_0.py:87:27: PYI019 [*] Use `Self` instead of custom TypeVar `S` 89 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... 90 90 | -PYI019_0.py:89:43: PYI019 [*] Use `Self` instead of custom TypeVar `_S695` +PYI019 [*] Use `Self` instead of custom TypeVar `_S695` + --> PYI019_0.py:89:43 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... 88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S695` with `Self` +help: Replace TypeVar `_S695` with `Self` ℹ Safe fix 86 86 | @@ -416,15 +437,16 @@ PYI019_0.py:89:43: PYI019 [*] Use `Self` instead of custom TypeVar `_S695` 91 91 | 92 92 | class InvalidButWeDoNotPanic: -PYI019_0.py:94:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:94:10 | 92 | class InvalidButWeDoNotPanic: 93 | @classmethod 94 | def m[S](cls: type[S], /) -> S[int]: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 95 | def n(self: S) -> S[int]: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 91 91 | @@ -436,14 +458,15 @@ PYI019_0.py:94:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 96 96 | 97 97 | -PYI019_0.py:114:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:114:10 | 112 | class SubscriptReturnType: 113 | @classmethod 114 | def m[S](cls: type[S]) -> type[S]: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 111 111 | @@ -455,15 +478,16 @@ PYI019_0.py:114:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 116 116 | 117 117 | class SelfNotUsedInReturnAnnotation: -PYI019_0.py:118:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:118:10 | 117 | class SelfNotUsedInReturnAnnotation: 118 | def m[S](self: S, other: S) -> int: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 119 | @classmethod 120 | def n[S](cls: type[S], other: S) -> int: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 115 115 | @@ -475,14 +499,15 @@ PYI019_0.py:118:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 120 120 | def n[S](cls: type[S], other: S) -> int: ... 121 121 | -PYI019_0.py:120:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:120:10 | 118 | def m[S](self: S, other: S) -> int: ... 119 | @classmethod 120 | def n[S](cls: type[S], other: S) -> int: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 117 117 | class SelfNotUsedInReturnAnnotation: @@ -494,15 +519,16 @@ PYI019_0.py:120:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 122 122 | 123 123 | class _NotATypeVar: ... -PYI019_0.py:135:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:135:10 | 134 | class NoReturnAnnotations: 135 | def m[S](self: S, other: S): ... - | ^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^ 136 | @classmethod 137 | def n[S](cls: type[S], other: S): ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 132 132 | @@ -514,16 +540,17 @@ PYI019_0.py:135:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 137 137 | def n[S](cls: type[S], other: S): ... 138 138 | -PYI019_0.py:137:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:137:10 | 135 | def m[S](self: S, other: S): ... 136 | @classmethod 137 | def n[S](cls: type[S], other: S): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 138 | 139 | class MultipleBoundParameters: | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 134 134 | class NoReturnAnnotations: @@ -535,14 +562,15 @@ PYI019_0.py:137:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 139 139 | class MultipleBoundParameters: 140 140 | def m[S: int, T: int](self: S, other: T) -> S: ... -PYI019_0.py:140:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:140:10 | 139 | class MultipleBoundParameters: 140 | def m[S: int, T: int](self: S, other: T) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 141 | def n[T: (int, str), S: (int, str)](self: S, other: T) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 137 137 | def n[S](cls: type[S], other: S): ... @@ -554,16 +582,17 @@ PYI019_0.py:140:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 142 142 | 143 143 | class MethodsWithBody: -PYI019_0.py:141:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:141:10 | 139 | class MultipleBoundParameters: 140 | def m[S: int, T: int](self: S, other: T) -> S: ... 141 | def n[T: (int, str), S: (int, str)](self: S, other: T) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 142 | 143 | class MethodsWithBody: | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 138 138 | @@ -575,15 +604,16 @@ PYI019_0.py:141:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 143 143 | class MethodsWithBody: 144 144 | def m[S](self: S, other: S) -> S: -PYI019_0.py:144:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:144:10 | 143 | class MethodsWithBody: 144 | def m[S](self: S, other: S) -> S: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 145 | x: S = other 146 | return x | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 141 141 | def n[T: (int, str), S: (int, str)](self: S, other: T) -> S: ... @@ -597,15 +627,16 @@ PYI019_0.py:144:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 147 147 | 148 148 | @classmethod -PYI019_0.py:149:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:149:10 | 148 | @classmethod 149 | def n[S](cls: type[S], other: S) -> S: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 150 | x: type[S] = type(other) 151 | return x() | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 146 146 | return x @@ -619,15 +650,16 @@ PYI019_0.py:149:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 152 152 | 153 153 | class StringizedReferencesCanBeFixed: -PYI019_0.py:154:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:154:10 | 153 | class StringizedReferencesCanBeFixed: 154 | def m[S](self: S) -> S: - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ 155 | x = cast("list[tuple[S, S]]", self) 156 | return x | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 151 151 | return x() @@ -641,25 +673,27 @@ PYI019_0.py:154:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 157 157 | 158 158 | class ButStrangeStringizedReferencesCannotBeFixed: -PYI019_0.py:159:10: PYI019 Use `Self` instead of custom TypeVar `_T` +PYI019 Use `Self` instead of custom TypeVar `_T` + --> PYI019_0.py:159:10 | 158 | class ButStrangeStringizedReferencesCannotBeFixed: 159 | def m[_T](self: _T) -> _T: - | ^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^ 160 | x = cast('list[_\x54]', self) 161 | return x | - = help: Replace TypeVar `_T` with `Self` +help: Replace TypeVar `_T` with `Self` -PYI019_0.py:164:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:164:10 | 163 | class DeletionsAreNotTouched: 164 | def m[S](self: S) -> S: - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ 165 | # `S` is not a local variable here, and `del` can only be used with local variables, 166 | # so `del S` here is not actually a reference to the type variable `S`. | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 161 161 | return x @@ -671,15 +705,16 @@ PYI019_0.py:164:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 166 166 | # so `del S` here is not actually a reference to the type variable `S`. 167 167 | # This `del` statement is therefore not touched by the autofix (it raises `UnboundLocalError` -PYI019_0.py:173:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:173:10 | 172 | class NamesShadowingTypeVarAreNotTouched: 173 | def m[S](self: S) -> S: - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ 174 | type S = int 175 | print(S) # not a reference to the type variable, so not touched by the autofix | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 170 170 | return self @@ -691,15 +726,16 @@ PYI019_0.py:173:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 175 175 | print(S) # not a reference to the type variable, so not touched by the autofix 176 176 | return 42 -PYI019_0.py:189:52: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.py:189:52 | 188 | class BadClassWithStringTypeHints: 189 | def bad_instance_method_with_string_annotations(self: "_S", arg: str) -> "_S": ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 190 | 191 | @classmethod | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 186 186 | from __future__ import annotations @@ -711,13 +747,14 @@ PYI019_0.py:189:52: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 191 191 | @classmethod 192 192 | def bad_class_method_with_string_annotations(cls: "type[_S]") -> "_S": ... # PYI019 -PYI019_0.py:192:49: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.py:192:49 | 191 | @classmethod 192 | def bad_class_method_with_string_annotations(cls: "type[_S]") -> "_S": ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 189 189 | def bad_instance_method_with_string_annotations(self: "_S", arg: str) -> "_S": ... # PYI019 @@ -729,13 +766,14 @@ PYI019_0.py:192:49: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 194 194 | 195 195 | @classmethod -PYI019_0.py:196:50: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.py:196:50 | 195 | @classmethod 196 | def bad_class_method_with_mixed_annotations_1(cls: "type[_S]") -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 193 193 | @@ -747,13 +785,14 @@ PYI019_0.py:196:50: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 198 198 | 199 199 | @classmethod -PYI019_0.py:200:50: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.py:200:50 | 199 | @classmethod 200 | def bad_class_method_with_mixed_annotations_1(cls: type[_S]) -> "_S": ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 197 197 | @@ -765,14 +804,15 @@ PYI019_0.py:200:50: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 202 202 | 203 203 | class BadSubscriptReturnTypeWithStringTypeHints: -PYI019_0.py:205:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.py:205:10 | 203 | class BadSubscriptReturnTypeWithStringTypeHints: 204 | @classmethod 205 | def m[S](cls: "type[S]") -> "type[S]": ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 202 202 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_0.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_0.pyi.snap index 9b4647f3fe..fcd0d9b54a 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_0.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_0.pyi.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI019_0.pyi:7:16: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.pyi:7:16 | 6 | class BadClass: 7 | def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 4 4 | _S2 = TypeVar("_S2", BadClass, GoodClass) @@ -19,12 +20,13 @@ PYI019_0.pyi:7:16: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 9 9 | 10 10 | def bad_instance_method(self: _S, arg: bytes) -> _S: ... # PYI019 -PYI019_0.pyi:10:28: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.pyi:10:28 | 10 | def bad_instance_method(self: _S, arg: bytes) -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 7 7 | def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... # PYI019 @@ -36,13 +38,14 @@ PYI019_0.pyi:10:28: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 12 12 | 13 13 | @classmethod -PYI019_0.pyi:14:25: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.pyi:14:25 | 13 | @classmethod 14 | def bad_class_method(cls: type[_S], arg: int) -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 11 11 | @@ -54,13 +57,14 @@ PYI019_0.pyi:14:25: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 16 16 | 17 17 | @classmethod -PYI019_0.pyi:18:33: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.pyi:18:33 | 17 | @classmethod 18 | def bad_posonly_class_method(cls: type[_S], /) -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 15 15 | @@ -72,14 +76,15 @@ PYI019_0.pyi:18:33: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 20 20 | 21 21 | @classmethod -PYI019_0.pyi:39:14: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:39:14 | 37 | # Python > 3.12 38 | class PEP695BadDunderNew[T]: 39 | def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 36 36 | @@ -91,12 +96,13 @@ PYI019_0.pyi:39:14: PYI019 [*] Use `Self` instead of custom TypeVar `S` 41 41 | 42 42 | def generic_instance_method[S](self: S) -> S: ... # PYI019 -PYI019_0.pyi:42:30: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:42:30 | 42 | def generic_instance_method[S](self: S) -> S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 39 39 | def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ... # PYI019 @@ -108,14 +114,15 @@ PYI019_0.pyi:42:30: PYI019 [*] Use `Self` instead of custom TypeVar `S` 44 44 | 45 45 | class PEP695GoodDunderNew[T]: -PYI019_0.pyi:54:11: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:54:11 | 52 | # in the settings for this test: 53 | @foo_classmethod 54 | def foo[S](cls: type[S]) -> S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 51 51 | # due to `foo_classmethod being listed in `pep8_naming.classmethod-decorators` @@ -127,15 +134,16 @@ PYI019_0.pyi:54:11: PYI019 [*] Use `Self` instead of custom TypeVar `S` 56 56 | 57 57 | _S695 = TypeVar("_S695", bound="PEP695Fix") -PYI019_0.pyi:61:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:61:16 | 60 | class PEP695Fix: 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 58 58 | @@ -147,16 +155,17 @@ PYI019_0.pyi:61:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 63 63 | def __init_subclass__[S](cls: type[S]) -> S: ... 64 64 | -PYI019_0.pyi:63:26: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:63:26 | 61 | def __new__[S: PEP695Fix](cls: type[S]) -> S: ... 62 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^ 64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 60 60 | class PEP695Fix: @@ -168,16 +177,17 @@ PYI019_0.pyi:63:26: PYI019 [*] Use `Self` instead of custom TypeVar `S` 65 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... 66 66 | -PYI019_0.pyi:65:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:65:16 | 63 | def __init_subclass__[S](cls: type[S]) -> S: ... 64 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | 67 | def __pos__[S](self: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 62 62 | @@ -189,16 +199,17 @@ PYI019_0.pyi:65:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 67 67 | def __pos__[S](self: S) -> S: ... 68 68 | -PYI019_0.pyi:67:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:67:16 | 65 | def __neg__[S: PEP695Fix](self: S) -> S: ... 66 | 67 | def __pos__[S](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ 68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 64 64 | @@ -210,16 +221,17 @@ PYI019_0.pyi:67:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 69 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... 70 70 | -PYI019_0.pyi:69:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:69:16 | 67 | def __pos__[S](self: S) -> S: ... 68 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | 71 | def __sub__[S](self: S, other: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 66 66 | @@ -231,16 +243,17 @@ PYI019_0.pyi:69:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 71 71 | def __sub__[S](self: S, other: S) -> S: ... 72 72 | -PYI019_0.pyi:71:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:71:16 | 69 | def __add__[S: PEP695Fix](self: S, other: S) -> S: ... 70 | 71 | def __sub__[S](self: S, other: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | @classmethod | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 68 68 | @@ -252,15 +265,16 @@ PYI019_0.pyi:71:16: PYI019 [*] Use `Self` instead of custom TypeVar `S` 73 73 | @classmethod 74 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... -PYI019_0.pyi:74:27: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:74:27 | 73 | @classmethod 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | 76 | @classmethod | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 71 71 | def __sub__[S](self: S, other: S) -> S: ... @@ -272,15 +286,16 @@ PYI019_0.pyi:74:27: PYI019 [*] Use `Self` instead of custom TypeVar `S` 76 76 | @classmethod 77 77 | def class_method_unbound[S](cls: type[S]) -> S: ... -PYI019_0.pyi:77:29: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:77:29 | 76 | @classmethod 77 | def class_method_unbound[S](cls: type[S]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^ 78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 74 74 | def class_method_bound[S: PEP695Fix](cls: type[S]) -> S: ... @@ -292,16 +307,17 @@ PYI019_0.pyi:77:29: PYI019 [*] Use `Self` instead of custom TypeVar `S` 79 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... 80 80 | -PYI019_0.pyi:79:30: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:79:30 | 77 | def class_method_unbound[S](cls: type[S]) -> S: ... 78 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 80 | 81 | def instance_method_unbound[S](self: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 76 76 | @classmethod @@ -313,16 +329,17 @@ PYI019_0.pyi:79:30: PYI019 [*] Use `Self` instead of custom TypeVar `S` 81 81 | def instance_method_unbound[S](self: S) -> S: ... 82 82 | -PYI019_0.pyi:81:32: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:81:32 | 79 | def instance_method_bound[S: PEP695Fix](self: S) -> S: ... 80 | 81 | def instance_method_unbound[S](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ 82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 78 78 | @@ -334,16 +351,17 @@ PYI019_0.pyi:81:32: PYI019 [*] Use `Self` instead of custom TypeVar `S` 83 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... 84 84 | -PYI019_0.pyi:83:53: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:83:53 | 81 | def instance_method_unbound[S](self: S) -> S: ... 82 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 80 80 | @@ -355,16 +373,17 @@ PYI019_0.pyi:83:53: PYI019 [*] Use `Self` instead of custom TypeVar `S` 85 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... 86 86 | -PYI019_0.pyi:85:55: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:85:55 | 83 | def instance_method_bound_with_another_parameter[S: PEP695Fix](self: S, other: S) -> S: ... 84 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 82 82 | @@ -376,16 +395,17 @@ PYI019_0.pyi:85:55: PYI019 [*] Use `Self` instead of custom TypeVar `S` 87 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... 88 88 | -PYI019_0.pyi:87:27: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:87:27 | 85 | def instance_method_unbound_with_another_parameter[S](self: S, other: S) -> S: ... 86 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 84 84 | @@ -397,14 +417,15 @@ PYI019_0.pyi:87:27: PYI019 [*] Use `Self` instead of custom TypeVar `S` 89 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... 90 90 | -PYI019_0.pyi:89:43: PYI019 [*] Use `Self` instead of custom TypeVar `_S695` +PYI019 [*] Use `Self` instead of custom TypeVar `_S695` + --> PYI019_0.pyi:89:43 | 87 | def multiple_type_vars[S, *Ts, T](self: S, other: S, /, *args: *Ts, a: T, b: list[T]) -> S: ... 88 | 89 | def mixing_old_and_new_style_type_vars[T](self: _S695, a: T, b: T) -> _S695: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S695` with `Self` +help: Replace TypeVar `_S695` with `Self` ℹ Safe fix 86 86 | @@ -416,15 +437,16 @@ PYI019_0.pyi:89:43: PYI019 [*] Use `Self` instead of custom TypeVar `_S695` 91 91 | 92 92 | class InvalidButWeDoNotPanic: -PYI019_0.pyi:94:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:94:10 | 92 | class InvalidButWeDoNotPanic: 93 | @classmethod 94 | def m[S](cls: type[S], /) -> S[int]: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 95 | def n(self: S) -> S[int]: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 91 91 | @@ -436,14 +458,15 @@ PYI019_0.pyi:94:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 96 96 | 97 97 | -PYI019_0.pyi:114:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:114:10 | 112 | class SubscriptReturnType: 113 | @classmethod 114 | def m[S](cls: type[S]) -> type[S]: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 111 111 | @@ -455,13 +478,14 @@ PYI019_0.pyi:114:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 116 116 | 117 117 | class PEP695TypeParameterAtTheVeryEndOfTheList: -PYI019_0.pyi:118:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:118:10 | 117 | class PEP695TypeParameterAtTheVeryEndOfTheList: 118 | def f[T, S](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 115 115 | @@ -473,14 +497,15 @@ PYI019_0.pyi:118:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 120 120 | 121 121 | class PEP695Again: -PYI019_0.pyi:122:26: PYI019 [*] Use `Self` instead of custom TypeVar `_S695` +PYI019 [*] Use `Self` instead of custom TypeVar `_S695` + --> PYI019_0.pyi:122:26 | 121 | class PEP695Again: 122 | def mixing_and_nested[T](self: _S695, a: list[_S695], b: dict[_S695, str | T | set[_S695]]) -> _S695: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 123 | def also_uses_s695_but_should_not_be_edited(self, v: set[tuple[_S695]]) -> _S695: ... | - = help: Replace TypeVar `_S695` with `Self` +help: Replace TypeVar `_S695` with `Self` ℹ Safe fix 119 119 | @@ -492,7 +517,8 @@ PYI019_0.pyi:122:26: PYI019 [*] Use `Self` instead of custom TypeVar `_S695` 124 124 | 125 125 | @classmethod -PYI019_0.pyi:126:29: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:126:29 | 125 | @classmethod 126 | def comment_in_fix_range[T, S]( @@ -503,11 +529,11 @@ PYI019_0.pyi:126:29: PYI019 [*] Use `Self` instead of custom TypeVar `S` 130 | | a: T, 131 | | b: tuple[S, T] 132 | | ) -> S: ... - | |__________^ PYI019 + | |__________^ 133 | 134 | def comment_outside_fix_range[T, S]( | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Unsafe fix 123 123 | def also_uses_s695_but_should_not_be_edited(self, v: set[tuple[_S695]]) -> _S695: ... @@ -528,7 +554,8 @@ PYI019_0.pyi:126:29: PYI019 [*] Use `Self` instead of custom TypeVar `S` 134 132 | def comment_outside_fix_range[T, S]( 135 133 | self: S, -PYI019_0.pyi:134:34: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:134:34 | 132 | ) -> S: ... 133 | @@ -541,9 +568,9 @@ PYI019_0.pyi:134:34: PYI019 [*] Use `Self` instead of custom TypeVar `S` 139 | | S, T 140 | | ] 141 | | ) -> S: ... - | |__________^ PYI019 + | |__________^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 131 131 | b: tuple[S, T] @@ -565,15 +592,16 @@ PYI019_0.pyi:134:34: PYI019 [*] Use `Self` instead of custom TypeVar `S` 143 143 | 144 144 | class SelfNotUsedInReturnAnnotation: -PYI019_0.pyi:145:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:145:10 | 144 | class SelfNotUsedInReturnAnnotation: 145 | def m[S](self: S, other: S) -> int: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 146 | @classmethod 147 | def n[S](cls: type[S], other: S) -> int: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 142 142 | @@ -585,14 +613,15 @@ PYI019_0.pyi:145:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 147 147 | def n[S](cls: type[S], other: S) -> int: ... 148 148 | -PYI019_0.pyi:147:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:147:10 | 145 | def m[S](self: S, other: S) -> int: ... 146 | @classmethod 147 | def n[S](cls: type[S], other: S) -> int: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 144 144 | class SelfNotUsedInReturnAnnotation: @@ -604,15 +633,16 @@ PYI019_0.pyi:147:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 149 149 | 150 150 | class _NotATypeVar: ... -PYI019_0.pyi:161:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:161:10 | 160 | class NoReturnAnnotations: 161 | def m[S](self: S, other: S): ... - | ^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^ 162 | @classmethod 163 | def n[S](cls: type[S], other: S): ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 158 158 | def y(self: type[_NotATypeVar]) -> _NotATypeVar: ... @@ -624,16 +654,17 @@ PYI019_0.pyi:161:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 163 163 | def n[S](cls: type[S], other: S): ... 164 164 | -PYI019_0.pyi:163:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:163:10 | 161 | def m[S](self: S, other: S): ... 162 | @classmethod 163 | def n[S](cls: type[S], other: S): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 164 | 165 | class MultipleBoundParameters: | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 160 160 | class NoReturnAnnotations: @@ -645,14 +676,15 @@ PYI019_0.pyi:163:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 165 165 | class MultipleBoundParameters: 166 166 | def m[S: int, T: int](self: S, other: T) -> S: ... -PYI019_0.pyi:166:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:166:10 | 165 | class MultipleBoundParameters: 166 | def m[S: int, T: int](self: S, other: T) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 167 | def n[T: (int, str), S: (int, str)](self: S, other: T) -> S: ... | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 163 163 | def n[S](cls: type[S], other: S): ... @@ -664,14 +696,15 @@ PYI019_0.pyi:166:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 168 168 | 169 169 | -PYI019_0.pyi:167:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:167:10 | 165 | class MultipleBoundParameters: 166 | def m[S: int, T: int](self: S, other: T) -> S: ... 167 | def n[T: (int, str), S: (int, str)](self: S, other: T) -> S: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 164 164 | @@ -683,15 +716,16 @@ PYI019_0.pyi:167:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` 169 169 | 170 170 | MetaType = TypeVar("MetaType") -PYI019_0.pyi:181:52: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.pyi:181:52 | 180 | class BadClassWithStringTypeHints: 181 | def bad_instance_method_with_string_annotations(self: "_S", arg: str) -> "_S": ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 182 | 183 | @classmethod | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 178 178 | @@ -703,13 +737,14 @@ PYI019_0.pyi:181:52: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 183 183 | @classmethod 184 184 | def bad_class_method_with_string_annotations(cls: "type[_S]") -> "_S": ... # PYI019 -PYI019_0.pyi:184:49: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.pyi:184:49 | 183 | @classmethod 184 | def bad_class_method_with_string_annotations(cls: "type[_S]") -> "_S": ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 181 181 | def bad_instance_method_with_string_annotations(self: "_S", arg: str) -> "_S": ... # PYI019 @@ -721,13 +756,14 @@ PYI019_0.pyi:184:49: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 186 186 | 187 187 | @classmethod -PYI019_0.pyi:188:50: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.pyi:188:50 | 187 | @classmethod 188 | def bad_class_method_with_mixed_annotations_1(cls: "type[_S]") -> _S: ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 185 185 | @@ -739,13 +775,14 @@ PYI019_0.pyi:188:50: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 190 190 | 191 191 | @classmethod -PYI019_0.pyi:192:50: PYI019 [*] Use `Self` instead of custom TypeVar `_S` +PYI019 [*] Use `Self` instead of custom TypeVar `_S` + --> PYI019_0.pyi:192:50 | 191 | @classmethod 192 | def bad_class_method_with_mixed_annotations_1(cls: type[_S]) -> "_S": ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `_S` with `Self` +help: Replace TypeVar `_S` with `Self` ℹ Safe fix 189 189 | @@ -757,14 +794,15 @@ PYI019_0.pyi:192:50: PYI019 [*] Use `Self` instead of custom TypeVar `_S` 194 194 | 195 195 | class BadSubscriptReturnTypeWithStringTypeHints: -PYI019_0.pyi:197:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_0.pyi:197:10 | 195 | class BadSubscriptReturnTypeWithStringTypeHints: 196 | @classmethod 197 | def m[S](cls: "type[S]") -> "type[S]": ... # PYI019 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 194 194 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_1.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_1.pyi.snap index 00a0b3b355..6a606ef108 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_1.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019_1.pyi.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI019_1.pyi:4:10: PYI019 [*] Use `Self` instead of custom TypeVar `S` +PYI019 [*] Use `Self` instead of custom TypeVar `S` + --> PYI019_1.pyi:4:10 | 3 | class F: 4 | def m[S](self: S) -> S: ... - | ^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^ | - = help: Replace TypeVar `S` with `Self` +help: Replace TypeVar `S` with `Self` ℹ Safe fix 1 1 | import typing diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap index 0512085eb1..2398a9f453 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI020.pyi:7:10: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:7:10 | 5 | import typing_extensions 6 | 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 + | ^^^^^ 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 4 4 | @@ -22,14 +23,15 @@ PYI020.pyi:7:10: PYI020 [*] Quoted annotations should not be included in stubs 9 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs 10 10 | -PYI020.pyi:8:15: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:8:15 | 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 + | ^^^^^ 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 5 5 | import typing_extensions @@ -41,16 +43,17 @@ PYI020.pyi:8:15: PYI020 [*] Quoted annotations should not be included in stubs 10 10 | 11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... -PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:9:26 | 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 + | ^^^^^ 10 | 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 6 6 | @@ -62,15 +65,16 @@ PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs 11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... 12 12 | -PYI020.pyi:13:12: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:13:12 | 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... 12 | 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 + | ^^^^^ 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 10 10 | @@ -82,15 +86,16 @@ PYI020.pyi:13:12: PYI020 [*] Quoted annotations should not be included in stubs 15 15 | 16 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs -PYI020.pyi:14:25: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:14:25 | 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 + | ^^^^^ 15 | 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... @@ -102,15 +107,16 @@ PYI020.pyi:14:25: PYI020 [*] Quoted annotations should not be included in stubs 16 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs 17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs -PYI020.pyi:16:18: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:16:18 | 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs 15 | 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 + | ^^^^^ 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs @@ -122,15 +128,16 @@ PYI020.pyi:16:18: PYI020 [*] Quoted annotations should not be included in stubs 18 18 | 19 19 | if sys.platform == "linux": -PYI020.pyi:20:8: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:20:8 | 19 | if sys.platform == "linux": 20 | f: "int" # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 + | ^^^^^ 21 | elif sys.platform == "win32": 22 | f: "str" # Y020 Quoted annotations should never be used in stubs | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs @@ -142,16 +149,17 @@ PYI020.pyi:20:8: PYI020 [*] Quoted annotations should not be included in stubs 22 22 | f: "str" # Y020 Quoted annotations should never be used in stubs 23 23 | else: -PYI020.pyi:22:8: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:22:8 | 20 | f: "int" # Y020 Quoted annotations should never be used in stubs 21 | elif sys.platform == "win32": 22 | f: "str" # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 + | ^^^^^ 23 | else: 24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 19 19 | if sys.platform == "linux": @@ -163,16 +171,17 @@ PYI020.pyi:22:8: PYI020 [*] Quoted annotations should not be included in stubs 24 24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs 25 25 | -PYI020.pyi:24:8: PYI020 [*] Quoted annotations should not be included in stubs +PYI020 [*] Quoted annotations should not be included in stubs + --> PYI020.pyi:24:8 | 22 | f: "str" # Y020 Quoted annotations should never be used in stubs 23 | else: 24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs - | ^^^^^^^ PYI020 + | ^^^^^^^ 25 | 26 | # These two shouldn't trigger Y020 -- empty strings can't be "quoted annotations" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 21 21 | elif sys.platform == "win32": diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap index a135eb377b..1813232fb8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI021.pyi:1:1: PYI021 [*] Docstrings should not be included in stubs +PYI021 [*] Docstrings should not be included in stubs + --> PYI021.pyi:1:1 | 1 | """foo""" # ERROR PYI021 - | ^^^^^^^^^ PYI021 + | ^^^^^^^^^ 2 | 3 | def foo(): | - = help: Remove docstring +help: Remove docstring ℹ Unsafe fix 1 |-"""foo""" # ERROR PYI021 @@ -17,15 +18,16 @@ PYI021.pyi:1:1: PYI021 [*] Docstrings should not be included in stubs 3 3 | def foo(): 4 4 | """foo""" # ERROR PYI021 -PYI021.pyi:4:5: PYI021 [*] Docstrings should not be included in stubs +PYI021 [*] Docstrings should not be included in stubs + --> PYI021.pyi:4:5 | 3 | def foo(): 4 | """foo""" # ERROR PYI021 - | ^^^^^^^^^ PYI021 + | ^^^^^^^^^ 5 | 6 | class Bar: | - = help: Remove docstring +help: Remove docstring ℹ Unsafe fix 1 1 | """foo""" # ERROR PYI021 @@ -37,15 +39,16 @@ PYI021.pyi:4:5: PYI021 [*] Docstrings should not be included in stubs 6 6 | class Bar: 7 7 | """bar""" # ERROR PYI021 -PYI021.pyi:7:5: PYI021 [*] Docstrings should not be included in stubs +PYI021 [*] Docstrings should not be included in stubs + --> PYI021.pyi:7:5 | 6 | class Bar: 7 | """bar""" # ERROR PYI021 - | ^^^^^^^^^ PYI021 + | ^^^^^^^^^ 8 | 9 | class Qux: | - = help: Remove docstring +help: Remove docstring ℹ Unsafe fix 4 4 | """foo""" # ERROR PYI021 @@ -57,15 +60,16 @@ PYI021.pyi:7:5: PYI021 [*] Docstrings should not be included in stubs 9 9 | class Qux: 10 10 | """qux""" # ERROR PYI021 -PYI021.pyi:10:5: PYI021 [*] Docstrings should not be included in stubs +PYI021 [*] Docstrings should not be included in stubs + --> PYI021.pyi:10:5 | 9 | class Qux: 10 | """qux""" # ERROR PYI021 - | ^^^^^^^^^ PYI021 + | ^^^^^^^^^ 11 | 12 | def __init__(self) -> None: ... | - = help: Remove docstring +help: Remove docstring ℹ Unsafe fix 7 7 | """bar""" # ERROR PYI021 @@ -77,18 +81,19 @@ PYI021.pyi:10:5: PYI021 [*] Docstrings should not be included in stubs 12 12 | def __init__(self) -> None: ... 13 13 | -PYI021.pyi:15:5: PYI021 [*] Docstrings should not be included in stubs +PYI021 [*] Docstrings should not be included in stubs + --> PYI021.pyi:15:5 | 14 | class Baz: 15 | / """Multiline docstring 16 | | 17 | | Lorem ipsum dolor sit amet 18 | | """ - | |_______^ PYI021 + | |_______^ 19 | 20 | def __init__(self) -> None: ... | - = help: Remove docstring +help: Remove docstring ℹ Unsafe fix 12 12 | def __init__(self) -> None: ... diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap index 98a5e1131c..a1a5f63c88 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap @@ -1,35 +1,38 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI024.py:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` +PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + --> PYI024.py:3:9 | 1 | import collections 2 | 3 | person: collections.namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | ^^^^^^^^^^^^^^^^^^^^^^ PYI024 + | ^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | from collections import namedtuple | - = help: Replace with `typing.NamedTuple` +help: Replace with `typing.NamedTuple` -PYI024.py:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` +PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + --> PYI024.py:7:9 | 5 | from collections import namedtuple 6 | 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | ^^^^^^^^^^ PYI024 + | ^^^^^^^^^^ 8 | 9 | person = namedtuple( | - = help: Replace with `typing.NamedTuple` +help: Replace with `typing.NamedTuple` -PYI024.py:9:10: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` +PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + --> PYI024.py:9:10 | 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" 8 | 9 | person = namedtuple( - | ^^^^^^^^^^ PYI024 + | ^^^^^^^^^^ 10 | "Person", ["name", "age"] 11 | ) # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" | - = help: Replace with `typing.NamedTuple` +help: Replace with `typing.NamedTuple` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap index 413264f767..04312a5216 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap @@ -1,35 +1,38 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI024.pyi:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` +PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + --> PYI024.pyi:3:9 | 1 | import collections 2 | 3 | person: collections.namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | ^^^^^^^^^^^^^^^^^^^^^^ PYI024 + | ^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | from collections import namedtuple | - = help: Replace with `typing.NamedTuple` +help: Replace with `typing.NamedTuple` -PYI024.pyi:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` +PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + --> PYI024.pyi:7:9 | 5 | from collections import namedtuple 6 | 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | ^^^^^^^^^^ PYI024 + | ^^^^^^^^^^ 8 | 9 | person = namedtuple( | - = help: Replace with `typing.NamedTuple` +help: Replace with `typing.NamedTuple` -PYI024.pyi:9:10: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` +PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + --> PYI024.pyi:9:10 | 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" 8 | 9 | person = namedtuple( - | ^^^^^^^^^^ PYI024 + | ^^^^^^^^^^ 10 | "Person", ["name", "age"] 11 | ) # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" | - = help: Replace with `typing.NamedTuple` +help: Replace with `typing.NamedTuple` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap index 842c97c533..1e5b623529 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI025_1.py:10:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_1.py:10:33 | 9 | def f(): 10 | from collections.abc import Set # PYI025 - | ^^^ PYI025 + | ^^^ | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Safe fix 7 7 | @@ -19,15 +20,16 @@ PYI025_1.py:10:33: PYI025 [*] Use `from collections.abc import Set as AbstractSe 12 12 | 13 13 | def f(): -PYI025_1.py:14:51: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_1.py:14:51 | 13 | def f(): 14 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 - | ^^^ PYI025 + | ^^^ 15 | 16 | GLOBAL: Set[int] = set() | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Safe fix 11 11 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap index e5ca3811d2..e8148d3b21 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_1.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI025_1.pyi:8:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_1.pyi:8:33 | 7 | def f(): 8 | from collections.abc import Set # PYI025 - | ^^^ PYI025 + | ^^^ 9 | 10 | def f(): | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Safe fix 5 5 | from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # Ok @@ -21,15 +22,16 @@ PYI025_1.pyi:8:33: PYI025 [*] Use `from collections.abc import Set as AbstractSe 10 10 | def f(): 11 11 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 -PYI025_1.pyi:11:51: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_1.pyi:11:51 | 10 | def f(): 11 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 - | ^^^ PYI025 + | ^^^ 12 | 13 | def f(): | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Safe fix 8 8 | from collections.abc import Set # PYI025 @@ -41,16 +43,17 @@ PYI025_1.pyi:11:51: PYI025 [*] Use `from collections.abc import Set as AbstractS 13 13 | def f(): 14 14 | """Test: local symbol renaming.""" -PYI025_1.pyi:16:37: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_1.pyi:16:37 | 14 | """Test: local symbol renaming.""" 15 | if True: 16 | from collections.abc import Set - | ^^^ PYI025 + | ^^^ 17 | else: 18 | Set = 1 | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Safe fix 13 13 | def f(): @@ -76,16 +79,17 @@ PYI025_1.pyi:16:37: PYI025 [*] Use `from collections.abc import Set as AbstractS 29 29 | def Set(): 30 30 | pass -PYI025_1.pyi:33:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_1.pyi:33:29 | 31 | print(Set) 32 | 33 | from collections.abc import Set - | ^^^ PYI025 + | ^^^ 34 | 35 | def f(): | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Safe fix 17 17 | else: @@ -119,16 +123,17 @@ PYI025_1.pyi:33:29: PYI025 [*] Use `from collections.abc import Set as AbstractS 42 42 | def f(): 43 43 | """Test: nonlocal symbol renaming.""" -PYI025_1.pyi:44:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_1.pyi:44:33 | 42 | def f(): 43 | """Test: nonlocal symbol renaming.""" 44 | from collections.abc import Set - | ^^^ PYI025 + | ^^^ 45 | 46 | def g(): | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Safe fix 41 41 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap index 284fe29019..ef5a7584bb 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI025_2.py:3:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_2.py:3:29 | 1 | """Tests to ensure we correctly rename references inside `__all__`""" 2 | 3 | from collections.abc import Set - | ^^^ PYI025 + | ^^^ 4 | 5 | __all__ = ["Set"] | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Unsafe fix 1 1 | """Tests to ensure we correctly rename references inside `__all__`""" diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap index 88d1423db0..16ad7a6cc6 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_2.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI025_2.pyi:3:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_2.pyi:3:29 | 1 | """Tests to ensure we correctly rename references inside `__all__`""" 2 | 3 | from collections.abc import Set - | ^^^ PYI025 + | ^^^ 4 | 5 | __all__ = ["Set"] | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Unsafe fix 1 1 | """Tests to ensure we correctly rename references inside `__all__`""" diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap index 8e29eb17f3..ae989e3db5 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI025_3.py:6:36: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_3.py:6:36 | 4 | """ 5 | 6 | from collections.abc import Set as Set # PYI025 triggered but fix is not marked as safe - | ^^^ PYI025 + | ^^^ | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Unsafe fix 3 3 | through usage of a "redundant" `import Set as Set` alias diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap index 8eb394f20c..c277b2ce9e 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025_3.pyi.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI025_3.pyi:6:36: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin +PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + --> PYI025_3.pyi:6:36 | 4 | """ 5 | 6 | from collections.abc import Set as Set # PYI025 triggered but fix is not marked as safe - | ^^^ PYI025 + | ^^^ | - = help: Alias `Set` to `AbstractSet` +help: Alias `Set` to `AbstractSet` ℹ Unsafe fix 3 3 | through usage of a "redundant" `import Set as Set` alias diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap index b59d96e3d2..5c772f1030 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI026.pyi:3:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` +PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` + --> PYI026.pyi:3:1 | 1 | from typing import Literal, Any 2 | 3 | NewAny = Any - | ^^^^^^ PYI026 + | ^^^^^^ 4 | OptionalStr = typing.Optional[str] 5 | Foo = Literal["foo"] | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 |-from typing import Literal, Any @@ -22,15 +23,16 @@ PYI026.pyi:3:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `NewAny: 5 5 | Foo = Literal["foo"] 6 6 | IntOrStr = int | str -PYI026.pyi:4:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]` +PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]` + --> PYI026.pyi:4:1 | 3 | NewAny = Any 4 | OptionalStr = typing.Optional[str] - | ^^^^^^^^^^^ PYI026 + | ^^^^^^^^^^^ 5 | Foo = Literal["foo"] 6 | IntOrStr = int | str | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 |-from typing import Literal, Any @@ -43,16 +45,17 @@ PYI026.pyi:4:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Optiona 6 6 | IntOrStr = int | str 7 7 | AliasNone = None -PYI026.pyi:5:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]` +PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]` + --> PYI026.pyi:5:1 | 3 | NewAny = Any 4 | OptionalStr = typing.Optional[str] 5 | Foo = Literal["foo"] - | ^^^ PYI026 + | ^^^ 6 | IntOrStr = int | str 7 | AliasNone = None | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 |-from typing import Literal, Any @@ -66,15 +69,16 @@ PYI026.pyi:5:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Foo: Ty 7 7 | AliasNone = None 8 8 | -PYI026.pyi:6:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str` +PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str` + --> PYI026.pyi:6:1 | 4 | OptionalStr = typing.Optional[str] 5 | Foo = Literal["foo"] 6 | IntOrStr = int | str - | ^^^^^^^^ PYI026 + | ^^^^^^^^ 7 | AliasNone = None | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 |-from typing import Literal, Any @@ -89,16 +93,17 @@ PYI026.pyi:6:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `IntOrSt 8 8 | 9 9 | NewAny: typing.TypeAlias = Any -PYI026.pyi:7:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None` +PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None` + --> PYI026.pyi:7:1 | 5 | Foo = Literal["foo"] 6 | IntOrStr = int | str 7 | AliasNone = None - | ^^^^^^^^^ PYI026 + | ^^^^^^^^^ 8 | 9 | NewAny: typing.TypeAlias = Any | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 |-from typing import Literal, Any @@ -114,15 +119,16 @@ PYI026.pyi:7:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `AliasNo 9 9 | NewAny: typing.TypeAlias = Any 10 10 | OptionalStr: TypeAlias = typing.Optional[str] -PYI026.pyi:17:5: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `FLAG_THIS: TypeAlias = None` +PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `FLAG_THIS: TypeAlias = None` + --> PYI026.pyi:17:5 | 16 | class NotAnEnum: 17 | FLAG_THIS = None - | ^^^^^^^^^ PYI026 + | ^^^^^^^^^ 18 | 19 | # these are ok | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 |-from typing import Literal, Any diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap index fee6501120..23fbe27ce2 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI029.pyi:10:9: PYI029 [*] Defining `__str__` in a stub is almost always redundant +PYI029 [*] Defining `__str__` in a stub is almost always redundant + --> PYI029.pyi:10:9 | 9 | class ShouldRemoveSingle: 10 | def __str__(self) -> builtins.str: ... # Error: PYI029 - | ^^^^^^^ PYI029 + | ^^^^^^^ 11 | 12 | class ShouldRemove: | - = help: Remove definition of `__str__` +help: Remove definition of `__str__` ℹ Safe fix 7 7 | def __repr__(self, *, foo) -> str: ... @@ -21,14 +22,15 @@ PYI029.pyi:10:9: PYI029 [*] Defining `__str__` in a stub is almost always redund 12 12 | class ShouldRemove: 13 13 | def __repr__(self) -> str: ... # Error: PYI029 -PYI029.pyi:13:9: PYI029 [*] Defining `__repr__` in a stub is almost always redundant +PYI029 [*] Defining `__repr__` in a stub is almost always redundant + --> PYI029.pyi:13:9 | 12 | class ShouldRemove: 13 | def __repr__(self) -> str: ... # Error: PYI029 - | ^^^^^^^^ PYI029 + | ^^^^^^^^ 14 | def __str__(self) -> builtins.str: ... # Error: PYI029 | - = help: Remove definition of `__repr__` +help: Remove definition of `__repr__` ℹ Safe fix 10 10 | def __str__(self) -> builtins.str: ... # Error: PYI029 @@ -39,16 +41,17 @@ PYI029.pyi:13:9: PYI029 [*] Defining `__repr__` in a stub is almost always redun 15 14 | 16 15 | class NoReturnSpecified: -PYI029.pyi:14:9: PYI029 [*] Defining `__str__` in a stub is almost always redundant +PYI029 [*] Defining `__str__` in a stub is almost always redundant + --> PYI029.pyi:14:9 | 12 | class ShouldRemove: 13 | def __repr__(self) -> str: ... # Error: PYI029 14 | def __str__(self) -> builtins.str: ... # Error: PYI029 - | ^^^^^^^ PYI029 + | ^^^^^^^ 15 | 16 | class NoReturnSpecified: | - = help: Remove definition of `__str__` +help: Remove definition of `__str__` ℹ Safe fix 11 11 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap index 4e92aa2078..1d3b52f3b9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI030.py:9:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:9:9 | 8 | # Should emit for duplicate field types. 9 | field2: Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # Should emit for union types in arguments. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 6 6 | field1: Literal[1] # OK @@ -21,14 +22,15 @@ PYI030.py:9:9: PYI030 [*] Multiple literal members in a union. Use a single lite 11 11 | # Should emit for union types in arguments. 12 12 | def func1(arg1: Literal[1] | Literal[2]): # Error -PYI030.py:12:17: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:12:17 | 11 | # Should emit for union types in arguments. 12 | def func1(arg1: Literal[1] | Literal[2]): # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 13 | print(arg1) | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 9 9 | field2: Literal[1] | Literal[2] # Error @@ -40,14 +42,15 @@ PYI030.py:12:17: PYI030 [*] Multiple literal members in a union. Use a single li 14 14 | 15 15 | -PYI030.py:17:16: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:17:16 | 16 | # Should emit for unions in return types. 17 | def func2() -> Literal[1] | Literal[2]: # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | return "my Literal[1]ing" | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 14 14 | @@ -59,15 +62,16 @@ PYI030.py:17:16: PYI030 [*] Multiple literal members in a union. Use a single li 19 19 | 20 20 | -PYI030.py:22:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:22:9 | 21 | # Should emit in longer unions, even if not directly adjacent. 22 | field3: Literal[1] | Literal[2] | str # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | field4: str | Literal[1] | Literal[2] # Error 24 | field5: Literal[1] | str | Literal[2] # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 19 19 | @@ -79,16 +83,17 @@ PYI030.py:22:9: PYI030 [*] Multiple literal members in a union. Use a single lit 24 24 | field5: Literal[1] | str | Literal[2] # Error 25 25 | field6: Literal[1] | bool | Literal[2] | str # Error -PYI030.py:23:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:23:9 | 21 | # Should emit in longer unions, even if not directly adjacent. 22 | field3: Literal[1] | Literal[2] | str # Error 23 | field4: str | Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | field5: Literal[1] | str | Literal[2] # Error 25 | field6: Literal[1] | bool | Literal[2] | str # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 20 20 | @@ -100,15 +105,16 @@ PYI030.py:23:9: PYI030 [*] Multiple literal members in a union. Use a single lit 25 25 | field6: Literal[1] | bool | Literal[2] | str # Error 26 26 | -PYI030.py:24:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:24:9 | 22 | field3: Literal[1] | Literal[2] | str # Error 23 | field4: str | Literal[1] | Literal[2] # Error 24 | field5: Literal[1] | str | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | field6: Literal[1] | bool | Literal[2] | str # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 21 21 | # Should emit in longer unions, even if not directly adjacent. @@ -120,16 +126,17 @@ PYI030.py:24:9: PYI030 [*] Multiple literal members in a union. Use a single lit 26 26 | 27 27 | # Should emit for non-type unions. -PYI030.py:25:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:25:9 | 23 | field4: str | Literal[1] | Literal[2] # Error 24 | field5: Literal[1] | str | Literal[2] # Error 25 | field6: Literal[1] | bool | Literal[2] | str # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | # Should emit for non-type unions. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 22 22 | field3: Literal[1] | Literal[2] | str # Error @@ -141,15 +148,16 @@ PYI030.py:25:9: PYI030 [*] Multiple literal members in a union. Use a single lit 27 27 | # Should emit for non-type unions. 28 28 | field7 = Literal[1] | Literal[2] # Error -PYI030.py:28:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:28:10 | 27 | # Should emit for non-type unions. 28 | field7 = Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 29 | 30 | # Should emit for parenthesized unions. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 25 25 | field6: Literal[1] | bool | Literal[2] | str # Error @@ -161,15 +169,16 @@ PYI030.py:28:10: PYI030 [*] Multiple literal members in a union. Use a single li 30 30 | # Should emit for parenthesized unions. 31 31 | field8: Literal[1] | (Literal[2] | str) # Error -PYI030.py:31:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:31:9 | 30 | # Should emit for parenthesized unions. 31 | field8: Literal[1] | (Literal[2] | str) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | # Should handle user parentheses when fixing. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 28 28 | field7 = Literal[1] | Literal[2] # Error @@ -181,14 +190,15 @@ PYI030.py:31:9: PYI030 [*] Multiple literal members in a union. Use a single lit 33 33 | # Should handle user parentheses when fixing. 34 34 | field9: Literal[1] | (Literal[2] | str) # Error -PYI030.py:34:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:34:9 | 33 | # Should handle user parentheses when fixing. 34 | field9: Literal[1] | (Literal[2] | str) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | field10: (Literal[1] | str) | Literal[2] # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 31 31 | field8: Literal[1] | (Literal[2] | str) # Error @@ -200,16 +210,17 @@ PYI030.py:34:9: PYI030 [*] Multiple literal members in a union. Use a single lit 36 36 | 37 37 | # Should emit for union in generic parent type. -PYI030.py:35:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:35:10 | 33 | # Should handle user parentheses when fixing. 34 | field9: Literal[1] | (Literal[2] | str) # Error 35 | field10: (Literal[1] | str) | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | 37 | # Should emit for union in generic parent type. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 32 32 | @@ -221,15 +232,16 @@ PYI030.py:35:10: PYI030 [*] Multiple literal members in a union. Use a single li 37 37 | # Should emit for union in generic parent type. 38 38 | field11: dict[Literal[1] | Literal[2], str] # Error -PYI030.py:38:15: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:38:15 | 37 | # Should emit for union in generic parent type. 38 | field11: dict[Literal[1] | Literal[2], str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 39 | 40 | # Should emit for unions with more than two cases | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 35 35 | field10: (Literal[1] | str) | Literal[2] # Error @@ -241,14 +253,15 @@ PYI030.py:38:15: PYI030 [*] Multiple literal members in a union. Use a single li 40 40 | # Should emit for unions with more than two cases 41 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error -PYI030.py:41:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` + --> PYI030.py:41:10 | 40 | # Should emit for unions with more than two cases 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 38 38 | field11: dict[Literal[1] | Literal[2], str] # Error @@ -260,16 +273,17 @@ PYI030.py:41:10: PYI030 [*] Multiple literal members in a union. Use a single li 43 43 | 44 44 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI030.py:42:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + --> PYI030.py:42:10 | 40 | # Should emit for unions with more than two cases 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | 44 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 39 39 | @@ -281,15 +295,16 @@ PYI030.py:42:10: PYI030 [*] Multiple literal members in a union. Use a single li 44 44 | # Should emit for unions with more than two cases, even if not directly adjacent 45 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error -PYI030.py:45:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` + --> PYI030.py:45:10 | 44 | # Should emit for unions with more than two cases, even if not directly adjacent 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | 47 | # Should emit for unions with mixed literal internal types | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 42 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error @@ -301,15 +316,16 @@ PYI030.py:45:10: PYI030 [*] Multiple literal members in a union. Use a single li 47 47 | # Should emit for unions with mixed literal internal types 48 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error -PYI030.py:48:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, "foo", True]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, "foo", True]` + --> PYI030.py:48:10 | 47 | # Should emit for unions with mixed literal internal types 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 49 | 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 45 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error @@ -321,15 +337,16 @@ PYI030.py:48:10: PYI030 [*] Multiple literal members in a union. Use a single li 50 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 51 51 | field16: Literal[1] | Literal[1] # OK -PYI030.py:51:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 1]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 1]` + --> PYI030.py:51:10 | 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 51 | field16: Literal[1] | Literal[1] # OK - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 52 | 53 | # Shouldn't emit if in new parent type | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 48 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error @@ -341,15 +358,16 @@ PYI030.py:51:10: PYI030 [*] Multiple literal members in a union. Use a single li 53 53 | # Shouldn't emit if in new parent type 54 54 | field17: Literal[1] | dict[Literal[2], str] # OK -PYI030.py:60:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:60:10 | 59 | # Should respect name of literal type used 60 | field19: typing.Literal[1] | typing.Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | # Should emit in cases with newlines | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 57 57 | field18: dict[Literal[1], Literal[2]] # OK @@ -361,7 +379,8 @@ PYI030.py:60:10: PYI030 [*] Multiple literal members in a union. Use a single li 62 62 | # Should emit in cases with newlines 63 63 | field20: typing.Union[ -PYI030.py:63:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:63:10 | 62 | # Should emit in cases with newlines 63 | field20: typing.Union[ @@ -371,11 +390,11 @@ PYI030.py:63:10: PYI030 [*] Multiple literal members in a union. Use a single li 66 | | ], 67 | | Literal[2], 68 | | ] # Error, newline and comment will not be emitted in message - | |_^ PYI030 + | |_^ 69 | 70 | # Should handle multiple unions with multiple members | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Unsafe fix 60 60 | field19: typing.Literal[1] | typing.Literal[2] # Error @@ -392,15 +411,16 @@ PYI030.py:63:10: PYI030 [*] Multiple literal members in a union. Use a single li 70 65 | # Should handle multiple unions with multiple members 71 66 | field21: Literal[1, 2] | Literal[3, 4] # Error -PYI030.py:71:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + --> PYI030.py:71:10 | 70 | # Should handle multiple unions with multiple members 71 | field21: Literal[1, 2] | Literal[3, 4] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | # Should emit in cases with `typing.Union` instead of `|` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 68 68 | ] # Error, newline and comment will not be emitted in message @@ -412,15 +432,16 @@ PYI030.py:71:10: PYI030 [*] Multiple literal members in a union. Use a single li 73 73 | # Should emit in cases with `typing.Union` instead of `|` 74 74 | field22: typing.Union[Literal[1], Literal[2]] # Error -PYI030.py:74:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:74:10 | 73 | # Should emit in cases with `typing.Union` instead of `|` 74 | field22: typing.Union[Literal[1], Literal[2]] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | 76 | # Should emit in cases with `typing_extensions.Literal` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 71 71 | field21: Literal[1, 2] | Literal[3, 4] # Error @@ -432,15 +453,16 @@ PYI030.py:74:10: PYI030 [*] Multiple literal members in a union. Use a single li 76 76 | # Should emit in cases with `typing_extensions.Literal` 77 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error -PYI030.py:77:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:77:10 | 76 | # Should emit in cases with `typing_extensions.Literal` 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 78 | 79 | # Should emit in cases with nested `typing.Union` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 74 74 | field22: typing.Union[Literal[1], Literal[2]] # Error @@ -452,15 +474,16 @@ PYI030.py:77:10: PYI030 [*] Multiple literal members in a union. Use a single li 79 79 | # Should emit in cases with nested `typing.Union` 80 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error -PYI030.py:80:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:80:10 | 79 | # Should emit in cases with nested `typing.Union` 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 81 | 82 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 77 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error @@ -472,15 +495,16 @@ PYI030.py:80:10: PYI030 [*] Multiple literal members in a union. Use a single li 82 82 | # Should emit in cases with mixed `typing.Union` and `|` 83 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error -PYI030.py:83:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.py:83:10 | 82 | # Should emit in cases with mixed `typing.Union` and `|` 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | 85 | # Should emit only once in cases with multiple nested `typing.Union` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 80 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error @@ -492,15 +516,16 @@ PYI030.py:83:10: PYI030 [*] Multiple literal members in a union. Use a single li 85 85 | # Should emit only once in cases with multiple nested `typing.Union` 86 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error -PYI030.py:86:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + --> PYI030.py:86:10 | 85 | # Should emit only once in cases with multiple nested `typing.Union` 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 | 88 | # Should use the first literal subscript attribute when fixing | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 83 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error @@ -512,15 +537,16 @@ PYI030.py:86:10: PYI030 [*] Multiple literal members in a union. Use a single li 88 88 | # Should use the first literal subscript attribute when fixing 89 89 | field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str] # Error -PYI030.py:89:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + --> PYI030.py:89:10 | 88 | # Should use the first literal subscript attribute when fixing 89 | field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | 91 | from typing import IO, Literal | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 86 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error @@ -532,16 +558,17 @@ PYI030.py:89:10: PYI030 [*] Multiple literal members in a union. Use a single li 91 91 | from typing import IO, Literal 92 92 | -PYI030.py:93:16: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b"]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b"]` + --> PYI030.py:93:16 | 91 | from typing import IO, Literal 92 | 93 | InlineOption = Literal["a"] | Literal["b"] | IO[str] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 94 | 95 | # Should use unsafe fix when comments are deleted | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 90 90 | @@ -553,18 +580,19 @@ PYI030.py:93:16: PYI030 [*] Multiple literal members in a union. Use a single li 95 95 | # Should use unsafe fix when comments are deleted 96 96 | field26: ( -PYI030.py:98:5: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]` + --> PYI030.py:98:5 | 96 | field26: ( 97 | # First comment 98 | / Literal["a", "b"] 99 | | # Second comment 100 | | | Literal["c", "d"] - | |_______________________^ PYI030 + | |_______________________^ 101 | ) 102 | field27: ( | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Unsafe fix 95 95 | # Should use unsafe fix when comments are deleted @@ -578,16 +606,17 @@ PYI030.py:98:5: PYI030 [*] Multiple literal members in a union. Use a single lit 102 100 | field27: ( 103 101 | Literal["a", "b"] # First comment -PYI030.py:103:5: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]` + --> PYI030.py:103:5 | 101 | ) 102 | field27: ( 103 | / Literal["a", "b"] # First comment 104 | | | Literal["c", "d"] # Second comment - | |_______________________^ PYI030 + | |_______________________^ 105 | ) | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Unsafe fix 100 100 | | Literal["c", "d"] diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap index d4788e5b03..7236f6b59d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI030.pyi:9:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:9:9 | 8 | # Should emit for duplicate field types. 9 | field2: Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # Should emit for union types in arguments. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 6 6 | field1: Literal[1] # OK @@ -21,14 +22,15 @@ PYI030.pyi:9:9: PYI030 [*] Multiple literal members in a union. Use a single lit 11 11 | # Should emit for union types in arguments. 12 12 | def func1(arg1: Literal[1] | Literal[2]): # Error -PYI030.pyi:12:17: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:12:17 | 11 | # Should emit for union types in arguments. 12 | def func1(arg1: Literal[1] | Literal[2]): # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 13 | print(arg1) | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 9 9 | field2: Literal[1] | Literal[2] # Error @@ -40,14 +42,15 @@ PYI030.pyi:12:17: PYI030 [*] Multiple literal members in a union. Use a single l 14 14 | 15 15 | -PYI030.pyi:17:16: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:17:16 | 16 | # Should emit for unions in return types. 17 | def func2() -> Literal[1] | Literal[2]: # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | return "my Literal[1]ing" | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 14 14 | @@ -59,15 +62,16 @@ PYI030.pyi:17:16: PYI030 [*] Multiple literal members in a union. Use a single l 19 19 | 20 20 | -PYI030.pyi:22:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:22:9 | 21 | # Should emit in longer unions, even if not directly adjacent. 22 | field3: Literal[1] | Literal[2] | str # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | field4: str | Literal[1] | Literal[2] # Error 24 | field5: Literal[1] | str | Literal[2] # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 19 19 | @@ -79,16 +83,17 @@ PYI030.pyi:22:9: PYI030 [*] Multiple literal members in a union. Use a single li 24 24 | field5: Literal[1] | str | Literal[2] # Error 25 25 | field6: Literal[1] | bool | Literal[2] | str # Error -PYI030.pyi:23:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:23:9 | 21 | # Should emit in longer unions, even if not directly adjacent. 22 | field3: Literal[1] | Literal[2] | str # Error 23 | field4: str | Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | field5: Literal[1] | str | Literal[2] # Error 25 | field6: Literal[1] | bool | Literal[2] | str # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 20 20 | @@ -100,15 +105,16 @@ PYI030.pyi:23:9: PYI030 [*] Multiple literal members in a union. Use a single li 25 25 | field6: Literal[1] | bool | Literal[2] | str # Error 26 26 | -PYI030.pyi:24:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:24:9 | 22 | field3: Literal[1] | Literal[2] | str # Error 23 | field4: str | Literal[1] | Literal[2] # Error 24 | field5: Literal[1] | str | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | field6: Literal[1] | bool | Literal[2] | str # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 21 21 | # Should emit in longer unions, even if not directly adjacent. @@ -120,16 +126,17 @@ PYI030.pyi:24:9: PYI030 [*] Multiple literal members in a union. Use a single li 26 26 | 27 27 | # Should emit for non-type unions. -PYI030.pyi:25:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:25:9 | 23 | field4: str | Literal[1] | Literal[2] # Error 24 | field5: Literal[1] | str | Literal[2] # Error 25 | field6: Literal[1] | bool | Literal[2] | str # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | # Should emit for non-type unions. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 22 22 | field3: Literal[1] | Literal[2] | str # Error @@ -141,15 +148,16 @@ PYI030.pyi:25:9: PYI030 [*] Multiple literal members in a union. Use a single li 27 27 | # Should emit for non-type unions. 28 28 | field7 = Literal[1] | Literal[2] # Error -PYI030.pyi:28:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:28:10 | 27 | # Should emit for non-type unions. 28 | field7 = Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 29 | 30 | # Should emit for parenthesized unions. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 25 25 | field6: Literal[1] | bool | Literal[2] | str # Error @@ -161,15 +169,16 @@ PYI030.pyi:28:10: PYI030 [*] Multiple literal members in a union. Use a single l 30 30 | # Should emit for parenthesized unions. 31 31 | field8: Literal[1] | (Literal[2] | str) # Error -PYI030.pyi:31:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:31:9 | 30 | # Should emit for parenthesized unions. 31 | field8: Literal[1] | (Literal[2] | str) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | # Should handle user parentheses when fixing. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 28 28 | field7 = Literal[1] | Literal[2] # Error @@ -181,14 +190,15 @@ PYI030.pyi:31:9: PYI030 [*] Multiple literal members in a union. Use a single li 33 33 | # Should handle user parentheses when fixing. 34 34 | field9: Literal[1] | (Literal[2] | str) # Error -PYI030.pyi:34:9: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:34:9 | 33 | # Should handle user parentheses when fixing. 34 | field9: Literal[1] | (Literal[2] | str) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | field10: (Literal[1] | str) | Literal[2] # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 31 31 | field8: Literal[1] | (Literal[2] | str) # Error @@ -200,16 +210,17 @@ PYI030.pyi:34:9: PYI030 [*] Multiple literal members in a union. Use a single li 36 36 | 37 37 | # Should emit for union in generic parent type. -PYI030.pyi:35:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:35:10 | 33 | # Should handle user parentheses when fixing. 34 | field9: Literal[1] | (Literal[2] | str) # Error 35 | field10: (Literal[1] | str) | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | 37 | # Should emit for union in generic parent type. | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 32 32 | @@ -221,15 +232,16 @@ PYI030.pyi:35:10: PYI030 [*] Multiple literal members in a union. Use a single l 37 37 | # Should emit for union in generic parent type. 38 38 | field11: dict[Literal[1] | Literal[2], str] # Error -PYI030.pyi:38:15: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:38:15 | 37 | # Should emit for union in generic parent type. 38 | field11: dict[Literal[1] | Literal[2], str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 39 | 40 | # Should emit for unions with more than two cases | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 35 35 | field10: (Literal[1] | str) | Literal[2] # Error @@ -241,14 +253,15 @@ PYI030.pyi:38:15: PYI030 [*] Multiple literal members in a union. Use a single l 40 40 | # Should emit for unions with more than two cases 41 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error -PYI030.pyi:41:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` + --> PYI030.pyi:41:10 | 40 | # Should emit for unions with more than two cases 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 38 38 | field11: dict[Literal[1] | Literal[2], str] # Error @@ -260,16 +273,17 @@ PYI030.pyi:41:10: PYI030 [*] Multiple literal members in a union. Use a single l 43 43 | 44 44 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI030.pyi:42:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + --> PYI030.pyi:42:10 | 40 | # Should emit for unions with more than two cases 41 | field12: Literal[1] | Literal[2] | Literal[3] # Error 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | 44 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 39 39 | @@ -281,15 +295,16 @@ PYI030.pyi:42:10: PYI030 [*] Multiple literal members in a union. Use a single l 44 44 | # Should emit for unions with more than two cases, even if not directly adjacent 45 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error -PYI030.pyi:45:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` + --> PYI030.pyi:45:10 | 44 | # Should emit for unions with more than two cases, even if not directly adjacent 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | 47 | # Should emit for unions with mixed literal internal types | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 42 42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error @@ -301,15 +316,16 @@ PYI030.pyi:45:10: PYI030 [*] Multiple literal members in a union. Use a single l 47 47 | # Should emit for unions with mixed literal internal types 48 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error -PYI030.pyi:48:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, "foo", True]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, "foo", True]` + --> PYI030.pyi:48:10 | 47 | # Should emit for unions with mixed literal internal types 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 49 | 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 45 45 | field14: Literal[1] | Literal[2] | str | Literal[3] # Error @@ -321,15 +337,16 @@ PYI030.pyi:48:10: PYI030 [*] Multiple literal members in a union. Use a single l 50 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 51 51 | field16: Literal[1] | Literal[1] # OK -PYI030.pyi:51:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 1]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 1]` + --> PYI030.pyi:51:10 | 50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 51 | field16: Literal[1] | Literal[1] # OK - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 52 | 53 | # Shouldn't emit if in new parent type | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 48 48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error @@ -341,15 +358,16 @@ PYI030.pyi:51:10: PYI030 [*] Multiple literal members in a union. Use a single l 53 53 | # Shouldn't emit if in new parent type 54 54 | field17: Literal[1] | dict[Literal[2], str] # OK -PYI030.pyi:60:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:60:10 | 59 | # Should respect name of literal type used 60 | field19: typing.Literal[1] | typing.Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | # Should emit in cases with newlines | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 57 57 | field18: dict[Literal[1], Literal[2]] # OK @@ -361,7 +379,8 @@ PYI030.pyi:60:10: PYI030 [*] Multiple literal members in a union. Use a single l 62 62 | # Should emit in cases with newlines 63 63 | field20: typing.Union[ -PYI030.pyi:63:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:63:10 | 62 | # Should emit in cases with newlines 63 | field20: typing.Union[ @@ -371,11 +390,11 @@ PYI030.pyi:63:10: PYI030 [*] Multiple literal members in a union. Use a single l 66 | | ], 67 | | Literal[2], 68 | | ] # Error, newline and comment will not be emitted in message - | |_^ PYI030 + | |_^ 69 | 70 | # Should handle multiple unions with multiple members | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Unsafe fix 60 60 | field19: typing.Literal[1] | typing.Literal[2] # Error @@ -392,15 +411,16 @@ PYI030.pyi:63:10: PYI030 [*] Multiple literal members in a union. Use a single l 70 65 | # Should handle multiple unions with multiple members 71 66 | field21: Literal[1, 2] | Literal[3, 4] # Error -PYI030.pyi:71:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + --> PYI030.pyi:71:10 | 70 | # Should handle multiple unions with multiple members 71 | field21: Literal[1, 2] | Literal[3, 4] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | # Should emit in cases with `typing.Union` instead of `|` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 68 68 | ] # Error, newline and comment will not be emitted in message @@ -412,15 +432,16 @@ PYI030.pyi:71:10: PYI030 [*] Multiple literal members in a union. Use a single l 73 73 | # Should emit in cases with `typing.Union` instead of `|` 74 74 | field22: typing.Union[Literal[1], Literal[2]] # Error -PYI030.pyi:74:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:74:10 | 73 | # Should emit in cases with `typing.Union` instead of `|` 74 | field22: typing.Union[Literal[1], Literal[2]] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | 76 | # Should emit in cases with `typing_extensions.Literal` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 71 71 | field21: Literal[1, 2] | Literal[3, 4] # Error @@ -432,15 +453,16 @@ PYI030.pyi:74:10: PYI030 [*] Multiple literal members in a union. Use a single l 76 76 | # Should emit in cases with `typing_extensions.Literal` 77 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error -PYI030.pyi:77:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:77:10 | 76 | # Should emit in cases with `typing_extensions.Literal` 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 78 | 79 | # Should emit in cases with nested `typing.Union` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 74 74 | field22: typing.Union[Literal[1], Literal[2]] # Error @@ -452,15 +474,16 @@ PYI030.pyi:77:10: PYI030 [*] Multiple literal members in a union. Use a single l 79 79 | # Should emit in cases with nested `typing.Union` 80 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error -PYI030.pyi:80:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:80:10 | 79 | # Should emit in cases with nested `typing.Union` 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 81 | 82 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 77 77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error @@ -472,15 +495,16 @@ PYI030.pyi:80:10: PYI030 [*] Multiple literal members in a union. Use a single l 82 82 | # Should emit in cases with mixed `typing.Union` and `|` 83 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error -PYI030.pyi:83:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + --> PYI030.pyi:83:10 | 82 | # Should emit in cases with mixed `typing.Union` and `|` 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | 85 | # Should emit only once in cases with multiple nested `typing.Union` | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 80 80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error @@ -492,15 +516,16 @@ PYI030.pyi:83:10: PYI030 [*] Multiple literal members in a union. Use a single l 85 85 | # Should emit only once in cases with multiple nested `typing.Union` 86 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error -PYI030.pyi:86:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + --> PYI030.pyi:86:10 | 85 | # Should emit only once in cases with multiple nested `typing.Union` 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 | 88 | # Should use the first literal subscript attribute when fixing | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 83 83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error @@ -512,15 +537,16 @@ PYI030.pyi:86:10: PYI030 [*] Multiple literal members in a union. Use a single l 88 88 | # Should use the first literal subscript attribute when fixing 89 89 | field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str] # Error -PYI030.pyi:89:10: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + --> PYI030.pyi:89:10 | 88 | # Should use the first literal subscript attribute when fixing 89 | field25: typing.Union[typing_extensions.Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]], str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | 91 | # Should use unsafe fix when comments are deleted | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Safe fix 86 86 | field24: typing.Union[Literal[1], typing.Union[Literal[2], typing.Union[Literal[3], Literal[4]]]] # Error @@ -532,18 +558,19 @@ PYI030.pyi:89:10: PYI030 [*] Multiple literal members in a union. Use a single l 91 91 | # Should use unsafe fix when comments are deleted 92 92 | field26: ( -PYI030.pyi:94:5: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]` + --> PYI030.pyi:94:5 | 92 | field26: ( 93 | # First comment 94 | / Literal["a", "b"] 95 | | # Second comment 96 | | | Literal["c", "d"] - | |_______________________^ PYI030 + | |_______________________^ 97 | ) 98 | field27: ( | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Unsafe fix 91 91 | # Should use unsafe fix when comments are deleted @@ -557,16 +584,17 @@ PYI030.pyi:94:5: PYI030 [*] Multiple literal members in a union. Use a single li 98 96 | field27: ( 99 97 | Literal["a", "b"] # First comment -PYI030.pyi:99:5: PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]` +PYI030 [*] Multiple literal members in a union. Use a single literal, e.g. `Literal["a", "b", "c", "d"]` + --> PYI030.pyi:99:5 | 97 | ) 98 | field27: ( 99 | / Literal["a", "b"] # First comment 100 | | | Literal["c", "d"] # Second comment - | |_______________________^ PYI030 + | |_______________________^ 101 | ) | - = help: Replace with a single `Literal` +help: Replace with a single `Literal` ℹ Unsafe fix 96 96 | | Literal["c", "d"] diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap index 730106f00e..142d812fa7 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI032.py:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` +PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` + --> PYI032.py:6:29 | 5 | class Bad: 6 | def __eq__(self, other: Any) -> bool: ... # PYI032 - | ^^^ PYI032 + | ^^^ 7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # PYI032 | - = help: Replace with `object` +help: Replace with `object` ℹ Safe fix 3 3 | @@ -21,14 +21,15 @@ PYI032.py:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to 8 8 | 9 9 | -PYI032.py:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` +PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` + --> PYI032.py:7:29 | 5 | class Bad: 6 | def __eq__(self, other: Any) -> bool: ... # PYI032 7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # PYI032 - | ^^^^^^^^^^ PYI032 + | ^^^^^^^^^^ | - = help: Replace with `object` +help: Replace with `object` ℹ Safe fix 4 4 | @@ -40,14 +41,15 @@ PYI032.py:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to 9 9 | 10 10 | class Good: -PYI032.py:27:28: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` +PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` + --> PYI032.py:27:28 | 26 | class BadStringized: 27 | def __eq__(self, other: "Any") -> bool: ... # PYI032 - | ^^^^^ PYI032 + | ^^^^^ 28 | def __ne__(self, other: "Any") -> bool: ... # PYI032 | - = help: Replace with `object` +help: Replace with `object` ℹ Safe fix 24 24 | @@ -57,14 +59,15 @@ PYI032.py:27:28: PYI032 [*] Prefer `object` to `Any` for the second parameter to 27 |+ def __eq__(self, other: object) -> bool: ... # PYI032 28 28 | def __ne__(self, other: "Any") -> bool: ... # PYI032 -PYI032.py:28:28: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` +PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` + --> PYI032.py:28:28 | 26 | class BadStringized: 27 | def __eq__(self, other: "Any") -> bool: ... # PYI032 28 | def __ne__(self, other: "Any") -> bool: ... # PYI032 - | ^^^^^ PYI032 + | ^^^^^ | - = help: Replace with `object` +help: Replace with `object` ℹ Safe fix 25 25 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap index 3e18a528d0..41bd9881af 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI032.pyi:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` +PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` + --> PYI032.pyi:6:29 | 5 | class Bad: 6 | def __eq__(self, other: Any) -> bool: ... # PYI032 - | ^^^ PYI032 + | ^^^ 7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # PYI032 | - = help: Replace with `object` +help: Replace with `object` ℹ Safe fix 3 3 | @@ -21,14 +21,15 @@ PYI032.pyi:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to 8 8 | 9 9 | -PYI032.pyi:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` +PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` + --> PYI032.pyi:7:29 | 5 | class Bad: 6 | def __eq__(self, other: Any) -> bool: ... # PYI032 7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # PYI032 - | ^^^^^^^^^^ PYI032 + | ^^^^^^^^^^ | - = help: Replace with `object` +help: Replace with `object` ℹ Safe fix 4 4 | @@ -40,14 +41,15 @@ PYI032.pyi:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to 9 9 | 10 10 | class Good: -PYI032.pyi:26:28: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` +PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` + --> PYI032.pyi:26:28 | 25 | class BadStringized: 26 | def __eq__(self, other: "Any") -> bool: ... # PYI032 - | ^^^^^ PYI032 + | ^^^^^ 27 | def __ne__(self, other: "Any") -> bool: ... # PYI032 | - = help: Replace with `object` +help: Replace with `object` ℹ Safe fix 23 23 | def __ne__(self) -> bool: ... @@ -57,14 +59,15 @@ PYI032.pyi:26:28: PYI032 [*] Prefer `object` to `Any` for the second parameter t 26 |+ def __eq__(self, other: object) -> bool: ... # PYI032 27 27 | def __ne__(self, other: "Any") -> bool: ... # PYI032 -PYI032.pyi:27:28: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` +PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` + --> PYI032.pyi:27:28 | 25 | class BadStringized: 26 | def __eq__(self, other: "Any") -> bool: ... # PYI032 27 | def __ne__(self, other: "Any") -> bool: ... # PYI032 - | ^^^^^ PYI032 + | ^^^^^ | - = help: Replace with `object` +help: Replace with `object` ℹ Safe fix 24 24 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap index 1908a7ab92..fbae961f26 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap @@ -1,104 +1,115 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI033.pyi:6:22: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:6:22 | -4 | … import TypeAlias -5 | … -6 | …s = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -7 | …s = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: … -8 | …s = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +4 | from typing import TypeAlias +5 | +6 | A: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 | B: TypeAlias = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g… +8 | C: TypeAlias = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | -PYI033.pyi:7:22: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:7:22 | 6 | …one # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") 7 | …one # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | …one #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") 9 | …one # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | -PYI033.pyi:8:22: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:8:22 | - 6 | …s = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - 7 | …s = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x:… - 8 | …s = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 - 9 | …s = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -10 | …s = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + 6 | A: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + 7 | B: TypeAlias = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.… + 8 | C: TypeAlias = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 9 | D: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +10 | E: TypeAlias = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | -PYI033.pyi:9:22: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:9:22 | - 7 | … None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x: in… - 8 | … None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - 9 | … None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -10 | … None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") -11 | … None#type:int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + 7 | …as = None # type: str # And here's an extra comment about why it's that type # Y033 Do not use type comments in stubs (e.g. use "x… + 8 | …as = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + 9 | …as = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +10 | …as = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") +11 | …as = None#type:int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | -PYI033.pyi:10:20: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:10:20 | 8 | C: TypeAlias = None #type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") 9 | D: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") 10 | E: TypeAlias = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | F: TypeAlias = None#type:int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") | -PYI033.pyi:11:20: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:11:20 | 9 | D: TypeAlias = None # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") 10 | E: TypeAlias = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") 11 | F: TypeAlias = None#type:int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | def func( | -PYI033.pyi:14:12: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:14:12 | -13 | …func( -14 | …arg1, # type: dict[str, int] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -15 | …arg2 # type: Sequence[bytes] # And here's some more info about this arg # Y033 Do not use type comments in stubs (e.g. use "x: int… -16 | ….. +13 | def func( +14 | arg1, # type: dict[str, int] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +15 | arg2 # type: Sequence[bytes] # And here's some more info about this arg # Y033 Do not use type comments in stubs (e.g. use "x: … +16 | ): ... | -PYI033.pyi:15:11: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:15:11 | 13 | …unc( 14 | …rg1, # type: dict[str, int] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") 15 | …rg2 # type: Sequence[bytes] # And here's some more info about this arg # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | …. | -PYI033.pyi:19:29: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:19:29 | 18 | … -19 | … None # type: set[str] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +19 | …as = None # type: set[str] # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | … -21 | …# type: ignore +21 | …ne # type: ignore | -PYI033.pyi:29:22: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:29:22 | 28 | # Whole line commented out # type: int 29 | M: TypeAlias = None # type: can't parse me! - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI033 + | ^^^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | class Bar: | -PYI033.pyi:32:26: PYI033 Don't use type comments in stub file +PYI033 Don't use type comments in stub file + --> PYI033.pyi:32:26 | 31 | class Bar: 32 | N: TypeAlias = None # type: can't parse me either! - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | # This whole line is commented out and indented # type: str | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap index bb520776d6..d9837eff5d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI034.py:21:9: PYI034 [*] `__new__` methods in classes like `Bad` usually return `self` at runtime +PYI034 [*] `__new__` methods in classes like `Bad` usually return `self` at runtime + --> PYI034.py:21:9 | 19 | object 20 | ): # Y040 Do not inherit from "object" explicitly, as it is redundant in Python 3 21 | def __new__(cls, *args: Any, **kwargs: Any) -> Bad: - | ^^^^^^^ PYI034 + | ^^^^^^^ 22 | ... # Y034 "__new__" methods usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__new__", e.g.… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 18 18 | class Bad( @@ -21,15 +22,16 @@ PYI034.py:21:9: PYI034 [*] `__new__` methods in classes like `Bad` usually retur 23 23 | 24 24 | def __repr__(self) -> str: -PYI034.py:36:9: PYI034 [*] `__enter__` methods in classes like `Bad` usually return `self` at runtime +PYI034 [*] `__enter__` methods in classes like `Bad` usually return `self` at runtime + --> PYI034.py:36:9 | 34 | ... # Y032 Prefer "object" to "Any" for the second parameter in "__ne__" methods 35 | 36 | def __enter__(self) -> Bad: - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 37 | ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 33 33 | def __ne__(self, other: typing.Any) -> typing.Any: @@ -41,15 +43,16 @@ PYI034.py:36:9: PYI034 [*] `__enter__` methods in classes like `Bad` usually ret 38 38 | 39 39 | async def __aenter__(self) -> Bad: -PYI034.py:39:15: PYI034 [*] `__aenter__` methods in classes like `Bad` usually return `self` at runtime +PYI034 [*] `__aenter__` methods in classes like `Bad` usually return `self` at runtime + --> PYI034.py:39:15 | 37 | ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self… 38 | 39 | async def __aenter__(self) -> Bad: - | ^^^^^^^^^^ PYI034 + | ^^^^^^^^^^ 40 | ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Sel… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 36 36 | def __enter__(self) -> Bad: @@ -61,15 +64,16 @@ PYI034.py:39:15: PYI034 [*] `__aenter__` methods in classes like `Bad` usually r 41 41 | 42 42 | def __iadd__(self, other: Bad) -> Bad: -PYI034.py:42:9: PYI034 [*] `__iadd__` methods in classes like `Bad` usually return `self` at runtime +PYI034 [*] `__iadd__` methods in classes like `Bad` usually return `self` at runtime + --> PYI034.py:42:9 | 40 | ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Sel… 41 | 42 | def __iadd__(self, other: Bad) -> Bad: - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 43 | ... # Y034 "__iadd__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self"… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 39 39 | async def __aenter__(self) -> Bad: @@ -81,14 +85,15 @@ PYI034.py:42:9: PYI034 [*] `__iadd__` methods in classes like `Bad` usually retu 44 44 | 45 45 | -PYI034.py:165:9: PYI034 [*] `__iter__` methods in classes like `BadIterator1` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `BadIterator1` usually return `self` at runtime + --> PYI034.py:165:9 | 164 | class BadIterator1(Iterator[int]): 165 | def __iter__(self) -> Iterator[int]: - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 166 | ... # Y034 "__iter__" methods in classes like "BadIterator1" usually return "self" at runtime. Consider using "typing_extens… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 162 162 | @@ -100,15 +105,16 @@ PYI034.py:165:9: PYI034 [*] `__iter__` methods in classes like `BadIterator1` us 167 167 | 168 168 | -PYI034.py:172:9: PYI034 [*] `__iter__` methods in classes like `BadIterator2` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `BadIterator2` usually return `self` at runtime + --> PYI034.py:172:9 | 170 | typing.Iterator[int] 171 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) 172 | def __iter__(self) -> Iterator[int]: - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 173 | ... # Y034 "__iter__" methods in classes like "BadIterator2" usually return "self" at runtime. Consider using "typing_extens… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 169 169 | class BadIterator2( @@ -120,15 +126,16 @@ PYI034.py:172:9: PYI034 [*] `__iter__` methods in classes like `BadIterator2` us 174 174 | 175 175 | -PYI034.py:179:9: PYI034 [*] `__iter__` methods in classes like `BadIterator3` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `BadIterator3` usually return `self` at runtime + --> PYI034.py:179:9 | 177 | typing.Iterator[int] 178 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) 179 | def __iter__(self) -> collections.abc.Iterator[int]: - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 180 | ... # Y034 "__iter__" methods in classes like "BadIterator3" usually return "self" at runtime. Consider using "typing_extens… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 176 176 | class BadIterator3( @@ -140,15 +147,16 @@ PYI034.py:179:9: PYI034 [*] `__iter__` methods in classes like `BadIterator3` us 181 181 | 182 182 | -PYI034.py:185:9: PYI034 [*] `__iter__` methods in classes like `BadIterator4` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `BadIterator4` usually return `self` at runtime + --> PYI034.py:185:9 | 183 | class BadIterator4(Iterator[int]): 184 | # Note: *Iterable*, not *Iterator*, returned! 185 | def __iter__(self) -> Iterable[int]: - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 186 | ... # Y034 "__iter__" methods in classes like "BadIterator4" usually return "self" at runtime. Consider using "typing_extens… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 182 182 | @@ -160,14 +168,15 @@ PYI034.py:185:9: PYI034 [*] `__iter__` methods in classes like `BadIterator4` us 187 187 | 188 188 | -PYI034.py:195:9: PYI034 [*] `__aiter__` methods in classes like `BadAsyncIterator` usually return `self` at runtime +PYI034 [*] `__aiter__` methods in classes like `BadAsyncIterator` usually return `self` at runtime + --> PYI034.py:195:9 | 194 | class BadAsyncIterator(collections.abc.AsyncIterator[str]): 195 | def __aiter__(self) -> typing.AsyncIterator[str]: - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 196 | ... # Y034 "__aiter__" methods in classes like "BadAsyncIterator" usually return "self" at runtime. Consider using "typing_e… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 192 192 | @@ -179,14 +188,15 @@ PYI034.py:195:9: PYI034 [*] `__aiter__` methods in classes like `BadAsyncIterato 197 197 | 198 198 | class SubclassOfBadIterator3(BadIterator3): -PYI034.py:199:9: PYI034 [*] `__iter__` methods in classes like `SubclassOfBadIterator3` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `SubclassOfBadIterator3` usually return `self` at runtime + --> PYI034.py:199:9 | 198 | class SubclassOfBadIterator3(BadIterator3): 199 | def __iter__(self) -> Iterator[int]: # Y034 - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 200 | ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 196 196 | ... # Y034 "__aiter__" methods in classes like "BadAsyncIterator" usually return "self" at runtime. Consider using "typing_extensions.Self" in "BadAsyncIterator.__aiter__", e.g. "def __aiter__(self) -> Self: ..." # Y022 Use "collections.abc.AsyncIterator[T]" instead of "typing.AsyncIterator[T]" (PEP 585 syntax) @@ -198,14 +208,15 @@ PYI034.py:199:9: PYI034 [*] `__iter__` methods in classes like `SubclassOfBadIte 201 201 | 202 202 | class SubclassOfBadAsyncIterator(BadAsyncIterator): -PYI034.py:203:9: PYI034 [*] `__aiter__` methods in classes like `SubclassOfBadAsyncIterator` usually return `self` at runtime +PYI034 [*] `__aiter__` methods in classes like `SubclassOfBadAsyncIterator` usually return `self` at runtime + --> PYI034.py:203:9 | 202 | class SubclassOfBadAsyncIterator(BadAsyncIterator): 203 | def __aiter__(self) -> collections.abc.AsyncIterator[str]: # Y034 - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 204 | ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 200 200 | ... @@ -217,14 +228,15 @@ PYI034.py:203:9: PYI034 [*] `__aiter__` methods in classes like `SubclassOfBadAs 205 205 | 206 206 | class AsyncIteratorReturningAsyncIterable: -PYI034.py:327:9: PYI034 [*] `__new__` methods in classes like `NonGeneric1` usually return `self` at runtime +PYI034 [*] `__new__` methods in classes like `NonGeneric1` usually return `self` at runtime + --> PYI034.py:327:9 | 326 | class NonGeneric1(tuple): 327 | def __new__(cls: type[NonGeneric1], *args, **kwargs) -> NonGeneric1: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 328 | def __enter__(self: NonGeneric1) -> NonGeneric1: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 324 324 | @@ -236,16 +248,17 @@ PYI034.py:327:9: PYI034 [*] `__new__` methods in classes like `NonGeneric1` usua 329 329 | 330 330 | class NonGeneric2(tuple): -PYI034.py:328:9: PYI034 [*] `__enter__` methods in classes like `NonGeneric1` usually return `self` at runtime +PYI034 [*] `__enter__` methods in classes like `NonGeneric1` usually return `self` at runtime + --> PYI034.py:328:9 | 326 | class NonGeneric1(tuple): 327 | def __new__(cls: type[NonGeneric1], *args, **kwargs) -> NonGeneric1: ... 328 | def __enter__(self: NonGeneric1) -> NonGeneric1: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 329 | 330 | class NonGeneric2(tuple): | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 325 325 | @@ -257,15 +270,16 @@ PYI034.py:328:9: PYI034 [*] `__enter__` methods in classes like `NonGeneric1` us 330 330 | class NonGeneric2(tuple): 331 331 | def __new__(cls: Type[NonGeneric2]) -> NonGeneric2: ... -PYI034.py:331:9: PYI034 [*] `__new__` methods in classes like `NonGeneric2` usually return `self` at runtime +PYI034 [*] `__new__` methods in classes like `NonGeneric2` usually return `self` at runtime + --> PYI034.py:331:9 | 330 | class NonGeneric2(tuple): 331 | def __new__(cls: Type[NonGeneric2]) -> NonGeneric2: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 332 | 333 | class Generic1[T](list): | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 328 328 | def __enter__(self: NonGeneric1) -> NonGeneric1: ... @@ -277,14 +291,15 @@ PYI034.py:331:9: PYI034 [*] `__new__` methods in classes like `NonGeneric2` usua 333 333 | class Generic1[T](list): 334 334 | def __new__(cls: type[Generic1]) -> Generic1: ... -PYI034.py:334:9: PYI034 `__new__` methods in classes like `Generic1` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic1` usually return `self` at runtime + --> PYI034.py:334:9 | 333 | class Generic1[T](list): 334 | def __new__(cls: type[Generic1]) -> Generic1: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 335 | def __enter__(self: Generic1) -> Generic1: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 331 331 | def __new__(cls: Type[NonGeneric2]) -> NonGeneric2: ... @@ -296,14 +311,15 @@ PYI034.py:334:9: PYI034 `__new__` methods in classes like `Generic1` usually ret 336 336 | 337 337 | -PYI034.py:335:9: PYI034 `__enter__` methods in classes like `Generic1` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic1` usually return `self` at runtime + --> PYI034.py:335:9 | 333 | class Generic1[T](list): 334 | def __new__(cls: type[Generic1]) -> Generic1: ... 335 | def __enter__(self: Generic1) -> Generic1: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 332 332 | @@ -315,14 +331,15 @@ PYI034.py:335:9: PYI034 `__enter__` methods in classes like `Generic1` usually r 337 337 | 338 338 | ### Correctness of typevar-likes are not verified. -PYI034.py:345:9: PYI034 `__new__` methods in classes like `Generic2` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic2` usually return `self` at runtime + --> PYI034.py:345:9 | 344 | class Generic2(Generic[T]): 345 | def __new__(cls: type[Generic2]) -> Generic2: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 346 | def __enter__(self: Generic2) -> Generic2: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 342 342 | Ts = TypeVarTuple('foo') @@ -334,16 +351,17 @@ PYI034.py:345:9: PYI034 `__new__` methods in classes like `Generic2` usually ret 347 347 | 348 348 | class Generic3(tuple[*Ts]): -PYI034.py:346:9: PYI034 `__enter__` methods in classes like `Generic2` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic2` usually return `self` at runtime + --> PYI034.py:346:9 | 344 | class Generic2(Generic[T]): 345 | def __new__(cls: type[Generic2]) -> Generic2: ... 346 | def __enter__(self: Generic2) -> Generic2: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 347 | 348 | class Generic3(tuple[*Ts]): | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 343 343 | @@ -355,14 +373,15 @@ PYI034.py:346:9: PYI034 `__enter__` methods in classes like `Generic2` usually r 348 348 | class Generic3(tuple[*Ts]): 349 349 | def __new__(cls: type[Generic3]) -> Generic3: ... -PYI034.py:349:9: PYI034 `__new__` methods in classes like `Generic3` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic3` usually return `self` at runtime + --> PYI034.py:349:9 | 348 | class Generic3(tuple[*Ts]): 349 | def __new__(cls: type[Generic3]) -> Generic3: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 350 | def __enter__(self: Generic3) -> Generic3: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 346 346 | def __enter__(self: Generic2) -> Generic2: ... @@ -374,16 +393,17 @@ PYI034.py:349:9: PYI034 `__new__` methods in classes like `Generic3` usually ret 351 351 | 352 352 | class Generic4(collections.abc.Callable[P, ...]): -PYI034.py:350:9: PYI034 `__enter__` methods in classes like `Generic3` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic3` usually return `self` at runtime + --> PYI034.py:350:9 | 348 | class Generic3(tuple[*Ts]): 349 | def __new__(cls: type[Generic3]) -> Generic3: ... 350 | def __enter__(self: Generic3) -> Generic3: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 351 | 352 | class Generic4(collections.abc.Callable[P, ...]): | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 347 347 | @@ -395,14 +415,15 @@ PYI034.py:350:9: PYI034 `__enter__` methods in classes like `Generic3` usually r 352 352 | class Generic4(collections.abc.Callable[P, ...]): 353 353 | def __new__(cls: type[Generic4]) -> Generic4: ... -PYI034.py:353:9: PYI034 `__new__` methods in classes like `Generic4` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic4` usually return `self` at runtime + --> PYI034.py:353:9 | 352 | class Generic4(collections.abc.Callable[P, ...]): 353 | def __new__(cls: type[Generic4]) -> Generic4: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 354 | def __enter__(self: Generic4) -> Generic4: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 350 350 | def __enter__(self: Generic3) -> Generic3: ... @@ -414,16 +435,17 @@ PYI034.py:353:9: PYI034 `__new__` methods in classes like `Generic4` usually ret 355 355 | 356 356 | from some_module import PotentialTypeVar -PYI034.py:354:9: PYI034 `__enter__` methods in classes like `Generic4` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic4` usually return `self` at runtime + --> PYI034.py:354:9 | 352 | class Generic4(collections.abc.Callable[P, ...]): 353 | def __new__(cls: type[Generic4]) -> Generic4: ... 354 | def __enter__(self: Generic4) -> Generic4: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 355 | 356 | from some_module import PotentialTypeVar | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 351 351 | @@ -435,14 +457,15 @@ PYI034.py:354:9: PYI034 `__enter__` methods in classes like `Generic4` usually r 356 356 | from some_module import PotentialTypeVar 357 357 | -PYI034.py:359:9: PYI034 [*] `__new__` methods in classes like `Generic5` usually return `self` at runtime +PYI034 [*] `__new__` methods in classes like `Generic5` usually return `self` at runtime + --> PYI034.py:359:9 | 358 | class Generic5(list[PotentialTypeVar]): 359 | def __new__(cls: type[Generic5]) -> Generic5: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 360 | def __enter__(self: Generic5) -> Generic5: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 356 356 | from some_module import PotentialTypeVar @@ -453,14 +476,15 @@ PYI034.py:359:9: PYI034 [*] `__new__` methods in classes like `Generic5` usually 360 360 | def __enter__(self: Generic5) -> Generic5: ... 361 361 | -PYI034.py:360:9: PYI034 [*] `__enter__` methods in classes like `Generic5` usually return `self` at runtime +PYI034 [*] `__enter__` methods in classes like `Generic5` usually return `self` at runtime + --> PYI034.py:360:9 | 358 | class Generic5(list[PotentialTypeVar]): 359 | def __new__(cls: type[Generic5]) -> Generic5: ... 360 | def __enter__(self: Generic5) -> Generic5: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 357 357 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap index 49952c3ef7..294587cb6d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI034.pyi:20:9: PYI034 [*] `__new__` methods in classes like `Bad` usually return `self` at runtime +PYI034 [*] `__new__` methods in classes like `Bad` usually return `self` at runtime + --> PYI034.pyi:20:9 | 18 | object 19 | ): # Y040 Do not inherit from "object" explicitly, as it is redundant in Python 3 20 | def __new__( - | ^^^^^^^ PYI034 + | ^^^^^^^ 21 | cls, *args: Any, **kwargs: Any 22 | ) -> Bad: ... # Y034 "__new__" methods usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__new__"… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 19 19 | ): # Y040 Do not inherit from "object" explicitly, as it is redundant in Python 3 @@ -22,16 +23,17 @@ PYI034.pyi:20:9: PYI034 [*] `__new__` methods in classes like `Bad` usually retu 24 24 | self, 25 25 | ) -> str: ... # Y029 Defining __repr__ or __str__ in a stub is almost always redundant -PYI034.pyi:35:9: PYI034 [*] `__enter__` methods in classes like `Bad` usually return `self` at runtime +PYI034 [*] `__enter__` methods in classes like `Bad` usually return `self` at runtime + --> PYI034.pyi:35:9 | 33 | self, other: typing.Any 34 | ) -> typing.Any: ... # Y032 Prefer "object" to "Any" for the second parameter in "__ne__" methods 35 | def __enter__( - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 36 | self, 37 | ) -> Bad: ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extension… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 34 34 | ) -> typing.Any: ... # Y032 Prefer "object" to "Any" for the second parameter in "__ne__" methods @@ -43,16 +45,17 @@ PYI034.pyi:35:9: PYI034 [*] `__enter__` methods in classes like `Bad` usually re 39 39 | self, 40 40 | ) -> Bad: ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__aenter__", e.g. "async def __aenter__(self) -> Self: ..." -PYI034.pyi:38:15: PYI034 [*] `__aenter__` methods in classes like `Bad` usually return `self` at runtime +PYI034 [*] `__aenter__` methods in classes like `Bad` usually return `self` at runtime + --> PYI034.pyi:38:15 | 36 | self, 37 | ) -> Bad: ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extension… 38 | async def __aenter__( - | ^^^^^^^^^^ PYI034 + | ^^^^^^^^^^ 39 | self, 40 | ) -> Bad: ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensio… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 37 37 | ) -> Bad: ... # Y034 "__enter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__enter__", e.g. "def __enter__(self) -> Self: ..." @@ -64,16 +67,17 @@ PYI034.pyi:38:15: PYI034 [*] `__aenter__` methods in classes like `Bad` usually 42 42 | self, other: Bad 43 43 | ) -> Bad: ... # Y034 "__iadd__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__iadd__", e.g. "def __iadd__(self, other: Bad) -> Self: ..." -PYI034.pyi:41:9: PYI034 [*] `__iadd__` methods in classes like `Bad` usually return `self` at runtime +PYI034 [*] `__iadd__` methods in classes like `Bad` usually return `self` at runtime + --> PYI034.pyi:41:9 | 39 | self, 40 | ) -> Bad: ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensio… 41 | def __iadd__( - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 42 | self, other: Bad 43 | ) -> Bad: ... # Y034 "__iadd__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions… | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 40 40 | ) -> Bad: ... # Y034 "__aenter__" methods in classes like "Bad" usually return "self" at runtime. Consider using "typing_extensions.Self" in "Bad.__aenter__", e.g. "async def __aenter__(self) -> Self: ..." @@ -85,15 +89,16 @@ PYI034.pyi:41:9: PYI034 [*] `__iadd__` methods in classes like `Bad` usually ret 45 45 | class AlsoBad( 46 46 | int, builtins.object -PYI034.pyi:104:9: PYI034 [*] `__iter__` methods in classes like `BadIterator1` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `BadIterator1` usually return `self` at runtime + --> PYI034.pyi:104:9 | 103 | class BadIterator1(Iterator[int]): 104 | def __iter__( - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 105 | self, 106 | ) -> Iterator[ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 103 103 | class BadIterator1(Iterator[int]): @@ -107,16 +112,17 @@ PYI034.pyi:104:9: PYI034 [*] `__iter__` methods in classes like `BadIterator1` u 110 108 | class BadIterator2( 111 109 | typing.Iterator[int] -PYI034.pyi:113:9: PYI034 [*] `__iter__` methods in classes like `BadIterator2` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `BadIterator2` usually return `self` at runtime + --> PYI034.pyi:113:9 | 111 | typing.Iterator[int] 112 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) 113 | def __iter__( - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 114 | self, 115 | ) -> Iterator[ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 112 112 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) @@ -130,16 +136,17 @@ PYI034.pyi:113:9: PYI034 [*] `__iter__` methods in classes like `BadIterator2` u 119 117 | class BadIterator3( 120 118 | typing.Iterator[int] -PYI034.pyi:122:9: PYI034 [*] `__iter__` methods in classes like `BadIterator3` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `BadIterator3` usually return `self` at runtime + --> PYI034.pyi:122:9 | 120 | typing.Iterator[int] 121 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) 122 | def __iter__( - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 123 | self, 124 | ) -> collections.abc.Iterator[ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 121 121 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) @@ -153,16 +160,17 @@ PYI034.pyi:122:9: PYI034 [*] `__iter__` methods in classes like `BadIterator3` u 128 126 | class BadIterator4(Iterator[int]): 129 127 | # Note: *Iterable*, not *Iterator*, returned! -PYI034.pyi:130:9: PYI034 [*] `__iter__` methods in classes like `BadIterator4` usually return `self` at runtime +PYI034 [*] `__iter__` methods in classes like `BadIterator4` usually return `self` at runtime + --> PYI034.pyi:130:9 | 128 | class BadIterator4(Iterator[int]): 129 | # Note: *Iterable*, not *Iterator*, returned! 130 | def __iter__( - | ^^^^^^^^ PYI034 + | ^^^^^^^^ 131 | self, 132 | ) -> Iterable[ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 129 129 | # Note: *Iterable*, not *Iterator*, returned! @@ -176,15 +184,16 @@ PYI034.pyi:130:9: PYI034 [*] `__iter__` methods in classes like `BadIterator4` u 136 134 | class IteratorReturningIterable: 137 135 | def __iter__( -PYI034.pyi:144:9: PYI034 [*] `__aiter__` methods in classes like `BadAsyncIterator` usually return `self` at runtime +PYI034 [*] `__aiter__` methods in classes like `BadAsyncIterator` usually return `self` at runtime + --> PYI034.pyi:144:9 | 143 | class BadAsyncIterator(collections.abc.AsyncIterator[str]): 144 | def __aiter__( - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 145 | self, 146 | ) -> typing.AsyncIterator[ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 143 143 | class BadAsyncIterator(collections.abc.AsyncIterator[str]): @@ -198,14 +207,15 @@ PYI034.pyi:144:9: PYI034 [*] `__aiter__` methods in classes like `BadAsyncIterat 150 148 | class AsyncIteratorReturningAsyncIterable: 151 149 | def __aiter__( -PYI034.pyi:221:9: PYI034 [*] `__new__` methods in classes like `NonGeneric1` usually return `self` at runtime +PYI034 [*] `__new__` methods in classes like `NonGeneric1` usually return `self` at runtime + --> PYI034.pyi:221:9 | 220 | class NonGeneric1(tuple): 221 | def __new__(cls: type[NonGeneric1], *args, **kwargs) -> NonGeneric1: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 222 | def __enter__(self: NonGeneric1) -> NonGeneric1: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 218 218 | @@ -217,16 +227,17 @@ PYI034.pyi:221:9: PYI034 [*] `__new__` methods in classes like `NonGeneric1` usu 223 223 | 224 224 | class NonGeneric2(tuple): -PYI034.pyi:222:9: PYI034 [*] `__enter__` methods in classes like `NonGeneric1` usually return `self` at runtime +PYI034 [*] `__enter__` methods in classes like `NonGeneric1` usually return `self` at runtime + --> PYI034.pyi:222:9 | 220 | class NonGeneric1(tuple): 221 | def __new__(cls: type[NonGeneric1], *args, **kwargs) -> NonGeneric1: ... 222 | def __enter__(self: NonGeneric1) -> NonGeneric1: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 223 | 224 | class NonGeneric2(tuple): | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 219 219 | @@ -238,15 +249,16 @@ PYI034.pyi:222:9: PYI034 [*] `__enter__` methods in classes like `NonGeneric1` u 224 224 | class NonGeneric2(tuple): 225 225 | def __new__(cls: Type[NonGeneric2]) -> NonGeneric2: ... -PYI034.pyi:225:9: PYI034 [*] `__new__` methods in classes like `NonGeneric2` usually return `self` at runtime +PYI034 [*] `__new__` methods in classes like `NonGeneric2` usually return `self` at runtime + --> PYI034.pyi:225:9 | 224 | class NonGeneric2(tuple): 225 | def __new__(cls: Type[NonGeneric2]) -> NonGeneric2: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 226 | 227 | class Generic1[T](list): | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Unsafe fix 222 222 | def __enter__(self: NonGeneric1) -> NonGeneric1: ... @@ -258,14 +270,15 @@ PYI034.pyi:225:9: PYI034 [*] `__new__` methods in classes like `NonGeneric2` usu 227 227 | class Generic1[T](list): 228 228 | def __new__(cls: type[Generic1]) -> Generic1: ... -PYI034.pyi:228:9: PYI034 `__new__` methods in classes like `Generic1` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic1` usually return `self` at runtime + --> PYI034.pyi:228:9 | 227 | class Generic1[T](list): 228 | def __new__(cls: type[Generic1]) -> Generic1: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 229 | def __enter__(self: Generic1) -> Generic1: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 225 225 | def __new__(cls: Type[NonGeneric2]) -> NonGeneric2: ... @@ -277,14 +290,15 @@ PYI034.pyi:228:9: PYI034 `__new__` methods in classes like `Generic1` usually re 230 230 | 231 231 | -PYI034.pyi:229:9: PYI034 `__enter__` methods in classes like `Generic1` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic1` usually return `self` at runtime + --> PYI034.pyi:229:9 | 227 | class Generic1[T](list): 228 | def __new__(cls: type[Generic1]) -> Generic1: ... 229 | def __enter__(self: Generic1) -> Generic1: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 226 226 | @@ -296,14 +310,15 @@ PYI034.pyi:229:9: PYI034 `__enter__` methods in classes like `Generic1` usually 231 231 | 232 232 | ### Correctness of typevar-likes are not verified. -PYI034.pyi:239:9: PYI034 `__new__` methods in classes like `Generic2` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic2` usually return `self` at runtime + --> PYI034.pyi:239:9 | 238 | class Generic2(Generic[T]): 239 | def __new__(cls: type[Generic2]) -> Generic2: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 240 | def __enter__(self: Generic2) -> Generic2: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 236 236 | Ts = TypeVarTuple('foo') @@ -315,16 +330,17 @@ PYI034.pyi:239:9: PYI034 `__new__` methods in classes like `Generic2` usually re 241 241 | 242 242 | class Generic3(tuple[*Ts]): -PYI034.pyi:240:9: PYI034 `__enter__` methods in classes like `Generic2` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic2` usually return `self` at runtime + --> PYI034.pyi:240:9 | 238 | class Generic2(Generic[T]): 239 | def __new__(cls: type[Generic2]) -> Generic2: ... 240 | def __enter__(self: Generic2) -> Generic2: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 241 | 242 | class Generic3(tuple[*Ts]): | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 237 237 | @@ -336,14 +352,15 @@ PYI034.pyi:240:9: PYI034 `__enter__` methods in classes like `Generic2` usually 242 242 | class Generic3(tuple[*Ts]): 243 243 | def __new__(cls: type[Generic3]) -> Generic3: ... -PYI034.pyi:243:9: PYI034 `__new__` methods in classes like `Generic3` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic3` usually return `self` at runtime + --> PYI034.pyi:243:9 | 242 | class Generic3(tuple[*Ts]): 243 | def __new__(cls: type[Generic3]) -> Generic3: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 244 | def __enter__(self: Generic3) -> Generic3: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 240 240 | def __enter__(self: Generic2) -> Generic2: ... @@ -355,16 +372,17 @@ PYI034.pyi:243:9: PYI034 `__new__` methods in classes like `Generic3` usually re 245 245 | 246 246 | class Generic4(collections.abc.Callable[P, ...]): -PYI034.pyi:244:9: PYI034 `__enter__` methods in classes like `Generic3` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic3` usually return `self` at runtime + --> PYI034.pyi:244:9 | 242 | class Generic3(tuple[*Ts]): 243 | def __new__(cls: type[Generic3]) -> Generic3: ... 244 | def __enter__(self: Generic3) -> Generic3: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 245 | 246 | class Generic4(collections.abc.Callable[P, ...]): | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 241 241 | @@ -376,14 +394,15 @@ PYI034.pyi:244:9: PYI034 `__enter__` methods in classes like `Generic3` usually 246 246 | class Generic4(collections.abc.Callable[P, ...]): 247 247 | def __new__(cls: type[Generic4]) -> Generic4: ... -PYI034.pyi:247:9: PYI034 `__new__` methods in classes like `Generic4` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic4` usually return `self` at runtime + --> PYI034.pyi:247:9 | 246 | class Generic4(collections.abc.Callable[P, ...]): 247 | def __new__(cls: type[Generic4]) -> Generic4: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 248 | def __enter__(self: Generic4) -> Generic4: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 244 244 | def __enter__(self: Generic3) -> Generic3: ... @@ -395,16 +414,17 @@ PYI034.pyi:247:9: PYI034 `__new__` methods in classes like `Generic4` usually re 249 249 | 250 250 | from some_module import PotentialTypeVar -PYI034.pyi:248:9: PYI034 `__enter__` methods in classes like `Generic4` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic4` usually return `self` at runtime + --> PYI034.pyi:248:9 | 246 | class Generic4(collections.abc.Callable[P, ...]): 247 | def __new__(cls: type[Generic4]) -> Generic4: ... 248 | def __enter__(self: Generic4) -> Generic4: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ 249 | 250 | from some_module import PotentialTypeVar | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 245 245 | @@ -416,14 +436,15 @@ PYI034.pyi:248:9: PYI034 `__enter__` methods in classes like `Generic4` usually 250 250 | from some_module import PotentialTypeVar 251 251 | -PYI034.pyi:253:9: PYI034 `__new__` methods in classes like `Generic5` usually return `self` at runtime +PYI034 `__new__` methods in classes like `Generic5` usually return `self` at runtime + --> PYI034.pyi:253:9 | 252 | class Generic5(list[PotentialTypeVar]): 253 | def __new__(cls: type[Generic5]) -> Generic5: ... - | ^^^^^^^ PYI034 + | ^^^^^^^ 254 | def __enter__(self: Generic5) -> Generic5: ... | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 250 250 | from some_module import PotentialTypeVar @@ -433,14 +454,15 @@ PYI034.pyi:253:9: PYI034 `__new__` methods in classes like `Generic5` usually re 253 |+ def __new__(cls) -> typing.Self: ... 254 254 | def __enter__(self: Generic5) -> Generic5: ... -PYI034.pyi:254:9: PYI034 `__enter__` methods in classes like `Generic5` usually return `self` at runtime +PYI034 `__enter__` methods in classes like `Generic5` usually return `self` at runtime + --> PYI034.pyi:254:9 | 252 | class Generic5(list[PotentialTypeVar]): 253 | def __new__(cls: type[Generic5]) -> Generic5: ... 254 | def __enter__(self: Generic5) -> Generic5: ... - | ^^^^^^^^^ PYI034 + | ^^^^^^^^^ | - = help: Use `Self` as return type +help: Use `Self` as return type ℹ Display-only fix 251 251 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap index 7a6209c383..c53f35984a 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap @@ -1,29 +1,32 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI035.pyi:1:1: PYI035 `__all__` in a stub file must have a value, as it has the same semantics as `__all__` at runtime +PYI035 `__all__` in a stub file must have a value, as it has the same semantics as `__all__` at runtime + --> PYI035.pyi:1:1 | 1 | __all__: list[str] # Error: PYI035 - | ^^^^^^^^^^^^^^^^^^ PYI035 + | ^^^^^^^^^^^^^^^^^^ 2 | 3 | __all__: list[str] = ["foo"] | -PYI035.pyi:7:5: PYI035 `__match_args__` in a stub file must have a value, as it has the same semantics as `__match_args__` at runtime +PYI035 `__match_args__` in a stub file must have a value, as it has the same semantics as `__match_args__` at runtime + --> PYI035.pyi:7:5 | 5 | class Foo: 6 | __all__: list[str] 7 | __match_args__: tuple[str, ...] # Error: PYI035 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | __slots__: tuple[str, ...] # Error: PYI035 | -PYI035.pyi:8:5: PYI035 `__slots__` in a stub file must have a value, as it has the same semantics as `__slots__` at runtime +PYI035 `__slots__` in a stub file must have a value, as it has the same semantics as `__slots__` at runtime + --> PYI035.pyi:8:5 | 6 | __all__: list[str] 7 | __match_args__: tuple[str, ...] # Error: PYI035 8 | __slots__: tuple[str, ...] # Error: PYI035 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | class Bar: | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap index 34e31a8ea7..15a8ed0a74 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI036.py:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `object` +PYI036 [*] Star-args in `__exit__` should be annotated with `object` + --> PYI036.py:54:31 | 53 | class BadOne: 54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation - | ^^^ PYI036 + | ^^^ 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args | - = help: Annotate star-args with `object` +help: Annotate star-args with `object` ℹ Safe fix 51 51 | @@ -20,96 +21,106 @@ PYI036.py:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `ob 56 56 | 57 57 | class BadTwo: -PYI036.py:55:24: PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`) +PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`) + --> PYI036.py:55:24 | 53 | class BadOne: 54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args - | ^^^^^^ PYI036 + | ^^^^^^ 56 | 57 | class BadTwo: | -PYI036.py:58:38: PYI036 All arguments after the first four in `__exit__` must have a default value +PYI036 All arguments after the first four in `__exit__` must have a default value + --> PYI036.py:58:38 | 57 | class BadTwo: 58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^ 59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ...# PYI036: Extra arg must have default | -PYI036.py:59:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value +PYI036 All keyword-only arguments in `__aexit__` must have a default value + --> PYI036.py:59:48 | 57 | class BadTwo: 58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default 59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ...# PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^ 60 | 61 | class BadThree: | -PYI036.py:62:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` +PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` + --> PYI036.py:62:29 | 61 | class BadThree: 62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… - | ^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^ 63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… | -PYI036.py:63:73: PYI036 The second argument in `__aexit__` should be annotated with `object` or `BaseException | None` +PYI036 The second argument in `__aexit__` should be annotated with `object` or `BaseException | None` + --> PYI036.py:63:73 | 61 | class BadThree: 62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… 63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… - | ^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^ 64 | 65 | class BadFour: | -PYI036.py:63:94: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` +PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` + --> PYI036.py:63:94 | 61 | class BadThree: 62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… 63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… - | ^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^ 64 | 65 | class BadFour: | -PYI036.py:66:111: PYI036 The third argument in `__exit__` should be annotated with `object` or `types.TracebackType | None` +PYI036 The third argument in `__exit__` should be annotated with `object` or `types.TracebackType | None` + --> PYI036.py:66:111 | -65 | … -66 | …xception]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation - | ^^^^^^^^^^^^^ PYI036 -67 | …n] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad… +65 | class BadFour: +66 | def __exit__(self, typ: typing.Optional[type[BaseException]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: … + | ^^^^^^^^^^^^^ +67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, … | -PYI036.py:67:101: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` +PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` + --> PYI036.py:67:101 | 65 | … -66 | …eption]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation -67 | … | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad a… - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 +66 | …Exception]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation +67 | …on] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has ba… + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 68 | … 69 | … | -PYI036.py:70:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` +PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` + --> PYI036.py:70:29 | 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation - | ^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^ 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | -PYI036.py:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `object` +PYI036 [*] Star-args in `__exit__` should be annotated with `object` + --> PYI036.py:70:58 | 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation - | ^^^^^^^^^ PYI036 + | ^^^^^^^^^ 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | - = help: Annotate star-args with `object` +help: Annotate star-args with `object` ℹ Safe fix 67 67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation @@ -121,16 +132,17 @@ PYI036.py:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `ob 72 72 | 73 73 | class BadSix: -PYI036.py:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `object` +PYI036 [*] Star-args in `__aexit__` should be annotated with `object` + --> PYI036.py:71:74 | 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… - | ^^^ PYI036 + | ^^^ 72 | 73 | class BadSix: | - = help: Annotate star-args with `object` +help: Annotate star-args with `object` ℹ Safe fix 68 68 | @@ -142,66 +154,73 @@ PYI036.py:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `o 73 73 | class BadSix: 74 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default -PYI036.py:74:38: PYI036 All arguments after the first four in `__exit__` must have a default value +PYI036 All arguments after the first four in `__exit__` must have a default value + --> PYI036.py:74:38 | 73 | class BadSix: 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^ 75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default | -PYI036.py:75:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value +PYI036 All keyword-only arguments in `__aexit__` must have a default value + --> PYI036.py:75:48 | 73 | class BadSix: 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default 75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default - | ^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^ 76 | 77 | class AllPositionalOnlyArgs: | -PYI036.py:82:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` +PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` + --> PYI036.py:82:29 | 81 | class BadAllPositionalOnlyArgs: 82 | def __exit__(self, typ: type[Exception] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ... - | ^^^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^^^ 83 | async def __aexit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType, /) -> None: ... | -PYI036.py:83:95: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` +PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` + --> PYI036.py:83:95 | 81 | class BadAllPositionalOnlyArgs: 82 | def __exit__(self, typ: type[Exception] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ... 83 | async def __aexit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType, /) -> None: ... - | ^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^ 84 | 85 | # Definitions not in a class scope can do whatever, we don't care | -PYI036.py:161:17: PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` +PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` + --> PYI036.py:161:17 | 159 | def __exit__(self, exc_typ: None, exc: None, tb: None) -> None: ... # Okay 160 | @overload 161 | def __exit__(self, exc_typ: Exception, exc: Exception, tb: TracebackType) -> None: ... # PYI036 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 162 | def __exit__(self, exc_typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ... | -PYI036.py:166:17: PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` +PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` + --> PYI036.py:166:17 | 164 | class UnacceptableOverload2: 165 | @overload 166 | def __exit__(self, exc_typ: type[BaseException] | None, exc: None, tb: None) -> None: ... # PYI036 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 167 | @overload 168 | def __exit__(self, exc_typ: object, exc: Exception, tb: builtins.TracebackType) -> None: ... # PYI036 | -PYI036.py:168:17: PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` +PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` + --> PYI036.py:168:17 | 166 | def __exit__(self, exc_typ: type[BaseException] | None, exc: None, tb: None) -> None: ... # PYI036 167 | @overload 168 | def __exit__(self, exc_typ: object, exc: Exception, tb: builtins.TracebackType) -> None: ... # PYI036 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 169 | def __exit__(self, exc_typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None: ... | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap index 116a7f499e..aad7a9348e 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI036.pyi:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `object` +PYI036 [*] Star-args in `__exit__` should be annotated with `object` + --> PYI036.pyi:54:31 | 53 | class BadOne: 54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation - | ^^^ PYI036 + | ^^^ 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args | - = help: Annotate star-args with `object` +help: Annotate star-args with `object` ℹ Safe fix 51 51 | @@ -20,106 +21,117 @@ PYI036.pyi:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `o 56 56 | 57 57 | class BadTwo: -PYI036.pyi:55:24: PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`) +PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`) + --> PYI036.pyi:55:24 | 53 | class BadOne: 54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args - | ^^^^^^ PYI036 + | ^^^^^^ 56 | 57 | class BadTwo: | -PYI036.pyi:58:38: PYI036 All arguments after the first four in `__exit__` must have a default value +PYI036 All arguments after the first four in `__exit__` must have a default value + --> PYI036.pyi:58:38 | 57 | class BadTwo: 58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^ 59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default | -PYI036.pyi:59:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value +PYI036 All keyword-only arguments in `__aexit__` must have a default value + --> PYI036.pyi:59:48 | 57 | class BadTwo: 58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default 59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default - | ^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^ 60 | 61 | class BadThree: | -PYI036.pyi:59:66: PYI036 All keyword-only arguments in `__aexit__` must have a default value +PYI036 All keyword-only arguments in `__aexit__` must have a default value + --> PYI036.pyi:59:66 | 57 | class BadTwo: 58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default 59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default - | ^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^ 60 | 61 | class BadThree: | -PYI036.pyi:62:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` +PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` + --> PYI036.pyi:62:29 | 61 | class BadThree: 62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… - | ^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^ 63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… | -PYI036.pyi:63:73: PYI036 The second argument in `__aexit__` should be annotated with `object` or `BaseException | None` +PYI036 The second argument in `__aexit__` should be annotated with `object` or `BaseException | None` + --> PYI036.pyi:63:73 | 61 | class BadThree: 62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… 63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… - | ^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^ 64 | 65 | class BadFour: | -PYI036.pyi:63:94: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` +PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` + --> PYI036.pyi:63:94 | 61 | class BadThree: 62 | def __exit__(self, typ: type[BaseException], exc: BaseException | None, tb: TracebackType | None) -> None: ... # PYI036: First arg… 63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI0… - | ^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^ 64 | 65 | class BadFour: | -PYI036.pyi:66:111: PYI036 The third argument in `__exit__` should be annotated with `object` or `types.TracebackType | None` +PYI036 The third argument in `__exit__` should be annotated with `object` or `types.TracebackType | None` + --> PYI036.pyi:66:111 | -65 | … -66 | …xception]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation - | ^^^^^^^^^^^^^ PYI036 -67 | …n] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad… +65 | class BadFour: +66 | def __exit__(self, typ: typing.Optional[type[BaseException]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: … + | ^^^^^^^^^^^^^ +67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, … | -PYI036.pyi:67:101: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` +PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` + --> PYI036.pyi:67:101 | 65 | … -66 | …eption]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation -67 | … | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad a… - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 +66 | …Exception]], exc: typing.Union[BaseException, None], tb: TracebackType) -> None: ... # PYI036: Third arg has bad annotation +67 | …on] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has ba… + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 68 | … 69 | … | -PYI036.pyi:70:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` +PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` + --> PYI036.pyi:70:29 | 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation - | ^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^ 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | -PYI036.pyi:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `object` +PYI036 [*] Star-args in `__exit__` should be annotated with `object` + --> PYI036.pyi:70:58 | 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation - | ^^^^^^^^^ PYI036 + | ^^^^^^^^^ 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… | - = help: Annotate star-args with `object` +help: Annotate star-args with `object` ℹ Safe fix 67 67 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException | None, __tb: typing.Union[TracebackType, None, int]) -> bool | None: ... # PYI036: Third arg has bad annotation @@ -131,16 +143,17 @@ PYI036.pyi:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `o 72 72 | 73 73 | class BadSix: -PYI036.pyi:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `object` +PYI036 [*] Star-args in `__aexit__` should be annotated with `object` + --> PYI036.pyi:71:74 | 69 | class BadFive: 70 | def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotati… - | ^^^ PYI036 + | ^^^ 72 | 73 | class BadSix: | - = help: Annotate star-args with `object` +help: Annotate star-args with `object` ℹ Safe fix 68 68 | @@ -152,64 +165,71 @@ PYI036.pyi:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with ` 73 73 | class BadSix: 74 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default -PYI036.pyi:74:38: PYI036 All arguments after the first four in `__exit__` must have a default value +PYI036 All arguments after the first four in `__exit__` must have a default value + --> PYI036.pyi:74:38 | 73 | class BadSix: 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^ 75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default | -PYI036.pyi:75:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value +PYI036 All keyword-only arguments in `__aexit__` must have a default value + --> PYI036.pyi:75:48 | 73 | class BadSix: 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default 75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default - | ^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^ | -PYI036.pyi:89:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` +PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` + --> PYI036.pyi:89:29 | 88 | class BadAllPositionalOnlyArgs: 89 | def __exit__(self, typ: type[Exception] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ... - | ^^^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^^^ 90 | async def __aexit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType, /) -> None: ... | -PYI036.pyi:90:95: PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` +PYI036 The third argument in `__aexit__` should be annotated with `object` or `types.TracebackType | None` + --> PYI036.pyi:90:95 | 88 | class BadAllPositionalOnlyArgs: 89 | def __exit__(self, typ: type[Exception] | None, exc: BaseException | None, tb: TracebackType | None, /) -> None: ... 90 | async def __aexit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: TracebackType, /) -> None: ... - | ^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^ 91 | 92 | # Definitions not in a class scope can do whatever, we don't care | -PYI036.pyi:159:17: PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` +PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` + --> PYI036.pyi:159:17 | 157 | def __exit__(self, exc_typ: None, exc: None, tb: None) -> None: ... # Okay 158 | @overload 159 | def __exit__(self, exc_typ: Exception, exc: Exception, tb: TracebackType) -> None: ... # PYI036 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 160 | 161 | class UnacceptableOverload2: | -PYI036.pyi:163:17: PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` +PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` + --> PYI036.pyi:163:17 | 161 | class UnacceptableOverload2: 162 | @overload 163 | def __exit__(self, exc_typ: type[BaseException] | None, exc: None, tb: None) -> None: ... # PYI036 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 164 | @overload 165 | def __exit__(self, exc_typ: object, exc: Exception, tb: builtins.TracebackType) -> None: ... # PYI036 | -PYI036.pyi:165:17: PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` +PYI036 Annotations for a three-argument `__exit__` overload (excluding `self`) should either be `None, None, None` or `type[BaseException], BaseException, types.TracebackType` + --> PYI036.pyi:165:17 | 163 | def __exit__(self, exc_typ: type[BaseException] | None, exc: None, tb: None) -> None: ... # PYI036 164 | @overload 165 | def __exit__(self, exc_typ: object, exc: Exception, tb: builtins.TracebackType) -> None: ... # PYI036 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_1.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_1.py.snap index a161e8d6f8..6f1d026f5c 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_1.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI041_1.py:23:14: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:23:14 | 23 | def f0(arg1: float | int) -> None: - | ^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^ 24 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 20 20 | ... @@ -19,13 +20,14 @@ PYI041_1.py:23:14: PYI041 [*] Use `float` instead of `int | float` 25 25 | 26 26 | -PYI041_1.py:27:30: PYI041 [*] Use `complex` instead of `float | complex` +PYI041 [*] Use `complex` instead of `float | complex` + --> PYI041_1.py:27:30 | 27 | def f1(arg1: float, *, arg2: float | list[str] | type[bool] | complex) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 24 24 | ... @@ -37,13 +39,14 @@ PYI041_1.py:27:30: PYI041 [*] Use `complex` instead of `float | complex` 29 29 | 30 30 | -PYI041_1.py:31:28: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:31:28 | 31 | def f2(arg1: int, /, arg2: int | int | float) -> None: - | ^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^ 32 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 28 28 | ... @@ -55,13 +58,14 @@ PYI041_1.py:31:28: PYI041 [*] Use `float` instead of `int | float` 33 33 | 34 34 | -PYI041_1.py:35:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:35:26 | 35 | def f3(arg1: int, *args: Union[int | int | float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 36 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 32 32 | ... @@ -73,13 +77,14 @@ PYI041_1.py:35:26: PYI041 [*] Use `float` instead of `int | float` 37 37 | 38 38 | -PYI041_1.py:39:24: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:39:24 | 39 | async def f4(**kwargs: int | int | float) -> None: - | ^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^ 40 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 36 36 | ... @@ -91,13 +96,14 @@ PYI041_1.py:39:24: PYI041 [*] Use `float` instead of `int | float` 41 41 | 42 42 | -PYI041_1.py:43:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:43:26 | 43 | def f5(arg1: int, *args: Union[int, int, float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^ 44 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 40 40 | ... @@ -109,13 +115,14 @@ PYI041_1.py:43:26: PYI041 [*] Use `float` instead of `int | float` 45 45 | 46 46 | -PYI041_1.py:47:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:47:26 | 47 | def f6(arg1: int, *args: Union[Union[int, int, float]]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 44 44 | ... @@ -127,13 +134,14 @@ PYI041_1.py:47:26: PYI041 [*] Use `float` instead of `int | float` 49 49 | 50 50 | -PYI041_1.py:51:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:51:26 | 51 | def f7(arg1: int, *args: Union[Union[Union[int, int, float]]]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 48 48 | ... @@ -145,13 +153,14 @@ PYI041_1.py:51:26: PYI041 [*] Use `float` instead of `int | float` 53 53 | 54 54 | -PYI041_1.py:55:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:55:26 | 55 | def f8(arg1: int, *args: Union[Union[Union[int | int | float]]]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 52 52 | ... @@ -163,18 +172,19 @@ PYI041_1.py:55:26: PYI041 [*] Use `float` instead of `int | float` 57 57 | 58 58 | -PYI041_1.py:60:10: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.py:60:10 | 59 | def f9( 60 | arg: Union[ # comment | __________^ 61 | | float, # another 62 | | complex, int] - | |_____________________^ PYI041 + | |_____________________^ 63 | ) -> None: 64 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Unsafe fix 57 57 | @@ -188,18 +198,19 @@ PYI041_1.py:60:10: PYI041 [*] Use `complex` instead of `int | float | complex` 64 62 | ... 65 63 | -PYI041_1.py:68:9: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.py:68:9 | 66 | def f10( 67 | arg: ( 68 | / int | # comment 69 | | float | # another 70 | | complex - | |_______________^ PYI041 + | |_______________^ 71 | ) 72 | ) -> None: | - = help: Remove redundant type +help: Remove redundant type ℹ Unsafe fix 65 65 | @@ -211,15 +222,16 @@ PYI041_1.py:68:9: PYI041 [*] Use `complex` instead of `int | float | complex` 71 69 | ) 72 70 | ) -> None: -PYI041_1.py:80:24: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.py:80:24 | 78 | ... 79 | 80 | def bad(self, arg: int | float | complex) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^ 81 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 77 77 | def good(self, arg: int) -> None: @@ -231,15 +243,16 @@ PYI041_1.py:80:24: PYI041 [*] Use `complex` instead of `int | float | complex` 82 82 | 83 83 | def bad2(self, arg: int | Union[float, complex]) -> None: -PYI041_1.py:83:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.py:83:25 | 81 | ... 82 | 83 | def bad2(self, arg: int | Union[float, complex]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 80 80 | def bad(self, arg: int | float | complex) -> None: @@ -251,15 +264,16 @@ PYI041_1.py:83:25: PYI041 [*] Use `complex` instead of `int | float | complex` 85 85 | 86 86 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: -PYI041_1.py:86:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.py:86:25 | 84 | ... 85 | 86 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 83 83 | def bad2(self, arg: int | Union[float, complex]) -> None: @@ -271,15 +285,16 @@ PYI041_1.py:86:25: PYI041 [*] Use `complex` instead of `int | float | complex` 88 88 | 89 89 | def bad4(self, arg: Union[float | complex, int]) -> None: -PYI041_1.py:89:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.py:89:25 | 87 | ... 88 | 89 | def bad4(self, arg: Union[float | complex, int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 86 86 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: @@ -291,15 +306,16 @@ PYI041_1.py:89:25: PYI041 [*] Use `complex` instead of `int | float | complex` 91 91 | 92 92 | def bad5(self, arg: int | (float | complex)) -> None: -PYI041_1.py:92:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.py:92:25 | 90 | ... 91 | 92 | def bad5(self, arg: int | (float | complex)) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^ 93 | ... | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 89 89 | def bad4(self, arg: Union[float | complex, int]) -> None: @@ -311,26 +327,28 @@ PYI041_1.py:92:25: PYI041 [*] Use `complex` instead of `int | float | complex` 94 94 | 95 95 | -PYI041_1.py:99:23: PYI041 Use `float` instead of `int | float` +PYI041 Use `float` instead of `int | float` + --> PYI041_1.py:99:23 | 97 | # fix must not yield runtime `None | None | ...` (TypeError) 98 | class Issue18298: 99 | def f1(self, arg: None | int | None | float = None) -> None: # PYI041 - no fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 100 | pass | - = help: Remove redundant type +help: Remove redundant type -PYI041_1.py:104:27: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:104:27 | 102 | if TYPE_CHECKING: 103 | 104 | def f2(self, arg: None | int | None | float = None) -> None: ... # PYI041 - with fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 105 | 106 | else: | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 101 101 | @@ -342,15 +360,16 @@ PYI041_1.py:104:27: PYI041 [*] Use `float` instead of `int | float` 106 106 | else: 107 107 | -PYI041_1.py:111:23: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.py:111:23 | 109 | pass 110 | 111 | def f3(self, arg: None | float | None | int | None = None) -> None: # PYI041 - with fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 112 | pass | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 108 108 | def f2(self, arg=None) -> None: diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_1.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_1.pyi.snap index 69f8f6fd36..a3cdaa28f9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_1.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_1.pyi.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI041_1.pyi:21:14: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:21:14 | 21 | def f0(arg1: float | int) -> None: ... # PYI041 - | ^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 18 18 | def good2(arg: int, arg2: int | bool) -> None: ... @@ -18,12 +19,13 @@ PYI041_1.pyi:21:14: PYI041 [*] Use `float` instead of `int | float` 23 23 | 24 24 | def f1(arg1: float, *, arg2: float | list[str] | type[bool] | complex) -> None: ... # PYI041 -PYI041_1.pyi:24:30: PYI041 [*] Use `complex` instead of `float | complex` +PYI041 [*] Use `complex` instead of `float | complex` + --> PYI041_1.pyi:24:30 | 24 | def f1(arg1: float, *, arg2: float | list[str] | type[bool] | complex) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 21 21 | def f0(arg1: float | int) -> None: ... # PYI041 @@ -35,12 +37,13 @@ PYI041_1.pyi:24:30: PYI041 [*] Use `complex` instead of `float | complex` 26 26 | 27 27 | def f2(arg1: int, /, arg2: int | int | float) -> None: ... # PYI041 -PYI041_1.pyi:27:28: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:27:28 | 27 | def f2(arg1: int, /, arg2: int | int | float) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 24 24 | def f1(arg1: float, *, arg2: float | list[str] | type[bool] | complex) -> None: ... # PYI041 @@ -52,12 +55,13 @@ PYI041_1.pyi:27:28: PYI041 [*] Use `float` instead of `int | float` 29 29 | 30 30 | def f3(arg1: int, *args: Union[int | int | float]) -> None: ... # PYI041 -PYI041_1.pyi:30:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:30:26 | 30 | def f3(arg1: int, *args: Union[int | int | float]) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 27 27 | def f2(arg1: int, /, arg2: int | int | float) -> None: ... # PYI041 @@ -69,14 +73,15 @@ PYI041_1.pyi:30:26: PYI041 [*] Use `float` instead of `int | float` 32 32 | 33 33 | async def f4(**kwargs: int | int | float) -> None: ... # PYI041 -PYI041_1.pyi:33:24: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:33:24 | 33 | async def f4(**kwargs: int | int | float) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^ 34 | 35 | def f5( | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 30 30 | def f3(arg1: int, *args: Union[int | int | float]) -> None: ... # PYI041 @@ -88,17 +93,18 @@ PYI041_1.pyi:33:24: PYI041 [*] Use `float` instead of `int | float` 35 35 | def f5( 36 36 | arg: Union[ # comment -PYI041_1.pyi:36:10: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.pyi:36:10 | 35 | def f5( 36 | arg: Union[ # comment | __________^ 37 | | float, # another 38 | | complex, int] - | |_____________________^ PYI041 + | |_____________________^ 39 | ) -> None: ... # PYI041 | - = help: Remove redundant type +help: Remove redundant type ℹ Unsafe fix 33 33 | async def f4(**kwargs: int | int | float) -> None: ... # PYI041 @@ -112,18 +118,19 @@ PYI041_1.pyi:36:10: PYI041 [*] Use `complex` instead of `int | float | complex` 40 38 | 41 39 | def f6( -PYI041_1.pyi:43:9: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.pyi:43:9 | 41 | def f6( 42 | arg: ( 43 | / int | # comment 44 | | float | # another 45 | | complex - | |_______________^ PYI041 + | |_______________^ 46 | ) 47 | ) -> None: ... # PYI041 | - = help: Remove redundant type +help: Remove redundant type ℹ Unsafe fix 40 40 | @@ -135,14 +142,15 @@ PYI041_1.pyi:43:9: PYI041 [*] Use `complex` instead of `int | float | complex` 46 44 | ) 47 45 | ) -> None: ... # PYI041 -PYI041_1.pyi:49:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:49:26 | 47 | ) -> None: ... # PYI041 48 | 49 | def f5(arg1: int, *args: Union[int, int, float]) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 46 46 | ) @@ -154,12 +162,13 @@ PYI041_1.pyi:49:26: PYI041 [*] Use `float` instead of `int | float` 51 51 | 52 52 | def f6(arg1: int, *args: Union[Union[int, int, float]]) -> None: ... # PYI041 -PYI041_1.pyi:52:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:52:26 | 52 | def f6(arg1: int, *args: Union[Union[int, int, float]]) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 49 49 | def f5(arg1: int, *args: Union[int, int, float]) -> None: ... # PYI041 @@ -171,12 +180,13 @@ PYI041_1.pyi:52:26: PYI041 [*] Use `float` instead of `int | float` 54 54 | 55 55 | def f7(arg1: int, *args: Union[Union[Union[int, int, float]]]) -> None: ... # PYI041 -PYI041_1.pyi:55:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:55:26 | 55 | def f7(arg1: int, *args: Union[Union[Union[int, int, float]]]) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 52 52 | def f6(arg1: int, *args: Union[Union[int, int, float]]) -> None: ... # PYI041 @@ -188,12 +198,13 @@ PYI041_1.pyi:55:26: PYI041 [*] Use `float` instead of `int | float` 57 57 | 58 58 | def f8(arg1: int, *args: Union[Union[Union[int | int | float]]]) -> None: ... # PYI041 -PYI041_1.pyi:58:26: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:58:26 | 58 | def f8(arg1: int, *args: Union[Union[Union[int | int | float]]]) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 55 55 | def f7(arg1: int, *args: Union[Union[Union[int, int, float]]]) -> None: ... # PYI041 @@ -205,16 +216,17 @@ PYI041_1.pyi:58:26: PYI041 [*] Use `float` instead of `int | float` 60 60 | 61 61 | class Foo: -PYI041_1.pyi:64:24: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.pyi:64:24 | 62 | def good(self, arg: int) -> None: ... 63 | 64 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^ 65 | 66 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 61 61 | class Foo: @@ -226,16 +238,17 @@ PYI041_1.pyi:64:24: PYI041 [*] Use `complex` instead of `int | float | complex` 66 66 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 67 67 | -PYI041_1.pyi:66:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.pyi:66:25 | 64 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 65 | 66 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 | 68 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 63 63 | @@ -247,16 +260,17 @@ PYI041_1.pyi:66:25: PYI041 [*] Use `complex` instead of `int | float | complex` 68 68 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 69 69 | -PYI041_1.pyi:68:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.pyi:68:25 | 66 | def bad2(self, arg: int | Union[float, complex]) -> None: ... # PYI041 67 | 68 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 69 | 70 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 65 65 | @@ -268,16 +282,17 @@ PYI041_1.pyi:68:25: PYI041 [*] Use `complex` instead of `int | float | complex` 70 70 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 71 71 | -PYI041_1.pyi:70:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.pyi:70:25 | 68 | def bad3(self, arg: Union[Union[float, complex], int]) -> None: ... # PYI041 69 | 70 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 71 | 72 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 67 67 | @@ -289,14 +304,15 @@ PYI041_1.pyi:70:25: PYI041 [*] Use `complex` instead of `int | float | complex` 72 72 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 73 73 | -PYI041_1.pyi:72:25: PYI041 [*] Use `complex` instead of `int | float | complex` +PYI041 [*] Use `complex` instead of `int | float | complex` + --> PYI041_1.pyi:72:25 | 70 | def bad4(self, arg: Union[float | complex, int]) -> None: ... # PYI041 71 | 72 | def bad5(self, arg: int | (float | complex)) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 69 69 | @@ -308,16 +324,17 @@ PYI041_1.pyi:72:25: PYI041 [*] Use `complex` instead of `int | float | complex` 74 74 | 75 75 | # https://github.com/astral-sh/ruff/issues/18298 -PYI041_1.pyi:78:23: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:78:23 | 76 | # fix must not yield runtime `None | None | ...` (TypeError) 77 | class Issue18298: 78 | def f1(self, arg: None | int | None | float = None) -> None: ... # PYI041 - with fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 79 | 80 | def f3(self, arg: None | float | None | int | None = None) -> None: ... # PYI041 - with fix | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 75 75 | # https://github.com/astral-sh/ruff/issues/18298 @@ -328,14 +345,15 @@ PYI041_1.pyi:78:23: PYI041 [*] Use `float` instead of `int | float` 79 79 | 80 80 | def f3(self, arg: None | float | None | int | None = None) -> None: ... # PYI041 - with fix -PYI041_1.pyi:80:23: PYI041 [*] Use `float` instead of `int | float` +PYI041 [*] Use `float` instead of `int | float` + --> PYI041_1.pyi:80:23 | 78 | def f1(self, arg: None | int | None | float = None) -> None: ... # PYI041 - with fix 79 | 80 | def f3(self, arg: None | float | None | int | None = None) -> None: ... # PYI041 - with fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove redundant type +help: Remove redundant type ℹ Safe fix 77 77 | class Issue18298: diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_2.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_2.py.snap index 10c39077a2..89e9266b91 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041_2.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI041_2.py:7:23: PYI041 Use `float` instead of `int | float` +PYI041 Use `float` instead of `int | float` + --> PYI041_2.py:7:23 | 5 | # fix must not yield runtime `None | None | ...` (TypeError) 6 | class Issue18298: 7 | def f1(self, arg: None | int | None | float = None) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | pass | - = help: Remove redundant type +help: Remove redundant type diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap index f4b565480b..990f785466 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI042.py:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase +PYI042 Type alias `just_literals_pipe_union` should be CamelCase + --> PYI042.py:10:1 | 8 | ) 9 | 10 | just_literals_pipe_union: TypeAlias = ( - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI042 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 11 | Literal[True] | Literal["idk"] 12 | ) # PYI042, since not camel case | -PYI042.py:19:1: PYI042 Type alias `snake_case_alias1` should be CamelCase +PYI042 Type alias `snake_case_alias1` should be CamelCase + --> PYI042.py:19:1 | 17 | _PrivateAliasS2: TypeAlias = Annotated[str, "also okay"] 18 | 19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case - | ^^^^^^^^^^^^^^^^^ PYI042 + | ^^^^^^^^^^^^^^^^^ 20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case 21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case | -PYI042.py:20:1: PYI042 Type alias `_snake_case_alias2` should be CamelCase +PYI042 Type alias `_snake_case_alias2` should be CamelCase + --> PYI042.py:20:1 | 19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case 20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case - | ^^^^^^^^^^^^^^^^^^ PYI042 + | ^^^^^^^^^^^^^^^^^^ 21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case | -PYI042.py:27:6: PYI042 Type alias `foo_bar` should be CamelCase +PYI042 Type alias `foo_bar` should be CamelCase + --> PYI042.py:27:6 | 26 | # PEP 695 27 | type foo_bar = int | str - | ^^^^^^^ PYI042 + | ^^^^^^^ 28 | type FooBar = int | str | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap index 7e1457c68b..78334e7896 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI042.pyi:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase +PYI042 Type alias `just_literals_pipe_union` should be CamelCase + --> PYI042.pyi:10:1 | 8 | ) 9 | 10 | just_literals_pipe_union: TypeAlias = ( - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI042 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 11 | Literal[True] | Literal["idk"] 12 | ) # PYI042, since not camel case | -PYI042.pyi:19:1: PYI042 Type alias `snake_case_alias1` should be CamelCase +PYI042 Type alias `snake_case_alias1` should be CamelCase + --> PYI042.pyi:19:1 | 17 | _PrivateAliasS2: TypeAlias = Annotated[str, "also okay"] 18 | 19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case - | ^^^^^^^^^^^^^^^^^ PYI042 + | ^^^^^^^^^^^^^^^^^ 20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case 21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case | -PYI042.pyi:20:1: PYI042 Type alias `_snake_case_alias2` should be CamelCase +PYI042 Type alias `_snake_case_alias2` should be CamelCase + --> PYI042.pyi:20:1 | 19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case 20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case - | ^^^^^^^^^^^^^^^^^^ PYI042 + | ^^^^^^^^^^^^^^^^^^ 21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case | -PYI042.pyi:27:6: PYI042 Type alias `foo_bar` should be CamelCase +PYI042 Type alias `foo_bar` should be CamelCase + --> PYI042.pyi:27:6 | 26 | # PEP 695 27 | type foo_bar = int | str - | ^^^^^^^ PYI042 + | ^^^^^^^ 28 | type FooBar = int | str | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap index d9a02f87e4..20ff0aaae4 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap @@ -1,39 +1,43 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI043.py:10:1: PYI043 Private type alias `_PrivateAliasT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) +PYI043 Private type alias `_PrivateAliasT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + --> PYI043.py:10:1 | 8 | ) 9 | 10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T - | ^^^^^^^^^^^^^^ PYI043 + | ^^^^^^^^^^^^^^ 11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T 12 | _PrivateAliasT3: TypeAlias = Literal[ | -PYI043.py:11:1: PYI043 Private type alias `_PrivateAliasT2` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) +PYI043 Private type alias `_PrivateAliasT2` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + --> PYI043.py:11:1 | 10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T 11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T - | ^^^^^^^^^^^^^^^ PYI043 + | ^^^^^^^^^^^^^^^ 12 | _PrivateAliasT3: TypeAlias = Literal[ 13 | "not", "a", "chance" | -PYI043.py:12:1: PYI043 Private type alias `_PrivateAliasT3` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) +PYI043 Private type alias `_PrivateAliasT3` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + --> PYI043.py:12:1 | 10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T 11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T 12 | _PrivateAliasT3: TypeAlias = Literal[ - | ^^^^^^^^^^^^^^^ PYI043 + | ^^^^^^^^^^^^^^^ 13 | "not", "a", "chance" 14 | ] # PYI043, since this ends in a T | -PYI043.py:26:6: PYI043 Private type alias `_FooT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) +PYI043 Private type alias `_FooT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + --> PYI043.py:26:6 | 25 | # PEP 695 26 | type _FooT = str | int - | ^^^^^ PYI043 + | ^^^^^ 27 | type Foo = str | int | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap index 81526e7463..54775126bd 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap @@ -1,39 +1,43 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI043.pyi:10:1: PYI043 Private type alias `_PrivateAliasT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) +PYI043 Private type alias `_PrivateAliasT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + --> PYI043.pyi:10:1 | 8 | ) 9 | 10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T - | ^^^^^^^^^^^^^^ PYI043 + | ^^^^^^^^^^^^^^ 11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T 12 | _PrivateAliasT3: TypeAlias = Literal[ | -PYI043.pyi:11:1: PYI043 Private type alias `_PrivateAliasT2` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) +PYI043 Private type alias `_PrivateAliasT2` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + --> PYI043.pyi:11:1 | 10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T 11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T - | ^^^^^^^^^^^^^^^ PYI043 + | ^^^^^^^^^^^^^^^ 12 | _PrivateAliasT3: TypeAlias = Literal[ 13 | "not", "a", "chance" | -PYI043.pyi:12:1: PYI043 Private type alias `_PrivateAliasT3` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) +PYI043 Private type alias `_PrivateAliasT3` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + --> PYI043.pyi:12:1 | 10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T 11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T 12 | _PrivateAliasT3: TypeAlias = Literal[ - | ^^^^^^^^^^^^^^^ PYI043 + | ^^^^^^^^^^^^^^^ 13 | "not", "a", "chance" 14 | ] # PYI043, since this ends in a T | -PYI043.pyi:26:6: PYI043 Private type alias `_FooT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) +PYI043 Private type alias `_FooT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + --> PYI043.pyi:26:6 | 25 | # PEP 695 26 | type _FooT = str | int - | ^^^^^ PYI043 + | ^^^^^ 27 | type Foo = str | int | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap index 4ae21763be..bf7da8eb1f 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI044.pyi:2:1: PYI044 [*] `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics +PYI044 [*] `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics + --> PYI044.pyi:2:1 | 1 | # Bad import. 2 | from __future__ import annotations # PYI044. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI044 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | from __future__ import annotations, with_statement # PYI044. | - = help: Remove `from __future__ import annotations` +help: Remove `from __future__ import annotations` ℹ Safe fix 1 1 | # Bad import. @@ -17,16 +18,17 @@ PYI044.pyi:2:1: PYI044 [*] `from __future__ import annotations` has no effect in 4 3 | 5 4 | # Good imports. -PYI044.pyi:3:1: PYI044 [*] `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics +PYI044 [*] `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics + --> PYI044.pyi:3:1 | 1 | # Bad import. 2 | from __future__ import annotations # PYI044. 3 | from __future__ import annotations, with_statement # PYI044. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI044 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | # Good imports. | - = help: Remove `from __future__ import annotations` +help: Remove `from __future__ import annotations` ℹ Safe fix 1 1 | # Bad import. diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.py.snap index 39967a4bbd..d0ef71d709 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.py.snap @@ -1,59 +1,65 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI045.py:12:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.py:12:27 | 11 | class TypingIterableTReturn: 12 | def __iter__(self) -> typing.Iterable[int]: - | ^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^ 13 | ... | -PYI045.py:20:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.py:20:27 | 19 | class TypingIterableReturn: 20 | def __iter__(self) -> typing.Iterable: - | ^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^ 21 | ... | -PYI045.py:28:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.py:28:27 | 27 | class CollectionsIterableTReturn: 28 | def __iter__(self) -> collections.abc.Iterable[int]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | ... | -PYI045.py:36:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.py:36:27 | 35 | class CollectionsIterableReturn: 36 | def __iter__(self) -> collections.abc.Iterable: - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 37 | ... | -PYI045.py:44:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.py:44:27 | 43 | class IterableReturn: 44 | def __iter__(self) -> Iterable: - | ^^^^^^^^ PYI045 + | ^^^^^^^^ 45 | ... | -PYI045.py:79:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` +PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` + --> PYI045.py:79:28 | 78 | class TypingAsyncIterableTReturn: 79 | def __aiter__(self) -> typing.AsyncIterable[int]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 80 | ... | -PYI045.py:84:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` +PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` + --> PYI045.py:84:28 | 83 | class TypingAsyncIterableReturn: 84 | def __aiter__(self) -> typing.AsyncIterable: - | ^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^ 85 | ... | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap index bca6451be5..7b97f5d3f8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap @@ -1,59 +1,66 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI045.pyi:9:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.pyi:9:27 | 8 | class TypingIterableTReturn: 9 | def __iter__(self) -> typing.Iterable[int]: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^ 10 | def not_iter(self) -> typing.Iterable[int]: ... | -PYI045.pyi:13:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.pyi:13:27 | 12 | class TypingIterableReturn: 13 | def __iter__(self) -> typing.Iterable: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^ 14 | def not_iter(self) -> typing.Iterable: ... | -PYI045.pyi:17:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.pyi:17:27 | 16 | class CollectionsIterableTReturn: 17 | def __iter__(self) -> collections.abc.Iterable[int]: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | def not_iter(self) -> collections.abc.Iterable[int]: ... | -PYI045.pyi:21:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.pyi:21:27 | 20 | class CollectionsIterableReturn: 21 | def __iter__(self) -> collections.abc.Iterable: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 22 | def not_iter(self) -> collections.abc.Iterable: ... | -PYI045.pyi:25:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` +PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + --> PYI045.pyi:25:27 | 24 | class IterableReturn: 25 | def __iter__(self) -> Iterable: ... # Error: PYI045 - | ^^^^^^^^ PYI045 + | ^^^^^^^^ 26 | 27 | class IteratorReturn: | -PYI045.pyi:46:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` +PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` + --> PYI045.pyi:46:28 | 45 | class TypingAsyncIterableTReturn: 46 | def __aiter__(self) -> typing.AsyncIterable[int]: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | 48 | class TypingAsyncIterableReturn: | -PYI045.pyi:49:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` +PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` + --> PYI045.pyi:49:28 | 48 | class TypingAsyncIterableReturn: 49 | def __aiter__(self) -> typing.AsyncIterable: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^ PYI045 + | ^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.py.snap index 69f5b98235..24e6a11063 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI046.py:5:7: PYI046 Private protocol `_Foo` is never used +PYI046 Private protocol `_Foo` is never used + --> PYI046.py:5:7 | 5 | class _Foo(Protocol): - | ^^^^ PYI046 + | ^^^^ 6 | bar: int | -PYI046.py:9:7: PYI046 Private protocol `_Bar` is never used +PYI046 Private protocol `_Bar` is never used + --> PYI046.py:9:7 | 9 | class _Bar(typing.Protocol): - | ^^^^ PYI046 + | ^^^^ 10 | bar: int | -PYI046.py:16:7: PYI046 Private protocol `_Baz` is never used +PYI046 Private protocol `_Baz` is never used + --> PYI046.py:16:7 | 16 | class _Baz(Protocol[_T]): - | ^^^^ PYI046 + | ^^^^ 17 | x: _T | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap index 9cd85868ae..bd6685efa5 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI046.pyi:5:7: PYI046 Private protocol `_Foo` is never used +PYI046 Private protocol `_Foo` is never used + --> PYI046.pyi:5:7 | 5 | class _Foo(object, Protocol): - | ^^^^ PYI046 + | ^^^^ 6 | bar: int | -PYI046.pyi:9:7: PYI046 Private protocol `_Bar` is never used +PYI046 Private protocol `_Bar` is never used + --> PYI046.pyi:9:7 | 9 | class _Bar(typing.Protocol): - | ^^^^ PYI046 + | ^^^^ 10 | bar: int | -PYI046.pyi:16:7: PYI046 Private protocol `_Baz` is never used +PYI046 Private protocol `_Baz` is never used + --> PYI046.pyi:16:7 | 16 | class _Baz(Protocol[_T]): - | ^^^^ PYI046 + | ^^^^ 17 | x: _T | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap index 3fda1b217d..4d7593b7d6 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap @@ -1,36 +1,40 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI047.py:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used +PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used + --> PYI047.py:6:1 | 6 | _UnusedPrivateTypeAlias: TypeAlias = int | None - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI047 + | ^^^^^^^^^^^^^^^^^^^^^^^ 7 | _T: typing.TypeAlias = str | -PYI047.py:7:1: PYI047 Private TypeAlias `_T` is never used +PYI047 Private TypeAlias `_T` is never used + --> PYI047.py:7:1 | 6 | _UnusedPrivateTypeAlias: TypeAlias = int | None 7 | _T: typing.TypeAlias = str - | ^^ PYI047 + | ^^ 8 | 9 | # OK | -PYI047.py:24:6: PYI047 Private TypeAlias `_UnusedPEP695` is never used +PYI047 Private TypeAlias `_UnusedPEP695` is never used + --> PYI047.py:24:6 | 22 | def func2(arg: _PrivateTypeAlias) -> None: ... 23 | 24 | type _UnusedPEP695 = int - | ^^^^^^^^^^^^^ PYI047 + | ^^^^^^^^^^^^^ 25 | type _UnusedGeneric695[T] = list[T] | -PYI047.py:25:6: PYI047 Private TypeAlias `_UnusedGeneric695` is never used +PYI047 Private TypeAlias `_UnusedGeneric695` is never used + --> PYI047.py:25:6 | 24 | type _UnusedPEP695 = int 25 | type _UnusedGeneric695[T] = list[T] - | ^^^^^^^^^^^^^^^^^ PYI047 + | ^^^^^^^^^^^^^^^^^ 26 | 27 | type _UsedPEP695 = str | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap index a27c276530..fabd47ebfe 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap @@ -1,36 +1,40 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI047.pyi:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used +PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used + --> PYI047.pyi:6:1 | 6 | _UnusedPrivateTypeAlias: TypeAlias = int | None - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI047 + | ^^^^^^^^^^^^^^^^^^^^^^^ 7 | _T: typing.TypeAlias = str | -PYI047.pyi:7:1: PYI047 Private TypeAlias `_T` is never used +PYI047 Private TypeAlias `_T` is never used + --> PYI047.pyi:7:1 | 6 | _UnusedPrivateTypeAlias: TypeAlias = int | None 7 | _T: typing.TypeAlias = str - | ^^ PYI047 + | ^^ 8 | 9 | # OK | -PYI047.pyi:24:6: PYI047 Private TypeAlias `_UnusedPEP695` is never used +PYI047 Private TypeAlias `_UnusedPEP695` is never used + --> PYI047.pyi:24:6 | 22 | def func2(arg: _PrivateTypeAlias) -> None: ... 23 | 24 | type _UnusedPEP695 = int - | ^^^^^^^^^^^^^ PYI047 + | ^^^^^^^^^^^^^ 25 | type _UnusedGeneric695[T] = list[T] | -PYI047.pyi:25:6: PYI047 Private TypeAlias `_UnusedGeneric695` is never used +PYI047 Private TypeAlias `_UnusedGeneric695` is never used + --> PYI047.pyi:25:6 | 24 | type _UnusedPEP695 = int 25 | type _UnusedGeneric695[T] = list[T] - | ^^^^^^^^^^^^^^^^^ PYI047 + | ^^^^^^^^^^^^^^^^^ 26 | 27 | type _UsedPEP695 = str | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap index ffd683822a..1f8b41d5d8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap @@ -1,32 +1,35 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI048.pyi:8:5: PYI048 Function body must contain exactly one statement +PYI048 Function body must contain exactly one statement + --> PYI048.pyi:8:5 | 6 | """oof""" # OK 7 | 8 | def oof(): # ERROR PYI048 - | ^^^ PYI048 + | ^^^ 9 | """oof""" 10 | print("foo") | -PYI048.pyi:12:5: PYI048 Function body must contain exactly one statement +PYI048 Function body must contain exactly one statement + --> PYI048.pyi:12:5 | 10 | print("foo") 11 | 12 | def foo(): # ERROR PYI048 - | ^^^ PYI048 + | ^^^ 13 | """foo""" 14 | print("foo") | -PYI048.pyi:17:5: PYI048 Function body must contain exactly one statement +PYI048 Function body must contain exactly one statement + --> PYI048.pyi:17:5 | 15 | print("foo") 16 | 17 | def buzz(): # ERROR PYI048 - | ^^^^ PYI048 + | ^^^^ 18 | print("fizz") 19 | print("buzz") | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.py.snap index 6c5b9a2542..bc182df49e 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI049.py:5:7: PYI049 Private TypedDict `_UnusedTypedDict` is never used +PYI049 Private TypedDict `_UnusedTypedDict` is never used + --> PYI049.py:5:7 | 5 | class _UnusedTypedDict(TypedDict): - | ^^^^^^^^^^^^^^^^ PYI049 + | ^^^^^^^^^^^^^^^^ 6 | foo: str | -PYI049.py:9:7: PYI049 Private TypedDict `_UnusedTypedDict2` is never used +PYI049 Private TypedDict `_UnusedTypedDict2` is never used + --> PYI049.py:9:7 | 9 | class _UnusedTypedDict2(typing.TypedDict): - | ^^^^^^^^^^^^^^^^^ PYI049 + | ^^^^^^^^^^^^^^^^^ 10 | bar: int | -PYI049.py:21:1: PYI049 Private TypedDict `_UnusedTypedDict3` is never used +PYI049 Private TypedDict `_UnusedTypedDict3` is never used + --> PYI049.py:21:1 | 21 | _UnusedTypedDict3 = TypedDict("_UnusedTypedDict3", {"foo": int}) - | ^^^^^^^^^^^^^^^^^ PYI049 + | ^^^^^^^^^^^^^^^^^ 22 | _UsedTypedDict3 = TypedDict("_UsedTypedDict3", {"bar": bytes}) | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap index 68cfc0c50f..615be91dfe 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap @@ -1,34 +1,38 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI049.pyi:6:7: PYI049 Private TypedDict `_UnusedTypedDict` is never used +PYI049 Private TypedDict `_UnusedTypedDict` is never used + --> PYI049.pyi:6:7 | 6 | class _UnusedTypedDict(TypedDict): - | ^^^^^^^^^^^^^^^^ PYI049 + | ^^^^^^^^^^^^^^^^ 7 | foo: str | -PYI049.pyi:10:7: PYI049 Private TypedDict `_UnusedTypedDict2` is never used +PYI049 Private TypedDict `_UnusedTypedDict2` is never used + --> PYI049.pyi:10:7 | 10 | class _UnusedTypedDict2(typing.TypedDict): - | ^^^^^^^^^^^^^^^^^ PYI049 + | ^^^^^^^^^^^^^^^^^ 11 | bar: int | -PYI049.pyi:34:1: PYI049 Private TypedDict `_UnusedTypedDict3` is never used +PYI049 Private TypedDict `_UnusedTypedDict3` is never used + --> PYI049.pyi:34:1 | 32 | bar: list[int] 33 | 34 | _UnusedTypedDict3 = TypedDict("_UnusedTypedDict3", {"foo": int}) - | ^^^^^^^^^^^^^^^^^ PYI049 + | ^^^^^^^^^^^^^^^^^ 35 | _UsedTypedDict3 = TypedDict("_UsedTypedDict3", {"bar": bytes}) | -PYI049.pyi:43:11: PYI049 Private TypedDict `_UnusedTypeDict4` is never used +PYI049 Private TypedDict `_UnusedTypeDict4` is never used + --> PYI049.pyi:43:11 | 41 | # scope (unlike in `.py` files). 42 | class _CustomClass3: 43 | class _UnusedTypeDict4(TypedDict): - | ^^^^^^^^^^^^^^^^ PYI049 + | ^^^^^^^^^^^^^^^^ 44 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.py.snap index 1ae425e4ba..3a3fdea0ca 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.py.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI050.py:13:24: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.py:13:24 | 13 | def foo_no_return(arg: NoReturn): - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 14 | ... | -PYI050.py:18:10: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.py:18:10 | 17 | def foo_no_return_typing_extensions( 18 | arg: typing_extensions.NoReturn, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI050 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | ): 20 | ... | -PYI050.py:23:44: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.py:23:44 | 23 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 24 | ... | -PYI050.py:27:47: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.py:27:47 | 27 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 28 | ... | -PYI050.py:35:21: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.py:35:21 | 35 | def stringized(arg: "NoReturn"): - | ^^^^^^^^^^ PYI050 + | ^^^^^^^^^^ 36 | ... | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap index 194e7e0253..ab34a1242f 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap @@ -1,112 +1,122 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI050.pyi:6:24: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:6:24 | 4 | def foo(arg): ... 5 | def foo_int(arg: int): ... 6 | def foo_no_return(arg: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 7 | def foo_no_return_typing_extensions( 8 | arg: typing_extensions.NoReturn, | -PYI050.pyi:8:10: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:8:10 | 6 | def foo_no_return(arg: NoReturn): ... # Error: PYI050 7 | def foo_no_return_typing_extensions( 8 | arg: typing_extensions.NoReturn, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI050 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | ): ... # Error: PYI050 10 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): ... # Error: PYI050 | -PYI050.pyi:10:44: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:10:44 | 8 | arg: typing_extensions.NoReturn, 9 | ): ... # Error: PYI050 10 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 11 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): ... # Error: PYI050 12 | def foo_never(arg: Never): ... | -PYI050.pyi:11:47: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:11:47 | 9 | ): ... # Error: PYI050 10 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): ... # Error: PYI050 11 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 12 | def foo_never(arg: Never): ... 13 | def foo_args(*args: NoReturn): ... # Error: PYI050 | -PYI050.pyi:13:21: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:13:21 | 11 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): ... # Error: PYI050 12 | def foo_never(arg: Never): ... 13 | def foo_args(*args: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 14 | def foo_kwargs(**kwargs: NoReturn): ... # Error: PYI050 15 | def foo_args_kwargs(*args: NoReturn, **kwargs: NoReturn): ... # Error: PYI050 | -PYI050.pyi:14:26: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:14:26 | 12 | def foo_never(arg: Never): ... 13 | def foo_args(*args: NoReturn): ... # Error: PYI050 14 | def foo_kwargs(**kwargs: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 15 | def foo_args_kwargs(*args: NoReturn, **kwargs: NoReturn): ... # Error: PYI050 16 | def foo_int_args(*args: int): ... | -PYI050.pyi:15:28: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:15:28 | 13 | def foo_args(*args: NoReturn): ... # Error: PYI050 14 | def foo_kwargs(**kwargs: NoReturn): ... # Error: PYI050 15 | def foo_args_kwargs(*args: NoReturn, **kwargs: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 16 | def foo_int_args(*args: int): ... 17 | def foo_int_kwargs(**kwargs: int): ... | -PYI050.pyi:15:48: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:15:48 | 13 | def foo_args(*args: NoReturn): ... # Error: PYI050 14 | def foo_kwargs(**kwargs: NoReturn): ... # Error: PYI050 15 | def foo_args_kwargs(*args: NoReturn, **kwargs: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 16 | def foo_int_args(*args: int): ... 17 | def foo_int_kwargs(**kwargs: int): ... | -PYI050.pyi:19:50: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:19:50 | 17 | def foo_int_kwargs(**kwargs: int): ... 18 | def foo_int_args_kwargs(*args: int, **kwargs: int): ... 19 | def foo_int_args_no_return(*args: int, **kwargs: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 20 | def foo_int_kwargs_no_return(*args: NoReturn, **kwargs: int): ... # Error: PYI050 21 | def foo_args_never(*args: Never): ... | -PYI050.pyi:20:37: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:20:37 | 18 | def foo_int_args_kwargs(*args: int, **kwargs: int): ... 19 | def foo_int_args_no_return(*args: int, **kwargs: NoReturn): ... # Error: PYI050 20 | def foo_int_kwargs_no_return(*args: NoReturn, **kwargs: int): ... # Error: PYI050 - | ^^^^^^^^ PYI050 + | ^^^^^^^^ 21 | def foo_args_never(*args: Never): ... 22 | def foo_kwargs_never(**kwargs: Never): ... | -PYI050.pyi:24:21: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations +PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + --> PYI050.pyi:24:21 | 22 | def foo_kwargs_never(**kwargs: Never): ... 23 | def foo_args_kwargs_never(*args: Never, **kwargs: Never): ... 24 | def stringized(arg: "NoReturn"): ... - | ^^^^^^^^^^ PYI050 + | ^^^^^^^^^^ 25 | def stringized_good(arg: "Never"): ... | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap index 84850e38e7..6175ba8090 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap @@ -1,119 +1,131 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI051.py:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.py:4:18 | 2 | from typing import Literal, TypeAlias, Union 3 | 4 | A: str | Literal["foo"] - | ^^^^^ PYI051 + | ^^^^^ 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] | -PYI051.py:5:37: PYI051 `Literal[b"bar"]` is redundant in a union with `bytes` +PYI051 `Literal[b"bar"]` is redundant in a union with `bytes` + --> PYI051.py:5:37 | 4 | A: str | Literal["foo"] 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] - | ^^^^^^ PYI051 + | ^^^^^^ 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] | -PYI051.py:5:45: PYI051 `Literal[b"foo"]` is redundant in a union with `bytes` +PYI051 `Literal[b"foo"]` is redundant in a union with `bytes` + --> PYI051.py:5:45 | 4 | A: str | Literal["foo"] 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] - | ^^^^^^ PYI051 + | ^^^^^^ 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] | -PYI051.py:6:37: PYI051 `Literal[5]` is redundant in a union with `int` +PYI051 `Literal[5]` is redundant in a union with `int` + --> PYI051.py:6:37 | 4 | A: str | Literal["foo"] 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | ^ PYI051 + | ^ 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] | -PYI051.py:6:67: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.py:6:67 | 4 | A: str | Literal["foo"] 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | ^^^^^ PYI051 + | ^^^^^ 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] | -PYI051.py:7:37: PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes` +PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes` + --> PYI051.py:7:37 | 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | ^^^^^^^^^^^^ PYI051 + | ^^^^^^^^^^^^ 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | -PYI051.py:7:51: PYI051 `Literal[42]` is redundant in a union with `int` +PYI051 `Literal[42]` is redundant in a union with `int` + --> PYI051.py:7:51 | 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | ^^ PYI051 + | ^^ 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | -PYI051.py:8:76: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.py:8:76 | 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] - | ^^^^^ PYI051 + | ^^^^^ 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | -PYI051.py:9:81: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.py:9:81 | 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] - | ^^^^^ PYI051 + | ^^^^^ 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | -PYI051.py:10:69: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.py:10:69 | 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] - | ^^^^^ PYI051 + | ^^^^^ 11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... | -PYI051.py:12:31: PYI051 `Literal[1J]` is redundant in a union with `complex` +PYI051 `Literal[1J]` is redundant in a union with `complex` + --> PYI051.py:12:31 | 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | ^^ PYI051 + | ^^ 13 | 14 | # OK | -PYI051.py:12:53: PYI051 `Literal[3.14]` is redundant in a union with `float` +PYI051 `Literal[3.14]` is redundant in a union with `float` + --> PYI051.py:12:53 | 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | ^^^^ PYI051 + | ^^^^ 13 | 14 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap index cf1f213ca1..c387b3ccc7 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap @@ -1,119 +1,131 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI051.pyi:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.pyi:4:18 | 2 | from typing import Literal, TypeAlias, Union 3 | 4 | A: str | Literal["foo"] - | ^^^^^ PYI051 + | ^^^^^ 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] | -PYI051.pyi:5:37: PYI051 `Literal[b"bar"]` is redundant in a union with `bytes` +PYI051 `Literal[b"bar"]` is redundant in a union with `bytes` + --> PYI051.pyi:5:37 | 4 | A: str | Literal["foo"] 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] - | ^^^^^^ PYI051 + | ^^^^^^ 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] | -PYI051.pyi:5:45: PYI051 `Literal[b"foo"]` is redundant in a union with `bytes` +PYI051 `Literal[b"foo"]` is redundant in a union with `bytes` + --> PYI051.pyi:5:45 | 4 | A: str | Literal["foo"] 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] - | ^^^^^^ PYI051 + | ^^^^^^ 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] | -PYI051.pyi:6:37: PYI051 `Literal[5]` is redundant in a union with `int` +PYI051 `Literal[5]` is redundant in a union with `int` + --> PYI051.pyi:6:37 | 4 | A: str | Literal["foo"] 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | ^ PYI051 + | ^ 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] | -PYI051.pyi:6:67: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.pyi:6:67 | 4 | A: str | Literal["foo"] 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | ^^^^^ PYI051 + | ^^^^^ 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] | -PYI051.pyi:7:37: PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes` +PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes` + --> PYI051.pyi:7:37 | 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | ^^^^^^^^^^^^ PYI051 + | ^^^^^^^^^^^^ 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | -PYI051.pyi:7:51: PYI051 `Literal[42]` is redundant in a union with `int` +PYI051 `Literal[42]` is redundant in a union with `int` + --> PYI051.pyi:7:51 | 5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | ^^ PYI051 + | ^^ 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | -PYI051.pyi:8:76: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.pyi:8:76 | 6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] - | ^^^^^ PYI051 + | ^^^^^ 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | -PYI051.pyi:9:81: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.pyi:9:81 | 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] - | ^^^^^ PYI051 + | ^^^^^ 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] | -PYI051.pyi:10:69: PYI051 `Literal["foo"]` is redundant in a union with `str` +PYI051 `Literal["foo"]` is redundant in a union with `str` + --> PYI051.pyi:10:69 | 8 | E: TypeAlias = typing.Union[typing.Union[typing.Union[typing.Union[Literal["foo"], str]]]] 9 | F: TypeAlias = typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] - | ^^^^^ PYI051 + | ^^^^^ 11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... | -PYI051.pyi:12:31: PYI051 `Literal[1J]` is redundant in a union with `complex` +PYI051 `Literal[1J]` is redundant in a union with `complex` + --> PYI051.pyi:12:31 | 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | ^^ PYI051 + | ^^ 13 | 14 | # OK | -PYI051.pyi:12:53: PYI051 `Literal[3.14]` is redundant in a union with `float` +PYI051 `Literal[3.14]` is redundant in a union with `float` + --> PYI051.pyi:12:53 | 10 | G: typing.Union[str, typing.Union[typing.Union[typing.Union[Literal["foo"], int]]]] 11 | 12 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | ^^^^ PYI051 + | ^^^^ 13 | 14 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap index 210dcc1918..2895a6c4f3 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap @@ -1,139 +1,153 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI052.pyi:14:10: PYI052 Need type annotation for `field5` +PYI052 Need type annotation for `field5` + --> PYI052.pyi:14:10 | 12 | field43: int = -0xFFFFFFFF 13 | field44: int = -1234567890 14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need ty… - | ^ PYI052 + | ^ 15 | field6 = 0 # Y052 Need type annotation for "field6" 16 | field7 = b"" # Y052 Need type annotation for "field7" | -PYI052.pyi:15:10: PYI052 Need type annotation for `field6` +PYI052 Need type annotation for `field6` + --> PYI052.pyi:15:10 | 13 | field44: int = -1234567890 14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need ty… 15 | field6 = 0 # Y052 Need type annotation for "field6" - | ^ PYI052 + | ^ 16 | field7 = b"" # Y052 Need type annotation for "field7" 17 | field71 = "foo" # Y052 Need type annotation for "field71" | -PYI052.pyi:16:10: PYI052 Need type annotation for `field7` +PYI052 Need type annotation for `field7` + --> PYI052.pyi:16:10 | 14 | field5 = 0 # type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") # Y052 Need ty… 15 | field6 = 0 # Y052 Need type annotation for "field6" 16 | field7 = b"" # Y052 Need type annotation for "field7" - | ^^^ PYI052 + | ^^^ 17 | field71 = "foo" # Y052 Need type annotation for "field71" 18 | field72: str = "foo" | -PYI052.pyi:17:11: PYI052 Need type annotation for `field71` +PYI052 Need type annotation for `field71` + --> PYI052.pyi:17:11 | 15 | field6 = 0 # Y052 Need type annotation for "field6" 16 | field7 = b"" # Y052 Need type annotation for "field7" 17 | field71 = "foo" # Y052 Need type annotation for "field71" - | ^^^^^ PYI052 + | ^^^^^ 18 | field72: str = "foo" 19 | field8 = False # Y052 Need type annotation for "field8" | -PYI052.pyi:19:10: PYI052 Need type annotation for `field8` +PYI052 Need type annotation for `field8` + --> PYI052.pyi:19:10 | 17 | field71 = "foo" # Y052 Need type annotation for "field71" 18 | field72: str = "foo" 19 | field8 = False # Y052 Need type annotation for "field8" - | ^^^^^ PYI052 + | ^^^^^ 20 | field81 = -1 # Y052 Need type annotation for "field81" 21 | field82: float = -98.43 | -PYI052.pyi:20:11: PYI052 Need type annotation for `field81` +PYI052 Need type annotation for `field81` + --> PYI052.pyi:20:11 | 18 | field72: str = "foo" 19 | field8 = False # Y052 Need type annotation for "field8" 20 | field81 = -1 # Y052 Need type annotation for "field81" - | ^^ PYI052 + | ^^ 21 | field82: float = -98.43 22 | field83 = -42j # Y052 Need type annotation for "field83" | -PYI052.pyi:22:11: PYI052 Need type annotation for `field83` +PYI052 Need type annotation for `field83` + --> PYI052.pyi:22:11 | 20 | field81 = -1 # Y052 Need type annotation for "field81" 21 | field82: float = -98.43 22 | field83 = -42j # Y052 Need type annotation for "field83" - | ^^^^ PYI052 + | ^^^^ 23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" 24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" | -PYI052.pyi:23:11: PYI052 Need type annotation for `field84` +PYI052 Need type annotation for `field84` + --> PYI052.pyi:23:11 | 21 | field82: float = -98.43 22 | field83 = -42j # Y052 Need type annotation for "field83" 23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" - | ^^^^^^^ PYI052 + | ^^^^^^^ 24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" 25 | field9 = None # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "field9: TypeAlias = None" | -PYI052.pyi:24:11: PYI052 Need type annotation for `field85` +PYI052 Need type annotation for `field85` + --> PYI052.pyi:24:11 | 22 | field83 = -42j # Y052 Need type annotation for "field83" 23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" 24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" - | ^^^^^^^^ PYI052 + | ^^^^^^^^ 25 | field9 = None # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "field9: TypeAlias = None" 26 | Field95: TypeAlias = None | -PYI052.pyi:33:11: PYI052 Need type annotation for `field19` +PYI052 Need type annotation for `field19` + --> PYI052.pyi:33:11 | 31 | Field100 = TypeVarTuple('Field100') 32 | Field101 = ParamSpec('Field101') 33 | field19 = [1, 2, 3] # Y052 Need type annotation for "field19" - | ^^^^^^^^^ PYI052 + | ^^^^^^^^^ 34 | field191: list[int] = [1, 2, 3] 35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" | -PYI052.pyi:35:11: PYI052 Need type annotation for `field20` +PYI052 Need type annotation for `field20` + --> PYI052.pyi:35:11 | 33 | field19 = [1, 2, 3] # Y052 Need type annotation for "field19" 34 | field191: list[int] = [1, 2, 3] 35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" - | ^^^^^^^^^ PYI052 + | ^^^^^^^^^ 36 | field201: tuple[int, ...] = (1, 2, 3) 37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" | -PYI052.pyi:37:11: PYI052 Need type annotation for `field21` +PYI052 Need type annotation for `field21` + --> PYI052.pyi:37:11 | 35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" 36 | field201: tuple[int, ...] = (1, 2, 3) 37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" - | ^^^^^^^^^ PYI052 + | ^^^^^^^^^ 38 | field211: set[int] = {1, 2, 3} 39 | field212 = {"foo": "bar"} # Y052 Need type annotation for "field212" | -PYI052.pyi:39:12: PYI052 Need type annotation for `field212` +PYI052 Need type annotation for `field212` + --> PYI052.pyi:39:12 | 37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" 38 | field211: set[int] = {1, 2, 3} 39 | field212 = {"foo": "bar"} # Y052 Need type annotation for "field212" - | ^^^^^^^^^^^^^^ PYI052 + | ^^^^^^^^^^^^^^ 40 | field213: dict[str, str] = {"foo": "bar"} 41 | field22: Final = {"foo": 5} | -PYI052.pyi:114:11: PYI052 Need type annotation for `WIZ` +PYI052 Need type annotation for `WIZ` + --> PYI052.pyi:114:11 | 113 | class Bop: 114 | WIZ = 4 - | ^ PYI052 + | ^ | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap index c6cb6da879..0bd6da014d 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI053.pyi:7:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted +PYI053 [*] String and bytes literals longer than 50 characters are not permitted + --> PYI053.pyi:7:14 | 5 | def f1(x: str = "50 character stringggggggggggggggggggggggggggggggg") -> None: ... # OK 6 | def f2( 7 | x: str = "51 character stringgggggggggggggggggggggggggggggggg", # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | ) -> None: ... 9 | def f3( | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 4 4 | @@ -22,16 +23,17 @@ PYI053.pyi:7:14: PYI053 [*] String and bytes literals longer than 50 characters 9 9 | def f3( 10 10 | x: str = "50 character stringgggggggggggggggggggggggggggggg\U0001f600", # OK -PYI053.pyi:13:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted +PYI053 [*] String and bytes literals longer than 50 characters are not permitted + --> PYI053.pyi:13:14 | 11 | ) -> None: ... 12 | def f4( 13 | x: str = "51 character stringggggggggggggggggggggggggggggggg\U0001f600", # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | ) -> None: ... 15 | def f5( | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 10 10 | x: str = "50 character stringgggggggggggggggggggggggggggggg\U0001f600", # OK @@ -43,15 +45,16 @@ PYI053.pyi:13:14: PYI053 [*] String and bytes literals longer than 50 characters 15 15 | def f5( 16 16 | x: bytes = b"50 character byte stringgggggggggggggggggggggggggg", # OK -PYI053.pyi:25:16: PYI053 [*] String and bytes literals longer than 50 characters are not permitted +PYI053 [*] String and bytes literals longer than 50 characters are not permitted + --> PYI053.pyi:25:16 | 23 | ) -> None: ... 24 | def f8( 25 | x: bytes = b"51 character byte stringgggggggggggggggggggggggggg\xff", # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | ) -> None: ... | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 22 22 | x: bytes = b"50 character byte stringggggggggggggggggggggggggg\xff", # OK @@ -63,16 +66,17 @@ PYI053.pyi:25:16: PYI053 [*] String and bytes literals longer than 50 characters 27 27 | 28 28 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK -PYI053.pyi:30:12: PYI053 [*] String and bytes literals longer than 50 characters are not permitted +PYI053 [*] String and bytes literals longer than 50 characters are not permitted + --> PYI053.pyi:30:12 | 28 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK 29 | 30 | bar: str = "51 character stringgggggggggggggggggggggggggggggggg" # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | 32 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 27 27 | @@ -84,16 +88,17 @@ PYI053.pyi:30:12: PYI053 [*] String and bytes literals longer than 50 characters 32 32 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK 33 33 | -PYI053.pyi:34:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted +PYI053 [*] String and bytes literals longer than 50 characters are not permitted + --> PYI053.pyi:34:14 | 32 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK 33 | 34 | qux: bytes = b"51 character byte stringggggggggggggggggggggggggggg\xff" # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | ffoo: str = f"50 character stringggggggggggggggggggggggggggggggg" # OK | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 31 31 | @@ -105,16 +110,17 @@ PYI053.pyi:34:14: PYI053 [*] String and bytes literals longer than 50 characters 36 36 | ffoo: str = f"50 character stringggggggggggggggggggggggggggggggg" # OK 37 37 | -PYI053.pyi:38:13: PYI053 [*] String and bytes literals longer than 50 characters are not permitted +PYI053 [*] String and bytes literals longer than 50 characters are not permitted + --> PYI053.pyi:38:13 | 36 | ffoo: str = f"50 character stringggggggggggggggggggggggggggggggg" # OK 37 | 38 | fbar: str = f"51 character stringgggggggggggggggggggggggggggggggg" # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | 40 | class Demo: | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 35 35 | @@ -126,15 +132,16 @@ PYI053.pyi:38:13: PYI053 [*] String and bytes literals longer than 50 characters 40 40 | class Demo: 41 41 | """Docstrings are excluded from this rule. Some padding.""" # OK -PYI053.pyi:64:5: PYI053 [*] String and bytes literals longer than 50 characters are not permitted +PYI053 [*] String and bytes literals longer than 50 characters are not permitted + --> PYI053.pyi:64:5 | 63 | @not_warnings_dot_deprecated( 64 | "Not warnings.deprecated, so this one *should* lead to PYI053 in a stub!" # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 | ) 66 | def not_a_deprecated_function() -> None: ... | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 61 61 | ) -> Callable[[Callable[[], None]], Callable[[], None]]: ... @@ -146,16 +153,17 @@ PYI053.pyi:64:5: PYI053 [*] String and bytes literals longer than 50 characters 66 66 | def not_a_deprecated_function() -> None: ... 67 67 | -PYI053.pyi:68:13: PYI053 [*] String and bytes literals longer than 50 characters are not permitted +PYI053 [*] String and bytes literals longer than 50 characters are not permitted + --> PYI053.pyi:68:13 | 66 | def not_a_deprecated_function() -> None: ... 67 | 68 | fbaz: str = f"51 character {foo} stringgggggggggggggggggggggggggg" # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 69 | 70 | from typing import TypeAlias, Literal, Annotated | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 65 65 | ) diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap index ec99151e03..2b9d8538c0 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI054.pyi:2:16: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted +PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + --> PYI054.pyi:2:16 | 1 | field01: int = 0xFFFFFFFF 2 | field02: int = 0xFFFFFFFFF # Error: PYI054 - | ^^^^^^^^^^^ PYI054 + | ^^^^^^^^^^^ 3 | field03: int = -0xFFFFFFFF 4 | field04: int = -0xFFFFFFFFF # Error: PYI054 | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 1 1 | field01: int = 0xFFFFFFFF @@ -19,16 +20,17 @@ PYI054.pyi:2:16: PYI054 [*] Numeric literals with a string representation longer 4 4 | field04: int = -0xFFFFFFFFF # Error: PYI054 5 5 | -PYI054.pyi:4:17: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted +PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + --> PYI054.pyi:4:17 | 2 | field02: int = 0xFFFFFFFFF # Error: PYI054 3 | field03: int = -0xFFFFFFFF 4 | field04: int = -0xFFFFFFFFF # Error: PYI054 - | ^^^^^^^^^^^ PYI054 + | ^^^^^^^^^^^ 5 | 6 | field05: int = 1234567890 | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 1 1 | field01: int = 0xFFFFFFFF @@ -40,16 +42,17 @@ PYI054.pyi:4:17: PYI054 [*] Numeric literals with a string representation longer 6 6 | field05: int = 1234567890 7 7 | field06: int = 12_456_890 -PYI054.pyi:8:16: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted +PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + --> PYI054.pyi:8:16 | 6 | field05: int = 1234567890 7 | field06: int = 12_456_890 8 | field07: int = 12345678901 # Error: PYI054 - | ^^^^^^^^^^^ PYI054 + | ^^^^^^^^^^^ 9 | field08: int = -1234567801 10 | field09: int = -234_567_890 # Error: PYI054 | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 5 5 | @@ -61,16 +64,17 @@ PYI054.pyi:8:16: PYI054 [*] Numeric literals with a string representation longer 10 10 | field09: int = -234_567_890 # Error: PYI054 11 11 | -PYI054.pyi:10:17: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted +PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + --> PYI054.pyi:10:17 | 8 | field07: int = 12345678901 # Error: PYI054 9 | field08: int = -1234567801 10 | field09: int = -234_567_890 # Error: PYI054 - | ^^^^^^^^^^^ PYI054 + | ^^^^^^^^^^^ 11 | 12 | field10: float = 123.456789 | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 7 7 | field06: int = 12_456_890 @@ -82,15 +86,16 @@ PYI054.pyi:10:17: PYI054 [*] Numeric literals with a string representation longe 12 12 | field10: float = 123.456789 13 13 | field11: float = 123.4567890 # Error: PYI054 -PYI054.pyi:13:18: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted +PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + --> PYI054.pyi:13:18 | 12 | field10: float = 123.456789 13 | field11: float = 123.4567890 # Error: PYI054 - | ^^^^^^^^^^^ PYI054 + | ^^^^^^^^^^^ 14 | field12: float = -123.456789 15 | field13: float = -123.567_890 # Error: PYI054 | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 10 10 | field09: int = -234_567_890 # Error: PYI054 @@ -102,16 +107,17 @@ PYI054.pyi:13:18: PYI054 [*] Numeric literals with a string representation longe 15 15 | field13: float = -123.567_890 # Error: PYI054 16 16 | -PYI054.pyi:15:19: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted +PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + --> PYI054.pyi:15:19 | 13 | field11: float = 123.4567890 # Error: PYI054 14 | field12: float = -123.456789 15 | field13: float = -123.567_890 # Error: PYI054 - | ^^^^^^^^^^^ PYI054 + | ^^^^^^^^^^^ 16 | 17 | field14: complex = 1e1234567j | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 12 12 | field10: float = 123.456789 @@ -123,15 +129,16 @@ PYI054.pyi:15:19: PYI054 [*] Numeric literals with a string representation longe 17 17 | field14: complex = 1e1234567j 18 18 | field15: complex = 1e12345678j # Error: PYI054 -PYI054.pyi:18:20: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted +PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + --> PYI054.pyi:18:20 | 17 | field14: complex = 1e1234567j 18 | field15: complex = 1e12345678j # Error: PYI054 - | ^^^^^^^^^^^ PYI054 + | ^^^^^^^^^^^ 19 | field16: complex = -1e1234567j 20 | field17: complex = 1e123456789j # Error: PYI054 | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 15 15 | field13: float = -123.567_890 # Error: PYI054 @@ -142,14 +149,15 @@ PYI054.pyi:18:20: PYI054 [*] Numeric literals with a string representation longe 19 19 | field16: complex = -1e1234567j 20 20 | field17: complex = 1e123456789j # Error: PYI054 -PYI054.pyi:20:20: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted +PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + --> PYI054.pyi:20:20 | 18 | field15: complex = 1e12345678j # Error: PYI054 19 | field16: complex = -1e1234567j 20 | field17: complex = 1e123456789j # Error: PYI054 - | ^^^^^^^^^^^^ PYI054 + | ^^^^^^^^^^^^ | - = help: Replace with `...` +help: Replace with `...` ℹ Safe fix 17 17 | field14: complex = 1e1234567j diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap index e9dadd685d..a1ec7eed26 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI055.py:34:8: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty | str]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty | str]`. + --> PYI055.py:34:8 | 32 | def func(): 33 | # PYI055 34 | x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker 36 | z: Union[ # comment | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 31 31 | @@ -22,16 +23,17 @@ PYI055.py:34:8: PYI055 [*] Multiple `type` members in a union. Combine them into 36 36 | z: Union[ # comment 37 37 | type[requests_mock.Mocker], # another comment -PYI055.py:35:8: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. + --> PYI055.py:35:8 | 33 | # PYI055 34 | x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker 35 | y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | z: Union[ # comment 37 | type[requests_mock.Mocker], # another comment | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 32 32 | def func(): @@ -43,7 +45,8 @@ PYI055.py:35:8: PYI055 [*] Multiple `type` members in a union. Combine them into 37 37 | type[requests_mock.Mocker], # another comment 38 38 | type[httpretty], type[str]] = requests_mock.Mocker -PYI055.py:36:8: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. + --> PYI055.py:36:8 | 34 | x: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker 35 | y: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker @@ -51,9 +54,9 @@ PYI055.py:36:8: PYI055 [*] Multiple `type` members in a union. Combine them into | ________^ 37 | | type[requests_mock.Mocker], # another comment 38 | | type[httpretty], type[str]] = requests_mock.Mocker - | |___________________________________^ PYI055 + | |___________________________________^ | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Unsafe fix 33 33 | # PYI055 @@ -67,13 +70,14 @@ PYI055.py:36:8: PYI055 [*] Multiple `type` members in a union. Combine them into 40 38 | 41 39 | def func(): -PYI055.py:45:8: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. + --> PYI055.py:45:8 | 44 | # PYI055 45 | x: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 42 42 | from typing import Union as U @@ -85,16 +89,17 @@ PYI055.py:45:8: PYI055 [*] Multiple `type` members in a union. Combine them into 47 47 | 48 48 | def convert_union(union: UnionType) -> _T | None: -PYI055.py:50:9: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`. + --> PYI055.py:50:9 | 48 | def convert_union(union: UnionType) -> _T | None: 49 | converters: tuple[ 50 | type[_T] | type[Converter[_T]] | Converter[_T] | Callable[[str], _T], ... # PYI055 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 51 | ] = union.__args__ 52 | ... | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 47 47 | @@ -106,16 +111,17 @@ PYI055.py:50:9: PYI055 [*] Multiple `type` members in a union. Combine them into 52 52 | ... 53 53 | -PYI055.py:56:9: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`. + --> PYI055.py:56:9 | 54 | def convert_union(union: UnionType) -> _T | None: 55 | converters: tuple[ 56 | Union[type[_T] | type[Converter[_T]] | Converter[_T] | Callable[[str], _T]], ... # PYI055 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 57 | ] = union.__args__ 58 | ... | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 53 53 | @@ -127,16 +133,17 @@ PYI055.py:56:9: PYI055 [*] Multiple `type` members in a union. Combine them into 58 58 | ... 59 59 | -PYI055.py:62:9: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`. + --> PYI055.py:62:9 | 60 | def convert_union(union: UnionType) -> _T | None: 61 | converters: tuple[ 62 | Union[type[_T] | type[Converter[_T]]] | Converter[_T] | Callable[[str], _T], ... # PYI055 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | ] = union.__args__ 64 | ... | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 59 59 | @@ -148,16 +155,17 @@ PYI055.py:62:9: PYI055 [*] Multiple `type` members in a union. Combine them into 64 64 | ... 65 65 | -PYI055.py:68:9: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[_T | Converter[_T]]`. + --> PYI055.py:68:9 | 66 | def convert_union(union: UnionType) -> _T | None: 67 | converters: tuple[ 68 | Union[type[_T] | type[Converter[_T]] | str] | Converter[_T] | Callable[[str], _T], ... # PYI055 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 69 | ] = union.__args__ 70 | ... | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 65 65 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap index 30515dd229..d921242df6 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI055.pyi:4:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`. + --> PYI055.pyi:4:4 | 2 | from typing import Union 3 | 4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | t: type[int] | type[str] | type[float] 6 | u: builtins.type[int] | type[str] | builtins.type[complex] | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 1 1 | import builtins @@ -22,15 +23,16 @@ PYI055.pyi:4:4: PYI055 [*] Multiple `type` members in a union. Combine them into 6 6 | u: builtins.type[int] | type[str] | builtins.type[complex] 7 7 | v: Union[type[float], type[complex]] -PYI055.pyi:5:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | float]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | float]`. + --> PYI055.pyi:5:4 | 4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex] 5 | t: type[int] | type[str] | type[float] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | u: builtins.type[int] | type[str] | builtins.type[complex] 7 | v: Union[type[float], type[complex]] | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 2 2 | from typing import Union @@ -42,16 +44,17 @@ PYI055.pyi:5:4: PYI055 [*] Multiple `type` members in a union. Combine them into 7 7 | v: Union[type[float], type[complex]] 8 8 | w: Union[type[Union[float, int]], type[complex]] -PYI055.pyi:6:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`. + --> PYI055.pyi:6:4 | 4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex] 5 | t: type[int] | type[str] | type[float] 6 | u: builtins.type[int] | type[str] | builtins.type[complex] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | v: Union[type[float], type[complex]] 8 | w: Union[type[Union[float, int]], type[complex]] | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 3 3 | @@ -63,16 +66,17 @@ PYI055.pyi:6:4: PYI055 [*] Multiple `type` members in a union. Combine them into 8 8 | w: Union[type[Union[float, int]], type[complex]] 9 9 | x: Union[Union[type[Union[float, int]], type[complex]]] -PYI055.pyi:7:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float, complex]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float, complex]]`. + --> PYI055.pyi:7:4 | 5 | t: type[int] | type[str] | type[float] 6 | u: builtins.type[int] | type[str] | builtins.type[complex] 7 | v: Union[type[float], type[complex]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | w: Union[type[Union[float, int]], type[complex]] 9 | x: Union[Union[type[Union[float, int]], type[complex]]] | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 4 4 | s: builtins.type[int] | builtins.type[str] | builtins.type[complex] @@ -84,16 +88,17 @@ PYI055.pyi:7:4: PYI055 [*] Multiple `type` members in a union. Combine them into 9 9 | x: Union[Union[type[Union[float, int]], type[complex]]] 10 10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]] -PYI055.pyi:8:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[Union[float, int], complex]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[Union[float, int], complex]]`. + --> PYI055.pyi:8:4 | 6 | u: builtins.type[int] | type[str] | builtins.type[complex] 7 | v: Union[type[float], type[complex]] 8 | w: Union[type[Union[float, int]], type[complex]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | x: Union[Union[type[Union[float, int]], type[complex]]] 10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]] | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 5 5 | t: type[int] | type[str] | type[float] @@ -105,16 +110,17 @@ PYI055.pyi:8:4: PYI055 [*] Multiple `type` members in a union. Combine them into 10 10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]] 11 11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]] -PYI055.pyi:9:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[Union[float, int], complex]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[Union[float, int], complex]]`. + --> PYI055.pyi:9:4 | 7 | v: Union[type[float], type[complex]] 8 | w: Union[type[Union[float, int]], type[complex]] 9 | x: Union[Union[type[Union[float, int]], type[complex]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]] 11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]] | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 6 6 | u: builtins.type[int] | type[str] | builtins.type[complex] @@ -126,15 +132,16 @@ PYI055.pyi:9:4: PYI055 [*] Multiple `type` members in a union. Combine them into 11 11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]] 12 12 | -PYI055.pyi:10:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[Union[float, int], complex]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[Union[float, int], complex]]`. + --> PYI055.pyi:10:4 | 8 | w: Union[type[Union[float, int]], type[complex]] 9 | x: Union[Union[type[Union[float, int]], type[complex]]] 10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]] | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 7 7 | v: Union[type[float], type[complex]] @@ -146,16 +153,17 @@ PYI055.pyi:10:4: PYI055 [*] Multiple `type` members in a union. Combine them int 12 12 | 13 13 | def func(arg: type[int] | str | type[float]) -> None: ... -PYI055.pyi:11:4: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[complex, Union[float, int]]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[complex, Union[float, int]]]`. + --> PYI055.pyi:11:4 | 9 | x: Union[Union[type[Union[float, int]], type[complex]]] 10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]] 11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | def func(arg: type[int] | str | type[float]) -> None: ... | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 8 8 | w: Union[type[Union[float, int]], type[complex]] @@ -167,16 +175,17 @@ PYI055.pyi:11:4: PYI055 [*] Multiple `type` members in a union. Combine them int 13 13 | def func(arg: type[int] | str | type[float]) -> None: ... 14 14 | -PYI055.pyi:13:15: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | float]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[int | float]`. + --> PYI055.pyi:13:15 | 11 | z: Union[type[complex], Union[Union[type[Union[float, int]]]]] 12 | 13 | def func(arg: type[int] | str | type[float]) -> None: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # OK | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 10 10 | y: Union[Union[Union[type[Union[float, int]], type[complex]]]] @@ -188,15 +197,16 @@ PYI055.pyi:13:15: PYI055 [*] Multiple `type` members in a union. Combine them in 15 15 | # OK 16 16 | x: type[int | str | float] -PYI055.pyi:23:7: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`. + --> PYI055.pyi:23:7 | 22 | # PYI055 23 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | 25 | def func(): | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 20 20 | def func(arg: type[int, float] | str) -> None: ... @@ -208,16 +218,17 @@ PYI055.pyi:23:7: PYI055 [*] Multiple `type` members in a union. Combine them int 25 25 | def func(): 26 26 | # PYI055 -PYI055.pyi:27:11: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty | str]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty | str]`. + --> PYI055.pyi:27:11 | 25 | def func(): 26 | # PYI055 27 | item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker 29 | item3: Union[ # comment | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 24 24 | @@ -229,16 +240,17 @@ PYI055.pyi:27:11: PYI055 [*] Multiple `type` members in a union. Combine them in 29 29 | item3: Union[ # comment 30 30 | type[requests_mock.Mocker], # another comment -PYI055.pyi:28:12: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. + --> PYI055.pyi:28:12 | 26 | # PYI055 27 | item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker 28 | item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | item3: Union[ # comment 30 | type[requests_mock.Mocker], # another comment | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Safe fix 25 25 | def func(): @@ -250,7 +262,8 @@ PYI055.pyi:28:12: PYI055 [*] Multiple `type` members in a union. Combine them in 30 30 | type[requests_mock.Mocker], # another comment 31 31 | type[httpretty], type[str]] = requests_mock.Mocker -PYI055.pyi:29:12: PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. +PYI055 [*] Multiple `type` members in a union. Combine them into one, e.g., `type[Union[requests_mock.Mocker, httpretty, str]]`. + --> PYI055.pyi:29:12 | 27 | item: type[requests_mock.Mocker] | type[httpretty] | type[str] = requests_mock.Mocker 28 | item2: Union[type[requests_mock.Mocker], type[httpretty], type[str]] = requests_mock.Mocker @@ -258,9 +271,9 @@ PYI055.pyi:29:12: PYI055 [*] Multiple `type` members in a union. Combine them in | ____________^ 30 | | type[requests_mock.Mocker], # another comment 31 | | type[httpretty], type[str]] = requests_mock.Mocker - | |___________________________________^ PYI055 + | |___________________________________^ | - = help: Combine multiple `type` members +help: Combine multiple `type` members ℹ Unsafe fix 26 26 | # PYI055 diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap index c8d9583e3d..48ec988e6c 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI056.py:4:1: PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) +PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) + --> PYI056.py:4:1 | 3 | # Errors 4 | __all__.append("D") - | ^^^^^^^^^^^^^^ PYI056 + | ^^^^^^^^^^^^^^ 5 | __all__.extend(["E", "Foo"]) 6 | __all__.remove("A") | -PYI056.py:5:1: PYI056 Calling `.extend()` on `__all__` may not be supported by all type checkers (use `+=` instead) +PYI056 Calling `.extend()` on `__all__` may not be supported by all type checkers (use `+=` instead) + --> PYI056.py:5:1 | 3 | # Errors 4 | __all__.append("D") 5 | __all__.extend(["E", "Foo"]) - | ^^^^^^^^^^^^^^ PYI056 + | ^^^^^^^^^^^^^^ 6 | __all__.remove("A") | -PYI056.py:6:1: PYI056 Calling `.remove()` on `__all__` may not be supported by all type checkers (use `+=` instead) +PYI056 Calling `.remove()` on `__all__` may not be supported by all type checkers (use `+=` instead) + --> PYI056.py:6:1 | 4 | __all__.append("D") 5 | __all__.extend(["E", "Foo"]) 6 | __all__.remove("A") - | ^^^^^^^^^^^^^^ PYI056 + | ^^^^^^^^^^^^^^ 7 | 8 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap index 7e7f78519e..38365f2c89 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI056.pyi:4:1: PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) +PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) + --> PYI056.pyi:4:1 | 3 | # Errors 4 | __all__.append("D") - | ^^^^^^^^^^^^^^ PYI056 + | ^^^^^^^^^^^^^^ 5 | __all__.extend(["E", "Foo"]) 6 | __all__.remove("A") | -PYI056.pyi:5:1: PYI056 Calling `.extend()` on `__all__` may not be supported by all type checkers (use `+=` instead) +PYI056 Calling `.extend()` on `__all__` may not be supported by all type checkers (use `+=` instead) + --> PYI056.pyi:5:1 | 3 | # Errors 4 | __all__.append("D") 5 | __all__.extend(["E", "Foo"]) - | ^^^^^^^^^^^^^^ PYI056 + | ^^^^^^^^^^^^^^ 6 | __all__.remove("A") | -PYI056.pyi:6:1: PYI056 Calling `.remove()` on `__all__` may not be supported by all type checkers (use `+=` instead) +PYI056 Calling `.remove()` on `__all__` may not be supported by all type checkers (use `+=` instead) + --> PYI056.pyi:6:1 | 4 | __all__.append("D") 5 | __all__.extend(["E", "Foo"]) 6 | __all__.remove("A") - | ^^^^^^^^^^^^^^ PYI056 + | ^^^^^^^^^^^^^^ 7 | 8 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.py.snap index efdd939335..c2c336298a 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.py.snap @@ -1,39 +1,43 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI057.py:4:20: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated +PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated + --> PYI057.py:4:20 | 2 | import collections.abc 3 | import foo 4 | from typing import ByteString - | ^^^^^^^^^^ PYI057 + | ^^^^^^^^^^ 5 | from collections.abc import ByteString 6 | from foo import ByteString | -PYI057.py:5:29: PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated +PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated + --> PYI057.py:5:29 | 3 | import foo 4 | from typing import ByteString 5 | from collections.abc import ByteString - | ^^^^^^^^^^ PYI057 + | ^^^^^^^^^^ 6 | from foo import ByteString | -PYI057.py:8:4: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated +PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated + --> PYI057.py:8:4 | 6 | from foo import ByteString 7 | 8 | a: typing.ByteString - | ^^^^^^^^^^^^^^^^^ PYI057 + | ^^^^^^^^^^^^^^^^^ 9 | b: collections.abc.ByteString 10 | c: foo.ByteString | -PYI057.py:9:4: PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated +PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated + --> PYI057.py:9:4 | 8 | a: typing.ByteString 9 | b: collections.abc.ByteString - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI057 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | c: foo.ByteString | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.pyi.snap index f1c72b4ba9..e5cfc7e5f9 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI057_PYI057.pyi.snap @@ -1,39 +1,43 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI057.pyi:4:20: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated +PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated + --> PYI057.pyi:4:20 | 2 | import collections.abc 3 | import foo 4 | from typing import ByteString - | ^^^^^^^^^^ PYI057 + | ^^^^^^^^^^ 5 | from collections.abc import ByteString 6 | from foo import ByteString | -PYI057.pyi:5:29: PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated +PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated + --> PYI057.pyi:5:29 | 3 | import foo 4 | from typing import ByteString 5 | from collections.abc import ByteString - | ^^^^^^^^^^ PYI057 + | ^^^^^^^^^^ 6 | from foo import ByteString | -PYI057.pyi:8:4: PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated +PYI057 Do not use `typing.ByteString`, which has unclear semantics and is deprecated + --> PYI057.pyi:8:4 | 6 | from foo import ByteString 7 | 8 | a: typing.ByteString - | ^^^^^^^^^^^^^^^^^ PYI057 + | ^^^^^^^^^^^^^^^^^ 9 | b: collections.abc.ByteString 10 | c: foo.ByteString | -PYI057.pyi:9:4: PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated +PYI057 Do not use `collections.abc.ByteString`, which has unclear semantics and is deprecated + --> PYI057.pyi:9:4 | 8 | a: typing.ByteString 9 | b: collections.abc.ByteString - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI057 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | c: foo.ByteString | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.py.snap index db2ba3e211..19d08064d6 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI058.py:5:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.py:5:13 | 4 | class IteratorReturningSimpleGenerator1: 5 | def __iter__(self) -> Generator: - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 6 | ... # PYI058 (use `Iterator`) | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 1 |+from collections.abc import Iterator @@ -23,14 +23,15 @@ PYI058.py:5:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter 7 8 | 8 9 | -PYI058.py:13:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.py:13:13 | 12 | class IteratorReturningSimpleGenerator2: 13 | def __iter__(self) -> typing.Generator: - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 14 | ... # PYI058 (use `Iterator`) | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 10 10 | import typing @@ -42,14 +43,15 @@ PYI058.py:13:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite 15 15 | 16 16 | -PYI058.py:21:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.py:21:13 | 20 | class IteratorReturningSimpleGenerator3: 21 | def __iter__(self) -> collections.abc.Generator: - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 22 | ... # PYI058 (use `Iterator`) | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 18 18 | import collections.abc @@ -61,14 +63,15 @@ PYI058.py:21:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite 23 23 | 24 24 | -PYI058.py:30:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.py:30:13 | 29 | class IteratorReturningSimpleGenerator4: 30 | def __iter__(self, /) -> collections.abc.Generator[str, Any, None]: - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 31 | ... # PYI058 (use `Iterator`) | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 27 27 | from typing import Any @@ -80,14 +83,15 @@ PYI058.py:30:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite 32 32 | 33 33 | -PYI058.py:39:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.py:39:13 | 38 | class IteratorReturningSimpleGenerator5: 39 | def __iter__(self, /) -> collections.abc.Generator[str, None, typing.Any]: - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 40 | ... # PYI058 (use `Iterator`) | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 36 36 | import typing @@ -99,14 +103,15 @@ PYI058.py:39:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite 41 41 | 42 42 | -PYI058.py:47:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.py:47:13 | 46 | class IteratorReturningSimpleGenerator6: 47 | def __iter__(self, /) -> Generator[str, None, None]: - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 48 | ... # PYI058 (use `Iterator`) | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 1 |+from collections.abc import Iterator @@ -123,15 +128,16 @@ PYI058.py:47:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite 49 50 | 50 51 | -PYI058.py:55:13: PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods +PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods + --> PYI058.py:55:13 | 54 | class AsyncIteratorReturningSimpleAsyncGenerator1: 55 | def __aiter__( - | ^^^^^^^^^ PYI058 + | ^^^^^^^^^ 56 | self, 57 | ) -> typing_extensions.AsyncGenerator: | - = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` +help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` ℹ Safe fix 54 54 | class AsyncIteratorReturningSimpleAsyncGenerator1: @@ -143,14 +149,15 @@ PYI058.py:55:13: PYI058 [*] Use `AsyncIterator` as the return value for simple ` 59 59 | 60 60 | -PYI058.py:73:13: PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods +PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods + --> PYI058.py:73:13 | 72 | class AsyncIteratorReturningSimpleAsyncGenerator3: 73 | def __aiter__(self, /) -> collections.abc.AsyncGenerator[str, None]: - | ^^^^^^^^^ PYI058 + | ^^^^^^^^^ 74 | ... # PYI058 (Use `AsyncIterator`) | - = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` +help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` ℹ Safe fix 70 70 | import collections.abc diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap index 915b6958e0..bb0d2ac135 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI058_PYI058.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI058.pyi:5:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.pyi:5:13 | 4 | class IteratorReturningSimpleGenerator1: 5 | def __iter__(self) -> Generator: ... # PYI058 (use `Iterator`) - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 6 | 7 | def scope(): | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 1 |+from collections.abc import Iterator @@ -23,15 +24,16 @@ PYI058.pyi:5:13: PYI058 [*] Use `Iterator` as the return value for simple `__ite 7 8 | def scope(): 8 9 | import typing -PYI058.pyi:11:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.pyi:11:13 | 10 | class IteratorReturningSimpleGenerator2: 11 | def __iter__(self) -> typing.Generator: ... # PYI058 (use `Iterator`) - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 12 | 13 | def scope(): | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 8 8 | import typing @@ -43,15 +45,16 @@ PYI058.pyi:11:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 13 13 | def scope(): 14 14 | import collections.abc -PYI058.pyi:17:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.pyi:17:13 | 16 | class IteratorReturningSimpleGenerator3: 17 | def __iter__(self) -> collections.abc.Generator: ... # PYI058 (use `Iterator`) - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 18 | 19 | def scope(): | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 14 14 | import collections.abc @@ -63,15 +66,16 @@ PYI058.pyi:17:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 19 19 | def scope(): 20 20 | import collections.abc -PYI058.pyi:24:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.pyi:24:13 | 23 | class IteratorReturningSimpleGenerator4: 24 | def __iter__(self, /) -> collections.abc.Generator[str, Any, None]: ... # PYI058 (use `Iterator`) - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 25 | 26 | def scope(): | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 21 21 | from typing import Any @@ -83,15 +87,16 @@ PYI058.pyi:24:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 26 26 | def scope(): 27 27 | import collections.abc -PYI058.pyi:31:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.pyi:31:13 | 30 | class IteratorReturningSimpleGenerator5: 31 | def __iter__(self, /) -> collections.abc.Generator[str, None, typing.Any]: ... # PYI058 (use `Iterator`) - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 32 | 33 | def scope(): | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 28 28 | import typing @@ -103,15 +108,16 @@ PYI058.pyi:31:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 33 33 | def scope(): 34 34 | from collections.abc import Generator -PYI058.pyi:37:13: PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods +PYI058 [*] Use `Iterator` as the return value for simple `__iter__` methods + --> PYI058.pyi:37:13 | 36 | class IteratorReturningSimpleGenerator6: 37 | def __iter__(self, /) -> Generator[str, None, None]: ... # PYI058 (use `Iterator`) - | ^^^^^^^^ PYI058 + | ^^^^^^^^ 38 | 39 | def scope(): | - = help: Convert the return annotation of your `__iter__` method to `Iterator` +help: Convert the return annotation of your `__iter__` method to `Iterator` ℹ Safe fix 1 |+from collections.abc import Iterator @@ -128,15 +134,16 @@ PYI058.pyi:37:13: PYI058 [*] Use `Iterator` as the return value for simple `__it 39 40 | def scope(): 40 41 | import typing_extensions -PYI058.pyi:43:13: PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods +PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods + --> PYI058.pyi:43:13 | 42 | class AsyncIteratorReturningSimpleAsyncGenerator1: 43 | def __aiter__(self,) -> typing_extensions.AsyncGenerator: ... # PYI058 (Use `AsyncIterator`) - | ^^^^^^^^^ PYI058 + | ^^^^^^^^^ 44 | 45 | def scope(): | - = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` +help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` ℹ Safe fix 40 40 | import typing_extensions @@ -148,14 +155,15 @@ PYI058.pyi:43:13: PYI058 [*] Use `AsyncIterator` as the return value for simple 45 45 | def scope(): 46 46 | import collections.abc -PYI058.pyi:49:13: PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods +PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods + --> PYI058.pyi:49:13 | 48 | class AsyncIteratorReturningSimpleAsyncGenerator3: 49 | def __aiter__(self, /) -> collections.abc.AsyncGenerator[str, None]: - | ^^^^^^^^^ PYI058 + | ^^^^^^^^^ 50 | ... # PYI058 (Use `AsyncIterator`) | - = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` +help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` ℹ Safe fix 46 46 | import collections.abc @@ -167,15 +175,16 @@ PYI058.pyi:49:13: PYI058 [*] Use `AsyncIterator` as the return value for simple 51 51 | 52 52 | def scope(): -PYI058.pyi:56:13: PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods +PYI058 [*] Use `AsyncIterator` as the return value for simple `__aiter__` methods + --> PYI058.pyi:56:13 | 55 | class AsyncIteratorReturningSimpleAsyncGenerator3: 56 | def __aiter__(self, /) -> collections.abc.AsyncGenerator[str, None]: ... # PYI058 (Use `AsyncIterator`) - | ^^^^^^^^^ PYI058 + | ^^^^^^^^^ 57 | 58 | def scope(): | - = help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` +help: Convert the return annotation of your `__aiter__` method to `AsyncIterator` ℹ Safe fix 53 53 | import collections.abc diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap index d5f7860983..ccf22bb545 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI059.py:8:17: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.py:8:17 | 6 | V = TypeVar('V') 7 | 8 | class LinkedList(Generic[T], Sized): # PYI059 - | ^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^ 9 | def __init__(self) -> None: 10 | self._items: List[T] = [] | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 5 5 | K = TypeVar('K') @@ -22,7 +23,8 @@ PYI059.py:8:17: PYI059 [*] `Generic[]` should always be the last base class 10 10 | self._items: List[T] = [] 11 11 | -PYI059.py:15:16: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.py:15:16 | 13 | self._items.append(item) 14 | @@ -32,10 +34,10 @@ PYI059.py:15:16: PYI059 [*] `Generic[]` should always be the last base class 17 | | Iterable[Tuple[K, V]], 18 | | Container[Tuple[K, V]], 19 | | ): - | |_^ PYI059 + | |_^ 20 | ... | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 13 13 | self._items.append(item) @@ -49,15 +51,16 @@ PYI059.py:15:16: PYI059 [*] `Generic[]` should always be the last base class 20 19 | ... 21 20 | -PYI059.py:26:10: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.py:26:10 | 24 | # to flag this issue in this case as well, since after fixing the error 25 | # the Generic's position issue persists. 26 | class Foo(Generic, LinkedList): # PYI059 - | ^^^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^^^ 27 | pass | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 23 23 | # Inheriting from just `Generic` is a TypeError, but it's probably fine @@ -69,7 +72,8 @@ PYI059.py:26:10: PYI059 [*] `Generic[]` should always be the last base class 28 28 | 29 29 | -PYI059.py:30:10: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.py:30:10 | 30 | class Foo( # comment about the bracket | __________^ @@ -83,10 +87,10 @@ PYI059.py:30:10: PYI059 [*] `Generic[]` should always be the last base class 38 | | int, # comment about int 39 | | # yet another comment? 40 | | ): # and another one for good measure - | |_^ PYI059 + | |_^ 41 | ... | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 30 30 | class Foo( # comment about the bracket @@ -104,23 +108,25 @@ PYI059.py:30:10: PYI059 [*] `Generic[]` should always be the last base class 40 38 | ): # and another one for good measure 41 39 | ... -PYI059.py:45:8: PYI059 `Generic[]` should always be the last base class +PYI059 `Generic[]` should always be the last base class + --> PYI059.py:45:8 | 44 | # in case of multiple Generic[] inheritance, don't fix it. 45 | class C(Generic[T], Generic[K, V]): ... # PYI059 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end -PYI059.py:59:9: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.py:59:9 | 57 | # syntax errors with starred and keyword arguments from 58 | # https://github.com/astral-sh/ruff/issues/18602 59 | class C1(Generic[T], str, **{"metaclass": type}): # PYI059 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | ... | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 56 56 | @@ -132,15 +138,16 @@ PYI059.py:59:9: PYI059 [*] `Generic[]` should always be the last base class 61 61 | 62 62 | class C2(Generic[T], str, metaclass=type): # PYI059 -PYI059.py:62:9: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.py:62:9 | 60 | ... 61 | 62 | class C2(Generic[T], str, metaclass=type): # PYI059 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | ... | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 59 59 | class C1(Generic[T], str, **{"metaclass": type}): # PYI059 @@ -152,12 +159,13 @@ PYI059.py:62:9: PYI059 [*] `Generic[]` should always be the last base class 64 64 | 65 65 | class C3(Generic[T], metaclass=type, *[str]): # PYI059 but no fix -PYI059.py:65:9: PYI059 `Generic[]` should always be the last base class +PYI059 `Generic[]` should always be the last base class + --> PYI059.py:65:9 | 63 | ... 64 | 65 | class C3(Generic[T], metaclass=type, *[str]): # PYI059 but no fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | ... | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap index 16c5c72d08..318b646903 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI059_PYI059.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI059.pyi:8:17: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.pyi:8:17 | 6 | V = TypeVar('V') 7 | 8 | class LinkedList(Generic[T], Sized): # PYI059 - | ^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^ 9 | def __init__(self) -> None: ... 10 | def push(self, item: T) -> None: ... | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 5 5 | K = TypeVar('K') @@ -22,7 +23,8 @@ PYI059.pyi:8:17: PYI059 [*] `Generic[]` should always be the last base class 10 10 | def push(self, item: T) -> None: ... 11 11 | -PYI059.pyi:12:16: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.pyi:12:16 | 10 | def push(self, item: T) -> None: ... 11 | @@ -32,10 +34,10 @@ PYI059.pyi:12:16: PYI059 [*] `Generic[]` should always be the last base class 14 | | Iterable[Tuple[K, V]], 15 | | Container[Tuple[K, V]], 16 | | ): - | |_^ PYI059 + | |_^ 17 | ... | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 10 10 | def push(self, item: T) -> None: ... @@ -49,14 +51,15 @@ PYI059.pyi:12:16: PYI059 [*] `Generic[]` should always be the last base class 17 16 | ... 18 17 | -PYI059.pyi:22:10: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.pyi:22:10 | 20 | # to flag this issue in this case as well, since after fixing the error 21 | # the Generic's position issue persists. 22 | class Foo(Generic, LinkedList): ... # PYI059 - | ^^^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 19 19 | # Inheriting from just `Generic` is a TypeError, but it's probably fine @@ -68,7 +71,8 @@ PYI059.pyi:22:10: PYI059 [*] `Generic[]` should always be the last base class 24 24 | 25 25 | class Foo( # comment about the bracket -PYI059.pyi:25:10: PYI059 [*] `Generic[]` should always be the last base class +PYI059 [*] `Generic[]` should always be the last base class + --> PYI059.pyi:25:10 | 25 | class Foo( # comment about the bracket | __________^ @@ -82,10 +86,10 @@ PYI059.pyi:25:10: PYI059 [*] `Generic[]` should always be the last base class 33 | | int, # comment about int 34 | | # yet another comment? 35 | | ): # and another one for good measure - | |_^ PYI059 + | |_^ 36 | ... | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end ℹ Unsafe fix 25 25 | class Foo( # comment about the bracket @@ -103,10 +107,11 @@ PYI059.pyi:25:10: PYI059 [*] `Generic[]` should always be the last base class 35 33 | ): # and another one for good measure 36 34 | ... -PYI059.pyi:40:8: PYI059 `Generic[]` should always be the last base class +PYI059 `Generic[]` should always be the last base class + --> PYI059.pyi:40:8 | 39 | # in case of multiple Generic[] inheritance, don't fix it. 40 | class C(Generic[T], Generic[K, V]): ... # PYI059 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI059 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Move `Generic[]` to the end +help: Move `Generic[]` to the end diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.py.snap index 32cfb3f84c..524844413e 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI061.py:4:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:4:25 | 4 | def func1(arg1: Literal[None]): - | ^^^^ PYI061 + | ^^^^ 5 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 1 1 | from typing import Literal, Union @@ -19,13 +20,14 @@ PYI061.py:4:25: PYI061 [*] Use `None` rather than `Literal[None]` 6 6 | 7 7 | -PYI061.py:8:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:8:25 | 8 | def func2(arg1: Literal[None] | int): - | ^^^^ PYI061 + | ^^^^ 9 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 5 5 | ... @@ -37,13 +39,14 @@ PYI061.py:8:25: PYI061 [*] Use `None` rather than `Literal[None]` 10 10 | 11 11 | -PYI061.py:12:24: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:12:24 | 12 | def func3() -> Literal[None]: - | ^^^^ PYI061 + | ^^^^ 13 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 9 9 | ... @@ -55,13 +58,14 @@ PYI061.py:12:24: PYI061 [*] Use `None` rather than `Literal[None]` 14 14 | 15 15 | -PYI061.py:16:30: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.py:16:30 | 16 | def func4(arg1: Literal[int, None, float]): - | ^^^^ PYI061 + | ^^^^ 17 | ... | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 13 13 | ... @@ -73,13 +77,14 @@ PYI061.py:16:30: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 18 18 | 19 19 | -PYI061.py:20:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:20:25 | 20 | def func5(arg1: Literal[None, None]): - | ^^^^ PYI061 + | ^^^^ 21 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 17 17 | ... @@ -91,13 +96,14 @@ PYI061.py:20:25: PYI061 [*] Use `None` rather than `Literal[None]` 22 22 | 23 23 | -PYI061.py:20:31: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:20:31 | 20 | def func5(arg1: Literal[None, None]): - | ^^^^ PYI061 + | ^^^^ 21 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 17 17 | ... @@ -109,16 +115,17 @@ PYI061.py:20:31: PYI061 [*] Use `None` rather than `Literal[None]` 22 22 | 23 23 | -PYI061.py:26:5: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.py:26:5 | 24 | def func6(arg1: Literal[ 25 | "hello", 26 | None # Comment 1 - | ^^^^ PYI061 + | ^^^^ 27 | , "world" 28 | ]): | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Unsafe fix 21 21 | ... @@ -134,15 +141,16 @@ PYI061.py:26:5: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 30 26 | 31 27 | -PYI061.py:33:5: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:33:5 | 32 | def func7(arg1: Literal[ 33 | None # Comment 1 - | ^^^^ PYI061 + | ^^^^ 34 | ]): 35 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Unsafe fix 29 29 | ... @@ -156,21 +164,23 @@ PYI061.py:33:5: PYI061 [*] Use `None` rather than `Literal[None]` 36 34 | 37 35 | -PYI061.py:38:25: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:38:25 | 38 | def func8(arg1: Literal[None] | None): - | ^^^^ PYI061 + | ^^^^ 39 | ... | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:42:31: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:42:31 | 42 | def func9(arg1: Union[Literal[None], None]): - | ^^^^ PYI061 + | ^^^^ 43 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 39 39 | ... @@ -182,14 +192,15 @@ PYI061.py:42:31: PYI061 [*] Use `None` rather than `Literal[None]` 44 44 | 45 45 | -PYI061.py:52:9: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:52:9 | 51 | # From flake8-pyi 52 | Literal[None] # Y061 None inside "Literal[]" expression. Replace with "None" - | ^^^^ PYI061 + | ^^^^ 53 | Literal[True, None] # Y061 None inside "Literal[]" expression. Replace with "Literal[True] | None" | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 49 49 | @@ -201,16 +212,17 @@ PYI061.py:52:9: PYI061 [*] Use `None` rather than `Literal[None]` 54 54 | 55 55 | ### -PYI061.py:53:15: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.py:53:15 | 51 | # From flake8-pyi 52 | Literal[None] # Y061 None inside "Literal[]" expression. Replace with "None" 53 | Literal[True, None] # Y061 None inside "Literal[]" expression. Replace with "Literal[True] | None" - | ^^^^ PYI061 + | ^^^^ 54 | 55 | ### | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 50 50 | @@ -222,15 +234,16 @@ PYI061.py:53:15: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 55 55 | ### 56 56 | # The following rules here are slightly subtle, -PYI061.py:62:9: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:62:9 | 60 | # If Y061 and Y062 both apply, but all the duplicate members are None, 61 | # only emit Y061... 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" - | ^^^^ PYI061 + | ^^^^ 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 59 59 | @@ -242,15 +255,16 @@ PYI061.py:62:9: PYI061 [*] Use `None` rather than `Literal[None]` 64 64 | 65 65 | # ... but if Y061 and Y062 both apply -PYI061.py:62:15: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:62:15 | 60 | # If Y061 and Y062 both apply, but all the duplicate members are None, 61 | # only emit Y061... 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" - | ^^^^ PYI061 + | ^^^^ 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 59 59 | @@ -262,16 +276,17 @@ PYI061.py:62:15: PYI061 [*] Use `None` rather than `Literal[None]` 64 64 | 65 65 | # ... but if Y061 and Y062 both apply -PYI061.py:63:12: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.py:63:12 | 61 | # only emit Y061... 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" - | ^^^^ PYI061 + | ^^^^ 64 | 65 | # ... but if Y061 and Y062 both apply | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 60 60 | # If Y061 and Y062 both apply, but all the duplicate members are None, @@ -283,16 +298,17 @@ PYI061.py:63:12: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 65 65 | # ... but if Y061 and Y062 both apply 66 66 | # and there are no None members in the Literal[] slice, -PYI061.py:63:25: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.py:63:25 | 61 | # only emit Y061... 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" - | ^^^^ PYI061 + | ^^^^ 64 | 65 | # ... but if Y061 and Y062 both apply | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 60 60 | # If Y061 and Y062 both apply, but all the duplicate members are None, @@ -304,14 +320,15 @@ PYI061.py:63:25: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 65 65 | # ... but if Y061 and Y062 both apply 66 66 | # and there are no None members in the Literal[] slice, -PYI061.py:68:9: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.py:68:9 | 66 | # and there are no None members in the Literal[] slice, 67 | # only emit Y062: 68 | Literal[None, True, None, True] # Y062 Duplicate "Literal[]" member "True" - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 65 65 | # ... but if Y061 and Y062 both apply @@ -323,14 +340,15 @@ PYI061.py:68:9: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 70 70 | 71 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 -PYI061.py:68:21: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.py:68:21 | 66 | # and there are no None members in the Literal[] slice, 67 | # only emit Y062: 68 | Literal[None, True, None, True] # Y062 Duplicate "Literal[]" member "True" - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 65 65 | # ... but if Y061 and Y062 both apply @@ -342,36 +360,39 @@ PYI061.py:68:21: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 70 70 | 71 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 -PYI061.py:72:12: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:72:12 | 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 72 | x: Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 73 | y: None | Literal[None] 74 | z: Union[Literal[None], None] | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:73:19: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:73:19 | 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 72 | x: Literal[None] | None 73 | y: None | Literal[None] - | ^^^^ PYI061 + | ^^^^ 74 | z: Union[Literal[None], None] | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:74:18: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:74:18 | 72 | x: Literal[None] | None 73 | y: None | Literal[None] 74 | z: Union[Literal[None], None] - | ^^^^ PYI061 + | ^^^^ 75 | 76 | a: int | Literal[None] | None | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 71 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 @@ -383,53 +404,58 @@ PYI061.py:74:18: PYI061 [*] Use `None` rather than `Literal[None]` 76 76 | a: int | Literal[None] | None 77 77 | b: None | Literal[None] | None -PYI061.py:76:18: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:76:18 | 74 | z: Union[Literal[None], None] 75 | 76 | a: int | Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 77 | b: None | Literal[None] | None 78 | c: (None | Literal[None]) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:77:19: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:77:19 | 76 | a: int | Literal[None] | None 77 | b: None | Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 78 | c: (None | Literal[None]) | None 79 | d: None | (Literal[None] | None) | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:78:20: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:78:20 | 76 | a: int | Literal[None] | None 77 | b: None | Literal[None] | None 78 | c: (None | Literal[None]) | None - | ^^^^ PYI061 + | ^^^^ 79 | d: None | (Literal[None] | None) 80 | e: None | ((None | Literal[None]) | None) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:79:20: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:79:20 | 77 | b: None | Literal[None] | None 78 | c: (None | Literal[None]) | None 79 | d: None | (Literal[None] | None) - | ^^^^ PYI061 + | ^^^^ 80 | e: None | ((None | Literal[None]) | None) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:80:28: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:80:28 | 78 | c: (None | Literal[None]) | None 79 | d: None | (Literal[None] | None) 80 | e: None | ((None | Literal[None]) | None) | None - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.pyi.snap index 6a48501c8d..181432a325 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI061_PYI061.pyi.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI061.pyi:4:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:4:25 | 4 | def func1(arg1: Literal[None]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 1 1 | from typing import Literal, Union @@ -18,12 +19,13 @@ PYI061.pyi:4:25: PYI061 [*] Use `None` rather than `Literal[None]` 6 6 | 7 7 | def func2(arg1: Literal[None] | int): ... -PYI061.pyi:7:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:7:25 | 7 | def func2(arg1: Literal[None] | int): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 4 4 | def func1(arg1: Literal[None]): ... @@ -35,12 +37,13 @@ PYI061.pyi:7:25: PYI061 [*] Use `None` rather than `Literal[None]` 9 9 | 10 10 | def func3() -> Literal[None]: ... -PYI061.pyi:10:24: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:10:24 | 10 | def func3() -> Literal[None]: ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 7 7 | def func2(arg1: Literal[None] | int): ... @@ -52,12 +55,13 @@ PYI061.pyi:10:24: PYI061 [*] Use `None` rather than `Literal[None]` 12 12 | 13 13 | def func4(arg1: Literal[int, None, float]): ... -PYI061.pyi:13:30: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.pyi:13:30 | 13 | def func4(arg1: Literal[int, None, float]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 10 10 | def func3() -> Literal[None]: ... @@ -69,12 +73,13 @@ PYI061.pyi:13:30: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None 15 15 | 16 16 | def func5(arg1: Literal[None, None]): ... -PYI061.pyi:16:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:16:25 | 16 | def func5(arg1: Literal[None, None]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 13 13 | def func4(arg1: Literal[int, None, float]): ... @@ -86,12 +91,13 @@ PYI061.pyi:16:25: PYI061 [*] Use `None` rather than `Literal[None]` 18 18 | 19 19 | def func6(arg1: Literal[ -PYI061.pyi:16:31: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:16:31 | 16 | def func5(arg1: Literal[None, None]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 13 13 | def func4(arg1: Literal[int, None, float]): ... @@ -103,16 +109,17 @@ PYI061.pyi:16:31: PYI061 [*] Use `None` rather than `Literal[None]` 18 18 | 19 19 | def func6(arg1: Literal[ -PYI061.pyi:21:5: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.pyi:21:5 | 19 | def func6(arg1: Literal[ 20 | "hello", 21 | None # Comment 1 - | ^^^^ PYI061 + | ^^^^ 22 | , "world" 23 | ]): ... | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Unsafe fix 16 16 | def func5(arg1: Literal[None, None]): ... @@ -128,14 +135,15 @@ PYI061.pyi:21:5: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 25 21 | 26 22 | def func7(arg1: Literal[ -PYI061.pyi:27:5: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:27:5 | 26 | def func7(arg1: Literal[ 27 | None # Comment 1 - | ^^^^ PYI061 + | ^^^^ 28 | ]): ... | - = help: Replace with `None` +help: Replace with `None` ℹ Unsafe fix 23 23 | ]): ... @@ -149,19 +157,21 @@ PYI061.pyi:27:5: PYI061 [*] Use `None` rather than `Literal[None]` 30 28 | 31 29 | def func8(arg1: Literal[None] | None):... -PYI061.pyi:31:25: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:31:25 | 31 | def func8(arg1: Literal[None] | None):... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:34:31: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:34:31 | 34 | def func9(arg1: Union[Literal[None], None]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 31 31 | def func8(arg1: Literal[None] | None):... @@ -173,14 +183,15 @@ PYI061.pyi:34:31: PYI061 [*] Use `None` rather than `Literal[None]` 36 36 | 37 37 | # OK -PYI061.pyi:42:9: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:42:9 | 41 | # From flake8-pyi 42 | Literal[None] # PYI061 None inside "Literal[]" expression. Replace with "None" - | ^^^^ PYI061 + | ^^^^ 43 | Literal[True, None] # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None" | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 39 39 | @@ -192,14 +203,15 @@ PYI061.pyi:42:9: PYI061 [*] Use `None` rather than `Literal[None]` 44 44 | 45 45 | -PYI061.pyi:43:15: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.pyi:43:15 | 41 | # From flake8-pyi 42 | Literal[None] # PYI061 None inside "Literal[]" expression. Replace with "None" 43 | Literal[True, None] # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None" - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 40 40 | @@ -211,36 +223,39 @@ PYI061.pyi:43:15: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None 45 45 | 46 46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 -PYI061.pyi:47:12: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:47:12 | 46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 47 | x: Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 48 | y: None | Literal[None] 49 | z: Union[Literal[None], None] | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:48:19: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:48:19 | 46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 47 | x: Literal[None] | None 48 | y: None | Literal[None] - | ^^^^ PYI061 + | ^^^^ 49 | z: Union[Literal[None], None] | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:49:18: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:49:18 | 47 | x: Literal[None] | None 48 | y: None | Literal[None] 49 | z: Union[Literal[None], None] - | ^^^^ PYI061 + | ^^^^ 50 | 51 | a: int | Literal[None] | None | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 46 46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 @@ -252,53 +267,58 @@ PYI061.pyi:49:18: PYI061 [*] Use `None` rather than `Literal[None]` 51 51 | a: int | Literal[None] | None 52 52 | b: None | Literal[None] | None -PYI061.pyi:51:18: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:51:18 | 49 | z: Union[Literal[None], None] 50 | 51 | a: int | Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 52 | b: None | Literal[None] | None 53 | c: (None | Literal[None]) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:52:19: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:52:19 | 51 | a: int | Literal[None] | None 52 | b: None | Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 53 | c: (None | Literal[None]) | None 54 | d: None | (Literal[None] | None) | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:53:20: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:53:20 | 51 | a: int | Literal[None] | None 52 | b: None | Literal[None] | None 53 | c: (None | Literal[None]) | None - | ^^^^ PYI061 + | ^^^^ 54 | d: None | (Literal[None] | None) 55 | e: None | ((None | Literal[None]) | None) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:54:20: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:54:20 | 52 | b: None | Literal[None] | None 53 | c: (None | Literal[None]) | None 54 | d: None | (Literal[None] | None) - | ^^^^ PYI061 + | ^^^^ 55 | e: None | ((None | Literal[None]) | None) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:55:28: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:55:28 | 53 | c: (None | Literal[None]) | None 54 | d: None | (Literal[None] | None) 55 | e: None | ((None | Literal[None]) | None) | None - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.py.snap index 6af025078b..879572b57b 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI062.py:5:25: PYI062 [*] Duplicate literal member `True` +PYI062 [*] Duplicate literal member `True` + --> PYI062.py:5:25 | 3 | import typing_extensions 4 | 5 | x: Literal[True, False, True, False] # PYI062 twice here - | ^^^^ PYI062 + | ^^^^ 6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 2 2 | import typing as t @@ -22,16 +23,17 @@ PYI062.py:5:25: PYI062 [*] Duplicate literal member `True` 7 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 8 8 | -PYI062.py:5:31: PYI062 [*] Duplicate literal member `False` +PYI062 [*] Duplicate literal member `False` + --> PYI062.py:5:31 | 3 | import typing_extensions 4 | 5 | x: Literal[True, False, True, False] # PYI062 twice here - | ^^^^^ PYI062 + | ^^^^^ 6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 2 2 | import typing as t @@ -43,16 +45,17 @@ PYI062.py:5:31: PYI062 [*] Duplicate literal member `False` 7 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 8 8 | -PYI062.py:7:45: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:7:45 | 5 | x: Literal[True, False, True, False] # PYI062 twice here 6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 - | ^ PYI062 + | ^ 8 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 4 4 | @@ -64,16 +67,17 @@ PYI062.py:7:45: PYI062 [*] Duplicate literal member `1` 9 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal 10 10 | -PYI062.py:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}` +PYI062 [*] Duplicate literal member `{1, 3, 5}` + --> PYI062.py:9:33 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 8 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal - | ^^^^^^^ PYI062 + | ^^^^^^^ 10 | 11 | Literal[1, Literal[1]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 6 6 | @@ -85,16 +89,17 @@ PYI062.py:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}` 11 11 | Literal[1, Literal[1]] # once 12 12 | Literal[1, 2, Literal[1, 2]] # twice -PYI062.py:11:20: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:11:20 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal 10 | 11 | Literal[1, Literal[1]] # once - | ^ PYI062 + | ^ 12 | Literal[1, 2, Literal[1, 2]] # twice 13 | Literal[1, Literal[1], Literal[1]] # twice | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 8 8 | @@ -106,15 +111,16 @@ PYI062.py:11:20: PYI062 [*] Duplicate literal member `1` 13 13 | Literal[1, Literal[1], Literal[1]] # twice 14 14 | Literal[1, Literal[2], Literal[2]] # once -PYI062.py:12:23: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:12:23 | 11 | Literal[1, Literal[1]] # once 12 | Literal[1, 2, Literal[1, 2]] # twice - | ^ PYI062 + | ^ 13 | Literal[1, Literal[1], Literal[1]] # twice 14 | Literal[1, Literal[2], Literal[2]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 9 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal @@ -126,15 +132,16 @@ PYI062.py:12:23: PYI062 [*] Duplicate literal member `1` 14 14 | Literal[1, Literal[2], Literal[2]] # once 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once -PYI062.py:12:26: PYI062 [*] Duplicate literal member `2` +PYI062 [*] Duplicate literal member `2` + --> PYI062.py:12:26 | 11 | Literal[1, Literal[1]] # once 12 | Literal[1, 2, Literal[1, 2]] # twice - | ^ PYI062 + | ^ 13 | Literal[1, Literal[1], Literal[1]] # twice 14 | Literal[1, Literal[2], Literal[2]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 9 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal @@ -146,16 +153,17 @@ PYI062.py:12:26: PYI062 [*] Duplicate literal member `2` 14 14 | Literal[1, Literal[2], Literal[2]] # once 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once -PYI062.py:13:20: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:13:20 | 11 | Literal[1, Literal[1]] # once 12 | Literal[1, 2, Literal[1, 2]] # twice 13 | Literal[1, Literal[1], Literal[1]] # twice - | ^ PYI062 + | ^ 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 10 10 | @@ -167,16 +175,17 @@ PYI062.py:13:20: PYI062 [*] Duplicate literal member `1` 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 16 | typing_extensions.Literal[1, 1, 1] # twice -PYI062.py:13:32: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:13:32 | 11 | Literal[1, Literal[1]] # once 12 | Literal[1, 2, Literal[1, 2]] # twice 13 | Literal[1, Literal[1], Literal[1]] # twice - | ^ PYI062 + | ^ 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 10 10 | @@ -188,16 +197,17 @@ PYI062.py:13:32: PYI062 [*] Duplicate literal member `1` 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 16 | typing_extensions.Literal[1, 1, 1] # twice -PYI062.py:14:32: PYI062 [*] Duplicate literal member `2` +PYI062 [*] Duplicate literal member `2` + --> PYI062.py:14:32 | 12 | Literal[1, 2, Literal[1, 2]] # twice 13 | Literal[1, Literal[1], Literal[1]] # twice 14 | Literal[1, Literal[2], Literal[2]] # once - | ^ PYI062 + | ^ 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 | typing_extensions.Literal[1, 1, 1] # twice | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 11 11 | Literal[1, Literal[1]] # once @@ -209,16 +219,17 @@ PYI062.py:14:32: PYI062 [*] Duplicate literal member `2` 16 16 | typing_extensions.Literal[1, 1, 1] # twice 17 17 | Literal[ -PYI062.py:15:37: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:15:37 | 13 | Literal[1, Literal[1], Literal[1]] # twice 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once - | ^ PYI062 + | ^ 16 | typing_extensions.Literal[1, 1, 1] # twice 17 | Literal[ | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 12 12 | Literal[1, 2, Literal[1, 2]] # twice @@ -230,16 +241,17 @@ PYI062.py:15:37: PYI062 [*] Duplicate literal member `1` 17 17 | Literal[ 18 18 | 1, # comment -PYI062.py:16:30: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:16:30 | 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 | typing_extensions.Literal[1, 1, 1] # twice - | ^ PYI062 + | ^ 17 | Literal[ 18 | 1, # comment | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 13 13 | Literal[1, Literal[1], Literal[1]] # twice @@ -251,16 +263,17 @@ PYI062.py:16:30: PYI062 [*] Duplicate literal member `1` 18 18 | 1, # comment 19 19 | Literal[ # another comment -PYI062.py:16:33: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:16:33 | 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 | typing_extensions.Literal[1, 1, 1] # twice - | ^ PYI062 + | ^ 17 | Literal[ 18 | 1, # comment | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 13 13 | Literal[1, Literal[1], Literal[1]] # twice @@ -272,16 +285,17 @@ PYI062.py:16:33: PYI062 [*] Duplicate literal member `1` 18 18 | 1, # comment 19 19 | Literal[ # another comment -PYI062.py:20:9: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:20:9 | 18 | 1, # comment 19 | Literal[ # another comment 20 | 1 - | ^ PYI062 + | ^ 21 | ] 22 | ] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Unsafe fix 14 14 | Literal[1, Literal[2], Literal[2]] # once @@ -298,15 +312,16 @@ PYI062.py:20:9: PYI062 [*] Duplicate literal member `1` 24 19 | # Ensure issue is only raised once, even on nested literals 25 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 -PYI062.py:25:46: PYI062 [*] Duplicate literal member `True` +PYI062 [*] Duplicate literal member `True` + --> PYI062.py:25:46 | 24 | # Ensure issue is only raised once, even on nested literals 25 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 - | ^^^^ PYI062 + | ^^^^ 26 | 27 | n: Literal["No", "duplicates", "here", 1, "1"] | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 22 22 | ] # once @@ -318,15 +333,16 @@ PYI062.py:25:46: PYI062 [*] Duplicate literal member `True` 27 27 | n: Literal["No", "duplicates", "here", 1, "1"] 28 28 | -PYI062.py:32:37: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:32:37 | 30 | # nested literals, all equivalent to `Literal[1]` 31 | Literal[Literal[1]] # no duplicate 32 | Literal[Literal[Literal[1], Literal[1]]] # once - | ^ PYI062 + | ^ 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 29 29 | @@ -336,14 +352,15 @@ PYI062.py:32:37: PYI062 [*] Duplicate literal member `1` 32 |+Literal[1] # once 33 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once -PYI062.py:33:45: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.py:33:45 | 31 | Literal[Literal[1]] # no duplicate 32 | Literal[Literal[Literal[1], Literal[1]]] # once 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once - | ^ PYI062 + | ^ | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 30 30 | # nested literals, all equivalent to `Literal[1]` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap index 60d45bc3c7..c94781a8b4 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI062_PYI062.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI062.pyi:5:25: PYI062 [*] Duplicate literal member `True` +PYI062 [*] Duplicate literal member `True` + --> PYI062.pyi:5:25 | 3 | import typing_extensions 4 | 5 | x: Literal[True, False, True, False] # PYI062 twice here - | ^^^^ PYI062 + | ^^^^ 6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 2 2 | import typing as t @@ -22,16 +23,17 @@ PYI062.pyi:5:25: PYI062 [*] Duplicate literal member `True` 7 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 8 8 | -PYI062.pyi:5:31: PYI062 [*] Duplicate literal member `False` +PYI062 [*] Duplicate literal member `False` + --> PYI062.pyi:5:31 | 3 | import typing_extensions 4 | 5 | x: Literal[True, False, True, False] # PYI062 twice here - | ^^^^^ PYI062 + | ^^^^^ 6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 2 2 | import typing as t @@ -43,16 +45,17 @@ PYI062.pyi:5:31: PYI062 [*] Duplicate literal member `False` 7 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 8 8 | -PYI062.pyi:7:45: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:7:45 | 5 | x: Literal[True, False, True, False] # PYI062 twice here 6 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 - | ^ PYI062 + | ^ 8 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 4 4 | @@ -64,16 +67,17 @@ PYI062.pyi:7:45: PYI062 [*] Duplicate literal member `1` 9 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal 10 10 | -PYI062.pyi:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}` +PYI062 [*] Duplicate literal member `{1, 3, 5}` + --> PYI062.pyi:9:33 | 7 | y: Literal[1, print("hello"), 3, Literal[4, 1]] # PYI062 on the last 1 8 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal - | ^^^^^^^ PYI062 + | ^^^^^^^ 10 | 11 | Literal[1, Literal[1]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 6 6 | @@ -85,16 +89,17 @@ PYI062.pyi:9:33: PYI062 [*] Duplicate literal member `{1, 3, 5}` 11 11 | Literal[1, Literal[1]] # once 12 12 | Literal[1, 2, Literal[1, 2]] # twice -PYI062.pyi:11:20: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:11:20 | 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal 10 | 11 | Literal[1, Literal[1]] # once - | ^ PYI062 + | ^ 12 | Literal[1, 2, Literal[1, 2]] # twice 13 | Literal[1, Literal[1], Literal[1]] # twice | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 8 8 | @@ -106,15 +111,16 @@ PYI062.pyi:11:20: PYI062 [*] Duplicate literal member `1` 13 13 | Literal[1, Literal[1], Literal[1]] # twice 14 14 | Literal[1, Literal[2], Literal[2]] # once -PYI062.pyi:12:23: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:12:23 | 11 | Literal[1, Literal[1]] # once 12 | Literal[1, 2, Literal[1, 2]] # twice - | ^ PYI062 + | ^ 13 | Literal[1, Literal[1], Literal[1]] # twice 14 | Literal[1, Literal[2], Literal[2]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 9 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal @@ -126,15 +132,16 @@ PYI062.pyi:12:23: PYI062 [*] Duplicate literal member `1` 14 14 | Literal[1, Literal[2], Literal[2]] # once 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once -PYI062.pyi:12:26: PYI062 [*] Duplicate literal member `2` +PYI062 [*] Duplicate literal member `2` + --> PYI062.pyi:12:26 | 11 | Literal[1, Literal[1]] # once 12 | Literal[1, 2, Literal[1, 2]] # twice - | ^ PYI062 + | ^ 13 | Literal[1, Literal[1], Literal[1]] # twice 14 | Literal[1, Literal[2], Literal[2]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 9 9 | z: Literal[{1, 3, 5}, "foobar", {1,3,5}] # PYI062 on the set literal @@ -146,16 +153,17 @@ PYI062.pyi:12:26: PYI062 [*] Duplicate literal member `2` 14 14 | Literal[1, Literal[2], Literal[2]] # once 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once -PYI062.pyi:13:20: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:13:20 | 11 | Literal[1, Literal[1]] # once 12 | Literal[1, 2, Literal[1, 2]] # twice 13 | Literal[1, Literal[1], Literal[1]] # twice - | ^ PYI062 + | ^ 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 10 10 | @@ -167,16 +175,17 @@ PYI062.pyi:13:20: PYI062 [*] Duplicate literal member `1` 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 16 | typing_extensions.Literal[1, 1, 1] # twice -PYI062.pyi:13:32: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:13:32 | 11 | Literal[1, Literal[1]] # once 12 | Literal[1, 2, Literal[1, 2]] # twice 13 | Literal[1, Literal[1], Literal[1]] # twice - | ^ PYI062 + | ^ 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 10 10 | @@ -188,16 +197,17 @@ PYI062.pyi:13:32: PYI062 [*] Duplicate literal member `1` 15 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 16 | typing_extensions.Literal[1, 1, 1] # twice -PYI062.pyi:14:32: PYI062 [*] Duplicate literal member `2` +PYI062 [*] Duplicate literal member `2` + --> PYI062.pyi:14:32 | 12 | Literal[1, 2, Literal[1, 2]] # twice 13 | Literal[1, Literal[1], Literal[1]] # twice 14 | Literal[1, Literal[2], Literal[2]] # once - | ^ PYI062 + | ^ 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 | typing_extensions.Literal[1, 1, 1] # twice | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 11 11 | Literal[1, Literal[1]] # once @@ -209,16 +219,17 @@ PYI062.pyi:14:32: PYI062 [*] Duplicate literal member `2` 16 16 | typing_extensions.Literal[1, 1, 1] # twice 17 17 | Literal[ -PYI062.pyi:15:37: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:15:37 | 13 | Literal[1, Literal[1], Literal[1]] # twice 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once - | ^ PYI062 + | ^ 16 | typing_extensions.Literal[1, 1, 1] # twice 17 | Literal[ | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 12 12 | Literal[1, 2, Literal[1, 2]] # twice @@ -230,16 +241,17 @@ PYI062.pyi:15:37: PYI062 [*] Duplicate literal member `1` 17 17 | Literal[ 18 18 | 1, # comment -PYI062.pyi:16:30: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:16:30 | 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 | typing_extensions.Literal[1, 1, 1] # twice - | ^ PYI062 + | ^ 17 | Literal[ 18 | 1, # comment | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 13 13 | Literal[1, Literal[1], Literal[1]] # twice @@ -251,16 +263,17 @@ PYI062.pyi:16:30: PYI062 [*] Duplicate literal member `1` 18 18 | 1, # comment 19 19 | Literal[ # another comment -PYI062.pyi:16:33: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:16:33 | 14 | Literal[1, Literal[2], Literal[2]] # once 15 | t.Literal[1, t.Literal[2, t.Literal[1]]] # once 16 | typing_extensions.Literal[1, 1, 1] # twice - | ^ PYI062 + | ^ 17 | Literal[ 18 | 1, # comment | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 13 13 | Literal[1, Literal[1], Literal[1]] # twice @@ -272,16 +285,17 @@ PYI062.pyi:16:33: PYI062 [*] Duplicate literal member `1` 18 18 | 1, # comment 19 19 | Literal[ # another comment -PYI062.pyi:20:9: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:20:9 | 18 | 1, # comment 19 | Literal[ # another comment 20 | 1 - | ^ PYI062 + | ^ 21 | ] 22 | ] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Unsafe fix 14 14 | Literal[1, Literal[2], Literal[2]] # once @@ -298,15 +312,16 @@ PYI062.pyi:20:9: PYI062 [*] Duplicate literal member `1` 24 19 | # Ensure issue is only raised once, even on nested literals 25 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 -PYI062.pyi:25:46: PYI062 [*] Duplicate literal member `True` +PYI062 [*] Duplicate literal member `True` + --> PYI062.pyi:25:46 | 24 | # Ensure issue is only raised once, even on nested literals 25 | MyType = Literal["foo", Literal[True, False, True], "bar"] # PYI062 - | ^^^^ PYI062 + | ^^^^ 26 | 27 | n: Literal["No", "duplicates", "here", 1, "1"] | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 22 22 | ] # once @@ -318,15 +333,16 @@ PYI062.pyi:25:46: PYI062 [*] Duplicate literal member `True` 27 27 | n: Literal["No", "duplicates", "here", 1, "1"] 28 28 | -PYI062.pyi:32:37: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:32:37 | 30 | # nested literals, all equivalent to `Literal[1]` 31 | Literal[Literal[1]] # no duplicate 32 | Literal[Literal[Literal[1], Literal[1]]] # once - | ^ PYI062 + | ^ 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 29 29 | @@ -336,14 +352,15 @@ PYI062.pyi:32:37: PYI062 [*] Duplicate literal member `1` 32 |+Literal[1] # once 33 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once -PYI062.pyi:33:45: PYI062 [*] Duplicate literal member `1` +PYI062 [*] Duplicate literal member `1` + --> PYI062.pyi:33:45 | 31 | Literal[Literal[1]] # no duplicate 32 | Literal[Literal[Literal[1], Literal[1]]] # once 33 | Literal[Literal[1], Literal[Literal[Literal[1]]]] # once - | ^ PYI062 + | ^ | - = help: Remove duplicates +help: Remove duplicates ℹ Safe fix 30 30 | # nested literals, all equivalent to `Literal[1]` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.py.snap index 044005bebb..4eda7eff08 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.py.snap @@ -1,110 +1,120 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI063.py:6:9: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:6:9 | 4 | from typing import Self 5 | 6 | def bad(__x: int) -> None: ... # PYI063 - | ^^^ PYI063 + | ^^^ 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 8 | def still_bad(__x_: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:7:14: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:7:14 | 6 | def bad(__x: int) -> None: ... # PYI063 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 - | ^^^ PYI063 + | ^^^ 8 | def still_bad(__x_: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:8:15: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:8:15 | 6 | def bad(__x: int) -> None: ... # PYI063 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 8 | def still_bad(__x_: int) -> None: ... # PYI063 - | ^^^^ PYI063 + | ^^^^ 9 | 10 | def no_args() -> None: ... | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:24:14: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:24:14 | 22 | def bad(__self) -> None: ... # PYI063 23 | @staticmethod 24 | def bad2(__self) -> None: ... # PYI063 - | ^^^^^^ PYI063 + | ^^^^^^ 25 | def bad3(__self, __x: int) -> None: ... # PYI063 26 | def still_bad(self, __x_: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:25:22: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:25:22 | 23 | @staticmethod 24 | def bad2(__self) -> None: ... # PYI063 25 | def bad3(__self, __x: int) -> None: ... # PYI063 - | ^^^ PYI063 + | ^^^ 26 | def still_bad(self, __x_: int) -> None: ... # PYI063 27 | @staticmethod | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:26:25: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:26:25 | 24 | def bad2(__self) -> None: ... # PYI063 25 | def bad3(__self, __x: int) -> None: ... # PYI063 26 | def still_bad(self, __x_: int) -> None: ... # PYI063 - | ^^^^ PYI063 + | ^^^^ 27 | @staticmethod 28 | def this_is_bad_too(__x: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:28:25: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:28:25 | 26 | def still_bad(self, __x_: int) -> None: ... # PYI063 27 | @staticmethod 28 | def this_is_bad_too(__x: int) -> None: ... # PYI063 - | ^^^ PYI063 + | ^^^ 29 | @classmethod 30 | def not_good(cls, __foo: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:30:23: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:30:23 | 28 | def this_is_bad_too(__x: int) -> None: ... # PYI063 29 | @classmethod 30 | def not_good(cls, __foo: int) -> None: ... # PYI063 - | ^^^^^ PYI063 + | ^^^^^ 31 | 32 | # The first non-self argument isn't positional-only, so logically the second can't be either: | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:52:23: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:52:23 | 50 | class Metaclass(type): 51 | @classmethod 52 | def __new__(mcls, __name: str, __bases: tuple[type, ...], __namespace: dict, **kwds) -> Self: ... # PYI063 - | ^^^^^^ PYI063 + | ^^^^^^ 53 | 54 | class Metaclass2(type): | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.py:56:26: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.py:56:26 | 54 | class Metaclass2(type): 55 | @classmethod 56 | def __new__(metacls, __name: str, __bases: tuple[type, ...], __namespace: dict, **kwds) -> Self: ... # PYI063 - | ^^^^^^ PYI063 + | ^^^^^^ 57 | 58 | class GoodMetaclass(type): | - = help: Add `/` to function signature +help: Add `/` to function signature diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.pyi.snap index 093baf963a..f8b2cb33dc 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI063_PYI063.pyi.snap @@ -1,110 +1,120 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI063.pyi:6:9: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:6:9 | 4 | from typing import Self 5 | 6 | def bad(__x: int) -> None: ... # PYI063 - | ^^^ PYI063 + | ^^^ 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 8 | def still_bad(__x_: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:7:14: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:7:14 | 6 | def bad(__x: int) -> None: ... # PYI063 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 - | ^^^ PYI063 + | ^^^ 8 | def still_bad(__x_: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:8:15: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:8:15 | 6 | def bad(__x: int) -> None: ... # PYI063 7 | def also_bad(__x: int, __y: str) -> None: ... # PYI063 8 | def still_bad(__x_: int) -> None: ... # PYI063 - | ^^^^ PYI063 + | ^^^^ 9 | 10 | def no_args() -> None: ... | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:24:14: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:24:14 | 22 | def bad(__self) -> None: ... # PYI063 23 | @staticmethod 24 | def bad2(__self) -> None: ... # PYI063 - | ^^^^^^ PYI063 + | ^^^^^^ 25 | def bad3(__self, __x: int) -> None: ... # PYI063 26 | def still_bad(self, __x_: int) -> None: ... # PYI063 # TODO: doesn't get raised here | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:25:22: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:25:22 | 23 | @staticmethod 24 | def bad2(__self) -> None: ... # PYI063 25 | def bad3(__self, __x: int) -> None: ... # PYI063 - | ^^^ PYI063 + | ^^^ 26 | def still_bad(self, __x_: int) -> None: ... # PYI063 # TODO: doesn't get raised here 27 | @staticmethod | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:26:25: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:26:25 | 24 | def bad2(__self) -> None: ... # PYI063 25 | def bad3(__self, __x: int) -> None: ... # PYI063 26 | def still_bad(self, __x_: int) -> None: ... # PYI063 # TODO: doesn't get raised here - | ^^^^ PYI063 + | ^^^^ 27 | @staticmethod 28 | def this_is_bad_too(__x: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:28:25: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:28:25 | 26 | def still_bad(self, __x_: int) -> None: ... # PYI063 # TODO: doesn't get raised here 27 | @staticmethod 28 | def this_is_bad_too(__x: int) -> None: ... # PYI063 - | ^^^ PYI063 + | ^^^ 29 | @classmethod 30 | def not_good(cls, __foo: int) -> None: ... # PYI063 | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:30:23: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:30:23 | 28 | def this_is_bad_too(__x: int) -> None: ... # PYI063 29 | @classmethod 30 | def not_good(cls, __foo: int) -> None: ... # PYI063 - | ^^^^^ PYI063 + | ^^^^^ 31 | 32 | # The first non-self argument isn't positional-only, so logically the second can't be either: | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:52:23: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:52:23 | 50 | class Metaclass(type): 51 | @classmethod 52 | def __new__(mcls, __name: str, __bases: tuple[type, ...], __namespace: dict, **kwds) -> Self: ... # PYI063 - | ^^^^^^ PYI063 + | ^^^^^^ 53 | 54 | class Metaclass2(type): | - = help: Add `/` to function signature +help: Add `/` to function signature -PYI063.pyi:56:26: PYI063 Use PEP 570 syntax for positional-only parameters +PYI063 Use PEP 570 syntax for positional-only parameters + --> PYI063.pyi:56:26 | 54 | class Metaclass2(type): 55 | @classmethod 56 | def __new__(metacls, __name: str, __bases: tuple[type, ...], __namespace: dict, **kwds) -> Self: ... # PYI063 - | ^^^^^^ PYI063 + | ^^^^^^ 57 | 58 | class GoodMetaclass(type): | - = help: Add `/` to function signature +help: Add `/` to function signature diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap index f212abc18b..397440ade2 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI064.py:3:1: PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `Final` +PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `Final` + --> PYI064.py:3:1 | 1 | from typing import Final, Literal 2 | 3 | x: Final[Literal[True]] = True # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | y: Final[Literal[None]] = None # PYI064 5 | z: Final[Literal[ # PYI064 | - = help: Replace with `Final` +help: Replace with `Final` ℹ Safe fix 1 1 | from typing import Final, Literal @@ -21,15 +22,16 @@ PYI064.py:3:1: PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `Fi 5 5 | z: Final[Literal[ # PYI064 6 6 | "this is a really long literal, that won't be rendered in the issue text" -PYI064.py:4:1: PYI064 [*] `Final[Literal[None]]` can be replaced with a bare `Final` +PYI064 [*] `Final[Literal[None]]` can be replaced with a bare `Final` + --> PYI064.py:4:1 | 3 | x: Final[Literal[True]] = True # PYI064 4 | y: Final[Literal[None]] = None # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | z: Final[Literal[ # PYI064 6 | "this is a really long literal, that won't be rendered in the issue text" | - = help: Replace with `Final` +help: Replace with `Final` ℹ Safe fix 1 1 | from typing import Final, Literal @@ -41,18 +43,19 @@ PYI064.py:4:1: PYI064 [*] `Final[Literal[None]]` can be replaced with a bare `Fi 6 6 | "this is a really long literal, that won't be rendered in the issue text" 7 7 | ]] = "this is a really long literal, that won't be rendered in the issue text" -PYI064.py:5:1: PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Final` +PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Final` + --> PYI064.py:5:1 | 3 | x: Final[Literal[True]] = True # PYI064 4 | y: Final[Literal[None]] = None # PYI064 5 | / z: Final[Literal[ # PYI064 6 | | "this is a really long literal, that won't be rendered in the issue text" 7 | | ]] = "this is a really long literal, that won't be rendered in the issue text" - | |______________________________________________________________________________^ PYI064 + | |______________________________________________________________________________^ 8 | 9 | # This should be fixable, and marked as safe | - = help: Replace with `Final` +help: Replace with `Final` ℹ Safe fix 2 2 | @@ -66,15 +69,16 @@ PYI064.py:5:1: PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Fin 9 7 | # This should be fixable, and marked as safe 10 8 | w1: Final[Literal[123]] # PYI064 -PYI064.py:10:1: PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Final` +PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Final` + --> PYI064.py:10:1 | 9 | # This should be fixable, and marked as safe 10 | w1: Final[Literal[123]] # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | # This should not be fixable | - = help: Replace with `Final` +help: Replace with `Final` ℹ Safe fix 7 7 | ]] = "this is a really long literal, that won't be rendered in the issue text" @@ -86,12 +90,13 @@ PYI064.py:10:1: PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Fi 12 12 | # This should not be fixable 13 13 | w2: Final[Literal[123]] = "random value" # PYI064 -PYI064.py:13:1: PYI064 `Final[Literal[123]]` can be replaced with a bare `Final` +PYI064 `Final[Literal[123]]` can be replaced with a bare `Final` + --> PYI064.py:13:1 | 12 | # This should not be fixable 13 | w2: Final[Literal[123]] = "random value" # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | n1: Final[Literal[True, False]] = True # No issue here | - = help: Replace with `Final` +help: Replace with `Final` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap index b02cfb5cc8..03f7f83dbd 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI064_PYI064.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI064.pyi:3:1: PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `Final` +PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `Final` + --> PYI064.pyi:3:1 | 1 | from typing import Final, Literal 2 | 3 | x: Final[Literal[True]] # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^ 4 | y: Final[Literal[None]] = None # PYI064 5 | z: Final[Literal["this is a really long literal, that won't be rendered in the issue text"]] # PYI064 | - = help: Replace with `Final` +help: Replace with `Final` ℹ Safe fix 1 1 | from typing import Final, Literal @@ -21,14 +22,15 @@ PYI064.pyi:3:1: PYI064 [*] `Final[Literal[True]]` can be replaced with a bare `F 5 5 | z: Final[Literal["this is a really long literal, that won't be rendered in the issue text"]] # PYI064 6 6 | -PYI064.pyi:4:1: PYI064 [*] `Final[Literal[None]]` can be replaced with a bare `Final` +PYI064 [*] `Final[Literal[None]]` can be replaced with a bare `Final` + --> PYI064.pyi:4:1 | 3 | x: Final[Literal[True]] # PYI064 4 | y: Final[Literal[None]] = None # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | z: Final[Literal["this is a really long literal, that won't be rendered in the issue text"]] # PYI064 | - = help: Replace with `Final` +help: Replace with `Final` ℹ Safe fix 1 1 | from typing import Final, Literal @@ -40,16 +42,17 @@ PYI064.pyi:4:1: PYI064 [*] `Final[Literal[None]]` can be replaced with a bare `F 6 6 | 7 7 | # This should be fixable, and marked as safe -PYI064.pyi:5:1: PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Final` +PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Final` + --> PYI064.pyi:5:1 | 3 | x: Final[Literal[True]] # PYI064 4 | y: Final[Literal[None]] = None # PYI064 5 | z: Final[Literal["this is a really long literal, that won't be rendered in the issue text"]] # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | # This should be fixable, and marked as safe | - = help: Replace with `Final` +help: Replace with `Final` ℹ Safe fix 2 2 | @@ -61,15 +64,16 @@ PYI064.pyi:5:1: PYI064 [*] `Final[Literal[...]]` can be replaced with a bare `Fi 7 7 | # This should be fixable, and marked as safe 8 8 | w1: Final[Literal[123]] # PYI064 -PYI064.pyi:8:1: PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Final` +PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Final` + --> PYI064.pyi:8:1 | 7 | # This should be fixable, and marked as safe 8 | w1: Final[Literal[123]] # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | # This should not be fixable | - = help: Replace with `Final` +help: Replace with `Final` ℹ Safe fix 5 5 | z: Final[Literal["this is a really long literal, that won't be rendered in the issue text"]] # PYI064 @@ -81,12 +85,13 @@ PYI064.pyi:8:1: PYI064 [*] `Final[Literal[123]]` can be replaced with a bare `Fi 10 10 | # This should not be fixable 11 11 | w2: Final[Literal[123]] = "random value" # PYI064 -PYI064.pyi:11:1: PYI064 `Final[Literal[123]]` can be replaced with a bare `Final` +PYI064 `Final[Literal[123]]` can be replaced with a bare `Final` + --> PYI064.pyi:11:1 | 10 | # This should not be fixable 11 | w2: Final[Literal[123]] = "random value" # PYI064 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI064 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | n1: Final[Literal[True, False]] # No issue here | - = help: Replace with `Final` +help: Replace with `Final` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI066_PYI066.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI066_PYI066.pyi.snap index 3d8cec865c..927e2c10ca 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI066_PYI066.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI066_PYI066.pyi.snap @@ -1,53 +1,57 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs -snapshot_kind: text --- -PYI066.pyi:3:4: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons +PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons + --> PYI066.pyi:3:4 | 1 | import sys 2 | 3 | if sys.version_info < (3, 10): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if s… - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | def foo(x): ... 5 | else: | -PYI066.pyi:8:4: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons +PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons + --> PYI066.pyi:8:4 | 6 | def foo(x, *, bar=True): ... 7 | 8 | if sys.version_info < (3, 8): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if s… - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | def bar(x): ... 10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if… | -PYI066.pyi:10:6: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons +PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons + --> PYI066.pyi:10:6 | 8 | if sys.version_info < (3, 8): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if s… 9 | def bar(x): ... 10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if… - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | def bar(x, *, bar=True): ... 12 | elif sys.version_info < (3, 11): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "i… | -PYI066.pyi:12:6: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons +PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons + --> PYI066.pyi:12:6 | 10 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if… 11 | def bar(x, *, bar=True): ... 12 | elif sys.version_info < (3, 11): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "i… - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | def bar(x, *, bar=True, baz=False): ... 14 | else: | -PYI066.pyi:20:6: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons +PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons + --> PYI066.pyi:20:6 | 18 | if sys.version_info >= (3, 5): 19 | ... 20 | elif sys.version_info < (3, 9): # Y066 When using if/else with sys.version_info, put the code for new Python versions first, e.g. "if… - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI066 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | ... 22 | else: | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI016_PYI016.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI016_PYI016.py.snap index a1212a7b5b..15f4e54dd8 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI016_PYI016.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI016_PYI016.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI016.py:7:15: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:7:15 | 6 | # Should emit for duplicate field types. 7 | field2: str | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 8 | 9 | # Should emit for union types in arguments. | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 4 4 | field1: str @@ -21,14 +22,15 @@ PYI016.py:7:15: PYI016 [*] Duplicate union member `str` 9 9 | # Should emit for union types in arguments. 10 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` -PYI016.py:10:23: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:10:23 | 9 | # Should emit for union types in arguments. 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 11 | print(arg1) | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 7 7 | field2: str | str # PYI016: Duplicate union member `str` @@ -40,14 +42,15 @@ PYI016.py:10:23: PYI016 [*] Duplicate union member `int` 12 12 | 13 13 | # Should emit for unions in return types. -PYI016.py:14:22: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:14:22 | 13 | # Should emit for unions in return types. 14 | def func2() -> str | str: # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 15 | return "my string" | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 11 11 | print(arg1) @@ -59,15 +62,16 @@ PYI016.py:14:22: PYI016 [*] Duplicate union member `str` 16 16 | 17 17 | # Should emit in longer unions, even if not directly adjacent. -PYI016.py:18:15: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:18:15 | 17 | # Should emit in longer unions, even if not directly adjacent. 18 | field3: str | str | int # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 15 15 | return "my string" @@ -79,16 +83,17 @@ PYI016.py:18:15: PYI016 [*] Duplicate union member `str` 20 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` -PYI016.py:19:15: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:19:15 | 17 | # Should emit in longer unions, even if not directly adjacent. 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 | field4: int | int | str # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 16 16 | @@ -100,15 +105,16 @@ PYI016.py:19:15: PYI016 [*] Duplicate union member `int` 21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` 22 22 | -PYI016.py:20:21: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:20:21 | 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 17 17 | # Should emit in longer unions, even if not directly adjacent. @@ -120,16 +126,17 @@ PYI016.py:20:21: PYI016 [*] Duplicate union member `str` 22 22 | 23 23 | # Shouldn't emit for non-type unions. -PYI016.py:21:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:21:28 | 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 22 | 23 | # Shouldn't emit for non-type unions. | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` @@ -141,15 +148,16 @@ PYI016.py:21:28: PYI016 [*] Duplicate union member `int` 23 23 | # Shouldn't emit for non-type unions. 24 24 | field7 = str | str -PYI016.py:27:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:27:22 | 26 | # Should emit for strangely-bracketed unions. 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 28 | 29 | # Should handle user brackets when fixing. | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 24 24 | field7 = str | str @@ -161,14 +169,15 @@ PYI016.py:27:22: PYI016 [*] Duplicate union member `int` 29 29 | # Should handle user brackets when fixing. 30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` -PYI016.py:30:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:30:16 | 29 | # Should handle user brackets when fixing. 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` @@ -180,16 +189,17 @@ PYI016.py:30:16: PYI016 [*] Duplicate union member `int` 32 32 | 33 33 | # Should emit for nested unions. -PYI016.py:31:24: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.py:31:24 | 29 | # Should handle user brackets when fixing. 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 32 | 33 | # Should emit for nested unions. | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 28 28 | @@ -201,15 +211,16 @@ PYI016.py:31:24: PYI016 [*] Duplicate union member `str` 33 33 | # Should emit for nested unions. 34 34 | field11: dict[int | int, str] -PYI016.py:34:21: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:34:21 | 33 | # Should emit for nested unions. 34 | field11: dict[int | int, str] - | ^^^ PYI016 + | ^^^ 35 | 36 | # Should emit for unions with more than two cases | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` @@ -221,14 +232,15 @@ PYI016.py:34:21: PYI016 [*] Duplicate union member `int` 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error -PYI016.py:37:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:37:16 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error - | ^^^ PYI016 + | ^^^ 38 | field13: int | int | int | int # Error | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 34 34 | field11: dict[int | int, str] @@ -240,14 +252,15 @@ PYI016.py:37:16: PYI016 [*] Duplicate union member `int` 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI016.py:37:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:37:22 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error - | ^^^ PYI016 + | ^^^ 38 | field13: int | int | int | int # Error | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 34 34 | field11: dict[int | int, str] @@ -259,16 +272,17 @@ PYI016.py:37:22: PYI016 [*] Duplicate union member `int` 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI016.py:38:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:38:16 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -280,16 +294,17 @@ PYI016.py:38:16: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.py:38:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:38:22 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -301,16 +316,17 @@ PYI016.py:38:22: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.py:38:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:38:28 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -322,15 +338,16 @@ PYI016.py:38:28: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.py:41:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:41:16 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error - | ^^^ PYI016 + | ^^^ 42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 38 38 | field13: int | int | int | int # Error @@ -342,15 +359,16 @@ PYI016.py:41:16: PYI016 [*] Duplicate union member `int` 43 43 | # Should emit for duplicate literal types; also covered by PYI030 44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error -PYI016.py:41:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:41:28 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error - | ^^^ PYI016 + | ^^^ 42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 38 38 | field13: int | int | int | int # Error @@ -362,15 +380,16 @@ PYI016.py:41:28: PYI016 [*] Duplicate union member `int` 43 43 | # Should emit for duplicate literal types; also covered by PYI030 44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error -PYI016.py:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` +PYI016 [*] Duplicate union member `typing.Literal[1]` + --> PYI016.py:44:30 | 43 | # Should emit for duplicate literal types; also covered by PYI030 44 | field15: typing.Literal[1] | typing.Literal[1] # Error - | ^^^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^^^ 45 | 46 | # Shouldn't emit if in new parent type | - = help: Remove duplicate union member `typing.Literal[1]` +help: Remove duplicate union member `typing.Literal[1]` ℹ Safe fix 41 41 | field14: int | int | str | int # Error @@ -382,17 +401,18 @@ PYI016.py:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` 46 46 | # Shouldn't emit if in new parent type 47 47 | field16: int | dict[int, str] # OK -PYI016.py:57:5: PYI016 [*] Duplicate union member `set[int]` +PYI016 [*] Duplicate union member `set[int]` + --> PYI016.py:57:5 | 55 | int # foo 56 | ], 57 | / set[ 58 | | int # bar 59 | | ], - | |_____^ PYI016 + | |_____^ 60 | ] # Error, newline and comment will not be emitted in message | - = help: Remove duplicate union member `set[int]` +help: Remove duplicate union member `set[int]` ℹ Unsafe fix 50 50 | field17: dict[int, int] # OK @@ -411,15 +431,16 @@ PYI016.py:57:5: PYI016 [*] Duplicate union member `set[int]` 62 55 | # Should emit in cases with `typing.Union` instead of `|` 63 56 | field19: typing.Union[int, int] # Error -PYI016.py:63:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:63:28 | 62 | # Should emit in cases with `typing.Union` instead of `|` 63 | field19: typing.Union[int, int] # Error - | ^^^ PYI016 + | ^^^ 64 | 65 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 60 60 | ] # Error, newline and comment will not be emitted in message @@ -431,15 +452,16 @@ PYI016.py:63:28: PYI016 [*] Duplicate union member `int` 65 65 | # Should emit in cases with nested `typing.Union` 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error -PYI016.py:66:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:66:41 | 65 | # Should emit in cases with nested `typing.Union` 66 | field20: typing.Union[int, typing.Union[int, str]] # Error - | ^^^ PYI016 + | ^^^ 67 | 68 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 63 63 | field19: typing.Union[int, int] # Error @@ -451,15 +473,16 @@ PYI016.py:66:41: PYI016 [*] Duplicate union member `int` 68 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 69 | field21: typing.Union[int, int | str] # Error -PYI016.py:69:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:69:28 | 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 | field21: typing.Union[int, int | str] # Error - | ^^^ PYI016 + | ^^^ 70 | 71 | # Should emit only once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error @@ -471,15 +494,16 @@ PYI016.py:69:28: PYI016 [*] Duplicate union member `int` 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error -PYI016.py:72:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:72:41 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -491,15 +515,16 @@ PYI016.py:72:41: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.py:72:59: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:72:59 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -511,15 +536,16 @@ PYI016.py:72:59: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.py:72:64: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:72:64 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -531,16 +557,17 @@ PYI016.py:72:64: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]` +PYI016 [*] Duplicate union member `set[int]` + --> PYI016.py:76:12 | 74 | # Should emit in cases with newlines 75 | field23: set[ # foo 76 | int] | set[int] - | ^^^^^^^^ PYI016 + | ^^^^^^^^ 77 | 78 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `set[int]` +help: Remove duplicate union member `set[int]` ℹ Unsafe fix 72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error @@ -553,16 +580,17 @@ PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]` 78 77 | # Should emit twice (once for each `int` in the nested union, both of which are 79 78 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.py:81:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:81:41 | 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 78 78 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -574,16 +602,17 @@ PYI016.py:81:41: PYI016 [*] Duplicate union member `int` 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.py:81:46: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:81:46 | 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 78 78 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -595,16 +624,17 @@ PYI016.py:81:46: PYI016 [*] Duplicate union member `int` 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.py:86:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:86:28 | 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 87 | 88 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -616,16 +646,17 @@ PYI016.py:86:28: PYI016 [*] Duplicate union member `int` 88 88 | # Should emit in cases with nested `typing.Union` 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` -PYI016.py:86:34: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:86:34 | 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 87 | 88 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -637,15 +668,16 @@ PYI016.py:86:34: PYI016 [*] Duplicate union member `int` 88 88 | # Should emit in cases with nested `typing.Union` 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` -PYI016.py:89:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:89:41 | 88 | # Should emit in cases with nested `typing.Union` 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 90 | 91 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 86 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` @@ -657,15 +689,16 @@ PYI016.py:89:41: PYI016 [*] Duplicate union member `int` 91 91 | # Should emit in cases with nested `typing.Union` 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` -PYI016.py:92:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:92:54 | 91 | # Should emit in cases with nested `typing.Union` 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 93 | 94 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` @@ -677,15 +710,16 @@ PYI016.py:92:54: PYI016 [*] Duplicate union member `int` 94 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 95 | field28: typing.Union[int | int] # Error -PYI016.py:95:29: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:95:29 | 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 | field28: typing.Union[int | int] # Error - | ^^^ PYI016 + | ^^^ 96 | 97 | # Should emit twice in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` @@ -697,15 +731,16 @@ PYI016.py:95:29: PYI016 [*] Duplicate union member `int` 97 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error -PYI016.py:98:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:98:54 | 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 95 95 | field28: typing.Union[int | int] # Error @@ -717,15 +752,16 @@ PYI016.py:98:54: PYI016 [*] Duplicate union member `int` 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error -PYI016.py:98:59: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:98:59 | 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 95 95 | field28: typing.Union[int | int] # Error @@ -737,15 +773,16 @@ PYI016.py:98:59: PYI016 [*] Duplicate union member `int` 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error -PYI016.py:101:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:101:54 | 100 | # Should emit once in cases with multiple nested `typing.Union` 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error - | ^^^ PYI016 + | ^^^ 102 | 103 | # Should emit once, and fix to `typing.Union[float, int]` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error @@ -757,15 +794,16 @@ PYI016.py:101:54: PYI016 [*] Duplicate union member `int` 103 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error -PYI016.py:104:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:104:49 | 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 | field31: typing.Union[float, typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 105 | 106 | # Should emit once, and fix to `typing.Union[float, int]` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error @@ -777,15 +815,16 @@ PYI016.py:104:49: PYI016 [*] Duplicate union member `int` 106 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error -PYI016.py:107:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:107:49 | 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error - | ^^^ PYI016 + | ^^^ 108 | 109 | # Test case for mixed union type fix | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error @@ -797,15 +836,16 @@ PYI016.py:107:49: PYI016 [*] Duplicate union member `int` 109 109 | # Test case for mixed union type fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error -PYI016.py:107:55: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:107:55 | 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error - | ^^^ PYI016 + | ^^^ 108 | 109 | # Test case for mixed union type fix | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error @@ -817,15 +857,16 @@ PYI016.py:107:55: PYI016 [*] Duplicate union member `int` 109 109 | # Test case for mixed union type fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error -PYI016.py:110:42: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:110:42 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -837,15 +878,16 @@ PYI016.py:110:42: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.py:110:62: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:110:62 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -857,15 +899,16 @@ PYI016.py:110:62: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.py:110:68: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:110:68 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -877,15 +920,16 @@ PYI016.py:110:68: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.py:113:61: PYI016 [*] Duplicate union member `list[int]` +PYI016 [*] Duplicate union member `list[int]` + --> PYI016.py:113:61 | 112 | # Test case for mixed union type 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error - | ^^^^^^^^^ PYI016 + | ^^^^^^^^^ 114 | 115 | field35: "int | str | int" # Error | - = help: Remove duplicate union member `list[int]` +help: Remove duplicate union member `list[int]` ℹ Safe fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error @@ -897,14 +941,15 @@ PYI016.py:113:61: PYI016 [*] Duplicate union member `list[int]` 115 115 | field35: "int | str | int" # Error 116 116 | -PYI016.py:115:23: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:115:23 | 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error 114 | 115 | field35: "int | str | int" # Error - | ^^^ PYI016 + | ^^^ | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 112 112 | # Test case for mixed union type @@ -916,16 +961,17 @@ PYI016.py:115:23: PYI016 [*] Duplicate union member `int` 117 117 | 118 118 | -PYI016.py:130:26: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:130:26 | 128 | field38: typing.Union[int, None] 129 | # equivalent to None 130 | field39: typing.Optional[None] - | ^^^^ PYI016 + | ^^^^ 131 | # equivalent to int | None 132 | field40: typing.Union[typing.Optional[int], None] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 127 127 | field37: typing.Optional[int] @@ -937,16 +983,17 @@ PYI016.py:130:26: PYI016 [*] Duplicate union member `None` 132 132 | field40: typing.Union[typing.Optional[int], None] 133 133 | field41: typing.Optional[typing.Union[int, None]] -PYI016.py:132:45: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:132:45 | 130 | field39: typing.Optional[None] 131 | # equivalent to int | None 132 | field40: typing.Union[typing.Optional[int], None] - | ^^^^ PYI016 + | ^^^^ 133 | field41: typing.Optional[typing.Union[int, None]] 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 129 129 | # equivalent to None @@ -958,16 +1005,17 @@ PYI016.py:132:45: PYI016 [*] Duplicate union member `None` 134 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] 135 135 | field43: typing.Optional[int] | None -PYI016.py:133:44: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:133:44 | 131 | # equivalent to int | None 132 | field40: typing.Union[typing.Optional[int], None] 133 | field41: typing.Optional[typing.Union[int, None]] - | ^^^^ PYI016 + | ^^^^ 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] 135 | field43: typing.Optional[int] | None | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 130 130 | field39: typing.Optional[None] @@ -979,16 +1027,17 @@ PYI016.py:133:44: PYI016 [*] Duplicate union member `None` 135 135 | field43: typing.Optional[int] | None 136 136 | field44: typing.Optional[int | None] -PYI016.py:134:45: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:134:45 | 132 | field40: typing.Union[typing.Optional[int], None] 133 | field41: typing.Optional[typing.Union[int, None]] 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] - | ^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^ 135 | field43: typing.Optional[int] | None 136 | field44: typing.Optional[int | None] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 131 131 | # equivalent to int | None @@ -1000,16 +1049,17 @@ PYI016.py:134:45: PYI016 [*] Duplicate union member `None` 136 136 | field44: typing.Optional[int | None] 137 137 | field45: typing.Optional[int] | typing.Optional[int] -PYI016.py:134:61: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:134:61 | 132 | field40: typing.Union[typing.Optional[int], None] 133 | field41: typing.Optional[typing.Union[int, None]] 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] - | ^^^ PYI016 + | ^^^ 135 | field43: typing.Optional[int] | None 136 | field44: typing.Optional[int | None] | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 131 131 | # equivalent to int | None @@ -1021,16 +1071,17 @@ PYI016.py:134:61: PYI016 [*] Duplicate union member `int` 136 136 | field44: typing.Optional[int | None] 137 137 | field45: typing.Optional[int] | typing.Optional[int] -PYI016.py:135:33: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:135:33 | 133 | field41: typing.Optional[typing.Union[int, None]] 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] 135 | field43: typing.Optional[int] | None - | ^^^^ PYI016 + | ^^^^ 136 | field44: typing.Optional[int | None] 137 | field45: typing.Optional[int] | typing.Optional[int] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 132 132 | field40: typing.Union[typing.Optional[int], None] @@ -1042,16 +1093,17 @@ PYI016.py:135:33: PYI016 [*] Duplicate union member `None` 137 137 | field45: typing.Optional[int] | typing.Optional[int] 138 138 | # equivalent to int | dict | None -PYI016.py:136:32: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:136:32 | 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] 135 | field43: typing.Optional[int] | None 136 | field44: typing.Optional[int | None] - | ^^^^ PYI016 + | ^^^^ 137 | field45: typing.Optional[int] | typing.Optional[int] 138 | # equivalent to int | dict | None | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 133 133 | field41: typing.Optional[typing.Union[int, None]] @@ -1063,16 +1115,17 @@ PYI016.py:136:32: PYI016 [*] Duplicate union member `None` 138 138 | # equivalent to int | dict | None 139 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] -PYI016.py:137:33: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:137:33 | 135 | field43: typing.Optional[int] | None 136 | field44: typing.Optional[int | None] 137 | field45: typing.Optional[int] | typing.Optional[int] - | ^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^ 138 | # equivalent to int | dict | None 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 134 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] @@ -1084,16 +1137,17 @@ PYI016.py:137:33: PYI016 [*] Duplicate union member `None` 139 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] 140 140 | field47: typing.Optional[int] | typing.Optional[dict] -PYI016.py:137:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.py:137:49 | 135 | field43: typing.Optional[int] | None 136 | field44: typing.Optional[int | None] 137 | field45: typing.Optional[int] | typing.Optional[int] - | ^^^ PYI016 + | ^^^ 138 | # equivalent to int | dict | None 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 134 134 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] @@ -1105,15 +1159,16 @@ PYI016.py:137:49: PYI016 [*] Duplicate union member `int` 139 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] 140 140 | field47: typing.Optional[int] | typing.Optional[dict] -PYI016.py:139:45: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:139:45 | 137 | field45: typing.Optional[int] | typing.Optional[int] 138 | # equivalent to int | dict | None 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] - | ^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^ 140 | field47: typing.Optional[int] | typing.Optional[dict] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 136 136 | field44: typing.Optional[int | None] @@ -1125,16 +1180,17 @@ PYI016.py:139:45: PYI016 [*] Duplicate union member `None` 141 141 | 142 142 | # avoid reporting twice -PYI016.py:140:33: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.py:140:33 | 138 | # equivalent to int | dict | None 139 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] 140 | field47: typing.Optional[int] | typing.Optional[dict] - | ^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^ 141 | 142 | # avoid reporting twice | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 137 137 | field45: typing.Optional[int] | typing.Optional[int] @@ -1146,14 +1202,15 @@ PYI016.py:140:33: PYI016 [*] Duplicate union member `None` 142 142 | # avoid reporting twice 143 143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] -PYI016.py:143:61: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.py:143:61 | 142 | # avoid reporting twice 143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] - | ^^^^^^^ PYI016 + | ^^^^^^^ 144 | field49: typing.Optional[complex | complex] | complex | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 140 140 | field47: typing.Optional[int] | typing.Optional[dict] @@ -1165,14 +1222,15 @@ PYI016.py:143:61: PYI016 [*] Duplicate union member `complex` 145 145 | 146 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 -PYI016.py:143:72: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.py:143:72 | 142 | # avoid reporting twice 143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] - | ^^^^^^^ PYI016 + | ^^^^^^^ 144 | field49: typing.Optional[complex | complex] | complex | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 140 140 | field47: typing.Optional[int] | typing.Optional[dict] @@ -1184,16 +1242,17 @@ PYI016.py:143:72: PYI016 [*] Duplicate union member `complex` 145 145 | 146 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 -PYI016.py:144:36: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.py:144:36 | 142 | # avoid reporting twice 143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] 144 | field49: typing.Optional[complex | complex] | complex - | ^^^^^^^ PYI016 + | ^^^^^^^ 145 | 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 141 141 | @@ -1205,16 +1264,17 @@ PYI016.py:144:36: PYI016 [*] Duplicate union member `complex` 146 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 147 147 | # Should throw duplicate union member but not fix -PYI016.py:144:47: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.py:144:47 | 142 | # avoid reporting twice 143 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] 144 | field49: typing.Optional[complex | complex] | complex - | ^^^^^^^ PYI016 + | ^^^^^^^ 145 | 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 141 141 | @@ -1226,11 +1286,12 @@ PYI016.py:144:47: PYI016 [*] Duplicate union member `complex` 146 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 147 147 | # Should throw duplicate union member but not fix -PYI016.py:148:37: PYI016 Duplicate union member `None` +PYI016 Duplicate union member `None` + --> PYI016.py:148:37 | 146 | # Regression test for https://github.com/astral-sh/ruff/issues/19403 147 | # Should throw duplicate union member but not fix 148 | isinstance(None, typing.Union[None, None]) - | ^^^^ PYI016 + | ^^^^ | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI016_PYI016.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI016_PYI016.pyi.snap index 4af0da5a50..4d970dddd1 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI016_PYI016.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__preview__PYI016_PYI016.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI016.pyi:7:15: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:7:15 | 6 | # Should emit for duplicate field types. 7 | field2: str | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 8 | 9 | # Should emit for union types in arguments. | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 4 4 | field1: str @@ -21,14 +22,15 @@ PYI016.pyi:7:15: PYI016 [*] Duplicate union member `str` 9 9 | # Should emit for union types in arguments. 10 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` -PYI016.pyi:10:23: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:10:23 | 9 | # Should emit for union types in arguments. 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 11 | print(arg1) | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 7 7 | field2: str | str # PYI016: Duplicate union member `str` @@ -40,14 +42,15 @@ PYI016.pyi:10:23: PYI016 [*] Duplicate union member `int` 12 12 | 13 13 | # Should emit for unions in return types. -PYI016.pyi:14:22: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:14:22 | 13 | # Should emit for unions in return types. 14 | def func2() -> str | str: # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 15 | return "my string" | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 11 11 | print(arg1) @@ -59,15 +62,16 @@ PYI016.pyi:14:22: PYI016 [*] Duplicate union member `str` 16 16 | 17 17 | # Should emit in longer unions, even if not directly adjacent. -PYI016.pyi:18:15: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:18:15 | 17 | # Should emit in longer unions, even if not directly adjacent. 18 | field3: str | str | int # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 15 15 | return "my string" @@ -79,16 +83,17 @@ PYI016.pyi:18:15: PYI016 [*] Duplicate union member `str` 20 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` -PYI016.pyi:19:15: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:19:15 | 17 | # Should emit in longer unions, even if not directly adjacent. 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 | field4: int | int | str # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 16 16 | @@ -100,15 +105,16 @@ PYI016.pyi:19:15: PYI016 [*] Duplicate union member `int` 21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` 22 22 | -PYI016.pyi:20:21: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:20:21 | 18 | field3: str | str | int # PYI016: Duplicate union member `str` 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 17 17 | # Should emit in longer unions, even if not directly adjacent. @@ -120,16 +126,17 @@ PYI016.pyi:20:21: PYI016 [*] Duplicate union member `str` 22 22 | 23 23 | # Shouldn't emit for non-type unions. -PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:21:28 | 19 | field4: int | int | str # PYI016: Duplicate union member `int` 20 | field5: str | int | str # PYI016: Duplicate union member `str` 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 22 | 23 | # Shouldn't emit for non-type unions. | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 18 18 | field3: str | str | int # PYI016: Duplicate union member `str` @@ -141,15 +148,16 @@ PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int` 23 23 | # Shouldn't emit for non-type unions. 24 24 | field7 = str | str -PYI016.pyi:27:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:27:22 | 26 | # Should emit for strangely-bracketed unions. 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 28 | 29 | # Should handle user brackets when fixing. | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 24 24 | field7 = str | str @@ -161,14 +169,15 @@ PYI016.pyi:27:22: PYI016 [*] Duplicate union member `int` 29 29 | # Should handle user brackets when fixing. 30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` -PYI016.pyi:30:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:30:16 | 29 | # Should handle user brackets when fixing. 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` @@ -180,16 +189,17 @@ PYI016.pyi:30:16: PYI016 [*] Duplicate union member `int` 32 32 | 33 33 | # Should emit for nested unions. -PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str` +PYI016 [*] Duplicate union member `str` + --> PYI016.pyi:31:24 | 29 | # Should handle user brackets when fixing. 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 + | ^^^ 32 | 33 | # Should emit for nested unions. | - = help: Remove duplicate union member `str` +help: Remove duplicate union member `str` ℹ Safe fix 28 28 | @@ -201,15 +211,16 @@ PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str` 33 33 | # Should emit for nested unions. 34 34 | field11: dict[int | int, str] -PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:34:21 | 33 | # Should emit for nested unions. 34 | field11: dict[int | int, str] - | ^^^ PYI016 + | ^^^ 35 | 36 | # Should emit for unions with more than two cases | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` @@ -221,14 +232,15 @@ PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int` 36 36 | # Should emit for unions with more than two cases 37 37 | field12: int | int | int # Error -PYI016.pyi:37:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:37:16 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error - | ^^^ PYI016 + | ^^^ 38 | field13: int | int | int | int # Error | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 34 34 | field11: dict[int | int, str] @@ -240,14 +252,15 @@ PYI016.pyi:37:16: PYI016 [*] Duplicate union member `int` 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI016.pyi:37:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:37:22 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error - | ^^^ PYI016 + | ^^^ 38 | field13: int | int | int | int # Error | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 34 34 | field11: dict[int | int, str] @@ -259,16 +272,17 @@ PYI016.pyi:37:22: PYI016 [*] Duplicate union member `int` 39 39 | 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:38:16 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -280,16 +294,17 @@ PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:38:22 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -301,16 +316,17 @@ PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:38:28 | 36 | # Should emit for unions with more than two cases 37 | field12: int | int | int # Error 38 | field13: int | int | int | int # Error - | ^^^ PYI016 + | ^^^ 39 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 35 35 | @@ -322,15 +338,16 @@ PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int` 40 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 41 | field14: int | int | str | int # Error -PYI016.pyi:41:16: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:41:16 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error - | ^^^ PYI016 + | ^^^ 42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 38 38 | field13: int | int | int | int # Error @@ -342,15 +359,16 @@ PYI016.pyi:41:16: PYI016 [*] Duplicate union member `int` 43 43 | # Should emit for duplicate literal types; also covered by PYI030 44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error -PYI016.pyi:41:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:41:28 | 40 | # Should emit for unions with more than two cases, even if not directly adjacent 41 | field14: int | int | str | int # Error - | ^^^ PYI016 + | ^^^ 42 | 43 | # Should emit for duplicate literal types; also covered by PYI030 | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 38 38 | field13: int | int | int | int # Error @@ -362,15 +380,16 @@ PYI016.pyi:41:28: PYI016 [*] Duplicate union member `int` 43 43 | # Should emit for duplicate literal types; also covered by PYI030 44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error -PYI016.pyi:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` +PYI016 [*] Duplicate union member `typing.Literal[1]` + --> PYI016.pyi:44:30 | 43 | # Should emit for duplicate literal types; also covered by PYI030 44 | field15: typing.Literal[1] | typing.Literal[1] # Error - | ^^^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^^^ 45 | 46 | # Shouldn't emit if in new parent type | - = help: Remove duplicate union member `typing.Literal[1]` +help: Remove duplicate union member `typing.Literal[1]` ℹ Safe fix 41 41 | field14: int | int | str | int # Error @@ -382,17 +401,18 @@ PYI016.pyi:44:30: PYI016 [*] Duplicate union member `typing.Literal[1]` 46 46 | # Shouldn't emit if in new parent type 47 47 | field16: int | dict[int, str] # OK -PYI016.pyi:57:5: PYI016 [*] Duplicate union member `set[int]` +PYI016 [*] Duplicate union member `set[int]` + --> PYI016.pyi:57:5 | 55 | int # foo 56 | ], 57 | / set[ 58 | | int # bar 59 | | ], - | |_____^ PYI016 + | |_____^ 60 | ] # Error, newline and comment will not be emitted in message | - = help: Remove duplicate union member `set[int]` +help: Remove duplicate union member `set[int]` ℹ Unsafe fix 50 50 | field17: dict[int, int] # OK @@ -411,15 +431,16 @@ PYI016.pyi:57:5: PYI016 [*] Duplicate union member `set[int]` 62 55 | # Should emit in cases with `typing.Union` instead of `|` 63 56 | field19: typing.Union[int, int] # Error -PYI016.pyi:63:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:63:28 | 62 | # Should emit in cases with `typing.Union` instead of `|` 63 | field19: typing.Union[int, int] # Error - | ^^^ PYI016 + | ^^^ 64 | 65 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 60 60 | ] # Error, newline and comment will not be emitted in message @@ -431,15 +452,16 @@ PYI016.pyi:63:28: PYI016 [*] Duplicate union member `int` 65 65 | # Should emit in cases with nested `typing.Union` 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error -PYI016.pyi:66:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:66:41 | 65 | # Should emit in cases with nested `typing.Union` 66 | field20: typing.Union[int, typing.Union[int, str]] # Error - | ^^^ PYI016 + | ^^^ 67 | 68 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 63 63 | field19: typing.Union[int, int] # Error @@ -451,15 +473,16 @@ PYI016.pyi:66:41: PYI016 [*] Duplicate union member `int` 68 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 69 | field21: typing.Union[int, int | str] # Error -PYI016.pyi:69:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:69:28 | 68 | # Should emit in cases with mixed `typing.Union` and `|` 69 | field21: typing.Union[int, int | str] # Error - | ^^^ PYI016 + | ^^^ 70 | 71 | # Should emit only once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error @@ -471,15 +494,16 @@ PYI016.pyi:69:28: PYI016 [*] Duplicate union member `int` 71 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error -PYI016.pyi:72:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:72:41 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -491,15 +515,16 @@ PYI016.pyi:72:41: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.pyi:72:59: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:72:59 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -511,15 +536,16 @@ PYI016.pyi:72:59: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.pyi:72:64: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:72:64 | 71 | # Should emit only once in cases with multiple nested `typing.Union` 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 73 | 74 | # Should emit in cases with newlines | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 69 69 | field21: typing.Union[int, int | str] # Error @@ -531,16 +557,17 @@ PYI016.pyi:72:64: PYI016 [*] Duplicate union member `int` 74 74 | # Should emit in cases with newlines 75 75 | field23: set[ # foo -PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]` +PYI016 [*] Duplicate union member `set[int]` + --> PYI016.pyi:76:12 | 74 | # Should emit in cases with newlines 75 | field23: set[ # foo 76 | int] | set[int] - | ^^^^^^^^ PYI016 + | ^^^^^^^^ 77 | 78 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `set[int]` +help: Remove duplicate union member `set[int]` ℹ Unsafe fix 72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error @@ -553,16 +580,17 @@ PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]` 78 77 | # Should emit twice (once for each `int` in the nested union, both of which are 79 78 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.pyi:81:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:81:41 | 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 78 78 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -574,16 +602,17 @@ PYI016.pyi:81:41: PYI016 [*] Duplicate union member `int` 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.pyi:81:46: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:81:46 | 79 | # duplicates of the outer `int`), but not three times (which would indicate that 80 | # we incorrectly re-checked the nested union). 81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 82 | 83 | # Should emit twice (once for each `int` in the nested union, both of which are | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 78 78 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -595,16 +624,17 @@ PYI016.pyi:81:46: PYI016 [*] Duplicate union member `int` 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are 84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:86:28 | 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 87 | 88 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -616,16 +646,17 @@ PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int` 88 88 | # Should emit in cases with nested `typing.Union` 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` -PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:86:34 | 84 | # duplicates of the outer `int`), but not three times (which would indicate that 85 | # we incorrectly re-checked the nested union). 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 87 | 88 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 83 83 | # Should emit twice (once for each `int` in the nested union, both of which are @@ -637,15 +668,16 @@ PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int` 88 88 | # Should emit in cases with nested `typing.Union` 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` -PYI016.pyi:89:41: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:89:41 | 88 | # Should emit in cases with nested `typing.Union` 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 90 | 91 | # Should emit in cases with nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 86 86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` @@ -657,15 +689,16 @@ PYI016.pyi:89:41: PYI016 [*] Duplicate union member `int` 91 91 | # Should emit in cases with nested `typing.Union` 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` -PYI016.pyi:92:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:92:54 | 91 | # Should emit in cases with nested `typing.Union` 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 + | ^^^ 93 | 94 | # Should emit in cases with mixed `typing.Union` and `|` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 89 89 | field26: typing.Union[typing.Union[int, int]] # PYI016: Duplicate union member `int` @@ -677,15 +710,16 @@ PYI016.pyi:92:54: PYI016 [*] Duplicate union member `int` 94 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 95 | field28: typing.Union[int | int] # Error -PYI016.pyi:95:29: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:95:29 | 94 | # Should emit in cases with mixed `typing.Union` and `|` 95 | field28: typing.Union[int | int] # Error - | ^^^ PYI016 + | ^^^ 96 | 97 | # Should emit twice in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 92 92 | field27: typing.Union[typing.Union[typing.Union[int, int]]] # PYI016: Duplicate union member `int` @@ -697,15 +731,16 @@ PYI016.pyi:95:29: PYI016 [*] Duplicate union member `int` 97 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error -PYI016.pyi:98:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:98:54 | 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 95 95 | field28: typing.Union[int | int] # Error @@ -717,15 +752,16 @@ PYI016.pyi:98:54: PYI016 [*] Duplicate union member `int` 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error -PYI016.pyi:98:59: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:98:59 | 97 | # Should emit twice in cases with multiple nested `typing.Union` 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error - | ^^^ PYI016 + | ^^^ 99 | 100 | # Should emit once in cases with multiple nested `typing.Union` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 95 95 | field28: typing.Union[int | int] # Error @@ -737,15 +773,16 @@ PYI016.pyi:98:59: PYI016 [*] Duplicate union member `int` 100 100 | # Should emit once in cases with multiple nested `typing.Union` 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error -PYI016.pyi:101:54: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:101:54 | 100 | # Should emit once in cases with multiple nested `typing.Union` 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error - | ^^^ PYI016 + | ^^^ 102 | 103 | # Should emit once, and fix to `typing.Union[float, int]` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 98 98 | field29: typing.Union[int, typing.Union[typing.Union[int, int]]] # Error @@ -757,15 +794,16 @@ PYI016.pyi:101:54: PYI016 [*] Duplicate union member `int` 103 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error -PYI016.pyi:104:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:104:49 | 103 | # Should emit once, and fix to `typing.Union[float, int]` 104 | field31: typing.Union[float, typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 105 | 106 | # Should emit once, and fix to `typing.Union[float, int]` | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 101 101 | field30: typing.Union[int, typing.Union[typing.Union[int, str]]] # Error @@ -777,15 +815,16 @@ PYI016.pyi:104:49: PYI016 [*] Duplicate union member `int` 106 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error -PYI016.pyi:107:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:107:49 | 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error - | ^^^ PYI016 + | ^^^ 108 | 109 | # Test case for mixed union type fix | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error @@ -797,15 +836,16 @@ PYI016.pyi:107:49: PYI016 [*] Duplicate union member `int` 109 109 | # Test case for mixed union type fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error -PYI016.pyi:107:55: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:107:55 | 106 | # Should emit once, and fix to `typing.Union[float, int]` 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error - | ^^^ PYI016 + | ^^^ 108 | 109 | # Test case for mixed union type fix | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 104 104 | field31: typing.Union[float, typing.Union[int | int]] # Error @@ -817,15 +857,16 @@ PYI016.pyi:107:55: PYI016 [*] Duplicate union member `int` 109 109 | # Test case for mixed union type fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error -PYI016.pyi:110:42: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:110:42 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -837,15 +878,16 @@ PYI016.pyi:110:42: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.pyi:110:62: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:110:62 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -857,15 +899,16 @@ PYI016.pyi:110:62: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.pyi:110:68: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:110:68 | 109 | # Test case for mixed union type fix 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error - | ^^^ PYI016 + | ^^^ 111 | 112 | # Test case for mixed union type | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 107 107 | field32: typing.Union[float, typing.Union[int | int | int]] # Error @@ -877,15 +920,16 @@ PYI016.pyi:110:68: PYI016 [*] Duplicate union member `int` 112 112 | # Test case for mixed union type 113 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error -PYI016.pyi:113:61: PYI016 [*] Duplicate union member `list[int]` +PYI016 [*] Duplicate union member `list[int]` + --> PYI016.pyi:113:61 | 112 | # Test case for mixed union type 113 | field34: typing.Union[list[int], str] | typing.Union[bytes, list[int]] # Error - | ^^^^^^^^^ PYI016 + | ^^^^^^^^^ 114 | 115 | # https://github.com/astral-sh/ruff/issues/18546 | - = help: Remove duplicate union member `list[int]` +help: Remove duplicate union member `list[int]` ℹ Safe fix 110 110 | field33: typing.Union[typing.Union[int | int] | typing.Union[int | int]] # Error @@ -897,16 +941,17 @@ PYI016.pyi:113:61: PYI016 [*] Duplicate union member `list[int]` 115 115 | # https://github.com/astral-sh/ruff/issues/18546 116 116 | # Expand Optional[T] to Union[T, None] -PYI016.pyi:121:26: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:121:26 | 119 | field38: typing.Union[int, None] 120 | # equivalent to None 121 | field39: typing.Optional[None] - | ^^^^ PYI016 + | ^^^^ 122 | # equivalent to int | None 123 | field40: typing.Union[typing.Optional[int], None] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 118 118 | field37: typing.Optional[int] @@ -918,16 +963,17 @@ PYI016.pyi:121:26: PYI016 [*] Duplicate union member `None` 123 123 | field40: typing.Union[typing.Optional[int], None] 124 124 | field41: typing.Optional[typing.Union[int, None]] -PYI016.pyi:123:45: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:123:45 | 121 | field39: typing.Optional[None] 122 | # equivalent to int | None 123 | field40: typing.Union[typing.Optional[int], None] - | ^^^^ PYI016 + | ^^^^ 124 | field41: typing.Optional[typing.Union[int, None]] 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 120 120 | # equivalent to None @@ -939,16 +985,17 @@ PYI016.pyi:123:45: PYI016 [*] Duplicate union member `None` 125 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] 126 126 | field43: typing.Optional[int] | None -PYI016.pyi:124:44: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:124:44 | 122 | # equivalent to int | None 123 | field40: typing.Union[typing.Optional[int], None] 124 | field41: typing.Optional[typing.Union[int, None]] - | ^^^^ PYI016 + | ^^^^ 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] 126 | field43: typing.Optional[int] | None | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 121 121 | field39: typing.Optional[None] @@ -960,16 +1007,17 @@ PYI016.pyi:124:44: PYI016 [*] Duplicate union member `None` 126 126 | field43: typing.Optional[int] | None 127 127 | field44: typing.Optional[int | None] -PYI016.pyi:125:45: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:125:45 | 123 | field40: typing.Union[typing.Optional[int], None] 124 | field41: typing.Optional[typing.Union[int, None]] 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] - | ^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^ 126 | field43: typing.Optional[int] | None 127 | field44: typing.Optional[int | None] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 122 122 | # equivalent to int | None @@ -981,16 +1029,17 @@ PYI016.pyi:125:45: PYI016 [*] Duplicate union member `None` 127 127 | field44: typing.Optional[int | None] 128 128 | field45: typing.Optional[int] | typing.Optional[int] -PYI016.pyi:125:61: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:125:61 | 123 | field40: typing.Union[typing.Optional[int], None] 124 | field41: typing.Optional[typing.Union[int, None]] 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] - | ^^^ PYI016 + | ^^^ 126 | field43: typing.Optional[int] | None 127 | field44: typing.Optional[int | None] | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 122 122 | # equivalent to int | None @@ -1002,16 +1051,17 @@ PYI016.pyi:125:61: PYI016 [*] Duplicate union member `int` 127 127 | field44: typing.Optional[int | None] 128 128 | field45: typing.Optional[int] | typing.Optional[int] -PYI016.pyi:126:33: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:126:33 | 124 | field41: typing.Optional[typing.Union[int, None]] 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] 126 | field43: typing.Optional[int] | None - | ^^^^ PYI016 + | ^^^^ 127 | field44: typing.Optional[int | None] 128 | field45: typing.Optional[int] | typing.Optional[int] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 123 123 | field40: typing.Union[typing.Optional[int], None] @@ -1023,16 +1073,17 @@ PYI016.pyi:126:33: PYI016 [*] Duplicate union member `None` 128 128 | field45: typing.Optional[int] | typing.Optional[int] 129 129 | # equivalent to int | dict | None -PYI016.pyi:127:32: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:127:32 | 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] 126 | field43: typing.Optional[int] | None 127 | field44: typing.Optional[int | None] - | ^^^^ PYI016 + | ^^^^ 128 | field45: typing.Optional[int] | typing.Optional[int] 129 | # equivalent to int | dict | None | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 124 124 | field41: typing.Optional[typing.Union[int, None]] @@ -1044,16 +1095,17 @@ PYI016.pyi:127:32: PYI016 [*] Duplicate union member `None` 129 129 | # equivalent to int | dict | None 130 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] -PYI016.pyi:128:33: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:128:33 | 126 | field43: typing.Optional[int] | None 127 | field44: typing.Optional[int | None] 128 | field45: typing.Optional[int] | typing.Optional[int] - | ^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^ 129 | # equivalent to int | dict | None 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 125 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] @@ -1065,16 +1117,17 @@ PYI016.pyi:128:33: PYI016 [*] Duplicate union member `None` 130 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] 131 131 | field47: typing.Optional[int] | typing.Optional[dict] -PYI016.pyi:128:49: PYI016 [*] Duplicate union member `int` +PYI016 [*] Duplicate union member `int` + --> PYI016.pyi:128:49 | 126 | field43: typing.Optional[int] | None 127 | field44: typing.Optional[int | None] 128 | field45: typing.Optional[int] | typing.Optional[int] - | ^^^ PYI016 + | ^^^ 129 | # equivalent to int | dict | None 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] | - = help: Remove duplicate union member `int` +help: Remove duplicate union member `int` ℹ Safe fix 125 125 | field42: typing.Union[typing.Optional[int], typing.Optional[int]] @@ -1086,15 +1139,16 @@ PYI016.pyi:128:49: PYI016 [*] Duplicate union member `int` 130 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] 131 131 | field47: typing.Optional[int] | typing.Optional[dict] -PYI016.pyi:130:45: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:130:45 | 128 | field45: typing.Optional[int] | typing.Optional[int] 129 | # equivalent to int | dict | None 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] - | ^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^ 131 | field47: typing.Optional[int] | typing.Optional[dict] | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 127 127 | field44: typing.Optional[int | None] @@ -1106,16 +1160,17 @@ PYI016.pyi:130:45: PYI016 [*] Duplicate union member `None` 132 132 | 133 133 | # avoid reporting twice -PYI016.pyi:131:33: PYI016 [*] Duplicate union member `None` +PYI016 [*] Duplicate union member `None` + --> PYI016.pyi:131:33 | 129 | # equivalent to int | dict | None 130 | field46: typing.Union[typing.Optional[int], typing.Optional[dict]] 131 | field47: typing.Optional[int] | typing.Optional[dict] - | ^^^^^^^^^^^^^^^ PYI016 + | ^^^^^^^^^^^^^^^ 132 | 133 | # avoid reporting twice | - = help: Remove duplicate union member `None` +help: Remove duplicate union member `None` ℹ Safe fix 128 128 | field45: typing.Optional[int] | typing.Optional[int] @@ -1127,14 +1182,15 @@ PYI016.pyi:131:33: PYI016 [*] Duplicate union member `None` 133 133 | # avoid reporting twice 134 134 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] -PYI016.pyi:134:61: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.pyi:134:61 | 133 | # avoid reporting twice 134 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] - | ^^^^^^^ PYI016 + | ^^^^^^^ 135 | field49: typing.Optional[complex | complex] | complex | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 131 131 | field47: typing.Optional[int] | typing.Optional[dict] @@ -1144,14 +1200,15 @@ PYI016.pyi:134:61: PYI016 [*] Duplicate union member `complex` 134 |+field48: typing.Union[None, complex] 135 135 | field49: typing.Optional[complex | complex] | complex -PYI016.pyi:134:72: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.pyi:134:72 | 133 | # avoid reporting twice 134 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] - | ^^^^^^^ PYI016 + | ^^^^^^^ 135 | field49: typing.Optional[complex | complex] | complex | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 131 131 | field47: typing.Optional[int] | typing.Optional[dict] @@ -1161,14 +1218,15 @@ PYI016.pyi:134:72: PYI016 [*] Duplicate union member `complex` 134 |+field48: typing.Union[None, complex] 135 135 | field49: typing.Optional[complex | complex] | complex -PYI016.pyi:135:36: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.pyi:135:36 | 133 | # avoid reporting twice 134 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] 135 | field49: typing.Optional[complex | complex] | complex - | ^^^^^^^ PYI016 + | ^^^^^^^ | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 132 132 | @@ -1177,14 +1235,15 @@ PYI016.pyi:135:36: PYI016 [*] Duplicate union member `complex` 135 |-field49: typing.Optional[complex | complex] | complex 135 |+field49: None | complex -PYI016.pyi:135:47: PYI016 [*] Duplicate union member `complex` +PYI016 [*] Duplicate union member `complex` + --> PYI016.pyi:135:47 | 133 | # avoid reporting twice 134 | field48: typing.Union[typing.Optional[typing.Union[complex, complex]], complex] 135 | field49: typing.Optional[complex | complex] | complex - | ^^^^^^^ PYI016 + | ^^^^^^^ | - = help: Remove duplicate union member `complex` +help: Remove duplicate union member `complex` ℹ Safe fix 132 132 | diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap index 405375d032..aca6cc9120 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI026.pyi:3:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` +PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` + --> PYI026.pyi:3:1 | 1 | from typing import Literal, Any 2 | 3 | NewAny = Any - | ^^^^^^ PYI026 + | ^^^^^^ 4 | OptionalStr = typing.Optional[str] 5 | Foo = Literal["foo"] | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 1 | from typing import Literal, Any @@ -22,15 +23,16 @@ PYI026.pyi:3:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g 5 6 | Foo = Literal["foo"] 6 7 | IntOrStr = int | str -PYI026.pyi:4:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]` +PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]` + --> PYI026.pyi:4:1 | 3 | NewAny = Any 4 | OptionalStr = typing.Optional[str] - | ^^^^^^^^^^^ PYI026 + | ^^^^^^^^^^^ 5 | Foo = Literal["foo"] 6 | IntOrStr = int | str | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 1 | from typing import Literal, Any @@ -43,16 +45,17 @@ PYI026.pyi:4:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g 6 7 | IntOrStr = int | str 7 8 | AliasNone = None -PYI026.pyi:5:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]` +PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]` + --> PYI026.pyi:5:1 | 3 | NewAny = Any 4 | OptionalStr = typing.Optional[str] 5 | Foo = Literal["foo"] - | ^^^ PYI026 + | ^^^ 6 | IntOrStr = int | str 7 | AliasNone = None | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 1 | from typing import Literal, Any @@ -66,15 +69,16 @@ PYI026.pyi:5:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g 7 8 | AliasNone = None 8 9 | -PYI026.pyi:6:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str` +PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str` + --> PYI026.pyi:6:1 | 4 | OptionalStr = typing.Optional[str] 5 | Foo = Literal["foo"] 6 | IntOrStr = int | str - | ^^^^^^^^ PYI026 + | ^^^^^^^^ 7 | AliasNone = None | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 1 | from typing import Literal, Any @@ -89,16 +93,17 @@ PYI026.pyi:6:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g 8 9 | 9 10 | NewAny: typing.TypeAlias = Any -PYI026.pyi:7:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None` +PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None` + --> PYI026.pyi:7:1 | 5 | Foo = Literal["foo"] 6 | IntOrStr = int | str 7 | AliasNone = None - | ^^^^^^^^^ PYI026 + | ^^^^^^^^^ 8 | 9 | NewAny: typing.TypeAlias = Any | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 1 | from typing import Literal, Any @@ -114,15 +119,16 @@ PYI026.pyi:7:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g 9 10 | NewAny: typing.TypeAlias = Any 10 11 | OptionalStr: TypeAlias = typing.Optional[str] -PYI026.pyi:17:5: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `FLAG_THIS: TypeAlias = None` +PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `FLAG_THIS: TypeAlias = None` + --> PYI026.pyi:17:5 | 16 | class NotAnEnum: 17 | FLAG_THIS = None - | ^^^^^^^^^ PYI026 + | ^^^^^^^^^ 18 | 19 | # these are ok | - = help: Add `TypeAlias` annotation +help: Add `TypeAlias` annotation ℹ Safe fix 1 1 | from typing import Literal, Any diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI061_PYI061.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI061_PYI061.py.snap index bbee6e9da5..dc91e6c77a 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI061_PYI061.py.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI061_PYI061.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI061.py:4:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:4:25 | 4 | def func1(arg1: Literal[None]): - | ^^^^ PYI061 + | ^^^^ 5 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 1 1 | from typing import Literal, Union @@ -19,13 +20,14 @@ PYI061.py:4:25: PYI061 [*] Use `None` rather than `Literal[None]` 6 6 | 7 7 | -PYI061.py:8:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:8:25 | 8 | def func2(arg1: Literal[None] | int): - | ^^^^ PYI061 + | ^^^^ 9 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 5 5 | ... @@ -37,13 +39,14 @@ PYI061.py:8:25: PYI061 [*] Use `None` rather than `Literal[None]` 10 10 | 11 11 | -PYI061.py:12:24: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:12:24 | 12 | def func3() -> Literal[None]: - | ^^^^ PYI061 + | ^^^^ 13 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 9 9 | ... @@ -55,13 +58,14 @@ PYI061.py:12:24: PYI061 [*] Use `None` rather than `Literal[None]` 14 14 | 15 15 | -PYI061.py:16:30: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` +PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` + --> PYI061.py:16:30 | 16 | def func4(arg1: Literal[int, None, float]): - | ^^^^ PYI061 + | ^^^^ 17 | ... | - = help: Replace with `Optional[Literal[...]]` +help: Replace with `Optional[Literal[...]]` ℹ Safe fix 1 |-from typing import Literal, Union @@ -79,13 +83,14 @@ PYI061.py:16:30: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[No 18 18 | 19 19 | -PYI061.py:20:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:20:25 | 20 | def func5(arg1: Literal[None, None]): - | ^^^^ PYI061 + | ^^^^ 21 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 17 17 | ... @@ -97,13 +102,14 @@ PYI061.py:20:25: PYI061 [*] Use `None` rather than `Literal[None]` 22 22 | 23 23 | -PYI061.py:20:31: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:20:31 | 20 | def func5(arg1: Literal[None, None]): - | ^^^^ PYI061 + | ^^^^ 21 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 17 17 | ... @@ -115,16 +121,17 @@ PYI061.py:20:31: PYI061 [*] Use `None` rather than `Literal[None]` 22 22 | 23 23 | -PYI061.py:26:5: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` +PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` + --> PYI061.py:26:5 | 24 | def func6(arg1: Literal[ 25 | "hello", 26 | None # Comment 1 - | ^^^^ PYI061 + | ^^^^ 27 | , "world" 28 | ]): | - = help: Replace with `Optional[Literal[...]]` +help: Replace with `Optional[Literal[...]]` ℹ Unsafe fix 1 |-from typing import Literal, Union @@ -146,15 +153,16 @@ PYI061.py:26:5: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[Non 30 26 | 31 27 | -PYI061.py:33:5: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:33:5 | 32 | def func7(arg1: Literal[ 33 | None # Comment 1 - | ^^^^ PYI061 + | ^^^^ 34 | ]): 35 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Unsafe fix 29 29 | ... @@ -168,21 +176,23 @@ PYI061.py:33:5: PYI061 [*] Use `None` rather than `Literal[None]` 36 34 | 37 35 | -PYI061.py:38:25: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:38:25 | 38 | def func8(arg1: Literal[None] | None): - | ^^^^ PYI061 + | ^^^^ 39 | ... | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:42:31: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:42:31 | 42 | def func9(arg1: Union[Literal[None], None]): - | ^^^^ PYI061 + | ^^^^ 43 | ... | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 39 39 | ... @@ -194,14 +204,15 @@ PYI061.py:42:31: PYI061 [*] Use `None` rather than `Literal[None]` 44 44 | 45 45 | -PYI061.py:52:9: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:52:9 | 51 | # From flake8-pyi 52 | Literal[None] # Y061 None inside "Literal[]" expression. Replace with "None" - | ^^^^ PYI061 + | ^^^^ 53 | Literal[True, None] # Y061 None inside "Literal[]" expression. Replace with "Literal[True] | None" | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 49 49 | @@ -213,16 +224,17 @@ PYI061.py:52:9: PYI061 [*] Use `None` rather than `Literal[None]` 54 54 | 55 55 | ### -PYI061.py:53:15: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` +PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` + --> PYI061.py:53:15 | 51 | # From flake8-pyi 52 | Literal[None] # Y061 None inside "Literal[]" expression. Replace with "None" 53 | Literal[True, None] # Y061 None inside "Literal[]" expression. Replace with "Literal[True] | None" - | ^^^^ PYI061 + | ^^^^ 54 | 55 | ### | - = help: Replace with `Optional[Literal[...]]` +help: Replace with `Optional[Literal[...]]` ℹ Safe fix 1 |-from typing import Literal, Union @@ -240,15 +252,16 @@ PYI061.py:53:15: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[No 55 55 | ### 56 56 | # The following rules here are slightly subtle, -PYI061.py:62:9: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:62:9 | 60 | # If Y061 and Y062 both apply, but all the duplicate members are None, 61 | # only emit Y061... 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" - | ^^^^ PYI061 + | ^^^^ 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 59 59 | @@ -260,15 +273,16 @@ PYI061.py:62:9: PYI061 [*] Use `None` rather than `Literal[None]` 64 64 | 65 65 | # ... but if Y061 and Y062 both apply -PYI061.py:62:15: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:62:15 | 60 | # If Y061 and Y062 both apply, but all the duplicate members are None, 61 | # only emit Y061... 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" - | ^^^^ PYI061 + | ^^^^ 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 59 59 | @@ -280,16 +294,17 @@ PYI061.py:62:15: PYI061 [*] Use `None` rather than `Literal[None]` 64 64 | 65 65 | # ... but if Y061 and Y062 both apply -PYI061.py:63:12: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` +PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` + --> PYI061.py:63:12 | 61 | # only emit Y061... 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" - | ^^^^ PYI061 + | ^^^^ 64 | 65 | # ... but if Y061 and Y062 both apply | - = help: Replace with `Optional[Literal[...]]` +help: Replace with `Optional[Literal[...]]` ℹ Safe fix 1 |-from typing import Literal, Union @@ -307,16 +322,17 @@ PYI061.py:63:12: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[No 65 65 | # ... but if Y061 and Y062 both apply 66 66 | # and there are no None members in the Literal[] slice, -PYI061.py:63:25: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` +PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` + --> PYI061.py:63:25 | 61 | # only emit Y061... 62 | Literal[None, None] # Y061 None inside "Literal[]" expression. Replace with "None" 63 | Literal[1, None, "foo", None] # Y061 None inside "Literal[]" expression. Replace with "Literal[1, 'foo'] | None" - | ^^^^ PYI061 + | ^^^^ 64 | 65 | # ... but if Y061 and Y062 both apply | - = help: Replace with `Optional[Literal[...]]` +help: Replace with `Optional[Literal[...]]` ℹ Safe fix 1 |-from typing import Literal, Union @@ -334,14 +350,15 @@ PYI061.py:63:25: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[No 65 65 | # ... but if Y061 and Y062 both apply 66 66 | # and there are no None members in the Literal[] slice, -PYI061.py:68:9: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` +PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` + --> PYI061.py:68:9 | 66 | # and there are no None members in the Literal[] slice, 67 | # only emit Y062: 68 | Literal[None, True, None, True] # Y062 Duplicate "Literal[]" member "True" - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `Optional[Literal[...]]` +help: Replace with `Optional[Literal[...]]` ℹ Safe fix 1 |-from typing import Literal, Union @@ -359,14 +376,15 @@ PYI061.py:68:9: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[Non 70 70 | 71 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 -PYI061.py:68:21: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` +PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[None, ...]` + --> PYI061.py:68:21 | 66 | # and there are no None members in the Literal[] slice, 67 | # only emit Y062: 68 | Literal[None, True, None, True] # Y062 Duplicate "Literal[]" member "True" - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `Optional[Literal[...]]` +help: Replace with `Optional[Literal[...]]` ℹ Safe fix 1 |-from typing import Literal, Union @@ -384,36 +402,39 @@ PYI061.py:68:21: PYI061 [*] Use `Optional[Literal[...]]` rather than `Literal[No 70 70 | 71 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 -PYI061.py:72:12: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:72:12 | 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 72 | x: Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 73 | y: None | Literal[None] 74 | z: Union[Literal[None], None] | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:73:19: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:73:19 | 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 72 | x: Literal[None] | None 73 | y: None | Literal[None] - | ^^^^ PYI061 + | ^^^^ 74 | z: Union[Literal[None], None] | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:74:18: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.py:74:18 | 72 | x: Literal[None] | None 73 | y: None | Literal[None] 74 | z: Union[Literal[None], None] - | ^^^^ PYI061 + | ^^^^ 75 | 76 | a: int | Literal[None] | None | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 71 71 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 @@ -425,53 +446,58 @@ PYI061.py:74:18: PYI061 [*] Use `None` rather than `Literal[None]` 76 76 | a: int | Literal[None] | None 77 77 | b: None | Literal[None] | None -PYI061.py:76:18: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:76:18 | 74 | z: Union[Literal[None], None] 75 | 76 | a: int | Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 77 | b: None | Literal[None] | None 78 | c: (None | Literal[None]) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:77:19: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:77:19 | 76 | a: int | Literal[None] | None 77 | b: None | Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 78 | c: (None | Literal[None]) | None 79 | d: None | (Literal[None] | None) | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:78:20: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:78:20 | 76 | a: int | Literal[None] | None 77 | b: None | Literal[None] | None 78 | c: (None | Literal[None]) | None - | ^^^^ PYI061 + | ^^^^ 79 | d: None | (Literal[None] | None) 80 | e: None | ((None | Literal[None]) | None) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:79:20: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:79:20 | 77 | b: None | Literal[None] | None 78 | c: (None | Literal[None]) | None 79 | d: None | (Literal[None] | None) - | ^^^^ PYI061 + | ^^^^ 80 | e: None | ((None | Literal[None]) | None) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.py:80:28: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.py:80:28 | 78 | c: (None | Literal[None]) | None 79 | d: None | (Literal[None] | None) 80 | e: None | ((None | Literal[None]) | None) | None - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI061_PYI061.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI061_PYI061.pyi.snap index 6a48501c8d..181432a325 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI061_PYI061.pyi.snap +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI061_PYI061.pyi.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs --- -PYI061.pyi:4:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:4:25 | 4 | def func1(arg1: Literal[None]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 1 1 | from typing import Literal, Union @@ -18,12 +19,13 @@ PYI061.pyi:4:25: PYI061 [*] Use `None` rather than `Literal[None]` 6 6 | 7 7 | def func2(arg1: Literal[None] | int): ... -PYI061.pyi:7:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:7:25 | 7 | def func2(arg1: Literal[None] | int): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 4 4 | def func1(arg1: Literal[None]): ... @@ -35,12 +37,13 @@ PYI061.pyi:7:25: PYI061 [*] Use `None` rather than `Literal[None]` 9 9 | 10 10 | def func3() -> Literal[None]: ... -PYI061.pyi:10:24: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:10:24 | 10 | def func3() -> Literal[None]: ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 7 7 | def func2(arg1: Literal[None] | int): ... @@ -52,12 +55,13 @@ PYI061.pyi:10:24: PYI061 [*] Use `None` rather than `Literal[None]` 12 12 | 13 13 | def func4(arg1: Literal[int, None, float]): ... -PYI061.pyi:13:30: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.pyi:13:30 | 13 | def func4(arg1: Literal[int, None, float]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 10 10 | def func3() -> Literal[None]: ... @@ -69,12 +73,13 @@ PYI061.pyi:13:30: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None 15 15 | 16 16 | def func5(arg1: Literal[None, None]): ... -PYI061.pyi:16:25: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:16:25 | 16 | def func5(arg1: Literal[None, None]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 13 13 | def func4(arg1: Literal[int, None, float]): ... @@ -86,12 +91,13 @@ PYI061.pyi:16:25: PYI061 [*] Use `None` rather than `Literal[None]` 18 18 | 19 19 | def func6(arg1: Literal[ -PYI061.pyi:16:31: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:16:31 | 16 | def func5(arg1: Literal[None, None]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 13 13 | def func4(arg1: Literal[int, None, float]): ... @@ -103,16 +109,17 @@ PYI061.pyi:16:31: PYI061 [*] Use `None` rather than `Literal[None]` 18 18 | 19 19 | def func6(arg1: Literal[ -PYI061.pyi:21:5: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.pyi:21:5 | 19 | def func6(arg1: Literal[ 20 | "hello", 21 | None # Comment 1 - | ^^^^ PYI061 + | ^^^^ 22 | , "world" 23 | ]): ... | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Unsafe fix 16 16 | def func5(arg1: Literal[None, None]): ... @@ -128,14 +135,15 @@ PYI061.pyi:21:5: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, 25 21 | 26 22 | def func7(arg1: Literal[ -PYI061.pyi:27:5: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:27:5 | 26 | def func7(arg1: Literal[ 27 | None # Comment 1 - | ^^^^ PYI061 + | ^^^^ 28 | ]): ... | - = help: Replace with `None` +help: Replace with `None` ℹ Unsafe fix 23 23 | ]): ... @@ -149,19 +157,21 @@ PYI061.pyi:27:5: PYI061 [*] Use `None` rather than `Literal[None]` 30 28 | 31 29 | def func8(arg1: Literal[None] | None):... -PYI061.pyi:31:25: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:31:25 | 31 | def func8(arg1: Literal[None] | None):... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:34:31: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:34:31 | 34 | def func9(arg1: Union[Literal[None], None]): ... - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 31 31 | def func8(arg1: Literal[None] | None):... @@ -173,14 +183,15 @@ PYI061.pyi:34:31: PYI061 [*] Use `None` rather than `Literal[None]` 36 36 | 37 37 | # OK -PYI061.pyi:42:9: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:42:9 | 41 | # From flake8-pyi 42 | Literal[None] # PYI061 None inside "Literal[]" expression. Replace with "None" - | ^^^^ PYI061 + | ^^^^ 43 | Literal[True, None] # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None" | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 39 39 | @@ -192,14 +203,15 @@ PYI061.pyi:42:9: PYI061 [*] Use `None` rather than `Literal[None]` 44 44 | 45 45 | -PYI061.pyi:43:15: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` +PYI061 [*] Use `Literal[...] | None` rather than `Literal[None, ...]` + --> PYI061.pyi:43:15 | 41 | # From flake8-pyi 42 | Literal[None] # PYI061 None inside "Literal[]" expression. Replace with "None" 43 | Literal[True, None] # PYI061 None inside "Literal[]" expression. Replace with "Literal[True] | None" - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `Literal[...] | None` +help: Replace with `Literal[...] | None` ℹ Safe fix 40 40 | @@ -211,36 +223,39 @@ PYI061.pyi:43:15: PYI061 [*] Use `Literal[...] | None` rather than `Literal[None 45 45 | 46 46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 -PYI061.pyi:47:12: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:47:12 | 46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 47 | x: Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 48 | y: None | Literal[None] 49 | z: Union[Literal[None], None] | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:48:19: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:48:19 | 46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 47 | x: Literal[None] | None 48 | y: None | Literal[None] - | ^^^^ PYI061 + | ^^^^ 49 | z: Union[Literal[None], None] | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:49:18: PYI061 [*] Use `None` rather than `Literal[None]` +PYI061 [*] Use `None` rather than `Literal[None]` + --> PYI061.pyi:49:18 | 47 | x: Literal[None] | None 48 | y: None | Literal[None] 49 | z: Union[Literal[None], None] - | ^^^^ PYI061 + | ^^^^ 50 | 51 | a: int | Literal[None] | None | - = help: Replace with `None` +help: Replace with `None` ℹ Safe fix 46 46 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 @@ -252,53 +267,58 @@ PYI061.pyi:49:18: PYI061 [*] Use `None` rather than `Literal[None]` 51 51 | a: int | Literal[None] | None 52 52 | b: None | Literal[None] | None -PYI061.pyi:51:18: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:51:18 | 49 | z: Union[Literal[None], None] 50 | 51 | a: int | Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 52 | b: None | Literal[None] | None 53 | c: (None | Literal[None]) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:52:19: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:52:19 | 51 | a: int | Literal[None] | None 52 | b: None | Literal[None] | None - | ^^^^ PYI061 + | ^^^^ 53 | c: (None | Literal[None]) | None 54 | d: None | (Literal[None] | None) | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:53:20: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:53:20 | 51 | a: int | Literal[None] | None 52 | b: None | Literal[None] | None 53 | c: (None | Literal[None]) | None - | ^^^^ PYI061 + | ^^^^ 54 | d: None | (Literal[None] | None) 55 | e: None | ((None | Literal[None]) | None) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:54:20: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:54:20 | 52 | b: None | Literal[None] | None 53 | c: (None | Literal[None]) | None 54 | d: None | (Literal[None] | None) - | ^^^^ PYI061 + | ^^^^ 55 | e: None | ((None | Literal[None]) | None) | None | - = help: Replace with `None` +help: Replace with `None` -PYI061.pyi:55:28: PYI061 Use `None` rather than `Literal[None]` +PYI061 Use `None` rather than `Literal[None]` + --> PYI061.pyi:55:28 | 53 | c: (None | Literal[None]) | None 54 | d: None | (Literal[None] | None) 55 | e: None | ((None | Literal[None]) | None) | None - | ^^^^ PYI061 + | ^^^^ | - = help: Replace with `None` +help: Replace with `None` diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap index 659e307c74..d362d1787e 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:14:1 | 14 | @pytest.fixture() - | ^^^^^^^^^^^^^^^^^ PT001 + | ^^^^^^^^^^^^^^^^^ 15 | def parentheses_no_params(): 16 | return 42 | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 11 11 | return 42 @@ -20,16 +21,17 @@ PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 16 16 | return 42 17 17 | -PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:24:1 | 24 | / @pytest.fixture( 25 | | 26 | | ) - | |_^ PT001 + | |_^ 27 | def parentheses_no_params_multiline(): 28 | return 42 | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 21 21 | return 42 @@ -43,14 +45,15 @@ PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 28 26 | return 42 29 27 | -PT001.py:39:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:39:1 | 39 | @fixture() - | ^^^^^^^^^^ PT001 + | ^^^^^^^^^^ 40 | def imported_from_parentheses_no_params(): 41 | return 42 | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 36 36 | return 42 @@ -62,16 +65,17 @@ PT001.py:39:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 41 41 | return 42 42 42 | -PT001.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:49:1 | 49 | / @fixture( 50 | | 51 | | ) - | |_^ PT001 + | |_^ 52 | def imported_from_parentheses_no_params_multiline(): 53 | return 42 | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 46 46 | return 42 @@ -85,14 +89,15 @@ PT001.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 53 51 | return 42 54 52 | -PT001.py:64:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:64:1 | 64 | @aliased() - | ^^^^^^^^^^ PT001 + | ^^^^^^^^^^ 65 | def aliased_parentheses_no_params(): 66 | return 42 | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 61 61 | return 42 @@ -104,16 +109,17 @@ PT001.py:64:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 66 66 | return 42 67 67 | -PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:74:1 | 74 | / @aliased( 75 | | 76 | | ) - | |_^ PT001 + | |_^ 77 | def aliased_parentheses_no_params_multiline(): 78 | return 42 | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 71 71 | return 42 @@ -127,17 +133,18 @@ PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 78 76 | return 42 79 77 | -PT001.py:81:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:81:1 | 80 | # https://github.com/astral-sh/ruff/issues/18770 81 | / @pytest.fixture( 82 | | # TODO: use module scope 83 | | # scope="module" 84 | | ) - | |_^ PT001 + | |_^ 85 | def my_fixture(): ... | - = help: Remove parentheses +help: Remove parentheses ℹ Unsafe fix 78 78 | return 42 @@ -152,14 +159,15 @@ PT001.py:81:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 86 83 | 87 84 | -PT001.py:88:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:88:1 | 88 | @(pytest.fixture()) - | ^^^^^^^^^^^^^^^^^^^ PT001 + | ^^^^^^^^^^^^^^^^^^^ 89 | def outer_paren_fixture_no_params(): 90 | return 42 | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 85 85 | def my_fixture(): ... @@ -171,14 +179,15 @@ PT001.py:88:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` 90 90 | return 42 91 91 | -PT001.py:93:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` +PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + --> PT001.py:93:1 | 93 | @(fixture()) - | ^^^^^^^^^^^^ PT001 + | ^^^^^^^^^^^^ 94 | def outer_paren_imported_fixture_no_params(): 95 | return 42 | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 90 90 | return 42 diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_parentheses.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_parentheses.snap index 31ad575ded..1ed682df4c 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_parentheses.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_parentheses.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT001.py:9:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` +PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` + --> PT001.py:9:1 | 9 | @pytest.fixture - | ^^^^^^^^^^^^^^^ PT001 + | ^^^^^^^^^^^^^^^ 10 | def no_parentheses(): 11 | return 42 | - = help: Add parentheses +help: Add parentheses ℹ Safe fix 6 6 | # `import pytest` @@ -21,14 +21,15 @@ PT001.py:9:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` 11 11 | return 42 12 12 | -PT001.py:34:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` +PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` + --> PT001.py:34:1 | 34 | @fixture - | ^^^^^^^^ PT001 + | ^^^^^^^^ 35 | def imported_from_no_parentheses(): 36 | return 42 | - = help: Add parentheses +help: Add parentheses ℹ Safe fix 31 31 | # `from pytest import fixture` @@ -40,14 +41,15 @@ PT001.py:34:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` 36 36 | return 42 37 37 | -PT001.py:59:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` +PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` + --> PT001.py:59:1 | 59 | @aliased - | ^^^^^^^^ PT001 + | ^^^^^^^^ 60 | def aliased_no_parentheses(): 61 | return 42 | - = help: Add parentheses +help: Add parentheses ℹ Safe fix 56 56 | # `from pytest import fixture as aliased` diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT002.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT002.snap index bde3e57c91..980a6f82ae 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT002.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT002.snap @@ -1,19 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT002.py:14:1: PT002 Configuration for fixture `my_fixture` specified via positional args, use kwargs +PT002 Configuration for fixture `my_fixture` specified via positional args, use kwargs + --> PT002.py:14:1 | 14 | @pytest.fixture("module") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | def my_fixture(): # Error only args 16 | return 0 | -PT002.py:19:1: PT002 Configuration for fixture `my_fixture` specified via positional args, use kwargs +PT002 Configuration for fixture `my_fixture` specified via positional args, use kwargs + --> PT002.py:19:1 | 19 | @pytest.fixture("module", autouse=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | def my_fixture(): # Error mixed 21 | return 0 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap index f57950bcd4..3ad32a399f 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT003.py:14:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` +PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + --> PT003.py:14:17 | 14 | @pytest.fixture(scope="function") - | ^^^^^^^^^^^^^^^^ PT003 + | ^^^^^^^^^^^^^^^^ 15 | def error(): 16 | ... | - = help: Remove implied `scope` argument +help: Remove implied `scope` argument ℹ Unsafe fix 11 11 | ... @@ -20,14 +21,15 @@ PT003.py:14:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` 16 16 | ... 17 17 | -PT003.py:19:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` +PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + --> PT003.py:19:17 | 19 | @pytest.fixture(scope="function", name="my_fixture") - | ^^^^^^^^^^^^^^^^ PT003 + | ^^^^^^^^^^^^^^^^ 20 | def error_multiple_args(): 21 | ... | - = help: Remove implied `scope` argument +help: Remove implied `scope` argument ℹ Unsafe fix 16 16 | ... @@ -39,14 +41,15 @@ PT003.py:19:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` 21 21 | ... 22 22 | -PT003.py:24:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` +PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + --> PT003.py:24:36 | 24 | @pytest.fixture(name="my_fixture", scope="function") - | ^^^^^^^^^^^^^^^^ PT003 + | ^^^^^^^^^^^^^^^^ 25 | def error_multiple_args(): 26 | ... | - = help: Remove implied `scope` argument +help: Remove implied `scope` argument ℹ Unsafe fix 21 21 | ... @@ -58,14 +61,15 @@ PT003.py:24:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` 26 26 | ... 27 27 | -PT003.py:29:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` +PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + --> PT003.py:29:36 | 29 | @pytest.fixture(name="my_fixture", scope="function", **kwargs) - | ^^^^^^^^^^^^^^^^ PT003 + | ^^^^^^^^^^^^^^^^ 30 | def error_second_arg(): 31 | ... | - = help: Remove implied `scope` argument +help: Remove implied `scope` argument ℹ Unsafe fix 26 26 | ... @@ -77,16 +81,17 @@ PT003.py:29:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` 31 31 | ... 32 32 | -PT003.py:37:31: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` +PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + --> PT003.py:37:31 | 35 | # tests the general case as we use a helper function that should 36 | # work for all cases. 37 | @pytest.fixture("my_fixture", scope="function") - | ^^^^^^^^^^^^^^^^ PT003 + | ^^^^^^^^^^^^^^^^ 38 | def error_arg(): 39 | ... | - = help: Remove implied `scope` argument +help: Remove implied `scope` argument ℹ Unsafe fix 34 34 | # pytest.fixture does not take positional arguments, however this @@ -98,15 +103,16 @@ PT003.py:37:31: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` 39 39 | ... 40 40 | -PT003.py:43:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` +PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + --> PT003.py:43:5 | 42 | @pytest.fixture( 43 | scope="function", - | ^^^^^^^^^^^^^^^^ PT003 + | ^^^^^^^^^^^^^^^^ 44 | name="my_fixture", 45 | ) | - = help: Remove implied `scope` argument +help: Remove implied `scope` argument ℹ Unsafe fix 40 40 | @@ -117,16 +123,17 @@ PT003.py:43:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` 45 44 | ) 46 45 | def error_multiple_args(): -PT003.py:52:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` +PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + --> PT003.py:52:5 | 50 | @pytest.fixture( 51 | name="my_fixture", 52 | scope="function", - | ^^^^^^^^^^^^^^^^ PT003 + | ^^^^^^^^^^^^^^^^ 53 | ) 54 | def error_multiple_args(): | - = help: Remove implied `scope` argument +help: Remove implied `scope` argument ℹ Unsafe fix 49 49 | @@ -137,16 +144,17 @@ PT003.py:52:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` 54 53 | def error_multiple_args(): 55 54 | ... -PT003.py:66:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` +PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + --> PT003.py:66:5 | 64 | # another comment ,) 65 | 66 | / scope=\ 67 | | "function" # some comment ), - | |__________________^ PT003 + | |__________________^ 68 | , | - = help: Remove implied `scope` argument +help: Remove implied `scope` argument ℹ Unsafe fix 63 63 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_and_PT007.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_and_PT007.snap index 53fcf3c33a..f8419f3b59 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_and_PT007.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_and_PT007.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT006_and_PT007.py:3:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006_and_PT007.py:3:26 | 1 | import pytest 2 | 3 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 4 | def test_PT006_and_PT007_do_not_conflict(param): 5 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 1 1 | import pytest @@ -20,16 +21,17 @@ PT006_and_PT007.py:3:26: PT006 [*] Wrong type passed to first argument of `pytes 4 4 | def test_PT006_and_PT007_do_not_conflict(param): 5 5 | ... -PT006_and_PT007.py:3:39: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT006_and_PT007.py:3:39 | 1 | import pytest 2 | 3 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^ PT007 + | ^^^ 4 | def test_PT006_and_PT007_do_not_conflict(param): 5 | ... | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 1 1 | import pytest @@ -39,16 +41,17 @@ PT006_and_PT007.py:3:39: PT007 [*] Wrong values type in `pytest.mark.parametrize 4 4 | def test_PT006_and_PT007_do_not_conflict(param): 5 5 | ... -PT006_and_PT007.py:3:44: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT006_and_PT007.py:3:44 | 1 | import pytest 2 | 3 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^ PT007 + | ^^^ 4 | def test_PT006_and_PT007_do_not_conflict(param): 5 | ... | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 1 1 | import pytest diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap index 1d00aa1453..def0e46f71 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values + --> PT006.py:24:26 | 24 | @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^ 25 | def test_tuple(param1, param2): 26 | ... | - = help: Use a string of comma-separated values for the first argument +help: Use a string of comma-separated values for the first argument ℹ Unsafe fix 21 21 | ... @@ -20,14 +21,15 @@ PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 26 26 | ... 27 27 | -PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:29:26 | 29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) - | ^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^ 30 | def test_tuple_one_elem(param1, param2): 31 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 26 26 | ... @@ -39,14 +41,15 @@ PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 31 31 | ... 32 32 | -PT006.py:34:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values + --> PT006.py:34:26 | 34 | @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^ 35 | def test_list(param1, param2): 36 | ... | - = help: Use a string of comma-separated values for the first argument +help: Use a string of comma-separated values for the first argument ℹ Unsafe fix 31 31 | ... @@ -58,14 +61,15 @@ PT006.py:34:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 36 36 | ... 37 37 | -PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:39:26 | 39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 40 | def test_list_one_elem(param1, param2): 41 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 36 36 | ... @@ -77,32 +81,35 @@ PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 41 41 | ... 42 42 | -PT006.py:44:26: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values +PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values + --> PT006.py:44:26 | 44 | @pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | def test_list_expressions(param1, param2): 46 | ... | - = help: Use a string of comma-separated values for the first argument +help: Use a string of comma-separated values for the first argument -PT006.py:49:26: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values +PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected a string of comma-separated values + --> PT006.py:49:26 | 49 | @pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^ 50 | def test_list_mixed_expr_literal(param1, param2): 51 | ... | - = help: Use a string of comma-separated values for the first argument +help: Use a string of comma-separated values for the first argument -PT006.py:86:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:86:26 | 86 | @pytest.mark.parametrize(("param",), [(1,), (2,)]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 87 | def test_single_element_tuple(param): 88 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 83 83 | ... @@ -114,14 +121,15 @@ PT006.py:86:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 88 88 | ... 89 89 | -PT006.py:91:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:91:26 | 91 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 92 | def test_single_element_list(param): 93 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 88 88 | ... @@ -133,14 +141,15 @@ PT006.py:91:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 93 93 | ... 94 94 | -PT006.py:96:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:96:26 | 96 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 97 | def test_single_element_list(param): 98 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 93 93 | ... @@ -152,7 +161,8 @@ PT006.py:96:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 98 98 | ... 99 99 | -PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:103:5 | 101 | # Unsafe fix 102 | @pytest.mark.parametrize( @@ -160,11 +170,11 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 104 | | # comment 105 | | "param", 106 | | ), - | |_____^ PT006 + | |_____^ 107 | [[1], [2]], 108 | ) | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Unsafe fix 100 100 | @@ -181,16 +191,17 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 109 106 | def test_comment_in_argnames(param): 110 107 | ... -PT006.py:114:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:114:5 | 112 | # Unsafe fix 113 | @pytest.mark.parametrize( 114 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 115 | [ 116 | ( | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Unsafe fix 111 111 | @@ -210,16 +221,17 @@ PT006.py:114:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 122 119 | ) 123 120 | def test_comment_in_argvalues(param): -PT006.py:129:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:129:5 | 127 | # Safe fix 128 | @pytest.mark.parametrize( 129 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 130 | [ 131 | (1,), | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 126 126 | @@ -237,16 +249,17 @@ PT006.py:129:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 135 135 | ) 136 136 | def test_comment_between_argvalues_items(param): -PT006.py:142:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:142:5 | 140 | # A fix should be suggested for `argnames`, but not for `argvalues`. 141 | @pytest.mark.parametrize( 142 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 143 | [ 144 | (1,), | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 139 139 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap index 78a833a98c..c444562708 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:9:26 | 9 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^ 10 | def test_csv(param1, param2): 11 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 6 6 | ... @@ -20,14 +21,15 @@ PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.par 11 11 | ... 12 12 | -PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:14:26 | 14 | @pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | def test_csv_with_whitespace(param1, param2): 16 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 11 11 | ... @@ -39,14 +41,15 @@ PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 16 16 | ... 17 17 | -PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:19:26 | 19 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^ 20 | def test_csv_bad_quotes(param1, param2): 21 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 16 16 | ... @@ -58,14 +61,15 @@ PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 21 21 | ... 22 22 | -PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:29:26 | 29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) - | ^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^ 30 | def test_tuple_one_elem(param1, param2): 31 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 26 26 | ... @@ -77,14 +81,15 @@ PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 31 31 | ... 32 32 | -PT006.py:34:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:34:26 | 34 | @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^ 35 | def test_list(param1, param2): 36 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 31 31 | ... @@ -96,14 +101,15 @@ PT006.py:34:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 36 36 | ... 37 37 | -PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:39:26 | 39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 40 | def test_list_one_elem(param1, param2): 41 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 36 36 | ... @@ -115,14 +121,15 @@ PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 41 41 | ... 42 42 | -PT006.py:44:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:44:26 | 44 | @pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | def test_list_expressions(param1, param2): 46 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 41 41 | ... @@ -134,14 +141,15 @@ PT006.py:44:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 46 46 | ... 47 47 | -PT006.py:49:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:49:26 | 49 | @pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^ 50 | def test_list_mixed_expr_literal(param1, param2): 51 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 46 46 | ... @@ -153,14 +161,15 @@ PT006.py:49:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 51 51 | ... 52 52 | -PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:54:26 | 54 | @pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | def test_implicit_str_concat_with_parens(param1, param2, param3): 56 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 51 51 | ... @@ -172,14 +181,15 @@ PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 56 56 | ... 57 57 | -PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:59:26 | 59 | @pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | def test_implicit_str_concat_no_parens(param1, param2, param3): 61 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 56 56 | ... @@ -191,14 +201,15 @@ PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 61 61 | ... 62 62 | -PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:64:26 | 64 | @pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): 66 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 61 61 | ... @@ -210,14 +221,15 @@ PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 66 66 | ... 67 67 | -PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:69:26 | 69 | @pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^ 70 | def test_csv_with_parens(param1, param2): 71 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 66 66 | ... @@ -229,14 +241,15 @@ PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 71 71 | ... 72 72 | -PT006.py:74:39: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:74:39 | 74 | parametrize = pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^ 75 | 76 | @parametrize | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 71 71 | ... @@ -248,14 +261,15 @@ PT006.py:74:39: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 76 76 | @parametrize 77 77 | def test_not_decorator(param1, param2): -PT006.py:81:35: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple` + --> PT006.py:81:35 | 81 | @pytest.mark.parametrize(argnames=("param1,param2"), argvalues=[(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^ 82 | def test_keyword_arguments(param1, param2): 83 | ... | - = help: Use a `tuple` for the first argument +help: Use a `tuple` for the first argument ℹ Unsafe fix 78 78 | ... @@ -267,14 +281,15 @@ PT006.py:81:35: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 83 83 | ... 84 84 | -PT006.py:86:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:86:26 | 86 | @pytest.mark.parametrize(("param",), [(1,), (2,)]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 87 | def test_single_element_tuple(param): 88 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 83 83 | ... @@ -286,14 +301,15 @@ PT006.py:86:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 88 88 | ... 89 89 | -PT006.py:91:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:91:26 | 91 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 92 | def test_single_element_list(param): 93 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 88 88 | ... @@ -305,14 +321,15 @@ PT006.py:91:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 93 93 | ... 94 94 | -PT006.py:96:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:96:26 | 96 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 97 | def test_single_element_list(param): 98 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 93 93 | ... @@ -324,7 +341,8 @@ PT006.py:96:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 98 98 | ... 99 99 | -PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:103:5 | 101 | # Unsafe fix 102 | @pytest.mark.parametrize( @@ -332,11 +350,11 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 104 | | # comment 105 | | "param", 106 | | ), - | |_____^ PT006 + | |_____^ 107 | [[1], [2]], 108 | ) | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Unsafe fix 100 100 | @@ -353,16 +371,17 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 109 106 | def test_comment_in_argnames(param): 110 107 | ... -PT006.py:114:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:114:5 | 112 | # Unsafe fix 113 | @pytest.mark.parametrize( 114 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 115 | [ 116 | ( | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Unsafe fix 111 111 | @@ -382,16 +401,17 @@ PT006.py:114:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 122 119 | ) 123 120 | def test_comment_in_argvalues(param): -PT006.py:129:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:129:5 | 127 | # Safe fix 128 | @pytest.mark.parametrize( 129 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 130 | [ 131 | (1,), | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 126 126 | @@ -409,16 +429,17 @@ PT006.py:129:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 135 135 | ) 136 136 | def test_comment_between_argvalues_items(param): -PT006.py:142:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:142:5 | 140 | # A fix should be suggested for `argnames`, but not for `argvalues`. 141 | @pytest.mark.parametrize( 142 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 143 | [ 144 | (1,), | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 139 139 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap index affd3540c9..9ff3aaeb43 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:9:26 | 9 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^ 10 | def test_csv(param1, param2): 11 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 6 6 | ... @@ -20,14 +21,15 @@ PT006.py:9:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.par 11 11 | ... 12 12 | -PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:14:26 | 14 | @pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | def test_csv_with_whitespace(param1, param2): 16 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 11 11 | ... @@ -39,14 +41,15 @@ PT006.py:14:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 16 16 | ... 17 17 | -PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:19:26 | 19 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^ 20 | def test_csv_bad_quotes(param1, param2): 21 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 16 16 | ... @@ -58,14 +61,15 @@ PT006.py:19:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 21 21 | ... 22 22 | -PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:24:26 | 24 | @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^ 25 | def test_tuple(param1, param2): 26 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 21 21 | ... @@ -77,14 +81,15 @@ PT006.py:24:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 26 26 | ... 27 27 | -PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:29:26 | 29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) - | ^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^ 30 | def test_tuple_one_elem(param1, param2): 31 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 26 26 | ... @@ -96,14 +101,15 @@ PT006.py:29:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 31 31 | ... 32 32 | -PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:39:26 | 39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 40 | def test_list_one_elem(param1, param2): 41 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 36 36 | ... @@ -115,14 +121,15 @@ PT006.py:39:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 41 41 | ... 42 42 | -PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:54:26 | 54 | @pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | def test_implicit_str_concat_with_parens(param1, param2, param3): 56 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 51 51 | ... @@ -134,14 +141,15 @@ PT006.py:54:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 56 56 | ... 57 57 | -PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:59:26 | 59 | @pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | def test_implicit_str_concat_no_parens(param1, param2, param3): 61 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 56 56 | ... @@ -153,14 +161,15 @@ PT006.py:59:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 61 61 | ... 62 62 | -PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:64:26 | 64 | @pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): 66 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 61 61 | ... @@ -172,14 +181,15 @@ PT006.py:64:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 66 66 | ... 67 67 | -PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:69:26 | 69 | @pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^ 70 | def test_csv_with_parens(param1, param2): 71 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 66 66 | ... @@ -191,14 +201,15 @@ PT006.py:69:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 71 71 | ... 72 72 | -PT006.py:74:39: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:74:39 | 74 | parametrize = pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^ 75 | 76 | @parametrize | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 71 71 | ... @@ -210,14 +221,15 @@ PT006.py:74:39: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 76 76 | @parametrize 77 77 | def test_not_decorator(param1, param2): -PT006.py:81:35: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `list` + --> PT006.py:81:35 | 81 | @pytest.mark.parametrize(argnames=("param1,param2"), argvalues=[(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^ PT006 + | ^^^^^^^^^^^^^^^^^ 82 | def test_keyword_arguments(param1, param2): 83 | ... | - = help: Use a `list` for the first argument +help: Use a `list` for the first argument ℹ Unsafe fix 78 78 | ... @@ -229,14 +241,15 @@ PT006.py:81:35: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 83 83 | ... 84 84 | -PT006.py:86:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:86:26 | 86 | @pytest.mark.parametrize(("param",), [(1,), (2,)]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 87 | def test_single_element_tuple(param): 88 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 83 83 | ... @@ -248,14 +261,15 @@ PT006.py:86:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 88 88 | ... 89 89 | -PT006.py:91:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:91:26 | 91 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 92 | def test_single_element_list(param): 93 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 88 88 | ... @@ -267,14 +281,15 @@ PT006.py:91:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 93 93 | ... 94 94 | -PT006.py:96:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:96:26 | 96 | @pytest.mark.parametrize(("param",), [[1], [2]]) - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 97 | def test_single_element_list(param): 98 | ... | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 93 93 | ... @@ -286,7 +301,8 @@ PT006.py:96:26: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 98 98 | ... 99 99 | -PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:103:5 | 101 | # Unsafe fix 102 | @pytest.mark.parametrize( @@ -294,11 +310,11 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 104 | | # comment 105 | | "param", 106 | | ), - | |_____^ PT006 + | |_____^ 107 | [[1], [2]], 108 | ) | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Unsafe fix 100 100 | @@ -315,16 +331,17 @@ PT006.py:103:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 109 106 | def test_comment_in_argnames(param): 110 107 | ... -PT006.py:114:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:114:5 | 112 | # Unsafe fix 113 | @pytest.mark.parametrize( 114 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 115 | [ 116 | ( | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Unsafe fix 111 111 | @@ -344,16 +361,17 @@ PT006.py:114:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 122 119 | ) 123 120 | def test_comment_in_argvalues(param): -PT006.py:129:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:129:5 | 127 | # Safe fix 128 | @pytest.mark.parametrize( 129 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 130 | [ 131 | (1,), | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 126 126 | @@ -371,16 +389,17 @@ PT006.py:129:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.pa 135 135 | ) 136 136 | def test_comment_between_argvalues_items(param): -PT006.py:142:5: PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` +PT006 [*] Wrong type passed to first argument of `pytest.mark.parametrize`; expected `str` + --> PT006.py:142:5 | 140 | # A fix should be suggested for `argnames`, but not for `argvalues`. 141 | @pytest.mark.parametrize( 142 | ("param",), - | ^^^^^^^^^^ PT006 + | ^^^^^^^^^^ 143 | [ 144 | (1,), | - = help: Use a string for the first argument +help: Use a string for the first argument ℹ Safe fix 139 139 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap index f3b1a2bb66..41e4434970 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT007.py:4:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:4:35 | 4 | @pytest.mark.parametrize("param", (1, 2)) - | ^^^^^^ PT007 + | ^^^^^^ 5 | def test_tuple(param): 6 | ... | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 1 1 | import pytest @@ -20,7 +21,8 @@ PT007.py:4:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 6 6 | ... 7 7 | -PT007.py:11:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:11:5 | 9 | @pytest.mark.parametrize( 10 | ("param1", "param2"), @@ -28,11 +30,11 @@ PT007.py:11:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 12 | | (1, 2), 13 | | (3, 4), 14 | | ), - | |_____^ PT007 + | |_____^ 15 | ) 16 | def test_tuple_of_tuples(param1, param2): | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 8 8 | @@ -48,16 +50,17 @@ PT007.py:11:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 16 16 | def test_tuple_of_tuples(param1, param2): 17 17 | ... -PT007.py:12:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:12:9 | 10 | ("param1", "param2"), 11 | ( 12 | (1, 2), - | ^^^^^^ PT007 + | ^^^^^^ 13 | (3, 4), 14 | ), | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 9 9 | @pytest.mark.parametrize( @@ -69,16 +72,17 @@ PT007.py:12:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 14 14 | ), 15 15 | ) -PT007.py:13:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:13:9 | 11 | ( 12 | (1, 2), 13 | (3, 4), - | ^^^^^^ PT007 + | ^^^^^^ 14 | ), 15 | ) | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 10 10 | ("param1", "param2"), @@ -90,7 +94,8 @@ PT007.py:13:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 15 15 | ) 16 16 | def test_tuple_of_tuples(param1, param2): -PT007.py:22:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:22:5 | 20 | @pytest.mark.parametrize( 21 | ("param1", "param2"), @@ -98,11 +103,11 @@ PT007.py:22:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 23 | | [1, 2], 24 | | [3, 4], 25 | | ), - | |_____^ PT007 + | |_____^ 26 | ) 27 | def test_tuple_of_lists(param1, param2): | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 19 19 | @@ -118,16 +123,17 @@ PT007.py:22:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 27 27 | def test_tuple_of_lists(param1, param2): 28 28 | ... -PT007.py:39:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:39:9 | 37 | ("param1", "param2"), 38 | [ 39 | (1, 2), - | ^^^^^^ PT007 + | ^^^^^^ 40 | (3, 4), 41 | ], | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 36 36 | @pytest.mark.parametrize( @@ -139,16 +145,17 @@ PT007.py:39:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 41 41 | ], 42 42 | ) -PT007.py:40:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:40:9 | 38 | [ 39 | (1, 2), 40 | (3, 4), - | ^^^^^^ PT007 + | ^^^^^^ 41 | ], 42 | ) | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 37 37 | ("param1", "param2"), @@ -160,15 +167,16 @@ PT007.py:40:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 42 42 | ) 43 43 | def test_list_of_tuples(param1, param2): -PT007.py:81:38: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:81:38 | 80 | @pytest.mark.parametrize("a", [1, 2]) 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^^^^^^^^^^^ PT007 + | ^^^^^^^^^^^^^^^^ 82 | @pytest.mark.parametrize("d", [3,]) 83 | @pytest.mark.parametrize( | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 78 78 | @@ -180,15 +188,16 @@ PT007.py:81:38: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 83 83 | @pytest.mark.parametrize( 84 84 | "d", -PT007.py:81:39: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:81:39 | 80 | @pytest.mark.parametrize("a", [1, 2]) 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^ PT007 + | ^^^^^^ 82 | @pytest.mark.parametrize("d", [3,]) 83 | @pytest.mark.parametrize( | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 78 78 | @@ -200,15 +209,16 @@ PT007.py:81:39: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 83 83 | @pytest.mark.parametrize( 84 84 | "d", -PT007.py:81:47: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `list` + --> PT007.py:81:47 | 80 | @pytest.mark.parametrize("a", [1, 2]) 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^ PT007 + | ^^^^^^ 82 | @pytest.mark.parametrize("d", [3,]) 83 | @pytest.mark.parametrize( | - = help: Use `list` of `list` for parameter values +help: Use `list` of `list` for parameter values ℹ Unsafe fix 78 78 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap index c3bb7dde90..1791c79d03 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT007.py:4:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:4:35 | 4 | @pytest.mark.parametrize("param", (1, 2)) - | ^^^^^^ PT007 + | ^^^^^^ 5 | def test_tuple(param): 6 | ... | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 1 1 | import pytest @@ -20,7 +21,8 @@ PT007.py:4:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 6 6 | ... 7 7 | -PT007.py:11:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:11:5 | 9 | @pytest.mark.parametrize( 10 | ("param1", "param2"), @@ -28,11 +30,11 @@ PT007.py:11:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 12 | | (1, 2), 13 | | (3, 4), 14 | | ), - | |_____^ PT007 + | |_____^ 15 | ) 16 | def test_tuple_of_tuples(param1, param2): | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 8 8 | @@ -48,7 +50,8 @@ PT007.py:11:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 16 16 | def test_tuple_of_tuples(param1, param2): 17 17 | ... -PT007.py:22:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:22:5 | 20 | @pytest.mark.parametrize( 21 | ("param1", "param2"), @@ -56,11 +59,11 @@ PT007.py:22:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 23 | | [1, 2], 24 | | [3, 4], 25 | | ), - | |_____^ PT007 + | |_____^ 26 | ) 27 | def test_tuple_of_lists(param1, param2): | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 19 19 | @@ -76,16 +79,17 @@ PT007.py:22:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 27 27 | def test_tuple_of_lists(param1, param2): 28 28 | ... -PT007.py:23:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:23:9 | 21 | ("param1", "param2"), 22 | ( 23 | [1, 2], - | ^^^^^^ PT007 + | ^^^^^^ 24 | [3, 4], 25 | ), | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 20 20 | @pytest.mark.parametrize( @@ -97,16 +101,17 @@ PT007.py:23:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 25 25 | ), 26 26 | ) -PT007.py:24:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:24:9 | 22 | ( 23 | [1, 2], 24 | [3, 4], - | ^^^^^^ PT007 + | ^^^^^^ 25 | ), 26 | ) | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 21 21 | ("param1", "param2"), @@ -118,16 +123,17 @@ PT007.py:24:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 26 26 | ) 27 27 | def test_tuple_of_lists(param1, param2): -PT007.py:50:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:50:9 | 48 | ("param1", "param2"), 49 | [ 50 | [1, 2], - | ^^^^^^ PT007 + | ^^^^^^ 51 | [3, 4], 52 | ], | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 47 47 | @pytest.mark.parametrize( @@ -139,16 +145,17 @@ PT007.py:50:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 52 52 | ], 53 53 | ) -PT007.py:51:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:51:9 | 49 | [ 50 | [1, 2], 51 | [3, 4], - | ^^^^^^ PT007 + | ^^^^^^ 52 | ], 53 | ) | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 48 48 | ("param1", "param2"), @@ -160,16 +167,17 @@ PT007.py:51:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 53 53 | ) 54 54 | def test_list_of_lists(param1, param2): -PT007.py:61:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:61:9 | 59 | "param1,param2", 60 | [ 61 | [1, 2], - | ^^^^^^ PT007 + | ^^^^^^ 62 | [3, 4], 63 | ], | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 58 58 | @pytest.mark.parametrize( @@ -181,16 +189,17 @@ PT007.py:61:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 63 63 | ], 64 64 | ) -PT007.py:62:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:62:9 | 60 | [ 61 | [1, 2], 62 | [3, 4], - | ^^^^^^ PT007 + | ^^^^^^ 63 | ], 64 | ) | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 59 59 | "param1,param2", @@ -202,15 +211,16 @@ PT007.py:62:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 64 64 | ) 65 65 | def test_csv_name_list_of_lists(param1, param2): -PT007.py:81:38: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `list` of `tuple` + --> PT007.py:81:38 | 80 | @pytest.mark.parametrize("a", [1, 2]) 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^^^^^^^^^^^ PT007 + | ^^^^^^^^^^^^^^^^ 82 | @pytest.mark.parametrize("d", [3,]) 83 | @pytest.mark.parametrize( | - = help: Use `list` of `tuple` for parameter values +help: Use `list` of `tuple` for parameter values ℹ Unsafe fix 78 78 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap index 48e4d90b11..9e6b515935 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT007.py:12:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:12:9 | 10 | ("param1", "param2"), 11 | ( 12 | (1, 2), - | ^^^^^^ PT007 + | ^^^^^^ 13 | (3, 4), 14 | ), | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 9 9 | @pytest.mark.parametrize( @@ -22,16 +23,17 @@ PT007.py:12:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 14 14 | ), 15 15 | ) -PT007.py:13:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:13:9 | 11 | ( 12 | (1, 2), 13 | (3, 4), - | ^^^^^^ PT007 + | ^^^^^^ 14 | ), 15 | ) | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 10 10 | ("param1", "param2"), @@ -43,14 +45,15 @@ PT007.py:13:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 15 15 | ) 16 16 | def test_tuple_of_tuples(param1, param2): -PT007.py:31:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:31:35 | 31 | @pytest.mark.parametrize("param", [1, 2]) - | ^^^^^^ PT007 + | ^^^^^^ 32 | def test_list(param): 33 | ... | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 28 28 | ... @@ -62,7 +65,8 @@ PT007.py:31:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 33 33 | ... 34 34 | -PT007.py:38:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:38:5 | 36 | @pytest.mark.parametrize( 37 | ("param1", "param2"), @@ -70,11 +74,11 @@ PT007.py:38:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 39 | | (1, 2), 40 | | (3, 4), 41 | | ], - | |_____^ PT007 + | |_____^ 42 | ) 43 | def test_list_of_tuples(param1, param2): | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 35 35 | @@ -90,16 +94,17 @@ PT007.py:38:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 43 43 | def test_list_of_tuples(param1, param2): 44 44 | ... -PT007.py:39:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:39:9 | 37 | ("param1", "param2"), 38 | [ 39 | (1, 2), - | ^^^^^^ PT007 + | ^^^^^^ 40 | (3, 4), 41 | ], | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 36 36 | @pytest.mark.parametrize( @@ -111,16 +116,17 @@ PT007.py:39:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 41 41 | ], 42 42 | ) -PT007.py:40:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:40:9 | 38 | [ 39 | (1, 2), 40 | (3, 4), - | ^^^^^^ PT007 + | ^^^^^^ 41 | ], 42 | ) | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 37 37 | ("param1", "param2"), @@ -132,7 +138,8 @@ PT007.py:40:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 42 42 | ) 43 43 | def test_list_of_tuples(param1, param2): -PT007.py:49:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:49:5 | 47 | @pytest.mark.parametrize( 48 | ("param1", "param2"), @@ -140,11 +147,11 @@ PT007.py:49:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 50 | | [1, 2], 51 | | [3, 4], 52 | | ], - | |_____^ PT007 + | |_____^ 53 | ) 54 | def test_list_of_lists(param1, param2): | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 46 46 | @@ -160,7 +167,8 @@ PT007.py:49:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 54 54 | def test_list_of_lists(param1, param2): 55 55 | ... -PT007.py:60:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:60:5 | 58 | @pytest.mark.parametrize( 59 | "param1,param2", @@ -168,11 +176,11 @@ PT007.py:60:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 61 | | [1, 2], 62 | | [3, 4], 63 | | ], - | |_____^ PT007 + | |_____^ 64 | ) 65 | def test_csv_name_list_of_lists(param1, param2): | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 57 57 | @@ -188,7 +196,8 @@ PT007.py:60:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 65 65 | def test_csv_name_list_of_lists(param1, param2): 66 66 | ... -PT007.py:71:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:71:5 | 69 | @pytest.mark.parametrize( 70 | "param", @@ -196,11 +205,11 @@ PT007.py:71:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 72 | | [1, 2], 73 | | [3, 4], 74 | | ], - | |_____^ PT007 + | |_____^ 75 | ) 76 | def test_single_list_of_lists(param): | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 68 68 | @@ -216,14 +225,15 @@ PT007.py:71:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 76 76 | def test_single_list_of_lists(param): 77 77 | ... -PT007.py:80:31: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:80:31 | 80 | @pytest.mark.parametrize("a", [1, 2]) - | ^^^^^^ PT007 + | ^^^^^^ 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) 82 | @pytest.mark.parametrize("d", [3,]) | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 77 77 | ... @@ -235,15 +245,16 @@ PT007.py:80:31: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 82 82 | @pytest.mark.parametrize("d", [3,]) 83 83 | @pytest.mark.parametrize( -PT007.py:81:39: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:81:39 | 80 | @pytest.mark.parametrize("a", [1, 2]) 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^ PT007 + | ^^^^^^ 82 | @pytest.mark.parametrize("d", [3,]) 83 | @pytest.mark.parametrize( | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 78 78 | @@ -255,15 +266,16 @@ PT007.py:81:39: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 83 83 | @pytest.mark.parametrize( 84 84 | "d", -PT007.py:81:47: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:81:47 | 80 | @pytest.mark.parametrize("a", [1, 2]) 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^ PT007 + | ^^^^^^ 82 | @pytest.mark.parametrize("d", [3,]) 83 | @pytest.mark.parametrize( | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 78 78 | @@ -275,16 +287,17 @@ PT007.py:81:47: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 83 83 | @pytest.mark.parametrize( 84 84 | "d", -PT007.py:82:31: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:82:31 | 80 | @pytest.mark.parametrize("a", [1, 2]) 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) 82 | @pytest.mark.parametrize("d", [3,]) - | ^^^^ PT007 + | ^^^^ 83 | @pytest.mark.parametrize( 84 | "d", | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 79 79 | @@ -296,16 +309,17 @@ PT007.py:82:31: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 84 84 | "d", 85 85 | [("3", "4")], -PT007.py:85:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:85:5 | 83 | @pytest.mark.parametrize( 84 | "d", 85 | [("3", "4")], - | ^^^^^^^^^^^^ PT007 + | ^^^^^^^^^^^^ 86 | ) 87 | @pytest.mark.parametrize( | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 82 82 | @pytest.mark.parametrize("d", [3,]) @@ -317,16 +331,17 @@ PT007.py:85:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 87 87 | @pytest.mark.parametrize( 88 88 | "e", -PT007.py:89:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `list` + --> PT007.py:89:5 | 87 | @pytest.mark.parametrize( 88 | "e", 89 | [("3", "4"),], - | ^^^^^^^^^^^^^ PT007 + | ^^^^^^^^^^^^^ 90 | ) 91 | def test_multiple_decorators(a, b, c, d, e): | - = help: Use `tuple` of `list` for parameter values +help: Use `tuple` of `list` for parameter values ℹ Unsafe fix 86 86 | ) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap index 822c8869ec..fda908e395 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT007.py:23:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:23:9 | 21 | ("param1", "param2"), 22 | ( 23 | [1, 2], - | ^^^^^^ PT007 + | ^^^^^^ 24 | [3, 4], 25 | ), | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 20 20 | @pytest.mark.parametrize( @@ -22,16 +23,17 @@ PT007.py:23:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 25 25 | ), 26 26 | ) -PT007.py:24:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:24:9 | 22 | ( 23 | [1, 2], 24 | [3, 4], - | ^^^^^^ PT007 + | ^^^^^^ 25 | ), 26 | ) | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 21 21 | ("param1", "param2"), @@ -43,14 +45,15 @@ PT007.py:24:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 26 26 | ) 27 27 | def test_tuple_of_lists(param1, param2): -PT007.py:31:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:31:35 | 31 | @pytest.mark.parametrize("param", [1, 2]) - | ^^^^^^ PT007 + | ^^^^^^ 32 | def test_list(param): 33 | ... | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 28 28 | ... @@ -62,7 +65,8 @@ PT007.py:31:35: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 33 33 | ... 34 34 | -PT007.py:38:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:38:5 | 36 | @pytest.mark.parametrize( 37 | ("param1", "param2"), @@ -70,11 +74,11 @@ PT007.py:38:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 39 | | (1, 2), 40 | | (3, 4), 41 | | ], - | |_____^ PT007 + | |_____^ 42 | ) 43 | def test_list_of_tuples(param1, param2): | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 35 35 | @@ -90,7 +94,8 @@ PT007.py:38:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 43 43 | def test_list_of_tuples(param1, param2): 44 44 | ... -PT007.py:49:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:49:5 | 47 | @pytest.mark.parametrize( 48 | ("param1", "param2"), @@ -98,11 +103,11 @@ PT007.py:49:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 50 | | [1, 2], 51 | | [3, 4], 52 | | ], - | |_____^ PT007 + | |_____^ 53 | ) 54 | def test_list_of_lists(param1, param2): | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 46 46 | @@ -118,16 +123,17 @@ PT007.py:49:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 54 54 | def test_list_of_lists(param1, param2): 55 55 | ... -PT007.py:50:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:50:9 | 48 | ("param1", "param2"), 49 | [ 50 | [1, 2], - | ^^^^^^ PT007 + | ^^^^^^ 51 | [3, 4], 52 | ], | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 47 47 | @pytest.mark.parametrize( @@ -139,16 +145,17 @@ PT007.py:50:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 52 52 | ], 53 53 | ) -PT007.py:51:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:51:9 | 49 | [ 50 | [1, 2], 51 | [3, 4], - | ^^^^^^ PT007 + | ^^^^^^ 52 | ], 53 | ) | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 48 48 | ("param1", "param2"), @@ -160,7 +167,8 @@ PT007.py:51:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 53 53 | ) 54 54 | def test_list_of_lists(param1, param2): -PT007.py:60:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:60:5 | 58 | @pytest.mark.parametrize( 59 | "param1,param2", @@ -168,11 +176,11 @@ PT007.py:60:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 61 | | [1, 2], 62 | | [3, 4], 63 | | ], - | |_____^ PT007 + | |_____^ 64 | ) 65 | def test_csv_name_list_of_lists(param1, param2): | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 57 57 | @@ -188,16 +196,17 @@ PT007.py:60:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 65 65 | def test_csv_name_list_of_lists(param1, param2): 66 66 | ... -PT007.py:61:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:61:9 | 59 | "param1,param2", 60 | [ 61 | [1, 2], - | ^^^^^^ PT007 + | ^^^^^^ 62 | [3, 4], 63 | ], | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 58 58 | @pytest.mark.parametrize( @@ -209,16 +218,17 @@ PT007.py:61:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 63 63 | ], 64 64 | ) -PT007.py:62:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:62:9 | 60 | [ 61 | [1, 2], 62 | [3, 4], - | ^^^^^^ PT007 + | ^^^^^^ 63 | ], 64 | ) | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 59 59 | "param1,param2", @@ -230,7 +240,8 @@ PT007.py:62:9: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 64 64 | ) 65 65 | def test_csv_name_list_of_lists(param1, param2): -PT007.py:71:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:71:5 | 69 | @pytest.mark.parametrize( 70 | "param", @@ -238,11 +249,11 @@ PT007.py:71:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 72 | | [1, 2], 73 | | [3, 4], 74 | | ], - | |_____^ PT007 + | |_____^ 75 | ) 76 | def test_single_list_of_lists(param): | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 68 68 | @@ -258,14 +269,15 @@ PT007.py:71:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 76 76 | def test_single_list_of_lists(param): 77 77 | ... -PT007.py:80:31: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:80:31 | 80 | @pytest.mark.parametrize("a", [1, 2]) - | ^^^^^^ PT007 + | ^^^^^^ 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) 82 | @pytest.mark.parametrize("d", [3,]) | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 77 77 | ... @@ -277,16 +289,17 @@ PT007.py:80:31: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 82 82 | @pytest.mark.parametrize("d", [3,]) 83 83 | @pytest.mark.parametrize( -PT007.py:82:31: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:82:31 | 80 | @pytest.mark.parametrize("a", [1, 2]) 81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) 82 | @pytest.mark.parametrize("d", [3,]) - | ^^^^ PT007 + | ^^^^ 83 | @pytest.mark.parametrize( 84 | "d", | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 79 79 | @@ -298,16 +311,17 @@ PT007.py:82:31: PT007 [*] Wrong values type in `pytest.mark.parametrize` expecte 84 84 | "d", 85 85 | [("3", "4")], -PT007.py:85:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:85:5 | 83 | @pytest.mark.parametrize( 84 | "d", 85 | [("3", "4")], - | ^^^^^^^^^^^^ PT007 + | ^^^^^^^^^^^^ 86 | ) 87 | @pytest.mark.parametrize( | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 82 82 | @pytest.mark.parametrize("d", [3,]) @@ -319,16 +333,17 @@ PT007.py:85:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected 87 87 | @pytest.mark.parametrize( 88 88 | "e", -PT007.py:89:5: PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` +PT007 [*] Wrong values type in `pytest.mark.parametrize` expected `tuple` of `tuple` + --> PT007.py:89:5 | 87 | @pytest.mark.parametrize( 88 | "e", 89 | [("3", "4"),], - | ^^^^^^^^^^^^^ PT007 + | ^^^^^^^^^^^^^ 90 | ) 91 | def test_multiple_decorators(a, b, c, d, e): | - = help: Use `tuple` of `tuple` for parameter values +help: Use `tuple` of `tuple` for parameter values ℹ Unsafe fix 86 86 | ) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap index 7d366bf5c4..ca221bd73b 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap @@ -1,114 +1,126 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT008.py:35:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:35:1 | 33 | # Error 34 | 35 | mocker.patch("module.name", lambda: None) - | ^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^ 36 | module_mocker.patch("module.name", lambda: None) 37 | mocker.patch.object(obj, "attr", lambda: None) | -PT008.py:36:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:36:1 | 35 | mocker.patch("module.name", lambda: None) 36 | module_mocker.patch("module.name", lambda: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^ 37 | mocker.patch.object(obj, "attr", lambda: None) 38 | module_mocker.patch.object(obj, "attr", lambda: None) | -PT008.py:37:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:37:1 | 35 | mocker.patch("module.name", lambda: None) 36 | module_mocker.patch("module.name", lambda: None) 37 | mocker.patch.object(obj, "attr", lambda: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^ 38 | module_mocker.patch.object(obj, "attr", lambda: None) | -PT008.py:38:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:38:1 | 36 | module_mocker.patch("module.name", lambda: None) 37 | mocker.patch.object(obj, "attr", lambda: None) 38 | module_mocker.patch.object(obj, "attr", lambda: None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | 40 | mocker.patch("module.name", lambda x, y: None) | -PT008.py:40:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:40:1 | 38 | module_mocker.patch.object(obj, "attr", lambda: None) 39 | 40 | mocker.patch("module.name", lambda x, y: None) - | ^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^ 41 | module_mocker.patch("module.name", lambda x, y: None) 42 | mocker.patch.object(obj, "attr", lambda x, y: None) | -PT008.py:41:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:41:1 | 40 | mocker.patch("module.name", lambda x, y: None) 41 | module_mocker.patch("module.name", lambda x, y: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^ 42 | mocker.patch.object(obj, "attr", lambda x, y: None) 43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) | -PT008.py:42:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:42:1 | 40 | mocker.patch("module.name", lambda x, y: None) 41 | module_mocker.patch("module.name", lambda x, y: None) 42 | mocker.patch.object(obj, "attr", lambda x, y: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^ 43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) | -PT008.py:43:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:43:1 | 41 | module_mocker.patch("module.name", lambda x, y: None) 42 | mocker.patch.object(obj, "attr", lambda x, y: None) 43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | mocker.patch("module.name", lambda *args, **kwargs: None) | -PT008.py:45:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:45:1 | 43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) 44 | 45 | mocker.patch("module.name", lambda *args, **kwargs: None) - | ^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^ 46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) 47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) | -PT008.py:46:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:46:1 | 45 | mocker.patch("module.name", lambda *args, **kwargs: None) 46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^ 47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) 48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) | -PT008.py:47:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:47:1 | 45 | mocker.patch("module.name", lambda *args, **kwargs: None) 46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) 47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^ 48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) | -PT008.py:48:1: PT008 Use `return_value=` instead of patching with `lambda` +PT008 Use `return_value=` instead of patching with `lambda` + --> PT008.py:48:1 | 46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) 47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) 48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap index f77df5ab5c..513a58b588 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT009.py:11:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` +PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:11:9 | 9 | expr = 1 10 | msg = "Must be True" 11 | self.assertTrue(expr) # Error - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 12 | self.assertTrue(expr=expr) # Error 13 | self.assertTrue(expr, msg) # Error | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` ℹ Unsafe fix 8 8 | def test_assert_true(self): @@ -22,16 +23,17 @@ PT009.py:11:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 13 13 | self.assertTrue(expr, msg) # Error 14 14 | self.assertTrue(expr=expr, msg=msg) # Error -PT009.py:12:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` +PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:12:9 | 10 | msg = "Must be True" 11 | self.assertTrue(expr) # Error 12 | self.assertTrue(expr=expr) # Error - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 13 | self.assertTrue(expr, msg) # Error 14 | self.assertTrue(expr=expr, msg=msg) # Error | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` ℹ Unsafe fix 9 9 | expr = 1 @@ -43,16 +45,17 @@ PT009.py:12:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 14 14 | self.assertTrue(expr=expr, msg=msg) # Error 15 15 | self.assertTrue(msg=msg, expr=expr) # Error -PT009.py:13:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` +PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:13:9 | 11 | self.assertTrue(expr) # Error 12 | self.assertTrue(expr=expr) # Error 13 | self.assertTrue(expr, msg) # Error - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 14 | self.assertTrue(expr=expr, msg=msg) # Error 15 | self.assertTrue(msg=msg, expr=expr) # Error | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` ℹ Unsafe fix 10 10 | msg = "Must be True" @@ -64,16 +67,17 @@ PT009.py:13:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 15 15 | self.assertTrue(msg=msg, expr=expr) # Error 16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable -PT009.py:14:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` +PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:14:9 | 12 | self.assertTrue(expr=expr) # Error 13 | self.assertTrue(expr, msg) # Error 14 | self.assertTrue(expr=expr, msg=msg) # Error - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 15 | self.assertTrue(msg=msg, expr=expr) # Error 16 | self.assertTrue(*(expr, msg)) # Error, unfixable | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` ℹ Unsafe fix 11 11 | self.assertTrue(expr) # Error @@ -85,16 +89,17 @@ PT009.py:14:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable 17 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable -PT009.py:15:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` +PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:15:9 | 13 | self.assertTrue(expr, msg) # Error 14 | self.assertTrue(expr=expr, msg=msg) # Error 15 | self.assertTrue(msg=msg, expr=expr) # Error - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 16 | self.assertTrue(*(expr, msg)) # Error, unfixable 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` ℹ Unsafe fix 12 12 | self.assertTrue(expr=expr) # Error @@ -106,92 +111,100 @@ PT009.py:15:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 17 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable 18 18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable -PT009.py:16:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` +PT009 Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:16:9 | 14 | self.assertTrue(expr=expr, msg=msg) # Error 15 | self.assertTrue(msg=msg, expr=expr) # Error 16 | self.assertTrue(*(expr, msg)) # Error, unfixable - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable 18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` -PT009.py:17:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` +PT009 Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:17:9 | 15 | self.assertTrue(msg=msg, expr=expr) # Error 16 | self.assertTrue(*(expr, msg)) # Error, unfixable 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable 19 | self.assertTrue(msg=msg) # Error, unfixable | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` -PT009.py:18:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` +PT009 Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:18:9 | 16 | self.assertTrue(*(expr, msg)) # Error, unfixable 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable 18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 19 | self.assertTrue(msg=msg) # Error, unfixable 20 | ( | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` -PT009.py:19:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` +PT009 Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:19:9 | 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable 18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable 19 | self.assertTrue(msg=msg) # Error, unfixable - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 20 | ( 21 | self.assertIsNotNone(value) # Error, unfixable | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` -PT009.py:21:13: PT009 Use a regular `assert` instead of unittest-style `assertIsNotNone` +PT009 Use a regular `assert` instead of unittest-style `assertIsNotNone` + --> PT009.py:21:13 | 19 | self.assertTrue(msg=msg) # Error, unfixable 20 | ( 21 | self.assertIsNotNone(value) # Error, unfixable - | ^^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^^ 22 | if expect_condition 23 | else self.assertIsNone(value) # Error, unfixable | - = help: Replace `assertIsNotNone(...)` with `assert ...` +help: Replace `assertIsNotNone(...)` with `assert ...` -PT009.py:23:18: PT009 Use a regular `assert` instead of unittest-style `assertIsNone` +PT009 Use a regular `assert` instead of unittest-style `assertIsNone` + --> PT009.py:23:18 | 21 | self.assertIsNotNone(value) # Error, unfixable 22 | if expect_condition 23 | else self.assertIsNone(value) # Error, unfixable - | ^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^ 24 | ) 25 | return self.assertEqual(True, False) # Error, unfixable | - = help: Replace `assertIsNone(...)` with `assert ...` +help: Replace `assertIsNone(...)` with `assert ...` -PT009.py:25:16: PT009 Use a regular `assert` instead of unittest-style `assertEqual` +PT009 Use a regular `assert` instead of unittest-style `assertEqual` + --> PT009.py:25:16 | 23 | else self.assertIsNone(value) # Error, unfixable 24 | ) 25 | return self.assertEqual(True, False) # Error, unfixable - | ^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^ 26 | 27 | def test_assert_false(self): | - = help: Replace `assertEqual(...)` with `assert ...` +help: Replace `assertEqual(...)` with `assert ...` -PT009.py:28:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertFalse` +PT009 [*] Use a regular `assert` instead of unittest-style `assertFalse` + --> PT009.py:28:9 | 27 | def test_assert_false(self): 28 | self.assertFalse(True) # Error - | ^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^ 29 | 30 | def test_assert_equal(self): | - = help: Replace `assertFalse(...)` with `assert ...` +help: Replace `assertFalse(...)` with `assert ...` ℹ Unsafe fix 25 25 | return self.assertEqual(True, False) # Error, unfixable @@ -203,15 +216,16 @@ PT009.py:28:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 30 30 | def test_assert_equal(self): 31 31 | self.assertEqual(1, 2) # Error -PT009.py:31:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual` +PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual` + --> PT009.py:31:9 | 30 | def test_assert_equal(self): 31 | self.assertEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^ 32 | 33 | def test_assert_not_equal(self): | - = help: Replace `assertEqual(...)` with `assert ...` +help: Replace `assertEqual(...)` with `assert ...` ℹ Unsafe fix 28 28 | self.assertFalse(True) # Error @@ -223,15 +237,16 @@ PT009.py:31:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 33 33 | def test_assert_not_equal(self): 34 34 | self.assertNotEqual(1, 1) # Error -PT009.py:34:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotEqual` +PT009 [*] Use a regular `assert` instead of unittest-style `assertNotEqual` + --> PT009.py:34:9 | 33 | def test_assert_not_equal(self): 34 | self.assertNotEqual(1, 1) # Error - | ^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^ 35 | 36 | def test_assert_greater(self): | - = help: Replace `assertNotEqual(...)` with `assert ...` +help: Replace `assertNotEqual(...)` with `assert ...` ℹ Unsafe fix 31 31 | self.assertEqual(1, 2) # Error @@ -243,15 +258,16 @@ PT009.py:34:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 36 36 | def test_assert_greater(self): 37 37 | self.assertGreater(1, 2) # Error -PT009.py:37:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertGreater` +PT009 [*] Use a regular `assert` instead of unittest-style `assertGreater` + --> PT009.py:37:9 | 36 | def test_assert_greater(self): 37 | self.assertGreater(1, 2) # Error - | ^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^ 38 | 39 | def test_assert_greater_equal(self): | - = help: Replace `assertGreater(...)` with `assert ...` +help: Replace `assertGreater(...)` with `assert ...` ℹ Unsafe fix 34 34 | self.assertNotEqual(1, 1) # Error @@ -263,15 +279,16 @@ PT009.py:37:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 39 39 | def test_assert_greater_equal(self): 40 40 | self.assertGreaterEqual(1, 2) # Error -PT009.py:40:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertGreaterEqual` +PT009 [*] Use a regular `assert` instead of unittest-style `assertGreaterEqual` + --> PT009.py:40:9 | 39 | def test_assert_greater_equal(self): 40 | self.assertGreaterEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^^^^^ 41 | 42 | def test_assert_less(self): | - = help: Replace `assertGreaterEqual(...)` with `assert ...` +help: Replace `assertGreaterEqual(...)` with `assert ...` ℹ Unsafe fix 37 37 | self.assertGreater(1, 2) # Error @@ -283,15 +300,16 @@ PT009.py:40:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 42 42 | def test_assert_less(self): 43 43 | self.assertLess(2, 1) # Error -PT009.py:43:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertLess` +PT009 [*] Use a regular `assert` instead of unittest-style `assertLess` + --> PT009.py:43:9 | 42 | def test_assert_less(self): 43 | self.assertLess(2, 1) # Error - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 44 | 45 | def test_assert_less_equal(self): | - = help: Replace `assertLess(...)` with `assert ...` +help: Replace `assertLess(...)` with `assert ...` ℹ Unsafe fix 40 40 | self.assertGreaterEqual(1, 2) # Error @@ -303,15 +321,16 @@ PT009.py:43:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 45 45 | def test_assert_less_equal(self): 46 46 | self.assertLessEqual(1, 2) # Error -PT009.py:46:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertLessEqual` +PT009 [*] Use a regular `assert` instead of unittest-style `assertLessEqual` + --> PT009.py:46:9 | 45 | def test_assert_less_equal(self): 46 | self.assertLessEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^^ 47 | 48 | def test_assert_in(self): | - = help: Replace `assertLessEqual(...)` with `assert ...` +help: Replace `assertLessEqual(...)` with `assert ...` ℹ Unsafe fix 43 43 | self.assertLess(2, 1) # Error @@ -323,15 +342,16 @@ PT009.py:46:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 48 48 | def test_assert_in(self): 49 49 | self.assertIn(1, [2, 3]) # Error -PT009.py:49:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIn` +PT009 [*] Use a regular `assert` instead of unittest-style `assertIn` + --> PT009.py:49:9 | 48 | def test_assert_in(self): 49 | self.assertIn(1, [2, 3]) # Error - | ^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^ 50 | 51 | def test_assert_not_in(self): | - = help: Replace `assertIn(...)` with `assert ...` +help: Replace `assertIn(...)` with `assert ...` ℹ Unsafe fix 46 46 | self.assertLessEqual(1, 2) # Error @@ -343,15 +363,16 @@ PT009.py:49:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 51 51 | def test_assert_not_in(self): 52 52 | self.assertNotIn(2, [2, 3]) # Error -PT009.py:52:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIn` +PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIn` + --> PT009.py:52:9 | 51 | def test_assert_not_in(self): 52 | self.assertNotIn(2, [2, 3]) # Error - | ^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^ 53 | 54 | def test_assert_is_none(self): | - = help: Replace `assertNotIn(...)` with `assert ...` +help: Replace `assertNotIn(...)` with `assert ...` ℹ Unsafe fix 49 49 | self.assertIn(1, [2, 3]) # Error @@ -363,15 +384,16 @@ PT009.py:52:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 54 54 | def test_assert_is_none(self): 55 55 | self.assertIsNone(0) # Error -PT009.py:55:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNone` +PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNone` + --> PT009.py:55:9 | 54 | def test_assert_is_none(self): 55 | self.assertIsNone(0) # Error - | ^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^ 56 | 57 | def test_assert_is_not_none(self): | - = help: Replace `assertIsNone(...)` with `assert ...` +help: Replace `assertIsNone(...)` with `assert ...` ℹ Unsafe fix 52 52 | self.assertNotIn(2, [2, 3]) # Error @@ -383,15 +405,16 @@ PT009.py:55:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 57 57 | def test_assert_is_not_none(self): 58 58 | self.assertIsNotNone(0) # Error -PT009.py:58:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNotNone` +PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNotNone` + --> PT009.py:58:9 | 57 | def test_assert_is_not_none(self): 58 | self.assertIsNotNone(0) # Error - | ^^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^^ 59 | 60 | def test_assert_is(self): | - = help: Replace `assertIsNotNone(...)` with `assert ...` +help: Replace `assertIsNotNone(...)` with `assert ...` ℹ Unsafe fix 55 55 | self.assertIsNone(0) # Error @@ -403,15 +426,16 @@ PT009.py:58:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 60 60 | def test_assert_is(self): 61 61 | self.assertIs([], []) # Error -PT009.py:61:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIs` +PT009 [*] Use a regular `assert` instead of unittest-style `assertIs` + --> PT009.py:61:9 | 60 | def test_assert_is(self): 61 | self.assertIs([], []) # Error - | ^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^ 62 | 63 | def test_assert_is_not(self): | - = help: Replace `assertIs(...)` with `assert ...` +help: Replace `assertIs(...)` with `assert ...` ℹ Unsafe fix 58 58 | self.assertIsNotNone(0) # Error @@ -423,15 +447,16 @@ PT009.py:61:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 63 63 | def test_assert_is_not(self): 64 64 | self.assertIsNot(1, 1) # Error -PT009.py:64:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNot` +PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNot` + --> PT009.py:64:9 | 63 | def test_assert_is_not(self): 64 | self.assertIsNot(1, 1) # Error - | ^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^ 65 | 66 | def test_assert_is_instance(self): | - = help: Replace `assertIsNot(...)` with `assert ...` +help: Replace `assertIsNot(...)` with `assert ...` ℹ Unsafe fix 61 61 | self.assertIs([], []) # Error @@ -443,15 +468,16 @@ PT009.py:64:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 66 66 | def test_assert_is_instance(self): 67 67 | self.assertIsInstance(1, str) # Error -PT009.py:67:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsInstance` +PT009 [*] Use a regular `assert` instead of unittest-style `assertIsInstance` + --> PT009.py:67:9 | 66 | def test_assert_is_instance(self): 67 | self.assertIsInstance(1, str) # Error - | ^^^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^^^ 68 | 69 | def test_assert_is_not_instance(self): | - = help: Replace `assertIsInstance(...)` with `assert ...` +help: Replace `assertIsInstance(...)` with `assert ...` ℹ Unsafe fix 64 64 | self.assertIsNot(1, 1) # Error @@ -463,15 +489,16 @@ PT009.py:67:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 69 69 | def test_assert_is_not_instance(self): 70 70 | self.assertNotIsInstance(1, int) # Error -PT009.py:70:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIsInstance` +PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIsInstance` + --> PT009.py:70:9 | 69 | def test_assert_is_not_instance(self): 70 | self.assertNotIsInstance(1, int) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 71 | 72 | def test_assert_regex(self): | - = help: Replace `assertNotIsInstance(...)` with `assert ...` +help: Replace `assertNotIsInstance(...)` with `assert ...` ℹ Unsafe fix 67 67 | self.assertIsInstance(1, str) # Error @@ -483,15 +510,16 @@ PT009.py:70:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 72 72 | def test_assert_regex(self): 73 73 | self.assertRegex("abc", r"def") # Error -PT009.py:73:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertRegex` +PT009 [*] Use a regular `assert` instead of unittest-style `assertRegex` + --> PT009.py:73:9 | 72 | def test_assert_regex(self): 73 | self.assertRegex("abc", r"def") # Error - | ^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^ 74 | 75 | def test_assert_not_regex(self): | - = help: Replace `assertRegex(...)` with `assert ...` +help: Replace `assertRegex(...)` with `assert ...` ℹ Unsafe fix 70 70 | self.assertNotIsInstance(1, int) # Error @@ -503,15 +531,16 @@ PT009.py:73:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 75 75 | def test_assert_not_regex(self): 76 76 | self.assertNotRegex("abc", r"abc") # Error -PT009.py:76:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` +PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` + --> PT009.py:76:9 | 75 | def test_assert_not_regex(self): 76 | self.assertNotRegex("abc", r"abc") # Error - | ^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^ 77 | 78 | def test_assert_regexp_matches(self): | - = help: Replace `assertNotRegex(...)` with `assert ...` +help: Replace `assertNotRegex(...)` with `assert ...` ℹ Unsafe fix 73 73 | self.assertRegex("abc", r"def") # Error @@ -523,15 +552,16 @@ PT009.py:76:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 78 78 | def test_assert_regexp_matches(self): 79 79 | self.assertRegexpMatches("abc", r"def") # Error -PT009.py:79:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertRegexpMatches` +PT009 [*] Use a regular `assert` instead of unittest-style `assertRegexpMatches` + --> PT009.py:79:9 | 78 | def test_assert_regexp_matches(self): 79 | self.assertRegexpMatches("abc", r"def") # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 80 | 81 | def test_assert_not_regexp_matches(self): | - = help: Replace `assertRegexpMatches(...)` with `assert ...` +help: Replace `assertRegexpMatches(...)` with `assert ...` ℹ Unsafe fix 76 76 | self.assertNotRegex("abc", r"abc") # Error @@ -543,15 +573,16 @@ PT009.py:79:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 81 81 | def test_assert_not_regexp_matches(self): 82 82 | self.assertNotRegex("abc", r"abc") # Error -PT009.py:82:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` +PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` + --> PT009.py:82:9 | 81 | def test_assert_not_regexp_matches(self): 82 | self.assertNotRegex("abc", r"abc") # Error - | ^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^ 83 | 84 | def test_fail_if(self): | - = help: Replace `assertNotRegex(...)` with `assert ...` +help: Replace `assertNotRegex(...)` with `assert ...` ℹ Unsafe fix 79 79 | self.assertRegexpMatches("abc", r"def") # Error @@ -563,15 +594,16 @@ PT009.py:82:9: PT009 [*] Use a regular `assert` instead of unittest-style `asser 84 84 | def test_fail_if(self): 85 85 | self.failIf("abc") # Error -PT009.py:85:9: PT009 [*] Use a regular `assert` instead of unittest-style `failIf` +PT009 [*] Use a regular `assert` instead of unittest-style `failIf` + --> PT009.py:85:9 | 84 | def test_fail_if(self): 85 | self.failIf("abc") # Error - | ^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^ 86 | 87 | def test_fail_unless(self): | - = help: Replace `failIf(...)` with `assert ...` +help: Replace `failIf(...)` with `assert ...` ℹ Unsafe fix 82 82 | self.assertNotRegex("abc", r"abc") # Error @@ -583,15 +615,16 @@ PT009.py:85:9: PT009 [*] Use a regular `assert` instead of unittest-style `failI 87 87 | def test_fail_unless(self): 88 88 | self.failUnless("abc") # Error -PT009.py:88:9: PT009 [*] Use a regular `assert` instead of unittest-style `failUnless` +PT009 [*] Use a regular `assert` instead of unittest-style `failUnless` + --> PT009.py:88:9 | 87 | def test_fail_unless(self): 88 | self.failUnless("abc") # Error - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 89 | 90 | def test_fail_unless_equal(self): | - = help: Replace `failUnless(...)` with `assert ...` +help: Replace `failUnless(...)` with `assert ...` ℹ Unsafe fix 85 85 | self.failIf("abc") # Error @@ -603,15 +636,16 @@ PT009.py:88:9: PT009 [*] Use a regular `assert` instead of unittest-style `failU 90 90 | def test_fail_unless_equal(self): 91 91 | self.failUnlessEqual(1, 2) # Error -PT009.py:91:9: PT009 [*] Use a regular `assert` instead of unittest-style `failUnlessEqual` +PT009 [*] Use a regular `assert` instead of unittest-style `failUnlessEqual` + --> PT009.py:91:9 | 90 | def test_fail_unless_equal(self): 91 | self.failUnlessEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^^^^^ 92 | 93 | def test_fail_if_equal(self): | - = help: Replace `failUnlessEqual(...)` with `assert ...` +help: Replace `failUnlessEqual(...)` with `assert ...` ℹ Unsafe fix 88 88 | self.failUnless("abc") # Error @@ -623,13 +657,14 @@ PT009.py:91:9: PT009 [*] Use a regular `assert` instead of unittest-style `failU 93 93 | def test_fail_if_equal(self): 94 94 | self.failIfEqual(1, 2) # Error -PT009.py:94:9: PT009 [*] Use a regular `assert` instead of unittest-style `failIfEqual` +PT009 [*] Use a regular `assert` instead of unittest-style `failIfEqual` + --> PT009.py:94:9 | 93 | def test_fail_if_equal(self): 94 | self.failIfEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^^ | - = help: Replace `failIfEqual(...)` with `assert ...` +help: Replace `failIfEqual(...)` with `assert ...` ℹ Unsafe fix 91 91 | self.failUnlessEqual(1, 2) # Error @@ -641,15 +676,16 @@ PT009.py:94:9: PT009 [*] Use a regular `assert` instead of unittest-style `failI 96 96 | 97 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 -PT009.py:98:2: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` +PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + --> PT009.py:98:2 | 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 98 | (self.assertTrue( - | ^^^^^^^^^^^^^^^ PT009 + | ^^^^^^^^^^^^^^^ 99 | "piAx_piAy_beta[r][x][y] = {17}".format( 100 | self.model.piAx_piAy_beta[r][x][y]))) | - = help: Replace `assertTrue(...)` with `assert ...` +help: Replace `assertTrue(...)` with `assert ...` ℹ Unsafe fix 95 95 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT010.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT010.snap index 14e9e2e2a8..b4b3a54799 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT010.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT010.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT010.py:5:10: PT010 Set the expected exception in `pytest.raises()` +PT010 Set the expected exception in `pytest.raises()` + --> PT010.py:5:10 | 4 | def test_ok(): 5 | with pytest.raises(): - | ^^^^^^^^^^^^^ PT010 + | ^^^^^^^^^^^^^ 6 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap index 7a4757d7eb..db9480f4e5 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap @@ -1,54 +1,60 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT011.py:25:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:25:24 | 24 | def test_error_no_argument_given(): 25 | with pytest.raises(ValueError): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 26 | raise ValueError("Can't divide 1 by 0") | -PT011.py:28:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:28:43 | 26 | raise ValueError("Can't divide 1 by 0") 27 | 28 | with pytest.raises(expected_exception=ValueError): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 29 | raise ValueError("Can't divide 1 by 0") | -PT011.py:31:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:31:24 | 29 | raise ValueError("Can't divide 1 by 0") 30 | 31 | with pytest.raises(socket.error): - | ^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^ 32 | raise ValueError("Can't divide 1 by 0") | -PT011.py:42:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:42:24 | 41 | def test_error_match_is_empty(): 42 | with pytest.raises(ValueError, match=None): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 43 | raise ValueError("Can't divide 1 by 0") | -PT011.py:45:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:45:24 | 43 | raise ValueError("Can't divide 1 by 0") 44 | 45 | with pytest.raises(ValueError, match=""): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 46 | raise ValueError("Can't divide 1 by 0") | -PT011.py:48:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:48:24 | 46 | raise ValueError("Can't divide 1 by 0") 47 | 48 | with pytest.raises(ValueError, match=f""): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 49 | raise ValueError("Can't divide 1 by 0") | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap index 9e8020a9d7..5616bf836d 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap @@ -1,62 +1,69 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:13:24 | 12 | def test_ok_different_error_from_config(): 13 | with pytest.raises(ZeroDivisionError): - | ^^^^^^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^^^^^^ 14 | raise ZeroDivisionError("Can't divide by 0") | -PT011.py:25:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:25:24 | 24 | def test_error_no_argument_given(): 25 | with pytest.raises(ValueError): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 26 | raise ValueError("Can't divide 1 by 0") | -PT011.py:28:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:28:43 | 26 | raise ValueError("Can't divide 1 by 0") 27 | 28 | with pytest.raises(expected_exception=ValueError): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 29 | raise ValueError("Can't divide 1 by 0") | -PT011.py:31:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:31:24 | 29 | raise ValueError("Can't divide 1 by 0") 30 | 31 | with pytest.raises(socket.error): - | ^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^ 32 | raise ValueError("Can't divide 1 by 0") | -PT011.py:42:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:42:24 | 41 | def test_error_match_is_empty(): 42 | with pytest.raises(ValueError, match=None): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 43 | raise ValueError("Can't divide 1 by 0") | -PT011.py:45:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:45:24 | 43 | raise ValueError("Can't divide 1 by 0") 44 | 45 | with pytest.raises(ValueError, match=""): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 46 | raise ValueError("Can't divide 1 by 0") | -PT011.py:48:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:48:24 | 46 | raise ValueError("Can't divide 1 by 0") 47 | 48 | with pytest.raises(ValueError, match=f""): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 49 | raise ValueError("Can't divide 1 by 0") | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap index d7d61cfe51..c1ee088e97 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap @@ -1,80 +1,89 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:13:24 | 12 | def test_ok_different_error_from_config(): 13 | with pytest.raises(ZeroDivisionError): - | ^^^^^^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^^^^^^ 14 | raise ZeroDivisionError("Can't divide by 0") | -PT011.py:25:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:25:24 | 24 | def test_error_no_argument_given(): 25 | with pytest.raises(ValueError): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 26 | raise ValueError("Can't divide 1 by 0") | -PT011.py:28:43: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:28:43 | 26 | raise ValueError("Can't divide 1 by 0") 27 | 28 | with pytest.raises(expected_exception=ValueError): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 29 | raise ValueError("Can't divide 1 by 0") | -PT011.py:31:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:31:24 | 29 | raise ValueError("Can't divide 1 by 0") 30 | 31 | with pytest.raises(socket.error): - | ^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^ 32 | raise ValueError("Can't divide 1 by 0") | -PT011.py:34:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:34:24 | 32 | raise ValueError("Can't divide 1 by 0") 33 | 34 | with pytest.raises(PicklingError): - | ^^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^^ 35 | raise PicklingError("Can't pickle") | -PT011.py:37:24: PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:37:24 | 35 | raise PicklingError("Can't pickle") 36 | 37 | with pytest.raises(UnpicklingError): - | ^^^^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^^^^ 38 | raise UnpicklingError("Can't unpickle") | -PT011.py:42:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:42:24 | 41 | def test_error_match_is_empty(): 42 | with pytest.raises(ValueError, match=None): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 43 | raise ValueError("Can't divide 1 by 0") | -PT011.py:45:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:45:24 | 43 | raise ValueError("Can't divide 1 by 0") 44 | 45 | with pytest.raises(ValueError, match=""): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 46 | raise ValueError("Can't divide 1 by 0") | -PT011.py:48:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:48:24 | 46 | raise ValueError("Can't divide 1 by 0") 47 | 48 | with pytest.raises(ValueError, match=f""): - | ^^^^^^^^^^ PT011 + | ^^^^^^^^^^ 49 | raise ValueError("Can't divide 1 by 0") | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap index 21162e38df..944693d46a 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT011.py:34:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:34:24 | 32 | raise ValueError("Can't divide 1 by 0") 33 | 34 | with pytest.raises(PicklingError): - | ^^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^^ 35 | raise PicklingError("Can't pickle") | -PT011.py:37:24: PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:37:24 | 35 | raise PicklingError("Can't pickle") 36 | 37 | with pytest.raises(UnpicklingError): - | ^^^^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^^^^ 38 | raise UnpicklingError("Can't unpickle") | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap index 1fd3e1badd..89fb1e4d0d 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception +PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception + --> PT011.py:13:24 | 12 | def test_ok_different_error_from_config(): 13 | with pytest.raises(ZeroDivisionError): - | ^^^^^^^^^^^^^^^^^ PT011 + | ^^^^^^^^^^^^^^^^^ 14 | raise ZeroDivisionError("Can't divide by 0") | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap index 43cf518d00..cd6b2a6d20 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap @@ -1,63 +1,69 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT012.py:42:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:42:5 | 41 | def test_error_multiple_statements(): 42 | / with pytest.raises(AttributeError): 43 | | len([]) 44 | | [].size - | |_______________^ PT012 + | |_______________^ | -PT012.py:48:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:48:5 | 47 | async def test_error_complex_statement(): 48 | / with pytest.raises(AttributeError): 49 | | if True: 50 | | [].size - | |___________________^ PT012 + | |___________________^ 51 | 52 | with pytest.raises(AttributeError): | -PT012.py:52:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:52:5 | 50 | [].size 51 | 52 | / with pytest.raises(AttributeError): 53 | | for i in []: 54 | | [].size - | |___________________^ PT012 + | |___________________^ 55 | 56 | with pytest.raises(AttributeError): | -PT012.py:56:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:56:5 | 54 | [].size 55 | 56 | / with pytest.raises(AttributeError): 57 | | async for i in []: 58 | | [].size - | |___________________^ PT012 + | |___________________^ 59 | 60 | with pytest.raises(AttributeError): | -PT012.py:60:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:60:5 | 58 | [].size 59 | 60 | / with pytest.raises(AttributeError): 61 | | while True: 62 | | [].size - | |___________________^ PT012 + | |___________________^ 63 | 64 | with pytest.raises(AttributeError): | -PT012.py:64:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:64:5 | 62 | [].size 63 | @@ -65,10 +71,11 @@ PT012.py:64:5: PT012 `pytest.raises()` block should contain a single simple stat 65 | | async with context_manager_under_test(): 66 | | if True: 67 | | raise Exception - | |_______________________________^ PT012 + | |_______________________________^ | -PT012.py:71:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:71:5 | 70 | def test_error_try(): 71 | / with pytest.raises(AttributeError): @@ -76,51 +83,55 @@ PT012.py:71:5: PT012 `pytest.raises()` block should contain a single simple stat 73 | | [].size 74 | | except: 75 | | raise - | |_________________^ PT012 + | |_________________^ | -PT012.py:83:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:83:5 | 81 | ## Errors 82 | 83 | / with pytest.raises(RuntimeError): 84 | | for a in b: 85 | | print() - | |___________________^ PT012 + | |___________________^ 86 | 87 | with pytest.raises(RuntimeError): | -PT012.py:87:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:87:5 | 85 | print() 86 | 87 | / with pytest.raises(RuntimeError): 88 | | for a in b: 89 | | assert foo - | |______________________^ PT012 + | |______________________^ 90 | 91 | with pytest.raises(RuntimeError): | -PT012.py:91:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:91:5 | 89 | assert foo 90 | 91 | / with pytest.raises(RuntimeError): 92 | | async for a in b: 93 | | print() - | |___________________^ PT012 + | |___________________^ 94 | 95 | with pytest.raises(RuntimeError): | -PT012.py:95:5: PT012 `pytest.raises()` block should contain a single simple statement +PT012 `pytest.raises()` block should contain a single simple statement + --> PT012.py:95:5 | 93 | print() 94 | 95 | / with pytest.raises(RuntimeError): 96 | | async for a in b: 97 | | assert foo - | |______________________^ PT012 + | |______________________^ | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap index b4da53b527..edf98e63d9 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap @@ -1,28 +1,31 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT013.py:11:1: PT013 Incorrect import of `pytest`; use `import pytest` instead +PT013 Incorrect import of `pytest`; use `import pytest` instead + --> PT013.py:11:1 | 9 | # Error 10 | 11 | import pytest as other_name - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | from pytest import fixture 13 | from pytest import fixture as other_name | -PT013.py:12:1: PT013 Incorrect import of `pytest`; use `import pytest` instead +PT013 Incorrect import of `pytest`; use `import pytest` instead + --> PT013.py:12:1 | 11 | import pytest as other_name 12 | from pytest import fixture - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | from pytest import fixture as other_name | -PT013.py:13:1: PT013 Incorrect import of `pytest`; use `import pytest` instead +PT013 Incorrect import of `pytest`; use `import pytest` instead + --> PT013.py:13:1 | 11 | import pytest as other_name 12 | from pytest import fixture 13 | from pytest import fixture as other_name - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap index 96b31adcdb..9b185de803 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT014.py:4:35: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` + --> PT014.py:4:35 | 4 | @pytest.mark.parametrize("x", [1, 1, 2]) - | ^ PT014 + | ^ 5 | def test_error_literal(x): 6 | ... | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 1 1 | import pytest @@ -21,14 +21,15 @@ PT014.py:4:35: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.param 6 6 | ... 7 7 | -PT014.py:14:35: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` + --> PT014.py:14:35 | 14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) - | ^ PT014 + | ^ 15 | def test_error_expr_simple(x): 16 | ... | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 11 11 | c = 3 @@ -40,14 +41,15 @@ PT014.py:14:35: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.para 16 16 | ... 17 17 | -PT014.py:14:41: PT014 [*] Duplicate of test case at index 2 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 2 in `pytest.mark.parametrize` + --> PT014.py:14:41 | 14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) - | ^ PT014 + | ^ 15 | def test_error_expr_simple(x): 16 | ... | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 11 11 | c = 3 @@ -59,14 +61,15 @@ PT014.py:14:41: PT014 [*] Duplicate of test case at index 2 in `pytest.mark.para 16 16 | ... 17 17 | -PT014.py:14:44: PT014 [*] Duplicate of test case at index 2 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 2 in `pytest.mark.parametrize` + --> PT014.py:14:44 | 14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) - | ^ PT014 + | ^ 15 | def test_error_expr_simple(x): 16 | ... | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 11 11 | c = 3 @@ -78,25 +81,27 @@ PT014.py:14:44: PT014 [*] Duplicate of test case at index 2 in `pytest.mark.para 16 16 | ... 17 17 | -PT014.py:24:9: PT014 Duplicate of test case at index 0 in `pytest.mark.parametrize` +PT014 Duplicate of test case at index 0 in `pytest.mark.parametrize` + --> PT014.py:24:9 | 22 | (a, b), 23 | # comment 24 | (a, b), - | ^^^^^^ PT014 + | ^^^^^^ 25 | (b, c), 26 | ], | - = help: Remove duplicate test case +help: Remove duplicate test case -PT014.py:32:39: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` + --> PT014.py:32:39 | 32 | @pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) - | ^ PT014 + | ^ 33 | def test_error_parentheses(x): 34 | ... | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 29 29 | ... @@ -108,14 +113,15 @@ PT014.py:32:39: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.para 34 34 | ... 35 35 | -PT014.py:32:48: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` + --> PT014.py:32:48 | 32 | @pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) - | ^ PT014 + | ^ 33 | def test_error_parentheses(x): 34 | ... | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 29 29 | ... @@ -127,16 +133,17 @@ PT014.py:32:48: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.para 34 34 | ... 35 35 | -PT014.py:42:10: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` + --> PT014.py:42:10 | 40 | a, 41 | b, 42 | (a), - | ^ PT014 + | ^ 43 | c, 44 | ((a)), | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 39 39 | [ @@ -147,16 +154,17 @@ PT014.py:42:10: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.para 44 43 | ((a)), 45 44 | ], -PT014.py:44:11: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` + --> PT014.py:44:11 | 42 | (a), 43 | c, 44 | ((a)), - | ^ PT014 + | ^ 45 | ], 46 | ) | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 41 41 | b, @@ -167,14 +175,15 @@ PT014.py:44:11: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.para 46 45 | ) 47 46 | def test_error_parentheses_trailing_comma(x): -PT014.py:56:53: PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` +PT014 [*] Duplicate of test case at index 0 in `pytest.mark.parametrize` + --> PT014.py:56:53 | 56 | @pytest.mark.parametrize('data, spec', [(1.0, 1.0), (1.0, 1.0)]) - | ^^^^^^^^^^ PT014 + | ^^^^^^^^^^ 57 | def test_numbers(data, spec): 58 | ... | - = help: Remove duplicate test case +help: Remove duplicate test case ℹ Unsafe fix 53 53 | ... diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT015.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT015.snap index 152e292cc6..88a035bada 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT015.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT015.snap @@ -1,169 +1,185 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT015.py:9:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:9:5 | 8 | def test_error(): 9 | assert None - | ^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^ 10 | assert False 11 | assert 0 | -PT015.py:10:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:10:5 | 8 | def test_error(): 9 | assert None 10 | assert False - | ^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^ 11 | assert 0 12 | assert 0.0 | -PT015.py:11:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:11:5 | 9 | assert None 10 | assert False 11 | assert 0 - | ^^^^^^^^ PT015 + | ^^^^^^^^ 12 | assert 0.0 13 | assert "" | -PT015.py:12:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:12:5 | 10 | assert False 11 | assert 0 12 | assert 0.0 - | ^^^^^^^^^^ PT015 + | ^^^^^^^^^^ 13 | assert "" 14 | assert f"" | -PT015.py:13:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:13:5 | 11 | assert 0 12 | assert 0.0 13 | assert "" - | ^^^^^^^^^ PT015 + | ^^^^^^^^^ 14 | assert f"" 15 | assert [] | -PT015.py:14:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:14:5 | 12 | assert 0.0 13 | assert "" 14 | assert f"" - | ^^^^^^^^^^ PT015 + | ^^^^^^^^^^ 15 | assert [] 16 | assert () | -PT015.py:15:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:15:5 | 13 | assert "" 14 | assert f"" 15 | assert [] - | ^^^^^^^^^ PT015 + | ^^^^^^^^^ 16 | assert () 17 | assert {} | -PT015.py:16:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:16:5 | 14 | assert f"" 15 | assert [] 16 | assert () - | ^^^^^^^^^ PT015 + | ^^^^^^^^^ 17 | assert {} 18 | assert list() | -PT015.py:17:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:17:5 | 15 | assert [] 16 | assert () 17 | assert {} - | ^^^^^^^^^ PT015 + | ^^^^^^^^^ 18 | assert list() 19 | assert set() | -PT015.py:18:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:18:5 | 16 | assert () 17 | assert {} 18 | assert list() - | ^^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^^ 19 | assert set() 20 | assert tuple() | -PT015.py:19:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:19:5 | 17 | assert {} 18 | assert list() 19 | assert set() - | ^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^ 20 | assert tuple() 21 | assert dict() | -PT015.py:20:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:20:5 | 18 | assert list() 19 | assert set() 20 | assert tuple() - | ^^^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^^^ 21 | assert dict() 22 | assert frozenset() | -PT015.py:21:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:21:5 | 19 | assert set() 20 | assert tuple() 21 | assert dict() - | ^^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^^ 22 | assert frozenset() 23 | assert list([]) | -PT015.py:22:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:22:5 | 20 | assert tuple() 21 | assert dict() 22 | assert frozenset() - | ^^^^^^^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^^^^^^^ 23 | assert list([]) 24 | assert set(set()) | -PT015.py:23:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:23:5 | 21 | assert dict() 22 | assert frozenset() 23 | assert list([]) - | ^^^^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^^^^ 24 | assert set(set()) 25 | assert tuple("") | -PT015.py:24:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:24:5 | 22 | assert frozenset() 23 | assert list([]) 24 | assert set(set()) - | ^^^^^^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^^^^^^ 25 | assert tuple("") | -PT015.py:25:5: PT015 Assertion always fails, replace with `pytest.fail()` +PT015 Assertion always fails, replace with `pytest.fail()` + --> PT015.py:25:5 | 23 | assert list([]) 24 | assert set(set()) 25 | assert tuple("") - | ^^^^^^^^^^^^^^^^ PT015 + | ^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT016.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT016.snap index 4730ecdeca..4c49b3e41e 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT016.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT016.snap @@ -1,71 +1,78 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT016.py:19:5: PT016 No message passed to `pytest.fail()` +PT016 No message passed to `pytest.fail()` + --> PT016.py:19:5 | 17 | # Errors 18 | def f(): 19 | pytest.fail() - | ^^^^^^^^^^^ PT016 + | ^^^^^^^^^^^ 20 | pytest.fail("") 21 | pytest.fail(f"") | -PT016.py:20:5: PT016 No message passed to `pytest.fail()` +PT016 No message passed to `pytest.fail()` + --> PT016.py:20:5 | 18 | def f(): 19 | pytest.fail() 20 | pytest.fail("") - | ^^^^^^^^^^^ PT016 + | ^^^^^^^^^^^ 21 | pytest.fail(f"") 22 | pytest.fail(msg="") | -PT016.py:21:5: PT016 No message passed to `pytest.fail()` +PT016 No message passed to `pytest.fail()` + --> PT016.py:21:5 | 19 | pytest.fail() 20 | pytest.fail("") 21 | pytest.fail(f"") - | ^^^^^^^^^^^ PT016 + | ^^^^^^^^^^^ 22 | pytest.fail(msg="") 23 | pytest.fail(msg=f"") | -PT016.py:22:5: PT016 No message passed to `pytest.fail()` +PT016 No message passed to `pytest.fail()` + --> PT016.py:22:5 | 20 | pytest.fail("") 21 | pytest.fail(f"") 22 | pytest.fail(msg="") - | ^^^^^^^^^^^ PT016 + | ^^^^^^^^^^^ 23 | pytest.fail(msg=f"") 24 | pytest.fail(reason="") | -PT016.py:23:5: PT016 No message passed to `pytest.fail()` +PT016 No message passed to `pytest.fail()` + --> PT016.py:23:5 | 21 | pytest.fail(f"") 22 | pytest.fail(msg="") 23 | pytest.fail(msg=f"") - | ^^^^^^^^^^^ PT016 + | ^^^^^^^^^^^ 24 | pytest.fail(reason="") 25 | pytest.fail(reason=f"") | -PT016.py:24:5: PT016 No message passed to `pytest.fail()` +PT016 No message passed to `pytest.fail()` + --> PT016.py:24:5 | 22 | pytest.fail(msg="") 23 | pytest.fail(msg=f"") 24 | pytest.fail(reason="") - | ^^^^^^^^^^^ PT016 + | ^^^^^^^^^^^ 25 | pytest.fail(reason=f"") | -PT016.py:25:5: PT016 No message passed to `pytest.fail()` +PT016 No message passed to `pytest.fail()` + --> PT016.py:25:5 | 23 | pytest.fail(msg=f"") 24 | pytest.fail(reason="") 25 | pytest.fail(reason=f"") - | ^^^^^^^^^^^ PT016 + | ^^^^^^^^^^^ 26 | 27 | # Skip for t-strings | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT017.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT017.snap index 588a3a8460..6fc520ff76 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT017.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT017.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT017.py:19:9: PT017 Found assertion on exception `e` in `except` block, use `pytest.raises()` instead +PT017 Found assertion on exception `e` in `except` block, use `pytest.raises()` instead + --> PT017.py:19:9 | 17 | something() 18 | except Exception as e: 19 | assert e.message, "blah blah" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap index 15ef642752..5cc41f4ecd 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT018.py:14:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:14:5 | 13 | def test_error(): 14 | assert something and something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | assert something and something_else and something_third 16 | assert something and not something_else | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 11 11 | @@ -22,16 +23,17 @@ PT018.py:14:5: PT018 [*] Assertion should be broken down into multiple parts 16 17 | assert something and not something_else 17 18 | assert something and (something_else or something_third) -PT018.py:15:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:15:5 | 13 | def test_error(): 14 | assert something and something_else 15 | assert something and something_else and something_third - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | assert something and not something_else 17 | assert something and (something_else or something_third) | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 12 12 | @@ -44,16 +46,17 @@ PT018.py:15:5: PT018 [*] Assertion should be broken down into multiple parts 17 18 | assert something and (something_else or something_third) 18 19 | assert not something and something_else -PT018.py:16:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:16:5 | 14 | assert something and something_else 15 | assert something and something_else and something_third 16 | assert something and not something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | assert something and (something_else or something_third) 18 | assert not something and something_else | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 13 13 | def test_error(): @@ -66,16 +69,17 @@ PT018.py:16:5: PT018 [*] Assertion should be broken down into multiple parts 18 19 | assert not something and something_else 19 20 | assert not (something or something_else) -PT018.py:17:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:17:5 | 15 | assert something and something_else and something_third 16 | assert something and not something_else 17 | assert something and (something_else or something_third) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | assert not something and something_else 19 | assert not (something or something_else) | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 14 14 | assert something and something_else @@ -88,16 +92,17 @@ PT018.py:17:5: PT018 [*] Assertion should be broken down into multiple parts 19 20 | assert not (something or something_else) 20 21 | assert not (something or something_else or something_third) -PT018.py:18:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:18:5 | 16 | assert something and not something_else 17 | assert something and (something_else or something_third) 18 | assert not something and something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | assert not (something or something_else) 20 | assert not (something or something_else or something_third) | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 15 15 | assert something and something_else and something_third @@ -110,16 +115,17 @@ PT018.py:18:5: PT018 [*] Assertion should be broken down into multiple parts 20 21 | assert not (something or something_else or something_third) 21 22 | assert something and something_else == """error -PT018.py:19:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:19:5 | 17 | assert something and (something_else or something_third) 18 | assert not something and something_else 19 | assert not (something or something_else) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | assert not (something or something_else or something_third) 21 | assert something and something_else == """error | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 16 16 | assert something and not something_else @@ -132,16 +138,17 @@ PT018.py:19:5: PT018 [*] Assertion should be broken down into multiple parts 21 22 | assert something and something_else == """error 22 23 | message -PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:20:5 | 18 | assert not something and something_else 19 | assert not (something or something_else) 20 | assert not (something or something_else or something_third) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | assert something and something_else == """error 22 | message | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 17 17 | assert something and (something_else or something_third) @@ -154,18 +161,19 @@ PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts 22 23 | message 23 24 | """ -PT018.py:21:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:21:5 | 19 | assert not (something or something_else) 20 | assert not (something or something_else or something_third) 21 | / assert something and something_else == """error 22 | | message 23 | | """ - | |_______^ PT018 + | |_______^ 24 | assert ( 25 | something | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 18 18 | assert not something and something_else @@ -178,7 +186,8 @@ PT018.py:21:5: PT018 [*] Assertion should be broken down into multiple parts 23 24 | """ 24 25 | assert ( -PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:24:5 | 22 | message 23 | """ @@ -189,11 +198,11 @@ PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts 28 | | message 29 | | """ 30 | | ) - | |_____^ PT018 + | |_____^ 31 | 32 | # recursive case | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 21 21 | assert something and something_else == """error @@ -208,14 +217,15 @@ PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts 28 28 | message 29 29 | """ -PT018.py:33:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:33:5 | 32 | # recursive case 33 | assert not (a or not (b or c)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | assert not (a or not (b and c)) | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 30 30 | ) @@ -228,16 +238,17 @@ PT018.py:33:5: PT018 [*] Assertion should be broken down into multiple parts 35 36 | 36 37 | # detected, but no fix for messages -PT018.py:34:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:34:5 | 32 | # recursive case 33 | assert not (a or not (b or c)) 34 | assert not (a or not (b and c)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | # detected, but no fix for messages | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 31 31 | @@ -250,44 +261,48 @@ PT018.py:34:5: PT018 [*] Assertion should be broken down into multiple parts 36 37 | # detected, but no fix for messages 37 38 | assert something and something_else, "error message" -PT018.py:37:5: PT018 Assertion should be broken down into multiple parts +PT018 Assertion should be broken down into multiple parts + --> PT018.py:37:5 | 36 | # detected, but no fix for messages 37 | assert something and something_else, "error message" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | assert not (something or something_else and something_third), "with message" 39 | # detected, but no fix for mixed conditions (e.g. `a or b and c`) | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts -PT018.py:38:5: PT018 Assertion should be broken down into multiple parts +PT018 Assertion should be broken down into multiple parts + --> PT018.py:38:5 | 36 | # detected, but no fix for messages 37 | assert something and something_else, "error message" 38 | assert not (something or something_else and something_third), "with message" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | # detected, but no fix for mixed conditions (e.g. `a or b and c`) 40 | assert not (something or something_else and something_third) | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts -PT018.py:40:5: PT018 Assertion should be broken down into multiple parts +PT018 Assertion should be broken down into multiple parts + --> PT018.py:40:5 | 38 | assert not (something or something_else and something_third), "with message" 39 | # detected, but no fix for mixed conditions (e.g. `a or b and c`) 40 | assert not (something or something_else and something_third) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts -PT018.py:44:1: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:44:1 | 43 | assert something # OK 44 | assert something and something_else # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | assert something and something_else and something_third # Error | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 41 41 | @@ -300,14 +315,15 @@ PT018.py:44:1: PT018 [*] Assertion should be broken down into multiple parts 46 47 | 47 48 | -PT018.py:45:1: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:45:1 | 43 | assert something # OK 44 | assert something and something_else # Error 45 | assert something and something_else and something_third # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 42 42 | @@ -320,36 +336,40 @@ PT018.py:45:1: PT018 [*] Assertion should be broken down into multiple parts 47 48 | 48 49 | def test_multiline(): -PT018.py:49:5: PT018 Assertion should be broken down into multiple parts +PT018 Assertion should be broken down into multiple parts + --> PT018.py:49:5 | 48 | def test_multiline(): 49 | assert something and something_else; x = 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | x = 1; assert something and something_else | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts -PT018.py:51:12: PT018 Assertion should be broken down into multiple parts +PT018 Assertion should be broken down into multiple parts + --> PT018.py:51:12 | 49 | assert something and something_else; x = 1 50 | 51 | x = 1; assert something and something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | 53 | x = 1; \ | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts -PT018.py:54:9: PT018 Assertion should be broken down into multiple parts +PT018 Assertion should be broken down into multiple parts + --> PT018.py:54:9 | 53 | x = 1; \ 54 | assert something and something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts -PT018.py:59:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:59:5 | 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7143 58 | def test_parenthesized_not(): @@ -358,11 +378,11 @@ PT018.py:59:5: PT018 [*] Assertion should be broken down into multiple parts 61 | | or self.find_graph_input(node.input[0]) 62 | | or self.find_graph_output(node.input[0]) 63 | | ) - | |_____^ PT018 + | |_____^ 64 | 65 | assert (not ( | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 59 59 | assert not ( @@ -377,7 +397,8 @@ PT018.py:59:5: PT018 [*] Assertion should be broken down into multiple parts 65 67 | assert (not ( 66 68 | self.find_graph_output(node.output[0]) -PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts +PT018 [*] Assertion should be broken down into multiple parts + --> PT018.py:65:5 | 63 | ) 64 | @@ -386,11 +407,11 @@ PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts 67 | | or self.find_graph_input(node.input[0]) 68 | | or self.find_graph_output(node.input[0]) 69 | | )) - | |______^ PT018 + | |______^ 70 | 71 | assert (not self.find_graph_output(node.output[0]) or | - = help: Break down assertion into multiple parts +help: Break down assertion into multiple parts ℹ Unsafe fix 62 62 | or self.find_graph_output(node.input[0]) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT019.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT019.snap index 2c2abc05e4..fa02f669c1 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT019.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT019.snap @@ -1,32 +1,36 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT019.py:9:14: PT019 Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead +PT019 Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead + --> PT019.py:9:14 | 9 | def test_xxx(_fixture): # Error arg - | ^^^^^^^^ PT019 + | ^^^^^^^^ 10 | pass | -PT019.py:13:17: PT019 Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead +PT019 Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead + --> PT019.py:13:17 | 13 | def test_xxx(*, _fixture): # Error kwonly - | ^^^^^^^^ PT019 + | ^^^^^^^^ 14 | pass | -PT019.py:31:24: PT019 Fixture `_bar` without value is injected as parameter, use `@pytest.mark.usefixtures` instead +PT019 Fixture `_bar` without value is injected as parameter, use `@pytest.mark.usefixtures` instead + --> PT019.py:31:24 | 30 | @pytest.mark.parametrize("_foo", [1, 2, 3]) 31 | def test_thingy2(_foo, _bar): # Error _bar is not defined in parametrize - | ^^^^ PT019 + | ^^^^ 32 | pass | -PT019.py:39:24: PT019 Fixture `_bar` without value is injected as parameter, use `@pytest.mark.usefixtures` instead +PT019 Fixture `_bar` without value is injected as parameter, use `@pytest.mark.usefixtures` instead + --> PT019.py:39:24 | 38 | @pytest.mark.parametrize(("_foo"), [1, 2, 3]) 39 | def test_thingy4(_foo, _bar): # Error _bar is not defined in parametrize - | ^^^^ PT019 + | ^^^^ 40 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT020.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT020.snap index 40b10db9ef..f792f81672 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT020.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT020.snap @@ -1,19 +1,20 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT020.py:14:1: PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` +PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` + --> PT020.py:14:1 | 14 | @pytest.yield_fixture() - | ^^^^^^^^^^^^^^^^^^^^^^^ PT020 + | ^^^^^^^^^^^^^^^^^^^^^^^ 15 | def error_without_parens(): 16 | return 0 | -PT020.py:19:1: PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` +PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` + --> PT020.py:19:1 | 19 | @pytest.yield_fixture - | ^^^^^^^^^^^^^^^^^^^^^ PT020 + | ^^^^^^^^^^^^^^^^^^^^^ 20 | def error_with_parens(): 21 | return 0 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT021.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT021.snap index b406e3998e..fd7ceb373b 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT021.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT021.snap @@ -1,22 +1,23 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT021.py:49:5: PT021 Use `yield` instead of `request.addfinalizer` +PT021 Use `yield` instead of `request.addfinalizer` + --> PT021.py:49:5 | 47 | def my_fixture(request): # Error return 48 | resource = acquire_resource() 49 | request.addfinalizer(resource.release) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT021 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | return resource | -PT021.py:56:5: PT021 Use `yield` instead of `request.addfinalizer` +PT021 Use `yield` instead of `request.addfinalizer` + --> PT021.py:56:5 | 54 | def my_fixture(request): # Error yield 55 | resource = acquire_resource() 56 | request.addfinalizer(resource.release) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT021 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 57 | yield resource 58 | resource # prevent PT022 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap index bacf1e2170..9fd4aa5ea5 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT022.py:17:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` +PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` + --> PT022.py:17:5 | 15 | def error(): 16 | resource = acquire_resource() 17 | yield resource - | ^^^^^^^^^^^^^^ PT022 + | ^^^^^^^^^^^^^^ | - = help: Replace `yield` with `return` +help: Replace `yield` with `return` ℹ Safe fix 14 14 | @pytest.fixture() @@ -21,14 +21,15 @@ PT022.py:17:5: PT022 [*] No teardown in fixture `error`, use `return` instead of 19 19 | 20 20 | import typing -PT022.py:37:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` +PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` + --> PT022.py:37:5 | 35 | def error() -> typing.Generator[typing.Any, None, None]: 36 | resource = acquire_resource() 37 | yield resource - | ^^^^^^^^^^^^^^ PT022 + | ^^^^^^^^^^^^^^ | - = help: Replace `yield` with `return` +help: Replace `yield` with `return` ℹ Safe fix 32 32 | @@ -43,14 +44,15 @@ PT022.py:37:5: PT022 [*] No teardown in fixture `error`, use `return` instead of 39 39 | 40 40 | @pytest.fixture() -PT022.py:43:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` +PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` + --> PT022.py:43:5 | 41 | def error() -> Generator[Resource, None, None]: 42 | resource = acquire_resource() 43 | yield resource - | ^^^^^^^^^^^^^^ PT022 + | ^^^^^^^^^^^^^^ | - = help: Replace `yield` with `return` +help: Replace `yield` with `return` ℹ Safe fix 38 38 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap index b28b6da126..da2feb3179 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT023.py:51:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` +PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + --> PT023.py:51:1 | 51 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^^^ 52 | def test_something(): 53 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 48 48 | # With parentheses @@ -20,14 +21,15 @@ PT023.py:51:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` 53 53 | pass 54 54 | -PT023.py:56:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` +PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + --> PT023.py:56:1 | 56 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^^^ 57 | class TestClass: 58 | def test_something(): | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 53 53 | pass @@ -39,15 +41,16 @@ PT023.py:56:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` 58 58 | def test_something(): 59 59 | pass -PT023.py:63:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` +PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + --> PT023.py:63:5 | 62 | class TestClass: 63 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^^^ 64 | def test_something(): 65 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 60 60 | @@ -59,15 +62,16 @@ PT023.py:63:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` 65 65 | pass 66 66 | -PT023.py:69:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` +PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + --> PT023.py:69:5 | 68 | class TestClass: 69 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^^^ 70 | class TestNestedClass: 71 | def test_something(): | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 66 66 | @@ -79,16 +83,17 @@ PT023.py:69:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` 71 71 | def test_something(): 72 72 | pass -PT023.py:77:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` +PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + --> PT023.py:77:9 | 75 | class TestClass: 76 | class TestNestedClass: 77 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^^^ 78 | def test_something(): 79 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 74 74 | @@ -100,7 +105,8 @@ PT023.py:77:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` 79 79 | pass 80 80 | -PT023.py:82:1: PT023 [*] Use `@pytest.mark.parametrize` over `@pytest.mark.parametrize()` +PT023 [*] Use `@pytest.mark.parametrize` over `@pytest.mark.parametrize()` + --> PT023.py:82:1 | 81 | # https://github.com/astral-sh/ruff/issues/18770 82 | / @pytest.mark.parametrize( @@ -111,10 +117,10 @@ PT023.py:82:1: PT023 [*] Use `@pytest.mark.parametrize` over `@pytest.mark.param 87 | | # (3, 4), 88 | | # ), 89 | | ) - | |_^ PT023 + | |_^ 90 | def test_bar(param1, param2): ... | - = help: Remove parentheses +help: Remove parentheses ℹ Unsafe fix 79 79 | pass @@ -133,14 +139,15 @@ PT023.py:82:1: PT023 [*] Use `@pytest.mark.parametrize` over `@pytest.mark.param 91 84 | 92 85 | -PT023.py:93:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` +PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + --> PT023.py:93:1 | 93 | @(pytest.mark.foo()) - | ^^^^^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^^^^^ 94 | def test_outer_paren_mark_function(): 95 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 90 90 | def test_bar(param1, param2): ... @@ -152,15 +159,16 @@ PT023.py:93:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` 95 95 | pass 96 96 | -PT023.py:99:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` +PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + --> PT023.py:99:5 | 98 | class TestClass: 99 | @(pytest.mark.foo()) - | ^^^^^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^^^^^ 100 | def test_method_outer_paren(): 101 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 96 96 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_parentheses.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_parentheses.snap index a992327458..ea28de9fa3 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_parentheses.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_parentheses.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT023.py:17:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` +PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + --> PT023.py:17:1 | 17 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^ 18 | def test_something(): 19 | pass | - = help: Add parentheses +help: Add parentheses ℹ Safe fix 14 14 | # Without parentheses @@ -20,14 +21,15 @@ PT023.py:17:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` 19 19 | pass 20 20 | -PT023.py:22:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` +PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + --> PT023.py:22:1 | 22 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^ 23 | class TestClass: 24 | def test_something(): | - = help: Add parentheses +help: Add parentheses ℹ Safe fix 19 19 | pass @@ -39,15 +41,16 @@ PT023.py:22:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` 24 24 | def test_something(): 25 25 | pass -PT023.py:29:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` +PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + --> PT023.py:29:5 | 28 | class TestClass: 29 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^ 30 | def test_something(): 31 | pass | - = help: Add parentheses +help: Add parentheses ℹ Safe fix 26 26 | @@ -59,15 +62,16 @@ PT023.py:29:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` 31 31 | pass 32 32 | -PT023.py:35:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` +PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + --> PT023.py:35:5 | 34 | class TestClass: 35 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^ 36 | class TestNestedClass: 37 | def test_something(): | - = help: Add parentheses +help: Add parentheses ℹ Safe fix 32 32 | @@ -79,16 +83,17 @@ PT023.py:35:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` 37 37 | def test_something(): 38 38 | pass -PT023.py:43:9: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` +PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + --> PT023.py:43:9 | 41 | class TestClass: 42 | class TestNestedClass: 43 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 + | ^^^^^^^^^^^^^^^^ 44 | def test_something(): 45 | pass | - = help: Add parentheses +help: Add parentheses ℹ Safe fix 40 40 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap index b8d8a2f677..fa977bf675 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT024.py:14:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures +PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures + --> PT024.py:14:1 | 14 | @pytest.mark.asyncio() - | ^^^^^^^^^^^^^^^^^^^^^^ PT024 + | ^^^^^^^^^^^^^^^^^^^^^^ 15 | @pytest.fixture() 16 | async def my_fixture(): # Error before | - = help: Remove `pytest.mark.asyncio` +help: Remove `pytest.mark.asyncio` ℹ Safe fix 11 11 | pass @@ -20,14 +20,15 @@ PT024.py:14:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures 16 15 | async def my_fixture(): # Error before 17 16 | return 0 -PT024.py:20:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures +PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures + --> PT024.py:20:1 | 20 | @pytest.mark.asyncio - | ^^^^^^^^^^^^^^^^^^^^ PT024 + | ^^^^^^^^^^^^^^^^^^^^ 21 | @pytest.fixture() 22 | async def my_fixture(): # Error before no parens | - = help: Remove `pytest.mark.asyncio` +help: Remove `pytest.mark.asyncio` ℹ Safe fix 17 17 | return 0 @@ -38,15 +39,16 @@ PT024.py:20:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures 22 21 | async def my_fixture(): # Error before no parens 23 22 | return 0 -PT024.py:27:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures +PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures + --> PT024.py:27:1 | 26 | @pytest.fixture() 27 | @pytest.mark.asyncio() - | ^^^^^^^^^^^^^^^^^^^^^^ PT024 + | ^^^^^^^^^^^^^^^^^^^^^^ 28 | async def my_fixture(): # Error after 29 | return 0 | - = help: Remove `pytest.mark.asyncio` +help: Remove `pytest.mark.asyncio` ℹ Safe fix 24 24 | @@ -57,15 +59,16 @@ PT024.py:27:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures 29 28 | return 0 30 29 | -PT024.py:33:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures +PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures + --> PT024.py:33:1 | 32 | @pytest.fixture() 33 | @pytest.mark.asyncio - | ^^^^^^^^^^^^^^^^^^^^ PT024 + | ^^^^^^^^^^^^^^^^^^^^ 34 | async def my_fixture(): # Error after no parens 35 | return 0 | - = help: Remove `pytest.mark.asyncio` +help: Remove `pytest.mark.asyncio` ℹ Safe fix 30 30 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap index 0463f18a8b..f7b1fcc698 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT025.py:9:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures +PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures + --> PT025.py:9:1 | 9 | @pytest.mark.usefixtures("a") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT025 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | @pytest.fixture() 11 | def my_fixture(): # Error before | - = help: Remove `pytest.mark.usefixtures` +help: Remove `pytest.mark.usefixtures` ℹ Safe fix 6 6 | pass @@ -20,15 +20,16 @@ PT025.py:9:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures 11 10 | def my_fixture(): # Error before 12 11 | return 0 -PT025.py:16:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures +PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures + --> PT025.py:16:1 | 15 | @pytest.fixture() 16 | @pytest.mark.usefixtures("a") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT025 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | def my_fixture(): # Error after 18 | return 0 | - = help: Remove `pytest.mark.usefixtures` +help: Remove `pytest.mark.usefixtures` ℹ Safe fix 13 13 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap index 27461361c8..7ecf7d42de 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT026.py:19:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters +PT026 [*] Useless `pytest.mark.usefixtures` without parameters + --> PT026.py:19:1 | 19 | @pytest.mark.usefixtures() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | def test_error_with_parens(): 21 | pass | - = help: Remove `usefixtures` decorator or pass parameters +help: Remove `usefixtures` decorator or pass parameters ℹ Unsafe fix 16 16 | pass @@ -21,14 +21,15 @@ PT026.py:19:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters 21 21 | pass 22 22 | -PT026.py:24:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters +PT026 [*] Useless `pytest.mark.usefixtures` without parameters + --> PT026.py:24:1 | 24 | @pytest.mark.usefixtures - | ^^^^^^^^^^^^^^^^^^^^^^^^ PT026 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 25 | def test_error_no_parens(): 26 | pass | - = help: Remove `usefixtures` decorator or pass parameters +help: Remove `usefixtures` decorator or pass parameters ℹ Unsafe fix 21 21 | pass diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap index 33e15bb5b0..616ea019da 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT027_0.py:6:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_0.py:6:14 | 4 | class Test(unittest.TestCase): 5 | def test_errors(self): 6 | with self.assertRaises(ValueError): - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 7 | raise ValueError 8 | with self.assertRaises(expected_exception=ValueError): | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` ℹ Unsafe fix 1 1 | import unittest @@ -25,15 +26,16 @@ PT027_0.py:6:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assert 8 9 | with self.assertRaises(expected_exception=ValueError): 9 10 | raise ValueError -PT027_0.py:8:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_0.py:8:14 | 6 | with self.assertRaises(ValueError): 7 | raise ValueError 8 | with self.assertRaises(expected_exception=ValueError): - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 9 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` ℹ Unsafe fix 1 1 | import unittest @@ -50,15 +52,16 @@ PT027_0.py:8:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assert 10 11 | 11 12 | with self.failUnlessRaises(ValueError): -PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failUnlessRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `failUnlessRaises` + --> PT027_0.py:11:14 | 9 | raise ValueError 10 | 11 | with self.failUnlessRaises(ValueError): - | ^^^^^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^^^^^ 12 | raise ValueError | - = help: Replace `failUnlessRaises` with `pytest.raises` +help: Replace `failUnlessRaises` with `pytest.raises` ℹ Unsafe fix 1 1 | import unittest @@ -76,15 +79,16 @@ PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failU 13 14 | 14 15 | with self.assertRaisesRegex(ValueError, "test"): -PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + --> PT027_0.py:14:14 | 12 | raise ValueError 13 | 14 | with self.assertRaisesRegex(ValueError, "test"): - | ^^^^^^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^^^^^^ 15 | raise ValueError("test") | - = help: Replace `assertRaisesRegex` with `pytest.raises` +help: Replace `assertRaisesRegex` with `pytest.raises` ℹ Unsafe fix 1 1 | import unittest @@ -102,15 +106,16 @@ PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 16 17 | 17 18 | with self.assertRaisesRegex(ValueError, expected_regex="test"): -PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + --> PT027_0.py:17:14 | 15 | raise ValueError("test") 16 | 17 | with self.assertRaisesRegex(ValueError, expected_regex="test"): - | ^^^^^^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^^^^^^ 18 | raise ValueError("test") | - = help: Replace `assertRaisesRegex` with `pytest.raises` +help: Replace `assertRaisesRegex` with `pytest.raises` ℹ Unsafe fix 1 1 | import unittest @@ -128,16 +133,17 @@ PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 19 20 | 20 21 | with self.assertRaisesRegex( -PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + --> PT027_0.py:20:14 | 18 | raise ValueError("test") 19 | 20 | with self.assertRaisesRegex( - | ^^^^^^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^^^^^^ 21 | expected_exception=ValueError, expected_regex="test" 22 | ): | - = help: Replace `assertRaisesRegex` with `pytest.raises` +help: Replace `assertRaisesRegex` with `pytest.raises` ℹ Unsafe fix 1 1 | import unittest @@ -157,16 +163,17 @@ PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 24 23 | 25 24 | with self.assertRaisesRegex( -PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + --> PT027_0.py:25:14 | 23 | raise ValueError("test") 24 | 25 | with self.assertRaisesRegex( - | ^^^^^^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^^^^^^ 26 | expected_regex="test", expected_exception=ValueError 27 | ): | - = help: Replace `assertRaisesRegex` with `pytest.raises` +help: Replace `assertRaisesRegex` with `pytest.raises` ℹ Unsafe fix 1 1 | import unittest @@ -186,15 +193,16 @@ PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 29 28 | 30 29 | with self.assertRaisesRegexp(ValueError, "test"): -PT027_0.py:30:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegexp` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegexp` + --> PT027_0.py:30:14 | 28 | raise ValueError("test") 29 | 30 | with self.assertRaisesRegexp(ValueError, "test"): - | ^^^^^^^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^^^^^^^ 31 | raise ValueError("test") | - = help: Replace `assertRaisesRegexp` with `pytest.raises` +help: Replace `assertRaisesRegexp` with `pytest.raises` ℹ Unsafe fix 1 1 | import unittest @@ -212,34 +220,37 @@ PT027_0.py:30:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 32 33 | 33 34 | def test_unfixable_errors(self): -PT027_0.py:34:14: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_0.py:34:14 | 33 | def test_unfixable_errors(self): 34 | with self.assertRaises(ValueError, msg="msg"): - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 35 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` -PT027_0.py:37:14: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_0.py:37:14 | 35 | raise ValueError 36 | 37 | with self.assertRaises( - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 38 | # comment 39 | ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` -PT027_0.py:44:13: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_0.py:44:13 | 43 | with ( 44 | / self 45 | | # comment 46 | | .assertRaises(ValueError) - | |_________________________^ PT027 + | |_________________________^ 47 | ): 48 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap index 3b79a1afa3..4003cfd7a4 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT027_1.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_1.py:11:14 | 10 | def test_errors(self): 11 | with self.assertRaises(ValueError): - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 12 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` ℹ Unsafe fix 8 8 | raise ValueError @@ -20,14 +21,15 @@ PT027_1.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 13 13 | 14 14 | def test_rewrite_references(self): -PT027_1.py:15:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_1.py:15:14 | 14 | def test_rewrite_references(self): 15 | with self.assertRaises(ValueError) as e: - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 16 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` ℹ Unsafe fix 12 12 | raise ValueError @@ -44,15 +46,16 @@ PT027_1.py:15:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 21 21 | def test_rewrite_references_multiple_items(self): 22 22 | with self.assertRaises(ValueError) as e1, \ -PT027_1.py:22:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_1.py:22:14 | 21 | def test_rewrite_references_multiple_items(self): 22 | with self.assertRaises(ValueError) as e1, \ - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 23 | self.assertRaises(ValueError) as e2: 24 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` ℹ Unsafe fix 19 19 | print(e.exception) @@ -70,15 +73,16 @@ PT027_1.py:22:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 29 29 | print(e2.foo) 30 30 | print(e2.exception) -PT027_1.py:23:13: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_1.py:23:13 | 21 | def test_rewrite_references_multiple_items(self): 22 | with self.assertRaises(ValueError) as e1, \ 23 | self.assertRaises(ValueError) as e2: - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 24 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` ℹ Unsafe fix 20 20 | @@ -98,15 +102,16 @@ PT027_1.py:23:13: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 32 32 | def test_rewrite_references_multiple_items_nested(self): 33 33 | with self.assertRaises(ValueError) as e1, \ -PT027_1.py:33:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_1.py:33:14 | 32 | def test_rewrite_references_multiple_items_nested(self): 33 | with self.assertRaises(ValueError) as e1, \ - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 34 | foo(self.assertRaises(ValueError)) as e2: 35 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` ℹ Unsafe fix 30 30 | print(e2.exception) @@ -124,15 +129,16 @@ PT027_1.py:33:14: PT027 [*] Use `pytest.raises` instead of unittest-style `asser 40 40 | print(e2.foo) 41 41 | print(e2.exception) -PT027_1.py:34:17: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` +PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + --> PT027_1.py:34:17 | 32 | def test_rewrite_references_multiple_items_nested(self): 33 | with self.assertRaises(ValueError) as e1, \ 34 | foo(self.assertRaises(ValueError)) as e2: - | ^^^^^^^^^^^^^^^^^ PT027 + | ^^^^^^^^^^^^^^^^^ 35 | raise ValueError | - = help: Replace `assertRaises` with `pytest.raises` +help: Replace `assertRaises` with `pytest.raises` ℹ Unsafe fix 31 31 | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT028.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT028.snap index 88b10b57c9..8b2d5c395f 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT028.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT028.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT028.py:3:16: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:3:16 | 1 | # Errors 2 | 3 | def test_foo(a=1): ... - | ^ PT028 + | ^ 4 | def test_foo(a = 1): ... 5 | def test_foo(a = (1)): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 1 1 | # Errors @@ -21,15 +22,16 @@ PT028.py:3:16: PT028 Test function parameter `a` has default argument 5 5 | def test_foo(a = (1)): ... 6 6 | def test_foo(a: int=1): ... -PT028.py:4:18: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:4:18 | 3 | def test_foo(a=1): ... 4 | def test_foo(a = 1): ... - | ^ PT028 + | ^ 5 | def test_foo(a = (1)): ... 6 | def test_foo(a: int=1): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 1 1 | # Errors @@ -41,16 +43,17 @@ PT028.py:4:18: PT028 Test function parameter `a` has default argument 6 6 | def test_foo(a: int=1): ... 7 7 | def test_foo(a: int = 1): ... -PT028.py:5:19: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:5:19 | 3 | def test_foo(a=1): ... 4 | def test_foo(a = 1): ... 5 | def test_foo(a = (1)): ... - | ^ PT028 + | ^ 6 | def test_foo(a: int=1): ... 7 | def test_foo(a: int = 1): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 2 2 | @@ -62,16 +65,17 @@ PT028.py:5:19: PT028 Test function parameter `a` has default argument 7 7 | def test_foo(a: int = 1): ... 8 8 | def test_foo(a: (int) = 1): ... -PT028.py:6:21: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:6:21 | 4 | def test_foo(a = 1): ... 5 | def test_foo(a = (1)): ... 6 | def test_foo(a: int=1): ... - | ^ PT028 + | ^ 7 | def test_foo(a: int = 1): ... 8 | def test_foo(a: (int) = 1): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 3 3 | def test_foo(a=1): ... @@ -83,16 +87,17 @@ PT028.py:6:21: PT028 Test function parameter `a` has default argument 8 8 | def test_foo(a: (int) = 1): ... 9 9 | def test_foo(a: int = (1)): ... -PT028.py:7:23: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:7:23 | 5 | def test_foo(a = (1)): ... 6 | def test_foo(a: int=1): ... 7 | def test_foo(a: int = 1): ... - | ^ PT028 + | ^ 8 | def test_foo(a: (int) = 1): ... 9 | def test_foo(a: int = (1)): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 4 4 | def test_foo(a = 1): ... @@ -104,16 +109,17 @@ PT028.py:7:23: PT028 Test function parameter `a` has default argument 9 9 | def test_foo(a: int = (1)): ... 10 10 | def test_foo(a: (int) = (1)): ... -PT028.py:8:25: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:8:25 | 6 | def test_foo(a: int=1): ... 7 | def test_foo(a: int = 1): ... 8 | def test_foo(a: (int) = 1): ... - | ^ PT028 + | ^ 9 | def test_foo(a: int = (1)): ... 10 | def test_foo(a: (int) = (1)): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 5 5 | def test_foo(a = (1)): ... @@ -125,16 +131,17 @@ PT028.py:8:25: PT028 Test function parameter `a` has default argument 10 10 | def test_foo(a: (int) = (1)): ... 11 11 | def test_foo(a=1, /, b=2, *, c=3): ... -PT028.py:9:24: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:9:24 | 7 | def test_foo(a: int = 1): ... 8 | def test_foo(a: (int) = 1): ... 9 | def test_foo(a: int = (1)): ... - | ^ PT028 + | ^ 10 | def test_foo(a: (int) = (1)): ... 11 | def test_foo(a=1, /, b=2, *, c=3): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 6 6 | def test_foo(a: int=1): ... @@ -146,15 +153,16 @@ PT028.py:9:24: PT028 Test function parameter `a` has default argument 11 11 | def test_foo(a=1, /, b=2, *, c=3): ... 12 12 | -PT028.py:10:26: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:10:26 | 8 | def test_foo(a: (int) = 1): ... 9 | def test_foo(a: int = (1)): ... 10 | def test_foo(a: (int) = (1)): ... - | ^ PT028 + | ^ 11 | def test_foo(a=1, /, b=2, *, c=3): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 7 7 | def test_foo(a: int = 1): ... @@ -166,14 +174,15 @@ PT028.py:10:26: PT028 Test function parameter `a` has default argument 12 12 | 13 13 | -PT028.py:11:16: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> PT028.py:11:16 | 9 | def test_foo(a: int = (1)): ... 10 | def test_foo(a: (int) = (1)): ... 11 | def test_foo(a=1, /, b=2, *, c=3): ... - | ^ PT028 + | ^ | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 8 8 | def test_foo(a: (int) = 1): ... @@ -185,14 +194,15 @@ PT028.py:11:16: PT028 Test function parameter `a` has default argument 13 13 | 14 14 | # No errors -PT028.py:11:24: PT028 Test function parameter `b` has default argument +PT028 Test function parameter `b` has default argument + --> PT028.py:11:24 | 9 | def test_foo(a: int = (1)): ... 10 | def test_foo(a: (int) = (1)): ... 11 | def test_foo(a=1, /, b=2, *, c=3): ... - | ^ PT028 + | ^ | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 8 8 | def test_foo(a: (int) = 1): ... @@ -204,14 +214,15 @@ PT028.py:11:24: PT028 Test function parameter `b` has default argument 13 13 | 14 14 | # No errors -PT028.py:11:32: PT028 Test function parameter `c` has default argument +PT028 Test function parameter `c` has default argument + --> PT028.py:11:32 | 9 | def test_foo(a: int = (1)): ... 10 | def test_foo(a: (int) = (1)): ... 11 | def test_foo(a=1, /, b=2, *, c=3): ... - | ^ PT028 + | ^ | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 8 8 | def test_foo(a: (int) = 1): ... diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT029.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT029.snap index 0806d2d4f5..b52c47d5ff 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT029.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT029.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT029.py:5:10: PT029 Set the expected warning in `pytest.warns()` +PT029 Set the expected warning in `pytest.warns()` + --> PT029.py:5:10 | 4 | def test_ok(): 5 | with pytest.warns(): - | ^^^^^^^^^^^^ PT029 + | ^^^^^^^^^^^^ 6 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_default.snap index 8e791ec77e..512c913827 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_default.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_default.snap @@ -1,45 +1,50 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT030.py:16:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:16:23 | 15 | def test_error_no_argument_given(): 16 | with pytest.warns(UserWarning): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 17 | pass | -PT030.py:19:40: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:19:40 | 17 | pass 18 | 19 | with pytest.warns(expected_warning=UserWarning): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 20 | pass | -PT030.py:27:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:27:23 | 26 | def test_error_match_is_empty(): 27 | with pytest.warns(UserWarning, match=None): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 28 | pass | -PT030.py:30:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:30:23 | 28 | pass 29 | 30 | with pytest.warns(UserWarning, match=""): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 31 | pass | -PT030.py:33:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:33:23 | 31 | pass 32 | 33 | with pytest.warns(UserWarning, match=f""): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 34 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_extend_broad_exceptions.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_extend_broad_exceptions.snap index 7eaf4703e1..1321136737 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_extend_broad_exceptions.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_extend_broad_exceptions.snap @@ -1,53 +1,59 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT030.py:11:23: PT030 `pytest.warns(EncodingWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(EncodingWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:11:23 | 10 | def test_ok_different_error_from_config(): 11 | with pytest.warns(EncodingWarning): - | ^^^^^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^^^^^ 12 | pass | -PT030.py:16:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:16:23 | 15 | def test_error_no_argument_given(): 16 | with pytest.warns(UserWarning): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 17 | pass | -PT030.py:19:40: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:19:40 | 17 | pass 18 | 19 | with pytest.warns(expected_warning=UserWarning): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 20 | pass | -PT030.py:27:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:27:23 | 26 | def test_error_match_is_empty(): 27 | with pytest.warns(UserWarning, match=None): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 28 | pass | -PT030.py:30:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:30:23 | 28 | pass 29 | 30 | with pytest.warns(UserWarning, match=""): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 31 | pass | -PT030.py:33:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:33:23 | 31 | pass 32 | 33 | with pytest.warns(UserWarning, match=f""): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 34 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_glob_all.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_glob_all.snap index 11c8873f1f..3b3bd5ddd8 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_glob_all.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_glob_all.snap @@ -1,62 +1,69 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT030.py:11:23: PT030 `pytest.warns(EncodingWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(EncodingWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:11:23 | 10 | def test_ok_different_error_from_config(): 11 | with pytest.warns(EncodingWarning): - | ^^^^^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^^^^^ 12 | pass | -PT030.py:16:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:16:23 | 15 | def test_error_no_argument_given(): 16 | with pytest.warns(UserWarning): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 17 | pass | -PT030.py:19:40: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:19:40 | 17 | pass 18 | 19 | with pytest.warns(expected_warning=UserWarning): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 20 | pass | -PT030.py:22:23: PT030 `pytest.warns(foo.FooWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(foo.FooWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:22:23 | 20 | pass 21 | 22 | with pytest.warns(FooWarning): - | ^^^^^^^^^^ PT030 + | ^^^^^^^^^^ 23 | pass | -PT030.py:27:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:27:23 | 26 | def test_error_match_is_empty(): 27 | with pytest.warns(UserWarning, match=None): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 28 | pass | -PT030.py:30:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:30:23 | 28 | pass 29 | 30 | with pytest.warns(UserWarning, match=""): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 31 | pass | -PT030.py:33:23: PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(UserWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:33:23 | 31 | pass 32 | 33 | with pytest.warns(UserWarning, match=f""): - | ^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^ 34 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_glob_prefix.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_glob_prefix.snap index b939b1a658..890641ea45 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_glob_prefix.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_glob_prefix.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT030.py:22:23: PT030 `pytest.warns(foo.FooWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(foo.FooWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:22:23 | 20 | pass 21 | 22 | with pytest.warns(FooWarning): - | ^^^^^^^^^^ PT030 + | ^^^^^^^^^^ 23 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_replace_broad_exceptions.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_replace_broad_exceptions.snap index 4268e3a690..1535f7fbfc 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_replace_broad_exceptions.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT030_replace_broad_exceptions.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs -snapshot_kind: text --- -PT030.py:11:23: PT030 `pytest.warns(EncodingWarning)` is too broad, set the `match` parameter or use a more specific warning +PT030 `pytest.warns(EncodingWarning)` is too broad, set the `match` parameter or use a more specific warning + --> PT030.py:11:23 | 10 | def test_ok_different_error_from_config(): 11 | with pytest.warns(EncodingWarning): - | ^^^^^^^^^^^^^^^ PT030 + | ^^^^^^^^^^^^^^^ 12 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT031.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT031.snap index ebf9e8b2fc..498b32eacf 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT031.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT031.snap @@ -1,63 +1,69 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -PT031.py:42:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:42:5 | 41 | def test_error_multiple_statements(): 42 | / with pytest.warns(UserWarning): 43 | | foo() 44 | | bar() - | |_____________^ PT031 + | |_____________^ | -PT031.py:48:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:48:5 | 47 | async def test_error_complex_statement(): 48 | / with pytest.warns(UserWarning): 49 | | if True: 50 | | foo() - | |_________________^ PT031 + | |_________________^ 51 | 52 | with pytest.warns(UserWarning): | -PT031.py:52:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:52:5 | 50 | foo() 51 | 52 | / with pytest.warns(UserWarning): 53 | | for i in []: 54 | | foo() - | |_________________^ PT031 + | |_________________^ 55 | 56 | with pytest.warns(UserWarning): | -PT031.py:56:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:56:5 | 54 | foo() 55 | 56 | / with pytest.warns(UserWarning): 57 | | async for i in []: 58 | | foo() - | |_________________^ PT031 + | |_________________^ 59 | 60 | with pytest.warns(UserWarning): | -PT031.py:60:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:60:5 | 58 | foo() 59 | 60 | / with pytest.warns(UserWarning): 61 | | while True: 62 | | foo() - | |_________________^ PT031 + | |_________________^ 63 | 64 | with pytest.warns(UserWarning): | -PT031.py:64:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:64:5 | 62 | foo() 63 | @@ -65,10 +71,11 @@ PT031.py:64:5: PT031 `pytest.warns()` block should contain a single simple state 65 | | async with context_manager_under_test(): 66 | | if True: 67 | | foo() - | |_____________________^ PT031 + | |_____________________^ | -PT031.py:71:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:71:5 | 70 | def test_error_try(): 71 | / with pytest.warns(UserWarning): @@ -76,51 +83,55 @@ PT031.py:71:5: PT031 `pytest.warns()` block should contain a single simple state 73 | | foo() 74 | | except: 75 | | raise - | |_________________^ PT031 + | |_________________^ | -PT031.py:83:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:83:5 | 81 | ## Errors 82 | 83 | / with pytest.warns(RuntimeError): 84 | | for a in b: 85 | | print() - | |___________________^ PT031 + | |___________________^ 86 | 87 | with pytest.warns(RuntimeError): | -PT031.py:87:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:87:5 | 85 | print() 86 | 87 | / with pytest.warns(RuntimeError): 88 | | for a in b: 89 | | assert foo - | |______________________^ PT031 + | |______________________^ 90 | 91 | with pytest.warns(RuntimeError): | -PT031.py:91:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:91:5 | 89 | assert foo 90 | 91 | / with pytest.warns(RuntimeError): 92 | | async for a in b: 93 | | print() - | |___________________^ PT031 + | |___________________^ 94 | 95 | with pytest.warns(RuntimeError): | -PT031.py:95:5: PT031 `pytest.warns()` block should contain a single simple statement +PT031 `pytest.warns()` block should contain a single simple statement + --> PT031.py:95:5 | 93 | print() 94 | 95 | / with pytest.warns(RuntimeError): 96 | | async for a in b: 97 | | assert foo - | |______________________^ PT031 + | |______________________^ | diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__is_pytest_test.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__is_pytest_test.snap index 66b3fc1395..9543b3f3d0 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__is_pytest_test.snap +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__is_pytest_test.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs --- -is_pytest_test.py:3:27: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> is_pytest_test.py:3:27 | 1 | # Errors 2 | 3 | def test_this_is_a_test(a=1): ... - | ^ PT028 + | ^ 4 | def testThisIsAlsoATest(a=1): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 1 1 | # Errors @@ -20,15 +21,16 @@ is_pytest_test.py:3:27: PT028 Test function parameter `a` has default argument 5 5 | 6 6 | class TestClass: -is_pytest_test.py:4:27: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> is_pytest_test.py:4:27 | 3 | def test_this_is_a_test(a=1): ... 4 | def testThisIsAlsoATest(a=1): ... - | ^ PT028 + | ^ 5 | 6 | class TestClass: | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 1 1 | # Errors @@ -40,14 +42,15 @@ is_pytest_test.py:4:27: PT028 Test function parameter `a` has default argument 6 6 | class TestClass: 7 7 | def test_this_too_is_a_test(self, a=1): ... -is_pytest_test.py:7:41: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> is_pytest_test.py:7:41 | 6 | class TestClass: 7 | def test_this_too_is_a_test(self, a=1): ... - | ^ PT028 + | ^ 8 | def testAndOfCourseThis(self, a=1): ... | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 4 4 | def testThisIsAlsoATest(a=1): ... @@ -59,14 +62,15 @@ is_pytest_test.py:7:41: PT028 Test function parameter `a` has default argument 9 9 | 10 10 | -is_pytest_test.py:8:37: PT028 Test function parameter `a` has default argument +PT028 Test function parameter `a` has default argument + --> is_pytest_test.py:8:37 | 6 | class TestClass: 7 | def test_this_too_is_a_test(self, a=1): ... 8 | def testAndOfCourseThis(self, a=1): ... - | ^ PT028 + | ^ | - = help: Remove default argument +help: Remove default argument ℹ Display-only fix 5 5 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap index 39a104d5b5..62729525e2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_docstring_doubles_all.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -doubles_all.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> doubles_all.py:1:1 | 1 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | 3 | this_is_an_inline_string = "double quote string" | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 1 |-"""This is a docstring.""" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap index 617c8d4d99..a0edc0e992 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_inline_doubles_all.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -doubles_all.py:3:28: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_all.py:3:28 | 1 | """This is a docstring.""" 2 | 3 | this_is_an_inline_string = "double quote string" - | ^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | this_is_a_multiline_string = """ | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 1 1 | """This is a docstring.""" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap index 2edceeb830..67c0fe2790 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__only_multiline_doubles_all.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -doubles_all.py:5:30: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> doubles_all.py:5:30 | 3 | this_is_an_inline_string = "double quote string" 4 | @@ -9,9 +10,9 @@ doubles_all.py:5:30: Q001 [*] Double quote multiline found but single quotes pre | ______________________________^ 6 | | double quote string 7 | | """ - | |___^ Q001 + | |___^ | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap index 4f3a569bde..030181a37c 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap @@ -1,18 +1,19 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles.py:5:1: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles.py:5:1 | 3 | """ 4 | 5 | / """ 6 | | this is not a docstring 7 | | """ - | |___^ Q001 + | |___^ 8 | 9 | l = [] | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 2 2 | Double quotes multiline module docstring @@ -27,18 +28,19 @@ docstring_doubles.py:5:1: Q001 [*] Double quote multiline found but single quote 9 9 | l = [] 10 10 | -docstring_doubles.py:16:5: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles.py:16:5 | 14 | """ 15 | 16 | / """ 17 | | this is not a docstring 18 | | """ - | |_______^ Q001 + | |_______^ 19 | 20 | # The colon in the list indexing below is an edge case for the docstring scanner | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 13 13 | Double quotes multiline class docstring @@ -53,17 +55,18 @@ docstring_doubles.py:16:5: Q001 [*] Double quote multiline found but single quot 20 20 | # The colon in the list indexing below is an edge case for the docstring scanner 21 21 | def f(self, bar=""" -docstring_doubles.py:21:21: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles.py:21:21 | 20 | # The colon in the list indexing below is an edge case for the docstring scanner 21 | def f(self, bar=""" | _____________________^ 22 | | definitely not a docstring""", - | |_____________________________________^ Q001 + | |_____________________________________^ 23 | val=l[Cls():3]): 24 | """ | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 18 18 | """ @@ -77,18 +80,19 @@ docstring_doubles.py:21:21: Q001 [*] Double quote multiline found but single quo 24 24 | """ 25 25 | Double quotes multiline function docstring -docstring_doubles.py:30:9: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles.py:30:9 | 28 | some_expression = 'hello world' 29 | 30 | / """ 31 | | this is not a docstring 32 | | """ - | |___________^ Q001 + | |___________^ 33 | 34 | if l: | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 27 27 | @@ -103,16 +107,17 @@ docstring_doubles.py:30:9: Q001 [*] Double quote multiline found but single quot 34 34 | if l: 35 35 | """ -docstring_doubles.py:35:13: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles.py:35:13 | 34 | if l: 35 | / """ 36 | | Looks like a docstring, but in reality it isn't - only modules, classes and functions 37 | | """ - | |_______________^ Q001 + | |_______________^ 38 | pass | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 32 32 | """ diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap index 400d7ae38e..c210842afe 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_class.py:3:5 | 1 | class SingleLineDocstrings(): 2 | """ Double quotes single line class docstring """ 3 | """ Not a docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | def foo(self, bar="""not a docstring"""): | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 1 1 | class SingleLineDocstrings(): @@ -21,16 +22,17 @@ docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single 5 5 | def foo(self, bar="""not a docstring"""): 6 6 | """ Double quotes single line method docstring""" -docstring_doubles_class.py:5:23: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_class.py:5:23 | 3 | """ Not a docstring """ 4 | 5 | def foo(self, bar="""not a docstring"""): - | ^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | """ Double quotes single line method docstring""" 7 | pass | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 2 2 | """ Double quotes single line class docstring """ diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap index c679542311..0384d64108 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -docstring_doubles_function.py:3:5: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_function.py:3:5 | 1 | def foo(): 2 | """function without params, single line docstring""" 3 | """ not a docstring""" - | ^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^ 4 | return | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 1 1 | def foo(): @@ -21,15 +21,16 @@ docstring_doubles_function.py:3:5: Q001 [*] Double quote multiline found but sin 5 5 | 6 6 | -docstring_doubles_function.py:11:5: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_function.py:11:5 | 9 | function without params, multiline docstring 10 | """ 11 | """ not a docstring""" - | ^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^ 12 | return | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 8 8 | """ @@ -41,16 +42,17 @@ docstring_doubles_function.py:11:5: Q001 [*] Double quote multiline found but si 13 13 | 14 14 | -docstring_doubles_function.py:15:39: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_function.py:15:39 | 15 | def fun_with_params_no_docstring(a, b=""" | _______________________________________^ 16 | | not a 17 | | """ """docstring"""): - | |___^ Q001 + | |___^ 18 | pass | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 12 12 | return @@ -65,15 +67,16 @@ docstring_doubles_function.py:15:39: Q001 [*] Double quote multiline found but s 19 19 | 20 20 | -docstring_doubles_function.py:17:5: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_function.py:17:5 | 15 | def fun_with_params_no_docstring(a, b=""" 16 | not a 17 | """ """docstring"""): - | ^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^ 18 | pass | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 14 14 | @@ -85,14 +88,15 @@ docstring_doubles_function.py:17:5: Q001 [*] Double quote multiline found but si 19 19 | 20 20 | -docstring_doubles_function.py:22:5: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_function.py:22:5 | 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ 22 | """ not a docstring """): - | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 19 19 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap index f0a6a7feac..1c56a4705a 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap @@ -1,19 +1,19 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -docstring_doubles_module_multiline.py:4:1: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_module_multiline.py:4:1 | 2 | Double quotes multiline module docstring 3 | """ 4 | / """ 5 | | this is not a docstring 6 | | """ - | |___^ Q001 + | |___^ 7 | def foo(): 8 | pass | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 1 1 | """ @@ -28,16 +28,17 @@ docstring_doubles_module_multiline.py:4:1: Q001 [*] Double quote multiline found 8 8 | pass 9 9 | """ -docstring_doubles_module_multiline.py:9:1: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_module_multiline.py:9:1 | 7 | def foo(): 8 | pass 9 | / """ 10 | | this is not a docstring 11 | | """ - | |___^ Q001 + | |___^ | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 6 6 | """ diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap index b4aa9a7b1f..a979eb5f39 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles_module_singleline.py:2:1: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_module_singleline.py:2:1 | 1 | """ Double quotes singleline module docstring """ 2 | """ this is not a docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | def foo(): | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 1 1 | """ Double quotes singleline module docstring """ @@ -19,14 +20,15 @@ docstring_doubles_module_singleline.py:2:1: Q001 [*] Double quote multiline foun 4 4 | def foo(): 5 5 | pass -docstring_doubles_module_singleline.py:6:1: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_doubles_module_singleline.py:6:1 | 4 | def foo(): 5 | pass 6 | """ this is not a docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap index c73763820c..22c1903a00 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles.py:1:1 | 1 | / ''' 2 | | Single quotes multiline module docstring 3 | | ''' - | |___^ Q002 + | |___^ 4 | 5 | ''' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 |-''' @@ -22,18 +23,19 @@ docstring_singles.py:1:1: Q002 [*] Single quote docstring found but double quote 5 5 | ''' 6 6 | this is not a docstring -docstring_singles.py:14:5: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles.py:14:5 | 12 | class params \t not a docstring 13 | ''')): 14 | / ''' 15 | | Single quotes multiline class docstring 16 | | ''' - | |_______^ Q002 + | |_______^ 17 | 18 | ''' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 11 11 | class Cls(MakeKlass(''' @@ -48,18 +50,19 @@ docstring_singles.py:14:5: Q002 [*] Single quote docstring found but double quot 18 18 | ''' 19 19 | this is not a docstring -docstring_singles.py:26:9: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles.py:26:9 | 24 | definitely not a docstring''', 25 | val=l[Cls():3]): 26 | / ''' 27 | | Single quotes multiline function docstring 28 | | ''' - | |___________^ Q002 + | |___________^ 29 | 30 | some_expression = 'hello world' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 23 23 | def f(self, bar=''' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap index b384b9e645..395b9a33c2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles_class.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_class.py:2:5 | 1 | class SingleLineDocstrings(): 2 | ''' Double quotes single line class docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | ''' Not a docstring ''' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 1 | class SingleLineDocstrings(): @@ -18,14 +19,15 @@ docstring_singles_class.py:2:5: Q002 [*] Single quote docstring found but double 4 4 | 5 5 | def foo(self, bar='''not a docstring'''): -docstring_singles_class.py:6:9: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_class.py:6:9 | 5 | def foo(self, bar='''not a docstring'''): 6 | ''' Double quotes single line method docstring''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | pass | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 3 3 | ''' Not a docstring ''' @@ -37,14 +39,15 @@ docstring_singles_class.py:6:9: Q002 [*] Single quote docstring found but double 8 8 | 9 9 | class Nested(foo()[:]): ''' inline docstring '''; pass -docstring_singles_class.py:9:29: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_class.py:9:29 | 7 | pass 8 | 9 | class Nested(foo()[:]): ''' inline docstring '''; pass - | ^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 6 6 | ''' Double quotes single line method docstring''' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap index 5c0f5b436b..1b6cea3816 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles_function.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_function.py:2:5 | 1 | def foo(): 2 | '''function without params, single line docstring''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | ''' not a docstring''' 4 | return | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 1 | def foo(): @@ -19,17 +20,18 @@ docstring_singles_function.py:2:5: Q002 [*] Single quote docstring found but dou 4 4 | return 5 5 | -docstring_singles_function.py:8:5: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_function.py:8:5 | 7 | def foo2(): 8 | / ''' 9 | | function without params, multiline docstring 10 | | ''' - | |_______^ Q002 + | |_______^ 11 | ''' not a docstring''' 12 | return | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 5 5 | @@ -44,13 +46,14 @@ docstring_singles_function.py:8:5: Q002 [*] Single quote docstring found but dou 12 12 | return 13 13 | -docstring_singles_function.py:27:5: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_function.py:27:5 | 26 | def function_with_single_docstring(a): 27 | 'Single line docstring' - | ^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 24 24 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap index d231495a11..1f3455801f 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_1.py.snap @@ -1,23 +1,25 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles_mixed_quotes_class_var_1.py:2:5: Q002 Single quote docstring found but double quotes preferred +Q002 Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_1.py:2:5 | 1 | class SingleLineDocstrings(): 2 | ''"Start with empty string" ' and lint docstring safely' - | ^^ Q002 + | ^^ 3 | ''' Not a docstring ''' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes -docstring_singles_mixed_quotes_class_var_1.py:2:33: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_1.py:2:33 | 1 | class SingleLineDocstrings(): 2 | ''"Start with empty string" ' and lint docstring safely' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | ''' Not a docstring ''' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 1 | class SingleLineDocstrings(): @@ -27,23 +29,25 @@ docstring_singles_mixed_quotes_class_var_1.py:2:33: Q002 [*] Single quote docstr 4 4 | 5 5 | def foo(self, bar='''not a docstring'''): -docstring_singles_mixed_quotes_class_var_1.py:6:9: Q002 Single quote docstring found but double quotes preferred +Q002 Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_1.py:6:9 | 5 | def foo(self, bar='''not a docstring'''): 6 | ''"Start with empty string" ' and lint docstring safely' - | ^^ Q002 + | ^^ 7 | pass | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes -docstring_singles_mixed_quotes_class_var_1.py:6:37: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_1.py:6:37 | 5 | def foo(self, bar='''not a docstring'''): 6 | ''"Start with empty string" ' and lint docstring safely' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | pass | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 3 3 | ''' Not a docstring ''' @@ -55,23 +59,25 @@ docstring_singles_mixed_quotes_class_var_1.py:6:37: Q002 [*] Single quote docstr 8 8 | 9 9 | class Nested(foo()[:]): ''"Start with empty string" ' and lint docstring safely'; pass -docstring_singles_mixed_quotes_class_var_1.py:9:29: Q002 Single quote docstring found but double quotes preferred +Q002 Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_1.py:9:29 | 7 | pass 8 | 9 | class Nested(foo()[:]): ''"Start with empty string" ' and lint docstring safely'; pass - | ^^ Q002 + | ^^ | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes -docstring_singles_mixed_quotes_class_var_1.py:9:57: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_1.py:9:57 | 7 | pass 8 | 9 | class Nested(foo()[:]): ''"Start with empty string" ' and lint docstring safely'; pass - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 6 6 | ''"Start with empty string" ' and lint docstring safely' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap index 1346b4f188..a5bbb5620e 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_class_var_2.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles_mixed_quotes_class_var_2.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_2.py:2:5 | 1 | class SingleLineDocstrings(): 2 | 'Do not'" start with empty string" ' and lint docstring safely' - | ^^^^^^^^ Q002 + | ^^^^^^^^ 3 | ''' Not a docstring ''' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 1 | class SingleLineDocstrings(): @@ -18,14 +19,15 @@ docstring_singles_mixed_quotes_class_var_2.py:2:5: Q002 [*] Single quote docstri 4 4 | 5 5 | def foo(self, bar='''not a docstring'''): -docstring_singles_mixed_quotes_class_var_2.py:2:40: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_2.py:2:40 | 1 | class SingleLineDocstrings(): 2 | 'Do not'" start with empty string" ' and lint docstring safely' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | ''' Not a docstring ''' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 1 | class SingleLineDocstrings(): @@ -35,14 +37,15 @@ docstring_singles_mixed_quotes_class_var_2.py:2:40: Q002 [*] Single quote docstr 4 4 | 5 5 | def foo(self, bar='''not a docstring'''): -docstring_singles_mixed_quotes_class_var_2.py:6:9: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_2.py:6:9 | 5 | def foo(self, bar='''not a docstring'''): 6 | 'Do not'" start with empty string" ' and lint docstring safely' - | ^^^^^^^^ Q002 + | ^^^^^^^^ 7 | pass | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 3 3 | ''' Not a docstring ''' @@ -54,14 +57,15 @@ docstring_singles_mixed_quotes_class_var_2.py:6:9: Q002 [*] Single quote docstri 8 8 | 9 9 | class Nested(foo()[:]): 'Do not'" start with empty string" ' and lint docstring safely'; pass -docstring_singles_mixed_quotes_class_var_2.py:6:44: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_2.py:6:44 | 5 | def foo(self, bar='''not a docstring'''): 6 | 'Do not'" start with empty string" ' and lint docstring safely' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | pass | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 3 3 | ''' Not a docstring ''' @@ -73,14 +77,15 @@ docstring_singles_mixed_quotes_class_var_2.py:6:44: Q002 [*] Single quote docstr 8 8 | 9 9 | class Nested(foo()[:]): 'Do not'" start with empty string" ' and lint docstring safely'; pass -docstring_singles_mixed_quotes_class_var_2.py:9:29: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_2.py:9:29 | 7 | pass 8 | 9 | class Nested(foo()[:]): 'Do not'" start with empty string" ' and lint docstring safely'; pass - | ^^^^^^^^ Q002 + | ^^^^^^^^ | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 6 6 | 'Do not'" start with empty string" ' and lint docstring safely' @@ -89,14 +94,15 @@ docstring_singles_mixed_quotes_class_var_2.py:9:29: Q002 [*] Single quote docstr 9 |- class Nested(foo()[:]): 'Do not'" start with empty string" ' and lint docstring safely'; pass 9 |+ class Nested(foo()[:]): "Do not"" start with empty string" ' and lint docstring safely'; pass -docstring_singles_mixed_quotes_class_var_2.py:9:64: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_class_var_2.py:9:64 | 7 | pass 8 | 9 | class Nested(foo()[:]): 'Do not'" start with empty string" ' and lint docstring safely'; pass - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 6 6 | 'Do not'" start with empty string" ' and lint docstring safely' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap index 298bf7a6d1..5b079058ba 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_1.py.snap @@ -1,23 +1,25 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles_mixed_quotes_module_singleline_var_1.py:1:1: Q002 Single quote docstring found but double quotes preferred +Q002 Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_module_singleline_var_1.py:1:1 | 1 | ''"Start with empty string" ' and lint docstring safely' - | ^^ Q002 + | ^^ 2 | 3 | def foo(): | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes -docstring_singles_mixed_quotes_module_singleline_var_1.py:1:29: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_module_singleline_var_1.py:1:29 | 1 | ''"Start with empty string" ' and lint docstring safely' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | 3 | def foo(): | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 |-''"Start with empty string" ' and lint docstring safely' @@ -26,14 +28,15 @@ docstring_singles_mixed_quotes_module_singleline_var_1.py:1:29: Q002 [*] Single 3 3 | def foo(): 4 4 | pass -docstring_singles_mixed_quotes_module_singleline_var_1.py:5:1: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_singles_mixed_quotes_module_singleline_var_1.py:5:1 | 3 | def foo(): 4 | pass 5 | """ this is not a docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap index 1faa802f1b..ad3726d457 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_mixed_quotes_module_singleline_var_2.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles_mixed_quotes_module_singleline_var_2.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_module_singleline_var_2.py:1:1 | 1 | 'Do not'" start with empty string" ' and lint docstring safely' - | ^^^^^^^^ Q002 + | ^^^^^^^^ 2 | 3 | def foo(): | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 |-'Do not'" start with empty string" ' and lint docstring safely' @@ -17,14 +18,15 @@ docstring_singles_mixed_quotes_module_singleline_var_2.py:1:1: Q002 [*] Single q 3 3 | def foo(): 4 4 | pass -docstring_singles_mixed_quotes_module_singleline_var_2.py:1:36: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_mixed_quotes_module_singleline_var_2.py:1:36 | 1 | 'Do not'" start with empty string" ' and lint docstring safely' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | 3 | def foo(): | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 |-'Do not'" start with empty string" ' and lint docstring safely' @@ -33,14 +35,15 @@ docstring_singles_mixed_quotes_module_singleline_var_2.py:1:36: Q002 [*] Single 3 3 | def foo(): 4 4 | pass -docstring_singles_mixed_quotes_module_singleline_var_2.py:5:1: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> docstring_singles_mixed_quotes_module_singleline_var_2.py:5:1 | 3 | def foo(): 4 | pass 5 | """ this is not a docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap index 85937832a7..b570d042b5 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -docstring_singles_module_multiline.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_module_multiline.py:1:1 | 1 | / ''' 2 | | Double quotes multiline module docstring 3 | | ''' - | |___^ Q002 + | |___^ 4 | ''' 5 | this is not a docstring | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 |-''' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap index 061a260223..b0ed1bc769 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -docstring_singles_module_singleline.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred +Q002 [*] Single quote docstring found but double quotes preferred + --> docstring_singles_module_singleline.py:1:1 | 1 | ''' Double quotes singleline module docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | ''' this is not a docstring ''' | - = help: Replace single quotes docstring with double quotes +help: Replace single quotes docstring with double quotes ℹ Safe fix 1 |-''' Double quotes singleline module docstring ''' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap index 84c7afaab8..3d976112e3 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles.py:1:1 | 1 | / """ 2 | | Double quotes multiline module docstring 3 | | """ - | |___^ Q002 + | |___^ 4 | 5 | """ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 1 |-""" @@ -22,17 +23,18 @@ docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quote 5 5 | """ 6 6 | this is not a docstring -docstring_doubles.py:12:5: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles.py:12:5 | 11 | class Cls: 12 | / """ 13 | | Double quotes multiline class docstring 14 | | """ - | |_______^ Q002 + | |_______^ 15 | 16 | """ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 9 9 | l = [] @@ -47,18 +49,19 @@ docstring_doubles.py:12:5: Q002 [*] Double quote docstring found but single quot 16 16 | """ 17 17 | this is not a docstring -docstring_doubles.py:24:9: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles.py:24:9 | 22 | definitely not a docstring""", 23 | val=l[Cls():3]): 24 | / """ 25 | | Double quotes multiline function docstring 26 | | """ - | |___________^ Q002 + | |___________^ 27 | 28 | some_expression = 'hello world' | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 21 21 | def f(self, bar=""" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap index e222557186..8cebae5756 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles_class.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_class.py:2:5 | 1 | class SingleLineDocstrings(): 2 | """ Double quotes single line class docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | """ Not a docstring """ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 1 1 | class SingleLineDocstrings(): @@ -18,14 +19,15 @@ docstring_doubles_class.py:2:5: Q002 [*] Double quote docstring found but single 4 4 | 5 5 | def foo(self, bar="""not a docstring"""): -docstring_doubles_class.py:6:9: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_class.py:6:9 | 5 | def foo(self, bar="""not a docstring"""): 6 | """ Double quotes single line method docstring""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | pass | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 3 3 | """ Not a docstring """ @@ -37,14 +39,15 @@ docstring_doubles_class.py:6:9: Q002 [*] Double quote docstring found but single 8 8 | 9 9 | class Nested(foo()[:]): """ inline docstring """; pass -docstring_doubles_class.py:9:29: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_class.py:9:29 | 7 | pass 8 | 9 | class Nested(foo()[:]): """ inline docstring """; pass - | ^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 6 6 | """ Double quotes single line method docstring""" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap index e33863957c..8eb0509992 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles_function.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_function.py:2:5 | 1 | def foo(): 2 | """function without params, single line docstring""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | """ not a docstring""" 4 | return | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 1 1 | def foo(): @@ -19,17 +20,18 @@ docstring_doubles_function.py:2:5: Q002 [*] Double quote docstring found but sin 4 4 | return 5 5 | -docstring_doubles_function.py:8:5: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_function.py:8:5 | 7 | def foo2(): 8 | / """ 9 | | function without params, multiline docstring 10 | | """ - | |_______^ Q002 + | |_______^ 11 | """ not a docstring""" 12 | return | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 5 5 | @@ -44,13 +46,14 @@ docstring_doubles_function.py:8:5: Q002 [*] Double quote docstring found but sin 12 12 | return 13 13 | -docstring_doubles_function.py:27:5: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_function.py:27:5 | 26 | def function_with_single_docstring(a): 27 | "Single line docstring" - | ^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 24 24 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_1.py.snap index 34ed1310df..28bd74c2a0 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_1.py.snap @@ -1,29 +1,32 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles_mixed_quotes_class_var_1.py:2:5: Q002 Double quote docstring found but single quotes preferred +Q002 Double quote docstring found but single quotes preferred + --> docstring_doubles_mixed_quotes_class_var_1.py:2:5 | 1 | class SingleLineDocstrings(): 2 | ""'Start with empty string' ' and lint docstring safely' - | ^^ Q002 + | ^^ 3 | """ Not a docstring """ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes -docstring_doubles_mixed_quotes_class_var_1.py:6:9: Q002 Double quote docstring found but single quotes preferred +Q002 Double quote docstring found but single quotes preferred + --> docstring_doubles_mixed_quotes_class_var_1.py:6:9 | 5 | def foo(self, bar="""not a docstring"""): 6 | ""'Start with empty string' ' and lint docstring safely' - | ^^ Q002 + | ^^ 7 | pass | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes -docstring_doubles_mixed_quotes_class_var_1.py:9:29: Q002 Double quote docstring found but single quotes preferred +Q002 Double quote docstring found but single quotes preferred + --> docstring_doubles_mixed_quotes_class_var_1.py:9:29 | 7 | pass 8 | 9 | class Nested(foo()[:]): ""'Start with empty string' ' and lint docstring safely'; pass - | ^^ Q002 + | ^^ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap index a9b6c90379..5855c8253e 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_class_var_2.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles_mixed_quotes_class_var_2.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_mixed_quotes_class_var_2.py:2:5 | 1 | class SingleLineDocstrings(): 2 | "Do not"' start with empty string' ' and lint docstring safely' - | ^^^^^^^^ Q002 + | ^^^^^^^^ 3 | """ Not a docstring """ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 1 1 | class SingleLineDocstrings(): @@ -18,14 +19,15 @@ docstring_doubles_mixed_quotes_class_var_2.py:2:5: Q002 [*] Double quote docstri 4 4 | 5 5 | def foo(self, bar="""not a docstring"""): -docstring_doubles_mixed_quotes_class_var_2.py:6:9: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_mixed_quotes_class_var_2.py:6:9 | 5 | def foo(self, bar="""not a docstring"""): 6 | "Do not"' start with empty string' ' and lint docstring safely' - | ^^^^^^^^ Q002 + | ^^^^^^^^ 7 | pass | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 3 3 | """ Not a docstring """ @@ -37,14 +39,15 @@ docstring_doubles_mixed_quotes_class_var_2.py:6:9: Q002 [*] Double quote docstri 8 8 | 9 9 | class Nested(foo()[:]): "Do not"' start with empty string' ' and lint docstring safely'; pass -docstring_doubles_mixed_quotes_class_var_2.py:9:29: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_mixed_quotes_class_var_2.py:9:29 | 7 | pass 8 | 9 | class Nested(foo()[:]): "Do not"' start with empty string' ' and lint docstring safely'; pass - | ^^^^^^^^ Q002 + | ^^^^^^^^ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 6 6 | "Do not"' start with empty string' ' and lint docstring safely' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_1.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_1.py.snap index e19a8dabb2..ae92611549 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_1.py.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles_mixed_quotes_module_singleline_var_1.py:1:1: Q002 Double quote docstring found but single quotes preferred +Q002 Double quote docstring found but single quotes preferred + --> docstring_doubles_mixed_quotes_module_singleline_var_1.py:1:1 | 1 | ""'Start with empty string' ' and lint docstring safely' - | ^^ Q002 + | ^^ 2 | 3 | def foo(): | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap index 81295100ba..9314ac3afc 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_mixed_quotes_module_singleline_var_2.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_doubles_mixed_quotes_module_singleline_var_2.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_mixed_quotes_module_singleline_var_2.py:1:1 | 1 | "Do not"' start with empty string' ' and lint docstring safely' - | ^^^^^^^^ Q002 + | ^^^^^^^^ 2 | 3 | def foo(): | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 1 |-"Do not"' start with empty string' ' and lint docstring safely' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap index fd73229e29..8de5e00a7c 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -docstring_doubles_module_multiline.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_module_multiline.py:1:1 | 1 | / """ 2 | | Double quotes multiline module docstring 3 | | """ - | |___^ Q002 + | |___^ 4 | """ 5 | this is not a docstring | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 1 |-""" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap index c474d2eedb..81dac4b5a0 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -docstring_doubles_module_singleline.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred +Q002 [*] Double quote docstring found but single quotes preferred + --> docstring_doubles_module_singleline.py:1:1 | 1 | """ Double quotes singleline module docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | """ this is not a docstring """ | - = help: Replace double quotes docstring with single quotes +help: Replace double quotes docstring with single quotes ℹ Safe fix 1 |-""" Double quotes singleline module docstring """ diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap index 43c7b6b7f8..8c17b17455 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap @@ -1,18 +1,19 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles.py:5:1: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles.py:5:1 | 3 | ''' 4 | 5 | / ''' 6 | | this is not a docstring 7 | | ''' - | |___^ Q001 + | |___^ 8 | 9 | l = [] | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 2 2 | Single quotes multiline module docstring @@ -27,7 +28,8 @@ docstring_singles.py:5:1: Q001 [*] Single quote multiline found but double quote 9 9 | l = [] 10 10 | -docstring_singles.py:11:21: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles.py:11:21 | 9 | l = [] 10 | @@ -35,11 +37,11 @@ docstring_singles.py:11:21: Q001 [*] Single quote multiline found but double quo | _____________________^ 12 | | class params \t not a docstring 13 | | ''')): - | |___^ Q001 + | |___^ 14 | ''' 15 | Single quotes multiline class docstring | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 8 8 | @@ -54,18 +56,19 @@ docstring_singles.py:11:21: Q001 [*] Single quote multiline found but double quo 15 15 | Single quotes multiline class docstring 16 16 | ''' -docstring_singles.py:18:5: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles.py:18:5 | 16 | ''' 17 | 18 | / ''' 19 | | this is not a docstring 20 | | ''' - | |_______^ Q001 + | |_______^ 21 | 22 | # The colon in the list indexing below is an edge case for the docstring scanner | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 15 15 | Single quotes multiline class docstring @@ -80,17 +83,18 @@ docstring_singles.py:18:5: Q001 [*] Single quote multiline found but double quot 22 22 | # The colon in the list indexing below is an edge case for the docstring scanner 23 23 | def f(self, bar=''' -docstring_singles.py:23:21: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles.py:23:21 | 22 | # The colon in the list indexing below is an edge case for the docstring scanner 23 | def f(self, bar=''' | _____________________^ 24 | | definitely not a docstring''', - | |_____________________________________^ Q001 + | |_____________________________________^ 25 | val=l[Cls():3]): 26 | ''' | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 20 20 | ''' @@ -104,18 +108,19 @@ docstring_singles.py:23:21: Q001 [*] Single quote multiline found but double quo 26 26 | ''' 27 27 | Single quotes multiline function docstring -docstring_singles.py:32:9: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles.py:32:9 | 30 | some_expression = 'hello world' 31 | 32 | / ''' 33 | | this is not a docstring 34 | | ''' - | |___________^ Q001 + | |___________^ 35 | 36 | if l: | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 29 29 | @@ -130,16 +135,17 @@ docstring_singles.py:32:9: Q001 [*] Single quote multiline found but double quot 36 36 | if l: 37 37 | ''' -docstring_singles.py:37:13: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles.py:37:13 | 36 | if l: 37 | / ''' 38 | | Looks like a docstring, but in reality it isn't - only modules, classes and functions 39 | | ''' - | |_______________^ Q001 + | |_______________^ 40 | pass | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 34 34 | ''' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap index d94db3e564..5cd192eba7 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles_class.py:3:5: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_class.py:3:5 | 1 | class SingleLineDocstrings(): 2 | ''' Double quotes single line class docstring ''' 3 | ''' Not a docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | def foo(self, bar='''not a docstring'''): | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 1 1 | class SingleLineDocstrings(): @@ -21,16 +22,17 @@ docstring_singles_class.py:3:5: Q001 [*] Single quote multiline found but double 5 5 | def foo(self, bar='''not a docstring'''): 6 6 | ''' Double quotes single line method docstring''' -docstring_singles_class.py:5:23: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_class.py:5:23 | 3 | ''' Not a docstring ''' 4 | 5 | def foo(self, bar='''not a docstring'''): - | ^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | ''' Double quotes single line method docstring''' 7 | pass | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 2 2 | ''' Double quotes single line class docstring ''' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap index 252740c4f4..455a32f692 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -docstring_singles_function.py:3:5: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_function.py:3:5 | 1 | def foo(): 2 | '''function without params, single line docstring''' 3 | ''' not a docstring''' - | ^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^ 4 | return | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 1 1 | def foo(): @@ -21,15 +21,16 @@ docstring_singles_function.py:3:5: Q001 [*] Single quote multiline found but dou 5 5 | 6 6 | -docstring_singles_function.py:11:5: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_function.py:11:5 | 9 | function without params, multiline docstring 10 | ''' 11 | ''' not a docstring''' - | ^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^ 12 | return | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 8 8 | ''' @@ -41,16 +42,17 @@ docstring_singles_function.py:11:5: Q001 [*] Single quote multiline found but do 13 13 | 14 14 | -docstring_singles_function.py:15:39: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_function.py:15:39 | 15 | def fun_with_params_no_docstring(a, b=''' | _______________________________________^ 16 | | not a 17 | | ''' '''docstring'''): - | |___^ Q001 + | |___^ 18 | pass | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 12 12 | return @@ -65,15 +67,16 @@ docstring_singles_function.py:15:39: Q001 [*] Single quote multiline found but d 19 19 | 20 20 | -docstring_singles_function.py:17:5: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_function.py:17:5 | 15 | def fun_with_params_no_docstring(a, b=''' 16 | not a 17 | ''' '''docstring'''): - | ^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^ 18 | pass | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 14 14 | @@ -85,14 +88,15 @@ docstring_singles_function.py:17:5: Q001 [*] Single quote multiline found but do 19 19 | 20 20 | -docstring_singles_function.py:22:5: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_function.py:22:5 | 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ 22 | ''' not a docstring '''): - | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 19 19 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap index 157f519253..8003cada09 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap @@ -1,19 +1,19 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -docstring_singles_module_multiline.py:4:1: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_module_multiline.py:4:1 | 2 | Double quotes multiline module docstring 3 | ''' 4 | / ''' 5 | | this is not a docstring 6 | | ''' - | |___^ Q001 + | |___^ 7 | def foo(): 8 | pass | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 1 1 | ''' @@ -28,16 +28,17 @@ docstring_singles_module_multiline.py:4:1: Q001 [*] Single quote multiline found 8 8 | pass 9 9 | ''' -docstring_singles_module_multiline.py:9:1: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_module_multiline.py:9:1 | 7 | def foo(): 8 | pass 9 | / ''' 10 | | this is not a docstring 11 | | ''' - | |___^ Q001 + | |___^ | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 6 6 | ''' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap index 85b17d1d40..72809993e9 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -docstring_singles_module_singleline.py:2:1: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_module_singleline.py:2:1 | 1 | ''' Double quotes singleline module docstring ''' 2 | ''' this is not a docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | def foo(): | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 1 1 | ''' Double quotes singleline module docstring ''' @@ -19,14 +20,15 @@ docstring_singles_module_singleline.py:2:1: Q001 [*] Single quote multiline foun 4 4 | def foo(): 5 5 | pass -docstring_singles_module_singleline.py:6:1: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> docstring_singles_module_singleline.py:6:1 | 4 | def foo(): 5 | pass 6 | ''' this is not a docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap index 779e8c1379..0732cb70c1 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -singles.py:1:25: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles.py:1:25 | 1 | this_should_be_linted = 'single quote string' - | ^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^ 2 | this_should_be_linted = u'double quote string' 3 | this_should_be_linted = f'double quote string' | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 |-this_should_be_linted = 'single quote string' @@ -18,15 +18,16 @@ singles.py:1:25: Q000 [*] Single quotes found but double quotes preferred 3 3 | this_should_be_linted = f'double quote string' 4 4 | this_should_be_linted = f'double {"quote"} string' -singles.py:2:25: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles.py:2:25 | 1 | this_should_be_linted = 'single quote string' 2 | this_should_be_linted = u'double quote string' - | ^^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^^ 3 | this_should_be_linted = f'double quote string' 4 | this_should_be_linted = f'double {"quote"} string' | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 1 | this_should_be_linted = 'single quote string' @@ -36,15 +37,16 @@ singles.py:2:25: Q000 [*] Single quotes found but double quotes preferred 4 4 | this_should_be_linted = f'double {"quote"} string' 5 5 | -singles.py:3:25: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles.py:3:25 | 1 | this_should_be_linted = 'single quote string' 2 | this_should_be_linted = u'double quote string' 3 | this_should_be_linted = f'double quote string' - | ^^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^^ 4 | this_should_be_linted = f'double {"quote"} string' | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 1 | this_should_be_linted = 'single quote string' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap index 260805955b..506d6d4953 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:1:26 | 1 | this_should_raise_Q003 = "This is a \"string\"" - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | this_is_fine = "'This' is a \"string\"" 3 | this_is_fine = 'This is a "string"' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 1 |-this_should_raise_Q003 = "This is a \"string\"" @@ -17,15 +18,16 @@ singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner qu 3 3 | this_is_fine = 'This is a "string"' 4 4 | this_is_fine = '\'This\' is a "string"' -singles_escaped.py:9:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:9:5 | 7 | this_should_raise = ( 8 | "This is a" 9 | "\"string\"" - | ^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^ 10 | ) | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 6 6 | this_is_fine = R"This is a \"string\"" @@ -37,15 +39,16 @@ singles_escaped.py:9:5: Q003 [*] Change outer quotes to avoid escaping inner quo 11 11 | 12 12 | # Same as above, but with f-strings -singles_escaped.py:13:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:13:1 | 12 | # Same as above, but with f-strings 13 | f"This is a \"string\"" - | ^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | f"'This' is a \"string\"" 15 | f'This is a "string"' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 10 10 | ) @@ -57,15 +60,16 @@ singles_escaped.py:13:1: Q003 [*] Change outer quotes to avoid escaping inner qu 15 15 | f'This is a "string"' 16 16 | f'\'This\' is a "string"' -singles_escaped.py:21:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:21:5 | 19 | foo = ( 20 | f"This is a" 21 | f"\"string\"" - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 22 | ) | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 18 18 | fR"This is a \"string\"" @@ -77,16 +81,17 @@ singles_escaped.py:21:5: Q003 [*] Change outer quotes to avoid escaping inner qu 23 23 | 24 24 | # Nested f-strings (Python 3.12+) -singles_escaped.py:31:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:31:1 | 29 | # 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 | f"\"foo\" {"foo"}" # Q003 - | ^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^ 32 | f"\"foo\" {f"foo"}" # Q003 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 28 28 | # f'"foo" {"nested"}' @@ -98,15 +103,16 @@ singles_escaped.py:31:1: Q003 [*] Change outer quotes to avoid escaping inner qu 33 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 34 34 | -singles_escaped.py:32:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:32:1 | 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 | f"\"foo\" {"foo"}" # Q003 32 | f"\"foo\" {f"foo"}" # Q003 - | ^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^ 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 29 29 | # @@ -118,16 +124,17 @@ singles_escaped.py:32:1: Q003 [*] Change outer quotes to avoid escaping inner qu 34 34 | 35 35 | f"normal {f"nested"} normal" -singles_escaped.py:33:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:33:1 | 31 | f"\"foo\" {"foo"}" # Q003 32 | f"\"foo\" {f"foo"}" # Q003 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | 35 | f"normal {f"nested"} normal" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -139,16 +146,17 @@ singles_escaped.py:33:1: Q003 [*] Change outer quotes to avoid escaping inner qu 35 35 | f"normal {f"nested"} normal" 36 36 | f"\"normal\" {f"nested"} normal" # Q003 -singles_escaped.py:33:12: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:33:12 | 31 | f"\"foo\" {"foo"}" # Q003 32 | f"\"foo\" {f"foo"}" # Q003 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 - | ^^^^^^^^^^ Q003 + | ^^^^^^^^^^ 34 | 35 | f"normal {f"nested"} normal" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -160,15 +168,16 @@ singles_escaped.py:33:12: Q003 [*] Change outer quotes to avoid escaping inner q 35 35 | f"normal {f"nested"} normal" 36 36 | f"\"normal\" {f"nested"} normal" # Q003 -singles_escaped.py:36:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:36:1 | 35 | f"normal {f"nested"} normal" 36 | f"\"normal\" {f"nested"} normal" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | f"\"normal\" {f"nested"} 'single quotes'" 38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 33 33 | f"\"foo\" {f"\"foo\""} \"\"" # Q003 @@ -180,15 +189,16 @@ singles_escaped.py:36:1: Q003 [*] Change outer quotes to avoid escaping inner qu 38 38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'" # Q003 39 39 | f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal" # Q003 -singles_escaped.py:38:15: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:38:15 | 36 | f"\"normal\" {f"nested"} normal" # Q003 37 | f"\"normal\" {f"nested"} 'single quotes'" 38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 35 35 | f"normal {f"nested"} normal" @@ -200,14 +210,15 @@ singles_escaped.py:38:15: Q003 [*] Change outer quotes to avoid escaping inner q 40 40 | 41 41 | -singles_escaped.py:39:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:39:1 | 37 | f"\"normal\" {f"nested"} 'single quotes'" 38 | f"\"normal\" {f"\"nested\" {"other"} normal"} 'single quotes'" # Q003 39 | f"\"normal\" {f"\"nested\" {"other"} 'single quotes'"} normal" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 36 36 | f"\"normal\" {f"nested"} normal" # Q003 @@ -219,15 +230,16 @@ singles_escaped.py:39:1: Q003 [*] Change outer quotes to avoid escaping inner qu 41 41 | 42 42 | # Same as above, but with t-strings -singles_escaped.py:43:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:43:1 | 42 | # Same as above, but with t-strings 43 | t"This is a \"string\"" - | ^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^ 44 | t"'This' is a \"string\"" 45 | f'This is a "string"' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 40 40 | @@ -239,16 +251,17 @@ singles_escaped.py:43:1: Q003 [*] Change outer quotes to avoid escaping inner qu 45 45 | f'This is a "string"' 46 46 | f'\'This\' is a "string"' -singles_escaped.py:51:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:51:5 | 49 | foo = ( 50 | t"This is a" 51 | t"\"string\"" - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 52 | ) 53 | t"\"foo\" {"foo"}" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 48 48 | fR"This is a \"string\"" @@ -260,16 +273,17 @@ singles_escaped.py:51:5: Q003 [*] Change outer quotes to avoid escaping inner qu 53 53 | t"\"foo\" {"foo"}" # Q003 54 54 | t"\"foo\" {t"foo"}" # Q003 -singles_escaped.py:53:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:53:1 | 51 | t"\"string\"" 52 | ) 53 | t"\"foo\" {"foo"}" # Q003 - | ^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^ 54 | t"\"foo\" {t"foo"}" # Q003 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 50 50 | t"This is a" @@ -281,15 +295,16 @@ singles_escaped.py:53:1: Q003 [*] Change outer quotes to avoid escaping inner qu 55 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 56 56 | -singles_escaped.py:54:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:54:1 | 52 | ) 53 | t"\"foo\" {"foo"}" # Q003 54 | t"\"foo\" {t"foo"}" # Q003 - | ^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^ 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 51 51 | t"\"string\"" @@ -301,16 +316,17 @@ singles_escaped.py:54:1: Q003 [*] Change outer quotes to avoid escaping inner qu 56 56 | 57 57 | t"normal {t"nested"} normal" -singles_escaped.py:55:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:55:1 | 53 | t"\"foo\" {"foo"}" # Q003 54 | t"\"foo\" {t"foo"}" # Q003 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | 57 | t"normal {t"nested"} normal" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 52 52 | ) @@ -322,16 +338,17 @@ singles_escaped.py:55:1: Q003 [*] Change outer quotes to avoid escaping inner qu 57 57 | t"normal {t"nested"} normal" 58 58 | t"\"normal\" {t"nested"} normal" # Q003 -singles_escaped.py:55:12: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:55:12 | 53 | t"\"foo\" {"foo"}" # Q003 54 | t"\"foo\" {t"foo"}" # Q003 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 - | ^^^^^^^^^^ Q003 + | ^^^^^^^^^^ 56 | 57 | t"normal {t"nested"} normal" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 52 52 | ) @@ -343,15 +360,16 @@ singles_escaped.py:55:12: Q003 [*] Change outer quotes to avoid escaping inner q 57 57 | t"normal {t"nested"} normal" 58 58 | t"\"normal\" {t"nested"} normal" # Q003 -singles_escaped.py:58:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:58:1 | 57 | t"normal {t"nested"} normal" 58 | t"\"normal\" {t"nested"} normal" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 59 | t"\"normal\" {t"nested"} 'single quotes'" 60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 55 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 @@ -363,15 +381,16 @@ singles_escaped.py:58:1: Q003 [*] Change outer quotes to avoid escaping inner qu 60 60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'" # Q003 61 61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal" # Q003 -singles_escaped.py:60:15: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:60:15 | 58 | t"\"normal\" {t"nested"} normal" # Q003 59 | t"\"normal\" {t"nested"} 'single quotes'" 60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 57 57 | t"normal {t"nested"} normal" @@ -381,14 +400,15 @@ singles_escaped.py:60:15: Q003 [*] Change outer quotes to avoid escaping inner q 60 |+t"\"normal\" {t'"nested" {"other"} normal'} 'single quotes'" # Q003 61 61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal" # Q003 -singles_escaped.py:61:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:61:1 | 59 | t"\"normal\" {t"nested"} 'single quotes'" 60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'" # Q003 61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 58 58 | t"\"normal\" {t"nested"} normal" # Q003 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_py311.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_py311.snap index cf7a8b3c70..a80c1353da 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_py311.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_py311.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:1:26 | 1 | this_should_raise_Q003 = "This is a \"string\"" - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | this_is_fine = "'This' is a \"string\"" 3 | this_is_fine = 'This is a "string"' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 1 |-this_should_raise_Q003 = "This is a \"string\"" @@ -17,15 +18,16 @@ singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner qu 3 3 | this_is_fine = 'This is a "string"' 4 4 | this_is_fine = '\'This\' is a "string"' -singles_escaped.py:9:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:9:5 | 7 | this_should_raise = ( 8 | "This is a" 9 | "\"string\"" - | ^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^ 10 | ) | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 6 6 | this_is_fine = R"This is a \"string\"" @@ -37,15 +39,16 @@ singles_escaped.py:9:5: Q003 [*] Change outer quotes to avoid escaping inner quo 11 11 | 12 12 | # Same as above, but with f-strings -singles_escaped.py:13:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:13:1 | 12 | # Same as above, but with f-strings 13 | f"This is a \"string\"" - | ^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | f"'This' is a \"string\"" 15 | f'This is a "string"' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 10 10 | ) @@ -57,15 +60,16 @@ singles_escaped.py:13:1: Q003 [*] Change outer quotes to avoid escaping inner qu 15 15 | f'This is a "string"' 16 16 | f'\'This\' is a "string"' -singles_escaped.py:21:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:21:5 | 19 | foo = ( 20 | f"This is a" 21 | f"\"string\"" - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 22 | ) | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 18 18 | fR"This is a \"string\"" @@ -77,15 +81,16 @@ singles_escaped.py:21:5: Q003 [*] Change outer quotes to avoid escaping inner qu 23 23 | 24 24 | # Nested f-strings (Python 3.12+) -singles_escaped.py:43:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:43:1 | 42 | # Same as above, but with t-strings 43 | t"This is a \"string\"" - | ^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^ 44 | t"'This' is a \"string\"" 45 | f'This is a "string"' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 40 40 | @@ -97,16 +102,17 @@ singles_escaped.py:43:1: Q003 [*] Change outer quotes to avoid escaping inner qu 45 45 | f'This is a "string"' 46 46 | f'\'This\' is a "string"' -singles_escaped.py:51:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:51:5 | 49 | foo = ( 50 | t"This is a" 51 | t"\"string\"" - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 52 | ) 53 | t"\"foo\" {"foo"}" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 48 48 | fR"This is a \"string\"" @@ -118,16 +124,17 @@ singles_escaped.py:51:5: Q003 [*] Change outer quotes to avoid escaping inner qu 53 53 | t"\"foo\" {"foo"}" # Q003 54 54 | t"\"foo\" {t"foo"}" # Q003 -singles_escaped.py:53:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:53:1 | 51 | t"\"string\"" 52 | ) 53 | t"\"foo\" {"foo"}" # Q003 - | ^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^ 54 | t"\"foo\" {t"foo"}" # Q003 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 50 50 | t"This is a" @@ -139,15 +146,16 @@ singles_escaped.py:53:1: Q003 [*] Change outer quotes to avoid escaping inner qu 55 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 56 56 | -singles_escaped.py:54:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:54:1 | 52 | ) 53 | t"\"foo\" {"foo"}" # Q003 54 | t"\"foo\" {t"foo"}" # Q003 - | ^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^ 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 51 51 | t"\"string\"" @@ -159,16 +167,17 @@ singles_escaped.py:54:1: Q003 [*] Change outer quotes to avoid escaping inner qu 56 56 | 57 57 | t"normal {t"nested"} normal" -singles_escaped.py:55:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:55:1 | 53 | t"\"foo\" {"foo"}" # Q003 54 | t"\"foo\" {t"foo"}" # Q003 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | 57 | t"normal {t"nested"} normal" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 52 52 | ) @@ -180,16 +189,17 @@ singles_escaped.py:55:1: Q003 [*] Change outer quotes to avoid escaping inner qu 57 57 | t"normal {t"nested"} normal" 58 58 | t"\"normal\" {t"nested"} normal" # Q003 -singles_escaped.py:55:12: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:55:12 | 53 | t"\"foo\" {"foo"}" # Q003 54 | t"\"foo\" {t"foo"}" # Q003 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 - | ^^^^^^^^^^ Q003 + | ^^^^^^^^^^ 56 | 57 | t"normal {t"nested"} normal" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 52 52 | ) @@ -201,15 +211,16 @@ singles_escaped.py:55:12: Q003 [*] Change outer quotes to avoid escaping inner q 57 57 | t"normal {t"nested"} normal" 58 58 | t"\"normal\" {t"nested"} normal" # Q003 -singles_escaped.py:58:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:58:1 | 57 | t"normal {t"nested"} normal" 58 | t"\"normal\" {t"nested"} normal" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 59 | t"\"normal\" {t"nested"} 'single quotes'" 60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 55 55 | t"\"foo\" {t"\"foo\""} \"\"" # Q003 @@ -221,15 +232,16 @@ singles_escaped.py:58:1: Q003 [*] Change outer quotes to avoid escaping inner qu 60 60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'" # Q003 61 61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal" # Q003 -singles_escaped.py:60:15: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:60:15 | 58 | t"\"normal\" {t"nested"} normal" # Q003 59 | t"\"normal\" {t"nested"} 'single quotes'" 60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal" # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 57 57 | t"normal {t"nested"} normal" @@ -239,14 +251,15 @@ singles_escaped.py:60:15: Q003 [*] Change outer quotes to avoid escaping inner q 60 |+t"\"normal\" {t'"nested" {"other"} normal'} 'single quotes'" # Q003 61 61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal" # Q003 -singles_escaped.py:61:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> singles_escaped.py:61:1 | 59 | t"\"normal\" {t"nested"} 'single quotes'" 60 | t"\"normal\" {t"\"nested\" {"other"} normal"} 'single quotes'" # Q003 61 | t"\"normal\" {t"\"nested\" {"other"} 'single quotes'"} normal" # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 58 58 | t"\"normal\" {t"nested"} normal" # Q003 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap index 71e3d38d97..01c794ca9c 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped_unnecessary.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -singles_escaped_unnecessary.py:1:26: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:1:26 | 1 | this_should_raise_Q004 = "This is a \'string\'" - | ^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | this_should_raise_Q004 = "'This' is a \'string\'" 3 | this_is_fine = 'This is a "string"' | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 1 |-this_should_raise_Q004 = "This is a \'string\'" @@ -17,15 +18,16 @@ singles_escaped_unnecessary.py:1:26: Q004 [*] Unnecessary escape on inner quote 3 3 | this_is_fine = 'This is a "string"' 4 4 | this_is_fine = '\'This\' is a "string"' -singles_escaped_unnecessary.py:2:26: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:2:26 | 1 | this_should_raise_Q004 = "This is a \'string\'" 2 | this_should_raise_Q004 = "'This' is a \'string\'" - | ^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 3 | this_is_fine = 'This is a "string"' 4 | this_is_fine = '\'This\' is a "string"' | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 1 1 | this_should_raise_Q004 = "This is a \'string\'" @@ -35,15 +37,16 @@ singles_escaped_unnecessary.py:2:26: Q004 [*] Unnecessary escape on inner quote 4 4 | this_is_fine = '\'This\' is a "string"' 5 5 | this_is_fine = r"This is a \'string\'" -singles_escaped_unnecessary.py:9:5: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:9:5 | 7 | this_should_raise_Q004 = ( 8 | "This is a" 9 | "\'string\'" - | ^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^ 10 | ) | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 6 6 | this_is_fine = R"This is a \'string\'" @@ -55,15 +58,16 @@ singles_escaped_unnecessary.py:9:5: Q004 [*] Unnecessary escape on inner quote c 11 11 | 12 12 | # Same as above, but with f-strings -singles_escaped_unnecessary.py:13:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:13:1 | 12 | # Same as above, but with f-strings 13 | f"This is a \'string\'" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | f"'This' is a \'string\'" # Q004 15 | f'This is a "string"' | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 10 10 | ) @@ -75,16 +79,17 @@ singles_escaped_unnecessary.py:13:1: Q004 [*] Unnecessary escape on inner quote 15 15 | f'This is a "string"' 16 16 | f'\'This\' is a "string"' -singles_escaped_unnecessary.py:14:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:14:1 | 12 | # Same as above, but with f-strings 13 | f"This is a \'string\'" # Q004 14 | f"'This' is a \'string\'" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | f'This is a "string"' 16 | f'\'This\' is a "string"' | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 11 11 | @@ -96,15 +101,16 @@ singles_escaped_unnecessary.py:14:1: Q004 [*] Unnecessary escape on inner quote 16 16 | f'\'This\' is a "string"' 17 17 | fr"This is a \'string\'" -singles_escaped_unnecessary.py:21:5: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:21:5 | 19 | this_should_raise_Q004 = ( 20 | f"This is a" 21 | f"\'string\'" # Q004 - | ^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^ 22 | ) | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 18 18 | fR"This is a \'string\'" @@ -116,16 +122,17 @@ singles_escaped_unnecessary.py:21:5: Q004 [*] Unnecessary escape on inner quote 23 23 | 24 24 | # Nested f-strings (Python 3.12+) -singles_escaped_unnecessary.py:31:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:31:1 | 29 | # 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 | f"\'foo\' {"foo"}" # Q004 - | ^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^ 32 | f"\'foo\' {f"foo"}" # Q004 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 28 28 | # f'"foo" {"nested"}' @@ -137,15 +144,16 @@ singles_escaped_unnecessary.py:31:1: Q004 [*] Unnecessary escape on inner quote 33 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 34 34 | -singles_escaped_unnecessary.py:32:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:32:1 | 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 31 | f"\'foo\' {"foo"}" # Q004 32 | f"\'foo\' {f"foo"}" # Q004 - | ^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^ 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 29 29 | # @@ -157,16 +165,17 @@ singles_escaped_unnecessary.py:32:1: Q004 [*] Unnecessary escape on inner quote 34 34 | 35 35 | f"normal {f"nested"} normal" -singles_escaped_unnecessary.py:33:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:33:1 | 31 | f"\'foo\' {"foo"}" # Q004 32 | f"\'foo\' {f"foo"}" # Q004 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | 35 | f"normal {f"nested"} normal" | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -178,16 +187,17 @@ singles_escaped_unnecessary.py:33:1: Q004 [*] Unnecessary escape on inner quote 35 35 | f"normal {f"nested"} normal" 36 36 | f"\'normal\' {f"nested"} normal" # Q004 -singles_escaped_unnecessary.py:33:12: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:33:12 | 31 | f"\'foo\' {"foo"}" # Q004 32 | f"\'foo\' {f"foo"}" # Q004 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 - | ^^^^^^^^^^ Q004 + | ^^^^^^^^^^ 34 | 35 | f"normal {f"nested"} normal" | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 30 30 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -199,15 +209,16 @@ singles_escaped_unnecessary.py:33:12: Q004 [*] Unnecessary escape on inner quote 35 35 | f"normal {f"nested"} normal" 36 36 | f"\'normal\' {f"nested"} normal" # Q004 -singles_escaped_unnecessary.py:36:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:36:1 | 35 | f"normal {f"nested"} normal" 36 | f"\'normal\' {f"nested"} normal" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | f"\'normal\' {f"nested"} 'single quotes'" 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 33 33 | f"\'foo\' {f"\'foo\'"} \'\'" # Q004 @@ -219,16 +230,17 @@ singles_escaped_unnecessary.py:36:1: Q004 [*] Unnecessary escape on inner quote 38 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 39 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 -singles_escaped_unnecessary.py:37:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:37:1 | 35 | f"normal {f"nested"} normal" 36 | f"\'normal\' {f"nested"} normal" # Q004 37 | f"\'normal\' {f"nested"} 'single quotes'" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 34 34 | @@ -240,15 +252,16 @@ singles_escaped_unnecessary.py:37:1: Q004 [*] Unnecessary escape on inner quote 39 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 40 40 | -singles_escaped_unnecessary.py:38:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:38:1 | 36 | f"\'normal\' {f"nested"} normal" # Q004 37 | f"\'normal\' {f"nested"} 'single quotes'" 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 35 35 | f"normal {f"nested"} normal" @@ -260,15 +273,16 @@ singles_escaped_unnecessary.py:38:1: Q004 [*] Unnecessary escape on inner quote 40 40 | 41 41 | # Make sure we do not unescape quotes -singles_escaped_unnecessary.py:38:15: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:38:15 | 36 | f"\'normal\' {f"nested"} normal" # Q004 37 | f"\'normal\' {f"nested"} 'single quotes'" 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 35 35 | f"normal {f"nested"} normal" @@ -280,16 +294,17 @@ singles_escaped_unnecessary.py:38:15: Q004 [*] Unnecessary escape on inner quote 40 40 | 41 41 | # Make sure we do not unescape quotes -singles_escaped_unnecessary.py:39:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:39:1 | 37 | f"\'normal\' {f"nested"} 'single quotes'" 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | 41 | # Make sure we do not unescape quotes | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 36 36 | f"\'normal\' {f"nested"} normal" # Q004 @@ -301,16 +316,17 @@ singles_escaped_unnecessary.py:39:1: Q004 [*] Unnecessary escape on inner quote 41 41 | # Make sure we do not unescape quotes 42 42 | this_is_fine = "This is an \\'escaped\\' quote" -singles_escaped_unnecessary.py:39:15: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:39:15 | 37 | f"\'normal\' {f"nested"} 'single quotes'" 38 | f"\'normal\' {f"\'nested\' {"other"} normal"} 'single quotes'" # Q004 39 | f"\'normal\' {f"\'nested\' {"other"} 'single quotes'"} normal" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | 41 | # Make sure we do not unescape quotes | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 36 36 | f"\'normal\' {f"nested"} normal" # Q004 @@ -322,16 +338,17 @@ singles_escaped_unnecessary.py:39:15: Q004 [*] Unnecessary escape on inner quote 41 41 | # Make sure we do not unescape quotes 42 42 | this_is_fine = "This is an \\'escaped\\' quote" -singles_escaped_unnecessary.py:43:26: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:43:26 | 41 | # Make sure we do not unescape quotes 42 | this_is_fine = "This is an \\'escaped\\' quote" 43 | this_should_raise_Q004 = "This is an \\\'escaped\\\' quote with an extra backslash" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | # Invalid escapes in bytestrings are also triggered: | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 40 40 | @@ -343,13 +360,14 @@ singles_escaped_unnecessary.py:43:26: Q004 [*] Unnecessary escape on inner quote 45 45 | # Invalid escapes in bytestrings are also triggered: 46 46 | x = b"\xe7\xeb\x0c\xa1\x1b\x83tN\xce=x\xe9\xbe\x01\xb9\x13B_\xba\xe7\x0c2\xce\'rm\x0e\xcd\xe9.\xf8\xd2" # Q004 -singles_escaped_unnecessary.py:46:5: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> singles_escaped_unnecessary.py:46:5 | 45 | # Invalid escapes in bytestrings are also triggered: 46 | x = b"\xe7\xeb\x0c\xa1\x1b\x83tN\xce=x\xe9\xbe\x01\xb9\x13B_\xba\xe7\x0c2\xce\'rm\x0e\xcd\xe9.\xf8\xd2" # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 43 43 | this_should_raise_Q004 = "This is an \\\'escaped\\\' quote with an extra backslash" # Q004 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap index a3e6dd40bf..cde1de341b 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -singles_implicit.py:2:5: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_implicit.py:2:5 | 1 | x = ( 2 | 'This' - | ^^^^^^ Q000 + | ^^^^^^ 3 | 'is' 4 | 'not' | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 1 | x = ( @@ -20,16 +20,17 @@ singles_implicit.py:2:5: Q000 [*] Single quotes found but double quotes preferre 4 4 | 'not' 5 5 | ) -singles_implicit.py:3:5: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_implicit.py:3:5 | 1 | x = ( 2 | 'This' 3 | 'is' - | ^^^^ Q000 + | ^^^^ 4 | 'not' 5 | ) | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 1 | x = ( @@ -40,15 +41,16 @@ singles_implicit.py:3:5: Q000 [*] Single quotes found but double quotes preferre 5 5 | ) 6 6 | -singles_implicit.py:4:5: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_implicit.py:4:5 | 2 | 'This' 3 | 'is' 4 | 'not' - | ^^^^^ Q000 + | ^^^^^ 5 | ) | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 1 | x = ( @@ -60,15 +62,16 @@ singles_implicit.py:4:5: Q000 [*] Single quotes found but double quotes preferre 6 6 | 7 7 | x = ( -singles_implicit.py:8:5: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_implicit.py:8:5 | 7 | x = ( 8 | 'This' \ - | ^^^^^^ Q000 + | ^^^^^^ 9 | 'is' \ 10 | 'not' | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 5 5 | ) @@ -80,16 +83,17 @@ singles_implicit.py:8:5: Q000 [*] Single quotes found but double quotes preferre 10 10 | 'not' 11 11 | ) -singles_implicit.py:9:5: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_implicit.py:9:5 | 7 | x = ( 8 | 'This' \ 9 | 'is' \ - | ^^^^ Q000 + | ^^^^ 10 | 'not' 11 | ) | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 6 6 | @@ -101,15 +105,16 @@ singles_implicit.py:9:5: Q000 [*] Single quotes found but double quotes preferre 11 11 | ) 12 12 | -singles_implicit.py:10:5: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_implicit.py:10:5 | 8 | 'This' \ 9 | 'is' \ 10 | 'not' - | ^^^^^ Q000 + | ^^^^^ 11 | ) | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 7 7 | x = ( @@ -121,14 +126,15 @@ singles_implicit.py:10:5: Q000 [*] Single quotes found but double quotes preferr 12 12 | 13 13 | x = ( -singles_implicit.py:27:1: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_implicit.py:27:1 | 25 | if True: 26 | 'This can use "single" quotes' 27 | 'But this needs to be changed' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 24 24 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap index d926ca1c41..81c1440f4c 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -singles_multiline_string.py:1:5: Q001 [*] Single quote multiline found but double quotes preferred +Q001 [*] Single quote multiline found but double quotes preferred + --> singles_multiline_string.py:1:5 | 1 | s = ''' This 'should' | _____^ 2 | | be 3 | | 'linted' ''' - | |____________^ Q001 + | |____________^ 4 | 5 | s = """ This 'should' | - = help: Replace single multiline quotes with double quotes +help: Replace single multiline quotes with double quotes ℹ Safe fix 1 |-s = ''' This 'should' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_would_be_triple_quotes.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_would_be_triple_quotes.py.snap index 6d78f8e992..84cb0501e2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_would_be_triple_quotes.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_would_be_triple_quotes.py.snap @@ -1,48 +1,51 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -singles_would_be_triple_quotes.py:1:5: Q000 Single quotes found but double quotes preferred +Q000 Single quotes found but double quotes preferred + --> singles_would_be_triple_quotes.py:1:5 | 1 | s = ''"Start with empty string" ' and lint docstring safely' - | ^^ Q000 + | ^^ 2 | s = 'Do not'" start with empty string" ' and lint docstring safely' | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes -singles_would_be_triple_quotes.py:1:33: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_would_be_triple_quotes.py:1:33 | 1 | s = ''"Start with empty string" ' and lint docstring safely' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | s = 'Do not'" start with empty string" ' and lint docstring safely' | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 |-s = ''"Start with empty string" ' and lint docstring safely' 1 |+s = ''"Start with empty string" " and lint docstring safely" 2 2 | s = 'Do not'" start with empty string" ' and lint docstring safely' -singles_would_be_triple_quotes.py:2:5: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_would_be_triple_quotes.py:2:5 | 1 | s = ''"Start with empty string" ' and lint docstring safely' 2 | s = 'Do not'" start with empty string" ' and lint docstring safely' - | ^^^^^^^^ Q000 + | ^^^^^^^^ | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 1 | s = ''"Start with empty string" ' and lint docstring safely' 2 |-s = 'Do not'" start with empty string" ' and lint docstring safely' 2 |+s = "Do not"" start with empty string" ' and lint docstring safely' -singles_would_be_triple_quotes.py:2:40: Q000 [*] Single quotes found but double quotes preferred +Q000 [*] Single quotes found but double quotes preferred + --> singles_would_be_triple_quotes.py:2:40 | 1 | s = ''"Start with empty string" ' and lint docstring safely' 2 | s = 'Do not'" start with empty string" ' and lint docstring safely' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace single quotes with double quotes +help: Replace single quotes with double quotes ℹ Safe fix 1 1 | s = ''"Start with empty string" ' and lint docstring safely' diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap index 6ff8370795..655e2a0943 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -doubles.py:1:25: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles.py:1:25 | 1 | this_should_be_linted = "double quote string" - | ^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^ 2 | this_should_be_linted = u"double quote string" 3 | this_should_be_linted = f"double quote string" | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 1 |-this_should_be_linted = "double quote string" @@ -18,15 +18,16 @@ doubles.py:1:25: Q000 [*] Double quotes found but single quotes preferred 3 3 | this_should_be_linted = f"double quote string" 4 4 | this_should_be_linted = f"double {'quote'} string" -doubles.py:2:25: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles.py:2:25 | 1 | this_should_be_linted = "double quote string" 2 | this_should_be_linted = u"double quote string" - | ^^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^^ 3 | this_should_be_linted = f"double quote string" 4 | this_should_be_linted = f"double {'quote'} string" | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 1 1 | this_should_be_linted = "double quote string" @@ -35,15 +36,16 @@ doubles.py:2:25: Q000 [*] Double quotes found but single quotes preferred 3 3 | this_should_be_linted = f"double quote string" 4 4 | this_should_be_linted = f"double {'quote'} string" -doubles.py:3:25: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles.py:3:25 | 1 | this_should_be_linted = "double quote string" 2 | this_should_be_linted = u"double quote string" 3 | this_should_be_linted = f"double quote string" - | ^^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^^ 4 | this_should_be_linted = f"double {'quote'} string" | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 1 1 | this_should_be_linted = "double quote string" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap index 014b383162..39a71b82a2 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:1:26 | 1 | this_should_raise_Q003 = 'This is a \'string\'' - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' 3 | this_is_fine = '"This" is a \'string\'' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 1 |-this_should_raise_Q003 = 'This is a \'string\'' @@ -17,15 +18,16 @@ doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner qu 3 3 | this_is_fine = '"This" is a \'string\'' 4 4 | this_is_fine = "This is a 'string'" -doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:2:26 | 1 | this_should_raise_Q003 = 'This is a \'string\'' 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | this_is_fine = '"This" is a \'string\'' 4 | this_is_fine = "This is a 'string'" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 1 1 | this_should_raise_Q003 = 'This is a \'string\'' @@ -35,15 +37,16 @@ doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner qu 4 4 | this_is_fine = "This is a 'string'" 5 5 | this_is_fine = "\"This\" is a 'string'" -doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:10:5 | 8 | this_should_raise = ( 9 | 'This is a' 10 | '\'string\'' - | ^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^ 11 | ) | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 7 7 | this_is_fine = R'This is a \'string\'' @@ -55,15 +58,16 @@ doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner qu 12 12 | 13 13 | # Same as above, but with f-strings -doubles_escaped.py:14:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:14:1 | 13 | # Same as above, but with f-strings 14 | f'This is a \'string\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^ 15 | f'This is \\ a \\\'string\'' # Q003 16 | f'"This" is a \'string\'' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 11 11 | ) @@ -75,16 +79,17 @@ doubles_escaped.py:14:1: Q003 [*] Change outer quotes to avoid escaping inner qu 16 16 | f'"This" is a \'string\'' 17 17 | f"This is a 'string'" -doubles_escaped.py:15:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:15:1 | 13 | # Same as above, but with f-strings 14 | f'This is a \'string\'' # Q003 15 | f'This is \\ a \\\'string\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | f'"This" is a \'string\'' 17 | f"This is a 'string'" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 12 12 | @@ -96,15 +101,16 @@ doubles_escaped.py:15:1: Q003 [*] Change outer quotes to avoid escaping inner qu 17 17 | f"This is a 'string'" 18 18 | f"\"This\" is a 'string'" -doubles_escaped.py:23:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:23:5 | 21 | foo = ( 22 | f'This is a' 23 | f'\'string\'' # Q003 - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 24 | ) | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 20 20 | fR'This is a \'string\'' @@ -116,16 +122,17 @@ doubles_escaped.py:23:5: Q003 [*] Change outer quotes to avoid escaping inner qu 25 25 | 26 26 | # Nested f-strings (Python 3.12+) -doubles_escaped.py:33:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:33:1 | 31 | # 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 | f'\'foo\' {'nested'}' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^ 34 | f'\'foo\' {f'nested'}' # Q003 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 30 30 | # f"'foo' {'nested'}" @@ -137,15 +144,16 @@ doubles_escaped.py:33:1: Q003 [*] Change outer quotes to avoid escaping inner qu 35 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 36 36 | -doubles_escaped.py:34:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:34:1 | 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 | f'\'foo\' {'nested'}' # Q003 34 | f'\'foo\' {f'nested'}' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^ 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 31 31 | # @@ -157,16 +165,17 @@ doubles_escaped.py:34:1: Q003 [*] Change outer quotes to avoid escaping inner qu 36 36 | 37 37 | f'normal {f'nested'} normal' -doubles_escaped.py:35:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:35:1 | 33 | f'\'foo\' {'nested'}' # Q003 34 | f'\'foo\' {f'nested'}' # Q003 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | 37 | f'normal {f'nested'} normal' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -178,16 +187,17 @@ doubles_escaped.py:35:1: Q003 [*] Change outer quotes to avoid escaping inner qu 37 37 | f'normal {f'nested'} normal' 38 38 | f'\'normal\' {f'nested'} normal' # Q003 -doubles_escaped.py:35:12: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:35:12 | 33 | f'\'foo\' {'nested'}' # Q003 34 | f'\'foo\' {f'nested'}' # Q003 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 36 | 37 | f'normal {f'nested'} normal' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -199,15 +209,16 @@ doubles_escaped.py:35:12: Q003 [*] Change outer quotes to avoid escaping inner q 37 37 | f'normal {f'nested'} normal' 38 38 | f'\'normal\' {f'nested'} normal' # Q003 -doubles_escaped.py:38:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:38:1 | 37 | f'normal {f'nested'} normal' 38 | f'\'normal\' {f'nested'} normal' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | f'\'normal\' {f'nested'} "double quotes"' 40 | f'\'normal\' {f'\'nested\' {'other'} normal'} "double quotes"' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 35 35 | f'\'foo\' {f'\'nested\''} \'\'' # Q003 @@ -219,15 +230,16 @@ doubles_escaped.py:38:1: Q003 [*] Change outer quotes to avoid escaping inner qu 40 40 | f'\'normal\' {f'\'nested\' {'other'} normal'} "double quotes"' # Q003 41 41 | f'\'normal\' {f'\'nested\' {'other'} "double quotes"'} normal' # Q00l -doubles_escaped.py:40:15: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:40:15 | 38 | f'\'normal\' {f'nested'} normal' # Q003 39 | f'\'normal\' {f'nested'} "double quotes"' 40 | f'\'normal\' {f'\'nested\' {'other'} normal'} "double quotes"' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | f'\'normal\' {f'\'nested\' {'other'} "double quotes"'} normal' # Q00l | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 37 37 | f'normal {f'nested'} normal' @@ -239,14 +251,15 @@ doubles_escaped.py:40:15: Q003 [*] Change outer quotes to avoid escaping inner q 42 42 | 43 43 | -doubles_escaped.py:41:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:41:1 | 39 | f'\'normal\' {f'nested'} "double quotes"' 40 | f'\'normal\' {f'\'nested\' {'other'} normal'} "double quotes"' # Q003 41 | f'\'normal\' {f'\'nested\' {'other'} "double quotes"'} normal' # Q00l - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 38 38 | f'\'normal\' {f'nested'} normal' # Q003 @@ -258,15 +271,16 @@ doubles_escaped.py:41:1: Q003 [*] Change outer quotes to avoid escaping inner qu 43 43 | 44 44 | -doubles_escaped.py:46:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:46:1 | 45 | # Same as above, but with t-strings 46 | t'This is a \'string\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^ 47 | t'This is \\ a \\\'string\'' # Q003 48 | t'"This" is a \'string\'' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 43 43 | @@ -278,16 +292,17 @@ doubles_escaped.py:46:1: Q003 [*] Change outer quotes to avoid escaping inner qu 48 48 | t'"This" is a \'string\'' 49 49 | f"This is a 'string'" -doubles_escaped.py:47:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:47:1 | 45 | # Same as above, but with t-strings 46 | t'This is a \'string\'' # Q003 47 | t'This is \\ a \\\'string\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | t'"This" is a \'string\'' 49 | f"This is a 'string'" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 44 44 | @@ -299,16 +314,17 @@ doubles_escaped.py:47:1: Q003 [*] Change outer quotes to avoid escaping inner qu 49 49 | f"This is a 'string'" 50 50 | f"\"This\" is a 'string'" -doubles_escaped.py:55:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:55:5 | 53 | foo = ( 54 | t'This is a' 55 | t'\'string\'' # Q003 - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 56 | ) 57 | t'\'foo\' {'nested'}' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 52 52 | fR'This is a \'string\'' @@ -320,16 +336,17 @@ doubles_escaped.py:55:5: Q003 [*] Change outer quotes to avoid escaping inner qu 57 57 | t'\'foo\' {'nested'}' # Q003 58 58 | t'\'foo\' {t'nested'}' # Q003 -doubles_escaped.py:57:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:57:1 | 55 | t'\'string\'' # Q003 56 | ) 57 | t'\'foo\' {'nested'}' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^ 58 | t'\'foo\' {t'nested'}' # Q003 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 54 54 | t'This is a' @@ -341,15 +358,16 @@ doubles_escaped.py:57:1: Q003 [*] Change outer quotes to avoid escaping inner qu 59 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 60 60 | -doubles_escaped.py:58:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:58:1 | 56 | ) 57 | t'\'foo\' {'nested'}' # Q003 58 | t'\'foo\' {t'nested'}' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^ 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 55 55 | t'\'string\'' # Q003 @@ -361,16 +379,17 @@ doubles_escaped.py:58:1: Q003 [*] Change outer quotes to avoid escaping inner qu 60 60 | 61 61 | t'normal {t'nested'} normal' -doubles_escaped.py:59:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:59:1 | 57 | t'\'foo\' {'nested'}' # Q003 58 | t'\'foo\' {t'nested'}' # Q003 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | 61 | t'normal {t'nested'} normal' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 56 56 | ) @@ -382,16 +401,17 @@ doubles_escaped.py:59:1: Q003 [*] Change outer quotes to avoid escaping inner qu 61 61 | t'normal {t'nested'} normal' 62 62 | t'\'normal\' {t'nested'} normal' # Q003 -doubles_escaped.py:59:12: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:59:12 | 57 | t'\'foo\' {'nested'}' # Q003 58 | t'\'foo\' {t'nested'}' # Q003 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 60 | 61 | t'normal {t'nested'} normal' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 56 56 | ) @@ -403,15 +423,16 @@ doubles_escaped.py:59:12: Q003 [*] Change outer quotes to avoid escaping inner q 61 61 | t'normal {t'nested'} normal' 62 62 | t'\'normal\' {t'nested'} normal' # Q003 -doubles_escaped.py:62:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:62:1 | 61 | t'normal {t'nested'} normal' 62 | t'\'normal\' {t'nested'} normal' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | t'\'normal\' {t'nested'} "double quotes"' 64 | t'\'normal\' {t'\'nested\' {'other'} normal'} "double quotes"' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 59 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 @@ -423,15 +444,16 @@ doubles_escaped.py:62:1: Q003 [*] Change outer quotes to avoid escaping inner qu 64 64 | t'\'normal\' {t'\'nested\' {'other'} normal'} "double quotes"' # Q003 65 65 | t'\'normal\' {t'\'nested\' {'other'} "double quotes"'} normal' # Q00l -doubles_escaped.py:64:15: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:64:15 | 62 | t'\'normal\' {t'nested'} normal' # Q003 63 | t'\'normal\' {t'nested'} "double quotes"' 64 | t'\'normal\' {t'\'nested\' {'other'} normal'} "double quotes"' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 | t'\'normal\' {t'\'nested\' {'other'} "double quotes"'} normal' # Q00l | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 61 61 | t'normal {t'nested'} normal' @@ -441,14 +463,15 @@ doubles_escaped.py:64:15: Q003 [*] Change outer quotes to avoid escaping inner q 64 |+t'\'normal\' {t"'nested' {'other'} normal"} "double quotes"' # Q003 65 65 | t'\'normal\' {t'\'nested\' {'other'} "double quotes"'} normal' # Q00l -doubles_escaped.py:65:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:65:1 | 63 | t'\'normal\' {t'nested'} "double quotes"' 64 | t'\'normal\' {t'\'nested\' {'other'} normal'} "double quotes"' # Q003 65 | t'\'normal\' {t'\'nested\' {'other'} "double quotes"'} normal' # Q00l - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 62 62 | t'\'normal\' {t'nested'} normal' # Q003 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_py311.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_py311.snap index 6b0b2348ca..57bcec82b5 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_py311.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_py311.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:1:26 | 1 | this_should_raise_Q003 = 'This is a \'string\'' - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' 3 | this_is_fine = '"This" is a \'string\'' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 1 |-this_should_raise_Q003 = 'This is a \'string\'' @@ -17,15 +18,16 @@ doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner qu 3 3 | this_is_fine = '"This" is a \'string\'' 4 4 | this_is_fine = "This is a 'string'" -doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:2:26 | 1 | this_should_raise_Q003 = 'This is a \'string\'' 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | this_is_fine = '"This" is a \'string\'' 4 | this_is_fine = "This is a 'string'" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 1 1 | this_should_raise_Q003 = 'This is a \'string\'' @@ -35,15 +37,16 @@ doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner qu 4 4 | this_is_fine = "This is a 'string'" 5 5 | this_is_fine = "\"This\" is a 'string'" -doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:10:5 | 8 | this_should_raise = ( 9 | 'This is a' 10 | '\'string\'' - | ^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^ 11 | ) | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 7 7 | this_is_fine = R'This is a \'string\'' @@ -55,15 +58,16 @@ doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner qu 12 12 | 13 13 | # Same as above, but with f-strings -doubles_escaped.py:14:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:14:1 | 13 | # Same as above, but with f-strings 14 | f'This is a \'string\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^ 15 | f'This is \\ a \\\'string\'' # Q003 16 | f'"This" is a \'string\'' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 11 11 | ) @@ -75,16 +79,17 @@ doubles_escaped.py:14:1: Q003 [*] Change outer quotes to avoid escaping inner qu 16 16 | f'"This" is a \'string\'' 17 17 | f"This is a 'string'" -doubles_escaped.py:15:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:15:1 | 13 | # Same as above, but with f-strings 14 | f'This is a \'string\'' # Q003 15 | f'This is \\ a \\\'string\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | f'"This" is a \'string\'' 17 | f"This is a 'string'" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 12 12 | @@ -96,15 +101,16 @@ doubles_escaped.py:15:1: Q003 [*] Change outer quotes to avoid escaping inner qu 17 17 | f"This is a 'string'" 18 18 | f"\"This\" is a 'string'" -doubles_escaped.py:23:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:23:5 | 21 | foo = ( 22 | f'This is a' 23 | f'\'string\'' # Q003 - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 24 | ) | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 20 20 | fR'This is a \'string\'' @@ -116,15 +122,16 @@ doubles_escaped.py:23:5: Q003 [*] Change outer quotes to avoid escaping inner qu 25 25 | 26 26 | # Nested f-strings (Python 3.12+) -doubles_escaped.py:46:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:46:1 | 45 | # Same as above, but with t-strings 46 | t'This is a \'string\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^ 47 | t'This is \\ a \\\'string\'' # Q003 48 | t'"This" is a \'string\'' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 43 43 | @@ -136,16 +143,17 @@ doubles_escaped.py:46:1: Q003 [*] Change outer quotes to avoid escaping inner qu 48 48 | t'"This" is a \'string\'' 49 49 | f"This is a 'string'" -doubles_escaped.py:47:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:47:1 | 45 | # Same as above, but with t-strings 46 | t'This is a \'string\'' # Q003 47 | t'This is \\ a \\\'string\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | t'"This" is a \'string\'' 49 | f"This is a 'string'" | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 44 44 | @@ -157,16 +165,17 @@ doubles_escaped.py:47:1: Q003 [*] Change outer quotes to avoid escaping inner qu 49 49 | f"This is a 'string'" 50 50 | f"\"This\" is a 'string'" -doubles_escaped.py:55:5: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:55:5 | 53 | foo = ( 54 | t'This is a' 55 | t'\'string\'' # Q003 - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 56 | ) 57 | t'\'foo\' {'nested'}' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 52 52 | fR'This is a \'string\'' @@ -178,16 +187,17 @@ doubles_escaped.py:55:5: Q003 [*] Change outer quotes to avoid escaping inner qu 57 57 | t'\'foo\' {'nested'}' # Q003 58 58 | t'\'foo\' {t'nested'}' # Q003 -doubles_escaped.py:57:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:57:1 | 55 | t'\'string\'' # Q003 56 | ) 57 | t'\'foo\' {'nested'}' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^ 58 | t'\'foo\' {t'nested'}' # Q003 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 54 54 | t'This is a' @@ -199,15 +209,16 @@ doubles_escaped.py:57:1: Q003 [*] Change outer quotes to avoid escaping inner qu 59 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 60 60 | -doubles_escaped.py:58:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:58:1 | 56 | ) 57 | t'\'foo\' {'nested'}' # Q003 58 | t'\'foo\' {t'nested'}' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^ 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 55 55 | t'\'string\'' # Q003 @@ -219,16 +230,17 @@ doubles_escaped.py:58:1: Q003 [*] Change outer quotes to avoid escaping inner qu 60 60 | 61 61 | t'normal {t'nested'} normal' -doubles_escaped.py:59:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:59:1 | 57 | t'\'foo\' {'nested'}' # Q003 58 | t'\'foo\' {t'nested'}' # Q003 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | 61 | t'normal {t'nested'} normal' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 56 56 | ) @@ -240,16 +252,17 @@ doubles_escaped.py:59:1: Q003 [*] Change outer quotes to avoid escaping inner qu 61 61 | t'normal {t'nested'} normal' 62 62 | t'\'normal\' {t'nested'} normal' # Q003 -doubles_escaped.py:59:12: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:59:12 | 57 | t'\'foo\' {'nested'}' # Q003 58 | t'\'foo\' {t'nested'}' # Q003 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 - | ^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^ 60 | 61 | t'normal {t'nested'} normal' | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 56 56 | ) @@ -261,15 +274,16 @@ doubles_escaped.py:59:12: Q003 [*] Change outer quotes to avoid escaping inner q 61 61 | t'normal {t'nested'} normal' 62 62 | t'\'normal\' {t'nested'} normal' # Q003 -doubles_escaped.py:62:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:62:1 | 61 | t'normal {t'nested'} normal' 62 | t'\'normal\' {t'nested'} normal' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | t'\'normal\' {t'nested'} "double quotes"' 64 | t'\'normal\' {t'\'nested\' {'other'} normal'} "double quotes"' # Q003 | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 59 59 | t'\'foo\' {t'\'nested\''} \'\'' # Q003 @@ -281,15 +295,16 @@ doubles_escaped.py:62:1: Q003 [*] Change outer quotes to avoid escaping inner qu 64 64 | t'\'normal\' {t'\'nested\' {'other'} normal'} "double quotes"' # Q003 65 65 | t'\'normal\' {t'\'nested\' {'other'} "double quotes"'} normal' # Q00l -doubles_escaped.py:64:15: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:64:15 | 62 | t'\'normal\' {t'nested'} normal' # Q003 63 | t'\'normal\' {t'nested'} "double quotes"' 64 | t'\'normal\' {t'\'nested\' {'other'} normal'} "double quotes"' # Q003 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 | t'\'normal\' {t'\'nested\' {'other'} "double quotes"'} normal' # Q00l | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 61 61 | t'normal {t'nested'} normal' @@ -299,14 +314,15 @@ doubles_escaped.py:64:15: Q003 [*] Change outer quotes to avoid escaping inner q 64 |+t'\'normal\' {t"'nested' {'other'} normal"} "double quotes"' # Q003 65 65 | t'\'normal\' {t'\'nested\' {'other'} "double quotes"'} normal' # Q00l -doubles_escaped.py:65:1: Q003 [*] Change outer quotes to avoid escaping inner quotes +Q003 [*] Change outer quotes to avoid escaping inner quotes + --> doubles_escaped.py:65:1 | 63 | t'\'normal\' {t'nested'} "double quotes"' 64 | t'\'normal\' {t'\'nested\' {'other'} normal'} "double quotes"' # Q003 65 | t'\'normal\' {t'\'nested\' {'other'} "double quotes"'} normal' # Q00l - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Change outer quotes to avoid escaping inner quotes +help: Change outer quotes to avoid escaping inner quotes ℹ Safe fix 62 62 | t'\'normal\' {t'nested'} normal' # Q003 diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap index 3cf6da94bb..5acb1b7482 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped_unnecessary.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -doubles_escaped_unnecessary.py:1:26: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:1:26 | 1 | this_should_raise_Q004 = 'This is a \"string\"' - | ^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | this_should_raise_Q004 = 'This is \\ a \\\"string\"' 3 | this_is_fine = '"This" is a \"string\"' | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 1 |-this_should_raise_Q004 = 'This is a \"string\"' @@ -17,15 +18,16 @@ doubles_escaped_unnecessary.py:1:26: Q004 [*] Unnecessary escape on inner quote 3 3 | this_is_fine = '"This" is a \"string\"' 4 4 | this_is_fine = "This is a 'string'" -doubles_escaped_unnecessary.py:2:26: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:2:26 | 1 | this_should_raise_Q004 = 'This is a \"string\"' 2 | this_should_raise_Q004 = 'This is \\ a \\\"string\"' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | this_is_fine = '"This" is a \"string\"' 4 | this_is_fine = "This is a 'string'" | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 1 1 | this_should_raise_Q004 = 'This is a \"string\"' @@ -35,16 +37,17 @@ doubles_escaped_unnecessary.py:2:26: Q004 [*] Unnecessary escape on inner quote 4 4 | this_is_fine = "This is a 'string'" 5 5 | this_is_fine = "\"This\" is a 'string'" -doubles_escaped_unnecessary.py:3:16: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:3:16 | 1 | this_should_raise_Q004 = 'This is a \"string\"' 2 | this_should_raise_Q004 = 'This is \\ a \\\"string\"' 3 | this_is_fine = '"This" is a \"string\"' - | ^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 4 | this_is_fine = "This is a 'string'" 5 | this_is_fine = "\"This\" is a 'string'" | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 1 1 | this_should_raise_Q004 = 'This is a \"string\"' @@ -55,15 +58,16 @@ doubles_escaped_unnecessary.py:3:16: Q004 [*] Unnecessary escape on inner quote 5 5 | this_is_fine = "\"This\" is a 'string'" 6 6 | this_is_fine = r'This is a \"string\"' -doubles_escaped_unnecessary.py:10:5: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:10:5 | 8 | this_should_raise_Q004 = ( 9 | 'This is a' 10 | '\"string\"' - | ^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^ 11 | ) | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 7 7 | this_is_fine = R'This is a \"string\"' @@ -75,15 +79,16 @@ doubles_escaped_unnecessary.py:10:5: Q004 [*] Unnecessary escape on inner quote 12 12 | 13 13 | # Same as above, but with f-strings -doubles_escaped_unnecessary.py:14:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:14:1 | 13 | # Same as above, but with f-strings 14 | f'This is a \"string\"' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^ 15 | f'This is \\ a \\\"string\"' # Q004 16 | f'"This" is a \"string\"' | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 11 11 | ) @@ -95,16 +100,17 @@ doubles_escaped_unnecessary.py:14:1: Q004 [*] Unnecessary escape on inner quote 16 16 | f'"This" is a \"string\"' 17 17 | f"This is a 'string'" -doubles_escaped_unnecessary.py:15:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:15:1 | 13 | # Same as above, but with f-strings 14 | f'This is a \"string\"' # Q004 15 | f'This is \\ a \\\"string\"' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | f'"This" is a \"string\"' 17 | f"This is a 'string'" | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 12 12 | @@ -116,16 +122,17 @@ doubles_escaped_unnecessary.py:15:1: Q004 [*] Unnecessary escape on inner quote 17 17 | f"This is a 'string'" 18 18 | f"\"This\" is a 'string'" -doubles_escaped_unnecessary.py:16:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:16:1 | 14 | f'This is a \"string\"' # Q004 15 | f'This is \\ a \\\"string\"' # Q004 16 | f'"This" is a \"string\"' - | ^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | f"This is a 'string'" 18 | f"\"This\" is a 'string'" | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 13 13 | # Same as above, but with f-strings @@ -137,15 +144,16 @@ doubles_escaped_unnecessary.py:16:1: Q004 [*] Unnecessary escape on inner quote 18 18 | f"\"This\" is a 'string'" 19 19 | fr'This is a \"string\"' -doubles_escaped_unnecessary.py:23:5: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:23:5 | 21 | this_should_raise_Q004 = ( 22 | f'This is a' 23 | f'\"string\"' # Q004 - | ^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^ 24 | ) | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 20 20 | fR'This is a \"string\"' @@ -157,16 +165,17 @@ doubles_escaped_unnecessary.py:23:5: Q004 [*] Unnecessary escape on inner quote 25 25 | 26 26 | # Nested f-strings (Python 3.12+) -doubles_escaped_unnecessary.py:33:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:33:1 | 31 | # 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 | f'\"foo\" {'nested'}' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^ 34 | f'\"foo\" {f'nested'}' # Q004 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 30 30 | # f"'foo' {'nested'}" @@ -178,15 +187,16 @@ doubles_escaped_unnecessary.py:33:1: Q004 [*] Unnecessary escape on inner quote 35 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 36 36 | -doubles_escaped_unnecessary.py:34:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:34:1 | 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. 33 | f'\"foo\" {'nested'}' # Q004 34 | f'\"foo\" {f'nested'}' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^ 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 31 31 | # @@ -198,16 +208,17 @@ doubles_escaped_unnecessary.py:34:1: Q004 [*] Unnecessary escape on inner quote 36 36 | 37 37 | f'normal {f'nested'} normal' -doubles_escaped_unnecessary.py:35:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:35:1 | 33 | f'\"foo\" {'nested'}' # Q004 34 | f'\"foo\" {f'nested'}' # Q004 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | 37 | f'normal {f'nested'} normal' | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -219,16 +230,17 @@ doubles_escaped_unnecessary.py:35:1: Q004 [*] Unnecessary escape on inner quote 37 37 | f'normal {f'nested'} normal' 38 38 | f'\"normal\" {f'nested'} normal' # Q004 -doubles_escaped_unnecessary.py:35:12: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:35:12 | 33 | f'\"foo\" {'nested'}' # Q004 34 | f'\"foo\" {f'nested'}' # Q004 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 - | ^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^ 36 | 37 | f'normal {f'nested'} normal' | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 32 32 | # but as the actual string itself is invalid pre 3.12, we don't catch it. @@ -240,15 +252,16 @@ doubles_escaped_unnecessary.py:35:12: Q004 [*] Unnecessary escape on inner quote 37 37 | f'normal {f'nested'} normal' 38 38 | f'\"normal\" {f'nested'} normal' # Q004 -doubles_escaped_unnecessary.py:38:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:38:1 | 37 | f'normal {f'nested'} normal' 38 | f'\"normal\" {f'nested'} normal' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | f'\"normal\" {f'nested'} "double quotes"' 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 35 35 | f'\"foo\" {f'\"nested\"'} \"\"' # Q004 @@ -260,16 +273,17 @@ doubles_escaped_unnecessary.py:38:1: Q004 [*] Unnecessary escape on inner quote 40 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 41 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 -doubles_escaped_unnecessary.py:39:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:39:1 | 37 | f'normal {f'nested'} normal' 38 | f'\"normal\" {f'nested'} normal' # Q004 39 | f'\"normal\" {f'nested'} "double quotes"' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 36 36 | @@ -281,15 +295,16 @@ doubles_escaped_unnecessary.py:39:1: Q004 [*] Unnecessary escape on inner quote 41 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 42 42 | -doubles_escaped_unnecessary.py:40:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:40:1 | 38 | f'\"normal\" {f'nested'} normal' # Q004 39 | f'\"normal\" {f'nested'} "double quotes"' 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 37 37 | f'normal {f'nested'} normal' @@ -301,15 +316,16 @@ doubles_escaped_unnecessary.py:40:1: Q004 [*] Unnecessary escape on inner quote 42 42 | 43 43 | # Make sure we do not unescape quotes -doubles_escaped_unnecessary.py:40:15: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:40:15 | 38 | f'\"normal\" {f'nested'} normal' # Q004 39 | f'\"normal\" {f'nested'} "double quotes"' 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 37 37 | f'normal {f'nested'} normal' @@ -321,16 +337,17 @@ doubles_escaped_unnecessary.py:40:15: Q004 [*] Unnecessary escape on inner quote 42 42 | 43 43 | # Make sure we do not unescape quotes -doubles_escaped_unnecessary.py:41:1: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:41:1 | 39 | f'\"normal\" {f'nested'} "double quotes"' 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | 43 | # Make sure we do not unescape quotes | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 38 38 | f'\"normal\" {f'nested'} normal' # Q004 @@ -342,16 +359,17 @@ doubles_escaped_unnecessary.py:41:1: Q004 [*] Unnecessary escape on inner quote 43 43 | # Make sure we do not unescape quotes 44 44 | this_is_fine = 'This is an \\"escaped\\" quote' -doubles_escaped_unnecessary.py:41:15: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:41:15 | 39 | f'\"normal\" {f'nested'} "double quotes"' 40 | f'\"normal\" {f'\"nested\" {'other'} normal'} "double quotes"' # Q004 41 | f'\"normal\" {f'\"nested\" {'other'} "double quotes"'} normal' # Q004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | 43 | # Make sure we do not unescape quotes | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 38 38 | f'\"normal\" {f'nested'} normal' # Q004 @@ -363,14 +381,15 @@ doubles_escaped_unnecessary.py:41:15: Q004 [*] Unnecessary escape on inner quote 43 43 | # Make sure we do not unescape quotes 44 44 | this_is_fine = 'This is an \\"escaped\\" quote' -doubles_escaped_unnecessary.py:45:26: Q004 [*] Unnecessary escape on inner quote character +Q004 [*] Unnecessary escape on inner quote character + --> doubles_escaped_unnecessary.py:45:26 | 43 | # Make sure we do not unescape quotes 44 | this_is_fine = 'This is an \\"escaped\\" quote' 45 | this_should_raise_Q004 = 'This is an \\\"escaped\\\" quote with an extra backslash' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove backslash +help: Remove backslash ℹ Safe fix 42 42 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap index d5b4db8f28..4779f6fd3a 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -doubles_implicit.py:2:5: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_implicit.py:2:5 | 1 | x = ( 2 | "This" - | ^^^^^^ Q000 + | ^^^^^^ 3 | "is" 4 | "not" | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 1 1 | x = ( @@ -20,16 +20,17 @@ doubles_implicit.py:2:5: Q000 [*] Double quotes found but single quotes preferre 4 4 | "not" 5 5 | ) -doubles_implicit.py:3:5: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_implicit.py:3:5 | 1 | x = ( 2 | "This" 3 | "is" - | ^^^^ Q000 + | ^^^^ 4 | "not" 5 | ) | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 1 1 | x = ( @@ -40,15 +41,16 @@ doubles_implicit.py:3:5: Q000 [*] Double quotes found but single quotes preferre 5 5 | ) 6 6 | -doubles_implicit.py:4:5: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_implicit.py:4:5 | 2 | "This" 3 | "is" 4 | "not" - | ^^^^^ Q000 + | ^^^^^ 5 | ) | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 1 1 | x = ( @@ -60,15 +62,16 @@ doubles_implicit.py:4:5: Q000 [*] Double quotes found but single quotes preferre 6 6 | 7 7 | x = ( -doubles_implicit.py:8:5: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_implicit.py:8:5 | 7 | x = ( 8 | "This" \ - | ^^^^^^ Q000 + | ^^^^^^ 9 | "is" \ 10 | "not" | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 5 5 | ) @@ -80,16 +83,17 @@ doubles_implicit.py:8:5: Q000 [*] Double quotes found but single quotes preferre 10 10 | "not" 11 11 | ) -doubles_implicit.py:9:5: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_implicit.py:9:5 | 7 | x = ( 8 | "This" \ 9 | "is" \ - | ^^^^ Q000 + | ^^^^ 10 | "not" 11 | ) | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 6 6 | @@ -101,15 +105,16 @@ doubles_implicit.py:9:5: Q000 [*] Double quotes found but single quotes preferre 11 11 | ) 12 12 | -doubles_implicit.py:10:5: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_implicit.py:10:5 | 8 | "This" \ 9 | "is" \ 10 | "not" - | ^^^^^ Q000 + | ^^^^^ 11 | ) | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 7 7 | x = ( @@ -121,14 +126,15 @@ doubles_implicit.py:10:5: Q000 [*] Double quotes found but single quotes preferr 12 12 | 13 13 | x = ( -doubles_implicit.py:27:1: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_implicit.py:27:1 | 25 | if True: 26 | "This can use 'double' quotes" 27 | "But this needs to be changed" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q000 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 24 24 | diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap index 7d40683d00..f5e48ab14d 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs --- -doubles_multiline_string.py:1:5: Q001 [*] Double quote multiline found but single quotes preferred +Q001 [*] Double quote multiline found but single quotes preferred + --> doubles_multiline_string.py:1:5 | 1 | s = """ This "should" | _____^ 2 | | be 3 | | "linted" """ - | |____________^ Q001 + | |____________^ 4 | 5 | s = ''' This "should" | - = help: Replace double multiline quotes with single quotes +help: Replace double multiline quotes with single quotes ℹ Safe fix 1 |-s = """ This "should" diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_would_be_triple_quotes.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_would_be_triple_quotes.py.snap index 5d48f06a35..95e36269b3 100644 --- a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_would_be_triple_quotes.py.snap +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_would_be_triple_quotes.py.snap @@ -1,22 +1,23 @@ --- source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs -snapshot_kind: text --- -doubles_would_be_triple_quotes.py:1:5: Q000 Double quotes found but single quotes preferred +Q000 Double quotes found but single quotes preferred + --> doubles_would_be_triple_quotes.py:1:5 | 1 | s = ""'Start with empty string' ' and lint docstring safely' - | ^^ Q000 + | ^^ 2 | s = "Do not"' start with empty string' ' and lint docstring safely' | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes -doubles_would_be_triple_quotes.py:2:5: Q000 [*] Double quotes found but single quotes preferred +Q000 [*] Double quotes found but single quotes preferred + --> doubles_would_be_triple_quotes.py:2:5 | 1 | s = ""'Start with empty string' ' and lint docstring safely' 2 | s = "Do not"' start with empty string' ' and lint docstring safely' - | ^^^^^^^^ Q000 + | ^^^^^^^^ | - = help: Replace double quotes with single quotes +help: Replace double quotes with single quotes ℹ Safe fix 1 1 | s = ""'Start with empty string' ' and lint docstring safely' diff --git a/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap b/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap index 3807968147..2ff56deeef 100644 --- a/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_raise/mod.rs --- -RSE102.py:5:21: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:5:21 | 3 | except TypeError: 4 | # RSE102 5 | raise ValueError() - | ^^ RSE102 + | ^^ 6 | 7 | try: | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 2 2 | y = 6 + "7" @@ -22,15 +23,16 @@ RSE102.py:5:21: RSE102 [*] Unnecessary parentheses on raised exception 7 7 | try: 8 8 | x = 1 / 0 -RSE102.py:13:16: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:13:16 | 12 | # RSE102 13 | raise TypeError() - | ^^ RSE102 + | ^^ 14 | 15 | # RSE102 | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 10 10 | raise @@ -42,15 +44,16 @@ RSE102.py:13:16: RSE102 [*] Unnecessary parentheses on raised exception 15 15 | # RSE102 16 16 | raise TypeError () -RSE102.py:16:17: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:16:17 | 15 | # RSE102 16 | raise TypeError () - | ^^ RSE102 + | ^^ 17 | 18 | # RSE102 | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 13 13 | raise TypeError() @@ -62,16 +65,17 @@ RSE102.py:16:17: RSE102 [*] Unnecessary parentheses on raised exception 18 18 | # RSE102 19 19 | raise TypeError \ -RSE102.py:20:5: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:20:5 | 18 | # RSE102 19 | raise TypeError \ 20 | () - | ^^ RSE102 + | ^^ 21 | 22 | # RSE102 | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 17 17 | @@ -83,16 +87,17 @@ RSE102.py:20:5: RSE102 [*] Unnecessary parentheses on raised exception 22 22 | # RSE102 23 23 | raise TypeError \ -RSE102.py:24:5: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:24:5 | 22 | # RSE102 23 | raise TypeError \ 24 | (); - | ^^ RSE102 + | ^^ 25 | 26 | # RSE102 | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 21 21 | @@ -104,18 +109,19 @@ RSE102.py:24:5: RSE102 [*] Unnecessary parentheses on raised exception 26 26 | # RSE102 27 27 | raise TypeError( -RSE102.py:27:16: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:27:16 | 26 | # RSE102 27 | raise TypeError( | ________________^ 28 | | 29 | | ) - | |_^ RSE102 + | |_^ 30 | 31 | # RSE102 | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 24 24 | (); @@ -129,18 +135,19 @@ RSE102.py:27:16: RSE102 [*] Unnecessary parentheses on raised exception 31 29 | # RSE102 32 30 | raise (TypeError) ( -RSE102.py:32:19: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:32:19 | 31 | # RSE102 32 | raise (TypeError) ( | ___________________^ 33 | | 34 | | ) - | |_^ RSE102 + | |_^ 35 | 36 | # RSE102 | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 29 29 | ) @@ -154,18 +161,19 @@ RSE102.py:32:19: RSE102 [*] Unnecessary parentheses on raised exception 36 34 | # RSE102 37 35 | raise TypeError( -RSE102.py:37:16: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:37:16 | 36 | # RSE102 37 | raise TypeError( | ________________^ 38 | | # Hello, world! 39 | | ) - | |_^ RSE102 + | |_^ 40 | 41 | # OK | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Unsafe fix 34 34 | ) @@ -179,15 +187,16 @@ RSE102.py:37:16: RSE102 [*] Unnecessary parentheses on raised exception 41 39 | # OK 42 40 | raise AssertionError -RSE102.py:74:17: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:74:17 | 73 | # RSE102 74 | raise IndexError()from ZeroDivisionError - | ^^ RSE102 + | ^^ 75 | 76 | raise IndexError()\ | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 71 71 | @@ -199,15 +208,16 @@ RSE102.py:74:17: RSE102 [*] Unnecessary parentheses on raised exception 76 76 | raise IndexError()\ 77 77 | from ZeroDivisionError -RSE102.py:76:17: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:76:17 | 74 | raise IndexError()from ZeroDivisionError 75 | 76 | raise IndexError()\ - | ^^ RSE102 + | ^^ 77 | from ZeroDivisionError | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 73 73 | # RSE102 @@ -219,16 +229,17 @@ RSE102.py:76:17: RSE102 [*] Unnecessary parentheses on raised exception 78 78 | 79 79 | raise IndexError() from ZeroDivisionError -RSE102.py:79:17: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:79:17 | 77 | from ZeroDivisionError 78 | 79 | raise IndexError() from ZeroDivisionError - | ^^ RSE102 + | ^^ 80 | 81 | raise IndexError(); | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 76 76 | raise IndexError()\ @@ -240,16 +251,17 @@ RSE102.py:79:17: RSE102 [*] Unnecessary parentheses on raised exception 81 81 | raise IndexError(); 82 82 | -RSE102.py:81:17: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:81:17 | 79 | raise IndexError() from ZeroDivisionError 80 | 81 | raise IndexError(); - | ^^ RSE102 + | ^^ 82 | 83 | # RSE102 | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 78 78 | @@ -261,15 +273,16 @@ RSE102.py:81:17: RSE102 [*] Unnecessary parentheses on raised exception 83 83 | # RSE102 84 84 | raise Foo() -RSE102.py:84:10: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:84:10 | 83 | # RSE102 84 | raise Foo() - | ^^ RSE102 + | ^^ 85 | 86 | # OK | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Unsafe fix 81 81 | raise IndexError(); @@ -281,14 +294,15 @@ RSE102.py:84:10: RSE102 [*] Unnecessary parentheses on raised exception 86 86 | # OK 87 87 | raise ctypes.WinError() -RSE102.py:107:27: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:107:27 | 105 | future = executor.submit(float, "a") 106 | if future.exception(): 107 | raise future.Exception() - | ^^ RSE102 + | ^^ | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Unsafe fix 104 104 | # RSE102 @@ -300,15 +314,16 @@ RSE102.py:107:27: RSE102 [*] Unnecessary parentheses on raised exception 109 109 | 110 110 | raise TypeError( -RSE102.py:110:16: RSE102 [*] Unnecessary parentheses on raised exception +RSE102 [*] Unnecessary parentheses on raised exception + --> RSE102.py:110:16 | 110 | raise TypeError( | ________________^ 111 | | # comment 112 | | ) - | |_^ RSE102 + | |_^ | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Unsafe fix 107 107 | raise future.Exception() diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap index 6afa398d94..a1076f9ab8 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs --- -RET501.py:4:5: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value +RET501 [*] Do not explicitly `return None` in function if it is the only possible return value + --> RET501.py:4:5 | 2 | if not y: 3 | return 4 | return None # error - | ^^^^^^^^^^^ RET501 + | ^^^^^^^^^^^ | - = help: Remove explicit `return None` +help: Remove explicit `return None` ℹ Safe fix 1 1 | def x(y): @@ -20,16 +21,17 @@ RET501.py:4:5: RET501 [*] Do not explicitly `return None` in function if it is t 6 6 | 7 7 | class BaseCache: -RET501.py:14:9: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value +RET501 [*] Do not explicitly `return None` in function if it is the only possible return value + --> RET501.py:14:9 | 12 | def get(self, key: str) -> None: 13 | print(f"{key} not found") 14 | return None - | ^^^^^^^^^^^ RET501 + | ^^^^^^^^^^^ 15 | 16 | @property | - = help: Remove explicit `return None` +help: Remove explicit `return None` ℹ Safe fix 11 11 | @@ -41,16 +43,17 @@ RET501.py:14:9: RET501 [*] Do not explicitly `return None` in function if it is 16 16 | @property 17 17 | def prop(self) -> None: -RET501.py:59:9: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value +RET501 [*] Do not explicitly `return None` in function if it is the only possible return value + --> RET501.py:59:9 | 57 | if not bar: 58 | return 59 | / return ( 60 | | None # comment 61 | | ) - | |_________^ RET501 + | |_________^ | - = help: Remove explicit `return None` +help: Remove explicit `return None` ℹ Unsafe fix 56 56 | def foo(bar): diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap index 8006570b6d..fcff245de3 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs -snapshot_kind: text --- -RET502.py:3:9: RET502 [*] Do not implicitly `return None` in function able to return non-`None` value +RET502 [*] Do not implicitly `return None` in function able to return non-`None` value + --> RET502.py:3:9 | 1 | def x(y): 2 | if not y: 3 | return # error - | ^^^^^^ RET502 + | ^^^^^^ 4 | return 1 | - = help: Add explicit `None` return value +help: Add explicit `None` return value ℹ Safe fix 1 1 | def x(y): diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap index 91c961e509..5d6e25f2b4 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs --- -RET503.py:20:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:20:1 | 19 | # if/elif/else 20 | / def x(y): 21 | | if not y: 22 | | return 1 - | |________________^ RET503 + | |________________^ 23 | # error | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 20 20 | def x(y): @@ -21,16 +22,17 @@ RET503.py:20:1: RET503 [*] Missing explicit `return` at the end of function able 24 25 | 25 26 | -RET503.py:26:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:26:1 | 26 | / def x(y): 27 | | if not y: 28 | | print() # error 29 | | else: 30 | | return 2 - | |________________^ RET503 + | |________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 28 28 | print() # error @@ -41,16 +43,17 @@ RET503.py:26:1: RET503 [*] Missing explicit `return` at the end of function able 32 33 | 33 34 | def x(y): -RET503.py:33:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:33:1 | 33 | / def x(y): 34 | | if not y: 35 | | return 1 36 | | 37 | | print() # error - | |___________^ RET503 + | |___________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 35 35 | return 1 @@ -61,17 +64,18 @@ RET503.py:33:1: RET503 [*] Missing explicit `return` at the end of function able 39 40 | 40 41 | # for -RET503.py:41:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:41:1 | 40 | # for 41 | / def x(y): 42 | | for i in range(10): 43 | | if i > 10: 44 | | return i - | |____________________^ RET503 + | |____________________^ 45 | # error | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 42 42 | for i in range(10): @@ -82,7 +86,8 @@ RET503.py:41:1: RET503 [*] Missing explicit `return` at the end of function able 46 47 | 47 48 | -RET503.py:48:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:48:1 | 48 | / def x(y): 49 | | for i in range(10): @@ -90,9 +95,9 @@ RET503.py:48:1: RET503 [*] Missing explicit `return` at the end of function able 51 | | return i 52 | | else: 53 | | print() # error - | |_______________^ RET503 + | |_______________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 51 51 | return i @@ -103,16 +108,17 @@ RET503.py:48:1: RET503 [*] Missing explicit `return` at the end of function able 55 56 | 56 57 | # A nonexistent function -RET503.py:57:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:57:1 | 56 | # A nonexistent function 57 | / def func_unknown(x): 58 | | if x > 0: 59 | | return False 60 | | no_such_function() # error - | |______________________^ RET503 + | |______________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 58 58 | if x > 0: @@ -123,16 +129,17 @@ RET503.py:57:1: RET503 [*] Missing explicit `return` at the end of function able 62 63 | 63 64 | # A function that does return the control -RET503.py:64:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:64:1 | 63 | # A function that does return the control 64 | / def func_no_noreturn(x): 65 | | if x > 0: 66 | | return False 67 | | print("", end="") # error - | |_____________________^ RET503 + | |_____________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 65 65 | if x > 0: @@ -143,7 +150,8 @@ RET503.py:64:1: RET503 [*] Missing explicit `return` at the end of function able 69 70 | 70 71 | ### -RET503.py:82:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:82:1 | 81 | # last line in while loop 82 | / def x(y): @@ -151,9 +159,9 @@ RET503.py:82:1: RET503 [*] Missing explicit `return` at the end of function able 84 | | if y > 0: 85 | | return 1 86 | | y += 1 - | |______________^ RET503 + | |______________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 84 84 | if y > 0: @@ -164,7 +172,8 @@ RET503.py:82:1: RET503 [*] Missing explicit `return` at the end of function able 88 89 | 89 90 | # exclude empty functions -RET503.py:113:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:113:1 | 112 | # return value within loop 113 | / def bar1(x, y, z): @@ -172,9 +181,9 @@ RET503.py:113:1: RET503 [*] Missing explicit `return` at the end of function abl 115 | | if i > y: 116 | | break 117 | | return z - | |________________^ RET503 + | |________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 115 115 | if i > y: @@ -185,7 +194,8 @@ RET503.py:113:1: RET503 [*] Missing explicit `return` at the end of function abl 119 120 | 120 121 | def bar3(x, y, z): -RET503.py:120:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:120:1 | 120 | / def bar3(x, y, z): 121 | | for i in x: @@ -195,9 +205,9 @@ RET503.py:120:1: RET503 [*] Missing explicit `return` at the end of function abl 125 | | else: 126 | | return z 127 | | return None - | |___________________^ RET503 + | |___________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 125 125 | else: @@ -208,16 +218,17 @@ RET503.py:120:1: RET503 [*] Missing explicit `return` at the end of function abl 129 130 | 130 131 | def bar1(x, y, z): -RET503.py:130:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:130:1 | 130 | / def bar1(x, y, z): 131 | | for i in x: 132 | | if i < y: 133 | | continue 134 | | return z - | |________________^ RET503 + | |________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 132 132 | if i < y: @@ -228,7 +239,8 @@ RET503.py:130:1: RET503 [*] Missing explicit `return` at the end of function abl 136 137 | 137 138 | def bar3(x, y, z): -RET503.py:137:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:137:1 | 137 | / def bar3(x, y, z): 138 | | for i in x: @@ -238,9 +250,9 @@ RET503.py:137:1: RET503 [*] Missing explicit `return` at the end of function abl 142 | | else: 143 | | return z 144 | | return None - | |___________________^ RET503 + | |___________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 142 142 | else: @@ -251,7 +263,8 @@ RET503.py:137:1: RET503 [*] Missing explicit `return` at the end of function abl 146 147 | 147 148 | def prompts(self, foo): -RET503.py:271:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:271:1 | 271 | / def nested(values): 272 | | if not values: @@ -259,9 +272,9 @@ RET503.py:271:1: RET503 [*] Missing explicit `return` at the end of function abl 274 | | 275 | | for value in values: 276 | | print(value) - | |____________________^ RET503 + | |____________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 274 274 | @@ -272,7 +285,8 @@ RET503.py:271:1: RET503 [*] Missing explicit `return` at the end of function abl 278 279 | 279 280 | def while_true(): -RET503.py:287:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:287:1 | 286 | # match 287 | / def x(y): @@ -281,9 +295,9 @@ RET503.py:287:1: RET503 [*] Missing explicit `return` at the end of function abl 290 | | return 1 291 | | case 1: 292 | | print() # error - | |___________________^ RET503 + | |___________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 290 290 | return 1 @@ -294,15 +308,16 @@ RET503.py:287:1: RET503 [*] Missing explicit `return` at the end of function abl 294 295 | 295 296 | def foo(baz: str) -> str: -RET503.py:300:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:300:5 | 299 | def end_of_statement(): 300 | / def example(): 301 | | if True: 302 | | return "" - | |_____________________^ RET503 + | |_____________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 300 300 | def example(): @@ -313,14 +328,15 @@ RET503.py:300:5: RET503 [*] Missing explicit `return` at the end of function abl 304 305 | 305 306 | def example(): -RET503.py:305:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:305:5 | 305 | / def example(): 306 | | if True: 307 | | return "" - | |_____________________^ RET503 + | |_____________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 305 305 | def example(): @@ -331,14 +347,15 @@ RET503.py:305:5: RET503 [*] Missing explicit `return` at the end of function abl 309 310 | 310 311 | def example(): -RET503.py:310:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:310:5 | 310 | / def example(): 311 | | if True: 312 | | return "" # type: ignore - | |_____________________^ RET503 + | |_____________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 310 310 | def example(): @@ -349,14 +366,15 @@ RET503.py:310:5: RET503 [*] Missing explicit `return` at the end of function abl 314 315 | 315 316 | def example(): -RET503.py:315:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:315:5 | 315 | / def example(): 316 | | if True: 317 | | return "" ; - | |_____________________^ RET503 + | |_____________________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 315 315 | def example(): @@ -367,15 +385,16 @@ RET503.py:315:5: RET503 [*] Missing explicit `return` at the end of function abl 319 320 | 320 321 | def example(): -RET503.py:320:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:320:5 | 320 | / def example(): 321 | | if True: 322 | | return "" \ - | |_____________________^ RET503 + | |_____________________^ 323 | ; # type: ignore | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 321 321 | if True: @@ -386,15 +405,16 @@ RET503.py:320:5: RET503 [*] Missing explicit `return` at the end of function abl 325 326 | 326 327 | def end_of_file(): -RET503.py:326:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:326:1 | 326 | / def end_of_file(): 327 | | if False: 328 | | return 1 329 | | x = 2 \ - | |_________^ RET503 + | |_________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 328 328 | return 1 @@ -405,7 +425,8 @@ RET503.py:326:1: RET503 [*] Missing explicit `return` at the end of function abl 332 333 | 333 334 | # function return type annotation NoReturn -RET503.py:398:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:398:1 | 398 | / def f(): 399 | | if a: @@ -413,9 +434,9 @@ RET503.py:398:1: RET503 [*] Missing explicit `return` at the end of function abl 401 | | else: 402 | | with c: 403 | | d - | |_____________^ RET503 + | |_____________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 401 401 | else: @@ -426,7 +447,8 @@ RET503.py:398:1: RET503 [*] Missing explicit `return` at the end of function abl 405 406 | 406 407 | -RET503.py:413:1: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value +RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + --> RET503.py:413:1 | 411 | # the semantic model hasn't yet seen `bar`'s declaration. 412 | # Supporting nested functions requires making this a deferred rule. @@ -436,9 +458,9 @@ RET503.py:413:1: RET503 [*] Missing explicit `return` at the end of function abl 416 | | if x == 5: 417 | | return 5 418 | | bar() - | |_________^ RET503 + | |_________^ | - = help: Add explicit `return` statement +help: Add explicit `return` statement ℹ Unsafe fix 415 415 | abort() diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap index afad18563c..0aef5af4ed 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs --- -RET504.py:6:12: RET504 [*] Unnecessary assignment to `a` before `return` statement +RET504 [*] Unnecessary assignment to `a` before `return` statement + --> RET504.py:6:12 | 4 | def x(): 5 | a = 1 6 | return a # RET504 - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 2 2 | # Errors @@ -21,14 +22,15 @@ RET504.py:6:12: RET504 [*] Unnecessary assignment to `a` before `return` stateme 8 7 | 9 8 | # Can be refactored false positives -RET504.py:23:12: RET504 [*] Unnecessary assignment to `formatted` before `return` statement +RET504 [*] Unnecessary assignment to `formatted` before `return` statement + --> RET504.py:23:12 | 21 | # clean up after any blank components 22 | formatted = formatted.replace("()", "").replace(" ", " ").strip() 23 | return formatted - | ^^^^^^^^^ RET504 + | ^^^^^^^^^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 19 19 | def x(): @@ -41,14 +43,15 @@ RET504.py:23:12: RET504 [*] Unnecessary assignment to `formatted` before `return 25 24 | 26 25 | # https://github.com/afonasev/flake8-return/issues/47#issue-641117366 -RET504.py:246:12: RET504 [*] Unnecessary assignment to `queryset` before `return` statement +RET504 [*] Unnecessary assignment to `queryset` before `return` statement + --> RET504.py:246:12 | 244 | queryset = Model.filter(a=1) 245 | queryset = queryset.filter(c=3) 246 | return queryset - | ^^^^^^^^ RET504 + | ^^^^^^^^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 242 242 | @@ -61,14 +64,15 @@ RET504.py:246:12: RET504 [*] Unnecessary assignment to `queryset` before `return 248 247 | 249 248 | def get_queryset(): -RET504.py:251:12: RET504 [*] Unnecessary assignment to `queryset` before `return` statement +RET504 [*] Unnecessary assignment to `queryset` before `return` statement + --> RET504.py:251:12 | 249 | def get_queryset(): 250 | queryset = Model.filter(a=1) 251 | return queryset # RET504 - | ^^^^^^^^ RET504 + | ^^^^^^^^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 247 247 | @@ -81,14 +85,15 @@ RET504.py:251:12: RET504 [*] Unnecessary assignment to `queryset` before `return 253 252 | 254 253 | # Function arguments -RET504.py:269:12: RET504 [*] Unnecessary assignment to `val` before `return` statement +RET504 [*] Unnecessary assignment to `val` before `return` statement + --> RET504.py:269:12 | 267 | return val 268 | val = 1 269 | return val # RET504 - | ^^^ RET504 + | ^^^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 265 265 | def str_to_bool(val): @@ -101,14 +106,15 @@ RET504.py:269:12: RET504 [*] Unnecessary assignment to `val` before `return` sta 271 270 | 272 271 | def str_to_bool(val): -RET504.py:321:12: RET504 [*] Unnecessary assignment to `x` before `return` statement +RET504 [*] Unnecessary assignment to `x` before `return` statement + --> RET504.py:321:12 | 319 | with open("foo.txt", "r") as f: 320 | x = f.read() 321 | return x # RET504 - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 317 317 | # `with` statements @@ -121,14 +127,15 @@ RET504.py:321:12: RET504 [*] Unnecessary assignment to `x` before `return` state 323 322 | 324 323 | def foo(): -RET504.py:342:12: RET504 [*] Unnecessary assignment to `b` before `return` statement +RET504 [*] Unnecessary assignment to `b` before `return` statement + --> RET504.py:342:12 | 340 | a = 1 341 | b=a 342 | return b # RET504 - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 338 338 | # Fix cases @@ -141,14 +148,15 @@ RET504.py:342:12: RET504 [*] Unnecessary assignment to `b` before `return` state 344 343 | 345 344 | def foo(): -RET504.py:348:12: RET504 [*] Unnecessary assignment to `b` before `return` statement +RET504 [*] Unnecessary assignment to `b` before `return` statement + --> RET504.py:348:12 | 346 | a = 1 347 | b =a 348 | return b # RET504 - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 344 344 | @@ -161,14 +169,15 @@ RET504.py:348:12: RET504 [*] Unnecessary assignment to `b` before `return` state 350 349 | 351 350 | def foo(): -RET504.py:354:12: RET504 [*] Unnecessary assignment to `b` before `return` statement +RET504 [*] Unnecessary assignment to `b` before `return` statement + --> RET504.py:354:12 | 352 | a = 1 353 | b= a 354 | return b # RET504 - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 350 350 | @@ -181,14 +190,15 @@ RET504.py:354:12: RET504 [*] Unnecessary assignment to `b` before `return` state 356 355 | 357 356 | def foo(): -RET504.py:359:12: RET504 [*] Unnecessary assignment to `a` before `return` statement +RET504 [*] Unnecessary assignment to `a` before `return` statement + --> RET504.py:359:12 | 357 | def foo(): 358 | a = 1 # Comment 359 | return a - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 355 355 | @@ -201,14 +211,15 @@ RET504.py:359:12: RET504 [*] Unnecessary assignment to `a` before `return` state 361 360 | 362 361 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 -RET504.py:365:12: RET504 [*] Unnecessary assignment to `D` before `return` statement +RET504 [*] Unnecessary assignment to `D` before `return` statement + --> RET504.py:365:12 | 363 | def mavko_debari(P_kbar): 364 | D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 365 | return D - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 361 361 | @@ -221,14 +232,15 @@ RET504.py:365:12: RET504 [*] Unnecessary assignment to `D` before `return` state 367 366 | 368 367 | # contextlib suppress in with statement -RET504.py:400:12: RET504 [*] Unnecessary assignment to `y` before `return` statement +RET504 [*] Unnecessary assignment to `y` before `return` statement + --> RET504.py:400:12 | 398 | x = 1 399 | y = y + 2 400 | return y # RET504 - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 396 396 | x = 2 @@ -241,14 +253,15 @@ RET504.py:400:12: RET504 [*] Unnecessary assignment to `y` before `return` state 402 401 | 403 402 | def foo(): -RET504.py:423:16: RET504 [*] Unnecessary assignment to `services` before `return` statement +RET504 [*] Unnecessary assignment to `services` before `return` statement + --> RET504.py:423:16 | 421 | if "services" in a: 422 | services = a["services"] 423 | return services - | ^^^^^^^^ RET504 + | ^^^^^^^^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 419 419 | # See: https://github.com/astral-sh/ruff/issues/10732 @@ -261,16 +274,17 @@ RET504.py:423:16: RET504 [*] Unnecessary assignment to `services` before `return 425 424 | 426 425 | # See: https://github.com/astral-sh/ruff/issues/14052 -RET504.py:458:12: RET504 [*] Unnecessary assignment to `x` before `return` statement +RET504 [*] Unnecessary assignment to `x` before `return` statement + --> RET504.py:458:12 | 456 | (#= 457 | x) = 1 458 | return x - | ^ RET504 + | ^ 459 | 460 | def f(): | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 453 453 | @@ -284,14 +298,15 @@ RET504.py:458:12: RET504 [*] Unnecessary assignment to `x` before `return` state 460 458 | def f(): 461 459 | x = (1 -RET504.py:463:12: RET504 [*] Unnecessary assignment to `x` before `return` statement +RET504 [*] Unnecessary assignment to `x` before `return` statement + --> RET504.py:463:12 | 461 | x = (1 462 | ) 463 | return x - | ^ RET504 + | ^ | - = help: Remove unnecessary assignment +help: Remove unnecessary assignment ℹ Unsafe fix 458 458 | return x diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap index 132296938a..e67b72a86f 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs --- -RET505.py:8:5: RET505 [*] Unnecessary `elif` after `return` statement +RET505 [*] Unnecessary `elif` after `return` statement + --> RET505.py:8:5 | 6 | a = 1 7 | return y 8 | elif z: - | ^^^^ RET505 + | ^^^^ 9 | b = 2 10 | return w | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 5 5 | if x: # [no-else-return] @@ -22,16 +23,17 @@ RET505.py:8:5: RET505 [*] Unnecessary `elif` after `return` statement 10 10 | return w 11 11 | else: -RET505.py:23:5: RET505 [*] Unnecessary `elif` after `return` statement +RET505 [*] Unnecessary `elif` after `return` statement + --> RET505.py:23:5 | 21 | b = 2 22 | return 23 | elif z: - | ^^^^ RET505 + | ^^^^ 24 | c = 2 25 | else: | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 20 20 | else: @@ -43,16 +45,17 @@ RET505.py:23:5: RET505 [*] Unnecessary `elif` after `return` statement 25 25 | else: 26 26 | c = 3 -RET505.py:41:5: RET505 [*] Unnecessary `elif` after `return` statement +RET505 [*] Unnecessary `elif` after `return` statement + --> RET505.py:41:5 | 39 | a = 1 40 | return y 41 | elif z: - | ^^^^ RET505 + | ^^^^ 42 | b = 2 43 | return w | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 38 38 | if x: # [no-else-return] @@ -64,16 +67,17 @@ RET505.py:41:5: RET505 [*] Unnecessary `elif` after `return` statement 43 43 | return w 44 44 | else: -RET505.py:53:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:53:5 | 51 | a = 1 52 | return y 53 | else: - | ^^^^ RET505 + | ^^^^ 54 | b = 2 55 | return z | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 50 50 | if x: # [no-else-return] @@ -88,16 +92,17 @@ RET505.py:53:5: RET505 [*] Unnecessary `else` after `return` statement 57 56 | 58 57 | def foo3(x, y, z): -RET505.py:64:9: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:64:9 | 62 | b = 2 63 | return y 64 | else: - | ^^^^ RET505 + | ^^^^ 65 | c = 3 66 | return x | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 61 61 | if y: # [no-else-return] @@ -112,16 +117,17 @@ RET505.py:64:9: RET505 [*] Unnecessary `else` after `return` statement 68 67 | d = 4 69 68 | return z -RET505.py:79:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:79:5 | 77 | b = 2 78 | return 79 | else: - | ^^^^ RET505 + | ^^^^ 80 | c = 3 81 | return | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 76 76 | else: @@ -134,16 +140,17 @@ RET505.py:79:5: RET505 [*] Unnecessary `else` after `return` statement 82 81 | 83 82 | -RET505.py:89:9: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:89:9 | 87 | a = 4 88 | return 89 | else: - | ^^^^ RET505 + | ^^^^ 90 | b = 2 91 | else: | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 86 86 | if y: # [no-else-return] @@ -156,16 +163,17 @@ RET505.py:89:9: RET505 [*] Unnecessary `else` after `return` statement 92 91 | c = 3 93 92 | return -RET505.py:99:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:99:5 | 97 | if x: # [no-else-return] 98 | return True 99 | else: - | ^^^^ RET505 + | ^^^^ 100 | try: 101 | return False | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 96 96 | def bar4(x): @@ -184,16 +192,17 @@ RET505.py:99:5: RET505 [*] Unnecessary `else` after `return` statement 105 104 | 106 105 | def fibo(n): -RET505.py:109:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:109:5 | 107 | if n<2: 108 | return n; 109 | else: - | ^^^^ RET505 + | ^^^^ 110 | last = 1; 111 | last2 = 0; | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 106 106 | def fibo(n): @@ -208,16 +217,17 @@ RET505.py:109:5: RET505 [*] Unnecessary `else` after `return` statement 113 112 | 114 113 | ### -RET505.py:145:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:145:5 | 143 | if True: 144 | return 145 | else: - | ^^^^ RET505 + | ^^^^ 146 | # comment 147 | pass | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 142 142 | def bar4(x): @@ -232,15 +242,16 @@ RET505.py:145:5: RET505 [*] Unnecessary `else` after `return` statement 149 148 | 150 149 | def bar5(): -RET505.py:153:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:153:5 | 151 | if True: 152 | return 153 | else: # comment - | ^^^^ RET505 + | ^^^^ 154 | pass | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 150 150 | def bar5(): @@ -254,16 +265,17 @@ RET505.py:153:5: RET505 [*] Unnecessary `else` after `return` statement 156 156 | 157 157 | def bar6(): -RET505.py:160:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:160:5 | 158 | if True: 159 | return 160 | else\ - | ^^^^ RET505 + | ^^^^ 161 | :\ 162 | # comment | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 157 157 | def bar6(): @@ -279,16 +291,17 @@ RET505.py:160:5: RET505 [*] Unnecessary `else` after `return` statement 165 163 | 166 164 | def bar7(): -RET505.py:169:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:169:5 | 167 | if True: 168 | return 169 | else\ - | ^^^^ RET505 + | ^^^^ 170 | : # comment 171 | pass | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 166 166 | def bar7(): @@ -303,14 +316,15 @@ RET505.py:169:5: RET505 [*] Unnecessary `else` after `return` statement 173 172 | 174 173 | def bar8(): -RET505.py:177:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:177:5 | 175 | if True: 176 | return 177 | else: pass - | ^^^^ RET505 + | ^^^^ | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 174 174 | def bar8(): @@ -322,15 +336,16 @@ RET505.py:177:5: RET505 [*] Unnecessary `else` after `return` statement 179 179 | 180 180 | def bar9(): -RET505.py:183:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:183:5 | 181 | if True: 182 | return 183 | else:\ - | ^^^^ RET505 + | ^^^^ 184 | pass | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 180 180 | def bar9(): @@ -343,14 +358,15 @@ RET505.py:183:5: RET505 [*] Unnecessary `else` after `return` statement 186 185 | 187 186 | x = 0 -RET505.py:200:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:200:5 | 198 | def sb(self): 199 | if self._sb is not None: return self._sb 200 | else: self._sb = '\033[01;%dm'; self._sa = '\033[0;0m'; - | ^^^^ RET505 + | ^^^^ | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 197 197 | # Regression test for: https://github.com/astral-sh/ruff/issues/9732 @@ -362,16 +378,17 @@ RET505.py:200:5: RET505 [*] Unnecessary `else` after `return` statement 202 202 | 203 203 | def indent(x, y, w, z): -RET505.py:207:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:207:5 | 205 | a = 1 206 | return y 207 | else: - | ^^^^ RET505 + | ^^^^ 208 | 209 | c = 3 | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 204 204 | if x: # [no-else-return] @@ -387,16 +404,17 @@ RET505.py:207:5: RET505 [*] Unnecessary `else` after `return` statement 212 211 | 213 212 | def indent(x, y, w, z): -RET505.py:217:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:217:5 | 215 | a = 1 216 | return y 217 | else: - | ^^^^ RET505 + | ^^^^ 218 | # comment 219 | c = 3 | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 214 214 | if x: # [no-else-return] @@ -413,16 +431,17 @@ RET505.py:217:5: RET505 [*] Unnecessary `else` after `return` statement 222 221 | 223 222 | def indent(x, y, w, z): -RET505.py:227:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:227:5 | 225 | a = 1 226 | return y 227 | else: - | ^^^^ RET505 + | ^^^^ 228 | # comment 229 | c = 3 | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 224 224 | if x: # [no-else-return] @@ -439,16 +458,17 @@ RET505.py:227:5: RET505 [*] Unnecessary `else` after `return` statement 232 231 | 233 232 | def indent(x, y, w, z): -RET505.py:237:5: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:237:5 | 235 | a = 1 236 | return y 237 | else: - | ^^^^ RET505 + | ^^^^ 238 | # comment 239 | c = 3 | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 234 234 | if x: # [no-else-return] @@ -464,15 +484,16 @@ RET505.py:237:5: RET505 [*] Unnecessary `else` after `return` statement 242 241 | def f(): 243 242 | if True: -RET505.py:245:2: RET505 [*] Unnecessary `else` after `return` statement +RET505 [*] Unnecessary `else` after `return` statement + --> RET505.py:245:2 | 243 | if True: 244 | return True 245 | else: - | ^^^^ RET505 + | ^^^^ 246 | return False | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 242 242 | def f(): @@ -485,13 +506,14 @@ RET505.py:245:2: RET505 [*] Unnecessary `else` after `return` statement 248 247 | 249 248 | def has_untracted_files(): -RET505.py:252:5: RET505 Unnecessary `else` after `return` statement +RET505 Unnecessary `else` after `return` statement + --> RET505.py:252:5 | 250 | if b'Untracked files' in result.stdout: 251 | return True 252 | else: - | ^^^^ RET505 + | ^^^^ 253 | \ 254 | return False | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET506_RET506.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET506_RET506.py.snap index 5a16ac0c71..30781b52ad 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET506_RET506.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET506_RET506.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs -snapshot_kind: text --- -RET506.py:8:5: RET506 [*] Unnecessary `elif` after `raise` statement +RET506 [*] Unnecessary `elif` after `raise` statement + --> RET506.py:8:5 | 6 | a = 1 7 | raise Exception(y) 8 | elif z: - | ^^^^ RET506 + | ^^^^ 9 | b = 2 10 | raise Exception(w) | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 5 5 | if x: # [no-else-raise] @@ -23,16 +23,17 @@ RET506.py:8:5: RET506 [*] Unnecessary `elif` after `raise` statement 10 10 | raise Exception(w) 11 11 | else: -RET506.py:23:5: RET506 [*] Unnecessary `elif` after `raise` statement +RET506 [*] Unnecessary `elif` after `raise` statement + --> RET506.py:23:5 | 21 | b = 2 22 | raise Exception(x) 23 | elif z: - | ^^^^ RET506 + | ^^^^ 24 | raise Exception(y) 25 | else: | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 20 20 | else: @@ -44,16 +45,17 @@ RET506.py:23:5: RET506 [*] Unnecessary `elif` after `raise` statement 25 25 | else: 26 26 | c = 3 -RET506.py:34:5: RET506 [*] Unnecessary `else` after `raise` statement +RET506 [*] Unnecessary `else` after `raise` statement + --> RET506.py:34:5 | 32 | a = 1 33 | raise Exception(y) 34 | else: - | ^^^^ RET506 + | ^^^^ 35 | b = 2 36 | raise Exception(z) | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 31 31 | if x: # [no-else-raise] @@ -68,16 +70,17 @@ RET506.py:34:5: RET506 [*] Unnecessary `else` after `raise` statement 38 37 | 39 38 | def foo3(x, y, z): -RET506.py:45:9: RET506 [*] Unnecessary `else` after `raise` statement +RET506 [*] Unnecessary `else` after `raise` statement + --> RET506.py:45:9 | 43 | b = 2 44 | raise Exception(y) 45 | else: - | ^^^^ RET506 + | ^^^^ 46 | c = 3 47 | raise Exception(x) | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 42 42 | if y: # [no-else-raise] @@ -92,16 +95,17 @@ RET506.py:45:9: RET506 [*] Unnecessary `else` after `raise` statement 49 48 | d = 4 50 49 | raise Exception(z) -RET506.py:60:5: RET506 [*] Unnecessary `else` after `raise` statement +RET506 [*] Unnecessary `else` after `raise` statement + --> RET506.py:60:5 | 58 | b = 2 59 | raise Exception(x) 60 | else: - | ^^^^ RET506 + | ^^^^ 61 | c = 3 62 | raise Exception(y) | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 57 57 | else: @@ -114,16 +118,17 @@ RET506.py:60:5: RET506 [*] Unnecessary `else` after `raise` statement 63 62 | 64 63 | -RET506.py:70:9: RET506 [*] Unnecessary `else` after `raise` statement +RET506 [*] Unnecessary `else` after `raise` statement + --> RET506.py:70:9 | 68 | a = 4 69 | raise Exception(x) 70 | else: - | ^^^^ RET506 + | ^^^^ 71 | b = 2 72 | else: | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 67 67 | if y: # [no-else-raise] @@ -136,16 +141,17 @@ RET506.py:70:9: RET506 [*] Unnecessary `else` after `raise` statement 73 72 | c = 3 74 73 | raise Exception(y) -RET506.py:80:5: RET506 [*] Unnecessary `else` after `raise` statement +RET506 [*] Unnecessary `else` after `raise` statement + --> RET506.py:80:5 | 78 | if x: # [no-else-raise] 79 | raise Exception(True) 80 | else: - | ^^^^ RET506 + | ^^^^ 81 | try: 82 | raise Exception(False) | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 77 77 | def bar4(x): diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET507_RET507.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET507_RET507.py.snap index 7481cae384..0a2c279fb5 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET507_RET507.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET507_RET507.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs -snapshot_kind: text --- -RET507.py:8:9: RET507 [*] Unnecessary `elif` after `continue` statement +RET507 [*] Unnecessary `elif` after `continue` statement + --> RET507.py:8:9 | 6 | if i < y: # [no-else-continue] 7 | continue 8 | elif i < w: - | ^^^^ RET507 + | ^^^^ 9 | continue 10 | else: | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 5 5 | for i in x: @@ -23,16 +23,17 @@ RET507.py:8:9: RET507 [*] Unnecessary `elif` after `continue` statement 10 10 | else: 11 11 | a = z -RET507.py:22:9: RET507 [*] Unnecessary `elif` after `continue` statement +RET507 [*] Unnecessary `elif` after `continue` statement + --> RET507.py:22:9 | 20 | b = 2 21 | continue 22 | elif z: - | ^^^^ RET507 + | ^^^^ 23 | c = 2 24 | else: | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 19 19 | else: @@ -44,15 +45,16 @@ RET507.py:22:9: RET507 [*] Unnecessary `elif` after `continue` statement 24 24 | else: 25 25 | c = 3 -RET507.py:36:9: RET507 [*] Unnecessary `else` after `continue` statement +RET507 [*] Unnecessary `else` after `continue` statement + --> RET507.py:36:9 | 34 | if i < y: # [no-else-continue] 35 | continue 36 | else: - | ^^^^ RET507 + | ^^^^ 37 | a = z | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 33 33 | for i in x: @@ -65,16 +67,17 @@ RET507.py:36:9: RET507 [*] Unnecessary `else` after `continue` statement 39 38 | 40 39 | def foo3(x, y, z): -RET507.py:47:13: RET507 [*] Unnecessary `else` after `continue` statement +RET507 [*] Unnecessary `else` after `continue` statement + --> RET507.py:47:13 | 45 | b = 2 46 | continue 47 | else: - | ^^^^ RET507 + | ^^^^ 48 | c = 3 49 | continue | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 44 44 | if z: # [no-else-continue] @@ -89,16 +92,17 @@ RET507.py:47:13: RET507 [*] Unnecessary `else` after `continue` statement 51 50 | d = 4 52 51 | continue -RET507.py:63:9: RET507 [*] Unnecessary `else` after `continue` statement +RET507 [*] Unnecessary `else` after `continue` statement + --> RET507.py:63:9 | 61 | b = 2 62 | continue 63 | else: - | ^^^^ RET507 + | ^^^^ 64 | c = 3 65 | continue | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 60 60 | else: @@ -111,16 +115,17 @@ RET507.py:63:9: RET507 [*] Unnecessary `else` after `continue` statement 66 65 | 67 66 | -RET507.py:74:13: RET507 [*] Unnecessary `else` after `continue` statement +RET507 [*] Unnecessary `else` after `continue` statement + --> RET507.py:74:13 | 72 | a = 4 73 | continue 74 | else: - | ^^^^ RET507 + | ^^^^ 75 | b = 2 76 | else: | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 71 71 | if y: # [no-else-continue] @@ -133,16 +138,17 @@ RET507.py:74:13: RET507 [*] Unnecessary `else` after `continue` statement 77 76 | c = 3 78 77 | continue -RET507.py:85:9: RET507 [*] Unnecessary `else` after `continue` statement +RET507 [*] Unnecessary `else` after `continue` statement + --> RET507.py:85:9 | 83 | if x: # [no-else-continue] 84 | continue 85 | else: - | ^^^^ RET507 + | ^^^^ 86 | try: 87 | return | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 82 82 | for i in range(10): diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET508_RET508.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET508_RET508.py.snap index 8d62c54ea0..3b0edfbc06 100644 --- a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET508_RET508.py.snap +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET508_RET508.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_return/mod.rs -snapshot_kind: text --- -RET508.py:8:9: RET508 [*] Unnecessary `elif` after `break` statement +RET508 [*] Unnecessary `elif` after `break` statement + --> RET508.py:8:9 | 6 | if i > y: # [no-else-break] 7 | break 8 | elif i > w: - | ^^^^ RET508 + | ^^^^ 9 | break 10 | else: | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 5 5 | for i in x: @@ -23,16 +23,17 @@ RET508.py:8:9: RET508 [*] Unnecessary `elif` after `break` statement 10 10 | else: 11 11 | a = z -RET508.py:22:9: RET508 [*] Unnecessary `elif` after `break` statement +RET508 [*] Unnecessary `elif` after `break` statement + --> RET508.py:22:9 | 20 | b = 2 21 | break 22 | elif z: - | ^^^^ RET508 + | ^^^^ 23 | c = 2 24 | else: | - = help: Remove unnecessary `elif` +help: Remove unnecessary `elif` ℹ Safe fix 19 19 | else: @@ -44,15 +45,16 @@ RET508.py:22:9: RET508 [*] Unnecessary `elif` after `break` statement 24 24 | else: 25 25 | c = 3 -RET508.py:33:9: RET508 [*] Unnecessary `else` after `break` statement +RET508 [*] Unnecessary `else` after `break` statement + --> RET508.py:33:9 | 31 | if i > y: # [no-else-break] 32 | break 33 | else: - | ^^^^ RET508 + | ^^^^ 34 | a = z | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 30 30 | for i in x: @@ -65,16 +67,17 @@ RET508.py:33:9: RET508 [*] Unnecessary `else` after `break` statement 36 35 | 37 36 | def foo3(x, y, z): -RET508.py:44:13: RET508 [*] Unnecessary `else` after `break` statement +RET508 [*] Unnecessary `else` after `break` statement + --> RET508.py:44:13 | 42 | b = 2 43 | break 44 | else: - | ^^^^ RET508 + | ^^^^ 45 | c = 3 46 | break | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 41 41 | if z: # [no-else-break] @@ -89,16 +92,17 @@ RET508.py:44:13: RET508 [*] Unnecessary `else` after `break` statement 48 47 | d = 4 49 48 | break -RET508.py:60:9: RET508 [*] Unnecessary `else` after `break` statement +RET508 [*] Unnecessary `else` after `break` statement + --> RET508.py:60:9 | 58 | b = 2 59 | break 60 | else: - | ^^^^ RET508 + | ^^^^ 61 | c = 3 62 | break | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 57 57 | else: @@ -111,16 +115,17 @@ RET508.py:60:9: RET508 [*] Unnecessary `else` after `break` statement 63 62 | 64 63 | -RET508.py:71:13: RET508 [*] Unnecessary `else` after `break` statement +RET508 [*] Unnecessary `else` after `break` statement + --> RET508.py:71:13 | 69 | a = 4 70 | break 71 | else: - | ^^^^ RET508 + | ^^^^ 72 | b = 2 73 | else: | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 68 68 | if y: # [no-else-break] @@ -133,16 +138,17 @@ RET508.py:71:13: RET508 [*] Unnecessary `else` after `break` statement 74 73 | c = 3 75 74 | break -RET508.py:82:9: RET508 [*] Unnecessary `else` after `break` statement +RET508 [*] Unnecessary `else` after `break` statement + --> RET508.py:82:9 | 80 | if x: # [no-else-break] 81 | break 82 | else: - | ^^^^ RET508 + | ^^^^ 83 | try: 84 | return | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 79 79 | for i in range(10): @@ -161,15 +167,16 @@ RET508.py:82:9: RET508 [*] Unnecessary `else` after `break` statement 88 87 | 89 88 | ### -RET508.py:158:13: RET508 [*] Unnecessary `else` after `break` statement +RET508 [*] Unnecessary `else` after `break` statement + --> RET508.py:158:13 | 156 | if i > w: 157 | break 158 | else: - | ^^^^ RET508 + | ^^^^ 159 | a = z | - = help: Remove unnecessary `else` +help: Remove unnecessary `else` ℹ Safe fix 155 155 | else: diff --git a/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__ignore_names.snap b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__ignore_names.snap index 343e864f3c..155b9281c2 100644 --- a/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__ignore_names.snap +++ b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__ignore_names.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/flake8_self/mod.rs -snapshot_kind: text --- -SLF001_extended.py:6:5: SLF001 Private member accessed: `_asdict` +SLF001 Private member accessed: `_asdict` + --> SLF001_extended.py:6:5 | 5 | def foo(obj): 6 | obj._asdict # SLF001 - | ^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^ | -SLF001_extended.py:10:5: SLF001 Private member accessed: `_bar` +SLF001 Private member accessed: `_bar` + --> SLF001_extended.py:10:5 | 9 | def foo(obj): 10 | obj._bar # SLF001 - | ^^^^^^^^ SLF001 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap index edd0ef3dd2..9589f18610 100644 --- a/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap @@ -1,109 +1,120 @@ --- source: crates/ruff_linter/src/rules/flake8_self/mod.rs --- -SLF001.py:34:12: SLF001 Private member accessed: `_private` +SLF001 Private member accessed: `_private` + --> SLF001.py:34:12 | 33 | def get_bar(): 34 | if self.bar._private: # SLF001 - | ^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^ 35 | return None 36 | if self.bar()._private: # SLF001 | -SLF001.py:36:12: SLF001 Private member accessed: `_private` +SLF001 Private member accessed: `_private` + --> SLF001.py:36:12 | 34 | if self.bar._private: # SLF001 35 | return None 36 | if self.bar()._private: # SLF001 - | ^^^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^^^ 37 | return None 38 | if Bar._private_thing: # SLF001 | -SLF001.py:38:12: SLF001 Private member accessed: `_private_thing` +SLF001 Private member accessed: `_private_thing` + --> SLF001.py:38:12 | 36 | if self.bar()._private: # SLF001 37 | return None 38 | if Bar._private_thing: # SLF001 - | ^^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^^ 39 | return None 40 | if Foo._private_thing: | -SLF001.py:43:12: SLF001 Private member accessed: `_private_thing` +SLF001 Private member accessed: `_private_thing` + --> SLF001.py:43:12 | 41 | return None 42 | Foo = Bar() 43 | if Foo._private_thing: # SLF001 - | ^^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^^ 44 | return None 45 | return self.bar | -SLF001.py:62:7: SLF001 Private member accessed: `_private_thing` +SLF001 Private member accessed: `_private_thing` + --> SLF001.py:62:7 | 60 | foo = Foo() 61 | 62 | print(foo._private_thing) # SLF001 - | ^^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^^ 63 | print(foo.__really_private_thing) # SLF001 64 | print(foo._private_func()) # SLF001 | -SLF001.py:63:7: SLF001 Private member accessed: `__really_private_thing` +SLF001 Private member accessed: `__really_private_thing` + --> SLF001.py:63:7 | 62 | print(foo._private_thing) # SLF001 63 | print(foo.__really_private_thing) # SLF001 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | print(foo._private_func()) # SLF001 65 | print(foo.__really_private_func(1)) # SLF001 | -SLF001.py:64:7: SLF001 Private member accessed: `_private_func` +SLF001 Private member accessed: `_private_func` + --> SLF001.py:64:7 | 62 | print(foo._private_thing) # SLF001 63 | print(foo.__really_private_thing) # SLF001 64 | print(foo._private_func()) # SLF001 - | ^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^ 65 | print(foo.__really_private_func(1)) # SLF001 66 | print(foo.bar._private) # SLF001 | -SLF001.py:65:7: SLF001 Private member accessed: `__really_private_func` +SLF001 Private member accessed: `__really_private_func` + --> SLF001.py:65:7 | 63 | print(foo.__really_private_thing) # SLF001 64 | print(foo._private_func()) # SLF001 65 | print(foo.__really_private_func(1)) # SLF001 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | print(foo.bar._private) # SLF001 67 | print(foo()._private_thing) # SLF001 | -SLF001.py:66:7: SLF001 Private member accessed: `_private` +SLF001 Private member accessed: `_private` + --> SLF001.py:66:7 | 64 | print(foo._private_func()) # SLF001 65 | print(foo.__really_private_func(1)) # SLF001 66 | print(foo.bar._private) # SLF001 - | ^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^ 67 | print(foo()._private_thing) # SLF001 68 | print(foo()._private_thing__) # SLF001 | -SLF001.py:67:7: SLF001 Private member accessed: `_private_thing` +SLF001 Private member accessed: `_private_thing` + --> SLF001.py:67:7 | 65 | print(foo.__really_private_func(1)) # SLF001 66 | print(foo.bar._private) # SLF001 67 | print(foo()._private_thing) # SLF001 - | ^^^^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^^^^ 68 | print(foo()._private_thing__) # SLF001 | -SLF001.py:68:7: SLF001 Private member accessed: `_private_thing__` +SLF001 Private member accessed: `_private_thing__` + --> SLF001.py:68:7 | 66 | print(foo.bar._private) # SLF001 67 | print(foo()._private_thing) # SLF001 68 | print(foo()._private_thing__) # SLF001 - | ^^^^^^^^^^^^^^^^^^^^^^ SLF001 + | ^^^^^^^^^^^^^^^^^^^^^^ 69 | 70 | print(foo.public_thing) | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap index 68fe445fbb..660a531793 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM101.py:1:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call +SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + --> SIM101.py:1:4 | 1 | if isinstance(a, int) or isinstance(a, float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | pass | - = help: Merge `isinstance` calls for `a` +help: Merge `isinstance` calls for `a` ℹ Unsafe fix 1 |-if isinstance(a, int) or isinstance(a, float): # SIM101 @@ -16,15 +17,16 @@ SIM101.py:1:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing 3 3 | 4 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 -SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call +SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + --> SIM101.py:4:4 | 2 | pass 3 | 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | pass | - = help: Merge `isinstance` calls for `a` +help: Merge `isinstance` calls for `a` ℹ Unsafe fix 1 1 | if isinstance(a, int) or isinstance(a, float): # SIM101 @@ -36,15 +38,16 @@ SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing 6 6 | 7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 -SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call +SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + --> SIM101.py:7:4 | 5 | pass 6 | 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | pass | - = help: Merge `isinstance` calls for `a` +help: Merge `isinstance` calls for `a` ℹ Unsafe fix 4 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 @@ -56,15 +59,16 @@ SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sing 9 9 | 10 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 -SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call +SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + --> SIM101.py:10:4 | 8 | pass 9 | 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | pass | - = help: Merge `isinstance` calls for `a` +help: Merge `isinstance` calls for `a` ℹ Unsafe fix 7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 @@ -76,15 +80,16 @@ SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin 12 12 | 13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 -SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call +SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + --> SIM101.py:16:5 | 14 | pass 15 | 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | pass | - = help: Merge `isinstance` calls for `a` +help: Merge `isinstance` calls for `a` ℹ Unsafe fix 13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 @@ -96,15 +101,16 @@ SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin 18 18 | 19 19 | if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 -SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call +SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call + --> SIM101.py:19:4 | 17 | pass 18 | 19 | if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | pass | - = help: Merge `isinstance` calls +help: Merge `isinstance` calls ℹ Unsafe fix 16 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 @@ -116,25 +122,27 @@ SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge int 21 21 | 22 22 | if isinstance(a(), int) or isinstance(a(), float): # SIM101 -SIM101.py:22:4: SIM101 Multiple `isinstance` calls for expression, merge into a single call +SIM101 Multiple `isinstance` calls for expression, merge into a single call + --> SIM101.py:22:4 | 20 | pass 21 | 22 | if isinstance(a(), int) or isinstance(a(), float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Merge `isinstance` calls +help: Merge `isinstance` calls -SIM101.py:38:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call +SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + --> SIM101.py:38:4 | 36 | pass 37 | 38 | if x or isinstance(a, int) or isinstance(a, float): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | pass | - = help: Merge `isinstance` calls for `a` +help: Merge `isinstance` calls for `a` ℹ Unsafe fix 35 35 | if isinstance(a, int) or unrelated_condition or isinstance(a, float): @@ -146,15 +154,16 @@ SIM101.py:38:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin 40 40 | 41 41 | if x or y or isinstance(a, int) or isinstance(a, float) or z: -SIM101.py:41:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call +SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + --> SIM101.py:41:4 | 39 | pass 40 | 41 | if x or y or isinstance(a, int) or isinstance(a, float) or z: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | pass | - = help: Merge `isinstance` calls for `a` +help: Merge `isinstance` calls for `a` ℹ Unsafe fix 38 38 | if x or isinstance(a, int) or isinstance(a, float): @@ -166,14 +175,15 @@ SIM101.py:41:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a sin 43 43 | 44 44 | def f(): -SIM101.py:53:3: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call +SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + --> SIM101.py:53:3 | 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 53 | if(isinstance(a, int)) or (isinstance(a, float)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | pass | - = help: Merge `isinstance` calls for `a` +help: Merge `isinstance` calls for `a` ℹ Unsafe fix 50 50 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap index 6d7178e361..94e6118857 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM102.py:2:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:2:1 | 1 | # SIM102 2 | / if a: 3 | | if b: - | |_________^ SIM102 + | |_________^ 4 | c | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 1 1 | # SIM102 @@ -22,16 +23,17 @@ SIM102.py:2:1: SIM102 [*] Use a single `if` statement instead of nested `if` sta 6 5 | # SIM102 7 6 | if a: -SIM102.py:7:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:7:1 | 6 | # SIM102 7 | / if a: 8 | | if b: 9 | | if c: - | |_____________^ SIM102 + | |_____________^ 10 | d | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 4 4 | c @@ -48,16 +50,17 @@ SIM102.py:7:1: SIM102 [*] Use a single `if` statement instead of nested `if` sta 12 11 | # SIM102 13 12 | if a: -SIM102.py:8:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:8:5 | 6 | # SIM102 7 | if a: 8 | / if b: 9 | | if c: - | |_____________^ SIM102 + | |_____________^ 10 | d | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 5 5 | @@ -72,16 +75,17 @@ SIM102.py:8:5: SIM102 [*] Use a single `if` statement instead of nested `if` sta 12 11 | # SIM102 13 12 | if a: -SIM102.py:15:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:15:1 | 13 | if a: 14 | pass 15 | / elif b: 16 | | if c: - | |_________^ SIM102 + | |_________^ 17 | d | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 12 12 | # SIM102 @@ -96,27 +100,29 @@ SIM102.py:15:1: SIM102 [*] Use a single `if` statement instead of nested `if` st 19 18 | # SIM102 20 19 | if a: -SIM102.py:20:1: SIM102 Use a single `if` statement instead of nested `if` statements +SIM102 Use a single `if` statement instead of nested `if` statements + --> SIM102.py:20:1 | 19 | # SIM102 20 | / if a: 21 | | # Unfixable due to placement of this comment. 22 | | if b: - | |_________^ SIM102 + | |_________^ 23 | c | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` -SIM102.py:26:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:26:1 | 25 | # SIM102 26 | / if a: 27 | | if b: - | |_________^ SIM102 + | |_________^ 28 | # Fixable due to placement of this comment. 29 | c | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 23 23 | c @@ -133,17 +139,18 @@ SIM102.py:26:1: SIM102 [*] Use a single `if` statement instead of nested `if` st 31 30 | # OK 32 31 | if a: -SIM102.py:51:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:51:5 | 49 | while x > 0: 50 | # SIM102 51 | / if y > 0: 52 | | if z > 0: - | |_________________^ SIM102 + | |_________________^ 53 | """this 54 | is valid""" | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 48 48 | @@ -170,16 +177,17 @@ SIM102.py:51:5: SIM102 [*] Use a single `if` statement instead of nested `if` st 64 63 | 65 64 | -SIM102.py:67:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:67:1 | 66 | # SIM102 67 | / if x > 0: 68 | | if y > 0: - | |_____________^ SIM102 + | |_____________^ 69 | """this 70 | is valid""" | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 64 64 | @@ -206,7 +214,8 @@ SIM102.py:67:1: SIM102 [*] Use a single `if` statement instead of nested `if` st 80 79 | 81 80 | while x > 0: -SIM102.py:83:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:83:5 | 81 | while x > 0: 82 | # SIM102 @@ -214,10 +223,10 @@ SIM102.py:83:5: SIM102 [*] Use a single `if` statement instead of nested `if` st 84 | | if node.module == "multiprocessing" or node.module.startswith( 85 | | "multiprocessing." 86 | | ): - | |__________^ SIM102 + | |__________^ 87 | print("Bad module!") | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 80 80 | @@ -236,17 +245,18 @@ SIM102.py:83:5: SIM102 [*] Use a single `if` statement instead of nested `if` st 89 88 | # SIM102 (auto-fixable) 90 89 | if node.module012345678: -SIM102.py:90:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:90:1 | 89 | # SIM102 (auto-fixable) 90 | / if node.module012345678: 91 | | if node.module == "multiprocß9💣2ℝ" or node.module.startswith( 92 | | "multiprocessing." 93 | | ): - | |______^ SIM102 + | |______^ 94 | print("Bad module!") | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 87 87 | print("Bad module!") @@ -265,29 +275,31 @@ SIM102.py:90:1: SIM102 [*] Use a single `if` statement instead of nested `if` st 96 95 | # SIM102 (not auto-fixable) 97 96 | if node.module0123456789: -SIM102.py:97:1: SIM102 Use a single `if` statement instead of nested `if` statements +SIM102 Use a single `if` statement instead of nested `if` statements + --> SIM102.py:97:1 | 96 | # SIM102 (not auto-fixable) 97 | / if node.module0123456789: 98 | | if node.module == "multiprocß9💣2ℝ" or node.module.startswith( 99 | | "multiprocessing." 100 | | ): - | |______^ SIM102 + | |______^ 101 | print("Bad module!") | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` -SIM102.py:106:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:106:5 | 104 | # Regression test for https://github.com/apache/airflow/blob/145b16caaa43f0c42bffd97344df916c602cddde/airflow/configuration.py#L1161 105 | if a: 106 | / if b: 107 | | if c: - | |_____________^ SIM102 + | |_____________^ 108 | print("if") 109 | elif d: | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 103 103 | # SIM102 @@ -302,17 +314,18 @@ SIM102.py:106:5: SIM102 [*] Use a single `if` statement instead of nested `if` s 110 109 | print("elif") 111 110 | -SIM102.py:132:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:132:5 | 130 | if a: 131 | # SIM 102 132 | / if b: 133 | | if c: - | |_____________^ SIM102 + | |_____________^ 134 | print("foo") 135 | else: | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 129 129 | # OK @@ -327,16 +340,17 @@ SIM102.py:132:5: SIM102 [*] Use a single `if` statement instead of nested `if` s 136 135 | print("bar") 137 136 | -SIM102.py:165:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements +SIM102 [*] Use a single `if` statement instead of nested `if` statements + --> SIM102.py:165:5 | 163 | if a: 164 | pass 165 | / elif b: 166 | | if c: - | |_____________^ SIM102 + | |_____________^ 167 | d | - = help: Combine `if` statements using `and` +help: Combine `if` statements using `and` ℹ Unsafe fix 162 162 | def f(): diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap index 58286e133c..4ae8c970c5 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM103.py:3:5: SIM103 [*] Return the condition `bool(a)` directly +SIM103 [*] Return the condition `bool(a)` directly + --> SIM103.py:3:5 | 1 | def f(): 2 | # SIM103 @@ -9,9 +10,9 @@ SIM103.py:3:5: SIM103 [*] Return the condition `bool(a)` directly 4 | | return True 5 | | else: 6 | | return False - | |____________________^ SIM103 + | |____________________^ | - = help: Replace with `return bool(a)` +help: Replace with `return bool(a)` ℹ Unsafe fix 1 1 | def f(): @@ -25,7 +26,8 @@ SIM103.py:3:5: SIM103 [*] Return the condition `bool(a)` directly 8 5 | 9 6 | def f(): -SIM103.py:11:5: SIM103 [*] Return the condition `a == b` directly +SIM103 [*] Return the condition `a == b` directly + --> SIM103.py:11:5 | 9 | def f(): 10 | # SIM103 @@ -33,9 +35,9 @@ SIM103.py:11:5: SIM103 [*] Return the condition `a == b` directly 12 | | return True 13 | | else: 14 | | return False - | |____________________^ SIM103 + | |____________________^ | - = help: Replace with `return a == b` +help: Replace with `return a == b` ℹ Unsafe fix 8 8 | @@ -50,7 +52,8 @@ SIM103.py:11:5: SIM103 [*] Return the condition `a == b` directly 16 13 | 17 14 | def f(): -SIM103.py:21:5: SIM103 [*] Return the condition `bool(b)` directly +SIM103 [*] Return the condition `bool(b)` directly + --> SIM103.py:21:5 | 19 | if a: 20 | return 1 @@ -58,9 +61,9 @@ SIM103.py:21:5: SIM103 [*] Return the condition `bool(b)` directly 22 | | return True 23 | | else: 24 | | return False - | |____________________^ SIM103 + | |____________________^ | - = help: Replace with `return bool(b)` +help: Replace with `return bool(b)` ℹ Unsafe fix 18 18 | # SIM103 @@ -75,7 +78,8 @@ SIM103.py:21:5: SIM103 [*] Return the condition `bool(b)` directly 26 23 | 27 24 | def f(): -SIM103.py:32:9: SIM103 [*] Return the condition `bool(b)` directly +SIM103 [*] Return the condition `bool(b)` directly + --> SIM103.py:32:9 | 30 | return 1 31 | else: @@ -83,9 +87,9 @@ SIM103.py:32:9: SIM103 [*] Return the condition `bool(b)` directly 33 | | return True 34 | | else: 35 | | return False - | |________________________^ SIM103 + | |________________________^ | - = help: Replace with `return bool(b)` +help: Replace with `return bool(b)` ℹ Unsafe fix 29 29 | if a: @@ -100,7 +104,8 @@ SIM103.py:32:9: SIM103 [*] Return the condition `bool(b)` directly 37 34 | 38 35 | def f(): -SIM103.py:57:5: SIM103 [*] Return the condition `not a` directly +SIM103 [*] Return the condition `not a` directly + --> SIM103.py:57:5 | 55 | def f(): 56 | # SIM103 @@ -108,9 +113,9 @@ SIM103.py:57:5: SIM103 [*] Return the condition `not a` directly 58 | | return False 59 | | else: 60 | | return True - | |___________________^ SIM103 + | |___________________^ | - = help: Replace with `return not a` +help: Replace with `return not a` ℹ Unsafe fix 54 54 | @@ -125,7 +130,8 @@ SIM103.py:57:5: SIM103 [*] Return the condition `not a` directly 62 59 | 63 60 | def f(): -SIM103.py:83:5: SIM103 Return the condition directly +SIM103 Return the condition directly + --> SIM103.py:83:5 | 81 | def bool(): 82 | return False @@ -133,11 +139,12 @@ SIM103.py:83:5: SIM103 Return the condition directly 84 | | return True 85 | | else: 86 | | return False - | |____________________^ SIM103 + | |____________________^ | - = help: Inline condition +help: Inline condition -SIM103.py:91:5: SIM103 [*] Return the condition `not (keys is not None and notice.key not in keys)` directly +SIM103 [*] Return the condition `not (keys is not None and notice.key not in keys)` directly + --> SIM103.py:91:5 | 89 | def f(): 90 | # SIM103 @@ -145,9 +152,9 @@ SIM103.py:91:5: SIM103 [*] Return the condition `not (keys is not None and notic 92 | | return False 93 | | else: 94 | | return True - | |___________________^ SIM103 + | |___________________^ | - = help: Replace with `return not (keys is not None and notice.key not in keys)` +help: Replace with `return not (keys is not None and notice.key not in keys)` ℹ Unsafe fix 88 88 | @@ -162,16 +169,17 @@ SIM103.py:91:5: SIM103 [*] Return the condition `not (keys is not None and notic 96 93 | 97 94 | ### -SIM103.py:104:5: SIM103 [*] Return the condition `bool(a)` directly +SIM103 [*] Return the condition `bool(a)` directly + --> SIM103.py:104:5 | 102 | def f(): 103 | # SIM103 104 | / if a: 105 | | return True 106 | | return False - | |________________^ SIM103 + | |________________^ | - = help: Replace with `return bool(a)` +help: Replace with `return bool(a)` ℹ Unsafe fix 101 101 | @@ -185,16 +193,17 @@ SIM103.py:104:5: SIM103 [*] Return the condition `bool(a)` directly 108 106 | 109 107 | def f(): -SIM103.py:111:5: SIM103 [*] Return the condition `not a` directly +SIM103 [*] Return the condition `not a` directly + --> SIM103.py:111:5 | 109 | def f(): 110 | # SIM103 111 | / if a: 112 | | return False 113 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return not a` +help: Replace with `return not a` ℹ Unsafe fix 108 108 | @@ -208,15 +217,16 @@ SIM103.py:111:5: SIM103 [*] Return the condition `not a` directly 115 113 | 116 114 | def f(): -SIM103.py:117:5: SIM103 [*] Return the condition `10 < a` directly +SIM103 [*] Return the condition `10 < a` directly + --> SIM103.py:117:5 | 116 | def f(): 117 | / if not 10 < a: 118 | | return False 119 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return 10 < a` +help: Replace with `return 10 < a` ℹ Unsafe fix 114 114 | @@ -230,15 +240,16 @@ SIM103.py:117:5: SIM103 [*] Return the condition `10 < a` directly 121 119 | 122 120 | def f(): -SIM103.py:123:5: SIM103 [*] Return the condition `not 10 < a` directly +SIM103 [*] Return the condition `not 10 < a` directly + --> SIM103.py:123:5 | 122 | def f(): 123 | / if 10 < a: 124 | | return False 125 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return not 10 < a` +help: Replace with `return not 10 < a` ℹ Unsafe fix 120 120 | @@ -252,15 +263,16 @@ SIM103.py:123:5: SIM103 [*] Return the condition `not 10 < a` directly 127 125 | 128 126 | def f(): -SIM103.py:129:5: SIM103 [*] Return the condition `10 not in a` directly +SIM103 [*] Return the condition `10 not in a` directly + --> SIM103.py:129:5 | 128 | def f(): 129 | / if 10 in a: 130 | | return False 131 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return 10 not in a` +help: Replace with `return 10 not in a` ℹ Unsafe fix 126 126 | @@ -274,15 +286,16 @@ SIM103.py:129:5: SIM103 [*] Return the condition `10 not in a` directly 133 131 | 134 132 | def f(): -SIM103.py:135:5: SIM103 [*] Return the condition `10 in a` directly +SIM103 [*] Return the condition `10 in a` directly + --> SIM103.py:135:5 | 134 | def f(): 135 | / if 10 not in a: 136 | | return False 137 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return 10 in a` +help: Replace with `return 10 in a` ℹ Unsafe fix 132 132 | @@ -296,15 +309,16 @@ SIM103.py:135:5: SIM103 [*] Return the condition `10 in a` directly 139 137 | 140 138 | def f(): -SIM103.py:141:5: SIM103 [*] Return the condition `a is not 10` directly +SIM103 [*] Return the condition `a is not 10` directly + --> SIM103.py:141:5 | 140 | def f(): 141 | / if a is 10: 142 | | return False 143 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return a is not 10` +help: Replace with `return a is not 10` ℹ Unsafe fix 138 138 | @@ -318,15 +332,16 @@ SIM103.py:141:5: SIM103 [*] Return the condition `a is not 10` directly 145 143 | 146 144 | def f(): -SIM103.py:147:5: SIM103 [*] Return the condition `a is 10` directly +SIM103 [*] Return the condition `a is 10` directly + --> SIM103.py:147:5 | 146 | def f(): 147 | / if a is not 10: 148 | | return False 149 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return a is 10` +help: Replace with `return a is 10` ℹ Unsafe fix 144 144 | @@ -340,15 +355,16 @@ SIM103.py:147:5: SIM103 [*] Return the condition `a is 10` directly 151 149 | 152 150 | def f(): -SIM103.py:153:5: SIM103 [*] Return the condition `a != 10` directly +SIM103 [*] Return the condition `a != 10` directly + --> SIM103.py:153:5 | 152 | def f(): 153 | / if a == 10: 154 | | return False 155 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return a != 10` +help: Replace with `return a != 10` ℹ Unsafe fix 150 150 | @@ -362,15 +378,16 @@ SIM103.py:153:5: SIM103 [*] Return the condition `a != 10` directly 157 155 | 158 156 | def f(): -SIM103.py:159:5: SIM103 [*] Return the condition `a == 10` directly +SIM103 [*] Return the condition `a == 10` directly + --> SIM103.py:159:5 | 158 | def f(): 159 | / if a != 10: 160 | | return False 161 | | return True - | |_______________^ SIM103 + | |_______________^ | - = help: Replace with `return a == 10` +help: Replace with `return a == 10` ℹ Unsafe fix 156 156 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap index c4fe31837c..829eff5b88 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM105_0.py:6:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + --> SIM105_0.py:6:1 | 5 | # SIM105 6 | / try: 7 | | foo() 8 | | except ValueError: 9 | | pass - | |________^ SIM105 + | |________^ | - = help: Replace with `contextlib.suppress(ValueError)` +help: Replace with `contextlib.suppress(ValueError)` ℹ Unsafe fix 1 |+import contextlib @@ -28,18 +29,19 @@ SIM105_0.py:6:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `tr 11 10 | 12 11 | # SIM105 -SIM105_0.py:13:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` + --> SIM105_0.py:13:1 | 12 | # SIM105 13 | / try: 14 | | foo() 15 | | except (ValueError, OSError): 16 | | pass - | |________^ SIM105 + | |________^ 17 | 18 | # SIM105 | - = help: Replace with `contextlib.suppress(ValueError, OSError)` +help: Replace with `contextlib.suppress(ValueError, OSError)` ℹ Unsafe fix 1 |+import contextlib @@ -59,18 +61,19 @@ SIM105_0.py:13:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` inst 18 17 | # SIM105 19 18 | try: -SIM105_0.py:19:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` + --> SIM105_0.py:19:1 | 18 | # SIM105 19 | / try: 20 | | foo() 21 | | except (ValueError, OSError) as e: 22 | | pass - | |________^ SIM105 + | |________^ 23 | 24 | # SIM105 | - = help: Replace with `contextlib.suppress(ValueError, OSError)` +help: Replace with `contextlib.suppress(ValueError, OSError)` ℹ Unsafe fix 1 |+import contextlib @@ -90,18 +93,19 @@ SIM105_0.py:19:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` inst 24 23 | # SIM105 25 24 | try: -SIM105_0.py:25:1: SIM105 [*] Use `contextlib.suppress(BaseException)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(BaseException)` instead of `try`-`except`-`pass` + --> SIM105_0.py:25:1 | 24 | # SIM105 25 | / try: 26 | | foo() 27 | | except: 28 | | pass - | |________^ SIM105 + | |________^ 29 | 30 | # SIM105 | - = help: Replace with `contextlib.suppress(BaseException)` +help: Replace with `contextlib.suppress(BaseException)` ℹ Unsafe fix 1 |+import contextlib @@ -122,18 +126,19 @@ SIM105_0.py:25:1: SIM105 [*] Use `contextlib.suppress(BaseException)` instead of 30 30 | # SIM105 31 31 | try: -SIM105_0.py:31:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead of `try`-`except`-`pass` + --> SIM105_0.py:31:1 | 30 | # SIM105 31 | / try: 32 | | foo() 33 | | except (a.Error, b.Error): 34 | | pass - | |________^ SIM105 + | |________^ 35 | 36 | # OK | - = help: Replace with `contextlib.suppress(a.Error, b.Error)` +help: Replace with `contextlib.suppress(a.Error, b.Error)` ℹ Unsafe fix 1 |+import contextlib @@ -153,7 +158,8 @@ SIM105_0.py:31:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead 36 35 | # OK 37 36 | try: -SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + --> SIM105_0.py:85:5 | 83 | def with_ellipsis(): 84 | # OK @@ -161,9 +167,9 @@ SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `t 86 | | foo() 87 | | except ValueError: 88 | | ... - | |___________^ SIM105 + | |___________^ | - = help: Replace with `contextlib.suppress(ValueError)` +help: Replace with `contextlib.suppress(ValueError)` ℹ Unsafe fix 1 |+import contextlib @@ -183,20 +189,22 @@ SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `t 90 89 | 91 90 | def with_ellipsis_and_return(): -SIM105_0.py:100:5: SIM105 Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` +SIM105 Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` + --> SIM105_0.py:100:5 | 99 | def with_comment(): 100 | / try: 101 | | foo() 102 | | except (ValueError, OSError): 103 | | pass # Trailing comment. - | |____________^ SIM105 + | |____________^ 104 | 105 | try: | - = help: Replace with `contextlib.suppress(ValueError, OSError)` +help: Replace with `contextlib.suppress(ValueError, OSError)` -SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + --> SIM105_0.py:117:5 | 115 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 116 | def write_models(directory, Models): @@ -204,11 +212,11 @@ SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try 118 | | os.makedirs(model_dir); 119 | | except OSError: 120 | | pass; - | |____________^ SIM105 + | |____________^ 121 | 122 | try: os.makedirs(model_dir); | - = help: Replace with `contextlib.suppress(OSError)` +help: Replace with `contextlib.suppress(OSError)` ℹ Unsafe fix 1 |+import contextlib @@ -228,18 +236,19 @@ SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try 122 121 | try: os.makedirs(model_dir); 123 122 | except OSError: -SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + --> SIM105_0.py:122:5 | 120 | pass; 121 | 122 | / try: os.makedirs(model_dir); 123 | | except OSError: 124 | | pass; - | |____________^ SIM105 + | |____________^ 125 | 126 | try: os.makedirs(model_dir); | - = help: Replace with `contextlib.suppress(OSError)` +help: Replace with `contextlib.suppress(OSError)` ℹ Unsafe fix 1 |+import contextlib @@ -258,18 +267,19 @@ SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try 126 125 | try: os.makedirs(model_dir); 127 126 | except OSError: -SIM105_0.py:126:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + --> SIM105_0.py:126:5 | 124 | pass; 125 | 126 | / try: os.makedirs(model_dir); 127 | | except OSError: 128 | | pass; \ - | |____________^ SIM105 + | |____________^ 129 | \ 130 | # | - = help: Replace with `contextlib.suppress(OSError)` +help: Replace with `contextlib.suppress(OSError)` ℹ Unsafe fix 1 |+import contextlib @@ -288,16 +298,17 @@ SIM105_0.py:126:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try 130 129 | # 131 130 | -SIM105_0.py:133:1: SIM105 [*] Use `contextlib.suppress()` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress()` instead of `try`-`except`-`pass` + --> SIM105_0.py:133:1 | 132 | # Regression tests for: https://github.com/astral-sh/ruff/issues/18209 133 | / try: 134 | | 1 / 0 135 | | except (): 136 | | pass - | |________^ SIM105 + | |________^ | - = help: Replace with `contextlib.suppress()` +help: Replace with `contextlib.suppress()` ℹ Unsafe fix 1 |+import contextlib @@ -317,16 +328,17 @@ SIM105_0.py:133:1: SIM105 [*] Use `contextlib.suppress()` instead of `try`-`exce 138 137 | 139 138 | BaseException = ValueError -SIM105_0.py:140:1: SIM105 [*] Use `contextlib.suppress(BaseException)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(BaseException)` instead of `try`-`except`-`pass` + --> SIM105_0.py:140:1 | 139 | BaseException = ValueError 140 | / try: 141 | | int("a") 142 | | except BaseException: 143 | | pass - | |________^ SIM105 + | |________^ | - = help: Replace with `contextlib.suppress(BaseException)` +help: Replace with `contextlib.suppress(BaseException)` ℹ Unsafe fix 1 |+import contextlib diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap index 4b935dd0b7..8dc7d3ba61 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- -SIM105_1.py:5:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + --> SIM105_1.py:5:1 | 4 | # SIM105 5 | / try: 6 | | math.sqrt(-1) 7 | | except ValueError: 8 | | pass - | |________^ SIM105 + | |________^ | - = help: Replace with `contextlib.suppress(ValueError)` +help: Replace with `contextlib.suppress(ValueError)` ℹ Unsafe fix 1 1 | """Case: There's a random import, so it should add `contextlib` after it.""" diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap index ad20200273..2373fbb0ee 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- -SIM105_2.py:10:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + --> SIM105_2.py:10:1 | 9 | # SIM105 10 | / try: 11 | | foo() 12 | | except ValueError: 13 | | pass - | |________^ SIM105 + | |________^ | - = help: Replace with `contextlib.suppress(ValueError)` +help: Replace with `contextlib.suppress(ValueError)` ℹ Unsafe fix 7 7 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap index 22cc4a2c59..385aabd5de 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM105_3.py:10:5: SIM105 Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` +SIM105 Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + --> SIM105_3.py:10:5 | 8 | def bar(): 9 | # SIM105 @@ -9,6 +10,6 @@ SIM105_3.py:10:5: SIM105 Use `contextlib.suppress(ValueError)` instead of `try`- 11 | | foo() 12 | | except ValueError: 13 | | pass - | |____________^ SIM105 + | |____________^ | - = help: Replace with `contextlib.suppress(ValueError)` +help: Replace with `contextlib.suppress(ValueError)` diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_4.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_4.py.snap index a292a320b6..86932241c7 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_4.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- -SIM105_4.py:2:1: SIM105 [*] Use `contextlib.suppress(ImportError)` instead of `try`-`except`-`pass` +SIM105 [*] Use `contextlib.suppress(ImportError)` instead of `try`-`except`-`pass` + --> SIM105_4.py:2:1 | -1 | #!/usr/bin/env python +1 | #!/usr/bin/env python 2 | / try: 3 | | from __builtin__ import bytes, str, open, super, range, zip, round, int, pow, object, input 4 | | except ImportError: pass - | |___________________________^ SIM105 + | |___________________________^ | - = help: Replace with `contextlib.suppress(ImportError)` +help: Replace with `contextlib.suppress(ImportError)` ℹ Unsafe fix 1 1 | #!/usr/bin/env python diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM107_SIM107.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM107_SIM107.py.snap index 8aa249ae1e..705b45e39d 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM107_SIM107.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM107_SIM107.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- -SIM107.py:9:9: SIM107 Don't use `return` in `try`-`except` and `finally` +SIM107 Don't use `return` in `try`-`except` and `finally` + --> SIM107.py:9:9 | 7 | return "2" 8 | finally: 9 | return "3" - | ^^^^^^^^^^ SIM107 + | ^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap index b4d70317ad..d9cf4f4c3c 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap @@ -1,18 +1,19 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `b = c if a else d` instead of `if`-`else`-block + --> SIM108.py:2:1 | 1 | # SIM108 2 | / if a: 3 | | b = c 4 | | else: 5 | | b = d - | |_________^ SIM108 + | |_________^ 6 | 7 | # OK | - = help: Replace `if`-`else`-block with `b = c if a else d` +help: Replace `if`-`else`-block with `b = c if a else d` ℹ Unsafe fix 1 1 | # SIM108 @@ -25,7 +26,8 @@ SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `i 7 4 | # OK 8 5 | b = c if a else d -SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of `if`-`else`-block + --> SIM108.py:30:5 | 28 | pass 29 | else: @@ -33,9 +35,9 @@ SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of ` 31 | | b = 1 32 | | else: 33 | | b = 2 - | |_____________^ SIM108 + | |_____________^ | - = help: Replace `if`-`else`-block with `b = 1 if a else 2` +help: Replace `if`-`else`-block with `b = 1 if a else 2` ℹ Unsafe fix 27 27 | if True: @@ -50,7 +52,8 @@ SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of ` 35 32 | 36 33 | import sys -SIM108.py:58:1: SIM108 Use ternary operator `abc = x if x > 0 else -x` instead of `if`-`else`-block +SIM108 Use ternary operator `abc = x if x > 0 else -x` instead of `if`-`else`-block + --> SIM108.py:58:1 | 57 | # SIM108 (without fix due to comments) 58 | / if x > 0: @@ -59,20 +62,21 @@ SIM108.py:58:1: SIM108 Use ternary operator `abc = x if x > 0 else -x` instead o 61 | | else: 62 | | # test test test 63 | | abc = -x - | |____________^ SIM108 + | |____________^ | - = help: Replace `if`-`else`-block with `abc = x if x > 0 else -x` +help: Replace `if`-`else`-block with `abc = x if x > 0 else -x` -SIM108.py:82:1: SIM108 [*] Use ternary operator `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` instead of `if`-`else`-block + --> SIM108.py:82:1 | 81 | # SIM108 82 | / if a: 83 | | b = "cccccccccccccccccccccccccccccccccß" 84 | | else: 85 | | b = "ddddddddddddddddddddddddddddddddd💣" - | |_____________________________________________^ SIM108 + | |_____________________________________________^ | - = help: Replace `if`-`else`-block with `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` +help: Replace `if`-`else`-block with `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` ℹ Unsafe fix 79 79 | @@ -87,38 +91,42 @@ SIM108.py:82:1: SIM108 [*] Use ternary operator `b = "cccccccccccccccccccccccccc 87 84 | 88 85 | # OK (too long) -SIM108.py:105:1: SIM108 Use ternary operator `exitcode = 0 if True else 1` instead of `if`-`else`-block +SIM108 Use ternary operator `exitcode = 0 if True else 1` instead of `if`-`else`-block + --> SIM108.py:105:1 | 104 | # SIM108 (without fix due to trailing comment) 105 | / if True: 106 | | exitcode = 0 107 | | else: 108 | | exitcode = 1 # Trailing comment - | |________________^ SIM108 + | |________________^ | - = help: Replace `if`-`else`-block with `exitcode = 0 if True else 1` +help: Replace `if`-`else`-block with `exitcode = 0 if True else 1` -SIM108.py:112:1: SIM108 Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block +SIM108 Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block + --> SIM108.py:112:1 | 111 | # SIM108 112 | / if True: x = 3 # Foo 113 | | else: x = 5 - | |___________^ SIM108 + | |___________^ | - = help: Replace `if`-`else`-block with `x = 3 if True else 5` +help: Replace `if`-`else`-block with `x = 3 if True else 5` -SIM108.py:117:1: SIM108 Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block +SIM108 Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block + --> SIM108.py:117:1 | 116 | # SIM108 117 | / if True: # Foo 118 | | x = 3 119 | | else: 120 | | x = 5 - | |_________^ SIM108 + | |_________^ | - = help: Replace `if`-`else`-block with `x = 3 if True else 5` +help: Replace `if`-`else`-block with `x = 3 if True else 5` -SIM108.py:141:1: SIM108 [*] Use binary operator `z = cond or other_cond` instead of `if`-`else`-block +SIM108 [*] Use binary operator `z = cond or other_cond` instead of `if`-`else`-block + --> SIM108.py:141:1 | 139 | # SIM108 - should suggest 140 | # z = cond or other_cond @@ -126,11 +134,11 @@ SIM108.py:141:1: SIM108 [*] Use binary operator `z = cond or other_cond` instead 142 | | z = cond 143 | | else: 144 | | z = other_cond - | |__________________^ SIM108 + | |__________________^ 145 | 146 | # SIM108 - should suggest | - = help: Replace `if`-`else`-block with `z = cond or other_cond` +help: Replace `if`-`else`-block with `z = cond or other_cond` ℹ Unsafe fix 138 138 | @@ -145,7 +153,8 @@ SIM108.py:141:1: SIM108 [*] Use binary operator `z = cond or other_cond` instead 146 143 | # SIM108 - should suggest 147 144 | # z = cond and other_cond -SIM108.py:148:1: SIM108 [*] Use binary operator `z = cond and other_cond` instead of `if`-`else`-block +SIM108 [*] Use binary operator `z = cond and other_cond` instead of `if`-`else`-block + --> SIM108.py:148:1 | 146 | # SIM108 - should suggest 147 | # z = cond and other_cond @@ -153,11 +162,11 @@ SIM108.py:148:1: SIM108 [*] Use binary operator `z = cond and other_cond` instea 149 | | z = cond 150 | | else: 151 | | z = other_cond - | |__________________^ SIM108 + | |__________________^ 152 | 153 | # SIM108 - should suggest | - = help: Replace `if`-`else`-block with `z = cond and other_cond` +help: Replace `if`-`else`-block with `z = cond and other_cond` ℹ Unsafe fix 145 145 | @@ -172,7 +181,8 @@ SIM108.py:148:1: SIM108 [*] Use binary operator `z = cond and other_cond` instea 153 150 | # SIM108 - should suggest 154 151 | # z = not cond and other_cond -SIM108.py:155:1: SIM108 [*] Use binary operator `z = not cond and other_cond` instead of `if`-`else`-block +SIM108 [*] Use binary operator `z = not cond and other_cond` instead of `if`-`else`-block + --> SIM108.py:155:1 | 153 | # SIM108 - should suggest 154 | # z = not cond and other_cond @@ -180,11 +190,11 @@ SIM108.py:155:1: SIM108 [*] Use binary operator `z = not cond and other_cond` in 156 | | z = not cond 157 | | else: 158 | | z = other_cond - | |__________________^ SIM108 + | |__________________^ 159 | 160 | # SIM108 does not suggest | - = help: Replace `if`-`else`-block with `z = not cond and other_cond` +help: Replace `if`-`else`-block with `z = not cond and other_cond` ℹ Unsafe fix 152 152 | @@ -199,7 +209,8 @@ SIM108.py:155:1: SIM108 [*] Use binary operator `z = not cond and other_cond` in 160 157 | # SIM108 does not suggest 161 158 | # a binary option in these cases, -SIM108.py:167:1: SIM108 [*] Use ternary operator `z = 1 if True else other` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `z = 1 if True else other` instead of `if`-`else`-block + --> SIM108.py:167:1 | 165 | # (Of course, these specific expressions 166 | # should be simplified for other reasons...) @@ -207,11 +218,11 @@ SIM108.py:167:1: SIM108 [*] Use ternary operator `z = 1 if True else other` inst 168 | | z = 1 169 | | else: 170 | | z = other - | |_____________^ SIM108 + | |_____________^ 171 | 172 | if False: | - = help: Replace `if`-`else`-block with `z = 1 if True else other` +help: Replace `if`-`else`-block with `z = 1 if True else other` ℹ Unsafe fix 164 164 | # so, e.g. `True == 1`. @@ -226,7 +237,8 @@ SIM108.py:167:1: SIM108 [*] Use ternary operator `z = 1 if True else other` inst 172 169 | if False: 173 170 | z = 1 -SIM108.py:172:1: SIM108 [*] Use ternary operator `z = 1 if False else other` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `z = 1 if False else other` instead of `if`-`else`-block + --> SIM108.py:172:1 | 170 | z = other 171 | @@ -234,11 +246,11 @@ SIM108.py:172:1: SIM108 [*] Use ternary operator `z = 1 if False else other` ins 173 | | z = 1 174 | | else: 175 | | z = other - | |_____________^ SIM108 + | |_____________^ 176 | 177 | if 1: | - = help: Replace `if`-`else`-block with `z = 1 if False else other` +help: Replace `if`-`else`-block with `z = 1 if False else other` ℹ Unsafe fix 169 169 | else: @@ -253,7 +265,8 @@ SIM108.py:172:1: SIM108 [*] Use ternary operator `z = 1 if False else other` ins 177 174 | if 1: 178 175 | z = True -SIM108.py:177:1: SIM108 [*] Use ternary operator `z = True if 1 else other` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `z = True if 1 else other` instead of `if`-`else`-block + --> SIM108.py:177:1 | 175 | z = other 176 | @@ -261,11 +274,11 @@ SIM108.py:177:1: SIM108 [*] Use ternary operator `z = True if 1 else other` inst 178 | | z = True 179 | | else: 180 | | z = other - | |_____________^ SIM108 + | |_____________^ 181 | 182 | # SIM108 does not suggest a binary option in this | - = help: Replace `if`-`else`-block with `z = True if 1 else other` +help: Replace `if`-`else`-block with `z = True if 1 else other` ℹ Unsafe fix 174 174 | else: @@ -280,7 +293,8 @@ SIM108.py:177:1: SIM108 [*] Use ternary operator `z = True if 1 else other` inst 182 179 | # SIM108 does not suggest a binary option in this 183 180 | # case, since we'd be reducing the number of calls -SIM108.py:185:1: SIM108 [*] Use ternary operator `z = foo() if foo() else other` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `z = foo() if foo() else other` instead of `if`-`else`-block + --> SIM108.py:185:1 | 183 | # case, since we'd be reducing the number of calls 184 | # from Two to one. @@ -288,11 +302,11 @@ SIM108.py:185:1: SIM108 [*] Use ternary operator `z = foo() if foo() else other` 186 | | z = foo() 187 | | else: 188 | | z = other - | |_____________^ SIM108 + | |_____________^ 189 | 190 | # SIM108 does not suggest a binary option in this | - = help: Replace `if`-`else`-block with `z = foo() if foo() else other` +help: Replace `if`-`else`-block with `z = foo() if foo() else other` ℹ Unsafe fix 182 182 | # SIM108 does not suggest a binary option in this @@ -307,7 +321,8 @@ SIM108.py:185:1: SIM108 [*] Use ternary operator `z = foo() if foo() else other` 190 187 | # SIM108 does not suggest a binary option in this 191 188 | # case, since we'd be reducing the number of calls -SIM108.py:193:1: SIM108 [*] Use ternary operator `z = not foo() if foo() else other` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `z = not foo() if foo() else other` instead of `if`-`else`-block + --> SIM108.py:193:1 | 191 | # case, since we'd be reducing the number of calls 192 | # from Two to one. @@ -315,9 +330,9 @@ SIM108.py:193:1: SIM108 [*] Use ternary operator `z = not foo() if foo() else ot 194 | | z = not foo() 195 | | else: 196 | | z = other - | |_____________^ SIM108 + | |_____________^ | - = help: Replace `if`-`else`-block with `z = not foo() if foo() else other` +help: Replace `if`-`else`-block with `z = not foo() if foo() else other` ℹ Unsafe fix 190 190 | # SIM108 does not suggest a binary option in this @@ -332,7 +347,8 @@ SIM108.py:193:1: SIM108 [*] Use ternary operator `z = not foo() if foo() else ot 198 195 | 199 196 | # These two cases double as tests for f-string quote preservation. The first -SIM108.py:202:1: SIM108 [*] Use ternary operator `var = "str" if cond else f"{first}-{second}"` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `var = "str" if cond else f"{first}-{second}"` instead of `if`-`else`-block + --> SIM108.py:202:1 | 200 | # f-string should preserve its double quotes, and the second should preserve 201 | # single quotes @@ -340,11 +356,11 @@ SIM108.py:202:1: SIM108 [*] Use ternary operator `var = "str" if cond else f"{fi 203 | | var = "str" 204 | | else: 205 | | var = f"{first}-{second}" - | |_____________________________^ SIM108 + | |_____________________________^ 206 | 207 | if cond: | - = help: Replace `if`-`else`-block with `var = "str" if cond else f"{first}-{second}"` +help: Replace `if`-`else`-block with `var = "str" if cond else f"{first}-{second}"` ℹ Unsafe fix 199 199 | # These two cases double as tests for f-string quote preservation. The first @@ -359,7 +375,8 @@ SIM108.py:202:1: SIM108 [*] Use ternary operator `var = "str" if cond else f"{fi 207 204 | if cond: 208 205 | var = "str" -SIM108.py:207:1: SIM108 [*] Use ternary operator `var = "str" if cond else f'{first}-{second}'` instead of `if`-`else`-block +SIM108 [*] Use ternary operator `var = "str" if cond else f'{first}-{second}'` instead of `if`-`else`-block + --> SIM108.py:207:1 | 205 | var = f"{first}-{second}" 206 | @@ -367,9 +384,9 @@ SIM108.py:207:1: SIM108 [*] Use ternary operator `var = "str" if cond else f'{fi 208 | | var = "str" 209 | | else: 210 | | var = f'{first}-{second}' - | |_____________________________^ SIM108 + | |_____________________________^ | - = help: Replace `if`-`else`-block with `var = "str" if cond else f'{first}-{second}'` +help: Replace `if`-`else`-block with `var = "str" if cond else f'{first}-{second}'` ℹ Unsafe fix 204 204 | else: diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap index 2b07ae1874..84e84015c3 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- -SIM109.py:2:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons +SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons + --> SIM109.py:2:4 | 1 | # SIM109 2 | if a == b or a == c: - | ^^^^^^^^^^^^^^^^ SIM109 + | ^^^^^^^^^^^^^^^^ 3 | d | - = help: Replace with `a in (b, c)` +help: Replace with `a in (b, c)` ℹ Unsafe fix 1 1 | # SIM109 @@ -19,14 +19,15 @@ SIM109.py:2:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality compari 4 4 | 5 5 | # SIM109 -SIM109.py:6:5: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons +SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons + --> SIM109.py:6:5 | 5 | # SIM109 6 | if (a == b or a == c) and None: - | ^^^^^^^^^^^^^^^^ SIM109 + | ^^^^^^^^^^^^^^^^ 7 | d | - = help: Replace with `a in (b, c)` +help: Replace with `a in (b, c)` ℹ Unsafe fix 3 3 | d @@ -38,14 +39,15 @@ SIM109.py:6:5: SIM109 [*] Use `a in (b, c)` instead of multiple equality compari 8 8 | 9 9 | # SIM109 -SIM109.py:10:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons +SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons + --> SIM109.py:10:4 | 9 | # SIM109 10 | if a == b or a == c or None: - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM109 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 11 | d | - = help: Replace with `a in (b, c)` +help: Replace with `a in (b, c)` ℹ Unsafe fix 7 7 | d @@ -57,14 +59,15 @@ SIM109.py:10:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality compar 12 12 | 13 13 | # SIM109 -SIM109.py:14:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons +SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons + --> SIM109.py:14:4 | 13 | # SIM109 14 | if a == b or None or a == c: - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM109 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 15 | d | - = help: Replace with `a in (b, c)` +help: Replace with `a in (b, c)` ℹ Unsafe fix 11 11 | d diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap index a689920625..742bd1fc86 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM110.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:3:5 | 1 | def f(): 2 | # SIM110 @@ -9,9 +10,9 @@ SIM110.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead o 4 | | if check(x): 5 | | return True 6 | | return False - | |________________^ SIM110 + | |________________^ | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 1 1 | def f(): @@ -25,7 +26,8 @@ SIM110.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead o 8 5 | 9 6 | def f(): -SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:25:5 | 23 | def f(): 24 | # SIM111 @@ -33,9 +35,9 @@ SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 26 | | if check(x): 27 | | return False 28 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` ℹ Unsafe fix 22 22 | @@ -50,7 +52,8 @@ SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 30 27 | 31 28 | def f(): -SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop + --> SIM110.py:33:5 | 31 | def f(): 32 | # SIM111 @@ -58,9 +61,9 @@ SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst 34 | | if not x.is_empty(): 35 | | return False 36 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(x.is_empty() for x in iterable)` +help: Replace with `return all(x.is_empty() for x in iterable)` ℹ Unsafe fix 30 30 | @@ -75,7 +78,8 @@ SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst 38 35 | 39 36 | def f(): -SIM110.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:55:5 | 53 | def f(): 54 | # SIM110 @@ -84,9 +88,9 @@ SIM110.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 57 | | return True 58 | | else: 59 | | return False - | |____________________^ SIM110 + | |____________________^ | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 52 52 | @@ -102,7 +106,8 @@ SIM110.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 61 57 | 62 58 | def f(): -SIM110.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:64:5 | 62 | def f(): 63 | # SIM111 @@ -111,9 +116,9 @@ SIM110.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 66 | | return False 67 | | else: 68 | | return True - | |___________________^ SIM110 + | |___________________^ | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` ℹ Unsafe fix 61 61 | @@ -129,7 +134,8 @@ SIM110.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 70 66 | 71 67 | def f(): -SIM110.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:73:5 | 71 | def f(): 72 | # SIM110 @@ -138,10 +144,10 @@ SIM110.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 75 | | return True 76 | | else: 77 | | return False - | |____________________^ SIM110 + | |____________________^ 78 | return True | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 70 70 | @@ -157,7 +163,8 @@ SIM110.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 79 75 | 80 76 | -SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:83:5 | 81 | def f(): 82 | # SIM111 @@ -166,10 +173,10 @@ SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 85 | | return False 86 | | else: 87 | | return True - | |___________________^ SIM110 + | |___________________^ 88 | return False | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` ℹ Unsafe fix 80 80 | @@ -185,7 +192,8 @@ SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 89 85 | 90 86 | -SIM110.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:124:5 | 122 | pass 123 | @@ -193,11 +201,12 @@ SIM110.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of 125 | | if check(x): 126 | | return True 127 | | return False - | |________________^ SIM110 + | |________________^ | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` -SIM110.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:134:5 | 132 | pass 133 | @@ -205,20 +214,21 @@ SIM110.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead 135 | | if check(x): 136 | | return False 137 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` -SIM110.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:144:5 | 143 | # SIM110 144 | / for x in iterable: 145 | | if check(x): 146 | | return True 147 | | return False - | |________________^ SIM110 + | |________________^ | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 141 141 | x = 1 @@ -233,16 +243,17 @@ SIM110.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 149 146 | 150 147 | def f(): -SIM110.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:154:5 | 153 | # SIM111 154 | / for x in iterable: 155 | | if check(x): 156 | | return False 157 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` ℹ Unsafe fix 151 151 | x = 1 @@ -257,7 +268,8 @@ SIM110.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` ins 159 156 | 160 157 | def f(): -SIM110.py:162:5: SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` instead of `for` loop +SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` instead of `for` loop + --> SIM110.py:162:5 | 160 | def f(): 161 | # SIM110 @@ -265,9 +277,9 @@ SIM110.py:162:5: SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ 163 | | if x.isdigit(): 164 | | return True 165 | | return False - | |________________^ SIM110 + | |________________^ | - = help: Replace with `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` +help: Replace with `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` ℹ Unsafe fix 159 159 | @@ -282,7 +294,8 @@ SIM110.py:162:5: SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ 167 164 | 168 165 | def f(): -SIM110.py:184:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM110.py:184:5 | 182 | async def f(): 183 | # SIM110 @@ -290,11 +303,11 @@ SIM110.py:184:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 185 | | if check(x): 186 | | return True 187 | | return False - | |________________^ SIM110 + | |________________^ 188 | 189 | async def f(): | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 181 181 | @@ -309,7 +322,8 @@ SIM110.py:184:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 189 186 | async def f(): 190 187 | # SIM110 -SIM110.py:191:5: SIM110 [*] Use `return any(check(x) for x in await iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in await iterable)` instead of `for` loop + --> SIM110.py:191:5 | 189 | async def f(): 190 | # SIM110 @@ -317,11 +331,11 @@ SIM110.py:191:5: SIM110 [*] Use `return any(check(x) for x in await iterable)` i 192 | | if check(x): 193 | | return True 194 | | return False - | |________________^ SIM110 + | |________________^ 195 | 196 | def f(): | - = help: Replace with `return any(check(x) for x in await iterable)` +help: Replace with `return any(check(x) for x in await iterable)` ℹ Unsafe fix 188 188 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap index 82c86ffb8d..a8c0b4d02c 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM111.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:3:5 | 1 | def f(): 2 | # SIM110 @@ -9,9 +10,9 @@ SIM111.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead o 4 | | if check(x): 5 | | return True 6 | | return False - | |________________^ SIM110 + | |________________^ | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 1 1 | def f(): @@ -25,7 +26,8 @@ SIM111.py:3:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead o 8 5 | 9 6 | def f(): -SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:25:5 | 23 | def f(): 24 | # SIM111 @@ -33,9 +35,9 @@ SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 26 | | if check(x): 27 | | return False 28 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` ℹ Unsafe fix 22 22 | @@ -50,7 +52,8 @@ SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 30 27 | 31 28 | def f(): -SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop + --> SIM111.py:33:5 | 31 | def f(): 32 | # SIM111 @@ -58,9 +61,9 @@ SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst 34 | | if not x.is_empty(): 35 | | return False 36 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(x.is_empty() for x in iterable)` +help: Replace with `return all(x.is_empty() for x in iterable)` ℹ Unsafe fix 30 30 | @@ -75,7 +78,8 @@ SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` inst 38 35 | 39 36 | def f(): -SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:55:5 | 53 | def f(): 54 | # SIM110 @@ -84,9 +88,9 @@ SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 57 | | return True 58 | | else: 59 | | return False - | |____________________^ SIM110 + | |____________________^ | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 52 52 | @@ -102,7 +106,8 @@ SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 61 57 | 62 58 | def f(): -SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:64:5 | 62 | def f(): 63 | # SIM111 @@ -111,9 +116,9 @@ SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 66 | | return False 67 | | else: 68 | | return True - | |___________________^ SIM110 + | |___________________^ | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` ℹ Unsafe fix 61 61 | @@ -129,7 +134,8 @@ SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 70 66 | 71 67 | def f(): -SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:73:5 | 71 | def f(): 72 | # SIM110 @@ -138,10 +144,10 @@ SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 75 | | return True 76 | | else: 77 | | return False - | |____________________^ SIM110 + | |____________________^ 78 | return True | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 70 70 | @@ -157,7 +163,8 @@ SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 79 75 | 80 76 | -SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:83:5 | 81 | def f(): 82 | # SIM111 @@ -166,10 +173,10 @@ SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 85 | | return False 86 | | else: 87 | | return True - | |___________________^ SIM110 + | |___________________^ 88 | return False | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` ℹ Unsafe fix 80 80 | @@ -185,7 +192,8 @@ SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` inst 89 85 | 90 86 | -SIM111.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:124:5 | 122 | pass 123 | @@ -193,11 +201,12 @@ SIM111.py:124:5: SIM110 Use `return any(check(x) for x in iterable)` instead of 125 | | if check(x): 126 | | return True 127 | | return False - | |________________^ SIM110 + | |________________^ | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` -SIM111.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:134:5 | 132 | pass 133 | @@ -205,20 +214,21 @@ SIM111.py:134:5: SIM110 Use `return all(not check(x) for x in iterable)` instead 135 | | if check(x): 136 | | return False 137 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` -SIM111.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:144:5 | 143 | # SIM110 144 | / for x in iterable: 145 | | if check(x): 146 | | return True 147 | | return False - | |________________^ SIM110 + | |________________^ | - = help: Replace with `return any(check(x) for x in iterable)` +help: Replace with `return any(check(x) for x in iterable)` ℹ Unsafe fix 141 141 | x = 1 @@ -233,16 +243,17 @@ SIM111.py:144:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead 149 146 | 150 147 | def f(): -SIM111.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + --> SIM111.py:154:5 | 153 | # SIM111 154 | / for x in iterable: 155 | | if check(x): 156 | | return False 157 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(not check(x) for x in iterable)` +help: Replace with `return all(not check(x) for x in iterable)` ℹ Unsafe fix 151 151 | x = 1 @@ -257,7 +268,8 @@ SIM111.py:154:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` ins 159 156 | 160 157 | def f(): -SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(x in y for x in iterable)` instead of `for` loop + --> SIM111.py:162:5 | 160 | def f(): 161 | # SIM111 @@ -265,9 +277,9 @@ SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead o 163 | | if x not in y: 164 | | return False 165 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(x in y for x in iterable)` +help: Replace with `return all(x in y for x in iterable)` ℹ Unsafe fix 159 159 | @@ -282,7 +294,8 @@ SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead o 167 164 | 168 165 | def f(): -SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead of `for` loop +SIM110 [*] Use `return all(x <= y for x in iterable)` instead of `for` loop + --> SIM111.py:170:5 | 168 | def f(): 169 | # SIM111 @@ -290,9 +303,9 @@ SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead o 171 | | if x > y: 172 | | return False 173 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(x <= y for x in iterable)` +help: Replace with `return all(x <= y for x in iterable)` ℹ Unsafe fix 167 167 | @@ -307,7 +320,8 @@ SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead o 175 172 | 176 173 | def f(): -SIM111.py:178:5: SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` instead of `for` loop +SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` instead of `for` loop + --> SIM111.py:178:5 | 176 | def f(): 177 | # SIM111 @@ -315,9 +329,9 @@ SIM111.py:178:5: SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣 179 | | if x.isdigit(): 180 | | return False 181 | | return True - | |_______________^ SIM110 + | |_______________^ | - = help: Replace with `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` +help: Replace with `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` ℹ Unsafe fix 175 175 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap index ac36a3bf67..2df4110d7c 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM112.py:4:12: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` +SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` + --> SIM112.py:4:12 | 3 | # Bad 4 | os.environ['foo'] - | ^^^^^ SIM112 + | ^^^^^ 5 | 6 | os.environ.get('foo') | - = help: Replace `foo` with `FOO` +help: Replace `foo` with `FOO` ℹ Unsafe fix 1 1 | import os @@ -21,60 +22,65 @@ SIM112.py:4:12: SIM112 [*] Use capitalized environment variable `FOO` instead of 6 6 | os.environ.get('foo') 7 7 | -SIM112.py:6:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` +SIM112 Use capitalized environment variable `FOO` instead of `foo` + --> SIM112.py:6:16 | 4 | os.environ['foo'] 5 | 6 | os.environ.get('foo') - | ^^^^^ SIM112 + | ^^^^^ 7 | 8 | os.environ.get('foo', 'bar') | - = help: Replace `foo` with `FOO` +help: Replace `foo` with `FOO` -SIM112.py:8:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` +SIM112 Use capitalized environment variable `FOO` instead of `foo` + --> SIM112.py:8:16 | 6 | os.environ.get('foo') 7 | 8 | os.environ.get('foo', 'bar') - | ^^^^^ SIM112 + | ^^^^^ 9 | 10 | os.getenv('foo') | - = help: Replace `foo` with `FOO` +help: Replace `foo` with `FOO` -SIM112.py:10:11: SIM112 Use capitalized environment variable `FOO` instead of `foo` +SIM112 Use capitalized environment variable `FOO` instead of `foo` + --> SIM112.py:10:11 | 8 | os.environ.get('foo', 'bar') 9 | 10 | os.getenv('foo') - | ^^^^^ SIM112 + | ^^^^^ 11 | 12 | env = os.environ.get('foo') | - = help: Replace `foo` with `FOO` +help: Replace `foo` with `FOO` -SIM112.py:12:22: SIM112 Use capitalized environment variable `FOO` instead of `foo` +SIM112 Use capitalized environment variable `FOO` instead of `foo` + --> SIM112.py:12:22 | 10 | os.getenv('foo') 11 | 12 | env = os.environ.get('foo') - | ^^^^^ SIM112 + | ^^^^^ 13 | 14 | env = os.environ['foo'] | - = help: Replace `foo` with `FOO` +help: Replace `foo` with `FOO` -SIM112.py:14:18: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` +SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` + --> SIM112.py:14:18 | 12 | env = os.environ.get('foo') 13 | 14 | env = os.environ['foo'] - | ^^^^^ SIM112 + | ^^^^^ 15 | 16 | if env := os.environ.get('foo'): | - = help: Replace `foo` with `FOO` +help: Replace `foo` with `FOO` ℹ Unsafe fix 11 11 | @@ -86,25 +92,27 @@ SIM112.py:14:18: SIM112 [*] Use capitalized environment variable `FOO` instead o 16 16 | if env := os.environ.get('foo'): 17 17 | pass -SIM112.py:16:26: SIM112 Use capitalized environment variable `FOO` instead of `foo` +SIM112 Use capitalized environment variable `FOO` instead of `foo` + --> SIM112.py:16:26 | 14 | env = os.environ['foo'] 15 | 16 | if env := os.environ.get('foo'): - | ^^^^^ SIM112 + | ^^^^^ 17 | pass | - = help: Replace `foo` with `FOO` +help: Replace `foo` with `FOO` -SIM112.py:19:22: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` +SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` + --> SIM112.py:19:22 | 17 | pass 18 | 19 | if env := os.environ['foo']: - | ^^^^^ SIM112 + | ^^^^^ 20 | pass | - = help: Replace `foo` with `FOO` +help: Replace `foo` with `FOO` ℹ Unsafe fix 16 16 | if env := os.environ.get('foo'): diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM113_SIM113.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM113_SIM113.py.snap index d58bcf8512..3015682026 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM113_SIM113.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM113_SIM113.py.snap @@ -1,46 +1,50 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs -snapshot_kind: text --- -SIM113.py:6:9: SIM113 Use `enumerate()` for index variable `idx` in `for` loop +SIM113 Use `enumerate()` for index variable `idx` in `for` loop + --> SIM113.py:6:9 | 4 | for x in range(5): 5 | g(x, idx) 6 | idx += 1 - | ^^^^^^^^ SIM113 + | ^^^^^^^^ 7 | h(x) | -SIM113.py:17:9: SIM113 Use `enumerate()` for index variable `idx` in `for` loop +SIM113 Use `enumerate()` for index variable `idx` in `for` loop + --> SIM113.py:17:9 | 15 | if g(x): 16 | break 17 | idx += 1 - | ^^^^^^^^ SIM113 + | ^^^^^^^^ 18 | sum += h(x, idx) | -SIM113.py:27:9: SIM113 Use `enumerate()` for index variable `idx` in `for` loop +SIM113 Use `enumerate()` for index variable `idx` in `for` loop + --> SIM113.py:27:9 | 25 | g(x) 26 | h(x, y) 27 | idx += 1 - | ^^^^^^^^ SIM113 + | ^^^^^^^^ | -SIM113.py:36:9: SIM113 Use `enumerate()` for index variable `idx` in `for` loop +SIM113 Use `enumerate()` for index variable `idx` in `for` loop + --> SIM113.py:36:9 | 34 | for x in range(5): 35 | sum += h(x, idx) 36 | idx += 1 - | ^^^^^^^^ SIM113 + | ^^^^^^^^ | -SIM113.py:44:9: SIM113 Use `enumerate()` for index variable `idx` in `for` loop +SIM113 Use `enumerate()` for index variable `idx` in `for` loop + --> SIM113.py:44:9 | 42 | for x in range(5): 43 | g(x, idx) 44 | idx += 1 - | ^^^^^^^^ SIM113 + | ^^^^^^^^ 45 | h(x) | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap index 3e555ee551..d5c11a5859 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap @@ -1,18 +1,19 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM114.py:2:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:2:1 | 1 | # Errors 2 | / if a: 3 | | b 4 | | elif c: 5 | | b - | |_____^ SIM114 + | |_____^ 6 | 7 | if a: # we preserve comments, too! | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 1 1 | # Errors @@ -24,7 +25,8 @@ SIM114.py:2:1: SIM114 [*] Combine `if` branches using logical `or` operator 6 4 | 7 5 | if a: # we preserve comments, too! -SIM114.py:7:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:7:1 | 5 | b 6 | @@ -32,11 +34,11 @@ SIM114.py:7:1: SIM114 [*] Combine `if` branches using logical `or` operator 8 | | b 9 | | elif c: # but not on the second branch 10 | | b - | |_____^ SIM114 + | |_____^ 11 | 12 | if x == 1: | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 4 4 | elif c: @@ -50,7 +52,8 @@ SIM114.py:7:1: SIM114 [*] Combine `if` branches using logical `or` operator 11 9 | 12 10 | if x == 1: -SIM114.py:12:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:12:1 | 10 | b 11 | @@ -60,11 +63,11 @@ SIM114.py:12:1: SIM114 [*] Combine `if` branches using logical `or` operator 15 | | elif x == 2: 16 | | for _ in range(20): 17 | | print("hello") - | |______________________^ SIM114 + | |______________________^ 18 | 19 | if x == 1: | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 9 9 | elif c: # but not on the second branch @@ -79,7 +82,8 @@ SIM114.py:12:1: SIM114 [*] Combine `if` branches using logical `or` operator 17 14 | print("hello") 18 15 | -SIM114.py:19:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:19:1 | 17 | print("hello") 18 | @@ -91,11 +95,11 @@ SIM114.py:19:1: SIM114 [*] Combine `if` branches using logical `or` operator 24 | | if True: 25 | | for _ in range(20): 26 | | print("hello") - | |__________________________^ SIM114 + | |__________________________^ 27 | 28 | if x == 1: | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 16 16 | for _ in range(20): @@ -111,7 +115,8 @@ SIM114.py:19:1: SIM114 [*] Combine `if` branches using logical `or` operator 25 21 | for _ in range(20): 26 22 | print("hello") -SIM114.py:28:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:28:1 | 26 | print("hello") 27 | @@ -129,11 +134,11 @@ SIM114.py:28:1: SIM114 [*] Combine `if` branches using logical `or` operator 39 | | elif False: 40 | | for _ in range(20): 41 | | print("hello") - | |__________________________^ SIM114 + | |__________________________^ 42 | 43 | if ( | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 25 25 | for _ in range(20): @@ -152,7 +157,8 @@ SIM114.py:28:1: SIM114 [*] Combine `if` branches using logical `or` operator 37 30 | for _ in range(20): 38 31 | print("hello") -SIM114.py:29:5: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:29:5 | 28 | if x == 1: 29 | / if True: @@ -161,11 +167,11 @@ SIM114.py:29:5: SIM114 [*] Combine `if` branches using logical `or` operator 32 | | elif False: 33 | | for _ in range(20): 34 | | print("hello") - | |__________________________^ SIM114 + | |__________________________^ 35 | elif x == 2: 36 | if True: | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 26 26 | print("hello") @@ -180,7 +186,8 @@ SIM114.py:29:5: SIM114 [*] Combine `if` branches using logical `or` operator 34 31 | print("hello") 35 32 | elif x == 2: -SIM114.py:36:5: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:36:5 | 34 | print("hello") 35 | elif x == 2: @@ -190,11 +197,11 @@ SIM114.py:36:5: SIM114 [*] Combine `if` branches using logical `or` operator 39 | | elif False: 40 | | for _ in range(20): 41 | | print("hello") - | |__________________________^ SIM114 + | |__________________________^ 42 | 43 | if ( | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 33 33 | for _ in range(20): @@ -209,7 +216,8 @@ SIM114.py:36:5: SIM114 [*] Combine `if` branches using logical `or` operator 41 38 | print("hello") 42 39 | -SIM114.py:43:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:43:1 | 41 | print("hello") 42 | @@ -232,11 +240,11 @@ SIM114.py:43:1: SIM114 [*] Combine `if` branches using logical `or` operator 59 | | pass 60 | | elif 1 == 2: 61 | | pass - | |________^ SIM114 + | |________^ 62 | 63 | if result.eofs == "O": | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 55 55 | and i == 12 @@ -250,7 +258,8 @@ SIM114.py:43:1: SIM114 [*] Combine `if` branches using logical `or` operator 62 60 | 63 61 | if result.eofs == "O": -SIM114.py:67:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:67:1 | 65 | elif result.eofs == "S": 66 | skipped = 1 @@ -258,11 +267,11 @@ SIM114.py:67:1: SIM114 [*] Combine `if` branches using logical `or` operator 68 | | errors = 1 69 | | elif result.eofs == "E": 70 | | errors = 1 - | |______________^ SIM114 + | |______________^ 71 | elif result.eofs == "X": 72 | errors = 1 | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 64 64 | pass @@ -276,7 +285,8 @@ SIM114.py:67:1: SIM114 [*] Combine `if` branches using logical `or` operator 71 69 | elif result.eofs == "X": 72 70 | errors = 1 -SIM114.py:69:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:69:1 | 67 | elif result.eofs == "F": 68 | errors = 1 @@ -284,11 +294,11 @@ SIM114.py:69:1: SIM114 [*] Combine `if` branches using logical `or` operator 70 | | errors = 1 71 | | elif result.eofs == "X": 72 | | errors = 1 - | |______________^ SIM114 + | |______________^ 73 | elif result.eofs == "C": 74 | errors = 1 | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 66 66 | skipped = 1 @@ -302,7 +312,8 @@ SIM114.py:69:1: SIM114 [*] Combine `if` branches using logical `or` operator 73 71 | elif result.eofs == "C": 74 72 | errors = 1 -SIM114.py:71:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:71:1 | 69 | elif result.eofs == "E": 70 | errors = 1 @@ -310,9 +321,9 @@ SIM114.py:71:1: SIM114 [*] Combine `if` branches using logical `or` operator 72 | | errors = 1 73 | | elif result.eofs == "C": 74 | | errors = 1 - | |______________^ SIM114 + | |______________^ | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 68 68 | errors = 1 @@ -326,7 +337,8 @@ SIM114.py:71:1: SIM114 [*] Combine `if` branches using logical `or` operator 75 73 | 76 74 | -SIM114.py:118:5: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:118:5 | 116 | a = True 117 | b = False @@ -334,11 +346,11 @@ SIM114.py:118:5: SIM114 [*] Combine `if` branches using logical `or` operator 119 | | return 3 120 | | elif a == b: 121 | | return 3 - | |________________^ SIM114 + | |________________^ 122 | elif a < b: # end-of-line 123 | return 4 | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 115 115 | def func(): @@ -352,7 +364,8 @@ SIM114.py:118:5: SIM114 [*] Combine `if` branches using logical `or` operator 122 120 | elif a < b: # end-of-line 123 121 | return 4 -SIM114.py:122:5: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:122:5 | 120 | elif a == b: 121 | return 3 @@ -360,9 +373,9 @@ SIM114.py:122:5: SIM114 [*] Combine `if` branches using logical `or` operator 123 | | return 4 124 | | elif b is None: 125 | | return 4 - | |________________^ SIM114 + | |________________^ | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 119 119 | return 3 @@ -376,7 +389,8 @@ SIM114.py:122:5: SIM114 [*] Combine `if` branches using logical `or` operator 126 124 | 127 125 | -SIM114.py:132:5: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:132:5 | 130 | a = True 131 | b = False @@ -384,9 +398,9 @@ SIM114.py:132:5: SIM114 [*] Combine `if` branches using logical `or` operator 133 | | return 3 134 | | elif a := 1: 135 | | return 3 - | |________________^ SIM114 + | |________________^ | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 129 129 | """Ensure that the named expression is parenthesized when merged.""" @@ -400,15 +414,16 @@ SIM114.py:132:5: SIM114 [*] Combine `if` branches using logical `or` operator 136 134 | 137 135 | -SIM114.py:138:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:138:1 | 138 | / if a: # we preserve comments, too! 139 | | b 140 | | elif c: # but not on the second branch 141 | | b - | |_____^ SIM114 + | |_____^ | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 135 135 | return 3 @@ -422,13 +437,14 @@ SIM114.py:138:1: SIM114 [*] Combine `if` branches using logical `or` operator 142 140 | 143 141 | -SIM114.py:144:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:144:1 | 144 | / if a: b # here's a comment 145 | | elif c: b - | |_________^ SIM114 + | |_________^ | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 141 141 | b @@ -441,14 +457,15 @@ SIM114.py:144:1: SIM114 [*] Combine `if` branches using logical `or` operator 147 146 | 148 147 | if(x > 200): pass -SIM114.py:148:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:148:1 | 148 | / if(x > 200): pass 149 | | elif(100 < x and x < 200 and 300 < y and y < 800): 150 | | pass - | |________^ SIM114 + | |________^ | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 145 145 | elif c: b @@ -462,18 +479,19 @@ SIM114.py:148:1: SIM114 [*] Combine `if` branches using logical `or` operator 152 150 | 153 151 | # See: https://github.com/astral-sh/ruff/issues/12732 -SIM114.py:154:1: SIM114 [*] Combine `if` branches using logical `or` operator +SIM114 [*] Combine `if` branches using logical `or` operator + --> SIM114.py:154:1 | 153 | # See: https://github.com/astral-sh/ruff/issues/12732 154 | / if False if True else False: 155 | | print(1) 156 | | elif True: 157 | | print(1) - | |____________^ SIM114 + | |____________^ 158 | else: 159 | print(2) | - = help: Combine `if` branches +help: Combine `if` branches ℹ Safe fix 151 151 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap index 5e448f3e6d..6218d98265 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap @@ -1,334 +1,368 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM115.py:8:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:8:5 | 7 | # SIM115 8 | f = open("foo.txt") - | ^^^^ SIM115 + | ^^^^ 9 | f = Path("foo.txt").open() 10 | f = pathlib.Path("foo.txt").open() | -SIM115.py:9:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:9:5 | 7 | # SIM115 8 | f = open("foo.txt") 9 | f = Path("foo.txt").open() - | ^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^ 10 | f = pathlib.Path("foo.txt").open() 11 | f = pl.Path("foo.txt").open() | -SIM115.py:10:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:10:5 | 8 | f = open("foo.txt") 9 | f = Path("foo.txt").open() 10 | f = pathlib.Path("foo.txt").open() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | f = pl.Path("foo.txt").open() 12 | f = P("foo.txt").open() | -SIM115.py:11:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:11:5 | 9 | f = Path("foo.txt").open() 10 | f = pathlib.Path("foo.txt").open() 11 | f = pl.Path("foo.txt").open() - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^^ 12 | f = P("foo.txt").open() 13 | data = f.read() | -SIM115.py:12:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:12:5 | 10 | f = pathlib.Path("foo.txt").open() 11 | f = pl.Path("foo.txt").open() 12 | f = P("foo.txt").open() - | ^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^ 13 | data = f.read() 14 | f.close() | -SIM115.py:40:9: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:40:9 | 38 | # SIM115 39 | with contextlib.ExitStack(): 40 | f = open("filename") - | ^^^^ SIM115 + | ^^^^ 41 | 42 | # OK | -SIM115.py:81:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:81:5 | 79 | import fileinput 80 | 81 | f = tempfile.NamedTemporaryFile() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 82 | f = tempfile.TemporaryFile() 83 | f = tempfile.SpooledTemporaryFile() | -SIM115.py:82:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:82:5 | 81 | f = tempfile.NamedTemporaryFile() 82 | f = tempfile.TemporaryFile() - | ^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^ 83 | f = tempfile.SpooledTemporaryFile() 84 | f = tarfile.open("foo.tar") | -SIM115.py:83:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:83:5 | 81 | f = tempfile.NamedTemporaryFile() 82 | f = tempfile.TemporaryFile() 83 | f = tempfile.SpooledTemporaryFile() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | f = tarfile.open("foo.tar") 85 | f = TarFile("foo.tar").open() | -SIM115.py:84:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:84:5 | 82 | f = tempfile.TemporaryFile() 83 | f = tempfile.SpooledTemporaryFile() 84 | f = tarfile.open("foo.tar") - | ^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^ 85 | f = TarFile("foo.tar").open() 86 | f = tarfile.TarFile("foo.tar").open() | -SIM115.py:85:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:85:5 | 83 | f = tempfile.SpooledTemporaryFile() 84 | f = tarfile.open("foo.tar") 85 | f = TarFile("foo.tar").open() - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^^ 86 | f = tarfile.TarFile("foo.tar").open() 87 | f = tarfile.TarFile().open() | -SIM115.py:86:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:86:5 | 84 | f = tarfile.open("foo.tar") 85 | f = TarFile("foo.tar").open() 86 | f = tarfile.TarFile("foo.tar").open() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 | f = tarfile.TarFile().open() 88 | f = zipfile.ZipFile("foo.zip").open("foo.txt") | -SIM115.py:87:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:87:5 | 85 | f = TarFile("foo.tar").open() 86 | f = tarfile.TarFile("foo.tar").open() 87 | f = tarfile.TarFile().open() - | ^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^ 88 | f = zipfile.ZipFile("foo.zip").open("foo.txt") 89 | f = io.open("foo.txt") | -SIM115.py:88:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:88:5 | 86 | f = tarfile.TarFile("foo.tar").open() 87 | f = tarfile.TarFile().open() 88 | f = zipfile.ZipFile("foo.zip").open("foo.txt") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 89 | f = io.open("foo.txt") 90 | f = io.open_code("foo.txt") | -SIM115.py:89:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:89:5 | 87 | f = tarfile.TarFile().open() 88 | f = zipfile.ZipFile("foo.zip").open("foo.txt") 89 | f = io.open("foo.txt") - | ^^^^^^^ SIM115 + | ^^^^^^^ 90 | f = io.open_code("foo.txt") 91 | f = codecs.open("foo.txt") | -SIM115.py:90:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:90:5 | 88 | f = zipfile.ZipFile("foo.zip").open("foo.txt") 89 | f = io.open("foo.txt") 90 | f = io.open_code("foo.txt") - | ^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^ 91 | f = codecs.open("foo.txt") 92 | f = bz2.open("foo.txt") | -SIM115.py:91:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:91:5 | 89 | f = io.open("foo.txt") 90 | f = io.open_code("foo.txt") 91 | f = codecs.open("foo.txt") - | ^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^ 92 | f = bz2.open("foo.txt") 93 | f = gzip.open("foo.txt") | -SIM115.py:92:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:92:5 | 90 | f = io.open_code("foo.txt") 91 | f = codecs.open("foo.txt") 92 | f = bz2.open("foo.txt") - | ^^^^^^^^ SIM115 + | ^^^^^^^^ 93 | f = gzip.open("foo.txt") 94 | f = dbm.open("foo.db") | -SIM115.py:93:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:93:5 | 91 | f = codecs.open("foo.txt") 92 | f = bz2.open("foo.txt") 93 | f = gzip.open("foo.txt") - | ^^^^^^^^^ SIM115 + | ^^^^^^^^^ 94 | f = dbm.open("foo.db") 95 | f = dbm.gnu.open("foo.db") | -SIM115.py:94:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:94:5 | 92 | f = bz2.open("foo.txt") 93 | f = gzip.open("foo.txt") 94 | f = dbm.open("foo.db") - | ^^^^^^^^ SIM115 + | ^^^^^^^^ 95 | f = dbm.gnu.open("foo.db") 96 | f = dbm.ndbm.open("foo.db") | -SIM115.py:95:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:95:5 | 93 | f = gzip.open("foo.txt") 94 | f = dbm.open("foo.db") 95 | f = dbm.gnu.open("foo.db") - | ^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^ 96 | f = dbm.ndbm.open("foo.db") 97 | f = dbm.dumb.open("foo.db") | -SIM115.py:96:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:96:5 | 94 | f = dbm.open("foo.db") 95 | f = dbm.gnu.open("foo.db") 96 | f = dbm.ndbm.open("foo.db") - | ^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^ 97 | f = dbm.dumb.open("foo.db") 98 | f = lzma.open("foo.xz") | -SIM115.py:97:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:97:5 | 95 | f = dbm.gnu.open("foo.db") 96 | f = dbm.ndbm.open("foo.db") 97 | f = dbm.dumb.open("foo.db") - | ^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^ 98 | f = lzma.open("foo.xz") 99 | f = lzma.LZMAFile("foo.xz") | -SIM115.py:98:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:98:5 | 96 | f = dbm.ndbm.open("foo.db") 97 | f = dbm.dumb.open("foo.db") 98 | f = lzma.open("foo.xz") - | ^^^^^^^^^ SIM115 + | ^^^^^^^^^ 99 | f = lzma.LZMAFile("foo.xz") 100 | f = shelve.open("foo.db") | -SIM115.py:99:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:99:5 | 97 | f = dbm.dumb.open("foo.db") 98 | f = lzma.open("foo.xz") 99 | f = lzma.LZMAFile("foo.xz") - | ^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^ 100 | f = shelve.open("foo.db") 101 | f = tokenize.open("foo.py") | -SIM115.py:100:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:100:5 | 98 | f = lzma.open("foo.xz") 99 | f = lzma.LZMAFile("foo.xz") 100 | f = shelve.open("foo.db") - | ^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^ 101 | f = tokenize.open("foo.py") 102 | f = wave.open("foo.wav") | -SIM115.py:101:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:101:5 | 99 | f = lzma.LZMAFile("foo.xz") 100 | f = shelve.open("foo.db") 101 | f = tokenize.open("foo.py") - | ^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^ 102 | f = wave.open("foo.wav") 103 | f = tarfile.TarFile.taropen("foo.tar") | -SIM115.py:102:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:102:5 | 100 | f = shelve.open("foo.db") 101 | f = tokenize.open("foo.py") 102 | f = wave.open("foo.wav") - | ^^^^^^^^^ SIM115 + | ^^^^^^^^^ 103 | f = tarfile.TarFile.taropen("foo.tar") 104 | f = fileinput.input("foo.txt") | -SIM115.py:103:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:103:5 | 101 | f = tokenize.open("foo.py") 102 | f = wave.open("foo.wav") 103 | f = tarfile.TarFile.taropen("foo.tar") - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^^^^^ 104 | f = fileinput.input("foo.txt") 105 | f = fileinput.FileInput("foo.txt") | -SIM115.py:104:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:104:5 | 102 | f = wave.open("foo.wav") 103 | f = tarfile.TarFile.taropen("foo.tar") 104 | f = fileinput.input("foo.txt") - | ^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^ 105 | f = fileinput.FileInput("foo.txt") | -SIM115.py:105:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:105:5 | 103 | f = tarfile.TarFile.taropen("foo.tar") 104 | f = fileinput.input("foo.txt") 105 | f = fileinput.FileInput("foo.txt") - | ^^^^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^^^^ 106 | 107 | with contextlib.suppress(Exception): | -SIM115.py:241:9: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:241:9 | 239 | def aliased(): 240 | from shelve import open as open_shelf 241 | x = open_shelf("foo.dbm") - | ^^^^^^^^^^ SIM115 + | ^^^^^^^^^^ 242 | x.close() | -SIM115.py:245:9: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:245:9 | 244 | from tarfile import TarFile as TF 245 | f = TF("foo").open() - | ^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^ 246 | f.close() | -SIM115.py:258:5: SIM115 Use a context manager for opening files +SIM115 Use a context manager for opening files + --> SIM115.py:258:5 | 257 | # SIM115 258 | f = dbm.sqlite3.open("foo.db") - | ^^^^^^^^^^^^^^^^ SIM115 + | ^^^^^^^^^^^^^^^^ 259 | f.close() | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap index 459f1a98d4..476cb65a95 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM116.py:6:5: SIM116 Use a dictionary instead of consecutive `if` statements +SIM116 Use a dictionary instead of consecutive `if` statements + --> SIM116.py:6:5 | 5 | # SIM116 6 | / if a == "foo": @@ -12,12 +13,13 @@ SIM116.py:6:5: SIM116 Use a dictionary instead of consecutive `if` statements 11 | | return "ooh" 12 | | else: 13 | | return 42 - | |_________________^ SIM116 + | |_________________^ 14 | 15 | # SIM116 | -SIM116.py:16:5: SIM116 Use a dictionary instead of consecutive `if` statements +SIM116 Use a dictionary instead of consecutive `if` statements + --> SIM116.py:16:5 | 15 | # SIM116 16 | / if a == 1: @@ -28,12 +30,13 @@ SIM116.py:16:5: SIM116 Use a dictionary instead of consecutive `if` statements 21 | | return (7, 8, 9) 22 | | else: 23 | | return (10, 11, 12) - | |___________________________^ SIM116 + | |___________________________^ 24 | 25 | # SIM116 | -SIM116.py:26:5: SIM116 Use a dictionary instead of consecutive `if` statements +SIM116 Use a dictionary instead of consecutive `if` statements + --> SIM116.py:26:5 | 25 | # SIM116 26 | / if a == 1: @@ -42,12 +45,13 @@ SIM116.py:26:5: SIM116 Use a dictionary instead of consecutive `if` statements 29 | | return (4, 5, 6) 30 | | elif a == 3: 31 | | return (7, 8, 9) - | |________________________^ SIM116 + | |________________________^ 32 | 33 | # SIM116 | -SIM116.py:34:5: SIM116 Use a dictionary instead of consecutive `if` statements +SIM116 Use a dictionary instead of consecutive `if` statements + --> SIM116.py:34:5 | 33 | # SIM116 34 | / if a == "hello 'sir'": @@ -58,12 +62,13 @@ SIM116.py:34:5: SIM116 Use a dictionary instead of consecutive `if` statements 39 | | return (7, 8, 9) 40 | | else: 41 | | return (10, 11, 12) - | |___________________________^ SIM116 + | |___________________________^ 42 | 43 | # SIM116 | -SIM116.py:44:5: SIM116 Use a dictionary instead of consecutive `if` statements +SIM116 Use a dictionary instead of consecutive `if` statements + --> SIM116.py:44:5 | 43 | # SIM116 44 | / if a == b"one": @@ -72,12 +77,13 @@ SIM116.py:44:5: SIM116 Use a dictionary instead of consecutive `if` statements 47 | | return 2 48 | | elif a == b"three": 49 | | return 3 - | |________________^ SIM116 + | |________________^ 50 | 51 | # SIM116 | -SIM116.py:52:5: SIM116 Use a dictionary instead of consecutive `if` statements +SIM116 Use a dictionary instead of consecutive `if` statements + --> SIM116.py:52:5 | 51 | # SIM116 52 | / if a == "hello 'sir'": @@ -88,12 +94,13 @@ SIM116.py:52:5: SIM116 Use a dictionary instead of consecutive `if` statements 57 | | return (7, 8, 9) 58 | | else: 59 | | return (10, 11, 12) - | |___________________________^ SIM116 + | |___________________________^ 60 | 61 | # OK | -SIM116.py:80:5: SIM116 Use a dictionary instead of consecutive `if` statements +SIM116 Use a dictionary instead of consecutive `if` statements + --> SIM116.py:80:5 | 79 | # SIM116 80 | / if func_name == "create": @@ -104,7 +111,7 @@ SIM116.py:80:5: SIM116 Use a dictionary instead of consecutive `if` statements 85 | | return "D" 86 | | elif func_name == "move": 87 | | return "MV" - | |___________________^ SIM116 + | |___________________^ 88 | 89 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap index f88cc5274a..5669f91959 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM117.py:2:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:2:1 | 1 | # SIM117 2 | / with A() as a: 3 | | with B() as b: - | |__________________^ SIM117 + | |__________________^ 4 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 1 1 | # SIM117 @@ -22,16 +23,17 @@ SIM117.py:2:1: SIM117 [*] Use a single `with` statement with multiple contexts i 6 5 | # SIM117 7 6 | with A(): -SIM117.py:7:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:7:1 | 6 | # SIM117 7 | / with A(): 8 | | with B(): - | |_____________^ SIM117 + | |_____________^ 9 | with C(): 10 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 4 4 | print("hello") @@ -48,27 +50,29 @@ SIM117.py:7:1: SIM117 [*] Use a single `with` statement with multiple contexts i 12 11 | # SIM117 13 12 | with A() as a: -SIM117.py:13:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:13:1 | 12 | # SIM117 13 | / with A() as a: 14 | | # Unfixable due to placement of this comment. 15 | | with B() as b: - | |__________________^ SIM117 + | |__________________^ 16 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements -SIM117.py:19:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:19:1 | 18 | # SIM117 19 | / with A() as a: 20 | | with B() as b: - | |__________________^ SIM117 + | |__________________^ 21 | # Fixable due to placement of this comment. 22 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 16 16 | print("hello") @@ -85,15 +89,16 @@ SIM117.py:19:1: SIM117 [*] Use a single `with` statement with multiple contexts 24 23 | # OK 25 24 | with A() as a: -SIM117.py:47:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:47:1 | 46 | # SIM117 47 | / async with A() as a: 48 | | async with B() as b: - | |________________________^ SIM117 + | |________________________^ 49 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 44 44 | print("hello") @@ -108,17 +113,18 @@ SIM117.py:47:1: SIM117 [*] Use a single `with` statement with multiple contexts 51 50 | while True: 52 51 | # SIM117 -SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:53:5 | 51 | while True: 52 | # SIM117 53 | / with A() as a: 54 | | with B() as b: - | |______________________^ SIM117 + | |______________________^ 55 | """this 56 | is valid""" | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 50 50 | @@ -145,7 +151,8 @@ SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts 66 65 | 67 66 | # SIM117 -SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:68:1 | 67 | # SIM117 68 | / with ( @@ -153,10 +160,10 @@ SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts 70 | | B() as b, 71 | | ): 72 | | with C() as c: - | |__________________^ SIM117 + | |__________________^ 73 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 67 67 | # SIM117 @@ -172,7 +179,8 @@ SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts 75 74 | # SIM117 76 75 | with A() as a: -SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:76:1 | 75 | # SIM117 76 | / with A() as a: @@ -180,10 +188,10 @@ SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts 78 | | B() as b, 79 | | C() as c, 80 | | ): - | |______^ SIM117 + | |______^ 81 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 73 73 | print("hello") @@ -204,7 +212,8 @@ SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts 83 82 | # SIM117 84 83 | with ( -SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:84:1 | 83 | # SIM117 84 | / with ( @@ -215,10 +224,10 @@ SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts 89 | | C() as c, 90 | | D() as d, 91 | | ): - | |______^ SIM117 + | |______^ 92 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 83 83 | # SIM117 @@ -238,15 +247,16 @@ SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts 94 91 | # SIM117 (auto-fixable) 95 92 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: -SIM117.py:95:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:95:1 | 94 | # SIM117 (auto-fixable) 95 | / with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: 96 | | with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: - | |__________________________________________________^ SIM117 + | |__________________________________________________^ 97 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 92 92 | print("hello") @@ -261,36 +271,39 @@ SIM117.py:95:1: SIM117 [*] Use a single `with` statement with multiple contexts 99 98 | # SIM117 (not auto-fixable too long) 100 99 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: -SIM117.py:100:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:100:1 | 99 | # SIM117 (not auto-fixable too long) 100 | / with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: 101 | | with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: - | |__________________________________________________^ SIM117 + | |__________________________________________________^ 102 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements -SIM117.py:106:5: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:106:5 | 104 | # From issue #3025. 105 | async def main(): 106 | / async with A() as a: # SIM117. 107 | | async with B() as b: - | |____________________________^ SIM117 + | |____________________________^ 108 | print("async-inside!") | - = help: Combine `with` statements +help: Combine `with` statements -SIM117.py:126:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:126:1 | 125 | # SIM117 126 | / with A() as a: 127 | | with B() as b: - | |__________________^ SIM117 + | |__________________^ 128 | type ListOrSet[T] = list[T] | set[T] | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 123 123 | f(b2, c2, d2) @@ -318,15 +331,16 @@ SIM117.py:126:1: SIM117 [*] Use a single `with` statement with multiple contexts 138 137 | # Allow cascading for some statements. 139 138 | import anyio -SIM117.py:163:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:163:1 | 162 | # Do not suppress combination, if a context manager is already combined with another. 163 | / async with asyncio.timeout(1), A(): 164 | | async with B(): - | |___________________^ SIM117 + | |___________________^ 165 | pass | - = help: Combine `with` statements +help: Combine `with` statements ℹ Unsafe fix 160 160 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap index 28b8ed5313..1400a9d93b 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM118.py:3:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:3:1 | 1 | obj = {} 2 | 3 | key in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^ 4 | 5 | key not in obj.keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 1 1 | obj = {} @@ -21,16 +22,17 @@ SIM118.py:3:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 5 5 | key not in obj.keys() # SIM118 6 6 | -SIM118.py:5:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` +SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` + --> SIM118.py:5:1 | 3 | key in obj.keys() # SIM118 4 | 5 | key not in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | foo["bar"] in obj.keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 2 2 | @@ -42,16 +44,17 @@ SIM118.py:5:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys 7 7 | foo["bar"] in obj.keys() # SIM118 8 8 | -SIM118.py:7:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:7:1 | 5 | key not in obj.keys() # SIM118 6 | 7 | foo["bar"] in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | foo["bar"] not in obj.keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 4 4 | @@ -63,16 +66,17 @@ SIM118.py:7:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 9 9 | foo["bar"] not in obj.keys() # SIM118 10 10 | -SIM118.py:9:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` +SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` + --> SIM118.py:9:1 | 7 | foo["bar"] in obj.keys() # SIM118 8 | 9 | foo["bar"] not in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | foo['bar'] in obj.keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 6 6 | @@ -84,16 +88,17 @@ SIM118.py:9:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys 11 11 | foo['bar'] in obj.keys() # SIM118 12 12 | -SIM118.py:11:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:11:1 | 9 | foo["bar"] not in obj.keys() # SIM118 10 | 11 | foo['bar'] in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | foo['bar'] not in obj.keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 8 8 | @@ -105,16 +110,17 @@ SIM118.py:11:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 13 13 | foo['bar'] not in obj.keys() # SIM118 14 14 | -SIM118.py:13:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` +SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` + --> SIM118.py:13:1 | 11 | foo['bar'] in obj.keys() # SIM118 12 | 13 | foo['bar'] not in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | foo() in obj.keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 10 10 | @@ -126,16 +132,17 @@ SIM118.py:13:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.key 15 15 | foo() in obj.keys() # SIM118 16 16 | -SIM118.py:15:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:15:1 | 13 | foo['bar'] not in obj.keys() # SIM118 14 | 15 | foo() in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^ 16 | 17 | foo() not in obj.keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 12 12 | @@ -147,16 +154,17 @@ SIM118.py:15:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 17 17 | foo() not in obj.keys() # SIM118 18 18 | -SIM118.py:17:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` +SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` + --> SIM118.py:17:1 | 15 | foo() in obj.keys() # SIM118 16 | 17 | foo() not in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | for key in obj.keys(): # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 14 14 | @@ -168,15 +176,16 @@ SIM118.py:17:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.key 19 19 | for key in obj.keys(): # SIM118 20 20 | pass -SIM118.py:19:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:19:5 | 17 | foo() not in obj.keys() # SIM118 18 | 19 | for key in obj.keys(): # SIM118 - | ^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^ 20 | pass | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 16 16 | @@ -188,16 +197,17 @@ SIM118.py:19:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 21 21 | 22 22 | for key in list(obj.keys()): -SIM118.py:26:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:26:8 | 24 | del obj[key] 25 | 26 | [k for k in obj.keys()] # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^ 27 | 28 | {k for k in obj.keys()} # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 23 23 | if some_property(key): @@ -209,16 +219,17 @@ SIM118.py:26:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 28 28 | {k for k in obj.keys()} # SIM118 29 29 | -SIM118.py:28:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:28:8 | 26 | [k for k in obj.keys()] # SIM118 27 | 28 | {k for k in obj.keys()} # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^ 29 | 30 | {k: k for k in obj.keys()} # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 25 25 | @@ -230,16 +241,17 @@ SIM118.py:28:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 30 30 | {k: k for k in obj.keys()} # SIM118 31 31 | -SIM118.py:30:11: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:30:11 | 28 | {k for k in obj.keys()} # SIM118 29 | 30 | {k: k for k in obj.keys()} # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^ 31 | 32 | (k for k in obj.keys()) # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 27 27 | @@ -251,16 +263,17 @@ SIM118.py:30:11: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 32 32 | (k for k in obj.keys()) # SIM118 33 33 | -SIM118.py:32:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:32:8 | 30 | {k: k for k in obj.keys()} # SIM118 31 | 32 | (k for k in obj.keys()) # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^ 33 | 34 | key in (obj or {}).keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 29 29 | @@ -272,16 +285,17 @@ SIM118.py:32:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 34 34 | key in (obj or {}).keys() # SIM118 35 35 | -SIM118.py:34:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:34:1 | 32 | (k for k in obj.keys()) # SIM118 33 | 34 | key in (obj or {}).keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | (key) in (obj or {}).keys() # SIM118 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Unsafe fix 31 31 | @@ -293,16 +307,17 @@ SIM118.py:34:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 36 36 | (key) in (obj or {}).keys() # SIM118 37 37 | -SIM118.py:36:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:36:1 | 34 | key in (obj or {}).keys() # SIM118 35 | 36 | (key) in (obj or {}).keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | 38 | from typing import KeysView | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Unsafe fix 33 33 | @@ -314,15 +329,16 @@ SIM118.py:36:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 38 38 | from typing import KeysView 39 39 | -SIM118.py:50:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:50:1 | 49 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 50 | key in obj.keys()and foo - | ^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^ 51 | (key in obj.keys())and foo 52 | key in (obj.keys())and foo | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 47 47 | @@ -334,15 +350,16 @@ SIM118.py:50:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 52 52 | key in (obj.keys())and foo 53 53 | -SIM118.py:51:2: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:51:2 | 49 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 50 | key in obj.keys()and foo 51 | (key in obj.keys())and foo - | ^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^ 52 | key in (obj.keys())and foo | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 48 48 | @@ -354,16 +371,17 @@ SIM118.py:51:2: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 53 53 | 54 54 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 -SIM118.py:52:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:52:1 | 50 | key in obj.keys()and foo 51 | (key in obj.keys())and foo 52 | key in (obj.keys())and foo - | ^^^^^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^^^^^ 53 | 54 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 49 49 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 @@ -375,7 +393,8 @@ SIM118.py:52:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 54 54 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 55 55 | for key in ( -SIM118.py:55:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:55:5 | 54 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 55 | for key in ( @@ -384,10 +403,10 @@ SIM118.py:55:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 57 | | .stations[0] 58 | | .keys() 59 | | ): - | |_^ SIM118 + | |_^ 60 | continue | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Unsafe fix 55 55 | for key in ( @@ -399,13 +418,14 @@ SIM118.py:55:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` 60 60 | continue 61 61 | -SIM118.py:65:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` +SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + --> SIM118.py:65:1 | 64 | d = SneakyDict() 65 | key in d.keys() # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 + | ^^^^^^^^^^^^^^^ | - = help: Remove `.keys()` +help: Remove `.keys()` ℹ Safe fix 62 62 | from builtins import dict as SneakyDict diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap index e3cceb1d69..fcf5326220 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM201.py:2:4: SIM201 [*] Use `a != b` instead of `not a == b` +SIM201 [*] Use `a != b` instead of `not a == b` + --> SIM201.py:2:4 | 1 | # SIM201 2 | if not a == b: - | ^^^^^^^^^^ SIM201 + | ^^^^^^^^^^ 3 | pass | - = help: Replace with `!=` operator +help: Replace with `!=` operator ℹ Unsafe fix 1 1 | # SIM201 @@ -18,14 +19,15 @@ SIM201.py:2:4: SIM201 [*] Use `a != b` instead of `not a == b` 4 4 | 5 5 | # SIM201 -SIM201.py:6:4: SIM201 [*] Use `a != b + c` instead of `not a == b + c` +SIM201 [*] Use `a != b + c` instead of `not a == b + c` + --> SIM201.py:6:4 | 5 | # SIM201 6 | if not a == (b + c): - | ^^^^^^^^^^^^^^^^ SIM201 + | ^^^^^^^^^^^^^^^^ 7 | pass | - = help: Replace with `!=` operator +help: Replace with `!=` operator ℹ Unsafe fix 3 3 | pass @@ -37,14 +39,15 @@ SIM201.py:6:4: SIM201 [*] Use `a != b + c` instead of `not a == b + c` 8 8 | 9 9 | # SIM201 -SIM201.py:10:4: SIM201 [*] Use `a + b != c` instead of `not a + b == c` +SIM201 [*] Use `a + b != c` instead of `not a + b == c` + --> SIM201.py:10:4 | 9 | # SIM201 10 | if not (a + b) == c: - | ^^^^^^^^^^^^^^^^ SIM201 + | ^^^^^^^^^^^^^^^^ 11 | pass | - = help: Replace with `!=` operator +help: Replace with `!=` operator ℹ Unsafe fix 7 7 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap index f32eb412b8..a843381049 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM202.py:2:4: SIM202 [*] Use `a == b` instead of `not a != b` +SIM202 [*] Use `a == b` instead of `not a != b` + --> SIM202.py:2:4 | 1 | # SIM202 2 | if not a != b: - | ^^^^^^^^^^ SIM202 + | ^^^^^^^^^^ 3 | pass | - = help: Replace with `==` operator +help: Replace with `==` operator ℹ Unsafe fix 1 1 | # SIM202 @@ -18,14 +19,15 @@ SIM202.py:2:4: SIM202 [*] Use `a == b` instead of `not a != b` 4 4 | 5 5 | # SIM202 -SIM202.py:6:4: SIM202 [*] Use `a == b + c` instead of `not a != b + c` +SIM202 [*] Use `a == b + c` instead of `not a != b + c` + --> SIM202.py:6:4 | 5 | # SIM202 6 | if not a != (b + c): - | ^^^^^^^^^^^^^^^^ SIM202 + | ^^^^^^^^^^^^^^^^ 7 | pass | - = help: Replace with `==` operator +help: Replace with `==` operator ℹ Unsafe fix 3 3 | pass @@ -37,14 +39,15 @@ SIM202.py:6:4: SIM202 [*] Use `a == b + c` instead of `not a != b + c` 8 8 | 9 9 | # SIM202 -SIM202.py:10:4: SIM202 [*] Use `a + b == c` instead of `not a + b != c` +SIM202 [*] Use `a + b == c` instead of `not a + b != c` + --> SIM202.py:10:4 | 9 | # SIM202 10 | if not (a + b) != c: - | ^^^^^^^^^^^^^^^^ SIM202 + | ^^^^^^^^^^^^^^^^ 11 | pass | - = help: Replace with `==` operator +help: Replace with `==` operator ℹ Unsafe fix 7 7 | pass diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap index 39455218cf..ba0415f28b 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM208.py:1:4: SIM208 [*] Use `a` instead of `not (not a)` +SIM208 [*] Use `a` instead of `not (not a)` + --> SIM208.py:1:4 | 1 | if not (not a): # SIM208 - | ^^^^^^^^^^^ SIM208 + | ^^^^^^^^^^^ 2 | pass | - = help: Replace with `a` +help: Replace with `a` ℹ Safe fix 1 |-if not (not a): # SIM208 @@ -16,15 +17,16 @@ SIM208.py:1:4: SIM208 [*] Use `a` instead of `not (not a)` 3 3 | 4 4 | if not (not (a == b)): # SIM208 -SIM208.py:4:4: SIM208 [*] Use `a == b` instead of `not (not a == b)` +SIM208 [*] Use `a == b` instead of `not (not a == b)` + --> SIM208.py:4:4 | 2 | pass 3 | 4 | if not (not (a == b)): # SIM208 - | ^^^^^^^^^^^^^^^^^^ SIM208 + | ^^^^^^^^^^^^^^^^^^ 5 | pass | - = help: Replace with `a == b` +help: Replace with `a == b` ℹ Safe fix 1 1 | if not (not a): # SIM208 @@ -36,16 +38,17 @@ SIM208.py:4:4: SIM208 [*] Use `a == b` instead of `not (not a == b)` 6 6 | 7 7 | if not a: # OK -SIM208.py:16:5: SIM208 [*] Use `b` instead of `not (not b)` +SIM208 [*] Use `b` instead of `not (not b)` + --> SIM208.py:16:5 | 14 | pass 15 | 16 | a = not not b # SIM208 - | ^^^^^^^^^ SIM208 + | ^^^^^^^^^ 17 | 18 | f(not not a) # SIM208 | - = help: Replace with `b` +help: Replace with `b` ℹ Safe fix 13 13 | if not a != b: # OK @@ -57,16 +60,17 @@ SIM208.py:16:5: SIM208 [*] Use `b` instead of `not (not b)` 18 18 | f(not not a) # SIM208 19 19 | -SIM208.py:18:3: SIM208 [*] Use `a` instead of `not (not a)` +SIM208 [*] Use `a` instead of `not (not a)` + --> SIM208.py:18:3 | 16 | a = not not b # SIM208 17 | 18 | f(not not a) # SIM208 - | ^^^^^^^^^ SIM208 + | ^^^^^^^^^ 19 | 20 | if 1 + (not (not a)): # SIM208 | - = help: Replace with `a` +help: Replace with `a` ℹ Safe fix 15 15 | @@ -78,15 +82,16 @@ SIM208.py:18:3: SIM208 [*] Use `a` instead of `not (not a)` 20 20 | if 1 + (not (not a)): # SIM208 21 21 | pass -SIM208.py:20:9: SIM208 [*] Use `a` instead of `not (not a)` +SIM208 [*] Use `a` instead of `not (not a)` + --> SIM208.py:20:9 | 18 | f(not not a) # SIM208 19 | 20 | if 1 + (not (not a)): # SIM208 - | ^^^^^^^^^^^ SIM208 + | ^^^^^^^^^^^ 21 | pass | - = help: Replace with `a` +help: Replace with `a` ℹ Safe fix 17 17 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap index 3ccfac277d..f6246838c4 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM210.py:1:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` +SIM210 [*] Use `bool(...)` instead of `True if ... else False` + --> SIM210.py:1:5 | 1 | a = True if b else False # SIM210 - | ^^^^^^^^^^^^^^^^^^^^ SIM210 + | ^^^^^^^^^^^^^^^^^^^^ 2 | 3 | a = True if b != c else False # SIM210 | - = help: Replace with `bool(...) +help: Replace with `bool(...) ℹ Unsafe fix 1 |-a = True if b else False # SIM210 @@ -17,16 +18,17 @@ SIM210.py:1:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` 3 3 | a = True if b != c else False # SIM210 4 4 | -SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` +SIM210 [*] Remove unnecessary `True if ... else False` + --> SIM210.py:3:5 | 1 | a = True if b else False # SIM210 2 | 3 | a = True if b != c else False # SIM210 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | a = True if b + c else False # SIM210 | - = help: Remove unnecessary `True if ... else False` +help: Remove unnecessary `True if ... else False` ℹ Unsafe fix 1 1 | a = True if b else False # SIM210 @@ -37,16 +39,17 @@ SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` 5 5 | a = True if b + c else False # SIM210 6 6 | -SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` +SIM210 [*] Use `bool(...)` instead of `True if ... else False` + --> SIM210.py:5:5 | 3 | a = True if b != c else False # SIM210 4 | 5 | a = True if b + c else False # SIM210 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM210 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | a = False if b else True # OK | - = help: Replace with `bool(...) +help: Replace with `bool(...) ℹ Unsafe fix 2 2 | @@ -58,24 +61,26 @@ SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` 7 7 | a = False if b else True # OK 8 8 | -SIM210.py:15:9: SIM210 Use `bool(...)` instead of `True if ... else False` +SIM210 Use `bool(...)` instead of `True if ... else False` + --> SIM210.py:15:9 | 13 | return False 14 | 15 | a = True if b else False - | ^^^^^^^^^^^^^^^^^^^^ SIM210 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `bool(...) +help: Replace with `bool(...) -SIM210.py:19:11: SIM210 [*] Remove unnecessary `True if ... else False` +SIM210 [*] Remove unnecessary `True if ... else False` + --> SIM210.py:19:11 | 18 | # Regression test for: https://github.com/astral-sh/ruff/issues/7076 19 | samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == | ___________^ 20 | | psl.privatesuffix(src.netloc)) else False - | |____________________________________________________________________________^ SIM210 + | |____________________________________________________________________________^ | - = help: Remove unnecessary `True if ... else False` +help: Remove unnecessary `True if ... else False` ℹ Unsafe fix 16 16 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap index f064d0046f..86e134ff58 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM211.py:1:5: SIM211 [*] Use `not ...` instead of `False if ... else True` +SIM211 [*] Use `not ...` instead of `False if ... else True` + --> SIM211.py:1:5 | 1 | a = False if b else True # SIM211 - | ^^^^^^^^^^^^^^^^^^^^ SIM211 + | ^^^^^^^^^^^^^^^^^^^^ 2 | 3 | a = False if b != c else True # SIM211 | - = help: Replace with `not ...` +help: Replace with `not ...` ℹ Unsafe fix 1 |-a = False if b else True # SIM211 @@ -17,16 +18,17 @@ SIM211.py:1:5: SIM211 [*] Use `not ...` instead of `False if ... else True` 3 3 | a = False if b != c else True # SIM211 4 4 | -SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` +SIM211 [*] Use `not ...` instead of `False if ... else True` + --> SIM211.py:3:5 | 1 | a = False if b else True # SIM211 2 | 3 | a = False if b != c else True # SIM211 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM211 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | a = False if b + c else True # SIM211 | - = help: Replace with `not ...` +help: Replace with `not ...` ℹ Unsafe fix 1 1 | a = False if b else True # SIM211 @@ -37,16 +39,17 @@ SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` 5 5 | a = False if b + c else True # SIM211 6 6 | -SIM211.py:5:5: SIM211 [*] Use `not ...` instead of `False if ... else True` +SIM211 [*] Use `not ...` instead of `False if ... else True` + --> SIM211.py:5:5 | 3 | a = False if b != c else True # SIM211 4 | 5 | a = False if b + c else True # SIM211 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM211 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | a = True if b else False # OK | - = help: Replace with `not ...` +help: Replace with `not ...` ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap index 8696c8e69d..7f8aefa640 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM212.py:1:5: SIM212 [*] Use `a if a else b` instead of `b if not a else a` +SIM212 [*] Use `a if a else b` instead of `b if not a else a` + --> SIM212.py:1:5 | 1 | c = b if not a else a # SIM212 - | ^^^^^^^^^^^^^^^^^ SIM212 + | ^^^^^^^^^^^^^^^^^ 2 | 3 | c = b + c if not a else a # SIM212 | - = help: Replace with `a if a else b` +help: Replace with `a if a else b` ℹ Unsafe fix 1 |-c = b if not a else a # SIM212 @@ -17,16 +18,17 @@ SIM212.py:1:5: SIM212 [*] Use `a if a else b` instead of `b if not a else a` 3 3 | c = b + c if not a else a # SIM212 4 4 | -SIM212.py:3:5: SIM212 [*] Use `a if a else b + c` instead of `b + c if not a else a` +SIM212 [*] Use `a if a else b + c` instead of `b + c if not a else a` + --> SIM212.py:3:5 | 1 | c = b if not a else a # SIM212 2 | 3 | c = b + c if not a else a # SIM212 - | ^^^^^^^^^^^^^^^^^^^^^ SIM212 + | ^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | c = b if not x else a # OK | - = help: Replace with `a if a else b + c` +help: Replace with `a if a else b + c` ℹ Unsafe fix 1 1 | c = b if not a else a # SIM212 diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap index a6a073846b..ab1d1e3165 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM220.py:1:4: SIM220 [*] Use `False` instead of `a and not a` +SIM220 [*] Use `False` instead of `a and not a` + --> SIM220.py:1:4 | 1 | if a and not a: - | ^^^^^^^^^^^ SIM220 + | ^^^^^^^^^^^ 2 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 1 |-if a and not a: @@ -16,15 +17,16 @@ SIM220.py:1:4: SIM220 [*] Use `False` instead of `a and not a` 3 3 | 4 4 | if (a and not a) and b: -SIM220.py:4:5: SIM220 [*] Use `False` instead of `a and not a` +SIM220 [*] Use `False` instead of `a and not a` + --> SIM220.py:4:5 | 2 | pass 3 | 4 | if (a and not a) and b: - | ^^^^^^^^^^^ SIM220 + | ^^^^^^^^^^^ 5 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 1 1 | if a and not a: @@ -36,15 +38,16 @@ SIM220.py:4:5: SIM220 [*] Use `False` instead of `a and not a` 6 6 | 7 7 | if (a and not a) or b: -SIM220.py:7:5: SIM220 [*] Use `False` instead of `a and not a` +SIM220 [*] Use `False` instead of `a and not a` + --> SIM220.py:7:5 | 5 | pass 6 | 7 | if (a and not a) or b: - | ^^^^^^^^^^^ SIM220 + | ^^^^^^^^^^^ 8 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 4 4 | if (a and not a) and b: diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap index d34af71f63..d7c0ec8b26 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM221.py:1:4: SIM221 [*] Use `True` instead of `a or not a` +SIM221 [*] Use `True` instead of `a or not a` + --> SIM221.py:1:4 | 1 | if a or not a: - | ^^^^^^^^^^ SIM221 + | ^^^^^^^^^^ 2 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 1 |-if a or not a: @@ -16,15 +17,16 @@ SIM221.py:1:4: SIM221 [*] Use `True` instead of `a or not a` 3 3 | 4 4 | if (a or not a) or b: -SIM221.py:4:5: SIM221 [*] Use `True` instead of `a or not a` +SIM221 [*] Use `True` instead of `a or not a` + --> SIM221.py:4:5 | 2 | pass 3 | 4 | if (a or not a) or b: - | ^^^^^^^^^^ SIM221 + | ^^^^^^^^^^ 5 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 1 1 | if a or not a: @@ -36,15 +38,16 @@ SIM221.py:4:5: SIM221 [*] Use `True` instead of `a or not a` 6 6 | 7 7 | if (a or not a) and b: -SIM221.py:7:5: SIM221 [*] Use `True` instead of `a or not a` +SIM221 [*] Use `True` instead of `a or not a` + --> SIM221.py:7:5 | 5 | pass 6 | 7 | if (a or not a) and b: - | ^^^^^^^^^^ SIM221 + | ^^^^^^^^^^ 8 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 4 4 | if (a or not a) or b: diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap index f011dba942..3c894ee321 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM222.py:1:4: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:1:4 | 1 | if a or True: # SIM222 - | ^^^^^^^^^ SIM222 + | ^^^^^^^^^ 2 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 1 |-if a or True: # SIM222 @@ -16,15 +17,16 @@ SIM222.py:1:4: SIM222 [*] Use `True` instead of `... or True` 3 3 | 4 4 | if (a or b) or True: # SIM222 -SIM222.py:4:4: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:4:4 | 2 | pass 3 | 4 | if (a or b) or True: # SIM222 - | ^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^ 5 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 1 1 | if a or True: # SIM222 @@ -36,15 +38,16 @@ SIM222.py:4:4: SIM222 [*] Use `True` instead of `... or True` 6 6 | 7 7 | if a or (b or True): # SIM222 -SIM222.py:7:10: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:7:10 | 5 | pass 6 | 7 | if a or (b or True): # SIM222 - | ^^^^^^^^^ SIM222 + | ^^^^^^^^^ 8 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 4 4 | if (a or b) or True: # SIM222 @@ -56,15 +59,16 @@ SIM222.py:7:10: SIM222 [*] Use `True` instead of `... or True` 9 9 | 10 10 | if a and True: # OK -SIM222.py:24:16: SIM222 [*] Use `True` instead of `True or ...` +SIM222 [*] Use `True` instead of `True or ...` + --> SIM222.py:24:16 | 22 | pass 23 | 24 | if a or f() or True or g() or b: # SIM222 - | ^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^ 25 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 21 21 | if a or f() or b or g() or True: # OK @@ -76,15 +80,16 @@ SIM222.py:24:16: SIM222 [*] Use `True` instead of `True or ...` 26 26 | 27 27 | if True or f() or a or g() or b: # SIM222 -SIM222.py:27:4: SIM222 [*] Use `True` instead of `True or ...` +SIM222 [*] Use `True` instead of `True or ...` + --> SIM222.py:27:4 | 25 | pass 26 | 27 | if True or f() or a or g() or b: # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 24 24 | if a or f() or True or g() or b: # SIM222 @@ -96,15 +101,16 @@ SIM222.py:27:4: SIM222 [*] Use `True` instead of `True or ...` 29 29 | 30 30 | if a or True or f() or b or g(): # SIM222 -SIM222.py:30:4: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:30:4 | 28 | pass 29 | 30 | if a or True or f() or b or g(): # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 27 27 | if True or f() or a or g() or b: # SIM222 @@ -116,14 +122,15 @@ SIM222.py:30:4: SIM222 [*] Use `True` instead of `... or True or ...` 32 32 | 33 33 | -SIM222.py:47:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:47:6 | 47 | a or "" or True # SIM222 - | ^^^^^^^^^^ SIM222 + | ^^^^^^^^^^ 48 | 49 | a or "foo" or True or "bar" # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 44 44 | pass @@ -135,16 +142,17 @@ SIM222.py:47:6: SIM222 [*] Use `True` instead of `... or True` 49 49 | a or "foo" or True or "bar" # SIM222 50 50 | -SIM222.py:49:6: SIM222 [*] Use `"foo"` instead of `"foo" or ...` +SIM222 [*] Use `"foo"` instead of `"foo" or ...` + --> SIM222.py:49:6 | 47 | a or "" or True # SIM222 48 | 49 | a or "foo" or True or "bar" # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | a or 0 or True # SIM222 | - = help: Replace with `"foo"` +help: Replace with `"foo"` ℹ Unsafe fix 46 46 | @@ -156,16 +164,17 @@ SIM222.py:49:6: SIM222 [*] Use `"foo"` instead of `"foo" or ...` 51 51 | a or 0 or True # SIM222 52 52 | -SIM222.py:51:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:51:6 | 49 | a or "foo" or True or "bar" # SIM222 50 | 51 | a or 0 or True # SIM222 - | ^^^^^^^^^ SIM222 + | ^^^^^^^^^ 52 | 53 | a or 1 or True or 2 # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 48 48 | @@ -177,16 +186,17 @@ SIM222.py:51:6: SIM222 [*] Use `True` instead of `... or True` 53 53 | a or 1 or True or 2 # SIM222 54 54 | -SIM222.py:53:6: SIM222 [*] Use `1` instead of `1 or ...` +SIM222 [*] Use `1` instead of `1 or ...` + --> SIM222.py:53:6 | 51 | a or 0 or True # SIM222 52 | 53 | a or 1 or True or 2 # SIM222 - | ^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^ 54 | 55 | a or 0.0 or True # SIM222 | - = help: Replace with `1` +help: Replace with `1` ℹ Unsafe fix 50 50 | @@ -198,16 +208,17 @@ SIM222.py:53:6: SIM222 [*] Use `1` instead of `1 or ...` 55 55 | a or 0.0 or True # SIM222 56 56 | -SIM222.py:55:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:55:6 | 53 | a or 1 or True or 2 # SIM222 54 | 55 | a or 0.0 or True # SIM222 - | ^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^ 56 | 57 | a or 0.1 or True or 0.2 # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 52 52 | @@ -219,16 +230,17 @@ SIM222.py:55:6: SIM222 [*] Use `True` instead of `... or True` 57 57 | a or 0.1 or True or 0.2 # SIM222 58 58 | -SIM222.py:57:6: SIM222 [*] Use `0.1` instead of `0.1 or ...` +SIM222 [*] Use `0.1` instead of `0.1 or ...` + --> SIM222.py:57:6 | 55 | a or 0.0 or True # SIM222 56 | 57 | a or 0.1 or True or 0.2 # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^ 58 | 59 | a or [] or True # SIM222 | - = help: Replace with `0.1` +help: Replace with `0.1` ℹ Unsafe fix 54 54 | @@ -240,16 +252,17 @@ SIM222.py:57:6: SIM222 [*] Use `0.1` instead of `0.1 or ...` 59 59 | a or [] or True # SIM222 60 60 | -SIM222.py:59:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:59:6 | 57 | a or 0.1 or True or 0.2 # SIM222 58 | 59 | a or [] or True # SIM222 - | ^^^^^^^^^^ SIM222 + | ^^^^^^^^^^ 60 | 61 | a or list([]) or True # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 56 56 | @@ -261,16 +274,17 @@ SIM222.py:59:6: SIM222 [*] Use `True` instead of `... or True` 61 61 | a or list([]) or True # SIM222 62 62 | -SIM222.py:61:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:61:6 | 59 | a or [] or True # SIM222 60 | 61 | a or list([]) or True # SIM222 - | ^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^ 62 | 63 | a or [1] or True or [2] # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 58 58 | @@ -282,16 +296,17 @@ SIM222.py:61:6: SIM222 [*] Use `True` instead of `... or True` 63 63 | a or [1] or True or [2] # SIM222 64 64 | -SIM222.py:63:6: SIM222 [*] Use `[1]` instead of `[1] or ...` +SIM222 [*] Use `[1]` instead of `[1] or ...` + --> SIM222.py:63:6 | 61 | a or list([]) or True # SIM222 62 | 63 | a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^ 64 | 65 | a or list([1]) or True or list([2]) # SIM222 | - = help: Replace with `[1]` +help: Replace with `[1]` ℹ Unsafe fix 60 60 | @@ -303,16 +318,17 @@ SIM222.py:63:6: SIM222 [*] Use `[1]` instead of `[1] or ...` 65 65 | a or list([1]) or True or list([2]) # SIM222 66 66 | -SIM222.py:65:6: SIM222 [*] Use `list([1])` instead of `list([1]) or ...` +SIM222 [*] Use `list([1])` instead of `list([1]) or ...` + --> SIM222.py:65:6 | 63 | a or [1] or True or [2] # SIM222 64 | 65 | a or list([1]) or True or list([2]) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | 67 | a or {} or True # SIM222 | - = help: Replace with `list([1])` +help: Replace with `list([1])` ℹ Unsafe fix 62 62 | @@ -324,16 +340,17 @@ SIM222.py:65:6: SIM222 [*] Use `list([1])` instead of `list([1]) or ...` 67 67 | a or {} or True # SIM222 68 68 | -SIM222.py:67:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:67:6 | 65 | a or list([1]) or True or list([2]) # SIM222 66 | 67 | a or {} or True # SIM222 - | ^^^^^^^^^^ SIM222 + | ^^^^^^^^^^ 68 | 69 | a or dict() or True # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 64 64 | @@ -345,16 +362,17 @@ SIM222.py:67:6: SIM222 [*] Use `True` instead of `... or True` 69 69 | a or dict() or True # SIM222 70 70 | -SIM222.py:69:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:69:6 | 67 | a or {} or True # SIM222 68 | 69 | a or dict() or True # SIM222 - | ^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^ 70 | 71 | a or {1: 1} or True or {2: 2} # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 66 66 | @@ -366,16 +384,17 @@ SIM222.py:69:6: SIM222 [*] Use `True` instead of `... or True` 71 71 | a or {1: 1} or True or {2: 2} # SIM222 72 72 | -SIM222.py:71:6: SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` +SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` + --> SIM222.py:71:6 | 69 | a or dict() or True # SIM222 70 | 71 | a or {1: 1} or True or {2: 2} # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 | - = help: Replace with `{1: 1}` +help: Replace with `{1: 1}` ℹ Unsafe fix 68 68 | @@ -387,16 +406,17 @@ SIM222.py:71:6: SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` 73 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 74 74 | -SIM222.py:73:6: SIM222 [*] Use `dict({1: 1})` instead of `dict({1: 1}) or ...` +SIM222 [*] Use `dict({1: 1})` instead of `dict({1: 1}) or ...` + --> SIM222.py:73:6 | 71 | a or {1: 1} or True or {2: 2} # SIM222 72 | 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 74 | 75 | a or set() or True # SIM222 | - = help: Replace with `dict({1: 1})` +help: Replace with `dict({1: 1})` ℹ Unsafe fix 70 70 | @@ -408,16 +428,17 @@ SIM222.py:73:6: SIM222 [*] Use `dict({1: 1})` instead of `dict({1: 1}) or ...` 75 75 | a or set() or True # SIM222 76 76 | -SIM222.py:75:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:75:6 | 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 74 | 75 | a or set() or True # SIM222 - | ^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^ 76 | 77 | a or set(set()) or True # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 72 72 | @@ -429,16 +450,17 @@ SIM222.py:75:6: SIM222 [*] Use `True` instead of `... or True` 77 77 | a or set(set()) or True # SIM222 78 78 | -SIM222.py:77:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:77:6 | 75 | a or set() or True # SIM222 76 | 77 | a or set(set()) or True # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^ 78 | 79 | a or {1} or True or {2} # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 74 74 | @@ -450,16 +472,17 @@ SIM222.py:77:6: SIM222 [*] Use `True` instead of `... or True` 79 79 | a or {1} or True or {2} # SIM222 80 80 | -SIM222.py:79:6: SIM222 [*] Use `{1}` instead of `{1} or ...` +SIM222 [*] Use `{1}` instead of `{1} or ...` + --> SIM222.py:79:6 | 77 | a or set(set()) or True # SIM222 78 | 79 | a or {1} or True or {2} # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^ 80 | 81 | a or set({1}) or True or set({2}) # SIM222 | - = help: Replace with `{1}` +help: Replace with `{1}` ℹ Unsafe fix 76 76 | @@ -471,16 +494,17 @@ SIM222.py:79:6: SIM222 [*] Use `{1}` instead of `{1} or ...` 81 81 | a or set({1}) or True or set({2}) # SIM222 82 82 | -SIM222.py:81:6: SIM222 [*] Use `set({1})` instead of `set({1}) or ...` +SIM222 [*] Use `set({1})` instead of `set({1}) or ...` + --> SIM222.py:81:6 | 79 | a or {1} or True or {2} # SIM222 80 | 81 | a or set({1}) or True or set({2}) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 82 | 83 | a or () or True # SIM222 | - = help: Replace with `set({1})` +help: Replace with `set({1})` ℹ Unsafe fix 78 78 | @@ -492,16 +516,17 @@ SIM222.py:81:6: SIM222 [*] Use `set({1})` instead of `set({1}) or ...` 83 83 | a or () or True # SIM222 84 84 | -SIM222.py:83:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:83:6 | 81 | a or set({1}) or True or set({2}) # SIM222 82 | 83 | a or () or True # SIM222 - | ^^^^^^^^^^ SIM222 + | ^^^^^^^^^^ 84 | 85 | a or tuple(()) or True # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 80 80 | @@ -513,16 +538,17 @@ SIM222.py:83:6: SIM222 [*] Use `True` instead of `... or True` 85 85 | a or tuple(()) or True # SIM222 86 86 | -SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:85:6 | 83 | a or () or True # SIM222 84 | 85 | a or tuple(()) or True # SIM222 - | ^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^ 86 | 87 | a or (1,) or True or (2,) # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 82 82 | @@ -534,16 +560,17 @@ SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` 87 87 | a or (1,) or True or (2,) # SIM222 88 88 | -SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` +SIM222 [*] Use `(1,)` instead of `(1,) or ...` + --> SIM222.py:87:6 | 85 | a or tuple(()) or True # SIM222 86 | 87 | a or (1,) or True or (2,) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^ 88 | 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 | - = help: Replace with `(1,)` +help: Replace with `(1,)` ℹ Unsafe fix 84 84 | @@ -555,16 +582,17 @@ SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` 89 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 90 90 | -SIM222.py:89:6: SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` +SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` + --> SIM222.py:89:6 | 87 | a or (1,) or True or (2,) # SIM222 88 | 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | 91 | a or frozenset() or True # SIM222 | - = help: Replace with `tuple((1,))` +help: Replace with `tuple((1,))` ℹ Unsafe fix 86 86 | @@ -576,16 +604,17 @@ SIM222.py:89:6: SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` 91 91 | a or frozenset() or True # SIM222 92 92 | -SIM222.py:91:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:91:6 | 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 90 | 91 | a or frozenset() or True # SIM222 - | ^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^ 92 | 93 | a or frozenset(frozenset()) or True # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 88 88 | @@ -597,16 +626,17 @@ SIM222.py:91:6: SIM222 [*] Use `True` instead of `... or True` 93 93 | a or frozenset(frozenset()) or True # SIM222 94 94 | -SIM222.py:93:6: SIM222 [*] Use `True` instead of `... or True` +SIM222 [*] Use `True` instead of `... or True` + --> SIM222.py:93:6 | 91 | a or frozenset() or True # SIM222 92 | 93 | a or frozenset(frozenset()) or True # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 94 | 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 90 90 | @@ -618,16 +648,17 @@ SIM222.py:93:6: SIM222 [*] Use `True` instead of `... or True` 95 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 96 96 | -SIM222.py:95:6: SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or ...` +SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or ...` + --> SIM222.py:95:6 | 93 | a or frozenset(frozenset()) or True # SIM222 94 | 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 96 | 97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 | - = help: Replace with `frozenset({1})` +help: Replace with `frozenset({1})` ℹ Unsafe fix 92 92 | @@ -639,14 +670,15 @@ SIM222.py:95:6: SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or .. 97 97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 98 98 | -SIM222.py:97:6: SIM222 [*] Use `frozenset(frozenset({1}))` instead of `frozenset(frozenset({1})) or ...` +SIM222 [*] Use `frozenset(frozenset({1}))` instead of `frozenset(frozenset({1})) or ...` + --> SIM222.py:97:6 | 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 96 | 97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `frozenset(frozenset({1}))` +help: Replace with `frozenset(frozenset({1}))` ℹ Unsafe fix 94 94 | @@ -658,16 +690,17 @@ SIM222.py:97:6: SIM222 [*] Use `frozenset(frozenset({1}))` instead of `frozenset 99 99 | 100 100 | # Inside test `a` is simplified. -SIM222.py:102:6: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:102:6 | 100 | # Inside test `a` is simplified. 101 | 102 | bool(a or [1] or True or [2]) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 103 | 104 | assert a or [1] or True or [2] # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 99 99 | @@ -679,16 +712,17 @@ SIM222.py:102:6: SIM222 [*] Use `True` instead of `... or True or ...` 104 104 | assert a or [1] or True or [2] # SIM222 105 105 | -SIM222.py:104:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:104:8 | 102 | bool(a or [1] or True or [2]) # SIM222 103 | 104 | assert a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 105 | 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 101 101 | @@ -700,15 +734,16 @@ SIM222.py:104:8: SIM222 [*] Use `True` instead of `... or True or ...` 106 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 107 107 | pass -SIM222.py:106:5: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:106:5 | 104 | assert a or [1] or True or [2] # SIM222 105 | 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 107 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 103 103 | @@ -720,15 +755,16 @@ SIM222.py:106:5: SIM222 [*] Use `True` instead of `... or True or ...` 108 108 | 109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 -SIM222.py:106:35: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:106:35 | 104 | assert a or [1] or True or [2] # SIM222 105 | 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 107 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 103 103 | @@ -740,16 +776,17 @@ SIM222.py:106:35: SIM222 [*] Use `True` instead of `... or True or ...` 108 108 | 109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 -SIM222.py:109:6: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:109:6 | 107 | pass 108 | 109 | 0 if a or [1] or True or [2] else 1 # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 110 | 111 | while a or [1] or True or [2]: # SIM222 | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 106 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 @@ -761,15 +798,16 @@ SIM222.py:109:6: SIM222 [*] Use `True` instead of `... or True or ...` 111 111 | while a or [1] or True or [2]: # SIM222 112 112 | pass -SIM222.py:111:7: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:111:7 | 109 | 0 if a or [1] or True or [2] else 1 # SIM222 110 | 111 | while a or [1] or True or [2]: # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 112 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 108 108 | @@ -781,16 +819,17 @@ SIM222.py:111:7: SIM222 [*] Use `True` instead of `... or True or ...` 113 113 | 114 114 | [ -SIM222.py:118:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:118:8 | 116 | for a in range(10) 117 | for b in range(10) 118 | if a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 119 | if b or [1] or True or [2] # SIM222 120 | ] | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 115 115 | 0 @@ -802,15 +841,16 @@ SIM222.py:118:8: SIM222 [*] Use `True` instead of `... or True or ...` 120 120 | ] 121 121 | -SIM222.py:119:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:119:8 | 117 | for b in range(10) 118 | if a or [1] or True or [2] # SIM222 119 | if b or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 120 | ] | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 116 116 | for a in range(10) @@ -822,16 +862,17 @@ SIM222.py:119:8: SIM222 [*] Use `True` instead of `... or True or ...` 121 121 | 122 122 | { -SIM222.py:126:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:126:8 | 124 | for a in range(10) 125 | for b in range(10) 126 | if a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 127 | if b or [1] or True or [2] # SIM222 128 | } | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 123 123 | 0 @@ -843,15 +884,16 @@ SIM222.py:126:8: SIM222 [*] Use `True` instead of `... or True or ...` 128 128 | } 129 129 | -SIM222.py:127:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:127:8 | 125 | for b in range(10) 126 | if a or [1] or True or [2] # SIM222 127 | if b or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 128 | } | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 124 124 | for a in range(10) @@ -863,16 +905,17 @@ SIM222.py:127:8: SIM222 [*] Use `True` instead of `... or True or ...` 129 129 | 130 130 | { -SIM222.py:134:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:134:8 | 132 | for a in range(10) 133 | for b in range(10) 134 | if a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 135 | if b or [1] or True or [2] # SIM222 136 | } | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 131 131 | 0: 0 @@ -884,15 +927,16 @@ SIM222.py:134:8: SIM222 [*] Use `True` instead of `... or True or ...` 136 136 | } 137 137 | -SIM222.py:135:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:135:8 | 133 | for b in range(10) 134 | if a or [1] or True or [2] # SIM222 135 | if b or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 136 | } | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 132 132 | for a in range(10) @@ -904,16 +948,17 @@ SIM222.py:135:8: SIM222 [*] Use `True` instead of `... or True or ...` 137 137 | 138 138 | ( -SIM222.py:142:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:142:8 | 140 | for a in range(10) 141 | for b in range(10) 142 | if a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 143 | if b or [1] or True or [2] # SIM222 144 | ) | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 139 139 | 0 @@ -925,15 +970,16 @@ SIM222.py:142:8: SIM222 [*] Use `True` instead of `... or True or ...` 144 144 | ) 145 145 | -SIM222.py:143:8: SIM222 [*] Use `True` instead of `... or True or ...` +SIM222 [*] Use `True` instead of `... or True or ...` + --> SIM222.py:143:8 | 141 | for b in range(10) 142 | if a or [1] or True or [2] # SIM222 143 | if b or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ 144 | ) | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 140 140 | for a in range(10) @@ -945,16 +991,17 @@ SIM222.py:143:8: SIM222 [*] Use `True` instead of `... or True or ...` 145 145 | 146 146 | # Outside test `a` is not simplified. -SIM222.py:148:6: SIM222 [*] Use `[1]` instead of `[1] or ...` +SIM222 [*] Use `[1]` instead of `[1] or ...` + --> SIM222.py:148:6 | 146 | # Outside test `a` is not simplified. 147 | 148 | a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^ 149 | 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 | - = help: Replace with `[1]` +help: Replace with `[1]` ℹ Unsafe fix 145 145 | @@ -966,15 +1013,16 @@ SIM222.py:148:6: SIM222 [*] Use `[1]` instead of `[1] or ...` 150 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 151 151 | pass -SIM222.py:150:10: SIM222 [*] Use `[1]` instead of `[1] or ...` +SIM222 [*] Use `[1]` instead of `[1] or ...` + --> SIM222.py:150:10 | 148 | a or [1] or True or [2] # SIM222 149 | 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^ 151 | pass | - = help: Replace with `[1]` +help: Replace with `[1]` ℹ Unsafe fix 147 147 | @@ -986,15 +1034,16 @@ SIM222.py:150:10: SIM222 [*] Use `[1]` instead of `[1] or ...` 152 152 | 153 153 | if f(a or [1] or True or [2]): # SIM222 -SIM222.py:153:11: SIM222 [*] Use `[1]` instead of `[1] or ...` +SIM222 [*] Use `[1]` instead of `[1] or ...` + --> SIM222.py:153:11 | 151 | pass 152 | 153 | if f(a or [1] or True or [2]): # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^ 154 | pass | - = help: Replace with `[1]` +help: Replace with `[1]` ℹ Unsafe fix 150 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 @@ -1006,14 +1055,15 @@ SIM222.py:153:11: SIM222 [*] Use `[1]` instead of `[1] or ...` 155 155 | 156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 -SIM222.py:157:30: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` +SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` + --> SIM222.py:157:30 | 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 157 | def secondToTime(s0: int) -> (int, int, int) or str: - | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^ 158 | m, s = divmod(s0, 60) | - = help: Replace with `(int, int, int)` +help: Replace with `(int, int, int)` ℹ Unsafe fix 154 154 | pass @@ -1025,13 +1075,14 @@ SIM222.py:157:30: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) o 159 159 | 160 160 | -SIM222.py:161:31: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` +SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` + --> SIM222.py:161:31 | 161 | def secondToTime(s0: int) -> ((int, int, int) or str): - | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^ 162 | m, s = divmod(s0, 60) | - = help: Replace with `(int, int, int)` +help: Replace with `(int, int, int)` ℹ Unsafe fix 158 158 | m, s = divmod(s0, 60) @@ -1043,15 +1094,16 @@ SIM222.py:161:31: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) o 163 163 | 164 164 | -SIM222.py:168:7: SIM222 [*] Use `"bar"` instead of `... or "bar"` +SIM222 [*] Use `"bar"` instead of `... or "bar"` + --> SIM222.py:168:7 | 166 | print(f"{a}{b}" or "bar") 167 | print(f"{a}{''}" or "bar") 168 | print(f"{''}{''}" or "bar") - | ^^^^^^^^^^^^^^^^^^^^ SIM222 + | ^^^^^^^^^^^^^^^^^^^^ 169 | print(f"{1}{''}" or "bar") | - = help: Replace with `"bar"` +help: Replace with `"bar"` ℹ Unsafe fix 165 165 | # Regression test for: https://github.com/astral-sh/ruff/issues/9479 diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap index 50e31f645c..c95fe3335a 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM223.py:1:4: SIM223 [*] Use `False` instead of `... and False` +SIM223 [*] Use `False` instead of `... and False` + --> SIM223.py:1:4 | 1 | if a and False: # SIM223 - | ^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^ 2 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 1 |-if a and False: # SIM223 @@ -16,15 +17,16 @@ SIM223.py:1:4: SIM223 [*] Use `False` instead of `... and False` 3 3 | 4 4 | if (a or b) and False: # SIM223 -SIM223.py:4:4: SIM223 [*] Use `False` instead of `... and False` +SIM223 [*] Use `False` instead of `... and False` + --> SIM223.py:4:4 | 2 | pass 3 | 4 | if (a or b) and False: # SIM223 - | ^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^ 5 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 1 1 | if a and False: # SIM223 @@ -36,15 +38,16 @@ SIM223.py:4:4: SIM223 [*] Use `False` instead of `... and False` 6 6 | 7 7 | if a or (b and False): # SIM223 -SIM223.py:7:10: SIM223 [*] Use `False` instead of `... and False` +SIM223 [*] Use `False` instead of `... and False` + --> SIM223.py:7:10 | 5 | pass 6 | 7 | if a or (b and False): # SIM223 - | ^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^ 8 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 4 4 | if (a or b) and False: # SIM223 @@ -56,15 +59,16 @@ SIM223.py:7:10: SIM223 [*] Use `False` instead of `... and False` 9 9 | 10 10 | if a or False: -SIM223.py:19:18: SIM223 [*] Use `False` instead of `False and ...` +SIM223 [*] Use `False` instead of `False and ...` + --> SIM223.py:19:18 | 17 | pass 18 | 19 | if a and f() and False and g() and b: # SIM223 - | ^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^ 20 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 16 16 | if a and f() and b and g() and False: # OK @@ -76,15 +80,16 @@ SIM223.py:19:18: SIM223 [*] Use `False` instead of `False and ...` 21 21 | 22 22 | if False and f() and a and g() and b: # SIM223 -SIM223.py:22:4: SIM223 [*] Use `False` instead of `False and ...` +SIM223 [*] Use `False` instead of `False and ...` + --> SIM223.py:22:4 | 20 | pass 21 | 22 | if False and f() and a and g() and b: # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 19 19 | if a and f() and False and g() and b: # SIM223 @@ -96,15 +101,16 @@ SIM223.py:22:4: SIM223 [*] Use `False` instead of `False and ...` 24 24 | 25 25 | if a and False and f() and b and g(): # SIM223 -SIM223.py:25:4: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:25:4 | 23 | pass 24 | 25 | if a and False and f() and b and g(): # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 22 22 | if False and f() and a and g() and b: # SIM223 @@ -116,14 +122,15 @@ SIM223.py:25:4: SIM223 [*] Use `False` instead of `... and False and ...` 27 27 | 28 28 | -SIM223.py:42:7: SIM223 [*] Use `""` instead of `"" and ...` +SIM223 [*] Use `""` instead of `"" and ...` + --> SIM223.py:42:7 | 42 | a and "" and False # SIM223 - | ^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^ 43 | 44 | a and "foo" and False and "bar" # SIM223 | - = help: Replace with `""` +help: Replace with `""` ℹ Unsafe fix 39 39 | pass @@ -135,16 +142,17 @@ SIM223.py:42:7: SIM223 [*] Use `""` instead of `"" and ...` 44 44 | a and "foo" and False and "bar" # SIM223 45 45 | -SIM223.py:44:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:44:7 | 42 | a and "" and False # SIM223 43 | 44 | a and "foo" and False and "bar" # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | a and 0 and False # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 41 41 | @@ -156,16 +164,17 @@ SIM223.py:44:7: SIM223 [*] Use `False` instead of `... and False and ...` 46 46 | a and 0 and False # SIM223 47 47 | -SIM223.py:46:7: SIM223 [*] Use `0` instead of `0 and ...` +SIM223 [*] Use `0` instead of `0 and ...` + --> SIM223.py:46:7 | 44 | a and "foo" and False and "bar" # SIM223 45 | 46 | a and 0 and False # SIM223 - | ^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^ 47 | 48 | a and 1 and False and 2 # SIM223 | - = help: Replace with `0` +help: Replace with `0` ℹ Unsafe fix 43 43 | @@ -177,16 +186,17 @@ SIM223.py:46:7: SIM223 [*] Use `0` instead of `0 and ...` 48 48 | a and 1 and False and 2 # SIM223 49 49 | -SIM223.py:48:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:48:7 | 46 | a and 0 and False # SIM223 47 | 48 | a and 1 and False and 2 # SIM223 - | ^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^ 49 | 50 | a and 0.0 and False # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 45 45 | @@ -198,16 +208,17 @@ SIM223.py:48:7: SIM223 [*] Use `False` instead of `... and False and ...` 50 50 | a and 0.0 and False # SIM223 51 51 | -SIM223.py:50:7: SIM223 [*] Use `0.0` instead of `0.0 and ...` +SIM223 [*] Use `0.0` instead of `0.0 and ...` + --> SIM223.py:50:7 | 48 | a and 1 and False and 2 # SIM223 49 | 50 | a and 0.0 and False # SIM223 - | ^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^ 51 | 52 | a and 0.1 and False and 0.2 # SIM223 | - = help: Replace with `0.0` +help: Replace with `0.0` ℹ Unsafe fix 47 47 | @@ -219,16 +230,17 @@ SIM223.py:50:7: SIM223 [*] Use `0.0` instead of `0.0 and ...` 52 52 | a and 0.1 and False and 0.2 # SIM223 53 53 | -SIM223.py:52:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:52:7 | 50 | a and 0.0 and False # SIM223 51 | 52 | a and 0.1 and False and 0.2 # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^ 53 | 54 | a and [] and False # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 49 49 | @@ -240,16 +252,17 @@ SIM223.py:52:7: SIM223 [*] Use `False` instead of `... and False and ...` 54 54 | a and [] and False # SIM223 55 55 | -SIM223.py:54:7: SIM223 [*] Use `[]` instead of `[] and ...` +SIM223 [*] Use `[]` instead of `[] and ...` + --> SIM223.py:54:7 | 52 | a and 0.1 and False and 0.2 # SIM223 53 | 54 | a and [] and False # SIM223 - | ^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^ 55 | 56 | a and list([]) and False # SIM223 | - = help: Replace with `[]` +help: Replace with `[]` ℹ Unsafe fix 51 51 | @@ -261,16 +274,17 @@ SIM223.py:54:7: SIM223 [*] Use `[]` instead of `[] and ...` 56 56 | a and list([]) and False # SIM223 57 57 | -SIM223.py:56:7: SIM223 [*] Use `list([])` instead of `list([]) and ...` +SIM223 [*] Use `list([])` instead of `list([]) and ...` + --> SIM223.py:56:7 | 54 | a and [] and False # SIM223 55 | 56 | a and list([]) and False # SIM223 - | ^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^ 57 | 58 | a and [1] and False and [2] # SIM223 | - = help: Replace with `list([])` +help: Replace with `list([])` ℹ Unsafe fix 53 53 | @@ -282,16 +296,17 @@ SIM223.py:56:7: SIM223 [*] Use `list([])` instead of `list([]) and ...` 58 58 | a and [1] and False and [2] # SIM223 59 59 | -SIM223.py:58:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:58:7 | 56 | a and list([]) and False # SIM223 57 | 58 | a and [1] and False and [2] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^ 59 | 60 | a and list([1]) and False and list([2]) # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 55 55 | @@ -303,16 +318,17 @@ SIM223.py:58:7: SIM223 [*] Use `False` instead of `... and False and ...` 60 60 | a and list([1]) and False and list([2]) # SIM223 61 61 | -SIM223.py:60:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:60:7 | 58 | a and [1] and False and [2] # SIM223 59 | 60 | a and list([1]) and False and list([2]) # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | a and {} and False # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 57 57 | @@ -324,16 +340,17 @@ SIM223.py:60:7: SIM223 [*] Use `False` instead of `... and False and ...` 62 62 | a and {} and False # SIM223 63 63 | -SIM223.py:62:7: SIM223 [*] Use `{}` instead of `{} and ...` +SIM223 [*] Use `{}` instead of `{} and ...` + --> SIM223.py:62:7 | 60 | a and list([1]) and False and list([2]) # SIM223 61 | 62 | a and {} and False # SIM223 - | ^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^ 63 | 64 | a and dict() and False # SIM223 | - = help: Replace with `{}` +help: Replace with `{}` ℹ Unsafe fix 59 59 | @@ -345,16 +362,17 @@ SIM223.py:62:7: SIM223 [*] Use `{}` instead of `{} and ...` 64 64 | a and dict() and False # SIM223 65 65 | -SIM223.py:64:7: SIM223 [*] Use `dict()` instead of `dict() and ...` +SIM223 [*] Use `dict()` instead of `dict() and ...` + --> SIM223.py:64:7 | 62 | a and {} and False # SIM223 63 | 64 | a and dict() and False # SIM223 - | ^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^ 65 | 66 | a and {1: 1} and False and {2: 2} # SIM223 | - = help: Replace with `dict()` +help: Replace with `dict()` ℹ Unsafe fix 61 61 | @@ -366,16 +384,17 @@ SIM223.py:64:7: SIM223 [*] Use `dict()` instead of `dict() and ...` 66 66 | a and {1: 1} and False and {2: 2} # SIM223 67 67 | -SIM223.py:66:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:66:7 | 64 | a and dict() and False # SIM223 65 | 66 | a and {1: 1} and False and {2: 2} # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 | 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 63 63 | @@ -387,16 +406,17 @@ SIM223.py:66:7: SIM223 [*] Use `False` instead of `... and False and ...` 68 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 69 69 | -SIM223.py:68:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:68:7 | 66 | a and {1: 1} and False and {2: 2} # SIM223 67 | 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 69 | 70 | a and set() and False # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 65 65 | @@ -408,16 +428,17 @@ SIM223.py:68:7: SIM223 [*] Use `False` instead of `... and False and ...` 70 70 | a and set() and False # SIM223 71 71 | -SIM223.py:70:7: SIM223 [*] Use `set()` instead of `set() and ...` +SIM223 [*] Use `set()` instead of `set() and ...` + --> SIM223.py:70:7 | 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 69 | 70 | a and set() and False # SIM223 - | ^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^ 71 | 72 | a and set(set()) and False # SIM223 | - = help: Replace with `set()` +help: Replace with `set()` ℹ Unsafe fix 67 67 | @@ -429,16 +450,17 @@ SIM223.py:70:7: SIM223 [*] Use `set()` instead of `set() and ...` 72 72 | a and set(set()) and False # SIM223 73 73 | -SIM223.py:72:7: SIM223 [*] Use `set(set())` instead of `set(set()) and ...` +SIM223 [*] Use `set(set())` instead of `set(set()) and ...` + --> SIM223.py:72:7 | 70 | a and set() and False # SIM223 71 | 72 | a and set(set()) and False # SIM223 - | ^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^ 73 | 74 | a and {1} and False and {2} # SIM223 | - = help: Replace with `set(set())` +help: Replace with `set(set())` ℹ Unsafe fix 69 69 | @@ -450,16 +472,17 @@ SIM223.py:72:7: SIM223 [*] Use `set(set())` instead of `set(set()) and ...` 74 74 | a and {1} and False and {2} # SIM223 75 75 | -SIM223.py:74:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:74:7 | 72 | a and set(set()) and False # SIM223 73 | 74 | a and {1} and False and {2} # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^ 75 | 76 | a and set({1}) and False and set({2}) # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 71 71 | @@ -471,16 +494,17 @@ SIM223.py:74:7: SIM223 [*] Use `False` instead of `... and False and ...` 76 76 | a and set({1}) and False and set({2}) # SIM223 77 77 | -SIM223.py:76:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:76:7 | 74 | a and {1} and False and {2} # SIM223 75 | 76 | a and set({1}) and False and set({2}) # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 77 | 78 | a and () and False # SIM222 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 73 73 | @@ -492,16 +516,17 @@ SIM223.py:76:7: SIM223 [*] Use `False` instead of `... and False and ...` 78 78 | a and () and False # SIM222 79 79 | -SIM223.py:78:7: SIM223 [*] Use `()` instead of `() and ...` +SIM223 [*] Use `()` instead of `() and ...` + --> SIM223.py:78:7 | 76 | a and set({1}) and False and set({2}) # SIM223 77 | 78 | a and () and False # SIM222 - | ^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^ 79 | 80 | a and tuple(()) and False # SIM222 | - = help: Replace with `()` +help: Replace with `()` ℹ Unsafe fix 75 75 | @@ -513,16 +538,17 @@ SIM223.py:78:7: SIM223 [*] Use `()` instead of `() and ...` 80 80 | a and tuple(()) and False # SIM222 81 81 | -SIM223.py:80:7: SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` +SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` + --> SIM223.py:80:7 | 78 | a and () and False # SIM222 79 | 80 | a and tuple(()) and False # SIM222 - | ^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^ 81 | 82 | a and (1,) and False and (2,) # SIM222 | - = help: Replace with `tuple(())` +help: Replace with `tuple(())` ℹ Unsafe fix 77 77 | @@ -534,16 +560,17 @@ SIM223.py:80:7: SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` 82 82 | a and (1,) and False and (2,) # SIM222 83 83 | -SIM223.py:82:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:82:7 | 80 | a and tuple(()) and False # SIM222 81 | 82 | a and (1,) and False and (2,) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^ 83 | 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 79 79 | @@ -555,16 +582,17 @@ SIM223.py:82:7: SIM223 [*] Use `False` instead of `... and False and ...` 84 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 85 85 | -SIM223.py:84:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:84:7 | 82 | a and (1,) and False and (2,) # SIM222 83 | 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 85 | 86 | a and frozenset() and False # SIM222 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 81 81 | @@ -576,16 +604,17 @@ SIM223.py:84:7: SIM223 [*] Use `False` instead of `... and False and ...` 86 86 | a and frozenset() and False # SIM222 87 87 | -SIM223.py:86:7: SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` +SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` + --> SIM223.py:86:7 | 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 85 | 86 | a and frozenset() and False # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^ 87 | 88 | a and frozenset(frozenset()) and False # SIM222 | - = help: Replace with `frozenset()` +help: Replace with `frozenset()` ℹ Unsafe fix 83 83 | @@ -597,16 +626,17 @@ SIM223.py:86:7: SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` 88 88 | a and frozenset(frozenset()) and False # SIM222 89 89 | -SIM223.py:88:7: SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(frozenset()) and ...` +SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(frozenset()) and ...` + --> SIM223.py:88:7 | 86 | a and frozenset() and False # SIM222 87 | 88 | a and frozenset(frozenset()) and False # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 89 | 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 | - = help: Replace with `frozenset(frozenset())` +help: Replace with `frozenset(frozenset())` ℹ Unsafe fix 85 85 | @@ -618,16 +648,17 @@ SIM223.py:88:7: SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(fr 90 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 91 91 | -SIM223.py:90:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:90:7 | 88 | a and frozenset(frozenset()) and False # SIM222 89 | 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 91 | 92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 87 87 | @@ -639,14 +670,15 @@ SIM223.py:90:7: SIM223 [*] Use `False` instead of `... and False and ...` 92 92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 93 93 | -SIM223.py:92:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:92:7 | 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 91 | 92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 89 89 | @@ -658,16 +690,17 @@ SIM223.py:92:7: SIM223 [*] Use `False` instead of `... and False and ...` 94 94 | 95 95 | # Inside test `a` is simplified. -SIM223.py:97:6: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:97:6 | 95 | # Inside test `a` is simplified. 96 | 97 | bool(a and [] and False and []) # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 98 | 99 | assert a and [] and False and [] # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 94 94 | @@ -679,16 +712,17 @@ SIM223.py:97:6: SIM223 [*] Use `False` instead of `... and False and ...` 99 99 | assert a and [] and False and [] # SIM223 100 100 | -SIM223.py:99:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:99:8 | 97 | bool(a and [] and False and []) # SIM223 98 | 99 | assert a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 100 | 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 96 96 | @@ -700,15 +734,16 @@ SIM223.py:99:8: SIM223 [*] Use `False` instead of `... and False and ...` 101 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 102 102 | pass -SIM223.py:101:5: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:101:5 | 99 | assert a and [] and False and [] # SIM223 100 | 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 102 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 98 98 | @@ -720,15 +755,16 @@ SIM223.py:101:5: SIM223 [*] Use `False` instead of `... and False and ...` 103 103 | 104 104 | 0 if a and [] and False and [] else 1 # SIM222 -SIM223.py:101:36: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:101:36 | 99 | assert a and [] and False and [] # SIM223 100 | 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 102 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 98 98 | @@ -740,16 +776,17 @@ SIM223.py:101:36: SIM223 [*] Use `False` instead of `... and False and ...` 103 103 | 104 104 | 0 if a and [] and False and [] else 1 # SIM222 -SIM223.py:104:6: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:104:6 | 102 | pass 103 | 104 | 0 if a and [] and False and [] else 1 # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 105 | 106 | while a and [] and False and []: # SIM223 | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 101 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 @@ -761,15 +798,16 @@ SIM223.py:104:6: SIM223 [*] Use `False` instead of `... and False and ...` 106 106 | while a and [] and False and []: # SIM223 107 107 | pass -SIM223.py:106:7: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:106:7 | 104 | 0 if a and [] and False and [] else 1 # SIM222 105 | 106 | while a and [] and False and []: # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 107 | pass | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 103 103 | @@ -781,16 +819,17 @@ SIM223.py:106:7: SIM223 [*] Use `False` instead of `... and False and ...` 108 108 | 109 109 | [ -SIM223.py:113:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:113:8 | 111 | for a in range(10) 112 | for b in range(10) 113 | if a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 114 | if b and [] and False and [] # SIM223 115 | ] | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 110 110 | 0 @@ -802,15 +841,16 @@ SIM223.py:113:8: SIM223 [*] Use `False` instead of `... and False and ...` 115 115 | ] 116 116 | -SIM223.py:114:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:114:8 | 112 | for b in range(10) 113 | if a and [] and False and [] # SIM223 114 | if b and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 115 | ] | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 111 111 | for a in range(10) @@ -822,16 +862,17 @@ SIM223.py:114:8: SIM223 [*] Use `False` instead of `... and False and ...` 116 116 | 117 117 | { -SIM223.py:121:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:121:8 | 119 | for a in range(10) 120 | for b in range(10) 121 | if a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 122 | if b and [] and False and [] # SIM223 123 | } | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 118 118 | 0 @@ -843,15 +884,16 @@ SIM223.py:121:8: SIM223 [*] Use `False` instead of `... and False and ...` 123 123 | } 124 124 | -SIM223.py:122:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:122:8 | 120 | for b in range(10) 121 | if a and [] and False and [] # SIM223 122 | if b and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 123 | } | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 119 119 | for a in range(10) @@ -863,16 +905,17 @@ SIM223.py:122:8: SIM223 [*] Use `False` instead of `... and False and ...` 124 124 | 125 125 | { -SIM223.py:129:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:129:8 | 127 | for a in range(10) 128 | for b in range(10) 129 | if a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 130 | if b and [] and False and [] # SIM223 131 | } | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 126 126 | 0: 0 @@ -884,15 +927,16 @@ SIM223.py:129:8: SIM223 [*] Use `False` instead of `... and False and ...` 131 131 | } 132 132 | -SIM223.py:130:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:130:8 | 128 | for b in range(10) 129 | if a and [] and False and [] # SIM223 130 | if b and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 131 | } | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 127 127 | for a in range(10) @@ -904,16 +948,17 @@ SIM223.py:130:8: SIM223 [*] Use `False` instead of `... and False and ...` 132 132 | 133 133 | ( -SIM223.py:137:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:137:8 | 135 | for a in range(10) 136 | for b in range(10) 137 | if a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 138 | if b and [] and False and [] # SIM223 139 | ) | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 134 134 | 0 @@ -925,15 +970,16 @@ SIM223.py:137:8: SIM223 [*] Use `False` instead of `... and False and ...` 139 139 | ) 140 140 | -SIM223.py:138:8: SIM223 [*] Use `False` instead of `... and False and ...` +SIM223 [*] Use `False` instead of `... and False and ...` + --> SIM223.py:138:8 | 136 | for b in range(10) 137 | if a and [] and False and [] # SIM223 138 | if b and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 139 | ) | - = help: Replace with `False` +help: Replace with `False` ℹ Unsafe fix 135 135 | for a in range(10) @@ -945,16 +991,17 @@ SIM223.py:138:8: SIM223 [*] Use `False` instead of `... and False and ...` 140 140 | 141 141 | # Outside test `a` is not simplified. -SIM223.py:143:7: SIM223 [*] Use `[]` instead of `[] and ...` +SIM223 [*] Use `[]` instead of `[] and ...` + --> SIM223.py:143:7 | 141 | # Outside test `a` is not simplified. 142 | 143 | a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^ 144 | 145 | if (a and [] and False and []) == (a and []): # SIM223 | - = help: Replace with `[]` +help: Replace with `[]` ℹ Unsafe fix 140 140 | @@ -966,15 +1013,16 @@ SIM223.py:143:7: SIM223 [*] Use `[]` instead of `[] and ...` 145 145 | if (a and [] and False and []) == (a and []): # SIM223 146 146 | pass -SIM223.py:145:11: SIM223 [*] Use `[]` instead of `[] and ...` +SIM223 [*] Use `[]` instead of `[] and ...` + --> SIM223.py:145:11 | 143 | a and [] and False and [] # SIM223 144 | 145 | if (a and [] and False and []) == (a and []): # SIM223 - | ^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^ 146 | pass | - = help: Replace with `[]` +help: Replace with `[]` ℹ Unsafe fix 142 142 | @@ -986,15 +1034,16 @@ SIM223.py:145:11: SIM223 [*] Use `[]` instead of `[] and ...` 147 147 | 148 148 | if f(a and [] and False and []): # SIM223 -SIM223.py:148:12: SIM223 [*] Use `[]` instead of `[] and ...` +SIM223 [*] Use `[]` instead of `[] and ...` + --> SIM223.py:148:12 | 146 | pass 147 | 148 | if f(a and [] and False and []): # SIM223 - | ^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^ 149 | pass | - = help: Replace with `[]` +help: Replace with `[]` ℹ Unsafe fix 145 145 | if (a and [] and False and []) == (a and []): # SIM223 @@ -1006,15 +1055,16 @@ SIM223.py:148:12: SIM223 [*] Use `[]` instead of `[] and ...` 150 150 | 151 151 | # Regression test for: https://github.com/astral-sh/ruff/issues/9479 -SIM223.py:154:7: SIM223 [*] Use `f"{''}{''}"` instead of `f"{''}{''}" and ...` +SIM223 [*] Use `f"{''}{''}"` instead of `f"{''}{''}" and ...` + --> SIM223.py:154:7 | 152 | print(f"{a}{b}" and "bar") 153 | print(f"{a}{''}" and "bar") 154 | print(f"{''}{''}" and "bar") - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 + | ^^^^^^^^^^^^^^^^^^^^^ 155 | print(f"{1}{''}" and "bar") | - = help: Replace with `f"{''}{''}"` +help: Replace with `f"{''}{''}"` ℹ Unsafe fix 151 151 | # Regression test for: https://github.com/astral-sh/ruff/issues/9479 diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap index 4782624224..8dc1a167be 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM300.py:2:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:2:1 | 1 | # Errors 2 | "yoda" == compare # SIM300 - | ^^^^^^^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^^^^^^^ 3 | 42 == age # SIM300 4 | ("a", "b") == compare # SIM300 | - = help: Rewrite as `compare == "yoda"` +help: Rewrite as `compare == "yoda"` ℹ Safe fix 1 1 | # Errors @@ -19,16 +20,17 @@ SIM300.py:2:1: SIM300 [*] Yoda condition detected 4 4 | ("a", "b") == compare # SIM300 5 5 | "yoda" <= compare # SIM300 -SIM300.py:3:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:3:1 | 1 | # Errors 2 | "yoda" == compare # SIM300 3 | 42 == age # SIM300 - | ^^^^^^^^^ SIM300 + | ^^^^^^^^^ 4 | ("a", "b") == compare # SIM300 5 | "yoda" <= compare # SIM300 | - = help: Rewrite as `age == 42` +help: Rewrite as `age == 42` ℹ Safe fix 1 1 | # Errors @@ -39,16 +41,17 @@ SIM300.py:3:1: SIM300 [*] Yoda condition detected 5 5 | "yoda" <= compare # SIM300 6 6 | "yoda" < compare # SIM300 -SIM300.py:4:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:4:1 | 2 | "yoda" == compare # SIM300 3 | 42 == age # SIM300 4 | ("a", "b") == compare # SIM300 - | ^^^^^^^^^^^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^^^^^^^^^^^ 5 | "yoda" <= compare # SIM300 6 | "yoda" < compare # SIM300 | - = help: Rewrite as `compare == ("a", "b")` +help: Rewrite as `compare == ("a", "b")` ℹ Safe fix 1 1 | # Errors @@ -60,16 +63,17 @@ SIM300.py:4:1: SIM300 [*] Yoda condition detected 6 6 | "yoda" < compare # SIM300 7 7 | 42 > age # SIM300 -SIM300.py:5:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:5:1 | 3 | 42 == age # SIM300 4 | ("a", "b") == compare # SIM300 5 | "yoda" <= compare # SIM300 - | ^^^^^^^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^^^^^^^ 6 | "yoda" < compare # SIM300 7 | 42 > age # SIM300 | - = help: Rewrite as `compare >= "yoda"` +help: Rewrite as `compare >= "yoda"` ℹ Safe fix 2 2 | "yoda" == compare # SIM300 @@ -81,16 +85,17 @@ SIM300.py:5:1: SIM300 [*] Yoda condition detected 7 7 | 42 > age # SIM300 8 8 | -42 > age # SIM300 -SIM300.py:6:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:6:1 | 4 | ("a", "b") == compare # SIM300 5 | "yoda" <= compare # SIM300 6 | "yoda" < compare # SIM300 - | ^^^^^^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^^^^^^ 7 | 42 > age # SIM300 8 | -42 > age # SIM300 | - = help: Rewrite as `compare > "yoda"` +help: Rewrite as `compare > "yoda"` ℹ Safe fix 3 3 | 42 == age # SIM300 @@ -102,16 +107,17 @@ SIM300.py:6:1: SIM300 [*] Yoda condition detected 8 8 | -42 > age # SIM300 9 9 | +42 > age # SIM300 -SIM300.py:7:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:7:1 | 5 | "yoda" <= compare # SIM300 6 | "yoda" < compare # SIM300 7 | 42 > age # SIM300 - | ^^^^^^^^ SIM300 + | ^^^^^^^^ 8 | -42 > age # SIM300 9 | +42 > age # SIM300 | - = help: Rewrite as `age < 42` +help: Rewrite as `age < 42` ℹ Safe fix 4 4 | ("a", "b") == compare # SIM300 @@ -123,16 +129,17 @@ SIM300.py:7:1: SIM300 [*] Yoda condition detected 9 9 | +42 > age # SIM300 10 10 | YODA == age # SIM300 -SIM300.py:8:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:8:1 | 6 | "yoda" < compare # SIM300 7 | 42 > age # SIM300 8 | -42 > age # SIM300 - | ^^^^^^^^^ SIM300 + | ^^^^^^^^^ 9 | +42 > age # SIM300 10 | YODA == age # SIM300 | - = help: Rewrite as `age < -42` +help: Rewrite as `age < -42` ℹ Safe fix 5 5 | "yoda" <= compare # SIM300 @@ -144,16 +151,17 @@ SIM300.py:8:1: SIM300 [*] Yoda condition detected 10 10 | YODA == age # SIM300 11 11 | YODA > age # SIM300 -SIM300.py:9:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:9:1 | 7 | 42 > age # SIM300 8 | -42 > age # SIM300 9 | +42 > age # SIM300 - | ^^^^^^^^^ SIM300 + | ^^^^^^^^^ 10 | YODA == age # SIM300 11 | YODA > age # SIM300 | - = help: Rewrite as `age < +42` +help: Rewrite as `age < +42` ℹ Safe fix 6 6 | "yoda" < compare # SIM300 @@ -165,16 +173,17 @@ SIM300.py:9:1: SIM300 [*] Yoda condition detected 11 11 | YODA > age # SIM300 12 12 | YODA >= age # SIM300 -SIM300.py:10:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:10:1 | 8 | -42 > age # SIM300 9 | +42 > age # SIM300 10 | YODA == age # SIM300 - | ^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^ 11 | YODA > age # SIM300 12 | YODA >= age # SIM300 | - = help: Rewrite as `age == YODA` +help: Rewrite as `age == YODA` ℹ Safe fix 7 7 | 42 > age # SIM300 @@ -186,16 +195,17 @@ SIM300.py:10:1: SIM300 [*] Yoda condition detected 12 12 | YODA >= age # SIM300 13 13 | JediOrder.YODA == age # SIM300 -SIM300.py:11:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:11:1 | 9 | +42 > age # SIM300 10 | YODA == age # SIM300 11 | YODA > age # SIM300 - | ^^^^^^^^^^ SIM300 + | ^^^^^^^^^^ 12 | YODA >= age # SIM300 13 | JediOrder.YODA == age # SIM300 | - = help: Rewrite as `age < YODA` +help: Rewrite as `age < YODA` ℹ Safe fix 8 8 | -42 > age # SIM300 @@ -207,16 +217,17 @@ SIM300.py:11:1: SIM300 [*] Yoda condition detected 13 13 | JediOrder.YODA == age # SIM300 14 14 | 0 < (number - 100) # SIM300 -SIM300.py:12:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:12:1 | 10 | YODA == age # SIM300 11 | YODA > age # SIM300 12 | YODA >= age # SIM300 - | ^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^ 13 | JediOrder.YODA == age # SIM300 14 | 0 < (number - 100) # SIM300 | - = help: Rewrite as `age <= YODA` +help: Rewrite as `age <= YODA` ℹ Safe fix 9 9 | +42 > age # SIM300 @@ -228,16 +239,17 @@ SIM300.py:12:1: SIM300 [*] Yoda condition detected 14 14 | 0 < (number - 100) # SIM300 15 15 | B SIM300.py:13:1 | 11 | YODA > age # SIM300 12 | YODA >= age # SIM300 13 | JediOrder.YODA == age # SIM300 - | ^^^^^^^^^^^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^^^^^^^^^^^ 14 | 0 < (number - 100) # SIM300 15 | B SIM300.py:14:1 | 12 | YODA >= age # SIM300 13 | JediOrder.YODA == age # SIM300 14 | 0 < (number - 100) # SIM300 - | ^^^^^^^^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^^^^^^^^ 15 | B 0` +help: Rewrite as `(number - 100) > 0` ℹ Safe fix 11 11 | YODA > age # SIM300 @@ -270,16 +283,17 @@ SIM300.py:14:1: SIM300 [*] Yoda condition detected 16 16 | B or(B) SIM300.py:15:1 | 13 | JediOrder.YODA == age # SIM300 14 | 0 < (number - 100) # SIM300 15 | B B` +help: Rewrite as `A[0][0] > B` ℹ Safe fix 12 12 | YODA >= age # SIM300 @@ -291,15 +305,16 @@ SIM300.py:15:1: SIM300 [*] Yoda condition detected 17 17 | {"non-empty-dict": "is-ok"} == DummyHandler.CONFIG 18 18 | -SIM300.py:16:5: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:16:5 | 14 | 0 < (number - 100) # SIM300 15 | B (B)` +help: Rewrite as `A[0][0] > (B)` ℹ Safe fix 13 13 | JediOrder.YODA == age # SIM300 @@ -311,16 +326,17 @@ SIM300.py:16:5: SIM300 [*] Yoda condition detected 18 18 | 19 19 | # Errors in preview -SIM300.py:17:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:17:1 | 15 | B SIM300.py:20:1 | 19 | # Errors in preview 20 | ['upper'] == UPPER_LIST - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^^^^^^^^^^^^^ 21 | {} == DummyHandler.CONFIG | - = help: Rewrite as `UPPER_LIST == ['upper']` +help: Rewrite as `UPPER_LIST == ['upper']` ℹ Safe fix 17 17 | {"non-empty-dict": "is-ok"} == DummyHandler.CONFIG @@ -351,16 +368,17 @@ SIM300.py:20:1: SIM300 [*] Yoda condition detected 22 22 | 23 23 | # Errors in stable -SIM300.py:21:1: SIM300 [*] Yoda condition detected +SIM300 [*] Yoda condition detected + --> SIM300.py:21:1 | 19 | # Errors in preview 20 | ['upper'] == UPPER_LIST 21 | {} == DummyHandler.CONFIG - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | # Errors in stable | - = help: Rewrite as `DummyHandler.CONFIG == {}` +help: Rewrite as `DummyHandler.CONFIG == {}` ℹ Safe fix 18 18 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap index a89ba6468d..36573493b8 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap @@ -1,18 +1,19 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM401.py:8:1: SIM401 [*] Use `var = a_dict.get(key, "default1")` instead of an `if` block +SIM401 [*] Use `var = a_dict.get(key, "default1")` instead of an `if` block + --> SIM401.py:8:1 | 7 | # SIM401 (pattern-1) 8 | / if key in a_dict: 9 | | var = a_dict[key] 10 | | else: 11 | | var = "default1" - | |____________________^ SIM401 + | |____________________^ 12 | 13 | # SIM401 (pattern-2) | - = help: Replace with `var = a_dict.get(key, "default1")` +help: Replace with `var = a_dict.get(key, "default1")` ℹ Unsafe fix 5 5 | a_dict = {} @@ -27,18 +28,19 @@ SIM401.py:8:1: SIM401 [*] Use `var = a_dict.get(key, "default1")` instead of an 13 10 | # SIM401 (pattern-2) 14 11 | if key not in a_dict: -SIM401.py:14:1: SIM401 [*] Use `var = a_dict.get(key, "default2")` instead of an `if` block +SIM401 [*] Use `var = a_dict.get(key, "default2")` instead of an `if` block + --> SIM401.py:14:1 | 13 | # SIM401 (pattern-2) 14 | / if key not in a_dict: 15 | | var = "default2" 16 | | else: 17 | | var = a_dict[key] - | |_____________________^ SIM401 + | |_____________________^ 18 | 19 | # OK (default contains effect) | - = help: Replace with `var = a_dict.get(key, "default2")` +help: Replace with `var = a_dict.get(key, "default2")` ℹ Unsafe fix 11 11 | var = "default1" @@ -53,18 +55,19 @@ SIM401.py:14:1: SIM401 [*] Use `var = a_dict.get(key, "default2")` instead of an 19 16 | # OK (default contains effect) 20 17 | if key in a_dict: -SIM401.py:26:1: SIM401 [*] Use `var = a_dict.get(keys[idx], "default")` instead of an `if` block +SIM401 [*] Use `var = a_dict.get(keys[idx], "default")` instead of an `if` block + --> SIM401.py:26:1 | 25 | # SIM401 (complex expression in key) 26 | / if keys[idx] in a_dict: 27 | | var = a_dict[keys[idx]] 28 | | else: 29 | | var = "default" - | |___________________^ SIM401 + | |___________________^ 30 | 31 | dicts = {"key": a_dict} | - = help: Replace with `var = a_dict.get(keys[idx], "default")` +help: Replace with `var = a_dict.get(keys[idx], "default")` ℹ Unsafe fix 23 23 | var = val1 + val2 @@ -79,18 +82,19 @@ SIM401.py:26:1: SIM401 [*] Use `var = a_dict.get(keys[idx], "default")` instead 31 28 | dicts = {"key": a_dict} 32 29 | -SIM401.py:40:1: SIM401 [*] Use `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789")` instead of an `if` block +SIM401 [*] Use `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789")` instead of an `if` block + --> SIM401.py:40:1 | 39 | # SIM401 (complex expression in var) 40 | / if key in a_dict: 41 | | vars[idx] = a_dict[key] 42 | | else: 43 | | vars[idx] = "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789" - | |___________________________________________________________________________^ SIM401 + | |___________________________________________________________________________^ 44 | 45 | # SIM401 | - = help: Replace with `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789")` +help: Replace with `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789")` ℹ Unsafe fix 37 37 | var = "default" @@ -105,7 +109,8 @@ SIM401.py:40:1: SIM401 [*] Use `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6 45 42 | # SIM401 46 43 | if foo(): -SIM401.py:49:5: SIM401 [*] Use `vars[idx] = a_dict.get(key, "default")` instead of an `if` block +SIM401 [*] Use `vars[idx] = a_dict.get(key, "default")` instead of an `if` block + --> SIM401.py:49:5 | 47 | pass 48 | else: @@ -113,11 +118,11 @@ SIM401.py:49:5: SIM401 [*] Use `vars[idx] = a_dict.get(key, "default")` instead 50 | | vars[idx] = a_dict[key] 51 | | else: 52 | | vars[idx] = "default" - | |_____________________________^ SIM401 + | |_____________________________^ 53 | 54 | ### | - = help: Replace with `vars[idx] = a_dict.get(key, "default")` +help: Replace with `vars[idx] = a_dict.get(key, "default")` ℹ Unsafe fix 46 46 | if foo(): @@ -132,15 +137,16 @@ SIM401.py:49:5: SIM401 [*] Use `vars[idx] = a_dict.get(key, "default")` instead 54 51 | ### 55 52 | # Negative cases -SIM401.py:149:7: SIM401 [*] Use `a_dict.get(key, "default3")` instead of an `if` block +SIM401 [*] Use `a_dict.get(key, "default3")` instead of an `if` block + --> SIM401.py:149:7 | 148 | # SIM401 149 | var = a_dict[key] if key in a_dict else "default3" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 150 | 151 | # SIM401 | - = help: Replace with `a_dict.get(key, "default3")` +help: Replace with `a_dict.get(key, "default3")` ℹ Unsafe fix 146 146 | ### @@ -152,15 +158,16 @@ SIM401.py:149:7: SIM401 [*] Use `a_dict.get(key, "default3")` instead of an `if` 151 151 | # SIM401 152 152 | var = "default-1" if key not in a_dict else a_dict[key] -SIM401.py:152:7: SIM401 [*] Use `a_dict.get(key, "default-1")` instead of an `if` block +SIM401 [*] Use `a_dict.get(key, "default-1")` instead of an `if` block + --> SIM401.py:152:7 | 151 | # SIM401 152 | var = "default-1" if key not in a_dict else a_dict[key] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 153 | 154 | # OK (default contains effect) | - = help: Replace with `a_dict.get(key, "default-1")` +help: Replace with `a_dict.get(key, "default-1")` ℹ Unsafe fix 149 149 | var = a_dict[key] if key in a_dict else "default3" diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap index 7f5b3f6456..66ef1e9c50 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM905_SIM905.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM905.py:6:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:6:1 | 5 | # positives 6 | / """ @@ -9,11 +10,11 @@ SIM905.py:6:1: SIM905 [*] Consider using a list literal instead of `str.split` 8 | | itemB 9 | | itemC 10 | | """.split() - | |___________^ SIM905 + | |___________^ 11 | 12 | "a,b,c,d".split(",") | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 3 3 | no_sep = None @@ -29,16 +30,17 @@ SIM905.py:6:1: SIM905 [*] Consider using a list literal instead of `str.split` 12 8 | "a,b,c,d".split(",") 13 9 | "a,b,c,d".split(None) -SIM905.py:12:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:12:1 | 10 | """.split() 11 | 12 | "a,b,c,d".split(",") - | ^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^ 13 | "a,b,c,d".split(None) 14 | "a,b,c,d".split(",", 1) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 9 9 | itemC @@ -50,15 +52,16 @@ SIM905.py:12:1: SIM905 [*] Consider using a list literal instead of `str.split` 14 14 | "a,b,c,d".split(",", 1) 15 15 | "a,b,c,d".split(None, 1) -SIM905.py:13:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:13:1 | 12 | "a,b,c,d".split(",") 13 | "a,b,c,d".split(None) - | ^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^ 14 | "a,b,c,d".split(",", 1) 15 | "a,b,c,d".split(None, 1) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 10 10 | """.split() @@ -70,16 +73,17 @@ SIM905.py:13:1: SIM905 [*] Consider using a list literal instead of `str.split` 15 15 | "a,b,c,d".split(None, 1) 16 16 | "a,b,c,d".split(sep=",") -SIM905.py:14:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:14:1 | 12 | "a,b,c,d".split(",") 13 | "a,b,c,d".split(None) 14 | "a,b,c,d".split(",", 1) - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^ 15 | "a,b,c,d".split(None, 1) 16 | "a,b,c,d".split(sep=",") | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 11 11 | @@ -91,27 +95,29 @@ SIM905.py:14:1: SIM905 [*] Consider using a list literal instead of `str.split` 16 16 | "a,b,c,d".split(sep=",") 17 17 | "a,b,c,d".split(sep=None) -SIM905.py:15:1: SIM905 Consider using a list literal instead of `str.split` +SIM905 Consider using a list literal instead of `str.split` + --> SIM905.py:15:1 | 13 | "a,b,c,d".split(None) 14 | "a,b,c,d".split(",", 1) 15 | "a,b,c,d".split(None, 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 16 | "a,b,c,d".split(sep=",") 17 | "a,b,c,d".split(sep=None) | - = help: Replace with list literal +help: Replace with list literal -SIM905.py:16:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:16:1 | 14 | "a,b,c,d".split(",", 1) 15 | "a,b,c,d".split(None, 1) 16 | "a,b,c,d".split(sep=",") - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 17 | "a,b,c,d".split(sep=None) 18 | "a,b,c,d".split(sep=",", maxsplit=1) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 13 13 | "a,b,c,d".split(None) @@ -123,16 +129,17 @@ SIM905.py:16:1: SIM905 [*] Consider using a list literal instead of `str.split` 18 18 | "a,b,c,d".split(sep=",", maxsplit=1) 19 19 | "a,b,c,d".split(sep=None, maxsplit=1) -SIM905.py:17:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:17:1 | 15 | "a,b,c,d".split(None, 1) 16 | "a,b,c,d".split(sep=",") 17 | "a,b,c,d".split(sep=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | "a,b,c,d".split(sep=",", maxsplit=1) 19 | "a,b,c,d".split(sep=None, maxsplit=1) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 14 14 | "a,b,c,d".split(",", 1) @@ -144,16 +151,17 @@ SIM905.py:17:1: SIM905 [*] Consider using a list literal instead of `str.split` 19 19 | "a,b,c,d".split(sep=None, maxsplit=1) 20 20 | "a,b,c,d".split(maxsplit=1, sep=",") -SIM905.py:18:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:18:1 | 16 | "a,b,c,d".split(sep=",") 17 | "a,b,c,d".split(sep=None) 18 | "a,b,c,d".split(sep=",", maxsplit=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | "a,b,c,d".split(sep=None, maxsplit=1) 20 | "a,b,c,d".split(maxsplit=1, sep=",") | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 15 15 | "a,b,c,d".split(None, 1) @@ -165,27 +173,29 @@ SIM905.py:18:1: SIM905 [*] Consider using a list literal instead of `str.split` 20 20 | "a,b,c,d".split(maxsplit=1, sep=",") 21 21 | "a,b,c,d".split(maxsplit=1, sep=None) -SIM905.py:19:1: SIM905 Consider using a list literal instead of `str.split` +SIM905 Consider using a list literal instead of `str.split` + --> SIM905.py:19:1 | 17 | "a,b,c,d".split(sep=None) 18 | "a,b,c,d".split(sep=",", maxsplit=1) 19 | "a,b,c,d".split(sep=None, maxsplit=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | "a,b,c,d".split(maxsplit=1, sep=",") 21 | "a,b,c,d".split(maxsplit=1, sep=None) | - = help: Replace with list literal +help: Replace with list literal -SIM905.py:20:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:20:1 | 18 | "a,b,c,d".split(sep=",", maxsplit=1) 19 | "a,b,c,d".split(sep=None, maxsplit=1) 20 | "a,b,c,d".split(maxsplit=1, sep=",") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | "a,b,c,d".split(maxsplit=1, sep=None) 22 | "a,b,c,d".split(",", maxsplit=1) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 17 17 | "a,b,c,d".split(sep=None) @@ -197,27 +207,29 @@ SIM905.py:20:1: SIM905 [*] Consider using a list literal instead of `str.split` 22 22 | "a,b,c,d".split(",", maxsplit=1) 23 23 | "a,b,c,d".split(None, maxsplit=1) -SIM905.py:21:1: SIM905 Consider using a list literal instead of `str.split` +SIM905 Consider using a list literal instead of `str.split` + --> SIM905.py:21:1 | 19 | "a,b,c,d".split(sep=None, maxsplit=1) 20 | "a,b,c,d".split(maxsplit=1, sep=",") 21 | "a,b,c,d".split(maxsplit=1, sep=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | "a,b,c,d".split(",", maxsplit=1) 23 | "a,b,c,d".split(None, maxsplit=1) | - = help: Replace with list literal +help: Replace with list literal -SIM905.py:22:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:22:1 | 20 | "a,b,c,d".split(maxsplit=1, sep=",") 21 | "a,b,c,d".split(maxsplit=1, sep=None) 22 | "a,b,c,d".split(",", maxsplit=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | "a,b,c,d".split(None, maxsplit=1) 24 | "a,b,c,d".split(maxsplit=1) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 19 19 | "a,b,c,d".split(sep=None, maxsplit=1) @@ -229,49 +241,53 @@ SIM905.py:22:1: SIM905 [*] Consider using a list literal instead of `str.split` 24 24 | "a,b,c,d".split(maxsplit=1) 25 25 | "a,b,c,d".split(maxsplit=1.0) -SIM905.py:23:1: SIM905 Consider using a list literal instead of `str.split` +SIM905 Consider using a list literal instead of `str.split` + --> SIM905.py:23:1 | 21 | "a,b,c,d".split(maxsplit=1, sep=None) 22 | "a,b,c,d".split(",", maxsplit=1) 23 | "a,b,c,d".split(None, maxsplit=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | "a,b,c,d".split(maxsplit=1) 25 | "a,b,c,d".split(maxsplit=1.0) | - = help: Replace with list literal +help: Replace with list literal -SIM905.py:24:1: SIM905 Consider using a list literal instead of `str.split` +SIM905 Consider using a list literal instead of `str.split` + --> SIM905.py:24:1 | 22 | "a,b,c,d".split(",", maxsplit=1) 23 | "a,b,c,d".split(None, maxsplit=1) 24 | "a,b,c,d".split(maxsplit=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | "a,b,c,d".split(maxsplit=1.0) 26 | "a,b,c,d".split(maxsplit=1) | - = help: Replace with list literal +help: Replace with list literal -SIM905.py:26:1: SIM905 Consider using a list literal instead of `str.split` +SIM905 Consider using a list literal instead of `str.split` + --> SIM905.py:26:1 | 24 | "a,b,c,d".split(maxsplit=1) 25 | "a,b,c,d".split(maxsplit=1.0) 26 | "a,b,c,d".split(maxsplit=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | "a,b,c,d".split(maxsplit=0) 28 | "VERB AUX PRON ADP DET".split(" ") | - = help: Replace with list literal +help: Replace with list literal -SIM905.py:27:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:27:1 | 25 | "a,b,c,d".split(maxsplit=1.0) 26 | "a,b,c,d".split(maxsplit=1) 27 | "a,b,c,d".split(maxsplit=0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | "VERB AUX PRON ADP DET".split(" ") 29 | ' 1 2 3 '.split() | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 24 24 | "a,b,c,d".split(maxsplit=1) @@ -283,16 +299,17 @@ SIM905.py:27:1: SIM905 [*] Consider using a list literal instead of `str.split` 29 29 | ' 1 2 3 '.split() 30 30 | '1<>2<>3<4'.split('<>') -SIM905.py:28:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:28:1 | 26 | "a,b,c,d".split(maxsplit=1) 27 | "a,b,c,d".split(maxsplit=0) 28 | "VERB AUX PRON ADP DET".split(" ") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | ' 1 2 3 '.split() 30 | '1<>2<>3<4'.split('<>') | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 25 25 | "a,b,c,d".split(maxsplit=1.0) @@ -304,15 +321,16 @@ SIM905.py:28:1: SIM905 [*] Consider using a list literal instead of `str.split` 30 30 | '1<>2<>3<4'.split('<>') 31 31 | -SIM905.py:29:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:29:1 | 27 | "a,b,c,d".split(maxsplit=0) 28 | "VERB AUX PRON ADP DET".split(" ") 29 | ' 1 2 3 '.split() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | '1<>2<>3<4'.split('<>') | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 26 26 | "a,b,c,d".split(maxsplit=1) @@ -324,16 +342,17 @@ SIM905.py:29:1: SIM905 [*] Consider using a list literal instead of `str.split` 31 31 | 32 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] -SIM905.py:30:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:30:1 | 28 | "VERB AUX PRON ADP DET".split(" ") 29 | ' 1 2 3 '.split() 30 | '1<>2<>3<4'.split('<>') - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^ 31 | 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 27 27 | "a,b,c,d".split(maxsplit=0) @@ -345,16 +364,17 @@ SIM905.py:30:1: SIM905 [*] Consider using a list literal instead of `str.split` 32 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] 33 33 | "".split() # [] -SIM905.py:32:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:32:1 | 30 | '1<>2<>3<4'.split('<>') 31 | 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | "".split() # [] 34 | """ | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 29 29 | ' 1 2 3 '.split() @@ -366,15 +386,16 @@ SIM905.py:32:1: SIM905 [*] Consider using a list literal instead of `str.split` 34 34 | """ 35 35 | """.split() # [] -SIM905.py:33:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:33:1 | 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] 33 | "".split() # [] - | ^^^^^^^^^^ SIM905 + | ^^^^^^^^^^ 34 | """ 35 | """.split() # [] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 30 30 | '1<>2<>3<4'.split('<>') @@ -386,17 +407,18 @@ SIM905.py:33:1: SIM905 [*] Consider using a list literal instead of `str.split` 35 35 | """.split() # [] 36 36 | " ".split() # [] -SIM905.py:34:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:34:1 | 32 | " a*a a*a a ".split("*", -1) # [" a", "a a", "a a "] 33 | "".split() # [] 34 | / """ 35 | | """.split() # [] - | |___________^ SIM905 + | |___________^ 36 | " ".split() # [] 37 | "/abc/".split() # ["/abc/"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 31 31 | @@ -409,16 +431,17 @@ SIM905.py:34:1: SIM905 [*] Consider using a list literal instead of `str.split` 37 36 | "/abc/".split() # ["/abc/"] 38 37 | ("a,b,c" -SIM905.py:36:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:36:1 | 34 | """ 35 | """.split() # [] 36 | " ".split() # [] - | ^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^ 37 | "/abc/".split() # ["/abc/"] 38 | ("a,b,c" | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 33 33 | "".split() # [] @@ -430,16 +453,17 @@ SIM905.py:36:1: SIM905 [*] Consider using a list literal instead of `str.split` 38 38 | ("a,b,c" 39 39 | # comment -SIM905.py:37:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:37:1 | 35 | """.split() # [] 36 | " ".split() # [] 37 | "/abc/".split() # ["/abc/"] - | ^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^ 38 | ("a,b,c" 39 | # comment | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 34 34 | """ @@ -451,7 +475,8 @@ SIM905.py:37:1: SIM905 [*] Consider using a list literal instead of `str.split` 39 39 | # comment 40 40 | .split() -SIM905.py:38:2: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:38:2 | 36 | " ".split() # [] 37 | "/abc/".split() # ["/abc/"] @@ -459,11 +484,11 @@ SIM905.py:38:2: SIM905 [*] Consider using a list literal instead of `str.split` | __^ 39 | | # comment 40 | | .split() - | |________^ SIM905 + | |________^ 41 | ) # ["a,b,c"] 42 | ("a,b,c" | - = help: Replace with list literal +help: Replace with list literal ℹ Unsafe fix 35 35 | """.split() # [] @@ -477,7 +502,8 @@ SIM905.py:38:2: SIM905 [*] Consider using a list literal instead of `str.split` 42 40 | ("a,b,c" 43 41 | # comment1 -SIM905.py:42:2: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:42:2 | 40 | .split() 41 | ) # ["a,b,c"] @@ -485,11 +511,11 @@ SIM905.py:42:2: SIM905 [*] Consider using a list literal instead of `str.split` | __^ 43 | | # comment1 44 | | .split(",") - | |___________^ SIM905 + | |___________^ 45 | ) # ["a", "b", "c"] 46 | ("a," | - = help: Replace with list literal +help: Replace with list literal ℹ Unsafe fix 39 39 | # comment @@ -503,7 +529,8 @@ SIM905.py:42:2: SIM905 [*] Consider using a list literal instead of `str.split` 46 44 | ("a," 47 45 | # comment -SIM905.py:46:2: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:46:2 | 44 | .split(",") 45 | ) # ["a", "b", "c"] @@ -513,10 +540,10 @@ SIM905.py:46:2: SIM905 [*] Consider using a list literal instead of `str.split` 48 | | "b," 49 | | "c" 50 | | .split(",") - | |___________^ SIM905 + | |___________^ 51 | ) # ["a", "b", "c"] | - = help: Replace with list literal +help: Replace with list literal ℹ Unsafe fix 43 43 | # comment1 @@ -532,16 +559,17 @@ SIM905.py:46:2: SIM905 [*] Consider using a list literal instead of `str.split` 52 48 | 53 49 | "hello "\ -SIM905.py:53:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:53:1 | 51 | ) # ["a", "b", "c"] 52 | 53 | / "hello "\ 54 | | "world".split() - | |___________________^ SIM905 + | |___________________^ 55 | # ["hello", "world"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 50 50 | .split(",") @@ -554,15 +582,16 @@ SIM905.py:53:1: SIM905 [*] Consider using a list literal instead of `str.split` 56 55 | 57 56 | # prefixes and isc -SIM905.py:58:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:58:1 | 57 | # prefixes and isc 58 | u"a b".split() # [u"a", u"b"] - | ^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^ 59 | r"a \n b".split() # [r"a", r"\n", r"b"] 60 | ("a " "b").split() # ["a", "b"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 55 55 | # ["hello", "world"] @@ -574,16 +603,17 @@ SIM905.py:58:1: SIM905 [*] Consider using a list literal instead of `str.split` 60 60 | ("a " "b").split() # ["a", "b"] 61 61 | "a " "b".split() # ["a", "b"] -SIM905.py:59:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:59:1 | 57 | # prefixes and isc 58 | u"a b".split() # [u"a", u"b"] 59 | r"a \n b".split() # [r"a", r"\n", r"b"] - | ^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^ 60 | ("a " "b").split() # ["a", "b"] 61 | "a " "b".split() # ["a", "b"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 56 56 | @@ -595,16 +625,17 @@ SIM905.py:59:1: SIM905 [*] Consider using a list literal instead of `str.split` 61 61 | "a " "b".split() # ["a", "b"] 62 62 | u"a " "b".split() # [u"a", u"b"] -SIM905.py:60:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:60:1 | 58 | u"a b".split() # [u"a", u"b"] 59 | r"a \n b".split() # [r"a", r"\n", r"b"] 60 | ("a " "b").split() # ["a", "b"] - | ^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^ 61 | "a " "b".split() # ["a", "b"] 62 | u"a " "b".split() # [u"a", u"b"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 57 57 | # prefixes and isc @@ -616,16 +647,17 @@ SIM905.py:60:1: SIM905 [*] Consider using a list literal instead of `str.split` 62 62 | u"a " "b".split() # [u"a", u"b"] 63 63 | "a " u"b".split() # ["a", "b"] -SIM905.py:61:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:61:1 | 59 | r"a \n b".split() # [r"a", r"\n", r"b"] 60 | ("a " "b").split() # ["a", "b"] 61 | "a " "b".split() # ["a", "b"] - | ^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^ 62 | u"a " "b".split() # [u"a", u"b"] 63 | "a " u"b".split() # ["a", "b"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 58 58 | u"a b".split() # [u"a", u"b"] @@ -637,16 +669,17 @@ SIM905.py:61:1: SIM905 [*] Consider using a list literal instead of `str.split` 63 63 | "a " u"b".split() # ["a", "b"] 64 64 | u"a " r"\n".split() # [u"a", u"\\n"] -SIM905.py:62:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:62:1 | 60 | ("a " "b").split() # ["a", "b"] 61 | "a " "b".split() # ["a", "b"] 62 | u"a " "b".split() # [u"a", u"b"] - | ^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^ 63 | "a " u"b".split() # ["a", "b"] 64 | u"a " r"\n".split() # [u"a", u"\\n"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 59 59 | r"a \n b".split() # [r"a", r"\n", r"b"] @@ -658,16 +691,17 @@ SIM905.py:62:1: SIM905 [*] Consider using a list literal instead of `str.split` 64 64 | u"a " r"\n".split() # [u"a", u"\\n"] 65 65 | r"\n " u"\n".split() # [r"\n"] -SIM905.py:63:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:63:1 | 61 | "a " "b".split() # ["a", "b"] 62 | u"a " "b".split() # [u"a", u"b"] 63 | "a " u"b".split() # ["a", "b"] - | ^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^ 64 | u"a " r"\n".split() # [u"a", u"\\n"] 65 | r"\n " u"\n".split() # [r"\n"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 60 60 | ("a " "b").split() # ["a", "b"] @@ -679,16 +713,17 @@ SIM905.py:63:1: SIM905 [*] Consider using a list literal instead of `str.split` 65 65 | r"\n " u"\n".split() # [r"\n"] 66 66 | r"\n " "\n".split() # [r"\n"] -SIM905.py:64:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:64:1 | 62 | u"a " "b".split() # [u"a", u"b"] 63 | "a " u"b".split() # ["a", "b"] 64 | u"a " r"\n".split() # [u"a", u"\\n"] - | ^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^ 65 | r"\n " u"\n".split() # [r"\n"] 66 | r"\n " "\n".split() # [r"\n"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 61 61 | "a " "b".split() # ["a", "b"] @@ -700,16 +735,17 @@ SIM905.py:64:1: SIM905 [*] Consider using a list literal instead of `str.split` 66 66 | r"\n " "\n".split() # [r"\n"] 67 67 | "a " r"\n".split() # ["a", "\\n"] -SIM905.py:65:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:65:1 | 63 | "a " u"b".split() # ["a", "b"] 64 | u"a " r"\n".split() # [u"a", u"\\n"] 65 | r"\n " u"\n".split() # [r"\n"] - | ^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^ 66 | r"\n " "\n".split() # [r"\n"] 67 | "a " r"\n".split() # ["a", "\\n"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 62 62 | u"a " "b".split() # [u"a", u"b"] @@ -721,15 +757,16 @@ SIM905.py:65:1: SIM905 [*] Consider using a list literal instead of `str.split` 67 67 | "a " r"\n".split() # ["a", "\\n"] 68 68 | -SIM905.py:66:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:66:1 | 64 | u"a " r"\n".split() # [u"a", u"\\n"] 65 | r"\n " u"\n".split() # [r"\n"] 66 | r"\n " "\n".split() # [r"\n"] - | ^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^ 67 | "a " r"\n".split() # ["a", "\\n"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 63 63 | "a " u"b".split() # ["a", "b"] @@ -741,16 +778,17 @@ SIM905.py:66:1: SIM905 [*] Consider using a list literal instead of `str.split` 68 68 | 69 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] -SIM905.py:67:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:67:1 | 65 | r"\n " u"\n".split() # [r"\n"] 66 | r"\n " "\n".split() # [r"\n"] 67 | "a " r"\n".split() # ["a", "\\n"] - | ^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^ 68 | 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 64 64 | u"a " r"\n".split() # [u"a", u"\\n"] @@ -762,16 +800,17 @@ SIM905.py:67:1: SIM905 [*] Consider using a list literal instead of `str.split` 69 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] 70 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] -SIM905.py:69:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:69:1 | 67 | "a " r"\n".split() # ["a", "\\n"] 68 | 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] 71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 66 66 | r"\n " "\n".split() # [r"\n"] @@ -783,15 +822,16 @@ SIM905.py:69:1: SIM905 [*] Consider using a list literal instead of `str.split` 71 71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] 72 72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] -SIM905.py:70:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:70:1 | 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] 72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 67 67 | "a " r"\n".split() # ["a", "\\n"] @@ -803,15 +843,16 @@ SIM905.py:70:1: SIM905 [*] Consider using a list literal instead of `str.split` 72 72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] 73 73 | -SIM905.py:71:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:71:1 | 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] 71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 68 68 | @@ -823,16 +864,17 @@ SIM905.py:71:1: SIM905 [*] Consider using a list literal instead of `str.split` 73 73 | 74 74 | # negatives -SIM905.py:72:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:72:1 | 70 | "a,b,c".split(',', maxsplit=-1) # ["a", "b", "c"] 71 | "a,b,c".split(',', maxsplit=-2) # ["a", "b", "c"] 72 | "a,b,c".split(',', maxsplit=-0) # ["a,b,c"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 73 | 74 | # negatives | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 69 69 | "a,b,c".split(',', maxsplit=0) # ["a,b,c"] @@ -844,7 +886,8 @@ SIM905.py:72:1: SIM905 [*] Consider using a list literal instead of `str.split` 74 74 | # negatives 75 75 | -SIM905.py:103:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:103:1 | 102 | # another positive demonstrating quote preservation 103 | / """ @@ -853,11 +896,11 @@ SIM905.py:103:1: SIM905 [*] Consider using a list literal instead of `str.split` 106 | | '''itemC''' 107 | | "'itemD'" 108 | | """.split() - | |___________^ SIM905 + | |___________^ 109 | 110 | # https://github.com/astral-sh/ruff/issues/18042 | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 100 100 | @@ -874,14 +917,15 @@ SIM905.py:103:1: SIM905 [*] Consider using a list literal instead of `str.split` 110 105 | # https://github.com/astral-sh/ruff/issues/18042 111 106 | print("a,b".rsplit(",")) -SIM905.py:111:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:111:7 | 110 | # https://github.com/astral-sh/ruff/issues/18042 111 | print("a,b".rsplit(",")) - | ^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^ 112 | print("a,b,c".rsplit(",", 1)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 108 108 | """.split() @@ -893,16 +937,17 @@ SIM905.py:111:7: SIM905 [*] Consider using a list literal instead of `str.split` 113 113 | 114 114 | # https://github.com/astral-sh/ruff/issues/18069 -SIM905.py:112:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:112:7 | 110 | # https://github.com/astral-sh/ruff/issues/18042 111 | print("a,b".rsplit(",")) 112 | print("a,b,c".rsplit(",", 1)) - | ^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^ 113 | 114 | # https://github.com/astral-sh/ruff/issues/18069 | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 109 109 | @@ -914,16 +959,17 @@ SIM905.py:112:7: SIM905 [*] Consider using a list literal instead of `str.split` 114 114 | # https://github.com/astral-sh/ruff/issues/18069 115 115 | -SIM905.py:116:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:116:7 | 114 | # https://github.com/astral-sh/ruff/issues/18069 115 | 116 | print("".split(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^ 117 | print("".split(sep=None, maxsplit=0)) 118 | print(" ".split(maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 113 113 | @@ -935,15 +981,16 @@ SIM905.py:116:7: SIM905 [*] Consider using a list literal instead of `str.split` 118 118 | print(" ".split(maxsplit=0)) 119 119 | print(" ".split(sep=None, maxsplit=0)) -SIM905.py:117:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:117:7 | 116 | print("".split(maxsplit=0)) 117 | print("".split(sep=None, maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 118 | print(" ".split(maxsplit=0)) 119 | print(" ".split(sep=None, maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 114 114 | # https://github.com/astral-sh/ruff/issues/18069 @@ -955,16 +1002,17 @@ SIM905.py:117:7: SIM905 [*] Consider using a list literal instead of `str.split` 119 119 | print(" ".split(sep=None, maxsplit=0)) 120 120 | print(" x ".split(maxsplit=0)) -SIM905.py:118:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:118:7 | 116 | print("".split(maxsplit=0)) 117 | print("".split(sep=None, maxsplit=0)) 118 | print(" ".split(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^ 119 | print(" ".split(sep=None, maxsplit=0)) 120 | print(" x ".split(maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 115 115 | @@ -976,16 +1024,17 @@ SIM905.py:118:7: SIM905 [*] Consider using a list literal instead of `str.split` 120 120 | print(" x ".split(maxsplit=0)) 121 121 | print(" x ".split(sep=None, maxsplit=0)) -SIM905.py:119:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:119:7 | 117 | print("".split(sep=None, maxsplit=0)) 118 | print(" ".split(maxsplit=0)) 119 | print(" ".split(sep=None, maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 120 | print(" x ".split(maxsplit=0)) 121 | print(" x ".split(sep=None, maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 116 116 | print("".split(maxsplit=0)) @@ -997,16 +1046,17 @@ SIM905.py:119:7: SIM905 [*] Consider using a list literal instead of `str.split` 121 121 | print(" x ".split(sep=None, maxsplit=0)) 122 122 | print(" x ".split(maxsplit=0)) -SIM905.py:120:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:120:7 | 118 | print(" ".split(maxsplit=0)) 119 | print(" ".split(sep=None, maxsplit=0)) 120 | print(" x ".split(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^ 121 | print(" x ".split(sep=None, maxsplit=0)) 122 | print(" x ".split(maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 117 117 | print("".split(sep=None, maxsplit=0)) @@ -1018,16 +1068,17 @@ SIM905.py:120:7: SIM905 [*] Consider using a list literal instead of `str.split` 122 122 | print(" x ".split(maxsplit=0)) 123 123 | print(" x ".split(sep=None, maxsplit=0)) -SIM905.py:121:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:121:7 | 119 | print(" ".split(sep=None, maxsplit=0)) 120 | print(" x ".split(maxsplit=0)) 121 | print(" x ".split(sep=None, maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 122 | print(" x ".split(maxsplit=0)) 123 | print(" x ".split(sep=None, maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 118 118 | print(" ".split(maxsplit=0)) @@ -1039,16 +1090,17 @@ SIM905.py:121:7: SIM905 [*] Consider using a list literal instead of `str.split` 123 123 | print(" x ".split(sep=None, maxsplit=0)) 124 124 | print("".rsplit(maxsplit=0)) -SIM905.py:122:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:122:7 | 120 | print(" x ".split(maxsplit=0)) 121 | print(" x ".split(sep=None, maxsplit=0)) 122 | print(" x ".split(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 123 | print(" x ".split(sep=None, maxsplit=0)) 124 | print("".rsplit(maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 119 119 | print(" ".split(sep=None, maxsplit=0)) @@ -1060,16 +1112,17 @@ SIM905.py:122:7: SIM905 [*] Consider using a list literal instead of `str.split` 124 124 | print("".rsplit(maxsplit=0)) 125 125 | print("".rsplit(sep=None, maxsplit=0)) -SIM905.py:123:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:123:7 | 121 | print(" x ".split(sep=None, maxsplit=0)) 122 | print(" x ".split(maxsplit=0)) 123 | print(" x ".split(sep=None, maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 124 | print("".rsplit(maxsplit=0)) 125 | print("".rsplit(sep=None, maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 120 120 | print(" x ".split(maxsplit=0)) @@ -1081,16 +1134,17 @@ SIM905.py:123:7: SIM905 [*] Consider using a list literal instead of `str.split` 125 125 | print("".rsplit(sep=None, maxsplit=0)) 126 126 | print(" ".rsplit(maxsplit=0)) -SIM905.py:124:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:124:7 | 122 | print(" x ".split(maxsplit=0)) 123 | print(" x ".split(sep=None, maxsplit=0)) 124 | print("".rsplit(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^ 125 | print("".rsplit(sep=None, maxsplit=0)) 126 | print(" ".rsplit(maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 121 121 | print(" x ".split(sep=None, maxsplit=0)) @@ -1102,16 +1156,17 @@ SIM905.py:124:7: SIM905 [*] Consider using a list literal instead of `str.split` 126 126 | print(" ".rsplit(maxsplit=0)) 127 127 | print(" ".rsplit(sep=None, maxsplit=0)) -SIM905.py:125:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:125:7 | 123 | print(" x ".split(sep=None, maxsplit=0)) 124 | print("".rsplit(maxsplit=0)) 125 | print("".rsplit(sep=None, maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 126 | print(" ".rsplit(maxsplit=0)) 127 | print(" ".rsplit(sep=None, maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 122 122 | print(" x ".split(maxsplit=0)) @@ -1123,16 +1178,17 @@ SIM905.py:125:7: SIM905 [*] Consider using a list literal instead of `str.split` 127 127 | print(" ".rsplit(sep=None, maxsplit=0)) 128 128 | print(" x ".rsplit(maxsplit=0)) -SIM905.py:126:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:126:7 | 124 | print("".rsplit(maxsplit=0)) 125 | print("".rsplit(sep=None, maxsplit=0)) 126 | print(" ".rsplit(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^ 127 | print(" ".rsplit(sep=None, maxsplit=0)) 128 | print(" x ".rsplit(maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 123 123 | print(" x ".split(sep=None, maxsplit=0)) @@ -1144,16 +1200,17 @@ SIM905.py:126:7: SIM905 [*] Consider using a list literal instead of `str.split` 128 128 | print(" x ".rsplit(maxsplit=0)) 129 129 | print(" x ".rsplit(maxsplit=0)) -SIM905.py:127:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:127:7 | 125 | print("".rsplit(sep=None, maxsplit=0)) 126 | print(" ".rsplit(maxsplit=0)) 127 | print(" ".rsplit(sep=None, maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 128 | print(" x ".rsplit(maxsplit=0)) 129 | print(" x ".rsplit(maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 124 124 | print("".rsplit(maxsplit=0)) @@ -1165,16 +1222,17 @@ SIM905.py:127:7: SIM905 [*] Consider using a list literal instead of `str.split` 129 129 | print(" x ".rsplit(maxsplit=0)) 130 130 | print(" x ".rsplit(sep=None, maxsplit=0)) -SIM905.py:128:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:128:7 | 126 | print(" ".rsplit(maxsplit=0)) 127 | print(" ".rsplit(sep=None, maxsplit=0)) 128 | print(" x ".rsplit(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 129 | print(" x ".rsplit(maxsplit=0)) 130 | print(" x ".rsplit(sep=None, maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 125 125 | print("".rsplit(sep=None, maxsplit=0)) @@ -1186,16 +1244,17 @@ SIM905.py:128:7: SIM905 [*] Consider using a list literal instead of `str.split` 130 130 | print(" x ".rsplit(sep=None, maxsplit=0)) 131 131 | print(" x ".rsplit(maxsplit=0)) -SIM905.py:129:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:129:7 | 127 | print(" ".rsplit(sep=None, maxsplit=0)) 128 | print(" x ".rsplit(maxsplit=0)) 129 | print(" x ".rsplit(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 130 | print(" x ".rsplit(sep=None, maxsplit=0)) 131 | print(" x ".rsplit(maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 126 126 | print(" ".rsplit(maxsplit=0)) @@ -1207,16 +1266,17 @@ SIM905.py:129:7: SIM905 [*] Consider using a list literal instead of `str.split` 131 131 | print(" x ".rsplit(maxsplit=0)) 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) -SIM905.py:130:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:130:7 | 128 | print(" x ".rsplit(maxsplit=0)) 129 | print(" x ".rsplit(maxsplit=0)) 130 | print(" x ".rsplit(sep=None, maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 131 | print(" x ".rsplit(maxsplit=0)) 132 | print(" x ".rsplit(sep=None, maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 127 127 | print(" ".rsplit(sep=None, maxsplit=0)) @@ -1228,15 +1288,16 @@ SIM905.py:130:7: SIM905 [*] Consider using a list literal instead of `str.split` 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) 133 133 | -SIM905.py:131:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:131:7 | 129 | print(" x ".rsplit(maxsplit=0)) 130 | print(" x ".rsplit(sep=None, maxsplit=0)) 131 | print(" x ".rsplit(maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 132 | print(" x ".rsplit(sep=None, maxsplit=0)) | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 128 128 | print(" x ".rsplit(maxsplit=0)) @@ -1248,16 +1309,17 @@ SIM905.py:131:7: SIM905 [*] Consider using a list literal instead of `str.split` 133 133 | 134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings -SIM905.py:132:7: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:132:7 | 130 | print(" x ".rsplit(sep=None, maxsplit=0)) 131 | print(" x ".rsplit(maxsplit=0)) 132 | print(" x ".rsplit(sep=None, maxsplit=0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM905 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 133 | 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 129 129 | print(" x ".rsplit(maxsplit=0)) @@ -1269,7 +1331,8 @@ SIM905.py:132:7: SIM905 [*] Consider using a list literal instead of `str.split` 134 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings 135 135 | r"""simple@example.com -SIM905.py:135:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:135:1 | 134 | # https://github.com/astral-sh/ruff/issues/19581 - embedded quotes in raw strings 135 | / r"""simple@example.com @@ -1295,9 +1358,9 @@ SIM905.py:135:1: SIM905 [*] Consider using a list literal instead of `str.split` 155 | | "Abc@def"@example.com 156 | | "Fred\ Bloggs"@example.com 157 | | "Joe.\\Blow"@example.com""".split("\n") - | |_______________________________________^ SIM905 + | |_______________________________________^ | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 132 132 | print(" x ".rsplit(sep=None, maxsplit=0)) @@ -1331,15 +1394,16 @@ SIM905.py:135:1: SIM905 [*] Consider using a list literal instead of `str.split` 159 137 | 160 138 | r"""first -SIM905.py:160:1: SIM905 [*] Consider using a list literal instead of `str.split` +SIM905 [*] Consider using a list literal instead of `str.split` + --> SIM905.py:160:1 | 160 | / r"""first 161 | | 'no need' to escape 162 | | "swap" quote style 163 | | "use' ugly triple quotes""".split("\n") - | |_______________________________________^ SIM905 + | |_______________________________________^ | - = help: Replace with list literal +help: Replace with list literal ℹ Safe fix 157 157 | "Joe.\\Blow"@example.com""".split("\n") diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap index 8bbbdc5fd5..4840899e7c 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM910.py:2:1: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` +SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` + --> SIM910.py:2:1 | 1 | # SIM910 2 | {}.get(key, None) - | ^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^ 3 | 4 | # SIM910 | - = help: Replace `{}.get(key, None)` with `{}.get(key)` +help: Replace `{}.get(key, None)` with `{}.get(key)` ℹ Safe fix 1 1 | # SIM910 @@ -19,15 +20,16 @@ SIM910.py:2:1: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` 4 4 | # SIM910 5 5 | {}.get("key", None) -SIM910.py:5:1: SIM910 [*] Use `{}.get("key")` instead of `{}.get("key", None)` +SIM910 [*] Use `{}.get("key")` instead of `{}.get("key", None)` + --> SIM910.py:5:1 | 4 | # SIM910 5 | {}.get("key", None) - | ^^^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^^^ 6 | 7 | # OK | - = help: Replace `{}.get("key", None)` with `{}.get("key")` +help: Replace `{}.get("key", None)` with `{}.get("key")` ℹ Safe fix 2 2 | {}.get(key, None) @@ -39,14 +41,15 @@ SIM910.py:5:1: SIM910 [*] Use `{}.get("key")` instead of `{}.get("key", None)` 7 7 | # OK 8 8 | {}.get(key) -SIM910.py:20:9: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` +SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` + --> SIM910.py:20:9 | 19 | # SIM910 20 | if a := {}.get(key, None): - | ^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^ 21 | pass | - = help: Replace `{}.get(key, None)` with `{}.get(key)` +help: Replace `{}.get(key, None)` with `{}.get(key)` ℹ Safe fix 17 17 | {}.get("key", False) @@ -58,15 +61,16 @@ SIM910.py:20:9: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` 22 22 | 23 23 | # SIM910 -SIM910.py:24:5: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` +SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` + --> SIM910.py:24:5 | 23 | # SIM910 24 | a = {}.get(key, None) - | ^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^ 25 | 26 | # SIM910 | - = help: Replace `{}.get(key, None)` with `{}.get(key)` +help: Replace `{}.get(key, None)` with `{}.get(key)` ℹ Safe fix 21 21 | pass @@ -78,15 +82,16 @@ SIM910.py:24:5: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` 26 26 | # SIM910 27 27 | ({}).get(key, None) -SIM910.py:27:1: SIM910 [*] Use `({}).get(key)` instead of `({}).get(key, None)` +SIM910 [*] Use `({}).get(key)` instead of `({}).get(key, None)` + --> SIM910.py:27:1 | 26 | # SIM910 27 | ({}).get(key, None) - | ^^^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^^^ 28 | 29 | # SIM910 | - = help: Replace `({}).get(key, None)` with `({}).get(key)` +help: Replace `({}).get(key, None)` with `({}).get(key)` ℹ Safe fix 24 24 | a = {}.get(key, None) @@ -98,16 +103,17 @@ SIM910.py:27:1: SIM910 [*] Use `({}).get(key)` instead of `({}).get(key, None)` 29 29 | # SIM910 30 30 | ages = {"Tom": 23, "Maria": 23, "Dog": 11} -SIM910.py:31:7: SIM910 [*] Use `ages.get("Cat")` instead of `ages.get("Cat", None)` +SIM910 [*] Use `ages.get("Cat")` instead of `ages.get("Cat", None)` + --> SIM910.py:31:7 | 29 | # SIM910 30 | ages = {"Tom": 23, "Maria": 23, "Dog": 11} 31 | age = ages.get("Cat", None) - | ^^^^^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | # OK | - = help: Replace `ages.get("Cat", None)` with `ages.get("Cat")` +help: Replace `ages.get("Cat", None)` with `ages.get("Cat")` ℹ Safe fix 28 28 | @@ -119,16 +125,17 @@ SIM910.py:31:7: SIM910 [*] Use `ages.get("Cat")` instead of `ages.get("Cat", Non 33 33 | # OK 34 34 | ages = ["Tom", "Maria", "Dog"] -SIM910.py:39:9: SIM910 [*] Use `kwargs.get('a')` instead of `kwargs.get('a', None)` +SIM910 [*] Use `kwargs.get('a')` instead of `kwargs.get('a', None)` + --> SIM910.py:39:9 | 37 | # SIM910 38 | def foo(**kwargs): 39 | a = kwargs.get('a', None) - | ^^^^^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^^^^^ 40 | 41 | # SIM910 | - = help: Replace `kwargs.get('a', None)` with `kwargs.get('a')` +help: Replace `kwargs.get('a', None)` with `kwargs.get('a')` ℹ Safe fix 36 36 | @@ -140,16 +147,17 @@ SIM910.py:39:9: SIM910 [*] Use `kwargs.get('a')` instead of `kwargs.get('a', Non 41 41 | # SIM910 42 42 | def foo(some_dict: dict): -SIM910.py:43:9: SIM910 [*] Use `some_dict.get('a')` instead of `some_dict.get('a', None)` +SIM910 [*] Use `some_dict.get('a')` instead of `some_dict.get('a', None)` + --> SIM910.py:43:9 | 41 | # SIM910 42 | def foo(some_dict: dict): 43 | a = some_dict.get('a', None) - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | # OK | - = help: Replace `some_dict.get('a', None)` with `some_dict.get('a')` +help: Replace `some_dict.get('a', None)` with `some_dict.get('a')` ℹ Safe fix 40 40 | @@ -161,14 +169,15 @@ SIM910.py:43:9: SIM910 [*] Use `some_dict.get('a')` instead of `some_dict.get('a 45 45 | # OK 46 46 | def foo(some_other: object): -SIM910.py:57:11: SIM910 [*] Use `dict.get("Cat")` instead of `dict.get("Cat", None)` +SIM910 [*] Use `dict.get("Cat")` instead of `dict.get("Cat", None)` + --> SIM910.py:57:11 | 55 | def foo(): 56 | dict = {"Tom": 23, "Maria": 23, "Dog": 11} 57 | age = dict.get("Cat", None) - | ^^^^^^^^^^^^^^^^^^^^^ SIM910 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace `dict.get("Cat", None)` with `dict.get("Cat")` +help: Replace `dict.get("Cat", None)` with `dict.get("Cat")` ℹ Safe fix 54 54 | # https://github.com/astral-sh/ruff/issues/18777 diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM911_SIM911.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM911_SIM911.py.snap index 261332a8be..4996e8d7d0 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM911_SIM911.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM911_SIM911.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM911.py:2:17: SIM911 [*] Use `d.items()` instead of `zip(d.keys(), d.values())` +SIM911 [*] Use `d.items()` instead of `zip(d.keys(), d.values())` + --> SIM911.py:2:17 | 1 | def foo(d: dict[str, str]) -> None: 2 | for k, v in zip(d.keys(), d.values()): # SIM911 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | ... | - = help: Replace `zip(d.keys(), d.values())` with `d.items()` +help: Replace `zip(d.keys(), d.values())` with `d.items()` ℹ Safe fix 1 1 | def foo(d: dict[str, str]) -> None: @@ -18,15 +19,16 @@ SIM911.py:2:17: SIM911 [*] Use `d.items()` instead of `zip(d.keys(), d.values()) 4 4 | 5 5 | for k, v in zip(d.keys(), d.values(), strict=True): # SIM911 -SIM911.py:5:17: SIM911 [*] Use `d.items()` instead of `zip(d.keys(), d.values(), strict=True)` +SIM911 [*] Use `d.items()` instead of `zip(d.keys(), d.values(), strict=True)` + --> SIM911.py:5:17 | 3 | ... 4 | 5 | for k, v in zip(d.keys(), d.values(), strict=True): # SIM911 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | ... | - = help: Replace `zip(d.keys(), d.values(), strict=True)` with `d.items()` +help: Replace `zip(d.keys(), d.values(), strict=True)` with `d.items()` ℹ Safe fix 2 2 | for k, v in zip(d.keys(), d.values()): # SIM911 @@ -38,15 +40,16 @@ SIM911.py:5:17: SIM911 [*] Use `d.items()` instead of `zip(d.keys(), d.values(), 7 7 | 8 8 | for k, v in zip(d.keys(), d.values(), struct=True): # OK -SIM911.py:20:13: SIM911 [*] Use `d2.items()` instead of `zip(d2.keys(), d2.values())` +SIM911 [*] Use `d2.items()` instead of `zip(d2.keys(), d2.values())` + --> SIM911.py:20:13 | 18 | ... 19 | 20 | for k, v in zip(d2.keys(), d2.values()): # SIM911 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | ... | - = help: Replace `zip(d2.keys(), d2.values())` with `d2.items()` +help: Replace `zip(d2.keys(), d2.values())` with `d2.items()` ℹ Safe fix 17 17 | for k, v in zip(d1.items(), d2.values()): # OK @@ -58,15 +61,16 @@ SIM911.py:20:13: SIM911 [*] Use `d2.items()` instead of `zip(d2.keys(), d2.value 22 22 | 23 23 | items = zip(x.keys(), x.values()) # OK -SIM911.py:30:27: SIM911 [*] Use `dict.items()` instead of `zip(dict.keys(), dict.values())` +SIM911 [*] Use `dict.items()` instead of `zip(dict.keys(), dict.values())` + --> SIM911.py:30:27 | 28 | def foo(): 29 | dict = {} 30 | for country, stars in zip(dict.keys(), dict.values()): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | ... | - = help: Replace `zip(dict.keys(), dict.values())` with `dict.items()` +help: Replace `zip(dict.keys(), dict.values())` with `dict.items()` ℹ Safe fix 27 27 | # https://github.com/astral-sh/ruff/issues/18777 @@ -78,14 +82,15 @@ SIM911.py:30:27: SIM911 [*] Use `dict.items()` instead of `zip(dict.keys(), dict 32 32 | 33 33 | -SIM911.py:36:22: SIM911 [*] Use ` flag_stars.items()` instead of `(zip)(flag_stars.keys(), flag_stars.values())` +SIM911 [*] Use ` flag_stars.items()` instead of `(zip)(flag_stars.keys(), flag_stars.values())` + --> SIM911.py:36:22 | 34 | # https://github.com/astral-sh/ruff/issues/18776 35 | flag_stars = {} 36 | for country, stars in(zip)(flag_stars.keys(), flag_stars.values()):... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM911 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace `(zip)(flag_stars.keys(), flag_stars.values())` with ` flag_stars.items()` +help: Replace `(zip)(flag_stars.keys(), flag_stars.values())` with ` flag_stars.items()` ℹ Safe fix 33 33 | diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM117_SIM117.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM117_SIM117.py.snap index 4928d2db7e..db3862e18e 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM117_SIM117.py.snap +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__preview__SIM117_SIM117.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs --- -SIM117.py:2:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:2:1 | 1 | # SIM117 2 | / with A() as a: 3 | | with B() as b: - | |__________________^ SIM117 + | |__________________^ 4 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 1 1 | # SIM117 @@ -22,16 +23,17 @@ SIM117.py:2:1: SIM117 [*] Use a single `with` statement with multiple contexts i 6 5 | # SIM117 7 6 | with A(): -SIM117.py:7:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:7:1 | 6 | # SIM117 7 | / with A(): 8 | | with B(): - | |_____________^ SIM117 + | |_____________^ 9 | with C(): 10 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 4 4 | print("hello") @@ -48,27 +50,29 @@ SIM117.py:7:1: SIM117 [*] Use a single `with` statement with multiple contexts i 12 11 | # SIM117 13 12 | with A() as a: -SIM117.py:13:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:13:1 | 12 | # SIM117 13 | / with A() as a: 14 | | # Unfixable due to placement of this comment. 15 | | with B() as b: - | |__________________^ SIM117 + | |__________________^ 16 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements -SIM117.py:19:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:19:1 | 18 | # SIM117 19 | / with A() as a: 20 | | with B() as b: - | |__________________^ SIM117 + | |__________________^ 21 | # Fixable due to placement of this comment. 22 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 16 16 | print("hello") @@ -85,15 +89,16 @@ SIM117.py:19:1: SIM117 [*] Use a single `with` statement with multiple contexts 24 23 | # OK 25 24 | with A() as a: -SIM117.py:47:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:47:1 | 46 | # SIM117 47 | / async with A() as a: 48 | | async with B() as b: - | |________________________^ SIM117 + | |________________________^ 49 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 44 44 | print("hello") @@ -108,17 +113,18 @@ SIM117.py:47:1: SIM117 [*] Use a single `with` statement with multiple contexts 51 50 | while True: 52 51 | # SIM117 -SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:53:5 | 51 | while True: 52 | # SIM117 53 | / with A() as a: 54 | | with B() as b: - | |______________________^ SIM117 + | |______________________^ 55 | """this 56 | is valid""" | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 50 50 | @@ -145,7 +151,8 @@ SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts 66 65 | 67 66 | # SIM117 -SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:68:1 | 67 | # SIM117 68 | / with ( @@ -153,10 +160,10 @@ SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts 70 | | B() as b, 71 | | ): 72 | | with C() as c: - | |__________________^ SIM117 + | |__________________^ 73 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 67 67 | # SIM117 @@ -172,7 +179,8 @@ SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts 75 74 | # SIM117 76 75 | with A() as a: -SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:76:1 | 75 | # SIM117 76 | / with A() as a: @@ -180,10 +188,10 @@ SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts 78 | | B() as b, 79 | | C() as c, 80 | | ): - | |______^ SIM117 + | |______^ 81 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 73 73 | print("hello") @@ -204,7 +212,8 @@ SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts 83 82 | # SIM117 84 83 | with ( -SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:84:1 | 83 | # SIM117 84 | / with ( @@ -215,10 +224,10 @@ SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts 89 | | C() as c, 90 | | D() as d, 91 | | ): - | |______^ SIM117 + | |______^ 92 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 83 83 | # SIM117 @@ -238,15 +247,16 @@ SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts 94 91 | # SIM117 (auto-fixable) 95 92 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: -SIM117.py:95:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:95:1 | 94 | # SIM117 (auto-fixable) 95 | / with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: 96 | | with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: - | |__________________________________________________^ SIM117 + | |__________________________________________________^ 97 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 92 92 | print("hello") @@ -261,36 +271,39 @@ SIM117.py:95:1: SIM117 [*] Use a single `with` statement with multiple contexts 99 98 | # SIM117 (not auto-fixable too long) 100 99 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: -SIM117.py:100:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:100:1 | 99 | # SIM117 (not auto-fixable too long) 100 | / with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: 101 | | with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: - | |__________________________________________________^ SIM117 + | |__________________________________________________^ 102 | print("hello") | - = help: Combine `with` statements +help: Combine `with` statements -SIM117.py:106:5: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:106:5 | 104 | # From issue #3025. 105 | async def main(): 106 | / async with A() as a: # SIM117. 107 | | async with B() as b: - | |____________________________^ SIM117 + | |____________________________^ 108 | print("async-inside!") | - = help: Combine `with` statements +help: Combine `with` statements -SIM117.py:126:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:126:1 | 125 | # SIM117 126 | / with A() as a: 127 | | with B() as b: - | |__________________^ SIM117 + | |__________________^ 128 | type ListOrSet[T] = list[T] | set[T] | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 123 123 | f(b2, c2, d2) @@ -318,15 +331,16 @@ SIM117.py:126:1: SIM117 [*] Use a single `with` statement with multiple contexts 138 137 | # Allow cascading for some statements. 139 138 | import anyio -SIM117.py:163:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements +SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + --> SIM117.py:163:1 | 162 | # Do not suppress combination, if a context manager is already combined with another. 163 | / async with asyncio.timeout(1), A(): 164 | | async with B(): - | |___________________^ SIM117 + | |___________________^ 165 | pass | - = help: Combine `with` statements +help: Combine `with` statements ℹ Safe fix 160 160 | pass diff --git a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap index 46964ddadf..a05894562c 100644 --- a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap +++ b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/flake8_slots/mod.rs -snapshot_kind: text --- -SLOT000.py:1:7: SLOT000 Subclasses of `str` should define `__slots__` +SLOT000 Subclasses of `str` should define `__slots__` + --> SLOT000.py:1:7 | 1 | class Bad(str): # SLOT000 - | ^^^ SLOT000 + | ^^^ 2 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap index d2566de057..448cd4747a 100644 --- a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap @@ -1,32 +1,36 @@ --- source: crates/ruff_linter/src/rules/flake8_slots/mod.rs --- -SLOT001.py:1:7: SLOT001 Subclasses of `tuple` should define `__slots__` +SLOT001 Subclasses of `tuple` should define `__slots__` + --> SLOT001.py:1:7 | 1 | class Bad(tuple): # SLOT001 - | ^^^ SLOT001 + | ^^^ 2 | pass | -SLOT001.py:12:7: SLOT001 Subclasses of `tuple` should define `__slots__` +SLOT001 Subclasses of `tuple` should define `__slots__` + --> SLOT001.py:12:7 | 12 | class Bad(Tuple): # SLOT001 - | ^^^ SLOT001 + | ^^^ 13 | pass | -SLOT001.py:16:7: SLOT001 Subclasses of `tuple` should define `__slots__` +SLOT001 Subclasses of `tuple` should define `__slots__` + --> SLOT001.py:16:7 | 16 | class Bad(Tuple[str, int, float]): # SLOT001 - | ^^^ SLOT001 + | ^^^ 17 | pass | -SLOT001.py:26:7: SLOT001 Subclasses of `tuple` should define `__slots__` +SLOT001 Subclasses of `tuple` should define `__slots__` + --> SLOT001.py:26:7 | 24 | import builtins 25 | 26 | class AlsoBad(builtins.tuple[int, int]): # SLOT001 - | ^^^^^^^ SLOT001 + | ^^^^^^^ 27 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap index 33bac57c22..a8e481401e 100644 --- a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap @@ -1,31 +1,34 @@ --- source: crates/ruff_linter/src/rules/flake8_slots/mod.rs -snapshot_kind: text --- -SLOT002.py:6:7: SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` +SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` + --> SLOT002.py:6:7 | 6 | class Bad(namedtuple("foo", ["str", "int"])): # SLOT002 - | ^^^ SLOT002 + | ^^^ 7 | pass | -SLOT002.py:10:7: SLOT002 Subclasses of call-based `typing.NamedTuple()` should define `__slots__` +SLOT002 Subclasses of call-based `typing.NamedTuple()` should define `__slots__` + --> SLOT002.py:10:7 | 10 | class UnusualButStillBad(NamedTuple("foo", [("x", int, "y", int)])): # SLOT002 - | ^^^^^^^^^^^^^^^^^^ SLOT002 + | ^^^^^^^^^^^^^^^^^^ 11 | pass | -SLOT002.py:30:7: SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` +SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` + --> SLOT002.py:30:7 | 30 | class UnusualButStillBad(namedtuple("foo", ["str", "int"]), NamedTuple("foo", [("x", int, "y", int)])): - | ^^^^^^^^^^^^^^^^^^ SLOT002 + | ^^^^^^^^^^^^^^^^^^ 31 | pass | -SLOT002.py:34:7: SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` +SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` + --> SLOT002.py:34:7 | 34 | class UnusualButStillBad(namedtuple("foo", ["str", "int"]), object): - | ^^^^^^^^^^^^^^^^^^ SLOT002 + | ^^^^^^^^^^^^^^^^^^ 35 | pass | diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_all_imports.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_all_imports.snap index 50282b2469..4a04d49a28 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_all_imports.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_all_imports.snap @@ -1,97 +1,105 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs -snapshot_kind: text --- -TID252.py:7:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:7:1 | 6 | # TID252 7 | from . import sibling - | ^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^ 8 | from .sibling import example 9 | from .. import parent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:8:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:8:1 | 6 | # TID252 7 | from . import sibling 8 | from .sibling import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | from .. import parent 10 | from ..parent import example | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:9:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:9:1 | 7 | from . import sibling 8 | from .sibling import example 9 | from .. import parent - | ^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | from ..parent import example 11 | from ... import grandparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:10:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:10:1 | 8 | from .sibling import example 9 | from .. import parent 10 | from ..parent import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | from ... import grandparent 12 | from ...grandparent import example | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:11:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:11:1 | 9 | from .. import parent 10 | from ..parent import example 11 | from ... import grandparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | from ...grandparent import example 13 | from .parent import hello | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:12:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:12:1 | 10 | from ..parent import example 11 | from ... import grandparent 12 | from ...grandparent import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | from .parent import hello 14 | from .\ | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:13:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:13:1 | 11 | from ... import grandparent 12 | from ...grandparent import example 13 | from .parent import hello - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | from .\ 15 | parent import \ | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:14:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:14:1 | 12 | from ...grandparent import example 13 | from .parent import hello 14 | / from .\ 15 | | parent import \ 16 | | hello_world - | |___________________^ TID252 + | |___________________^ 17 | from \ 18 | ..parent\ | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:17:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:17:1 | 15 | parent import \ 16 | hello_world @@ -99,93 +107,101 @@ TID252.py:17:1: TID252 Prefer absolute imports over relative imports 18 | | ..parent\ 19 | | import \ 20 | | world_hello - | |_______________^ TID252 + | |_______________^ 21 | from ..... import ultragrantparent 22 | from ...... import ultragrantparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:21:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:21:1 | 19 | import \ 20 | world_hello 21 | from ..... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | from ...... import ultragrantparent 23 | from ....... import ultragrantparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:22:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:22:1 | 20 | world_hello 21 | from ..... import ultragrantparent 22 | from ...... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | from ....... import ultragrantparent 24 | from ......... import ultragrantparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:23:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:23:1 | 21 | from ..... import ultragrantparent 22 | from ...... import ultragrantparent 23 | from ....... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | from ......... import ultragrantparent 25 | from ........................... import ultragrantparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:24:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:24:1 | 22 | from ...... import ultragrantparent 23 | from ....... import ultragrantparent 24 | from ......... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | from ........................... import ultragrantparent 26 | from .....parent import ultragrantparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:25:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:25:1 | 23 | from ....... import ultragrantparent 24 | from ......... import ultragrantparent 25 | from ........................... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | from .....parent import ultragrantparent 27 | from .........parent import ultragrantparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:26:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:26:1 | 24 | from ......... import ultragrantparent 25 | from ........................... import ultragrantparent 26 | from .....parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | from .........parent import ultragrantparent 28 | from ...........................parent import ultragrantparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:27:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:27:1 | 25 | from ........................... import ultragrantparent 26 | from .....parent import ultragrantparent 27 | from .........parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | from ...........................parent import ultragrantparent | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports -TID252.py:28:1: TID252 Prefer absolute imports over relative imports +TID252 Prefer absolute imports over relative imports + --> TID252.py:28:1 | 26 | from .....parent import ultragrantparent 27 | from .........parent import ultragrantparent 28 | from ...........................parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace relative imports with absolute imports +help: Replace relative imports with absolute imports diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports.snap index 9a0db54c45..3f085ace7c 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports.snap @@ -1,52 +1,56 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs -snapshot_kind: text --- -TID252.py:9:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:9:1 | 7 | from . import sibling 8 | from .sibling import example 9 | from .. import parent - | ^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | from ..parent import example 11 | from ... import grandparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:10:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:10:1 | 8 | from .sibling import example 9 | from .. import parent 10 | from ..parent import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | from ... import grandparent 12 | from ...grandparent import example | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:11:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:11:1 | 9 | from .. import parent 10 | from ..parent import example 11 | from ... import grandparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | from ...grandparent import example 13 | from .parent import hello | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:12:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:12:1 | 10 | from ..parent import example 11 | from ... import grandparent 12 | from ...grandparent import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | from .parent import hello 14 | from .\ | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:17:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:17:1 | 15 | parent import \ 16 | hello_world @@ -54,93 +58,101 @@ TID252.py:17:1: TID252 Prefer absolute imports over relative imports from parent 18 | | ..parent\ 19 | | import \ 20 | | world_hello - | |_______________^ TID252 + | |_______________^ 21 | from ..... import ultragrantparent 22 | from ...... import ultragrantparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:21:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:21:1 | 19 | import \ 20 | world_hello 21 | from ..... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | from ...... import ultragrantparent 23 | from ....... import ultragrantparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:22:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:22:1 | 20 | world_hello 21 | from ..... import ultragrantparent 22 | from ...... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | from ....... import ultragrantparent 24 | from ......... import ultragrantparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:23:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:23:1 | 21 | from ..... import ultragrantparent 22 | from ...... import ultragrantparent 23 | from ....... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | from ......... import ultragrantparent 25 | from ........................... import ultragrantparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:24:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:24:1 | 22 | from ...... import ultragrantparent 23 | from ....... import ultragrantparent 24 | from ......... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | from ........................... import ultragrantparent 26 | from .....parent import ultragrantparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:25:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:25:1 | 23 | from ....... import ultragrantparent 24 | from ......... import ultragrantparent 25 | from ........................... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | from .....parent import ultragrantparent 27 | from .........parent import ultragrantparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:26:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:26:1 | 24 | from ......... import ultragrantparent 25 | from ........................... import ultragrantparent 26 | from .....parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | from .........parent import ultragrantparent 28 | from ...........................parent import ultragrantparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:27:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:27:1 | 25 | from ........................... import ultragrantparent 26 | from .....parent import ultragrantparent 27 | from .........parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | from ...........................parent import ultragrantparent | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -TID252.py:28:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> TID252.py:28:1 | 26 | from .....parent import ultragrantparent 27 | from .........parent import ultragrantparent 28 | from ...........................parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap index 652c0975bc..0829419730 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap @@ -1,26 +1,28 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs --- -application.py:5:1: TID252 Prefer absolute imports over relative imports from parent modules +TID252 Prefer absolute imports over relative imports from parent modules + --> application.py:5:1 | 3 | import attrs 4 | 5 | from ....import unknown - | ^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^ 6 | from ..protocol import commands, definitions, responses 7 | from ..server import example | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports -application.py:6:1: TID252 [*] Prefer absolute imports over relative imports from parent modules +TID252 [*] Prefer absolute imports over relative imports from parent modules + --> application.py:6:1 | 5 | from ....import unknown 6 | from ..protocol import commands, definitions, responses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | from ..server import example 8 | from .. import server | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports ℹ Unsafe fix 3 3 | import attrs @@ -32,15 +34,16 @@ application.py:6:1: TID252 [*] Prefer absolute imports over relative imports fro 8 8 | from .. import server 9 9 | from . import logger, models -application.py:6:1: TID252 [*] Prefer absolute imports over relative imports from parent modules +TID252 [*] Prefer absolute imports over relative imports from parent modules + --> application.py:6:1 | 5 | from ....import unknown 6 | from ..protocol import commands, definitions, responses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | from ..server import example 8 | from .. import server | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports ℹ Unsafe fix 3 3 | import attrs @@ -52,15 +55,16 @@ application.py:6:1: TID252 [*] Prefer absolute imports over relative imports fro 8 8 | from .. import server 9 9 | from . import logger, models -application.py:6:1: TID252 [*] Prefer absolute imports over relative imports from parent modules +TID252 [*] Prefer absolute imports over relative imports from parent modules + --> application.py:6:1 | 5 | from ....import unknown 6 | from ..protocol import commands, definitions, responses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | from ..server import example 8 | from .. import server | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports ℹ Unsafe fix 3 3 | import attrs @@ -72,16 +76,17 @@ application.py:6:1: TID252 [*] Prefer absolute imports over relative imports fro 8 8 | from .. import server 9 9 | from . import logger, models -application.py:7:1: TID252 [*] Prefer absolute imports over relative imports from parent modules +TID252 [*] Prefer absolute imports over relative imports from parent modules + --> application.py:7:1 | 5 | from ....import unknown 6 | from ..protocol import commands, definitions, responses 7 | from ..server import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | from .. import server 9 | from . import logger, models | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports ℹ Unsafe fix 4 4 | @@ -93,16 +98,17 @@ application.py:7:1: TID252 [*] Prefer absolute imports over relative imports fro 9 9 | from . import logger, models 10 10 | from ..protocol.UpperCaseModule import some_function -application.py:8:1: TID252 [*] Prefer absolute imports over relative imports from parent modules +TID252 [*] Prefer absolute imports over relative imports from parent modules + --> application.py:8:1 | 6 | from ..protocol import commands, definitions, responses 7 | from ..server import example 8 | from .. import server - | ^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^ 9 | from . import logger, models 10 | from ..protocol.UpperCaseModule import some_function | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports ℹ Unsafe fix 5 5 | from ....import unknown @@ -113,14 +119,15 @@ application.py:8:1: TID252 [*] Prefer absolute imports over relative imports fro 9 9 | from . import logger, models 10 10 | from ..protocol.UpperCaseModule import some_function -application.py:10:1: TID252 [*] Prefer absolute imports over relative imports from parent modules +TID252 [*] Prefer absolute imports over relative imports from parent modules + --> application.py:10:1 | 8 | from .. import server 9 | from . import logger, models 10 | from ..protocol.UpperCaseModule import some_function - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace relative imports from parent modules with absolute imports +help: Replace relative imports from parent modules with absolute imports ℹ Unsafe fix 7 7 | from ..server import example diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap index e74e8b7f3e..2e765bdb12 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap @@ -1,118 +1,130 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs --- -TID251.py:2:8: TID251 `cgi` is banned: The cgi module is deprecated. +TID251 `cgi` is banned: The cgi module is deprecated. + --> TID251.py:2:8 | 1 | ## Banned modules ## 2 | import cgi - | ^^^ TID251 + | ^^^ 3 | 4 | from cgi import * | -TID251.py:4:1: TID251 `cgi` is banned: The cgi module is deprecated. +TID251 `cgi` is banned: The cgi module is deprecated. + --> TID251.py:4:1 | 2 | import cgi 3 | 4 | from cgi import * - | ^^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^^ 5 | 6 | from cgi import a, b, c | -TID251.py:6:1: TID251 `cgi` is banned: The cgi module is deprecated. +TID251 `cgi` is banned: The cgi module is deprecated. + --> TID251.py:6:1 | 4 | from cgi import * 5 | 6 | from cgi import a, b, c - | ^^^^^^^^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | # banning a module also bans any submodules | -TID251.py:9:8: TID251 `cgi` is banned: The cgi module is deprecated. +TID251 `cgi` is banned: The cgi module is deprecated. + --> TID251.py:9:8 | 8 | # banning a module also bans any submodules 9 | import cgi.foo.bar - | ^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^ 10 | 11 | from cgi.foo import bar | -TID251.py:11:1: TID251 `cgi` is banned: The cgi module is deprecated. +TID251 `cgi` is banned: The cgi module is deprecated. + --> TID251.py:11:1 | 9 | import cgi.foo.bar 10 | 11 | from cgi.foo import bar - | ^^^^^^^^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | from cgi.foo.bar import * | -TID251.py:13:1: TID251 `cgi` is banned: The cgi module is deprecated. +TID251 `cgi` is banned: The cgi module is deprecated. + --> TID251.py:13:1 | 11 | from cgi.foo import bar 12 | 13 | from cgi.foo.bar import * - | ^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | ## Banned module members ## | -TID251.py:17:20: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. +TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + --> TID251.py:17:20 | 15 | ## Banned module members ## 16 | 17 | from typing import TypedDict - | ^^^^^^^^^ TID251 + | ^^^^^^^^^ 18 | 19 | import typing | -TID251.py:22:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. +TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + --> TID251.py:22:1 | 21 | # attribute access is checked 22 | typing.TypedDict - | ^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^ 23 | 24 | typing.TypedDict.anything | -TID251.py:24:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. +TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + --> TID251.py:24:1 | 22 | typing.TypedDict 23 | 24 | typing.TypedDict.anything - | ^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^ 25 | 26 | # function calls are checked | -TID251.py:27:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. +TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + --> TID251.py:27:1 | 26 | # function calls are checked 27 | typing.TypedDict() - | ^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^ 28 | 29 | typing.TypedDict.anything() | -TID251.py:29:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. +TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + --> TID251.py:29:1 | 27 | typing.TypedDict() 28 | 29 | typing.TypedDict.anything() - | ^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^ 30 | 31 | # import aliases are resolved | -TID251.py:33:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. +TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + --> TID251.py:33:1 | 31 | # import aliases are resolved 32 | import typing as totally_not_typing 33 | totally_not_typing.TypedDict - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | 35 | # relative imports are respected | diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap index 47f5e38597..f387a1dc4a 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap @@ -1,29 +1,32 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs --- -application.py:3:8: TID251 `attrs` is banned: The attrs module is deprecated. +TID251 `attrs` is banned: The attrs module is deprecated. + --> application.py:3:8 | 1 | from typing import TYPE_CHECKING, Any, ClassVar 2 | 3 | import attrs - | ^^^^^ TID251 + | ^^^^^ 4 | 5 | from ....import unknown | -application.py:6:1: TID251 `my_package.sublib.protocol` is banned: The protocol module is deprecated. +TID251 `my_package.sublib.protocol` is banned: The protocol module is deprecated. + --> application.py:6:1 | 5 | from ....import unknown 6 | from ..protocol import commands, definitions, responses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | from ..server import example 8 | from .. import server | -application.py:10:1: TID251 `my_package.sublib.protocol` is banned: The protocol module is deprecated. +TID251 `my_package.sublib.protocol` is banned: The protocol module is deprecated. + --> application.py:10:1 | 8 | from .. import server 9 | from . import logger, models 10 | from ..protocol.UpperCaseModule import some_function - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap index eb8c2d42a5..057c6def8a 100644 --- a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap @@ -1,79 +1,87 @@ --- source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs --- -TID253.py:2:8: TID253 `torch` is banned at the module level +TID253 `torch` is banned at the module level + --> TID253.py:2:8 | 1 | ## Banned modules ## 2 | import torch - | ^^^^^ TID253 + | ^^^^^ 3 | 4 | from torch import * | -TID253.py:4:1: TID253 `torch` is banned at the module level +TID253 `torch` is banned at the module level + --> TID253.py:4:1 | 2 | import torch 3 | 4 | from torch import * - | ^^^^^^^^^^^^^^^^^^^ TID253 + | ^^^^^^^^^^^^^^^^^^^ 5 | 6 | from tensorflow import a, b, c | -TID253.py:6:1: TID253 `tensorflow` is banned at the module level +TID253 `tensorflow` is banned at the module level + --> TID253.py:6:1 | 4 | from torch import * 5 | 6 | from tensorflow import a, b, c - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | import torch as torch_wearing_a_trenchcoat | -TID253.py:8:8: TID253 `torch` is banned at the module level +TID253 `torch` is banned at the module level + --> TID253.py:8:8 | 6 | from tensorflow import a, b, c 7 | 8 | import torch as torch_wearing_a_trenchcoat - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | # this should count as module level | -TID253.py:11:15: TID253 `tensorflow` is banned at the module level +TID253 `tensorflow` is banned at the module level + --> TID253.py:11:15 | 10 | # this should count as module level 11 | x = 1; import tensorflow - | ^^^^^^^^^^ TID253 + | ^^^^^^^^^^ 12 | 13 | # banning a module also bans any submodules | -TID253.py:14:8: TID253 `torch` is banned at the module level +TID253 `torch` is banned at the module level + --> TID253.py:14:8 | 13 | # banning a module also bans any submodules 14 | import torch.foo.bar - | ^^^^^^^^^^^^^ TID253 + | ^^^^^^^^^^^^^ 15 | 16 | from tensorflow.foo import bar | -TID253.py:16:1: TID253 `tensorflow` is banned at the module level +TID253 `tensorflow` is banned at the module level + --> TID253.py:16:1 | 14 | import torch.foo.bar 15 | 16 | from tensorflow.foo import bar - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | from torch.foo.bar import * | -TID253.py:18:1: TID253 `torch` is banned at the module level +TID253 `torch` is banned at the module level + --> TID253.py:18:1 | 16 | from tensorflow.foo import bar 17 | 18 | from torch.foo.bar import * - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # unlike TID251, inline imports are *not* banned | diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap index 6b84c98c68..3876b47eba 100644 --- a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_todos/mod.rs -snapshot_kind: text --- -TD006.py:5:3: TD006 [*] Invalid TODO capitalization: `ToDo` should be `TODO` +TD006 [*] Invalid TODO capitalization: `ToDo` should be `TODO` + --> TD006.py:5:3 | 3 | # Todoism is a word which starts with todo, but is not a todo 4 | # TDO006 - error 5 | # ToDo (evanrittenhouse): invalid capitalization - | ^^^^ TD006 + | ^^^^ 6 | # todo (evanrittenhouse): another invalid capitalization 7 | # foo # todo: invalid capitalization | - = help: Replace `ToDo` with `TODO` +help: Replace `ToDo` with `TODO` ℹ Safe fix 2 2 | # TODO (evanrittenhouse): this is a valid TODO @@ -22,15 +22,16 @@ TD006.py:5:3: TD006 [*] Invalid TODO capitalization: `ToDo` should be `TODO` 6 6 | # todo (evanrittenhouse): another invalid capitalization 7 7 | # foo # todo: invalid capitalization -TD006.py:6:3: TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` +TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` + --> TD006.py:6:3 | 4 | # TDO006 - error 5 | # ToDo (evanrittenhouse): invalid capitalization 6 | # todo (evanrittenhouse): another invalid capitalization - | ^^^^ TD006 + | ^^^^ 7 | # foo # todo: invalid capitalization | - = help: Replace `todo` with `TODO` +help: Replace `todo` with `TODO` ℹ Safe fix 3 3 | # Todoism is a word which starts with todo, but is not a todo @@ -40,14 +41,15 @@ TD006.py:6:3: TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` 6 |+# TODO (evanrittenhouse): another invalid capitalization 7 7 | # foo # todo: invalid capitalization -TD006.py:7:9: TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` +TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` + --> TD006.py:7:9 | 5 | # ToDo (evanrittenhouse): invalid capitalization 6 | # todo (evanrittenhouse): another invalid capitalization 7 | # foo # todo: invalid capitalization - | ^^^^ TD006 + | ^^^^ | - = help: Replace `todo` with `TODO` +help: Replace `todo` with `TODO` ℹ Safe fix 4 4 | # TDO006 - error diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap index 1bc8754c51..dbfe98f34b 100644 --- a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap @@ -1,29 +1,31 @@ --- source: crates/ruff_linter/src/rules/flake8_todos/mod.rs -snapshot_kind: text --- -TD001.py:7:3: TD001 Invalid TODO tag: `XXX` +TD001 Invalid TODO tag: `XXX` + --> TD001.py:7:3 | 6 | # T001 - errors 7 | # XXX (evanrittenhouse): this is not fine - | ^^^ TD001 + | ^^^ 8 | # FIXME (evanrittenhouse): this is not fine 9 | # foo # XXX: this isn't fine either | -TD001.py:8:3: TD001 Invalid TODO tag: `FIXME` +TD001 Invalid TODO tag: `FIXME` + --> TD001.py:8:3 | 6 | # T001 - errors 7 | # XXX (evanrittenhouse): this is not fine 8 | # FIXME (evanrittenhouse): this is not fine - | ^^^^^ TD001 + | ^^^^^ 9 | # foo # XXX: this isn't fine either | -TD001.py:9:9: TD001 Invalid TODO tag: `XXX` +TD001 Invalid TODO tag: `XXX` + --> TD001.py:9:9 | 7 | # XXX (evanrittenhouse): this is not fine 8 | # FIXME (evanrittenhouse): this is not fine 9 | # foo # XXX: this isn't fine either - | ^^^ TD001 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap index babe25d322..88e1af9b4c 100644 --- a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap @@ -1,52 +1,56 @@ --- source: crates/ruff_linter/src/rules/flake8_todos/mod.rs -snapshot_kind: text --- -TD007.py:5:3: TD007 Missing space after colon in TODO +TD007 Missing space after colon in TODO + --> TD007.py:5:3 | 3 | # TODO: so does this 4 | # T007 - errors 5 | # TODO(evanrittenhouse):this has no space after a colon - | ^^^^ TD007 + | ^^^^ 6 | # TODO (evanrittenhouse):this doesn't either 7 | # TODO:neither does this | -TD007.py:6:3: TD007 Missing space after colon in TODO +TD007 Missing space after colon in TODO + --> TD007.py:6:3 | 4 | # T007 - errors 5 | # TODO(evanrittenhouse):this has no space after a colon 6 | # TODO (evanrittenhouse):this doesn't either - | ^^^^ TD007 + | ^^^^ 7 | # TODO:neither does this 8 | # FIXME:and lastly neither does this | -TD007.py:7:3: TD007 Missing space after colon in TODO +TD007 Missing space after colon in TODO + --> TD007.py:7:3 | 5 | # TODO(evanrittenhouse):this has no space after a colon 6 | # TODO (evanrittenhouse):this doesn't either 7 | # TODO:neither does this - | ^^^^ TD007 + | ^^^^ 8 | # FIXME:and lastly neither does this 9 | # foo # TODO:this is really the last one | -TD007.py:8:3: TD007 Missing space after colon in TODO +TD007 Missing space after colon in TODO + --> TD007.py:8:3 | 6 | # TODO (evanrittenhouse):this doesn't either 7 | # TODO:neither does this 8 | # FIXME:and lastly neither does this - | ^^^^^ TD007 + | ^^^^^ 9 | # foo # TODO:this is really the last one 10 | # TODO this colon doesn't terminate the tag, so don't check it. https://www.google.com | -TD007.py:9:9: TD007 Missing space after colon in TODO +TD007 Missing space after colon in TODO + --> TD007.py:9:9 | 7 | # TODO:neither does this 8 | # FIXME:and lastly neither does this 9 | # foo # TODO:this is really the last one - | ^^^^ TD007 + | ^^^^ 10 | # TODO this colon doesn't terminate the tag, so don't check it. https://www.google.com | diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap index 5c941c0c12..c502cfd8e0 100644 --- a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap @@ -1,40 +1,43 @@ --- source: crates/ruff_linter/src/rules/flake8_todos/mod.rs -snapshot_kind: text --- -TD002.py:11:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` +TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` + --> TD002.py:11:3 | 9 | # TODO @mayrholu and more: this has an author 10 | # T002 - errors 11 | # TODO: this has no author - | ^^^^ TD002 + | ^^^^ 12 | # FIXME: neither does this 13 | # TODO : and neither does this | -TD002.py:12:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` +TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` + --> TD002.py:12:3 | 10 | # T002 - errors 11 | # TODO: this has no author 12 | # FIXME: neither does this - | ^^^^^ TD002 + | ^^^^^ 13 | # TODO : and neither does this 14 | # foo # TODO: this doesn't either | -TD002.py:13:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` +TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` + --> TD002.py:13:3 | 11 | # TODO: this has no author 12 | # FIXME: neither does this 13 | # TODO : and neither does this - | ^^^^ TD002 + | ^^^^ 14 | # foo # TODO: this doesn't either | -TD002.py:14:9: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` +TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` + --> TD002.py:14:9 | 12 | # FIXME: neither does this 13 | # TODO : and neither does this 14 | # foo # TODO: this doesn't either - | ^^^^ TD002 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap index 6b10dd8618..c7a23dc658 100644 --- a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap @@ -1,50 +1,54 @@ --- source: crates/ruff_linter/src/rules/flake8_todos/mod.rs -snapshot_kind: text --- -TD004.py:4:3: TD004 Missing colon in TODO +TD004 Missing colon in TODO + --> TD004.py:4:3 | 2 | # TODO(evanrittenhouse): this has a colon 3 | # T004 - errors 4 | # TODO this has no colon - | ^^^^ TD004 + | ^^^^ 5 | # TODO(evanrittenhouse 😀) this has no colon 6 | # FIXME add a colon | -TD004.py:5:3: TD004 Missing colon in TODO +TD004 Missing colon in TODO + --> TD004.py:5:3 | 3 | # T004 - errors 4 | # TODO this has no colon 5 | # TODO(evanrittenhouse 😀) this has no colon - | ^^^^ TD004 + | ^^^^ 6 | # FIXME add a colon 7 | # foo # TODO add a colon | -TD004.py:6:3: TD004 Missing colon in TODO +TD004 Missing colon in TODO + --> TD004.py:6:3 | 4 | # TODO this has no colon 5 | # TODO(evanrittenhouse 😀) this has no colon 6 | # FIXME add a colon - | ^^^^^ TD004 + | ^^^^^ 7 | # foo # TODO add a colon 8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com | -TD004.py:7:9: TD004 Missing colon in TODO +TD004 Missing colon in TODO + --> TD004.py:7:9 | 5 | # TODO(evanrittenhouse 😀) this has no colon 6 | # FIXME add a colon 7 | # foo # TODO add a colon - | ^^^^ TD004 + | ^^^^ 8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com | -TD004.py:8:3: TD004 Missing colon in TODO +TD004 Missing colon in TODO + --> TD004.py:8:3 | 6 | # FIXME add a colon 7 | # foo # TODO add a colon 8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com - | ^^^^ TD004 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap index 861fd96e8c..47f392f447 100644 --- a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap @@ -1,40 +1,43 @@ --- source: crates/ruff_linter/src/rules/flake8_todos/mod.rs -snapshot_kind: text --- -TD005.py:4:3: TD005 Missing issue description after `TODO` +TD005 Missing issue description after `TODO` + --> TD005.py:4:3 | 2 | # TODO(evanrittenhouse): this has text, while the errors do not 3 | # T005 - errors 4 | # TODO(evanrittenhouse): - | ^^^^ TD005 + | ^^^^ 5 | # TODO(evanrittenhouse) 6 | # FIXME | -TD005.py:5:3: TD005 Missing issue description after `TODO` +TD005 Missing issue description after `TODO` + --> TD005.py:5:3 | 3 | # T005 - errors 4 | # TODO(evanrittenhouse): 5 | # TODO(evanrittenhouse) - | ^^^^ TD005 + | ^^^^ 6 | # FIXME 7 | # foo # TODO | -TD005.py:6:3: TD005 Missing issue description after `TODO` +TD005 Missing issue description after `TODO` + --> TD005.py:6:3 | 4 | # TODO(evanrittenhouse): 5 | # TODO(evanrittenhouse) 6 | # FIXME - | ^^^^^ TD005 + | ^^^^^ 7 | # foo # TODO | -TD005.py:7:9: TD005 Missing issue description after `TODO` +TD005 Missing issue description after `TODO` + --> TD005.py:7:9 | 5 | # TODO(evanrittenhouse) 6 | # FIXME 7 | # foo # TODO - | ^^^^ TD005 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap index 2b7e00d4c8..6786d440b6 100644 --- a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap @@ -1,58 +1,64 @@ --- source: crates/ruff_linter/src/rules/flake8_todos/mod.rs --- -TD003.py:15:3: TD003 Missing issue link for this TODO +TD003 Missing issue link for this TODO + --> TD003.py:15:3 | 14 | # TDO003 - errors 15 | # TODO: this comment has no - | ^^^^ TD003 + | ^^^^ 16 | # link after it | -TD003.py:18:3: TD003 Missing issue link for this TODO +TD003 Missing issue link for this TODO + --> TD003.py:18:3 | 16 | # link after it 17 | 18 | # TODO: here's a TODO with no link after it - | ^^^^ TD003 + | ^^^^ 19 | def foo(x): 20 | return x | -TD003.py:31:3: TD003 Missing issue link for this TODO +TD003 Missing issue link for this TODO + --> TD003.py:31:3 | 29 | # TDO-3870 30 | 31 | # TODO: here's a TODO without an issue link - | ^^^^ TD003 + | ^^^^ 32 | # TODO: followed by a new TODO with an issue link 33 | # TDO-3870 | -TD003.py:35:9: TD003 Missing issue link for this TODO +TD003 Missing issue link for this TODO + --> TD003.py:35:9 | 33 | # TDO-3870 34 | 35 | # foo # TODO: no link! - | ^^^^ TD003 + | ^^^^ 36 | 37 | # TODO: https://github.com/astral-sh/ruff/pull/9627 A todo with a link on the same line | -TD003.py:41:3: TD003 Missing issue link for this TODO +TD003 Missing issue link for this TODO + --> TD003.py:41:3 | 39 | # TODO: #9627 A todo with a number on the same line 40 | 41 | # TODO: A todo with a random number, 5431 - | ^^^^ TD003 + | ^^^^ 42 | 43 | # TODO: here's a TODO on the last line with no link | -TD003.py:43:3: TD003 Missing issue link for this TODO +TD003 Missing issue link for this TODO + --> TD003.py:43:3 | 41 | # TODO: A todo with a random number, 5431 42 | 43 | # TODO: here's a TODO on the last line with no link - | ^^^^ TD003 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001-TC002-TC003_TC001-3_future.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001-TC002-TC003_TC001-3_future.py.snap index 9db86ba0f6..4dbb82a063 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001-TC002-TC003_TC001-3_future.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001-TC002-TC003_TC001-3_future.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC001-3_future.py:1:25: TC003 [*] Move standard library import `collections.Counter` into a type-checking block +TC003 [*] Move standard library import `collections.Counter` into a type-checking block + --> TC001-3_future.py:1:25 | 1 | from collections import Counter - | ^^^^^^^ TC003 + | ^^^^^^^ 2 | 3 | from elsewhere import third_party | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |-from collections import Counter @@ -25,16 +26,17 @@ TC001-3_future.py:1:25: TC003 [*] Move standard library import `collections.Coun 7 11 | 8 12 | def f(x: first_party.foo): ... -TC001-3_future.py:3:23: TC002 [*] Move third-party import `elsewhere.third_party` into a type-checking block +TC002 [*] Move third-party import `elsewhere.third_party` into a type-checking block + --> TC001-3_future.py:3:23 | 1 | from collections import Counter 2 | 3 | from elsewhere import third_party - | ^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^ 4 | 5 | from . import first_party | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from __future__ import annotations @@ -51,14 +53,15 @@ TC001-3_future.py:3:23: TC002 [*] Move third-party import `elsewhere.third_party 7 11 | 8 12 | def f(x: first_party.foo): ... -TC001-3_future.py:5:15: TC001 [*] Move application import `.first_party` into a type-checking block +TC001 [*] Move application import `.first_party` into a type-checking block + --> TC001-3_future.py:5:15 | 3 | from elsewhere import third_party 4 | 5 | from . import first_party - | ^^^^^^^^^^^ TC001 + | ^^^^^^^^^^^ | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001.py.snap index cc9d12d169..f9b554bbbc 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC001.py:20:19: TC001 [*] Move application import `.TYP001` into a type-checking block +TC001 [*] Move application import `.TYP001` into a type-checking block + --> TC001.py:20:19 | 19 | def f(): 20 | from . import TYP001 - | ^^^^^^ TC001 + | ^^^^^^ 21 | 22 | x: TYP001 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001_future.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001_future.py.snap index 0ecb18cd62..b775c34e96 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001_future.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001_future.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC001_future.py:2:19: TC001 [*] Move application import `.first_party` into a type-checking block +TC001 [*] Move application import `.first_party` into a type-checking block + --> TC001_future.py:2:19 | 1 | def f(): 2 | from . import first_party - | ^^^^^^^^^^^ TC001 + | ^^^^^^^^^^^ 3 | 4 | def f(x: first_party.foo): ... | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |-def f(): @@ -23,15 +24,16 @@ TC001_future.py:2:19: TC001 [*] Move application import `.first_party` into a ty 4 8 | def f(x: first_party.foo): ... 5 9 | -TC001_future.py:57:19: TC001 [*] Move application import `.foo` into a type-checking block +TC001 [*] Move application import `.foo` into a type-checking block + --> TC001_future.py:57:19 | 56 | def n(): 57 | from . import foo - | ^^^ TC001 + | ^^^ 58 | 59 | def f(x: Union[foo.Ty, int]): ... | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001_future_present.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001_future_present.py.snap index 0f6d0b7388..b3105c9e1f 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001_future_present.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC001_TC001_future_present.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC001_future_present.py:3:15: TC001 [*] Move application import `.first_party` into a type-checking block +TC001 [*] Move application import `.first_party` into a type-checking block + --> TC001_future_present.py:3:15 | 1 | from __future__ import annotations 2 | 3 | from . import first_party - | ^^^^^^^^^^^ TC001 + | ^^^^^^^^^^^ | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC002_TC002.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC002_TC002.py.snap index 3b34f3141c..f060bd6715 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC002_TC002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC002_TC002.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC002.py:5:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> TC002.py:5:22 | 4 | def f(): 5 | import pandas as pd # TC002 - | ^^ TC002 + | ^^ 6 | 7 | x: pd.DataFrame | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -25,15 +26,16 @@ TC002.py:5:22: TC002 [*] Move third-party import `pandas` into a type-checking b 7 10 | x: pd.DataFrame 8 11 | -TC002.py:11:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> TC002.py:11:24 | 10 | def f(): 11 | from pandas import DataFrame # TC002 - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 12 | 13 | x: DataFrame | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -53,15 +55,16 @@ TC002.py:11:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 13 16 | x: DataFrame 14 17 | -TC002.py:17:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> TC002.py:17:37 | 16 | def f(): 17 | from pandas import DataFrame as df # TC002 - | ^^ TC002 + | ^^ 18 | 19 | x: df | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -81,15 +84,16 @@ TC002.py:17:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type 19 22 | x: df 20 23 | -TC002.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> TC002.py:23:22 | 22 | def f(): 23 | import pandas as pd # TC002 - | ^^ TC002 + | ^^ 24 | 25 | x: pd.DataFrame = 1 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -109,15 +113,16 @@ TC002.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking 25 28 | x: pd.DataFrame = 1 26 29 | -TC002.py:29:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> TC002.py:29:24 | 28 | def f(): 29 | from pandas import DataFrame # TC002 - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 30 | 31 | x: DataFrame = 2 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -137,15 +142,16 @@ TC002.py:29:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 31 34 | x: DataFrame = 2 32 35 | -TC002.py:35:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> TC002.py:35:37 | 34 | def f(): 35 | from pandas import DataFrame as df # TC002 - | ^^ TC002 + | ^^ 36 | 37 | x: df = 3 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -165,15 +171,16 @@ TC002.py:35:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type 37 40 | x: df = 3 38 41 | -TC002.py:41:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> TC002.py:41:22 | 40 | def f(): 41 | import pandas as pd # TC002 - | ^^ TC002 + | ^^ 42 | 43 | x: "pd.DataFrame" = 1 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -193,15 +200,16 @@ TC002.py:41:22: TC002 [*] Move third-party import `pandas` into a type-checking 43 46 | x: "pd.DataFrame" = 1 44 47 | -TC002.py:47:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> TC002.py:47:22 | 46 | def f(): 47 | import pandas as pd # TC002 - | ^^ TC002 + | ^^ 48 | 49 | x = dict["pd.DataFrame", "pd.DataFrame"] | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -221,16 +229,17 @@ TC002.py:47:22: TC002 [*] Move third-party import `pandas` into a type-checking 49 52 | x = dict["pd.DataFrame", "pd.DataFrame"] 50 53 | -TC002.py:172:24: TC002 [*] Move third-party import `module.Member` into a type-checking block +TC002 [*] Move third-party import `module.Member` into a type-checking block + --> TC002.py:172:24 | 170 | global Member 171 | 172 | from module import Member - | ^^^^^^ TC002 + | ^^^^^^ 173 | 174 | x: Member = 1 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC003_TC003.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC003_TC003.py.snap index e7590ea5c2..90bd90e695 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC003_TC003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__add_future_import__TC003_TC003.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC003.py:8:12: TC003 [*] Move standard library import `os` into a type-checking block +TC003 [*] Move standard library import `os` into a type-checking block + --> TC003.py:8:12 | 7 | def f(): 8 | import os - | ^^ TC003 + | ^^ 9 | 10 | x: os | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TC005.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TC005.py.snap index 5486cdfa4c..169c38f1ad 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TC005.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TC005.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC005.py:4:5: TC005 [*] Found empty type-checking block +TC005 [*] Found empty type-checking block + --> TC005.py:4:5 | 3 | if TYPE_CHECKING: 4 | pass # TC005 - | ^^^^ TC005 + | ^^^^ | - = help: Delete empty type-checking block +help: Delete empty type-checking block ℹ Safe fix 1 1 | from typing import TYPE_CHECKING, List @@ -18,15 +19,16 @@ TC005.py:4:5: TC005 [*] Found empty type-checking block 6 4 | 7 5 | def example(): -TC005.py:9:9: TC005 [*] Found empty type-checking block +TC005 [*] Found empty type-checking block + --> TC005.py:9:9 | 7 | def example(): 8 | if TYPE_CHECKING: 9 | pass # TC005 - | ^^^^ TC005 + | ^^^^ 10 | return | - = help: Delete empty type-checking block +help: Delete empty type-checking block ℹ Safe fix 5 5 | @@ -38,15 +40,16 @@ TC005.py:9:9: TC005 [*] Found empty type-checking block 11 9 | 12 10 | -TC005.py:15:9: TC005 [*] Found empty type-checking block +TC005 [*] Found empty type-checking block + --> TC005.py:15:9 | 13 | class Test: 14 | if TYPE_CHECKING: 15 | pass # TC005 - | ^^^^ TC005 + | ^^^^ 16 | x = 2 | - = help: Delete empty type-checking block +help: Delete empty type-checking block ℹ Safe fix 11 11 | @@ -58,15 +61,16 @@ TC005.py:15:9: TC005 [*] Found empty type-checking block 17 15 | 18 16 | -TC005.py:31:5: TC005 [*] Found empty type-checking block +TC005 [*] Found empty type-checking block + --> TC005.py:31:5 | 30 | if TYPE_CHECKING: 31 | pass # TC005 - | ^^^^ TC005 + | ^^^^ 32 | 33 | # https://github.com/astral-sh/ruff/issues/11368 | - = help: Delete empty type-checking block +help: Delete empty type-checking block ℹ Safe fix 27 27 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap index 8681340443..013562d793 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -exempt_modules.py:14:12: TC002 [*] Move third-party import `flask` into a type-checking block +TC002 [*] Move third-party import `flask` into a type-checking block + --> exempt_modules.py:14:12 | 13 | def f(): 14 | import flask - | ^^^^^ TC002 + | ^^^^^ 15 | 16 | x: flask | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__github_issue_15681_fix_test.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__github_issue_15681_fix_test.snap index 86bb647a61..bf88fa10a8 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__github_issue_15681_fix_test.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__github_issue_15681_fix_test.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:4:8: TC003 [*] Move standard library import `pathlib` into a type-checking block +TC003 [*] Move standard library import `pathlib` into a type-checking block + --> :4:8 | 2 | from __future__ import annotations 3 | 4 | import pathlib # TC003 - | ^^^^^^^ TC003 + | ^^^^^^^ 5 | 6 | TYPE_CHECKING = False | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from.snap index d289137f6e..38f00f2e07 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -:5:5: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> :5:5 | 4 | from pandas import ( 5 | DataFrame, # DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 6 | Series, # Series 7 | ) | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from_type_checking_block.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from_type_checking_block.snap index 2d61a1e9c9..57b5fc2893 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from_type_checking_block.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from_type_checking_block.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -:7:5: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> :7:5 | 6 | from pandas import ( 7 | DataFrame, # DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 8 | Series, # Series 9 | ) | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 4 4 | from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_members.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_members.snap index 718590d0fb..23b306e112 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_members.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_members.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -:7:5: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> :7:5 | 6 | from pandas import ( 7 | DataFrame, # DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 8 | Series, # Series 9 | ) | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | @@ -30,15 +30,16 @@ snapshot_kind: text 11 13 | def f(x: DataFrame, y: Series): 12 14 | pass -:8:5: TC002 [*] Move third-party import `pandas.Series` into a type-checking block +TC002 [*] Move third-party import `pandas.Series` into a type-checking block + --> :8:5 | 6 | from pandas import ( 7 | DataFrame, # DataFrame 8 | Series, # Series - | ^^^^^^ TC002 + | ^^^^^^ 9 | ) | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap index 2e46ea78ae..b0fae941ba 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:8: TC003 [*] Move standard library import `os` into a type-checking block +TC003 [*] Move standard library import `os` into a type-checking block + --> :6:8 | 4 | from typing import TYPE_CHECKING 5 | 6 | import os, pandas - | ^^ TC003 + | ^^ 7 | 8 | def f(x: os, y: pandas): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | @@ -25,16 +26,17 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 11 | def f(x: os, y: pandas): 9 12 | pass -:6:12: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> :6:12 | 4 | from typing import TYPE_CHECKING 5 | 6 | import os, pandas - | ^^^^^^ TC002 + | ^^^^^^ 7 | 8 | def f(x: os, y: pandas): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap index 4b1eeaaeb9..fe26ff1dcd 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:8: TC003 [*] Move standard library import `os` into a type-checking block +TC003 [*] Move standard library import `os` into a type-checking block + --> :6:8 | 4 | from typing import TYPE_CHECKING 5 | 6 | import os, sys - | ^^ TC003 + | ^^ 7 | 8 | def f(x: os, y: sys): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | @@ -24,16 +25,17 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 8 10 | def f(x: os, y: sys): 9 11 | pass -:6:12: TC003 [*] Move standard library import `sys` into a type-checking block +TC003 [*] Move standard library import `sys` into a type-checking block + --> :6:12 | 4 | from typing import TYPE_CHECKING 5 | 6 | import os, sys - | ^^^ TC003 + | ^^^ 7 | 8 | def f(x: os, y: sys): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap index 5b14c673f9..6861baaee0 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:4:18: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> :4:18 | 2 | from __future__ import annotations 3 | 4 | import pandas as pd - | ^^ TC002 + | ^^ 5 | 6 | def f(x: pd.DataFrame): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__pre_py310_quoted-type-alias_TC008_union_syntax_pre_py310.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__pre_py310_quoted-type-alias_TC008_union_syntax_pre_py310.py.snap index 3d1c97799b..7943a3d635 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__pre_py310_quoted-type-alias_TC008_union_syntax_pre_py310.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__pre_py310_quoted-type-alias_TC008_union_syntax_pre_py310.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC008_union_syntax_pre_py310.py:10:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_union_syntax_pre_py310.py:10:20 | 8 | if TYPE_CHECKING: 9 | c: TypeAlias = 'int | None' # OK 10 | d: TypeAlias = 'Annotated[int, 1 | 2]' # TC008 - | ^^^^^^^^^^^^^^^^^^^^^^^ TC008 + | ^^^^^^^^^^^^^^^^^^^^^^^ 11 | e: TypeAlias = 'Annotated[int, 1 + 2]' # TC008 12 | f: TypeAlias = 'dict[str, int | None]' # OK | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 7 7 | @@ -21,15 +22,16 @@ TC008_union_syntax_pre_py310.py:10:20: TC008 [*] Remove quotes from type alias 11 11 | e: TypeAlias = 'Annotated[int, 1 + 2]' # TC008 12 12 | f: TypeAlias = 'dict[str, int | None]' # OK -TC008_union_syntax_pre_py310.py:11:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_union_syntax_pre_py310.py:11:20 | 9 | c: TypeAlias = 'int | None' # OK 10 | d: TypeAlias = 'Annotated[int, 1 | 2]' # TC008 11 | e: TypeAlias = 'Annotated[int, 1 + 2]' # TC008 - | ^^^^^^^^^^^^^^^^^^^^^^^ TC008 + | ^^^^^^^^^^^^^^^^^^^^^^^ 12 | f: TypeAlias = 'dict[str, int | None]' # OK | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 8 8 | if TYPE_CHECKING: diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap index 658646b7c2..24cd5aa546 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_runtime-import-in-type-checking-block_quote.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -quote.py:57:28: TC004 [*] Quote references to `pandas.DataFrame`. Import is in a type-checking block. +TC004 [*] Quote references to `pandas.DataFrame`. Import is in a type-checking block. + --> quote.py:57:28 | 56 | if TYPE_CHECKING: 57 | from pandas import DataFrame - | ^^^^^^^^^ TC004 + | ^^^^^^^^^ 58 | 59 | def func(value: DataFrame): | - = help: Quote references +help: Quote references ℹ Unsafe fix 56 56 | if TYPE_CHECKING: @@ -21,15 +22,16 @@ quote.py:57:28: TC004 [*] Quote references to `pandas.DataFrame`. Import is in a 61 61 | 62 62 | -quote.py:110:28: TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting. + --> quote.py:110:28 | 109 | if TYPE_CHECKING: 110 | from pandas import DataFrame - | ^^^^^^^^^ TC004 + | ^^^^^^^^^ 111 | 112 | x: TypeAlias = DataFrame | None | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 |+from pandas import DataFrame diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap index 89ab3746f0..452c839561 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -quote.py:2:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> quote.py:2:24 | 1 | def f(): 2 | from pandas import DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 3 | 4 | def baz() -> DataFrame: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |-def f(): @@ -25,15 +26,16 @@ quote.py:2:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type- 6 9 | 7 10 | -quote.py:9:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> quote.py:9:24 | 8 | def f(): 9 | from pandas import DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 10 | 11 | def baz() -> DataFrame[int]: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -55,15 +57,16 @@ quote.py:9:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type- 13 16 | 14 17 | -quote.py:16:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> quote.py:16:22 | 15 | def f(): 16 | import pandas as pd - | ^^ TC002 + | ^^ 17 | 18 | def baz() -> pd.DataFrame: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -85,15 +88,16 @@ quote.py:16:22: TC002 [*] Move third-party import `pandas` into a type-checking 20 23 | 21 24 | -quote.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> quote.py:23:22 | 22 | def f(): 23 | import pandas as pd - | ^^ TC002 + | ^^ 24 | 25 | def baz() -> pd.DataFrame.Extra: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -115,15 +119,16 @@ quote.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking 27 30 | 28 31 | -quote.py:30:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> quote.py:30:22 | 29 | def f(): 30 | import pandas as pd - | ^^ TC002 + | ^^ 31 | 32 | def baz() -> pd.DataFrame | int: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -145,15 +150,16 @@ quote.py:30:22: TC002 [*] Move third-party import `pandas` into a type-checking 34 37 | 35 38 | -quote.py:38:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> quote.py:38:24 | 37 | def f(): 38 | from pandas import DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 39 | 40 | def baz() -> DataFrame(): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -175,16 +181,17 @@ quote.py:38:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 42 45 | 43 46 | -quote.py:47:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> quote.py:47:24 | 45 | from typing import Literal 46 | 47 | from pandas import DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 48 | 49 | def baz() -> DataFrame[Literal["int"]]: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -206,15 +213,16 @@ quote.py:47:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 51 54 | 52 55 | -quote.py:64:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> quote.py:64:24 | 63 | def f(): 64 | from pandas import DataFrame, Series - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 65 | 66 | def baz() -> DataFrame | Series: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -236,15 +244,16 @@ quote.py:64:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 68 71 | 69 72 | -quote.py:64:35: TC002 [*] Move third-party import `pandas.Series` into a type-checking block +TC002 [*] Move third-party import `pandas.Series` into a type-checking block + --> quote.py:64:35 | 63 | def f(): 64 | from pandas import DataFrame, Series - | ^^^^^^ TC002 + | ^^^^^^ 65 | 66 | def baz() -> DataFrame | Series: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -266,15 +275,16 @@ quote.py:64:35: TC002 [*] Move third-party import `pandas.Series` into a type-ch 68 71 | 69 72 | -quote.py:71:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> quote.py:71:24 | 70 | def f(): 71 | from pandas import DataFrame, Series - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 72 | 73 | def baz() -> ( | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -309,15 +319,16 @@ quote.py:71:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 86 86 | 87 87 | -quote.py:71:35: TC002 [*] Move third-party import `pandas.Series` into a type-checking block +TC002 [*] Move third-party import `pandas.Series` into a type-checking block + --> quote.py:71:35 | 70 | def f(): 71 | from pandas import DataFrame, Series - | ^^^^^^ TC002 + | ^^^^^^ 72 | 73 | def baz() -> ( | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -352,15 +363,16 @@ quote.py:71:35: TC002 [*] Move third-party import `pandas.Series` into a type-ch 86 86 | 87 87 | -quote.py:89:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> quote.py:89:24 | 88 | def f(): 89 | from pandas import DataFrame, Series - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 90 | 91 | def func(self) -> DataFrame | list[Series]: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -382,15 +394,16 @@ quote.py:89:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 93 96 | 94 97 | -quote.py:89:35: TC002 [*] Move third-party import `pandas.Series` into a type-checking block +TC002 [*] Move third-party import `pandas.Series` into a type-checking block + --> quote.py:89:35 | 88 | def f(): 89 | from pandas import DataFrame, Series - | ^^^^^^ TC002 + | ^^^^^^ 90 | 91 | def func(self) -> DataFrame | list[Series]: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote2.py.snap index 747fe681cc..3cb135c374 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote2.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -quote2.py:2:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:2:44 | 1 | def f(): 2 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 3 | 4 | def test_remove_inner_quotes_double(self, user: AbstractBaseUser["int"]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |-def f(): @@ -25,15 +26,16 @@ quote2.py:2:44: TC002 [*] Move third-party import `django.contrib.auth.models.Ab 6 9 | 7 10 | -quote2.py:9:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:9:44 | 8 | def f(): 9 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 10 | 11 | def test_remove_inner_quotes_single(self, user: AbstractBaseUser['int']): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -55,15 +57,16 @@ quote2.py:9:44: TC002 [*] Move third-party import `django.contrib.auth.models.Ab 13 16 | 14 17 | -quote2.py:16:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:16:44 | 15 | def f(): 16 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 17 | 18 | def test_remove_inner_quotes_mixed(self, user: AbstractBaseUser['int', "str"]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -85,16 +88,17 @@ quote2.py:16:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 20 23 | 21 24 | -quote2.py:25:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:25:44 | 23 | from typing import Annotated, Literal 24 | 25 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 26 | 27 | def test_literal_annotation_args_contain_quotes(self, type1: AbstractBaseUser[Literal["user", "admin"], Annotated["int", "1", 2]]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -116,16 +120,17 @@ quote2.py:25:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 29 32 | 30 33 | -quote2.py:34:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:34:44 | 32 | from typing import Literal 33 | 34 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 35 | 36 | def test_union_contain_inner_quotes(self, type1: AbstractBaseUser["int" | Literal["int"]]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -147,16 +152,17 @@ quote2.py:34:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 38 41 | 39 42 | -quote2.py:43:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:43:44 | 41 | from typing import Literal 42 | 43 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 44 | 45 | def test_inner_literal_mixed_quotes(user: AbstractBaseUser[Literal['user', "admin"]]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -178,16 +184,17 @@ quote2.py:43:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 47 50 | 48 51 | -quote2.py:52:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:52:44 | 50 | from typing import Literal 51 | 52 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 53 | 54 | def test_inner_literal_single_quote(user: AbstractBaseUser[Literal['int'], str]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -209,16 +216,17 @@ quote2.py:52:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 56 59 | 57 60 | -quote2.py:61:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:61:44 | 59 | from typing import Literal 60 | 61 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 62 | 63 | def test_mixed_quotes_literal(user: AbstractBaseUser[Literal['user'], "int"]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -240,16 +248,17 @@ quote2.py:61:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 65 68 | 66 69 | -quote2.py:70:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote2.py:70:44 | 68 | from typing import Annotated, Literal 69 | 70 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 71 | 72 | def test_annotated_literal_mixed_quotes(user: AbstractBaseUser[Annotated[str, "max_length=20", Literal['user', "admin"]]]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote3.py.snap index 8e70e33c74..61e7ae28ed 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quote_typing-only-third-party-import_quote3.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -quote3.py:4:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote3.py:4:44 | 2 | from typing import Literal, Union 3 | 4 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 5 | 6 | def test_union_literal_mixed_quotes(user: AbstractBaseUser[Union[Literal['active', "inactive"], str]]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -28,16 +29,17 @@ quote3.py:4:44: TC002 [*] Move third-party import `django.contrib.auth.models.Ab 8 11 | 9 12 | -quote3.py:13:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote3.py:13:44 | 11 | from typing import Callable, Literal 12 | 13 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 14 | 15 | def test_callable_literal_mixed_quotes(callable_fn: AbstractBaseUser[Callable[["int", Literal['admin', "user"]], 'bool']]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -59,16 +61,17 @@ quote3.py:13:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 17 20 | 18 21 | -quote3.py:22:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block + --> quote3.py:22:44 | 20 | from typing import Annotated, Callable, Literal 21 | 22 | from django.contrib.auth.models import AbstractBaseUser - | ^^^^^^^^^^^^^^^^ TC002 + | ^^^^^^^^^^^^^^^^ 23 | 24 | def test_callable_annotated_literal(callable_fn: AbstractBaseUser[Callable[[int, Annotated[str, Literal['active', "inactive"]]], b… | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -90,16 +93,17 @@ quote3.py:22:44: TC002 [*] Move third-party import `django.contrib.auth.models.A 26 29 | 27 30 | -quote3.py:31:37: TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block + --> quote3.py:31:37 | 29 | from typing import literal 30 | 31 | from django.contrib.auth import models - | ^^^^^^ TC002 + | ^^^^^^ 32 | 33 | def test_attribute(arg: models.AbstractBaseUser["int"]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -121,16 +125,17 @@ quote3.py:31:37: TC002 [*] Move third-party import `django.contrib.auth.models` 35 38 | 36 39 | -quote3.py:40:37: TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block +TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block + --> quote3.py:40:37 | 38 | from typing import Literal 39 | 40 | from django.contrib.auth import models - | ^^^^^^ TC002 + | ^^^^^^ 41 | 42 | def test_attribute_typing_literal(arg: models.AbstractBaseUser[Literal["admin"]]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -152,16 +157,17 @@ quote3.py:40:37: TC002 [*] Move third-party import `django.contrib.auth.models` 44 47 | 45 48 | -quote3.py:59:29: TC002 [*] Move third-party import `third_party.Type` into a type-checking block +TC002 [*] Move third-party import `third_party.Type` into a type-checking block + --> quote3.py:59:29 | 57 | def f(): 58 | from typing import Literal 59 | from third_party import Type - | ^^^^ TC002 + | ^^^^ 60 | 61 | def test_string_contains_opposite_quote(self, type1: Type[Literal["'"]], type2: Type[Literal["\'"]]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING @@ -183,16 +189,17 @@ quote3.py:59:29: TC002 [*] Move third-party import `third_party.Type` into a typ 63 66 | 64 67 | -quote3.py:67:29: TC002 [*] Move third-party import `third_party.Type` into a type-checking block +TC002 [*] Move third-party import `third_party.Type` into a type-checking block + --> quote3.py:67:29 | 65 | def f(): 66 | from typing import Literal 67 | from third_party import Type - | ^^^^ TC002 + | ^^^^ 68 | 69 | def test_quote_contains_backslash(self, type1: Type[Literal["\n"]], type2: Type[Literal["\""]]): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 |+from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008.py.snap index b55796e607..bc584f9775 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC008.py:15:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:15:16 | 13 | Bar = Foo 14 | 15 | a: TypeAlias = 'int' # TC008 - | ^^^^^ TC008 + | ^^^^^ 16 | b: TypeAlias = 'Dict' # OK 17 | c: TypeAlias = 'Foo' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 12 12 | else: @@ -22,16 +23,17 @@ TC008.py:15:16: TC008 [*] Remove quotes from type alias 17 17 | c: TypeAlias = 'Foo' # TC008 18 18 | d: TypeAlias = 'Foo[str]' # OK -TC008.py:17:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:17:16 | 15 | a: TypeAlias = 'int' # TC008 16 | b: TypeAlias = 'Dict' # OK 17 | c: TypeAlias = 'Foo' # TC008 - | ^^^^^ TC008 + | ^^^^^ 18 | d: TypeAlias = 'Foo[str]' # OK 19 | e: TypeAlias = 'Foo.bar' # OK | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 14 14 | @@ -43,16 +45,17 @@ TC008.py:17:16: TC008 [*] Remove quotes from type alias 19 19 | e: TypeAlias = 'Foo.bar' # OK 20 20 | f: TypeAlias = 'Foo | None' # TC008 -TC008.py:20:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:20:16 | 18 | d: TypeAlias = 'Foo[str]' # OK 19 | e: TypeAlias = 'Foo.bar' # OK 20 | f: TypeAlias = 'Foo | None' # TC008 - | ^^^^^^^^^^^^ TC008 + | ^^^^^^^^^^^^ 21 | g: TypeAlias = 'OptStr' # OK 22 | h: TypeAlias = 'Bar' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 17 17 | c: TypeAlias = 'Foo' # TC008 @@ -64,16 +67,17 @@ TC008.py:20:16: TC008 [*] Remove quotes from type alias 22 22 | h: TypeAlias = 'Bar' # TC008 23 23 | i: TypeAlias = Foo['str'] # TC008 -TC008.py:22:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:22:16 | 20 | f: TypeAlias = 'Foo | None' # TC008 21 | g: TypeAlias = 'OptStr' # OK 22 | h: TypeAlias = 'Bar' # TC008 - | ^^^^^ TC008 + | ^^^^^ 23 | i: TypeAlias = Foo['str'] # TC008 24 | j: TypeAlias = 'Baz' # OK | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 19 19 | e: TypeAlias = 'Foo.bar' # OK @@ -85,16 +89,17 @@ TC008.py:22:16: TC008 [*] Remove quotes from type alias 24 24 | j: TypeAlias = 'Baz' # OK 25 25 | k: TypeAlias = 'k | None' # OK -TC008.py:23:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:23:20 | 21 | g: TypeAlias = 'OptStr' # OK 22 | h: TypeAlias = 'Bar' # TC008 23 | i: TypeAlias = Foo['str'] # TC008 - | ^^^^^ TC008 + | ^^^^^ 24 | j: TypeAlias = 'Baz' # OK 25 | k: TypeAlias = 'k | None' # OK | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 20 20 | f: TypeAlias = 'Foo | None' # TC008 @@ -106,16 +111,17 @@ TC008.py:23:20: TC008 [*] Remove quotes from type alias 25 25 | k: TypeAlias = 'k | None' # OK 26 26 | l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) -TC008.py:26:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:26:16 | 24 | j: TypeAlias = 'Baz' # OK 25 | k: TypeAlias = 'k | None' # OK 26 | l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) - | ^^^^^ TC008 + | ^^^^^ 27 | m: TypeAlias = ('int' # TC008 28 | | None) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 23 23 | i: TypeAlias = Foo['str'] # TC008 @@ -127,16 +133,17 @@ TC008.py:26:16: TC008 [*] Remove quotes from type alias 28 28 | | None) 29 29 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) -TC008.py:27:17: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:27:17 | 25 | k: TypeAlias = 'k | None' # OK 26 | l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) 27 | m: TypeAlias = ('int' # TC008 - | ^^^^^ TC008 + | ^^^^^ 28 | | None) 29 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 24 24 | j: TypeAlias = 'Baz' # OK @@ -148,18 +155,19 @@ TC008.py:27:17: TC008 [*] Remove quotes from type alias 29 29 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) 30 30 | ' | None') -TC008.py:29:17: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:29:17 | 27 | m: TypeAlias = ('int' # TC008 28 | | None) 29 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) | _________________^ 30 | | ' | None') - | |_____________^ TC008 + | |_____________^ 31 | 32 | type B = 'Dict' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Unsafe fix 26 26 | l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) @@ -172,16 +180,17 @@ TC008.py:29:17: TC008 [*] Remove quotes from type alias 32 31 | type B = 'Dict' # TC008 33 32 | type D = 'Foo[str]' # TC008 -TC008.py:32:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:32:10 | 30 | ' | None') 31 | 32 | type B = 'Dict' # TC008 - | ^^^^^^ TC008 + | ^^^^^^ 33 | type D = 'Foo[str]' # TC008 34 | type E = 'Foo.bar' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 29 29 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) @@ -193,15 +202,16 @@ TC008.py:32:10: TC008 [*] Remove quotes from type alias 34 34 | type E = 'Foo.bar' # TC008 35 35 | type G = 'OptStr' # TC008 -TC008.py:33:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:33:10 | 32 | type B = 'Dict' # TC008 33 | type D = 'Foo[str]' # TC008 - | ^^^^^^^^^^ TC008 + | ^^^^^^^^^^ 34 | type E = 'Foo.bar' # TC008 35 | type G = 'OptStr' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 30 30 | ' | None') @@ -213,16 +223,17 @@ TC008.py:33:10: TC008 [*] Remove quotes from type alias 35 35 | type G = 'OptStr' # TC008 36 36 | type I = Foo['str'] # TC008 -TC008.py:34:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:34:10 | 32 | type B = 'Dict' # TC008 33 | type D = 'Foo[str]' # TC008 34 | type E = 'Foo.bar' # TC008 - | ^^^^^^^^^ TC008 + | ^^^^^^^^^ 35 | type G = 'OptStr' # TC008 36 | type I = Foo['str'] # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 31 31 | @@ -234,16 +245,17 @@ TC008.py:34:10: TC008 [*] Remove quotes from type alias 36 36 | type I = Foo['str'] # TC008 37 37 | type J = 'Baz' # TC008 -TC008.py:35:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:35:10 | 33 | type D = 'Foo[str]' # TC008 34 | type E = 'Foo.bar' # TC008 35 | type G = 'OptStr' # TC008 - | ^^^^^^^^ TC008 + | ^^^^^^^^ 36 | type I = Foo['str'] # TC008 37 | type J = 'Baz' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 32 32 | type B = 'Dict' # TC008 @@ -255,16 +267,17 @@ TC008.py:35:10: TC008 [*] Remove quotes from type alias 37 37 | type J = 'Baz' # TC008 38 38 | type K = 'K | None' # TC008 -TC008.py:36:14: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:36:14 | 34 | type E = 'Foo.bar' # TC008 35 | type G = 'OptStr' # TC008 36 | type I = Foo['str'] # TC008 - | ^^^^^ TC008 + | ^^^^^ 37 | type J = 'Baz' # TC008 38 | type K = 'K | None' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 33 33 | type D = 'Foo[str]' # TC008 @@ -276,16 +289,17 @@ TC008.py:36:14: TC008 [*] Remove quotes from type alias 38 38 | type K = 'K | None' # TC008 39 39 | type L = 'int' | None # TC008 (because TC010 is not enabled) -TC008.py:37:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:37:10 | 35 | type G = 'OptStr' # TC008 36 | type I = Foo['str'] # TC008 37 | type J = 'Baz' # TC008 - | ^^^^^ TC008 + | ^^^^^ 38 | type K = 'K | None' # TC008 39 | type L = 'int' | None # TC008 (because TC010 is not enabled) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 34 34 | type E = 'Foo.bar' # TC008 @@ -297,16 +311,17 @@ TC008.py:37:10: TC008 [*] Remove quotes from type alias 39 39 | type L = 'int' | None # TC008 (because TC010 is not enabled) 40 40 | type M = ('int' # TC008 -TC008.py:38:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:38:10 | 36 | type I = Foo['str'] # TC008 37 | type J = 'Baz' # TC008 38 | type K = 'K | None' # TC008 - | ^^^^^^^^^^ TC008 + | ^^^^^^^^^^ 39 | type L = 'int' | None # TC008 (because TC010 is not enabled) 40 | type M = ('int' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 35 35 | type G = 'OptStr' # TC008 @@ -318,16 +333,17 @@ TC008.py:38:10: TC008 [*] Remove quotes from type alias 40 40 | type M = ('int' # TC008 41 41 | | None) -TC008.py:39:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:39:10 | 37 | type J = 'Baz' # TC008 38 | type K = 'K | None' # TC008 39 | type L = 'int' | None # TC008 (because TC010 is not enabled) - | ^^^^^ TC008 + | ^^^^^ 40 | type M = ('int' # TC008 41 | | None) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 36 36 | type I = Foo['str'] # TC008 @@ -339,16 +355,17 @@ TC008.py:39:10: TC008 [*] Remove quotes from type alias 41 41 | | None) 42 42 | type N = ('int' # TC008 (fix removes comment currently) -TC008.py:40:11: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:40:11 | 38 | type K = 'K | None' # TC008 39 | type L = 'int' | None # TC008 (because TC010 is not enabled) 40 | type M = ('int' # TC008 - | ^^^^^ TC008 + | ^^^^^ 41 | | None) 42 | type N = ('int' # TC008 (fix removes comment currently) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 37 37 | type J = 'Baz' # TC008 @@ -360,16 +377,17 @@ TC008.py:40:11: TC008 [*] Remove quotes from type alias 42 42 | type N = ('int' # TC008 (fix removes comment currently) 43 43 | ' | None') -TC008.py:42:11: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:42:11 | 40 | type M = ('int' # TC008 41 | | None) 42 | type N = ('int' # TC008 (fix removes comment currently) | ___________^ 43 | | ' | None') - | |_____________^ TC008 + | |_____________^ | - = help: Remove quotes +help: Remove quotes ℹ Unsafe fix 39 39 | type L = 'int' | None # TC008 (because TC010 is not enabled) @@ -382,16 +400,17 @@ TC008.py:42:11: TC008 [*] Remove quotes from type alias 45 44 | 46 45 | class Baz: -TC008.py:48:14: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:48:14 | 46 | class Baz: 47 | a: TypeAlias = 'Baz' # OK 48 | type A = 'Baz' # TC008 - | ^^^^^ TC008 + | ^^^^^ 49 | 50 | class Nested: | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 45 45 | @@ -403,16 +422,17 @@ TC008.py:48:14: TC008 [*] Remove quotes from type alias 50 50 | class Nested: 51 51 | a: TypeAlias = 'Baz' # OK -TC008.py:52:18: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:52:18 | 50 | class Nested: 51 | a: TypeAlias = 'Baz' # OK 52 | type A = 'Baz' # TC008 - | ^^^^^ TC008 + | ^^^^^ 53 | 54 | # O should have parenthesis added | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 49 49 | @@ -424,17 +444,18 @@ TC008.py:52:18: TC008 [*] Remove quotes from type alias 54 54 | # O should have parenthesis added 55 55 | o: TypeAlias = """int -TC008.py:55:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:55:16 | 54 | # O should have parenthesis added 55 | o: TypeAlias = """int | ________________^ 56 | | | None""" - | |_________^ TC008 + | |_________^ 57 | type O = """int 58 | | None""" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 52 52 | type A = 'Baz' # TC008 @@ -448,18 +469,19 @@ TC008.py:55:16: TC008 [*] Remove quotes from type alias 58 58 | | None""" 59 59 | -TC008.py:57:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:57:10 | 55 | o: TypeAlias = """int 56 | | None""" 57 | type O = """int | __________^ 58 | | | None""" - | |_________^ TC008 + | |_________^ 59 | 60 | # P, Q, and R should not have parenthesis added | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 54 54 | # O should have parenthesis added @@ -473,17 +495,18 @@ TC008.py:57:10: TC008 [*] Remove quotes from type alias 60 60 | # P, Q, and R should not have parenthesis added 61 61 | p: TypeAlias = ("""int -TC008.py:61:17: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:61:17 | 60 | # P, Q, and R should not have parenthesis added 61 | p: TypeAlias = ("""int | _________________^ 62 | | | None""") - | |_________^ TC008 + | |_________^ 63 | type P = ("""int 64 | | None""") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 58 58 | | None""" @@ -497,18 +520,19 @@ TC008.py:61:17: TC008 [*] Remove quotes from type alias 64 64 | | None""") 65 65 | -TC008.py:63:11: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:63:11 | 61 | p: TypeAlias = ("""int 62 | | None""") 63 | type P = ("""int | ___________^ 64 | | | None""") - | |_________^ TC008 + | |_________^ 65 | 66 | q: TypeAlias = """(int | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 60 60 | # P, Q, and R should not have parenthesis added @@ -522,18 +546,19 @@ TC008.py:63:11: TC008 [*] Remove quotes from type alias 66 66 | q: TypeAlias = """(int 67 67 | | None)""" -TC008.py:66:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:66:16 | 64 | | None""") 65 | 66 | q: TypeAlias = """(int | ________________^ 67 | | | None)""" - | |__________^ TC008 + | |__________^ 68 | type Q = """(int 69 | | None)""" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 63 63 | type P = ("""int @@ -547,18 +572,19 @@ TC008.py:66:16: TC008 [*] Remove quotes from type alias 69 69 | | None)""" 70 70 | -TC008.py:68:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:68:10 | 66 | q: TypeAlias = """(int 67 | | None)""" 68 | type Q = """(int | __________^ 69 | | | None)""" - | |__________^ TC008 + | |__________^ 70 | 71 | r: TypeAlias = """int | None""" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 65 65 | @@ -572,15 +598,16 @@ TC008.py:68:10: TC008 [*] Remove quotes from type alias 71 71 | r: TypeAlias = """int | None""" 72 72 | type R = """int | None""" -TC008.py:71:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:71:16 | 69 | | None)""" 70 | 71 | r: TypeAlias = """int | None""" - | ^^^^^^^^^^^^^^^^ TC008 + | ^^^^^^^^^^^^^^^^ 72 | type R = """int | None""" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 68 68 | type Q = """(int @@ -590,13 +617,14 @@ TC008.py:71:16: TC008 [*] Remove quotes from type alias 71 |+r: TypeAlias = int | None 72 72 | type R = """int | None""" -TC008.py:72:10: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008.py:72:10 | 71 | r: TypeAlias = """int | None""" 72 | type R = """int | None""" - | ^^^^^^^^^^^^^^^^ TC008 + | ^^^^^^^^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 69 69 | | None)""" diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008_typing_execution_context.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008_typing_execution_context.py.snap index c3b71b50de..9d729f56b3 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008_typing_execution_context.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__quoted-type-alias_TC008_typing_execution_context.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC008_typing_execution_context.py:13:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:13:20 | 11 | Bar: TypeAlias = Foo[int] 12 | 13 | a: TypeAlias = 'int' # TC008 - | ^^^^^ TC008 + | ^^^^^ 14 | b: TypeAlias = 'Dict' # TC008 15 | c: TypeAlias = 'Foo' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 10 10 | OptStr: TypeAlias = str | None @@ -22,15 +23,16 @@ TC008_typing_execution_context.py:13:20: TC008 [*] Remove quotes from type alias 15 15 | c: TypeAlias = 'Foo' # TC008 16 16 | d: TypeAlias = 'Foo[str]' # TC008 -TC008_typing_execution_context.py:14:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:14:20 | 13 | a: TypeAlias = 'int' # TC008 14 | b: TypeAlias = 'Dict' # TC008 - | ^^^^^^ TC008 + | ^^^^^^ 15 | c: TypeAlias = 'Foo' # TC008 16 | d: TypeAlias = 'Foo[str]' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 11 11 | Bar: TypeAlias = Foo[int] @@ -42,16 +44,17 @@ TC008_typing_execution_context.py:14:20: TC008 [*] Remove quotes from type alias 16 16 | d: TypeAlias = 'Foo[str]' # TC008 17 17 | e: TypeAlias = 'Foo.bar' # TC008 -TC008_typing_execution_context.py:15:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:15:20 | 13 | a: TypeAlias = 'int' # TC008 14 | b: TypeAlias = 'Dict' # TC008 15 | c: TypeAlias = 'Foo' # TC008 - | ^^^^^ TC008 + | ^^^^^ 16 | d: TypeAlias = 'Foo[str]' # TC008 17 | e: TypeAlias = 'Foo.bar' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 12 12 | @@ -63,16 +66,17 @@ TC008_typing_execution_context.py:15:20: TC008 [*] Remove quotes from type alias 17 17 | e: TypeAlias = 'Foo.bar' # TC008 18 18 | f: TypeAlias = 'Foo | None' # TC008 -TC008_typing_execution_context.py:16:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:16:20 | 14 | b: TypeAlias = 'Dict' # TC008 15 | c: TypeAlias = 'Foo' # TC008 16 | d: TypeAlias = 'Foo[str]' # TC008 - | ^^^^^^^^^^ TC008 + | ^^^^^^^^^^ 17 | e: TypeAlias = 'Foo.bar' # TC008 18 | f: TypeAlias = 'Foo | None' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 13 13 | a: TypeAlias = 'int' # TC008 @@ -84,16 +88,17 @@ TC008_typing_execution_context.py:16:20: TC008 [*] Remove quotes from type alias 18 18 | f: TypeAlias = 'Foo | None' # TC008 19 19 | g: TypeAlias = 'OptStr' # TC008 -TC008_typing_execution_context.py:17:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:17:20 | 15 | c: TypeAlias = 'Foo' # TC008 16 | d: TypeAlias = 'Foo[str]' # TC008 17 | e: TypeAlias = 'Foo.bar' # TC008 - | ^^^^^^^^^ TC008 + | ^^^^^^^^^ 18 | f: TypeAlias = 'Foo | None' # TC008 19 | g: TypeAlias = 'OptStr' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 14 14 | b: TypeAlias = 'Dict' # TC008 @@ -105,16 +110,17 @@ TC008_typing_execution_context.py:17:20: TC008 [*] Remove quotes from type alias 19 19 | g: TypeAlias = 'OptStr' # TC008 20 20 | h: TypeAlias = 'Bar' # TC008 -TC008_typing_execution_context.py:18:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:18:20 | 16 | d: TypeAlias = 'Foo[str]' # TC008 17 | e: TypeAlias = 'Foo.bar' # TC008 18 | f: TypeAlias = 'Foo | None' # TC008 - | ^^^^^^^^^^^^ TC008 + | ^^^^^^^^^^^^ 19 | g: TypeAlias = 'OptStr' # TC008 20 | h: TypeAlias = 'Bar' # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 15 15 | c: TypeAlias = 'Foo' # TC008 @@ -126,16 +132,17 @@ TC008_typing_execution_context.py:18:20: TC008 [*] Remove quotes from type alias 20 20 | h: TypeAlias = 'Bar' # TC008 21 21 | i: TypeAlias = Foo['str'] # TC008 -TC008_typing_execution_context.py:19:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:19:20 | 17 | e: TypeAlias = 'Foo.bar' # TC008 18 | f: TypeAlias = 'Foo | None' # TC008 19 | g: TypeAlias = 'OptStr' # TC008 - | ^^^^^^^^ TC008 + | ^^^^^^^^ 20 | h: TypeAlias = 'Bar' # TC008 21 | i: TypeAlias = Foo['str'] # TC008 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 16 16 | d: TypeAlias = 'Foo[str]' # TC008 @@ -147,16 +154,17 @@ TC008_typing_execution_context.py:19:20: TC008 [*] Remove quotes from type alias 21 21 | i: TypeAlias = Foo['str'] # TC008 22 22 | j: TypeAlias = 'Baz' # OK (this would be treated as use before define) -TC008_typing_execution_context.py:20:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:20:20 | 18 | f: TypeAlias = 'Foo | None' # TC008 19 | g: TypeAlias = 'OptStr' # TC008 20 | h: TypeAlias = 'Bar' # TC008 - | ^^^^^ TC008 + | ^^^^^ 21 | i: TypeAlias = Foo['str'] # TC008 22 | j: TypeAlias = 'Baz' # OK (this would be treated as use before define) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 17 17 | e: TypeAlias = 'Foo.bar' # TC008 @@ -168,16 +176,17 @@ TC008_typing_execution_context.py:20:20: TC008 [*] Remove quotes from type alias 22 22 | j: TypeAlias = 'Baz' # OK (this would be treated as use before define) 23 23 | k: TypeAlias = 'k | None' # False negative in type checking block -TC008_typing_execution_context.py:21:24: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:21:24 | 19 | g: TypeAlias = 'OptStr' # TC008 20 | h: TypeAlias = 'Bar' # TC008 21 | i: TypeAlias = Foo['str'] # TC008 - | ^^^^^ TC008 + | ^^^^^ 22 | j: TypeAlias = 'Baz' # OK (this would be treated as use before define) 23 | k: TypeAlias = 'k | None' # False negative in type checking block | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 18 18 | f: TypeAlias = 'Foo | None' # TC008 @@ -189,16 +198,17 @@ TC008_typing_execution_context.py:21:24: TC008 [*] Remove quotes from type alias 23 23 | k: TypeAlias = 'k | None' # False negative in type checking block 24 24 | l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) -TC008_typing_execution_context.py:24:20: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:24:20 | 22 | j: TypeAlias = 'Baz' # OK (this would be treated as use before define) 23 | k: TypeAlias = 'k | None' # False negative in type checking block 24 | l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) - | ^^^^^ TC008 + | ^^^^^ 25 | m: TypeAlias = ('int' # TC008 26 | | None) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 21 21 | i: TypeAlias = Foo['str'] # TC008 @@ -210,16 +220,17 @@ TC008_typing_execution_context.py:24:20: TC008 [*] Remove quotes from type alias 26 26 | | None) 27 27 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) -TC008_typing_execution_context.py:25:21: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:25:21 | 23 | k: TypeAlias = 'k | None' # False negative in type checking block 24 | l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) 25 | m: TypeAlias = ('int' # TC008 - | ^^^^^ TC008 + | ^^^^^ 26 | | None) 27 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 22 22 | j: TypeAlias = 'Baz' # OK (this would be treated as use before define) @@ -231,16 +242,17 @@ TC008_typing_execution_context.py:25:21: TC008 [*] Remove quotes from type alias 27 27 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) 28 28 | ' | None') -TC008_typing_execution_context.py:27:21: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> TC008_typing_execution_context.py:27:21 | 25 | m: TypeAlias = ('int' # TC008 26 | | None) 27 | n: TypeAlias = ('int' # TC008 (fix removes comment currently) | _____________________^ 28 | | ' | None') - | |_________________^ TC008 + | |_________________^ | - = help: Remove quotes +help: Remove quotes ℹ Unsafe fix 24 24 | l: TypeAlias = 'int' | None # TC008 (because TC010 is not enabled) diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-cast-value_TC006.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-cast-value_TC006.py.snap index f117c364f7..cb009f96d5 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-cast-value_TC006.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-cast-value_TC006.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC006.py:4:10: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:4:10 | 2 | from typing import cast 3 | 4 | cast(int, 3.0) # TC006 - | ^^^ TC006 + | ^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 1 1 | def f(): @@ -20,14 +21,15 @@ TC006.py:4:10: TC006 [*] Add quotes to type expression in `typing.cast()` 6 6 | 7 7 | def f(): -TC006.py:10:10: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:10:10 | 8 | from typing import cast 9 | 10 | cast(list[tuple[bool | float | int | str]], 3.0) # TC006 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TC006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 7 7 | def f(): @@ -39,14 +41,15 @@ TC006.py:10:10: TC006 [*] Add quotes to type expression in `typing.cast()` 12 12 | 13 13 | def f(): -TC006.py:16:10: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:16:10 | 14 | from typing import Union, cast 15 | 16 | cast(list[tuple[Union[bool, float, int, str]]], 3.0) # TC006 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TC006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 13 13 | def f(): @@ -58,14 +61,15 @@ TC006.py:16:10: TC006 [*] Add quotes to type expression in `typing.cast()` 18 18 | 19 19 | def f(): -TC006.py:40:14: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:40:14 | 38 | from typing import cast as typecast 39 | 40 | typecast(int, 3.0) # TC006 - | ^^^ TC006 + | ^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 37 37 | def f(): @@ -77,14 +81,15 @@ TC006.py:40:14: TC006 [*] Add quotes to type expression in `typing.cast()` 42 42 | 43 43 | def f(): -TC006.py:46:17: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:46:17 | 44 | import typing 45 | 46 | typing.cast(int, 3.0) # TC006 - | ^^^ TC006 + | ^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 43 43 | def f(): @@ -96,14 +101,15 @@ TC006.py:46:17: TC006 [*] Add quotes to type expression in `typing.cast()` 48 48 | 49 49 | def f(): -TC006.py:52:12: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:52:12 | 50 | import typing as t 51 | 52 | t.cast(t.Literal["3.0", '3'], 3.0) # TC006 - | ^^^^^^^^^^^^^^^^^^^^^ TC006 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 49 49 | def f(): @@ -115,16 +121,17 @@ TC006.py:52:12: TC006 [*] Add quotes to type expression in `typing.cast()` 54 54 | 55 55 | def f(): -TC006.py:59:9: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:59:9 | 58 | cast( 59 | / int # TC006 (unsafe, because it will get rid of this comment) 60 | | | None, - | |______________^ TC006 + | |______________^ 61 | 3.0 62 | ) | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 56 56 | from typing import cast @@ -137,14 +144,15 @@ TC006.py:59:9: TC006 [*] Add quotes to type expression in `typing.cast()` 62 61 | ) 63 62 | -TC006.py:68:17: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:68:17 | 66 | # Regression test for #14554 67 | import typing 68 | typing.cast(M-()) - | ^^^^ TC006 + | ^^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 65 65 | def f(): @@ -156,14 +164,15 @@ TC006.py:68:17: TC006 [*] Add quotes to type expression in `typing.cast()` 70 70 | 71 71 | def f(): -TC006.py:75:10: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:75:10 | 73 | from typing import cast, Literal 74 | 75 | cast(Literal["A"], 'A') - | ^^^^^^^^^^^^ TC006 + | ^^^^^^^^^^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 72 72 | # Simple case with Literal that should lead to nested quotes @@ -175,14 +184,15 @@ TC006.py:75:10: TC006 [*] Add quotes to type expression in `typing.cast()` 77 77 | 78 78 | def f(): -TC006.py:82:10: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:82:10 | 80 | from typing import cast, Annotated, Literal 81 | 82 | cast(list[Annotated["list['Literal[\"A\"]']", "Foo"]], ['A']) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TC006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 79 79 | # Really complex case with nested forward references @@ -194,15 +204,16 @@ TC006.py:82:10: TC006 [*] Add quotes to type expression in `typing.cast()` 84 84 | 85 85 | def f(): -TC006.py:89:9: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:89:9 | 88 | cast( 89 | int # TC006 - | ^^^ TC006 + | ^^^ 90 | , 6.0 91 | ) | - = help: Add quotes +help: Add quotes ℹ Safe fix 86 86 | from typing import cast @@ -214,15 +225,16 @@ TC006.py:89:9: TC006 [*] Add quotes to type expression in `typing.cast()` 91 91 | ) 92 92 | -TC006.py:98:14: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:98:14 | 96 | from typing import cast 97 | 98 | cast(typ=int, val=3.0) # TC006 - | ^^^ TC006 + | ^^^ 99 | cast(val=3.0, typ=int) # TC006 | - = help: Add quotes +help: Add quotes ℹ Safe fix 95 95 | # Keyword arguments @@ -232,13 +244,14 @@ TC006.py:98:14: TC006 [*] Add quotes to type expression in `typing.cast()` 98 |+ cast(typ="int", val=3.0) # TC006 99 99 | cast(val=3.0, typ=int) # TC006 -TC006.py:99:23: TC006 [*] Add quotes to type expression in `typing.cast()` +TC006 [*] Add quotes to type expression in `typing.cast()` + --> TC006.py:99:23 | 98 | cast(typ=int, val=3.0) # TC006 99 | cast(val=3.0, typ=int) # TC006 - | ^^^ TC006 + | ^^^ | - = help: Add quotes +help: Add quotes ℹ Safe fix 96 96 | from typing import cast diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_1.py.snap index 9b4d1f4a76..4092c2bc4a 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_1.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -TC004_1.py:4:26: TC004 [*] Move import `datetime.datetime` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `datetime.datetime` out of type-checking block. Import is used for more than type hinting. + --> TC004_1.py:4:26 | 3 | if TYPE_CHECKING: 4 | from datetime import datetime - | ^^^^^^^^ TC004 + | ^^^^^^^^ 5 | x = datetime | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_11.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_11.py.snap index b9858550b2..3d60b335c8 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_11.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_11.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC004_11.py:4:24: TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting. + --> TC004_11.py:4:24 | 3 | if TYPE_CHECKING: 4 | from typing import List - | ^^^^ TC004 + | ^^^^ 5 | 6 | __all__ = ("List",) | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_12.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_12.py.snap index 52ee66998c..8382e0a7a2 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_12.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_12.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC004_12.py:6:33: TC004 [*] Move import `collections.abc.Callable` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `collections.abc.Callable` out of type-checking block. Import is used for more than type hinting. + --> TC004_12.py:6:33 | 5 | if TYPE_CHECKING: 6 | from collections.abc import Callable - | ^^^^^^^^ TC004 + | ^^^^^^^^ 7 | 8 | AnyCallable: TypeAlias = Callable[..., Any] | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_17.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_17.py.snap index 1dd9c839b7..84b0738d53 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_17.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_17.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -TC004_17.py:6:24: TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting. + --> TC004_17.py:6:24 | 5 | if TYPE_CHECKING: 6 | from pandas import DataFrame - | ^^^^^^^^^ TC004 + | ^^^^^^^^^ | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_2.py.snap index 135189e40d..a7c102496f 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_2.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -TC004_2.py:4:26: TC004 [*] Move import `datetime.date` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `datetime.date` out of type-checking block. Import is used for more than type hinting. + --> TC004_2.py:4:26 | 3 | if TYPE_CHECKING: 4 | from datetime import date - | ^^^^ TC004 + | ^^^^ | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_4.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_4.py.snap index 7dfef5f3eb..e5971221d0 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_4.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_4.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -TC004_4.py:4:24: TC004 [*] Move import `typing.Any` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `typing.Any` out of type-checking block. Import is used for more than type hinting. + --> TC004_4.py:4:24 | 3 | if TYPE_CHECKING: 4 | from typing import Any - | ^^^ TC004 + | ^^^ | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING, Type diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_5.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_5.py.snap index 39efab2ee5..a9dcddd513 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_5.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_5.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -TC004_5.py:4:24: TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting. + --> TC004_5.py:4:24 | 3 | if TYPE_CHECKING: 4 | from typing import List, Sequence, Set - | ^^^^ TC004 + | ^^^^ | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING @@ -21,13 +21,14 @@ TC004_5.py:4:24: TC004 [*] Move import `typing.List` out of type-checking block. 6 7 | 7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): -TC004_5.py:4:30: TC004 [*] Move import `typing.Sequence` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `typing.Sequence` out of type-checking block. Import is used for more than type hinting. + --> TC004_5.py:4:30 | 3 | if TYPE_CHECKING: 4 | from typing import List, Sequence, Set - | ^^^^^^^^ TC004 + | ^^^^^^^^ | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING @@ -40,13 +41,14 @@ TC004_5.py:4:30: TC004 [*] Move import `typing.Sequence` out of type-checking bl 6 7 | 7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): -TC004_5.py:4:40: TC004 [*] Move import `typing.Set` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `typing.Set` out of type-checking block. Import is used for more than type hinting. + --> TC004_5.py:4:40 | 3 | if TYPE_CHECKING: 4 | from typing import List, Sequence, Set - | ^^^ TC004 + | ^^^ | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_9.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_9.py.snap index 29514c37a1..93d461cb89 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_9.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TC004_9.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC004_9.py:4:24: TC004 [*] Move import `typing.Tuple` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `typing.Tuple` out of type-checking block. Import is used for more than type hinting. + --> TC004_9.py:4:24 | 3 | if TYPE_CHECKING: 4 | from typing import Tuple, List, Dict - | ^^^^^ TC004 + | ^^^^^ 5 | 6 | x: Tuple | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING @@ -22,15 +23,16 @@ TC004_9.py:4:24: TC004 [*] Move import `typing.Tuple` out of type-checking block 6 7 | x: Tuple 7 8 | -TC004_9.py:4:31: TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting. + --> TC004_9.py:4:31 | 3 | if TYPE_CHECKING: 4 | from typing import Tuple, List, Dict - | ^^^^ TC004 + | ^^^^ 5 | 6 | x: Tuple | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | from typing import TYPE_CHECKING diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_module__app.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_module__app.py.snap index 436e35992b..0dbc9b654e 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_module__app.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_module__app.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -app.py:9:12: TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. + --> app.py:9:12 | 8 | if TYPE_CHECKING: 9 | import datetime # TC004 - | ^^^^^^^^ TC004 + | ^^^^^^^^ 10 | from array import array # TC004 | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 4 4 | @@ -22,16 +23,17 @@ app.py:9:12: TC004 [*] Move import `datetime` out of type-checking block. Import 11 11 | 12 12 | app = fastapi.FastAPI("First application") -app.py:10:23: TC004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. + --> app.py:10:23 | 8 | if TYPE_CHECKING: 9 | import datetime # TC004 10 | from array import array # TC004 - | ^^^^^ TC004 + | ^^^^^ 11 | 12 | app = fastapi.FastAPI("First application") | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 4 4 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap index dbb418b692..175d447961 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_quote.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -quote.py:57:28: TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting. + --> quote.py:57:28 | 56 | if TYPE_CHECKING: 57 | from pandas import DataFrame - | ^^^^^^^^^ TC004 + | ^^^^^^^^^ 58 | 59 | def func(value: DataFrame): | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 |+from pandas import DataFrame @@ -26,15 +27,16 @@ quote.py:57:28: TC004 [*] Move import `pandas.DataFrame` out of type-checking bl 59 60 | def func(value: DataFrame): 60 61 | ... -quote.py:110:28: TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting. + --> quote.py:110:28 | 109 | if TYPE_CHECKING: 110 | from pandas import DataFrame - | ^^^^^^^^^ TC004 + | ^^^^^^^^^ 111 | 112 | x: TypeAlias = DataFrame | None | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 |+from pandas import DataFrame diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap index 70d301b0b5..437547481b 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -runtime_evaluated_base_classes_1.py:10:12: TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. + --> runtime_evaluated_base_classes_1.py:10:12 | 9 | if TYPE_CHECKING: 10 | import datetime # TC004 - | ^^^^^^^^ TC004 + | ^^^^^^^^ 11 | from array import array # TC004 | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 5 5 | @@ -22,16 +23,17 @@ runtime_evaluated_base_classes_1.py:10:12: TC004 [*] Move import `datetime` out 12 12 | 13 13 | import pandas # TC004 -runtime_evaluated_base_classes_1.py:11:23: TC004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. + --> runtime_evaluated_base_classes_1.py:11:23 | 9 | if TYPE_CHECKING: 10 | import datetime # TC004 11 | from array import array # TC004 - | ^^^^^ TC004 + | ^^^^^ 12 | 13 | import pandas # TC004 | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 5 5 | @@ -46,15 +48,16 @@ runtime_evaluated_base_classes_1.py:11:23: TC004 [*] Move import `array.array` o 13 13 | import pandas # TC004 14 14 | import pyproj -runtime_evaluated_base_classes_1.py:13:12: TC004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. + --> runtime_evaluated_base_classes_1.py:13:12 | 11 | from array import array # TC004 12 | 13 | import pandas # TC004 - | ^^^^^^ TC004 + | ^^^^^^ 14 | import pyproj | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 5 5 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap index bab0a4ba63..c6d82c4794 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -runtime_evaluated_decorators_1.py:12:12: TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. + --> runtime_evaluated_decorators_1.py:12:12 | 11 | if TYPE_CHECKING: 12 | import datetime # TC004 - | ^^^^^^^^ TC004 + | ^^^^^^^^ 13 | from array import array # TC004 | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 7 7 | from attrs import frozen @@ -22,16 +23,17 @@ runtime_evaluated_decorators_1.py:12:12: TC004 [*] Move import `datetime` out of 14 14 | 15 15 | import pandas # TC004 -runtime_evaluated_decorators_1.py:13:23: TC004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. + --> runtime_evaluated_decorators_1.py:13:23 | 11 | if TYPE_CHECKING: 12 | import datetime # TC004 13 | from array import array # TC004 - | ^^^^^ TC004 + | ^^^^^ 14 | 15 | import pandas # TC004 | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 7 7 | from attrs import frozen @@ -46,15 +48,16 @@ runtime_evaluated_decorators_1.py:13:23: TC004 [*] Move import `array.array` out 15 15 | import pandas # TC004 16 16 | import pyproj -runtime_evaluated_decorators_1.py:15:12: TC004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. + --> runtime_evaluated_decorators_1.py:15:12 | 13 | from array import array # TC004 14 | 15 | import pandas # TC004 - | ^^^^^^ TC004 + | ^^^^^^ 16 | import pyproj | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 7 7 | from attrs import frozen diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_whitespace.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_whitespace.py.snap index b4dd04e5ba..000858b290 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_whitespace.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_whitespace.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -whitespace.py:5:26: TC004 [*] Move import `builtins` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `builtins` out of type-checking block. Import is used for more than type hinting. + --> whitespace.py:5:26 | 3 | from typing import TYPE_CHECKING \ 4 | 5 | if TYPE_CHECKING: import builtins - | ^^^^^^^^ TC004 + | ^^^^^^^^ 6 | builtins.print("!") | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 1 1 | # Regression test for: https://github.com/astral-sh/ruff/issues/19175 diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_1.py.snap index 364d44103b..559272a6ad 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_1.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC010_1.py:18:30: TC010 Invalid string member in `X | Y`-style union type +TC010 Invalid string member in `X | Y`-style union type + --> TC010_1.py:18:30 | 16 | type A = Value["int" | str] # OK 17 | 18 | OldS = TypeVar('OldS', int | 'str', str) # TC010 - | ^^^^^ TC010 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_2.py.snap index 1e169cb50c..ab0b2a8952 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-string-union_TC010_2.py.snap @@ -1,39 +1,44 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC010_2.py:4:4: TC010 Invalid string member in `X | Y`-style union type +TC010 Invalid string member in `X | Y`-style union type + --> TC010_2.py:4:4 | 4 | x: "int" | str # TC010 - | ^^^^^ TC010 + | ^^^^^ 5 | x: ("int" | str) | "bool" # TC010 | -TC010_2.py:5:5: TC010 Invalid string member in `X | Y`-style union type +TC010 Invalid string member in `X | Y`-style union type + --> TC010_2.py:5:5 | 4 | x: "int" | str # TC010 5 | x: ("int" | str) | "bool" # TC010 - | ^^^^^ TC010 + | ^^^^^ | -TC010_2.py:5:20: TC010 Invalid string member in `X | Y`-style union type +TC010 Invalid string member in `X | Y`-style union type + --> TC010_2.py:5:20 | 4 | x: "int" | str # TC010 5 | x: ("int" | str) | "bool" # TC010 - | ^^^^^^ TC010 + | ^^^^^^ | -TC010_2.py:12:20: TC010 Invalid string member in `X | Y`-style union type +TC010 Invalid string member in `X | Y`-style union type + --> TC010_2.py:12:20 | 12 | z: list[str, str | "int"] = [] # TC010 - | ^^^^^ TC010 + | ^^^^^ 13 | 14 | type A = Value["int" | str] # OK | -TC010_2.py:16:30: TC010 Invalid string member in `X | Y`-style union type +TC010 Invalid string member in `X | Y`-style union type + --> TC010_2.py:16:30 | 14 | type A = Value["int" | str] # OK 15 | 16 | OldS = TypeVar('OldS', int | 'str', str) # TC010 - | ^^^^^ TC010 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap index b5260d86db..326a0d894f 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_init_var.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -init_var.py:5:25: TC003 [*] Move standard library import `dataclasses.FrozenInstanceError` into a type-checking block +TC003 [*] Move standard library import `dataclasses.FrozenInstanceError` into a type-checking block + --> init_var.py:5:25 | 3 | from __future__ import annotations 4 | 5 | from dataclasses import FrozenInstanceError, InitVar, dataclass - | ^^^^^^^^^^^^^^^^^^^ TC003 + | ^^^^^^^^^^^^^^^^^^^ 6 | from pathlib import Path | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | @@ -26,13 +27,14 @@ init_var.py:5:25: TC003 [*] Move standard library import `dataclasses.FrozenInst 8 12 | 9 13 | @dataclass -init_var.py:6:21: TC003 [*] Move standard library import `pathlib.Path` into a type-checking block +TC003 [*] Move standard library import `pathlib.Path` into a type-checking block + --> init_var.py:6:21 | 5 | from dataclasses import FrozenInstanceError, InitVar, dataclass 6 | from pathlib import Path - | ^^^^ TC003 + | ^^^^ | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_kw_only.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_kw_only.py.snap index 541a83ad17..57c6a1adeb 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_kw_only.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-standard-library-import_kw_only.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -kw_only.py:5:45: TC003 [*] Move standard library import `dataclasses.Field` into a type-checking block +TC003 [*] Move standard library import `dataclasses.Field` into a type-checking block + --> kw_only.py:5:45 | 3 | from __future__ import annotations 4 | 5 | from dataclasses import KW_ONLY, dataclass, Field - | ^^^^^ TC003 + | ^^^^^ | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap index d8451b6dfb..fbbef0ec9d 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict_typing-only-third-party-import_strict.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -strict.py:27:21: TC002 [*] Move third-party import `pkg.A` into a type-checking block +TC002 [*] Move third-party import `pkg.A` into a type-checking block + --> strict.py:27:21 | 25 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. 26 | import pkg 27 | from pkg import A - | ^ TC002 + | ^ 28 | 29 | def test(value: A): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -30,16 +31,17 @@ strict.py:27:21: TC002 [*] Move third-party import `pkg.A` into a type-checking 29 32 | def test(value: A): 30 33 | return pkg.B() -strict.py:35:21: TC002 [*] Move third-party import `pkg.A` into a type-checking block +TC002 [*] Move third-party import `pkg.A` into a type-checking block + --> strict.py:35:21 | 33 | def f(): 34 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. 35 | from pkg import A, B - | ^ TC002 + | ^ 36 | 37 | def test(value: A): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -60,16 +62,17 @@ strict.py:35:21: TC002 [*] Move third-party import `pkg.A` into a type-checking 37 41 | def test(value: A): 38 42 | return B() -strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-checking block +TC002 [*] Move third-party import `pkg.bar.A` into a type-checking block + --> strict.py:54:25 | 52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime 53 | import pkg 54 | from pkg.bar import A - | ^ TC002 + | ^ 55 | 56 | def test(value: A): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -89,15 +92,16 @@ strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-check 56 59 | def test(value: A): 57 60 | return pkg.B() -strict.py:62:12: TC002 [*] Move third-party import `pkg` into a type-checking block +TC002 [*] Move third-party import `pkg` into a type-checking block + --> strict.py:62:12 | 60 | def f(): 61 | # In un-strict mode, this shouldn't raise an error, since `pkg.bar` is used at runtime. 62 | import pkg - | ^^^ TC002 + | ^^^ 63 | import pkg.bar as B | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -117,15 +121,16 @@ strict.py:62:12: TC002 [*] Move third-party import `pkg` into a type-checking bl 64 67 | 65 68 | def test(value: pkg.A): -strict.py:71:23: TC002 [*] Move third-party import `pkg.foo` into a type-checking block +TC002 [*] Move third-party import `pkg.foo` into a type-checking block + --> strict.py:71:23 | 69 | def f(): 70 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. 71 | import pkg.foo as F - | ^ TC002 + | ^ 72 | import pkg.foo.bar as B | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -145,15 +150,16 @@ strict.py:71:23: TC002 [*] Move third-party import `pkg.foo` into a type-checkin 73 76 | 74 77 | def test(value: F.Foo): -strict.py:80:12: TC002 [*] Move third-party import `pkg` into a type-checking block +TC002 [*] Move third-party import `pkg` into a type-checking block + --> strict.py:80:12 | 78 | def f(): 79 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. 80 | import pkg - | ^^^ TC002 + | ^^^ 81 | import pkg.foo.bar as B | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -173,15 +179,16 @@ strict.py:80:12: TC002 [*] Move third-party import `pkg` into a type-checking bl 82 85 | 83 86 | def test(value: pkg.A): -strict.py:91:12: TC002 [*] Move third-party import `pkg` into a type-checking block +TC002 [*] Move third-party import `pkg` into a type-checking block + --> strict.py:91:12 | 89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is 90 | # testing the implementation. 91 | import pkg - | ^^^ TC002 + | ^^^ 92 | import pkgfoo.bar as B | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -201,16 +208,17 @@ strict.py:91:12: TC002 [*] Move third-party import `pkg` into a type-checking bl 93 96 | 94 97 | def test(value: pkg.A): -strict.py:101:23: TC002 [*] Move third-party import `pkg.foo` into a type-checking block +TC002 [*] Move third-party import `pkg.foo` into a type-checking block + --> strict.py:101:23 | 99 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. 100 | import pkg.bar as B 101 | import pkg.foo as F - | ^ TC002 + | ^ 102 | 103 | def test(value: F.Foo): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc004_precedence_over_tc007.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc004_precedence_over_tc007.snap index b4ae0f7ff9..066155d1b9 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc004_precedence_over_tc007.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc004_precedence_over_tc007.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:21: TC004 [*] Move import `foo.Foo` out of type-checking block. Import is used for more than type hinting. +TC004 [*] Move import `foo.Foo` out of type-checking block. Import is used for more than type hinting. + --> :6:21 | 4 | from typing import TYPE_CHECKING, TypeAlias 5 | if TYPE_CHECKING: 6 | from foo import Foo # TC004 - | ^^^ TC004 + | ^^^ 7 | 8 | a: TypeAlias = Foo | None # OK | - = help: Move out of type-checking block +help: Move out of type-checking block ℹ Unsafe fix 2 2 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc010_precedence_over_tc008.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc010_precedence_over_tc008.snap index 3f7510c00f..7cba591164 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc010_precedence_over_tc008.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__tc010_precedence_over_tc008.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:16: TC008 [*] Remove quotes from type alias +TC008 [*] Remove quotes from type alias + --> :6:16 | 4 | from typing import TypeAlias 5 | 6 | a: TypeAlias = 'int | None' # TC008 - | ^^^^^^^^^^^^ TC008 + | ^^^^^^^^^^^^ 7 | b: TypeAlias = 'int' | None # TC010 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 3 3 | @@ -19,9 +20,10 @@ source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs 6 |+a: TypeAlias = int | None # TC008 7 7 | b: TypeAlias = 'int' | None # TC010 -:7:16: TC010 Invalid string member in `X | Y`-style union type +TC010 Invalid string member in `X | Y`-style union type + --> :7:16 | 6 | a: TypeAlias = 'int | None' # TC008 7 | b: TypeAlias = 'int' | None # TC010 - | ^^^^^ TC010 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap index cdacd1ba29..d49fc5ac43 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> :6:18 | 4 | from typing import TYPE_CHECKING 5 | 6 | import pandas as pd - | ^^ TC002 + | ^^ 7 | 8 | def f(x: pd.DataFrame): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap index ce5864c57d..622926c8f9 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> :6:18 | 4 | from typing import TYPE_CHECKING 5 | 6 | import pandas as pd - | ^^ TC002 + | ^^ 7 | 8 | if TYPE_CHECKING: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap index bafccc1d13..3154d35ecd 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> :6:18 | 4 | from typing import TYPE_CHECKING 5 | 6 | import pandas as pd - | ^^ TC002 + | ^^ 7 | 8 | if TYPE_CHECKING: import os | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap index ac2f55bc5a..b2018bd971 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> :6:18 | 4 | from typing import TYPE_CHECKING 5 | 6 | import pandas as pd - | ^^ TC002 + | ^^ 7 | 8 | if TYPE_CHECKING: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TC001.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TC001.py.snap index cc9d12d169..f9b554bbbc 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TC001.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TC001.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC001.py:20:19: TC001 [*] Move application import `.TYP001` into a type-checking block +TC001 [*] Move application import `.TYP001` into a type-checking block + --> TC001.py:20:19 | 19 | def f(): 20 | from . import TYP001 - | ^^^^^^ TC001 + | ^^^^^^ 21 | 22 | x: TYP001 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TC003.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TC003.py.snap index e7590ea5c2..90bd90e695 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TC003.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TC003.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC003.py:8:12: TC003 [*] Move standard library import `os` into a type-checking block +TC003 [*] Move standard library import `os` into a type-checking block + --> TC003.py:8:12 | 7 | def f(): 8 | import os - | ^^ TC003 + | ^^ 9 | 10 | x: os | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap index 98f48ef06a..9d978decd1 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_1.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -exempt_type_checking_1.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block +TC003 [*] Move standard library import `typing.Final` into a type-checking block + --> exempt_type_checking_1.py:5:20 | 3 | from __future__ import annotations 4 | 5 | from typing import Final - | ^^^^^ TC003 + | ^^^^^ 6 | 7 | Const: Final[dict] = {} | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap index 909e0d5530..1c40a7ad20 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_2.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -exempt_type_checking_2.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block +TC003 [*] Move standard library import `typing.Final` into a type-checking block + --> exempt_type_checking_2.py:5:20 | 3 | from __future__ import annotations 4 | 5 | from typing import Final, TYPE_CHECKING - | ^^^^^ TC003 + | ^^^^^ 6 | 7 | Const: Final[dict] = {} | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap index afd7480ade..1e257387db 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_exempt_type_checking_3.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -exempt_type_checking_3.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block +TC003 [*] Move standard library import `typing.Final` into a type-checking block + --> exempt_type_checking_3.py:5:20 | 3 | from __future__ import annotations 4 | 5 | from typing import Final, Mapping - | ^^^^^ TC003 + | ^^^^^ 6 | 7 | Const: Final[dict] = {} | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_init_var.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_init_var.py.snap index 11a40633dd..c7ca4bfe79 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_init_var.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_init_var.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -init_var.py:6:21: TC003 [*] Move standard library import `pathlib.Path` into a type-checking block +TC003 [*] Move standard library import `pathlib.Path` into a type-checking block + --> init_var.py:6:21 | 5 | from dataclasses import FrozenInstanceError, InitVar, dataclass 6 | from pathlib import Path - | ^^^^ TC003 + | ^^^^ | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap index 89f0a91947..49c2af1dca 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_module__undefined.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -undefined.py:3:29: TC003 [*] Move standard library import `collections.abc.Sequence` into a type-checking block +TC003 [*] Move standard library import `collections.abc.Sequence` into a type-checking block + --> undefined.py:3:29 | 1 | from __future__ import annotations 2 | 3 | from collections.abc import Sequence - | ^^^^^^^^ TC003 + | ^^^^^^^^ | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap index 06d344ed01..afc6053cd8 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -runtime_evaluated_base_classes_3.py:5:18: TC003 [*] Move standard library import `uuid.UUID` into a type-checking block +TC003 [*] Move standard library import `uuid.UUID` into a type-checking block + --> runtime_evaluated_base_classes_3.py:5:18 | 3 | import datetime 4 | import pathlib 5 | from uuid import UUID # TC003 - | ^^^^ TC003 + | ^^^^ 6 | 7 | import pydantic | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap index bba4e32fee..35712dc794 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -runtime_evaluated_decorators_3.py:6:18: TC003 [*] Move standard library import `uuid.UUID` into a type-checking block +TC003 [*] Move standard library import `uuid.UUID` into a type-checking block + --> runtime_evaluated_decorators_3.py:6:18 | 4 | from array import array 5 | from dataclasses import dataclass 6 | from uuid import UUID # TC003 - | ^^^^ TC003 + | ^^^^ 7 | from collections.abc import Sequence 8 | from pydantic import validate_call | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | import datetime diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_singledispatchmethod.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_singledispatchmethod.py.snap index 18e5d97933..919be0bfcc 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_singledispatchmethod.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_singledispatchmethod.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs -snapshot_kind: text --- -singledispatchmethod.py:4:21: TC003 [*] Move standard library import `pathlib.Path` into a type-checking block +TC003 [*] Move standard library import `pathlib.Path` into a type-checking block + --> singledispatchmethod.py:4:21 | 3 | from collections.abc import MutableMapping, Mapping 4 | from pathlib import Path - | ^^^^ TC003 + | ^^^^ 5 | from functools import singledispatchmethod 6 | from typing import Union | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TC002.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TC002.py.snap index 3b34f3141c..f060bd6715 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TC002.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TC002.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC002.py:5:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> TC002.py:5:22 | 4 | def f(): 5 | import pandas as pd # TC002 - | ^^ TC002 + | ^^ 6 | 7 | x: pd.DataFrame | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -25,15 +26,16 @@ TC002.py:5:22: TC002 [*] Move third-party import `pandas` into a type-checking b 7 10 | x: pd.DataFrame 8 11 | -TC002.py:11:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> TC002.py:11:24 | 10 | def f(): 11 | from pandas import DataFrame # TC002 - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 12 | 13 | x: DataFrame | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -53,15 +55,16 @@ TC002.py:11:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 13 16 | x: DataFrame 14 17 | -TC002.py:17:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> TC002.py:17:37 | 16 | def f(): 17 | from pandas import DataFrame as df # TC002 - | ^^ TC002 + | ^^ 18 | 19 | x: df | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -81,15 +84,16 @@ TC002.py:17:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type 19 22 | x: df 20 23 | -TC002.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> TC002.py:23:22 | 22 | def f(): 23 | import pandas as pd # TC002 - | ^^ TC002 + | ^^ 24 | 25 | x: pd.DataFrame = 1 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -109,15 +113,16 @@ TC002.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking 25 28 | x: pd.DataFrame = 1 26 29 | -TC002.py:29:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> TC002.py:29:24 | 28 | def f(): 29 | from pandas import DataFrame # TC002 - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 30 | 31 | x: DataFrame = 2 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -137,15 +142,16 @@ TC002.py:29:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type 31 34 | x: DataFrame = 2 32 35 | -TC002.py:35:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> TC002.py:35:37 | 34 | def f(): 35 | from pandas import DataFrame as df # TC002 - | ^^ TC002 + | ^^ 36 | 37 | x: df = 3 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -165,15 +171,16 @@ TC002.py:35:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type 37 40 | x: df = 3 38 41 | -TC002.py:41:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> TC002.py:41:22 | 40 | def f(): 41 | import pandas as pd # TC002 - | ^^ TC002 + | ^^ 42 | 43 | x: "pd.DataFrame" = 1 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -193,15 +200,16 @@ TC002.py:41:22: TC002 [*] Move third-party import `pandas` into a type-checking 43 46 | x: "pd.DataFrame" = 1 44 47 | -TC002.py:47:22: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> TC002.py:47:22 | 46 | def f(): 47 | import pandas as pd # TC002 - | ^^ TC002 + | ^^ 48 | 49 | x = dict["pd.DataFrame", "pd.DataFrame"] | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" @@ -221,16 +229,17 @@ TC002.py:47:22: TC002 [*] Move third-party import `pandas` into a type-checking 49 52 | x = dict["pd.DataFrame", "pd.DataFrame"] 50 53 | -TC002.py:172:24: TC002 [*] Move third-party import `module.Member` into a type-checking block +TC002 [*] Move third-party import `module.Member` into a type-checking block + --> TC002.py:172:24 | 170 | global Member 171 | 172 | from module import Member - | ^^^^^^ TC002 + | ^^^^^^ 173 | 174 | x: Member = 1 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | """Tests to determine accurate detection of typing-only imports.""" diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap index d52dd420f8..77938f9a02 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -runtime_evaluated_base_classes_2.py:3:21: TC002 [*] Move third-party import `geopandas` into a type-checking block +TC002 [*] Move third-party import `geopandas` into a type-checking block + --> runtime_evaluated_base_classes_2.py:3:21 | 1 | from __future__ import annotations 2 | 3 | import geopandas as gpd # TC002 - | ^^^ TC002 + | ^^^ 4 | import pydantic 5 | import pyproj # TC002 | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -29,15 +30,16 @@ runtime_evaluated_base_classes_2.py:3:21: TC002 [*] Move third-party import `geo 10 13 | 11 14 | class A(BaseModel): -runtime_evaluated_base_classes_2.py:5:8: TC002 [*] Move third-party import `pyproj` into a type-checking block +TC002 [*] Move third-party import `pyproj` into a type-checking block + --> runtime_evaluated_base_classes_2.py:5:8 | 3 | import geopandas as gpd # TC002 4 | import pydantic 5 | import pyproj # TC002 - | ^^^^^^ TC002 + | ^^^^^^ 6 | from pydantic import BaseModel | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap index daf471f921..e4245adea6 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -runtime_evaluated_decorators_2.py:10:8: TC002 [*] Move third-party import `numpy` into a type-checking block +TC002 [*] Move third-party import `numpy` into a type-checking block + --> runtime_evaluated_decorators_2.py:10:8 | 8 | from attrs import frozen 9 | 10 | import numpy # TC002 - | ^^^^^ TC002 + | ^^^^^ | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 7 7 | import pyproj diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap index c226a6cfd1..f6d4f2f11c 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_singledispatch.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -singledispatch.py:12:20: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> singledispatch.py:12:20 | 10 | from numpy.typing import ArrayLike 11 | from scipy.sparse import spmatrix 12 | from pandas import DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 13 | 14 | if TYPE_CHECKING: | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 9 9 | from numpy import asarray diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap index 94b85230ae..fef1a107a0 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-checking block +TC002 [*] Move third-party import `pkg.bar.A` into a type-checking block + --> strict.py:54:25 | 52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime 53 | import pkg 54 | from pkg.bar import A - | ^ TC002 + | ^ 55 | 56 | def test(value: A): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations @@ -30,15 +31,16 @@ strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-check 56 59 | def test(value: A): 57 60 | return pkg.B() -strict.py:91:12: TC002 [*] Move third-party import `pkg` into a type-checking block +TC002 [*] Move third-party import `pkg` into a type-checking block + --> strict.py:91:12 | 89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is 90 | # testing the implementation. 91 | import pkg - | ^^^ TC002 + | ^^^ 92 | import pkgfoo.bar as B | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap index d02dab7f4a..3e38e94b6d 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_1.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -typing_modules_1.py:7:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> typing_modules_1.py:7:24 | 6 | def func(): 7 | from pandas import DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 8 | 9 | df: DataFrame | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap index ba8a621fcc..d0f633a1f0 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_typing_modules_2.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -typing_modules_2.py:7:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block +TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + --> typing_modules_2.py:7:24 | 6 | def func(): 7 | from pandas import DataFrame - | ^^^^^^^^^ TC002 + | ^^^^^^^^^ 8 | 9 | df: DataFrame | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap index 4c00f74102..36ac27e90e 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:4:18: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> :4:18 | 2 | from __future__ import annotations 3 | 4 | import pandas as pd - | ^^ TC002 + | ^^ 5 | 6 | from typing import TYPE_CHECKING | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 1 1 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap index d5353c0939..e9136cbf2b 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:4:18: TC002 Move third-party import `pandas` into a type-checking block +TC002 Move third-party import `pandas` into a type-checking block + --> :4:18 | 2 | from __future__ import annotations 3 | 4 | import pandas as pd - | ^^ TC002 + | ^^ 5 | 6 | def f(x: pd.DataFrame): | - = help: Move into type-checking block +help: Move into type-checking block diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap index 581f1bb10f..b06fe0450d 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block +TC002 [*] Move third-party import `pandas` into a type-checking block + --> :6:18 | 4 | from typing import TYPE_CHECKING 5 | 6 | import pandas as pd - | ^^ TC002 + | ^^ 7 | 8 | def f(x: pd.DataFrame): | - = help: Move into type-checking block +help: Move into type-checking block ℹ Unsafe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__unquoted-type-alias_TC007.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__unquoted-type-alias_TC007.py.snap index 5ce4bcc79f..b06e7c139c 100644 --- a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__unquoted-type-alias_TC007.py.snap +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__unquoted-type-alias_TC007.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs --- -TC007.py:15:16: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:15:16 | 13 | a: TypeAlias = int # OK 14 | b: TypeAlias = Dict # OK 15 | c: TypeAlias = Foo # TC007 - | ^^^ TC007 + | ^^^ 16 | d: TypeAlias = Foo | None # TC007 17 | e: TypeAlias = OptStr # TC007 | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 12 12 | @@ -22,16 +23,17 @@ TC007.py:15:16: TC007 [*] Add quotes to type alias 17 17 | e: TypeAlias = OptStr # TC007 18 18 | f: TypeAlias = Bar # TC007 -TC007.py:16:16: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:16:16 | 14 | b: TypeAlias = Dict # OK 15 | c: TypeAlias = Foo # TC007 16 | d: TypeAlias = Foo | None # TC007 - | ^^^ TC007 + | ^^^ 17 | e: TypeAlias = OptStr # TC007 18 | f: TypeAlias = Bar # TC007 | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 13 13 | a: TypeAlias = int # OK @@ -43,16 +45,17 @@ TC007.py:16:16: TC007 [*] Add quotes to type alias 18 18 | f: TypeAlias = Bar # TC007 19 19 | g: TypeAlias = Foo | Bar # TC007 x2 -TC007.py:17:16: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:17:16 | 15 | c: TypeAlias = Foo # TC007 16 | d: TypeAlias = Foo | None # TC007 17 | e: TypeAlias = OptStr # TC007 - | ^^^^^^ TC007 + | ^^^^^^ 18 | f: TypeAlias = Bar # TC007 19 | g: TypeAlias = Foo | Bar # TC007 x2 | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 14 14 | b: TypeAlias = Dict # OK @@ -64,16 +67,17 @@ TC007.py:17:16: TC007 [*] Add quotes to type alias 19 19 | g: TypeAlias = Foo | Bar # TC007 x2 20 20 | h: TypeAlias = Foo[str] # TC007 -TC007.py:18:16: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:18:16 | 16 | d: TypeAlias = Foo | None # TC007 17 | e: TypeAlias = OptStr # TC007 18 | f: TypeAlias = Bar # TC007 - | ^^^ TC007 + | ^^^ 19 | g: TypeAlias = Foo | Bar # TC007 x2 20 | h: TypeAlias = Foo[str] # TC007 | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 15 15 | c: TypeAlias = Foo # TC007 @@ -85,16 +89,17 @@ TC007.py:18:16: TC007 [*] Add quotes to type alias 20 20 | h: TypeAlias = Foo[str] # TC007 21 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) -TC007.py:19:16: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:19:16 | 17 | e: TypeAlias = OptStr # TC007 18 | f: TypeAlias = Bar # TC007 19 | g: TypeAlias = Foo | Bar # TC007 x2 - | ^^^ TC007 + | ^^^ 20 | h: TypeAlias = Foo[str] # TC007 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 16 16 | d: TypeAlias = Foo | None # TC007 @@ -106,16 +111,17 @@ TC007.py:19:16: TC007 [*] Add quotes to type alias 21 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) 22 22 | Bar) -TC007.py:19:22: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:19:22 | 17 | e: TypeAlias = OptStr # TC007 18 | f: TypeAlias = Bar # TC007 19 | g: TypeAlias = Foo | Bar # TC007 x2 - | ^^^ TC007 + | ^^^ 20 | h: TypeAlias = Foo[str] # TC007 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 16 16 | d: TypeAlias = Foo | None # TC007 @@ -127,16 +133,17 @@ TC007.py:19:22: TC007 [*] Add quotes to type alias 21 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) 22 22 | Bar) -TC007.py:20:16: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:20:16 | 18 | f: TypeAlias = Bar # TC007 19 | g: TypeAlias = Foo | Bar # TC007 x2 20 | h: TypeAlias = Foo[str] # TC007 - | ^^^ TC007 + | ^^^ 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) 22 | Bar) | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 17 17 | e: TypeAlias = OptStr # TC007 @@ -148,15 +155,16 @@ TC007.py:20:16: TC007 [*] Add quotes to type alias 22 22 | Bar) 23 23 | -TC007.py:21:17: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:21:17 | 19 | g: TypeAlias = Foo | Bar # TC007 x2 20 | h: TypeAlias = Foo[str] # TC007 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) - | ^^^ TC007 + | ^^^ 22 | Bar) | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 18 18 | f: TypeAlias = Bar # TC007 @@ -169,16 +177,17 @@ TC007.py:21:17: TC007 [*] Add quotes to type alias 24 23 | type C = Foo # OK 25 24 | type D = Foo | None # OK -TC007.py:22:5: TC007 [*] Add quotes to type alias +TC007 [*] Add quotes to type alias + --> TC007.py:22:5 | 20 | h: TypeAlias = Foo[str] # TC007 21 | i: TypeAlias = (Foo | # TC007 x2 (fix removes comment currently) 22 | Bar) - | ^^^ TC007 + | ^^^ 23 | 24 | type C = Foo # OK | - = help: Add quotes +help: Add quotes ℹ Unsafe fix 18 18 | f: TypeAlias = Bar # TC007 diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap index f53c64b064..421e782b07 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap @@ -1,35 +1,38 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs -snapshot_kind: text --- -ARG.py:9:7: ARG001 Unused function argument: `self` +ARG001 Unused function argument: `self` + --> ARG.py:9:7 | 7 | # Unused arguments on functions. 8 | ### 9 | def f(self, x): - | ^^^^ ARG001 + | ^^^^ 10 | print("Hello, world!") | -ARG.py:9:13: ARG001 Unused function argument: `x` +ARG001 Unused function argument: `x` + --> ARG.py:9:13 | 7 | # Unused arguments on functions. 8 | ### 9 | def f(self, x): - | ^ ARG001 + | ^ 10 | print("Hello, world!") | -ARG.py:13:7: ARG001 Unused function argument: `cls` +ARG001 Unused function argument: `cls` + --> ARG.py:13:7 | 13 | def f(cls, x): - | ^^^ ARG001 + | ^^^ 14 | print("Hello, world!") | -ARG.py:13:12: ARG001 Unused function argument: `x` +ARG001 Unused function argument: `x` + --> ARG.py:13:12 | 13 | def f(cls, x): - | ^ ARG001 + | ^ 14 | print("Hello, world!") | diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap index 2c7fe70056..75605df353 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap @@ -1,78 +1,86 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs --- -ARG.py:37:17: ARG002 Unused method argument: `x` +ARG002 Unused method argument: `x` + --> ARG.py:37:17 | 35 | # Unused arguments. 36 | ### 37 | def f(self, x): - | ^ ARG002 + | ^ 38 | print("Hello, world!") | -ARG.py:40:20: ARG002 Unused method argument: `x` +ARG002 Unused method argument: `x` + --> ARG.py:40:20 | 38 | print("Hello, world!") 39 | 40 | def f(self, /, x): - | ^ ARG002 + | ^ 41 | print("Hello, world!") | -ARG.py:43:16: ARG002 Unused method argument: `x` +ARG002 Unused method argument: `x` + --> ARG.py:43:16 | 41 | print("Hello, world!") 42 | 43 | def f(cls, x): - | ^ ARG002 + | ^ 44 | print("Hello, world!") | -ARG.py:58:17: ARG002 Unused method argument: `x` +ARG002 Unused method argument: `x` + --> ARG.py:58:17 | 56 | print("Hello, world!") 57 | 58 | def f(self, x): - | ^ ARG002 + | ^ 59 | msg[0] = "..." 60 | raise NotImplementedError(msg) | -ARG.py:62:17: ARG002 Unused method argument: `x` +ARG002 Unused method argument: `x` + --> ARG.py:62:17 | 60 | raise NotImplementedError(msg) 61 | 62 | def f(self, x): - | ^ ARG002 + | ^ 63 | msg = "..." 64 | raise NotImplementedError(foo) | -ARG.py:66:17: ARG002 Unused method argument: `x` +ARG002 Unused method argument: `x` + --> ARG.py:66:17 | 64 | raise NotImplementedError(foo) 65 | 66 | def f(self, x): - | ^ ARG002 + | ^ 67 | msg = "..." 68 | raise NotImplementedError("must use msg") | -ARG.py:216:24: ARG002 Unused method argument: `x` +ARG002 Unused method argument: `x` + --> ARG.py:216:24 | 214 | print("Hello, world!") 215 | 216 | def __init__(self, x) -> None: - | ^ ARG002 + | ^ 217 | print("Hello, world!") | -ARG.py:255:20: ARG002 Unused method argument: `y` +ARG002 Unused method argument: `y` + --> ARG.py:255:20 | 253 | ### 254 | class C: 255 | def f(self, x, y): - | ^ ARG002 + | ^ 256 | """Docstring.""" 257 | msg = t"{x}..." | diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap index c0187e8c67..26eb6650a7 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs --- -ARG.py:47:16: ARG003 Unused class method argument: `x` +ARG003 Unused class method argument: `x` + --> ARG.py:47:16 | 46 | @classmethod 47 | def f(cls, x): - | ^ ARG003 + | ^ 48 | print("Hello, world!") | diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap index da31a5449a..f930a331a4 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap @@ -1,35 +1,39 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs --- -ARG.py:51:11: ARG004 Unused static method argument: `cls` +ARG004 Unused static method argument: `cls` + --> ARG.py:51:11 | 50 | @staticmethod 51 | def f(cls, x): - | ^^^ ARG004 + | ^^^ 52 | print("Hello, world!") | -ARG.py:51:16: ARG004 Unused static method argument: `x` +ARG004 Unused static method argument: `x` + --> ARG.py:51:16 | 50 | @staticmethod 51 | def f(cls, x): - | ^ ARG004 + | ^ 52 | print("Hello, world!") | -ARG.py:55:11: ARG004 Unused static method argument: `x` +ARG004 Unused static method argument: `x` + --> ARG.py:55:11 | 54 | @staticmethod 55 | def f(x): - | ^ ARG004 + | ^ 56 | print("Hello, world!") | -ARG.py:213:22: ARG004 Unused static method argument: `x` +ARG004 Unused static method argument: `x` + --> ARG.py:213:22 | 211 | ### 212 | class C: 213 | def __new__(cls, x): - | ^ ARG004 + | ^ 214 | print("Hello, world!") | diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap index db2dbbab78..c60f07fbbb 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs --- -ARG.py:28:8: ARG005 Unused lambda argument: `x` +ARG005 Unused lambda argument: `x` + --> ARG.py:28:8 | 26 | # Unused arguments on lambdas. 27 | ### 28 | lambda x: print("Hello, world!") - | ^ ARG005 + | ^ 29 | 30 | lambda: print("Hello, world!") | diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap index 430bd44bb2..f724fc6506 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap @@ -1,96 +1,108 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs --- -ignore_variadic_names.py:1:7: ARG001 Unused function argument: `a` +ARG001 Unused function argument: `a` + --> ignore_variadic_names.py:1:7 | 1 | def f(a, b): - | ^ ARG001 + | ^ 2 | print("Hello, world!") | -ignore_variadic_names.py:1:10: ARG001 Unused function argument: `b` +ARG001 Unused function argument: `b` + --> ignore_variadic_names.py:1:10 | 1 | def f(a, b): - | ^ ARG001 + | ^ 2 | print("Hello, world!") | -ignore_variadic_names.py:5:7: ARG001 Unused function argument: `a` +ARG001 Unused function argument: `a` + --> ignore_variadic_names.py:5:7 | 5 | def f(a, b, *args, **kwargs): - | ^ ARG001 + | ^ 6 | print("Hello, world!") | -ignore_variadic_names.py:5:10: ARG001 Unused function argument: `b` +ARG001 Unused function argument: `b` + --> ignore_variadic_names.py:5:10 | 5 | def f(a, b, *args, **kwargs): - | ^ ARG001 + | ^ 6 | print("Hello, world!") | -ignore_variadic_names.py:5:14: ARG001 Unused function argument: `args` +ARG001 Unused function argument: `args` + --> ignore_variadic_names.py:5:14 | 5 | def f(a, b, *args, **kwargs): - | ^^^^ ARG001 + | ^^^^ 6 | print("Hello, world!") | -ignore_variadic_names.py:5:22: ARG001 Unused function argument: `kwargs` +ARG001 Unused function argument: `kwargs` + --> ignore_variadic_names.py:5:22 | 5 | def f(a, b, *args, **kwargs): - | ^^^^^^ ARG001 + | ^^^^^^ 6 | print("Hello, world!") | -ignore_variadic_names.py:10:17: ARG002 Unused method argument: `a` +ARG002 Unused method argument: `a` + --> ignore_variadic_names.py:10:17 | 9 | class C: 10 | def f(self, a, b): - | ^ ARG002 + | ^ 11 | print("Hello, world!") | -ignore_variadic_names.py:10:20: ARG002 Unused method argument: `b` +ARG002 Unused method argument: `b` + --> ignore_variadic_names.py:10:20 | 9 | class C: 10 | def f(self, a, b): - | ^ ARG002 + | ^ 11 | print("Hello, world!") | -ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` +ARG002 Unused method argument: `a` + --> ignore_variadic_names.py:13:17 | 11 | print("Hello, world!") 12 | 13 | def f(self, a, b, *args, **kwargs): - | ^ ARG002 + | ^ 14 | print("Hello, world!") | -ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` +ARG002 Unused method argument: `b` + --> ignore_variadic_names.py:13:20 | 11 | print("Hello, world!") 12 | 13 | def f(self, a, b, *args, **kwargs): - | ^ ARG002 + | ^ 14 | print("Hello, world!") | -ignore_variadic_names.py:13:24: ARG002 Unused method argument: `args` +ARG002 Unused method argument: `args` + --> ignore_variadic_names.py:13:24 | 11 | print("Hello, world!") 12 | 13 | def f(self, a, b, *args, **kwargs): - | ^^^^ ARG002 + | ^^^^ 14 | print("Hello, world!") | -ignore_variadic_names.py:13:32: ARG002 Unused method argument: `kwargs` +ARG002 Unused method argument: `kwargs` + --> ignore_variadic_names.py:13:32 | 11 | print("Hello, world!") 12 | 13 | def f(self, a, b, *args, **kwargs): - | ^^^^^^ ARG002 + | ^^^^^^ 14 | print("Hello, world!") | diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap index 16e2230d2c..68c16ad3d0 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap @@ -1,64 +1,72 @@ --- source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs --- -ignore_variadic_names.py:1:7: ARG001 Unused function argument: `a` +ARG001 Unused function argument: `a` + --> ignore_variadic_names.py:1:7 | 1 | def f(a, b): - | ^ ARG001 + | ^ 2 | print("Hello, world!") | -ignore_variadic_names.py:1:10: ARG001 Unused function argument: `b` +ARG001 Unused function argument: `b` + --> ignore_variadic_names.py:1:10 | 1 | def f(a, b): - | ^ ARG001 + | ^ 2 | print("Hello, world!") | -ignore_variadic_names.py:5:7: ARG001 Unused function argument: `a` +ARG001 Unused function argument: `a` + --> ignore_variadic_names.py:5:7 | 5 | def f(a, b, *args, **kwargs): - | ^ ARG001 + | ^ 6 | print("Hello, world!") | -ignore_variadic_names.py:5:10: ARG001 Unused function argument: `b` +ARG001 Unused function argument: `b` + --> ignore_variadic_names.py:5:10 | 5 | def f(a, b, *args, **kwargs): - | ^ ARG001 + | ^ 6 | print("Hello, world!") | -ignore_variadic_names.py:10:17: ARG002 Unused method argument: `a` +ARG002 Unused method argument: `a` + --> ignore_variadic_names.py:10:17 | 9 | class C: 10 | def f(self, a, b): - | ^ ARG002 + | ^ 11 | print("Hello, world!") | -ignore_variadic_names.py:10:20: ARG002 Unused method argument: `b` +ARG002 Unused method argument: `b` + --> ignore_variadic_names.py:10:20 | 9 | class C: 10 | def f(self, a, b): - | ^ ARG002 + | ^ 11 | print("Hello, world!") | -ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` +ARG002 Unused method argument: `a` + --> ignore_variadic_names.py:13:17 | 11 | print("Hello, world!") 12 | 13 | def f(self, a, b, *args, **kwargs): - | ^ ARG002 + | ^ 14 | print("Hello, world!") | -ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` +ARG002 Unused method argument: `b` + --> ignore_variadic_names.py:13:20 | 11 | print("Hello, world!") 12 | 13 | def f(self, a, b, *args, **kwargs): - | ^ ARG002 + | ^ 14 | print("Hello, world!") | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap index bea8d4778a..69808fd0ed 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -py_path_1.py:3:5: PTH124 `py.path` is in maintenance mode, use `pathlib` instead +PTH124 `py.path` is in maintenance mode, use `pathlib` instead + --> py_path_1.py:3:5 | 1 | import py 2 | 3 | p = py.path.local("../foo") - | ^^^^^^^^^^^^^ PTH124 + | ^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap index f5b5e5c089..3b73893a1f 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -py_path_2.py:3:5: PTH124 `py.path` is in maintenance mode, use `pathlib` instead +PTH124 `py.path` is in maintenance mode, use `pathlib` instead + --> py_path_2.py:3:5 | 1 | from py.path import local as path 2 | 3 | p = path("/foo") - | ^^^^ PTH124 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap index 4165133a01..8e5ee8eb59 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH201.py:6:10: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:6:10 | 5 | # match 6 | _ = Path(".") - | ^^^ PTH201 + | ^^^ 7 | _ = pth(".") 8 | _ = PurePath(".") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 3 3 | @@ -21,16 +22,17 @@ PTH201.py:6:10: PTH201 [*] Do not pass the current directory explicitly to `Path 8 8 | _ = PurePath(".") 9 9 | _ = Path("") -PTH201.py:7:9: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:7:9 | 5 | # match 6 | _ = Path(".") 7 | _ = pth(".") - | ^^^ PTH201 + | ^^^ 8 | _ = PurePath(".") 9 | _ = Path("") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 4 4 | @@ -42,15 +44,16 @@ PTH201.py:7:9: PTH201 [*] Do not pass the current directory explicitly to `Path` 9 9 | _ = Path("") 10 10 | -PTH201.py:8:14: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:8:14 | 6 | _ = Path(".") 7 | _ = pth(".") 8 | _ = PurePath(".") - | ^^^ PTH201 + | ^^^ 9 | _ = Path("") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 5 5 | # match @@ -62,16 +65,17 @@ PTH201.py:8:14: PTH201 [*] Do not pass the current directory explicitly to `Path 10 10 | 11 11 | Path('', ) -PTH201.py:9:10: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:9:10 | 7 | _ = pth(".") 8 | _ = PurePath(".") 9 | _ = Path("") - | ^^ PTH201 + | ^^ 10 | 11 | Path('', ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 6 6 | _ = Path(".") @@ -83,16 +87,17 @@ PTH201.py:9:10: PTH201 [*] Do not pass the current directory explicitly to `Path 11 11 | Path('', ) 12 12 | -PTH201.py:11:6: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:11:6 | 9 | _ = Path("") 10 | 11 | Path('', ) - | ^^ PTH201 + | ^^ 12 | 13 | Path( | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 8 8 | _ = PurePath(".") @@ -104,14 +109,15 @@ PTH201.py:11:6: PTH201 [*] Do not pass the current directory explicitly to `Path 13 13 | Path( 14 14 | '', -PTH201.py:14:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:14:5 | 13 | Path( 14 | '', - | ^^ PTH201 + | ^^ 15 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 10 10 | @@ -125,14 +131,15 @@ PTH201.py:14:5: PTH201 [*] Do not pass the current directory explicitly to `Path 17 15 | Path( # Comment before argument 18 16 | '', -PTH201.py:18:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:18:5 | 17 | Path( # Comment before argument 18 | '', - | ^^ PTH201 + | ^^ 19 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 14 14 | '', @@ -146,14 +153,15 @@ PTH201.py:18:5: PTH201 [*] Do not pass the current directory explicitly to `Path 21 19 | Path( 22 20 | '', # EOL comment -PTH201.py:22:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:22:5 | 21 | Path( 22 | '', # EOL comment - | ^^ PTH201 + | ^^ 23 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 18 18 | '', @@ -167,15 +175,16 @@ PTH201.py:22:5: PTH201 [*] Do not pass the current directory explicitly to `Path 25 23 | Path( 26 24 | '' # Comment in the middle of implicitly concatenated string -PTH201.py:26:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:26:5 | 25 | Path( 26 | / '' # Comment in the middle of implicitly concatenated string 27 | | ".", - | |_______^ PTH201 + | |_______^ 28 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 22 22 | '', # EOL comment @@ -190,15 +199,16 @@ PTH201.py:26:5: PTH201 [*] Do not pass the current directory explicitly to `Path 30 27 | Path( 31 28 | '' # Comment before comma -PTH201.py:31:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:31:5 | 30 | Path( 31 | '' # Comment before comma - | ^^ PTH201 + | ^^ 32 | , 33 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 27 27 | ".", @@ -213,14 +223,15 @@ PTH201.py:31:5: PTH201 [*] Do not pass the current directory explicitly to `Path 35 32 | Path( 36 33 | '', -PTH201.py:36:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:36:5 | 35 | Path( 36 | '', - | ^^ PTH201 + | ^^ 37 | ) / "bare" | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 33 33 | ) @@ -234,14 +245,15 @@ PTH201.py:36:5: PTH201 [*] Do not pass the current directory explicitly to `Path 39 39 | Path( # Comment before argument 40 40 | '', -PTH201.py:40:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:40:5 | 39 | Path( # Comment before argument 40 | '', - | ^^ PTH201 + | ^^ 41 | ) / ("parenthesized") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 37 37 | ) / "bare" @@ -255,14 +267,15 @@ PTH201.py:40:5: PTH201 [*] Do not pass the current directory explicitly to `Path 43 43 | Path( 44 44 | '', # EOL comment -PTH201.py:44:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:44:5 | 43 | Path( 44 | '', # EOL comment - | ^^ PTH201 + | ^^ 45 | ) / ( ("double parenthesized" ) ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 41 41 | ) / ("parenthesized") @@ -276,16 +289,17 @@ PTH201.py:44:5: PTH201 [*] Do not pass the current directory explicitly to `Path 47 47 | ( Path( 48 48 | '' # Comment in the middle of implicitly concatenated string -PTH201.py:48:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:48:5 | 47 | ( Path( 48 | / '' # Comment in the middle of implicitly concatenated string 49 | | ".", - | |_______^ PTH201 + | |_______^ 50 | ) )/ (("parenthesized path call") 51 | # Comment between closing parentheses | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 44 44 | '', # EOL comment @@ -303,15 +317,16 @@ PTH201.py:48:5: PTH201 [*] Do not pass the current directory explicitly to `Path 53 52 | 54 53 | Path( -PTH201.py:55:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:55:5 | 54 | Path( 55 | '' # Comment before comma - | ^^ PTH201 + | ^^ 56 | , 57 | ) / "multiple" / ( | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 52 52 | ) diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap index 4ae823b9e1..b7175ee1cd 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap @@ -1,333 +1,365 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH202.py:10:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:10:1 | 10 | os.path.getsize("filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 11 | os.path.getsize(b"filename") 12 | os.path.getsize(Path("filename")) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:11:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:11:1 | 10 | os.path.getsize("filename") 11 | os.path.getsize(b"filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 12 | os.path.getsize(Path("filename")) 13 | os.path.getsize(__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:12:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:12:1 | 10 | os.path.getsize("filename") 11 | os.path.getsize(b"filename") 12 | os.path.getsize(Path("filename")) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 13 | os.path.getsize(__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:13:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:13:1 | 11 | os.path.getsize(b"filename") 12 | os.path.getsize(Path("filename")) 13 | os.path.getsize(__file__) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 14 | 15 | os.path.getsize(filename) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:15:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:15:1 | 13 | os.path.getsize(__file__) 14 | 15 | os.path.getsize(filename) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 16 | os.path.getsize(filename1) 17 | os.path.getsize(filename2) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:16:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:16:1 | 15 | os.path.getsize(filename) 16 | os.path.getsize(filename1) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 17 | os.path.getsize(filename2) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:17:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:17:1 | 15 | os.path.getsize(filename) 16 | os.path.getsize(filename1) 17 | os.path.getsize(filename2) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 18 | 19 | os.path.getsize(filename="filename") | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:19:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:19:1 | 17 | os.path.getsize(filename2) 18 | 19 | os.path.getsize(filename="filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 20 | os.path.getsize(filename=b"filename") 21 | os.path.getsize(filename=Path("filename")) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:20:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:20:1 | 19 | os.path.getsize(filename="filename") 20 | os.path.getsize(filename=b"filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 21 | os.path.getsize(filename=Path("filename")) 22 | os.path.getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:21:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:21:1 | 19 | os.path.getsize(filename="filename") 20 | os.path.getsize(filename=b"filename") 21 | os.path.getsize(filename=Path("filename")) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 22 | os.path.getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:22:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:22:1 | 20 | os.path.getsize(filename=b"filename") 21 | os.path.getsize(filename=Path("filename")) 22 | os.path.getsize(filename=__file__) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 23 | 24 | getsize("filename") | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:24:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:24:1 | 22 | os.path.getsize(filename=__file__) 23 | 24 | getsize("filename") - | ^^^^^^^ PTH202 + | ^^^^^^^ 25 | getsize(b"filename") 26 | getsize(Path("filename")) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:25:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:25:1 | 24 | getsize("filename") 25 | getsize(b"filename") - | ^^^^^^^ PTH202 + | ^^^^^^^ 26 | getsize(Path("filename")) 27 | getsize(__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:26:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:26:1 | 24 | getsize("filename") 25 | getsize(b"filename") 26 | getsize(Path("filename")) - | ^^^^^^^ PTH202 + | ^^^^^^^ 27 | getsize(__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:27:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:27:1 | 25 | getsize(b"filename") 26 | getsize(Path("filename")) 27 | getsize(__file__) - | ^^^^^^^ PTH202 + | ^^^^^^^ 28 | 29 | getsize(filename="filename") | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:29:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:29:1 | 27 | getsize(__file__) 28 | 29 | getsize(filename="filename") - | ^^^^^^^ PTH202 + | ^^^^^^^ 30 | getsize(filename=b"filename") 31 | getsize(filename=Path("filename")) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:30:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:30:1 | 29 | getsize(filename="filename") 30 | getsize(filename=b"filename") - | ^^^^^^^ PTH202 + | ^^^^^^^ 31 | getsize(filename=Path("filename")) 32 | getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:31:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:31:1 | 29 | getsize(filename="filename") 30 | getsize(filename=b"filename") 31 | getsize(filename=Path("filename")) - | ^^^^^^^ PTH202 + | ^^^^^^^ 32 | getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:32:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:32:1 | 30 | getsize(filename=b"filename") 31 | getsize(filename=Path("filename")) 32 | getsize(filename=__file__) - | ^^^^^^^ PTH202 + | ^^^^^^^ 33 | 34 | getsize(filename) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:34:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:34:1 | 32 | getsize(filename=__file__) 33 | 34 | getsize(filename) - | ^^^^^^^ PTH202 + | ^^^^^^^ 35 | getsize(filename1) 36 | getsize(filename2) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:35:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:35:1 | 34 | getsize(filename) 35 | getsize(filename1) - | ^^^^^^^ PTH202 + | ^^^^^^^ 36 | getsize(filename2) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:36:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:36:1 | 34 | getsize(filename) 35 | getsize(filename1) 36 | getsize(filename2) - | ^^^^^^^ PTH202 + | ^^^^^^^ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:39:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:39:1 | 39 | os.path.getsize( - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 40 | "filename", # comment 41 | ) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:43:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:43:1 | 41 | ) 42 | 43 | os.path.getsize( - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 44 | # comment 45 | "filename" | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:50:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:50:1 | 48 | ) 49 | 50 | os.path.getsize( - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 51 | # comment 52 | b"filename" | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:56:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:56:1 | 54 | ) 55 | 56 | os.path.getsize( # comment - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 57 | Path(__file__) 58 | # comment | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:61:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:61:1 | 59 | ) # comment 60 | 61 | getsize( # comment - | ^^^^^^^ PTH202 + | ^^^^^^^ 62 | "filename") | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:64:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:64:1 | 62 | "filename") 63 | 64 | getsize( # comment - | ^^^^^^^ PTH202 + | ^^^^^^^ 65 | b"filename", 66 | #comment | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:69:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:69:1 | 67 | ) 68 | 69 | os.path.getsize("file" + "name") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 70 | 71 | getsize \ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:71:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:71:1 | 69 | os.path.getsize("file" + "name") 70 | 71 | getsize \ - | ^^^^^^^ PTH202 + | ^^^^^^^ 72 | \ 73 | \ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:78:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:78:1 | 76 | ) 77 | 78 | getsize(Path("filename").resolve()) - | ^^^^^^^ PTH202 + | ^^^^^^^ 79 | 80 | import pathlib | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202.py:82:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:82:1 | 80 | import pathlib 81 | 82 | os.path.getsize(pathlib.Path("filename")) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202_2.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202_2.py.snap index a5c3c8b7c2..5b4fade357 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202_2.py.snap @@ -1,31 +1,34 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH202_2.py:3:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202_2.py:3:1 | 1 | import os 2 | 3 | os.path.getsize(filename="filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 4 | os.path.getsize(filename=b"filename") 5 | os.path.getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202_2.py:4:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202_2.py:4:1 | 3 | os.path.getsize(filename="filename") 4 | os.path.getsize(filename=b"filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 5 | os.path.getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` -PTH202_2.py:5:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202_2.py:5:1 | 3 | os.path.getsize(filename="filename") 4 | os.path.getsize(filename=b"filename") 5 | os.path.getsize(filename=__file__) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap index 112cb7933a..2a3663c845 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap @@ -1,142 +1,156 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH203.py:5:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:5:1 | 3 | from os.path import getatime 4 | 5 | os.path.getatime("filename") - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 6 | os.path.getatime(b"filename") 7 | os.path.getatime(Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:6:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:6:1 | 5 | os.path.getatime("filename") 6 | os.path.getatime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 7 | os.path.getatime(Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:7:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:7:1 | 5 | os.path.getatime("filename") 6 | os.path.getatime(b"filename") 7 | os.path.getatime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:10:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:10:1 | 10 | getatime("filename") - | ^^^^^^^^ PTH203 + | ^^^^^^^^ 11 | getatime(b"filename") 12 | getatime(Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:11:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:11:1 | 10 | getatime("filename") 11 | getatime(b"filename") - | ^^^^^^^^ PTH203 + | ^^^^^^^^ 12 | getatime(Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:12:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:12:1 | 10 | getatime("filename") 11 | getatime(b"filename") 12 | getatime(Path("filename")) - | ^^^^^^^^ PTH203 + | ^^^^^^^^ | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:17:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:17:1 | 15 | file = __file__ 16 | 17 | os.path.getatime(file) - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 18 | os.path.getatime(filename="filename") 19 | os.path.getatime(filename=Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:18:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:18:1 | 17 | os.path.getatime(file) 18 | os.path.getatime(filename="filename") - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 19 | os.path.getatime(filename=Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:19:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:19:1 | 17 | os.path.getatime(file) 18 | os.path.getatime(filename="filename") 19 | os.path.getatime(filename=Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 20 | 21 | os.path.getatime( # comment 1 | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:21:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:21:1 | 19 | os.path.getatime(filename=Path("filename")) 20 | 21 | os.path.getatime( # comment 1 - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 22 | # comment 2 23 | "filename" # comment 3 | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:29:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:29:1 | 27 | ) # comment 7 28 | 29 | os.path.getatime("file" + "name") - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 30 | 31 | getatime(Path("filename").resolve()) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:31:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:31:1 | 29 | os.path.getatime("file" + "name") 30 | 31 | getatime(Path("filename").resolve()) - | ^^^^^^^^ PTH203 + | ^^^^^^^^ 32 | 33 | os.path.getatime(pathlib.Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:33:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:33:1 | 31 | getatime(Path("filename").resolve()) 32 | 33 | os.path.getatime(pathlib.Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 34 | 35 | getatime(Path("dir") / "file.txt") | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` -PTH203.py:35:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:35:1 | 33 | os.path.getatime(pathlib.Path("filename")) 34 | 35 | getatime(Path("dir") / "file.txt") - | ^^^^^^^^ PTH203 + | ^^^^^^^^ | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap index 7e3b242486..10b08dfdb3 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap @@ -1,56 +1,62 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH204.py:6:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:6:1 | 6 | os.path.getmtime("filename") - | ^^^^^^^^^^^^^^^^ PTH204 + | ^^^^^^^^^^^^^^^^ 7 | os.path.getmtime(b"filename") 8 | os.path.getmtime(Path("filename")) | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` -PTH204.py:7:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:7:1 | 6 | os.path.getmtime("filename") 7 | os.path.getmtime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH204 + | ^^^^^^^^^^^^^^^^ 8 | os.path.getmtime(Path("filename")) | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` -PTH204.py:8:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:8:1 | 6 | os.path.getmtime("filename") 7 | os.path.getmtime(b"filename") 8 | os.path.getmtime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH204 + | ^^^^^^^^^^^^^^^^ | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` -PTH204.py:11:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:11:1 | 11 | getmtime("filename") - | ^^^^^^^^ PTH204 + | ^^^^^^^^ 12 | getmtime(b"filename") 13 | getmtime(Path("filename")) | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` -PTH204.py:12:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:12:1 | 11 | getmtime("filename") 12 | getmtime(b"filename") - | ^^^^^^^^ PTH204 + | ^^^^^^^^ 13 | getmtime(Path("filename")) | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` -PTH204.py:13:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:13:1 | 11 | getmtime("filename") 12 | getmtime(b"filename") 13 | getmtime(Path("filename")) - | ^^^^^^^^ PTH204 + | ^^^^^^^^ | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap index a8b523d0ce..65ae0f7219 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap @@ -1,60 +1,66 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH205.py:6:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:6:1 | 6 | os.path.getctime("filename") - | ^^^^^^^^^^^^^^^^ PTH205 + | ^^^^^^^^^^^^^^^^ 7 | os.path.getctime(b"filename") 8 | os.path.getctime(Path("filename")) | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` -PTH205.py:7:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:7:1 | 6 | os.path.getctime("filename") 7 | os.path.getctime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH205 + | ^^^^^^^^^^^^^^^^ 8 | os.path.getctime(Path("filename")) | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` -PTH205.py:8:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:8:1 | 6 | os.path.getctime("filename") 7 | os.path.getctime(b"filename") 8 | os.path.getctime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH205 + | ^^^^^^^^^^^^^^^^ 9 | 10 | getctime("filename") | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` -PTH205.py:10:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:10:1 | 8 | os.path.getctime(Path("filename")) 9 | 10 | getctime("filename") - | ^^^^^^^^ PTH205 + | ^^^^^^^^ 11 | getctime(b"filename") 12 | getctime(Path("filename")) | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` -PTH205.py:11:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:11:1 | 10 | getctime("filename") 11 | getctime(b"filename") - | ^^^^^^^^ PTH205 + | ^^^^^^^^ 12 | getctime(Path("filename")) | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` -PTH205.py:12:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:12:1 | 10 | getctime("filename") 11 | getctime(b"filename") 12 | getctime(Path("filename")) - | ^^^^^^^^ PTH205 + | ^^^^^^^^ | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap index 70e6338726..fa7b62d657 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap @@ -1,100 +1,110 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH206.py:8:12: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:8:12 | 7 | # PTH206 8 | "foo/bar/".split(os.sep) - | ^^^^^ PTH206 + | ^^^^^ 9 | "foo/bar/".split(sep=os.sep) 10 | "foo/bar/".split(os.sep)[-1] | -PTH206.py:9:12: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:9:12 | 7 | # PTH206 8 | "foo/bar/".split(os.sep) 9 | "foo/bar/".split(sep=os.sep) - | ^^^^^ PTH206 + | ^^^^^ 10 | "foo/bar/".split(os.sep)[-1] 11 | "foo/bar/".split(os.sep)[-2] | -PTH206.py:10:12: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:10:12 | 8 | "foo/bar/".split(os.sep) 9 | "foo/bar/".split(sep=os.sep) 10 | "foo/bar/".split(os.sep)[-1] - | ^^^^^ PTH206 + | ^^^^^ 11 | "foo/bar/".split(os.sep)[-2] 12 | "foo/bar/".split(os.sep)[-2:] | -PTH206.py:11:12: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:11:12 | 9 | "foo/bar/".split(sep=os.sep) 10 | "foo/bar/".split(os.sep)[-1] 11 | "foo/bar/".split(os.sep)[-2] - | ^^^^^ PTH206 + | ^^^^^ 12 | "foo/bar/".split(os.sep)[-2:] 13 | "fizz/buzz".split(sep) | -PTH206.py:12:12: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:12:12 | 10 | "foo/bar/".split(os.sep)[-1] 11 | "foo/bar/".split(os.sep)[-2] 12 | "foo/bar/".split(os.sep)[-2:] - | ^^^^^ PTH206 + | ^^^^^ 13 | "fizz/buzz".split(sep) 14 | "fizz/buzz".split(sep)[-1] | -PTH206.py:13:13: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:13:13 | 11 | "foo/bar/".split(os.sep)[-2] 12 | "foo/bar/".split(os.sep)[-2:] 13 | "fizz/buzz".split(sep) - | ^^^^^ PTH206 + | ^^^^^ 14 | "fizz/buzz".split(sep)[-1] 15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] | -PTH206.py:14:13: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:14:13 | 12 | "foo/bar/".split(os.sep)[-2:] 13 | "fizz/buzz".split(sep) 14 | "fizz/buzz".split(sep)[-1] - | ^^^^^ PTH206 + | ^^^^^ 15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] 16 | file_name.split(os.sep) | -PTH206.py:15:47: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:15:47 | 13 | "fizz/buzz".split(sep) 14 | "fizz/buzz".split(sep)[-1] 15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] - | ^^^^^ PTH206 + | ^^^^^ 16 | file_name.split(os.sep) 17 | (os.path.abspath(file_name)).split(os.sep) | -PTH206.py:16:11: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:16:11 | 14 | "fizz/buzz".split(sep)[-1] 15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] 16 | file_name.split(os.sep) - | ^^^^^ PTH206 + | ^^^^^ 17 | (os.path.abspath(file_name)).split(os.sep) | -PTH206.py:17:30: PTH206 Replace `.split(os.sep)` with `Path.parts` +PTH206 Replace `.split(os.sep)` with `Path.parts` + --> PTH206.py:17:30 | 15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] 16 | file_name.split(os.sep) 17 | (os.path.abspath(file_name)).split(os.sep) - | ^^^^^ PTH206 + | ^^^^^ 18 | 19 | # OK | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap index ddcba2ba59..8df4194155 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH207.py:9:1: PTH207 Replace `glob` with `Path.glob` or `Path.rglob` +PTH207 Replace `glob` with `Path.glob` or `Path.rglob` + --> PTH207.py:9:1 | 8 | # PTH207 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) - | ^^^^^^^^^ PTH207 + | ^^^^^^^^^ 10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) 11 | search("*.png") | -PTH207.py:10:6: PTH207 Replace `iglob` with `Path.glob` or `Path.rglob` +PTH207 Replace `iglob` with `Path.glob` or `Path.rglob` + --> PTH207.py:10:6 | 8 | # PTH207 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) 10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) - | ^^^^^^^^^^ PTH207 + | ^^^^^^^^^^ 11 | search("*.png") | -PTH207.py:11:1: PTH207 Replace `glob` with `Path.glob` or `Path.rglob` +PTH207 Replace `glob` with `Path.glob` or `Path.rglob` + --> PTH207.py:11:1 | 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) 10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) 11 | search("*.png") - | ^^^^^^ PTH207 + | ^^^^^^ 12 | 13 | # if `dir_fd` is set, suppress the diagnostic | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH208_PTH208.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH208_PTH208.py.snap index f8dfff97ec..b35f942060 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH208_PTH208.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH208_PTH208.py.snap @@ -1,59 +1,66 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH208.py:3:1: PTH208 Use `pathlib.Path.iterdir()` instead. +PTH208 Use `pathlib.Path.iterdir()` instead. + --> PTH208.py:3:1 | 1 | import os 2 | 3 | os.listdir('.') - | ^^^^^^^^^^ PTH208 + | ^^^^^^^^^^ 4 | os.listdir(b'.') | -PTH208.py:4:1: PTH208 Use `pathlib.Path.iterdir()` instead. +PTH208 Use `pathlib.Path.iterdir()` instead. + --> PTH208.py:4:1 | 3 | os.listdir('.') 4 | os.listdir(b'.') - | ^^^^^^^^^^ PTH208 + | ^^^^^^^^^^ 5 | 6 | string_path = '.' | -PTH208.py:7:1: PTH208 Use `pathlib.Path.iterdir()` instead. +PTH208 Use `pathlib.Path.iterdir()` instead. + --> PTH208.py:7:1 | 6 | string_path = '.' 7 | os.listdir(string_path) - | ^^^^^^^^^^ PTH208 + | ^^^^^^^^^^ 8 | 9 | bytes_path = b'.' | -PTH208.py:10:1: PTH208 Use `pathlib.Path.iterdir()` instead. +PTH208 Use `pathlib.Path.iterdir()` instead. + --> PTH208.py:10:1 | 9 | bytes_path = b'.' 10 | os.listdir(bytes_path) - | ^^^^^^^^^^ PTH208 + | ^^^^^^^^^^ | -PTH208.py:16:1: PTH208 Use `pathlib.Path.iterdir()` instead. +PTH208 Use `pathlib.Path.iterdir()` instead. + --> PTH208.py:16:1 | 15 | path_path = Path('.') 16 | os.listdir(path_path) - | ^^^^^^^^^^ PTH208 + | ^^^^^^^^^^ | -PTH208.py:19:4: PTH208 Use `pathlib.Path.iterdir()` instead. +PTH208 Use `pathlib.Path.iterdir()` instead. + --> PTH208.py:19:4 | 19 | if os.listdir("dir"): - | ^^^^^^^^^^ PTH208 + | ^^^^^^^^^^ 20 | ... | -PTH208.py:22:14: PTH208 Use `pathlib.Path.iterdir()` instead. +PTH208 Use `pathlib.Path.iterdir()` instead. + --> PTH208.py:22:14 | 20 | ... 21 | 22 | if "file" in os.listdir("dir"): - | ^^^^^^^^^^ PTH208 + | ^^^^^^^^^^ 23 | ... | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210.py.snap index ad539aa709..512cbe18b3 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210.py.snap @@ -1,26 +1,28 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH210.py:21:1: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210.py:21:1 | 20 | ### Errors 21 | path.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^ 22 | path.with_suffix("py") 23 | path.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210.py:22:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:22:1 | 20 | ### Errors 21 | path.with_suffix(".") 22 | path.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^ 23 | path.with_suffix(r"s") 24 | path.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 19 19 | @@ -32,16 +34,17 @@ PTH210.py:22:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 24 24 | path.with_suffix(u'' "json") 25 25 | path.with_suffix(suffix="js") -PTH210.py:23:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:23:1 | 21 | path.with_suffix(".") 22 | path.with_suffix("py") 23 | path.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^ 24 | path.with_suffix(u'' "json") 25 | path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 20 20 | ### Errors @@ -53,15 +56,16 @@ PTH210.py:23:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 25 25 | path.with_suffix(suffix="js") 26 26 | -PTH210.py:24:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:24:1 | 22 | path.with_suffix("py") 23 | path.with_suffix(r"s") 24 | path.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 21 21 | path.with_suffix(".") @@ -73,16 +77,17 @@ PTH210.py:24:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 26 26 | 27 27 | posix_path.with_suffix(".") -PTH210.py:25:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:25:1 | 23 | path.with_suffix(r"s") 24 | path.with_suffix(u'' "json") 25 | path.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | posix_path.with_suffix(".") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 22 22 | path.with_suffix("py") @@ -94,26 +99,28 @@ PTH210.py:25:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 27 27 | posix_path.with_suffix(".") 28 28 | posix_path.with_suffix("py") -PTH210.py:27:1: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210.py:27:1 | 25 | path.with_suffix(suffix="js") 26 | 27 | posix_path.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | posix_path.with_suffix("py") 29 | posix_path.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210.py:28:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:28:1 | 27 | posix_path.with_suffix(".") 28 | posix_path.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | posix_path.with_suffix(r"s") 30 | posix_path.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 25 25 | path.with_suffix(suffix="js") @@ -125,16 +132,17 @@ PTH210.py:28:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 30 30 | posix_path.with_suffix(u'' "json") 31 31 | posix_path.with_suffix(suffix="js") -PTH210.py:29:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:29:1 | 27 | posix_path.with_suffix(".") 28 | posix_path.with_suffix("py") 29 | posix_path.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | posix_path.with_suffix(u'' "json") 31 | posix_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 26 26 | @@ -146,15 +154,16 @@ PTH210.py:29:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 31 31 | posix_path.with_suffix(suffix="js") 32 32 | -PTH210.py:30:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:30:1 | 28 | posix_path.with_suffix("py") 29 | posix_path.with_suffix(r"s") 30 | posix_path.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | posix_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 27 27 | posix_path.with_suffix(".") @@ -166,16 +175,17 @@ PTH210.py:30:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 32 32 | 33 33 | pure_path.with_suffix(".") -PTH210.py:31:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:31:1 | 29 | posix_path.with_suffix(r"s") 30 | posix_path.with_suffix(u'' "json") 31 | posix_path.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | pure_path.with_suffix(".") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 28 28 | posix_path.with_suffix("py") @@ -187,26 +197,28 @@ PTH210.py:31:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 33 33 | pure_path.with_suffix(".") 34 34 | pure_path.with_suffix("py") -PTH210.py:33:1: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210.py:33:1 | 31 | posix_path.with_suffix(suffix="js") 32 | 33 | pure_path.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | pure_path.with_suffix("py") 35 | pure_path.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210.py:34:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:34:1 | 33 | pure_path.with_suffix(".") 34 | pure_path.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | pure_path.with_suffix(r"s") 36 | pure_path.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 31 31 | posix_path.with_suffix(suffix="js") @@ -218,16 +230,17 @@ PTH210.py:34:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 36 36 | pure_path.with_suffix(u'' "json") 37 37 | pure_path.with_suffix(suffix="js") -PTH210.py:35:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:35:1 | 33 | pure_path.with_suffix(".") 34 | pure_path.with_suffix("py") 35 | pure_path.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | pure_path.with_suffix(u'' "json") 37 | pure_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 32 32 | @@ -239,15 +252,16 @@ PTH210.py:35:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 37 37 | pure_path.with_suffix(suffix="js") 38 38 | -PTH210.py:36:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:36:1 | 34 | pure_path.with_suffix("py") 35 | pure_path.with_suffix(r"s") 36 | pure_path.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | pure_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 33 33 | pure_path.with_suffix(".") @@ -259,16 +273,17 @@ PTH210.py:36:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 38 38 | 39 39 | pure_posix_path.with_suffix(".") -PTH210.py:37:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:37:1 | 35 | pure_path.with_suffix(r"s") 36 | pure_path.with_suffix(u'' "json") 37 | pure_path.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | 39 | pure_posix_path.with_suffix(".") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 34 34 | pure_path.with_suffix("py") @@ -280,26 +295,28 @@ PTH210.py:37:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 39 39 | pure_posix_path.with_suffix(".") 40 40 | pure_posix_path.with_suffix("py") -PTH210.py:39:1: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210.py:39:1 | 37 | pure_path.with_suffix(suffix="js") 38 | 39 | pure_posix_path.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | pure_posix_path.with_suffix("py") 41 | pure_posix_path.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210.py:40:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:40:1 | 39 | pure_posix_path.with_suffix(".") 40 | pure_posix_path.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | pure_posix_path.with_suffix(r"s") 42 | pure_posix_path.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 37 37 | pure_path.with_suffix(suffix="js") @@ -311,16 +328,17 @@ PTH210.py:40:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 42 42 | pure_posix_path.with_suffix(u'' "json") 43 43 | pure_posix_path.with_suffix(suffix="js") -PTH210.py:41:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:41:1 | 39 | pure_posix_path.with_suffix(".") 40 | pure_posix_path.with_suffix("py") 41 | pure_posix_path.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | pure_posix_path.with_suffix(u'' "json") 43 | pure_posix_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 38 38 | @@ -332,15 +350,16 @@ PTH210.py:41:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 43 43 | pure_posix_path.with_suffix(suffix="js") 44 44 | -PTH210.py:42:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:42:1 | 40 | pure_posix_path.with_suffix("py") 41 | pure_posix_path.with_suffix(r"s") 42 | pure_posix_path.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | pure_posix_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 39 39 | pure_posix_path.with_suffix(".") @@ -352,16 +371,17 @@ PTH210.py:42:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 44 44 | 45 45 | pure_windows_path.with_suffix(".") -PTH210.py:43:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:43:1 | 41 | pure_posix_path.with_suffix(r"s") 42 | pure_posix_path.with_suffix(u'' "json") 43 | pure_posix_path.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | pure_windows_path.with_suffix(".") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 40 40 | pure_posix_path.with_suffix("py") @@ -373,26 +393,28 @@ PTH210.py:43:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 45 45 | pure_windows_path.with_suffix(".") 46 46 | pure_windows_path.with_suffix("py") -PTH210.py:45:1: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210.py:45:1 | 43 | pure_posix_path.with_suffix(suffix="js") 44 | 45 | pure_windows_path.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | pure_windows_path.with_suffix("py") 47 | pure_windows_path.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210.py:46:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:46:1 | 45 | pure_windows_path.with_suffix(".") 46 | pure_windows_path.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | pure_windows_path.with_suffix(r"s") 48 | pure_windows_path.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 43 43 | pure_posix_path.with_suffix(suffix="js") @@ -404,16 +426,17 @@ PTH210.py:46:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 48 48 | pure_windows_path.with_suffix(u'' "json") 49 49 | pure_windows_path.with_suffix(suffix="js") -PTH210.py:47:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:47:1 | 45 | pure_windows_path.with_suffix(".") 46 | pure_windows_path.with_suffix("py") 47 | pure_windows_path.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | pure_windows_path.with_suffix(u'' "json") 49 | pure_windows_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 44 44 | @@ -425,15 +448,16 @@ PTH210.py:47:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 49 49 | pure_windows_path.with_suffix(suffix="js") 50 50 | -PTH210.py:48:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:48:1 | 46 | pure_windows_path.with_suffix("py") 47 | pure_windows_path.with_suffix(r"s") 48 | pure_windows_path.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 49 | pure_windows_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 45 45 | pure_windows_path.with_suffix(".") @@ -445,16 +469,17 @@ PTH210.py:48:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 50 50 | 51 51 | windows_path.with_suffix(".") -PTH210.py:49:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:49:1 | 47 | pure_windows_path.with_suffix(r"s") 48 | pure_windows_path.with_suffix(u'' "json") 49 | pure_windows_path.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | windows_path.with_suffix(".") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 46 46 | pure_windows_path.with_suffix("py") @@ -466,26 +491,28 @@ PTH210.py:49:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 51 51 | windows_path.with_suffix(".") 52 52 | windows_path.with_suffix("py") -PTH210.py:51:1: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210.py:51:1 | 49 | pure_windows_path.with_suffix(suffix="js") 50 | 51 | windows_path.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | windows_path.with_suffix("py") 53 | windows_path.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210.py:52:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:52:1 | 51 | windows_path.with_suffix(".") 52 | windows_path.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 53 | windows_path.with_suffix(r"s") 54 | windows_path.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 49 49 | pure_windows_path.with_suffix(suffix="js") @@ -497,16 +524,17 @@ PTH210.py:52:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 54 54 | windows_path.with_suffix(u'' "json") 55 55 | windows_path.with_suffix(suffix="js") -PTH210.py:53:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:53:1 | 51 | windows_path.with_suffix(".") 52 | windows_path.with_suffix("py") 53 | windows_path.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | windows_path.with_suffix(u'' "json") 55 | windows_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 50 50 | @@ -518,15 +546,16 @@ PTH210.py:53:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 55 55 | windows_path.with_suffix(suffix="js") 56 56 | -PTH210.py:54:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:54:1 | 52 | windows_path.with_suffix("py") 53 | windows_path.with_suffix(r"s") 54 | windows_path.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | windows_path.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 51 51 | windows_path.with_suffix(".") @@ -538,16 +567,17 @@ PTH210.py:54:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 56 56 | 57 57 | Path().with_suffix(".") -PTH210.py:55:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:55:1 | 53 | windows_path.with_suffix(r"s") 54 | windows_path.with_suffix(u'' "json") 55 | windows_path.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | 57 | Path().with_suffix(".") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 52 52 | windows_path.with_suffix("py") @@ -559,26 +589,28 @@ PTH210.py:55:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 57 57 | Path().with_suffix(".") 58 58 | Path().with_suffix("py") -PTH210.py:57:1: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210.py:57:1 | 55 | windows_path.with_suffix(suffix="js") 56 | 57 | Path().with_suffix(".") - | ^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^ 58 | Path().with_suffix("py") 59 | PosixPath().with_suffix("py") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210.py:58:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:58:1 | 57 | Path().with_suffix(".") 58 | Path().with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 59 | PosixPath().with_suffix("py") 60 | PurePath().with_suffix("py") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 55 55 | windows_path.with_suffix(suffix="js") @@ -590,16 +622,17 @@ PTH210.py:58:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 60 60 | PurePath().with_suffix("py") 61 61 | PurePosixPath().with_suffix("py") -PTH210.py:59:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:59:1 | 57 | Path().with_suffix(".") 58 | Path().with_suffix("py") 59 | PosixPath().with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | PurePath().with_suffix("py") 61 | PurePosixPath().with_suffix("py") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 56 56 | @@ -611,16 +644,17 @@ PTH210.py:59:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 61 61 | PurePosixPath().with_suffix("py") 62 62 | PureWindowsPath().with_suffix("py") -PTH210.py:60:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:60:1 | 58 | Path().with_suffix("py") 59 | PosixPath().with_suffix("py") 60 | PurePath().with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | PurePosixPath().with_suffix("py") 62 | PureWindowsPath().with_suffix("py") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 57 57 | Path().with_suffix(".") @@ -632,16 +666,17 @@ PTH210.py:60:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 62 62 | PureWindowsPath().with_suffix("py") 63 63 | WindowsPath().with_suffix("py") -PTH210.py:61:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:61:1 | 59 | PosixPath().with_suffix("py") 60 | PurePath().with_suffix("py") 61 | PurePosixPath().with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 62 | PureWindowsPath().with_suffix("py") 63 | WindowsPath().with_suffix("py") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 58 58 | Path().with_suffix("py") @@ -653,15 +688,16 @@ PTH210.py:61:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 63 63 | WindowsPath().with_suffix("py") 64 64 | -PTH210.py:62:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:62:1 | 60 | PurePath().with_suffix("py") 61 | PurePosixPath().with_suffix("py") 62 | PureWindowsPath().with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | WindowsPath().with_suffix("py") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 59 59 | PosixPath().with_suffix("py") @@ -673,16 +709,17 @@ PTH210.py:62:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` 64 64 | 65 65 | ### No errors -PTH210.py:63:1: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210.py:63:1 | 61 | PurePosixPath().with_suffix("py") 62 | PureWindowsPath().with_suffix("py") 63 | WindowsPath().with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | 65 | ### No errors | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 60 60 | PurePath().with_suffix("py") diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210_1.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210_1.py.snap index 9778ac85a9..04a5e8e740 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210_1.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH210_PTH210_1.py.snap @@ -1,27 +1,29 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH210_1.py:13:5: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210_1.py:13:5 | 11 | def test_path(p: Path) -> None: 12 | ## Errors 13 | p.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^ 14 | p.with_suffix("py") 15 | p.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210_1.py:14:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:14:5 | 12 | ## Errors 13 | p.with_suffix(".") 14 | p.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 15 | p.with_suffix(r"s") 16 | p.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 11 11 | def test_path(p: Path) -> None: @@ -33,16 +35,17 @@ PTH210_1.py:14:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 16 16 | p.with_suffix(u'' "json") 17 17 | p.with_suffix(suffix="js") -PTH210_1.py:15:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:15:5 | 13 | p.with_suffix(".") 14 | p.with_suffix("py") 15 | p.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 16 | p.with_suffix(u'' "json") 17 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 12 12 | ## Errors @@ -54,15 +57,16 @@ PTH210_1.py:15:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 17 17 | p.with_suffix(suffix="js") 18 18 | -PTH210_1.py:16:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:16:5 | 14 | p.with_suffix("py") 15 | p.with_suffix(r"s") 16 | p.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 13 13 | p.with_suffix(".") @@ -74,16 +78,17 @@ PTH210_1.py:16:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 18 18 | 19 19 | ## No errors -PTH210_1.py:17:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:17:5 | 15 | p.with_suffix(r"s") 16 | p.with_suffix(u'' "json") 17 | p.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | ## No errors | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 14 14 | p.with_suffix("py") @@ -95,27 +100,29 @@ PTH210_1.py:17:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 19 19 | ## No errors 20 20 | p.with_suffix() -PTH210_1.py:31:5: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210_1.py:31:5 | 29 | def test_posix_path(p: PosixPath) -> None: 30 | ## Errors 31 | p.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^ 32 | p.with_suffix("py") 33 | p.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210_1.py:32:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:32:5 | 30 | ## Errors 31 | p.with_suffix(".") 32 | p.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 33 | p.with_suffix(r"s") 34 | p.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 29 29 | def test_posix_path(p: PosixPath) -> None: @@ -127,16 +134,17 @@ PTH210_1.py:32:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 34 34 | p.with_suffix(u'' "json") 35 35 | p.with_suffix(suffix="js") -PTH210_1.py:33:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:33:5 | 31 | p.with_suffix(".") 32 | p.with_suffix("py") 33 | p.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 34 | p.with_suffix(u'' "json") 35 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 30 30 | ## Errors @@ -148,15 +156,16 @@ PTH210_1.py:33:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 35 35 | p.with_suffix(suffix="js") 36 36 | -PTH210_1.py:34:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:34:5 | 32 | p.with_suffix("py") 33 | p.with_suffix(r"s") 34 | p.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 31 31 | p.with_suffix(".") @@ -168,16 +177,17 @@ PTH210_1.py:34:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 36 36 | 37 37 | ## No errors -PTH210_1.py:35:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:35:5 | 33 | p.with_suffix(r"s") 34 | p.with_suffix(u'' "json") 35 | p.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | 37 | ## No errors | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 32 32 | p.with_suffix("py") @@ -189,27 +199,29 @@ PTH210_1.py:35:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 37 37 | ## No errors 38 38 | p.with_suffix() -PTH210_1.py:49:5: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210_1.py:49:5 | 47 | def test_pure_path(p: PurePath) -> None: 48 | ## Errors 49 | p.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^ 50 | p.with_suffix("py") 51 | p.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210_1.py:50:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:50:5 | 48 | ## Errors 49 | p.with_suffix(".") 50 | p.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 51 | p.with_suffix(r"s") 52 | p.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 47 47 | def test_pure_path(p: PurePath) -> None: @@ -221,16 +233,17 @@ PTH210_1.py:50:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 52 52 | p.with_suffix(u'' "json") 53 53 | p.with_suffix(suffix="js") -PTH210_1.py:51:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:51:5 | 49 | p.with_suffix(".") 50 | p.with_suffix("py") 51 | p.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 52 | p.with_suffix(u'' "json") 53 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 48 48 | ## Errors @@ -242,15 +255,16 @@ PTH210_1.py:51:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 53 53 | p.with_suffix(suffix="js") 54 54 | -PTH210_1.py:52:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:52:5 | 50 | p.with_suffix("py") 51 | p.with_suffix(r"s") 52 | p.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 53 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 49 49 | p.with_suffix(".") @@ -262,16 +276,17 @@ PTH210_1.py:52:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 54 54 | 55 55 | ## No errors -PTH210_1.py:53:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:53:5 | 51 | p.with_suffix(r"s") 52 | p.with_suffix(u'' "json") 53 | p.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | 55 | ## No errors | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 50 50 | p.with_suffix("py") @@ -283,27 +298,29 @@ PTH210_1.py:53:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 55 55 | ## No errors 56 56 | p.with_suffix() -PTH210_1.py:67:5: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210_1.py:67:5 | 65 | def test_pure_posix_path(p: PurePosixPath) -> None: 66 | ## Errors 67 | p.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^ 68 | p.with_suffix("py") 69 | p.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210_1.py:68:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:68:5 | 66 | ## Errors 67 | p.with_suffix(".") 68 | p.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 69 | p.with_suffix(r"s") 70 | p.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 65 65 | def test_pure_posix_path(p: PurePosixPath) -> None: @@ -315,16 +332,17 @@ PTH210_1.py:68:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 70 70 | p.with_suffix(u'' "json") 71 71 | p.with_suffix(suffix="js") -PTH210_1.py:69:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:69:5 | 67 | p.with_suffix(".") 68 | p.with_suffix("py") 69 | p.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 70 | p.with_suffix(u'' "json") 71 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 66 66 | ## Errors @@ -336,15 +354,16 @@ PTH210_1.py:69:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 71 71 | p.with_suffix(suffix="js") 72 72 | -PTH210_1.py:70:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:70:5 | 68 | p.with_suffix("py") 69 | p.with_suffix(r"s") 70 | p.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 71 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 67 67 | p.with_suffix(".") @@ -356,16 +375,17 @@ PTH210_1.py:70:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 72 72 | 73 73 | ## No errors -PTH210_1.py:71:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:71:5 | 69 | p.with_suffix(r"s") 70 | p.with_suffix(u'' "json") 71 | p.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | ## No errors | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 68 68 | p.with_suffix("py") @@ -377,27 +397,29 @@ PTH210_1.py:71:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 73 73 | ## No errors 74 74 | p.with_suffix() -PTH210_1.py:85:5: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210_1.py:85:5 | 83 | def test_pure_windows_path(p: PureWindowsPath) -> None: 84 | ## Errors 85 | p.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^ 86 | p.with_suffix("py") 87 | p.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210_1.py:86:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:86:5 | 84 | ## Errors 85 | p.with_suffix(".") 86 | p.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 87 | p.with_suffix(r"s") 88 | p.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 83 83 | def test_pure_windows_path(p: PureWindowsPath) -> None: @@ -409,16 +431,17 @@ PTH210_1.py:86:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 88 88 | p.with_suffix(u'' "json") 89 89 | p.with_suffix(suffix="js") -PTH210_1.py:87:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:87:5 | 85 | p.with_suffix(".") 86 | p.with_suffix("py") 87 | p.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 88 | p.with_suffix(u'' "json") 89 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 84 84 | ## Errors @@ -430,15 +453,16 @@ PTH210_1.py:87:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 89 89 | p.with_suffix(suffix="js") 90 90 | -PTH210_1.py:88:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:88:5 | 86 | p.with_suffix("py") 87 | p.with_suffix(r"s") 88 | p.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 89 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 85 85 | p.with_suffix(".") @@ -450,16 +474,17 @@ PTH210_1.py:88:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 90 90 | 91 91 | ## No errors -PTH210_1.py:89:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:89:5 | 87 | p.with_suffix(r"s") 88 | p.with_suffix(u'' "json") 89 | p.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | 91 | ## No errors | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 86 86 | p.with_suffix("py") @@ -471,27 +496,29 @@ PTH210_1.py:89:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 91 91 | ## No errors 92 92 | p.with_suffix() -PTH210_1.py:103:5: PTH210 Invalid suffix passed to `.with_suffix()` +PTH210 Invalid suffix passed to `.with_suffix()` + --> PTH210_1.py:103:5 | 101 | def test_windows_path(p: WindowsPath) -> None: 102 | ## Errors 103 | p.with_suffix(".") - | ^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^ 104 | p.with_suffix("py") 105 | p.with_suffix(r"s") | - = help: Remove "." or extend to valid suffix +help: Remove "." or extend to valid suffix -PTH210_1.py:104:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:104:5 | 102 | ## Errors 103 | p.with_suffix(".") 104 | p.with_suffix("py") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 105 | p.with_suffix(r"s") 106 | p.with_suffix(u'' "json") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 101 101 | def test_windows_path(p: WindowsPath) -> None: @@ -503,16 +530,17 @@ PTH210_1.py:104:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 106 106 | p.with_suffix(u'' "json") 107 107 | p.with_suffix(suffix="js") -PTH210_1.py:105:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:105:5 | 103 | p.with_suffix(".") 104 | p.with_suffix("py") 105 | p.with_suffix(r"s") - | ^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^ 106 | p.with_suffix(u'' "json") 107 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 102 102 | ## Errors @@ -524,15 +552,16 @@ PTH210_1.py:105:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 107 107 | p.with_suffix(suffix="js") 108 108 | -PTH210_1.py:106:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:106:5 | 104 | p.with_suffix("py") 105 | p.with_suffix(r"s") 106 | p.with_suffix(u'' "json") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 107 | p.with_suffix(suffix="js") | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 103 103 | p.with_suffix(".") @@ -544,16 +573,17 @@ PTH210_1.py:106:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` 108 108 | 109 109 | ## No errors -PTH210_1.py:107:5: PTH210 [*] Dotless suffix passed to `.with_suffix()` +PTH210 [*] Dotless suffix passed to `.with_suffix()` + --> PTH210_1.py:107:5 | 105 | p.with_suffix(r"s") 106 | p.with_suffix(u'' "json") 107 | p.with_suffix(suffix="js") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PTH210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 108 | 109 | ## No errors | - = help: Add a leading dot +help: Add a leading dot ℹ Unsafe fix 104 104 | p.with_suffix("py") diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH211_PTH211.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH211_PTH211.py.snap index 76ac48db2c..69dffd9abb 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH211_PTH211.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH211_PTH211.py.snap @@ -1,36 +1,40 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH211.py:5:1: PTH211 `os.symlink` should be replaced by `Path.symlink_to` +PTH211 `os.symlink` should be replaced by `Path.symlink_to` + --> PTH211.py:5:1 | 5 | os.symlink("usr/bin/python", "tmp/python") - | ^^^^^^^^^^ PTH211 + | ^^^^^^^^^^ 6 | os.symlink(b"usr/bin/python", b"tmp/python") 7 | Path("tmp/python").symlink_to("usr/bin/python") # Ok | -PTH211.py:6:1: PTH211 `os.symlink` should be replaced by `Path.symlink_to` +PTH211 `os.symlink` should be replaced by `Path.symlink_to` + --> PTH211.py:6:1 | 5 | os.symlink("usr/bin/python", "tmp/python") 6 | os.symlink(b"usr/bin/python", b"tmp/python") - | ^^^^^^^^^^ PTH211 + | ^^^^^^^^^^ 7 | Path("tmp/python").symlink_to("usr/bin/python") # Ok | -PTH211.py:9:1: PTH211 `os.symlink` should be replaced by `Path.symlink_to` +PTH211 `os.symlink` should be replaced by `Path.symlink_to` + --> PTH211.py:9:1 | 7 | Path("tmp/python").symlink_to("usr/bin/python") # Ok 8 | 9 | os.symlink("usr/bin/python", "tmp/python", target_is_directory=True) - | ^^^^^^^^^^ PTH211 + | ^^^^^^^^^^ 10 | os.symlink(b"usr/bin/python", b"tmp/python", target_is_directory=True) 11 | Path("tmp/python").symlink_to("usr/bin/python", target_is_directory=True) # Ok | -PTH211.py:10:1: PTH211 `os.symlink` should be replaced by `Path.symlink_to` +PTH211 `os.symlink` should be replaced by `Path.symlink_to` + --> PTH211.py:10:1 | 9 | os.symlink("usr/bin/python", "tmp/python", target_is_directory=True) 10 | os.symlink(b"usr/bin/python", b"tmp/python", target_is_directory=True) - | ^^^^^^^^^^ PTH211 + | ^^^^^^^^^^ 11 | Path("tmp/python").symlink_to("usr/bin/python", target_is_directory=True) # Ok | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap index a1e7f26c6f..7a22a5615d 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap @@ -1,386 +1,423 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -full_name.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` +PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` + --> full_name.py:7:5 | 5 | q = "bar" 6 | 7 | a = os.path.abspath(p) - | ^^^^^^^^^^^^^^^ PTH100 + | ^^^^^^^^^^^^^^^ 8 | aa = os.chmod(p) 9 | aaa = os.mkdir(p) | - = help: Replace with `Path(...).resolve()` +help: Replace with `Path(...).resolve()` -full_name.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` +PTH101 `os.chmod()` should be replaced by `Path.chmod()` + --> full_name.py:8:6 | 7 | a = os.path.abspath(p) 8 | aa = os.chmod(p) - | ^^^^^^^^ PTH101 + | ^^^^^^^^ 9 | aaa = os.mkdir(p) 10 | os.makedirs(p) | - = help: Replace with `Path(...).chmod(...)` +help: Replace with `Path(...).chmod(...)` -full_name.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` +PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + --> full_name.py:9:7 | 7 | a = os.path.abspath(p) 8 | aa = os.chmod(p) 9 | aaa = os.mkdir(p) - | ^^^^^^^^ PTH102 + | ^^^^^^^^ 10 | os.makedirs(p) 11 | os.rename(p) | -full_name.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` +PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + --> full_name.py:10:1 | 8 | aa = os.chmod(p) 9 | aaa = os.mkdir(p) 10 | os.makedirs(p) - | ^^^^^^^^^^^ PTH103 + | ^^^^^^^^^^^ 11 | os.rename(p) 12 | os.replace(p) | -full_name.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> full_name.py:11:1 | 9 | aaa = os.mkdir(p) 10 | os.makedirs(p) 11 | os.rename(p) - | ^^^^^^^^^ PTH104 + | ^^^^^^^^^ 12 | os.replace(p) 13 | os.rmdir(p) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -full_name.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()` +PTH105 `os.replace()` should be replaced by `Path.replace()` + --> full_name.py:12:1 | 10 | os.makedirs(p) 11 | os.rename(p) 12 | os.replace(p) - | ^^^^^^^^^^ PTH105 + | ^^^^^^^^^^ 13 | os.rmdir(p) 14 | os.remove(p) | - = help: Replace with `Path(...).replace(...)` +help: Replace with `Path(...).replace(...)` -full_name.py:13:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` +PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` + --> full_name.py:13:1 | 11 | os.rename(p) 12 | os.replace(p) 13 | os.rmdir(p) - | ^^^^^^^^ PTH106 + | ^^^^^^^^ 14 | os.remove(p) 15 | os.unlink(p) | - = help: Replace with `Path(...).rmdir()` +help: Replace with `Path(...).rmdir()` -full_name.py:14:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` +PTH107 `os.remove()` should be replaced by `Path.unlink()` + --> full_name.py:14:1 | 12 | os.replace(p) 13 | os.rmdir(p) 14 | os.remove(p) - | ^^^^^^^^^ PTH107 + | ^^^^^^^^^ 15 | os.unlink(p) 16 | os.getcwd(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` -full_name.py:15:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` +PTH108 `os.unlink()` should be replaced by `Path.unlink()` + --> full_name.py:15:1 | 13 | os.rmdir(p) 14 | os.remove(p) 15 | os.unlink(p) - | ^^^^^^^^^ PTH108 + | ^^^^^^^^^ 16 | os.getcwd(p) 17 | b = os.path.exists(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` -full_name.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> full_name.py:16:1 | 14 | os.remove(p) 15 | os.unlink(p) 16 | os.getcwd(p) - | ^^^^^^^^^ PTH109 + | ^^^^^^^^^ 17 | b = os.path.exists(p) 18 | bb = os.path.expanduser(p) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -full_name.py:17:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` +PTH110 `os.path.exists()` should be replaced by `Path.exists()` + --> full_name.py:17:5 | 15 | os.unlink(p) 16 | os.getcwd(p) 17 | b = os.path.exists(p) - | ^^^^^^^^^^^^^^ PTH110 + | ^^^^^^^^^^^^^^ 18 | bb = os.path.expanduser(p) 19 | bbb = os.path.isdir(p) | - = help: Replace with `Path(...).exists()` +help: Replace with `Path(...).exists()` -full_name.py:18:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` +PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` + --> full_name.py:18:6 | 16 | os.getcwd(p) 17 | b = os.path.exists(p) 18 | bb = os.path.expanduser(p) - | ^^^^^^^^^^^^^^^^^^ PTH111 + | ^^^^^^^^^^^^^^^^^^ 19 | bbb = os.path.isdir(p) 20 | bbbb = os.path.isfile(p) | - = help: Replace with `Path(...).expanduser()` +help: Replace with `Path(...).expanduser()` -full_name.py:19:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` +PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` + --> full_name.py:19:7 | 17 | b = os.path.exists(p) 18 | bb = os.path.expanduser(p) 19 | bbb = os.path.isdir(p) - | ^^^^^^^^^^^^^ PTH112 + | ^^^^^^^^^^^^^ 20 | bbbb = os.path.isfile(p) 21 | bbbbb = os.path.islink(p) | - = help: Replace with `Path(...).is_dir()` +help: Replace with `Path(...).is_dir()` -full_name.py:20:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` +PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` + --> full_name.py:20:8 | 18 | bb = os.path.expanduser(p) 19 | bbb = os.path.isdir(p) 20 | bbbb = os.path.isfile(p) - | ^^^^^^^^^^^^^^ PTH113 + | ^^^^^^^^^^^^^^ 21 | bbbbb = os.path.islink(p) 22 | os.readlink(p) | - = help: Replace with `Path(...).is_file()` +help: Replace with `Path(...).is_file()` -full_name.py:21:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` +PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` + --> full_name.py:21:9 | 19 | bbb = os.path.isdir(p) 20 | bbbb = os.path.isfile(p) 21 | bbbbb = os.path.islink(p) - | ^^^^^^^^^^^^^^ PTH114 + | ^^^^^^^^^^^^^^ 22 | os.readlink(p) 23 | os.stat(p) | - = help: Replace with `Path(...).is_symlink()` +help: Replace with `Path(...).is_symlink()` -full_name.py:22:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` +PTH115 `os.readlink()` should be replaced by `Path.readlink()` + --> full_name.py:22:1 | 20 | bbbb = os.path.isfile(p) 21 | bbbbb = os.path.islink(p) 22 | os.readlink(p) - | ^^^^^^^^^^^ PTH115 + | ^^^^^^^^^^^ 23 | os.stat(p) 24 | os.path.isabs(p) | - = help: Replace with `Path(...).readlink()` +help: Replace with `Path(...).readlink()` -full_name.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` +PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + --> full_name.py:23:1 | 21 | bbbbb = os.path.islink(p) 22 | os.readlink(p) 23 | os.stat(p) - | ^^^^^^^ PTH116 + | ^^^^^^^ 24 | os.path.isabs(p) 25 | os.path.join(p, q) | -full_name.py:24:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` +PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` + --> full_name.py:24:1 | 22 | os.readlink(p) 23 | os.stat(p) 24 | os.path.isabs(p) - | ^^^^^^^^^^^^^ PTH117 + | ^^^^^^^^^^^^^ 25 | os.path.join(p, q) 26 | os.sep.join([p, q]) | - = help: Replace with `Path(...).is_absolute()` +help: Replace with `Path(...).is_absolute()` -full_name.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator +PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + --> full_name.py:25:1 | 23 | os.stat(p) 24 | os.path.isabs(p) 25 | os.path.join(p, q) - | ^^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^^ 26 | os.sep.join([p, q]) 27 | os.sep.join((p, q)) | -full_name.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> full_name.py:26:1 | 24 | os.path.isabs(p) 25 | os.path.join(p, q) 26 | os.sep.join([p, q]) - | ^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^ 27 | os.sep.join((p, q)) 28 | os.path.basename(p) | -full_name.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> full_name.py:27:1 | 25 | os.path.join(p, q) 26 | os.sep.join([p, q]) 27 | os.sep.join((p, q)) - | ^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^ 28 | os.path.basename(p) 29 | os.path.dirname(p) | -full_name.py:28:1: PTH119 `os.path.basename()` should be replaced by `Path.name` +PTH119 `os.path.basename()` should be replaced by `Path.name` + --> full_name.py:28:1 | 26 | os.sep.join([p, q]) 27 | os.sep.join((p, q)) 28 | os.path.basename(p) - | ^^^^^^^^^^^^^^^^ PTH119 + | ^^^^^^^^^^^^^^^^ 29 | os.path.dirname(p) 30 | os.path.samefile(p) | - = help: Replace with `Path(...).name` +help: Replace with `Path(...).name` -full_name.py:29:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` +PTH120 `os.path.dirname()` should be replaced by `Path.parent` + --> full_name.py:29:1 | 27 | os.sep.join((p, q)) 28 | os.path.basename(p) 29 | os.path.dirname(p) - | ^^^^^^^^^^^^^^^ PTH120 + | ^^^^^^^^^^^^^^^ 30 | os.path.samefile(p) 31 | os.path.splitext(p) | - = help: Replace with `Path(...).parent` +help: Replace with `Path(...).parent` -full_name.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` +PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + --> full_name.py:30:1 | 28 | os.path.basename(p) 29 | os.path.dirname(p) 30 | os.path.samefile(p) - | ^^^^^^^^^^^^^^^^ PTH121 + | ^^^^^^^^^^^^^^^^ 31 | os.path.splitext(p) 32 | with open(p) as fp: | - = help: Replace with `Path(...).samefile()` +help: Replace with `Path(...).samefile()` -full_name.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` +PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + --> full_name.py:31:1 | 29 | os.path.dirname(p) 30 | os.path.samefile(p) 31 | os.path.splitext(p) - | ^^^^^^^^^^^^^^^^ PTH122 + | ^^^^^^^^^^^^^^^^ 32 | with open(p) as fp: 33 | fp.read() | -full_name.py:32:6: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:32:6 | 30 | os.path.samefile(p) 31 | os.path.splitext(p) 32 | with open(p) as fp: - | ^^^^ PTH123 + | ^^^^ 33 | fp.read() 34 | open(p).close() | -full_name.py:34:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:34:1 | 32 | with open(p) as fp: 33 | fp.read() 34 | open(p).close() - | ^^^^ PTH123 + | ^^^^ 35 | os.getcwdb(p) 36 | os.path.join(p, *q) | -full_name.py:35:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> full_name.py:35:1 | 33 | fp.read() 34 | open(p).close() 35 | os.getcwdb(p) - | ^^^^^^^^^^ PTH109 + | ^^^^^^^^^^ 36 | os.path.join(p, *q) 37 | os.sep.join(p, *q) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -full_name.py:36:1: PTH118 `os.path.join()` should be replaced by `Path.joinpath()` +PTH118 `os.path.join()` should be replaced by `Path.joinpath()` + --> full_name.py:36:1 | 34 | open(p).close() 35 | os.getcwdb(p) 36 | os.path.join(p, *q) - | ^^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^^ 37 | os.sep.join(p, *q) | -full_name.py:37:1: PTH118 `os.sep.join()` should be replaced by `Path.joinpath()` +PTH118 `os.sep.join()` should be replaced by `Path.joinpath()` + --> full_name.py:37:1 | 35 | os.getcwdb(p) 36 | os.path.join(p, *q) 37 | os.sep.join(p, *q) - | ^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^ 38 | 39 | # https://github.com/astral-sh/ruff/issues/7620 | -full_name.py:46:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:46:1 | 44 | open(p, closefd=False) 45 | open(p, opener=opener) 46 | open(p, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^^ PTH123 + | ^^^^ 47 | open(p, 'r', - 1, None, None, None, True, None) 48 | open(p, 'r', - 1, None, None, None, False, opener) | -full_name.py:47:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:47:1 | 45 | open(p, opener=opener) 46 | open(p, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 47 | open(p, 'r', - 1, None, None, None, True, None) - | ^^^^ PTH123 + | ^^^^ 48 | open(p, 'r', - 1, None, None, None, False, opener) | -full_name.py:65:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:65:1 | 63 | open(f()) 64 | 65 | open(b"foo") - | ^^^^ PTH123 + | ^^^^ 66 | byte_str = b"bar" 67 | open(byte_str) | -full_name.py:67:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:67:1 | 65 | open(b"foo") 66 | byte_str = b"bar" 67 | open(byte_str) - | ^^^^ PTH123 + | ^^^^ 68 | 69 | def bytes_str_func() -> bytes: | -full_name.py:71:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:71:1 | 69 | def bytes_str_func() -> bytes: 70 | return b"foo" 71 | open(bytes_str_func()) - | ^^^^ PTH123 + | ^^^^ 72 | 73 | # https://github.com/astral-sh/ruff/issues/17693 | -full_name.py:108:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> full_name.py:108:1 | 106 | os.replace("src", "dst", dst_dir_fd=2) 107 | 108 | os.getcwd() - | ^^^^^^^^^ PTH109 + | ^^^^^^^^^ 109 | os.getcwdb() | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -full_name.py:109:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> full_name.py:109:1 | 108 | os.getcwd() 109 | os.getcwdb() - | ^^^^^^^^^^ PTH109 + | ^^^^^^^^^^ | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap index b3571f0799..3d94e4eb06 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap @@ -1,266 +1,291 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -import_as.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` +PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` + --> import_as.py:7:5 | 5 | q = "bar" 6 | 7 | a = foo_p.abspath(p) - | ^^^^^^^^^^^^^ PTH100 + | ^^^^^^^^^^^^^ 8 | aa = foo.chmod(p) 9 | aaa = foo.mkdir(p) | - = help: Replace with `Path(...).resolve()` +help: Replace with `Path(...).resolve()` -import_as.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` +PTH101 `os.chmod()` should be replaced by `Path.chmod()` + --> import_as.py:8:6 | 7 | a = foo_p.abspath(p) 8 | aa = foo.chmod(p) - | ^^^^^^^^^ PTH101 + | ^^^^^^^^^ 9 | aaa = foo.mkdir(p) 10 | foo.makedirs(p) | - = help: Replace with `Path(...).chmod(...)` +help: Replace with `Path(...).chmod(...)` -import_as.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` +PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + --> import_as.py:9:7 | 7 | a = foo_p.abspath(p) 8 | aa = foo.chmod(p) 9 | aaa = foo.mkdir(p) - | ^^^^^^^^^ PTH102 + | ^^^^^^^^^ 10 | foo.makedirs(p) 11 | foo.rename(p) | -import_as.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` +PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + --> import_as.py:10:1 | 8 | aa = foo.chmod(p) 9 | aaa = foo.mkdir(p) 10 | foo.makedirs(p) - | ^^^^^^^^^^^^ PTH103 + | ^^^^^^^^^^^^ 11 | foo.rename(p) 12 | foo.replace(p) | -import_as.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_as.py:11:1 | 9 | aaa = foo.mkdir(p) 10 | foo.makedirs(p) 11 | foo.rename(p) - | ^^^^^^^^^^ PTH104 + | ^^^^^^^^^^ 12 | foo.replace(p) 13 | foo.rmdir(p) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -import_as.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()` +PTH105 `os.replace()` should be replaced by `Path.replace()` + --> import_as.py:12:1 | 10 | foo.makedirs(p) 11 | foo.rename(p) 12 | foo.replace(p) - | ^^^^^^^^^^^ PTH105 + | ^^^^^^^^^^^ 13 | foo.rmdir(p) 14 | foo.remove(p) | - = help: Replace with `Path(...).replace(...)` +help: Replace with `Path(...).replace(...)` -import_as.py:13:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` +PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` + --> import_as.py:13:1 | 11 | foo.rename(p) 12 | foo.replace(p) 13 | foo.rmdir(p) - | ^^^^^^^^^ PTH106 + | ^^^^^^^^^ 14 | foo.remove(p) 15 | foo.unlink(p) | - = help: Replace with `Path(...).rmdir()` +help: Replace with `Path(...).rmdir()` -import_as.py:14:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` +PTH107 `os.remove()` should be replaced by `Path.unlink()` + --> import_as.py:14:1 | 12 | foo.replace(p) 13 | foo.rmdir(p) 14 | foo.remove(p) - | ^^^^^^^^^^ PTH107 + | ^^^^^^^^^^ 15 | foo.unlink(p) 16 | foo.getcwd(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` -import_as.py:15:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` +PTH108 `os.unlink()` should be replaced by `Path.unlink()` + --> import_as.py:15:1 | 13 | foo.rmdir(p) 14 | foo.remove(p) 15 | foo.unlink(p) - | ^^^^^^^^^^ PTH108 + | ^^^^^^^^^^ 16 | foo.getcwd(p) 17 | b = foo_p.exists(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` -import_as.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> import_as.py:16:1 | 14 | foo.remove(p) 15 | foo.unlink(p) 16 | foo.getcwd(p) - | ^^^^^^^^^^ PTH109 + | ^^^^^^^^^^ 17 | b = foo_p.exists(p) 18 | bb = foo_p.expanduser(p) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -import_as.py:17:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` +PTH110 `os.path.exists()` should be replaced by `Path.exists()` + --> import_as.py:17:5 | 15 | foo.unlink(p) 16 | foo.getcwd(p) 17 | b = foo_p.exists(p) - | ^^^^^^^^^^^^ PTH110 + | ^^^^^^^^^^^^ 18 | bb = foo_p.expanduser(p) 19 | bbb = foo_p.isdir(p) | - = help: Replace with `Path(...).exists()` +help: Replace with `Path(...).exists()` -import_as.py:18:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` +PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` + --> import_as.py:18:6 | 16 | foo.getcwd(p) 17 | b = foo_p.exists(p) 18 | bb = foo_p.expanduser(p) - | ^^^^^^^^^^^^^^^^ PTH111 + | ^^^^^^^^^^^^^^^^ 19 | bbb = foo_p.isdir(p) 20 | bbbb = foo_p.isfile(p) | - = help: Replace with `Path(...).expanduser()` +help: Replace with `Path(...).expanduser()` -import_as.py:19:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` +PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` + --> import_as.py:19:7 | 17 | b = foo_p.exists(p) 18 | bb = foo_p.expanduser(p) 19 | bbb = foo_p.isdir(p) - | ^^^^^^^^^^^ PTH112 + | ^^^^^^^^^^^ 20 | bbbb = foo_p.isfile(p) 21 | bbbbb = foo_p.islink(p) | - = help: Replace with `Path(...).is_dir()` +help: Replace with `Path(...).is_dir()` -import_as.py:20:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` +PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` + --> import_as.py:20:8 | 18 | bb = foo_p.expanduser(p) 19 | bbb = foo_p.isdir(p) 20 | bbbb = foo_p.isfile(p) - | ^^^^^^^^^^^^ PTH113 + | ^^^^^^^^^^^^ 21 | bbbbb = foo_p.islink(p) 22 | foo.readlink(p) | - = help: Replace with `Path(...).is_file()` +help: Replace with `Path(...).is_file()` -import_as.py:21:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` +PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` + --> import_as.py:21:9 | 19 | bbb = foo_p.isdir(p) 20 | bbbb = foo_p.isfile(p) 21 | bbbbb = foo_p.islink(p) - | ^^^^^^^^^^^^ PTH114 + | ^^^^^^^^^^^^ 22 | foo.readlink(p) 23 | foo.stat(p) | - = help: Replace with `Path(...).is_symlink()` +help: Replace with `Path(...).is_symlink()` -import_as.py:22:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` +PTH115 `os.readlink()` should be replaced by `Path.readlink()` + --> import_as.py:22:1 | 20 | bbbb = foo_p.isfile(p) 21 | bbbbb = foo_p.islink(p) 22 | foo.readlink(p) - | ^^^^^^^^^^^^ PTH115 + | ^^^^^^^^^^^^ 23 | foo.stat(p) 24 | foo_p.isabs(p) | - = help: Replace with `Path(...).readlink()` +help: Replace with `Path(...).readlink()` -import_as.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` +PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + --> import_as.py:23:1 | 21 | bbbbb = foo_p.islink(p) 22 | foo.readlink(p) 23 | foo.stat(p) - | ^^^^^^^^ PTH116 + | ^^^^^^^^ 24 | foo_p.isabs(p) 25 | foo_p.join(p, q) | -import_as.py:24:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` +PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` + --> import_as.py:24:1 | 22 | foo.readlink(p) 23 | foo.stat(p) 24 | foo_p.isabs(p) - | ^^^^^^^^^^^ PTH117 + | ^^^^^^^^^^^ 25 | foo_p.join(p, q) 26 | foo.sep.join([p, q]) | - = help: Replace with `Path(...).is_absolute()` +help: Replace with `Path(...).is_absolute()` -import_as.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator +PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + --> import_as.py:25:1 | 23 | foo.stat(p) 24 | foo_p.isabs(p) 25 | foo_p.join(p, q) - | ^^^^^^^^^^ PTH118 + | ^^^^^^^^^^ 26 | foo.sep.join([p, q]) 27 | foo.sep.join((p, q)) | -import_as.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_as.py:26:1 | 24 | foo_p.isabs(p) 25 | foo_p.join(p, q) 26 | foo.sep.join([p, q]) - | ^^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^^ 27 | foo.sep.join((p, q)) 28 | foo_p.basename(p) | -import_as.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_as.py:27:1 | 25 | foo_p.join(p, q) 26 | foo.sep.join([p, q]) 27 | foo.sep.join((p, q)) - | ^^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^^ 28 | foo_p.basename(p) 29 | foo_p.dirname(p) | -import_as.py:28:1: PTH119 `os.path.basename()` should be replaced by `Path.name` +PTH119 `os.path.basename()` should be replaced by `Path.name` + --> import_as.py:28:1 | 26 | foo.sep.join([p, q]) 27 | foo.sep.join((p, q)) 28 | foo_p.basename(p) - | ^^^^^^^^^^^^^^ PTH119 + | ^^^^^^^^^^^^^^ 29 | foo_p.dirname(p) 30 | foo_p.samefile(p) | - = help: Replace with `Path(...).name` +help: Replace with `Path(...).name` -import_as.py:29:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` +PTH120 `os.path.dirname()` should be replaced by `Path.parent` + --> import_as.py:29:1 | 27 | foo.sep.join((p, q)) 28 | foo_p.basename(p) 29 | foo_p.dirname(p) - | ^^^^^^^^^^^^^ PTH120 + | ^^^^^^^^^^^^^ 30 | foo_p.samefile(p) 31 | foo_p.splitext(p) | - = help: Replace with `Path(...).parent` +help: Replace with `Path(...).parent` -import_as.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` +PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + --> import_as.py:30:1 | 28 | foo_p.basename(p) 29 | foo_p.dirname(p) 30 | foo_p.samefile(p) - | ^^^^^^^^^^^^^^ PTH121 + | ^^^^^^^^^^^^^^ 31 | foo_p.splitext(p) | - = help: Replace with `Path(...).samefile()` +help: Replace with `Path(...).samefile()` -import_as.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` +PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + --> import_as.py:31:1 | 29 | foo_p.dirname(p) 30 | foo_p.samefile(p) 31 | foo_p.splitext(p) - | ^^^^^^^^^^^^^^ PTH122 + | ^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap index 7fdfa8ad30..5e8b12f577 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap @@ -1,328 +1,359 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -import_from.py:9:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` +PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` + --> import_from.py:9:5 | 7 | q = "bar" 8 | 9 | a = abspath(p) - | ^^^^^^^ PTH100 + | ^^^^^^^ 10 | aa = chmod(p) 11 | aaa = mkdir(p) | - = help: Replace with `Path(...).resolve()` +help: Replace with `Path(...).resolve()` -import_from.py:10:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` +PTH101 `os.chmod()` should be replaced by `Path.chmod()` + --> import_from.py:10:6 | 9 | a = abspath(p) 10 | aa = chmod(p) - | ^^^^^ PTH101 + | ^^^^^ 11 | aaa = mkdir(p) 12 | makedirs(p) | - = help: Replace with `Path(...).chmod(...)` +help: Replace with `Path(...).chmod(...)` -import_from.py:11:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` +PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + --> import_from.py:11:7 | 9 | a = abspath(p) 10 | aa = chmod(p) 11 | aaa = mkdir(p) - | ^^^^^ PTH102 + | ^^^^^ 12 | makedirs(p) 13 | rename(p) | -import_from.py:12:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` +PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + --> import_from.py:12:1 | 10 | aa = chmod(p) 11 | aaa = mkdir(p) 12 | makedirs(p) - | ^^^^^^^^ PTH103 + | ^^^^^^^^ 13 | rename(p) 14 | replace(p) | -import_from.py:13:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_from.py:13:1 | 11 | aaa = mkdir(p) 12 | makedirs(p) 13 | rename(p) - | ^^^^^^ PTH104 + | ^^^^^^ 14 | replace(p) 15 | rmdir(p) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -import_from.py:14:1: PTH105 `os.replace()` should be replaced by `Path.replace()` +PTH105 `os.replace()` should be replaced by `Path.replace()` + --> import_from.py:14:1 | 12 | makedirs(p) 13 | rename(p) 14 | replace(p) - | ^^^^^^^ PTH105 + | ^^^^^^^ 15 | rmdir(p) 16 | remove(p) | - = help: Replace with `Path(...).replace(...)` +help: Replace with `Path(...).replace(...)` -import_from.py:15:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` +PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` + --> import_from.py:15:1 | 13 | rename(p) 14 | replace(p) 15 | rmdir(p) - | ^^^^^ PTH106 + | ^^^^^ 16 | remove(p) 17 | unlink(p) | - = help: Replace with `Path(...).rmdir()` +help: Replace with `Path(...).rmdir()` -import_from.py:16:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` +PTH107 `os.remove()` should be replaced by `Path.unlink()` + --> import_from.py:16:1 | 14 | replace(p) 15 | rmdir(p) 16 | remove(p) - | ^^^^^^ PTH107 + | ^^^^^^ 17 | unlink(p) 18 | getcwd(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` -import_from.py:17:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` +PTH108 `os.unlink()` should be replaced by `Path.unlink()` + --> import_from.py:17:1 | 15 | rmdir(p) 16 | remove(p) 17 | unlink(p) - | ^^^^^^ PTH108 + | ^^^^^^ 18 | getcwd(p) 19 | b = exists(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` -import_from.py:18:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> import_from.py:18:1 | 16 | remove(p) 17 | unlink(p) 18 | getcwd(p) - | ^^^^^^ PTH109 + | ^^^^^^ 19 | b = exists(p) 20 | bb = expanduser(p) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -import_from.py:19:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` +PTH110 `os.path.exists()` should be replaced by `Path.exists()` + --> import_from.py:19:5 | 17 | unlink(p) 18 | getcwd(p) 19 | b = exists(p) - | ^^^^^^ PTH110 + | ^^^^^^ 20 | bb = expanduser(p) 21 | bbb = isdir(p) | - = help: Replace with `Path(...).exists()` +help: Replace with `Path(...).exists()` -import_from.py:20:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` +PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` + --> import_from.py:20:6 | 18 | getcwd(p) 19 | b = exists(p) 20 | bb = expanduser(p) - | ^^^^^^^^^^ PTH111 + | ^^^^^^^^^^ 21 | bbb = isdir(p) 22 | bbbb = isfile(p) | - = help: Replace with `Path(...).expanduser()` +help: Replace with `Path(...).expanduser()` -import_from.py:21:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` +PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` + --> import_from.py:21:7 | 19 | b = exists(p) 20 | bb = expanduser(p) 21 | bbb = isdir(p) - | ^^^^^ PTH112 + | ^^^^^ 22 | bbbb = isfile(p) 23 | bbbbb = islink(p) | - = help: Replace with `Path(...).is_dir()` +help: Replace with `Path(...).is_dir()` -import_from.py:22:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` +PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` + --> import_from.py:22:8 | 20 | bb = expanduser(p) 21 | bbb = isdir(p) 22 | bbbb = isfile(p) - | ^^^^^^ PTH113 + | ^^^^^^ 23 | bbbbb = islink(p) 24 | readlink(p) | - = help: Replace with `Path(...).is_file()` +help: Replace with `Path(...).is_file()` -import_from.py:23:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` +PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` + --> import_from.py:23:9 | 21 | bbb = isdir(p) 22 | bbbb = isfile(p) 23 | bbbbb = islink(p) - | ^^^^^^ PTH114 + | ^^^^^^ 24 | readlink(p) 25 | stat(p) | - = help: Replace with `Path(...).is_symlink()` +help: Replace with `Path(...).is_symlink()` -import_from.py:24:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` +PTH115 `os.readlink()` should be replaced by `Path.readlink()` + --> import_from.py:24:1 | 22 | bbbb = isfile(p) 23 | bbbbb = islink(p) 24 | readlink(p) - | ^^^^^^^^ PTH115 + | ^^^^^^^^ 25 | stat(p) 26 | isabs(p) | - = help: Replace with `Path(...).readlink()` +help: Replace with `Path(...).readlink()` -import_from.py:25:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` +PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + --> import_from.py:25:1 | 23 | bbbbb = islink(p) 24 | readlink(p) 25 | stat(p) - | ^^^^ PTH116 + | ^^^^ 26 | isabs(p) 27 | join(p, q) | -import_from.py:26:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` +PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` + --> import_from.py:26:1 | 24 | readlink(p) 25 | stat(p) 26 | isabs(p) - | ^^^^^ PTH117 + | ^^^^^ 27 | join(p, q) 28 | sep.join((p, q)) | - = help: Replace with `Path(...).is_absolute()` +help: Replace with `Path(...).is_absolute()` -import_from.py:27:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator +PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + --> import_from.py:27:1 | 25 | stat(p) 26 | isabs(p) 27 | join(p, q) - | ^^^^ PTH118 + | ^^^^ 28 | sep.join((p, q)) 29 | sep.join([p, q]) | -import_from.py:28:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_from.py:28:1 | 26 | isabs(p) 27 | join(p, q) 28 | sep.join((p, q)) - | ^^^^^^^^ PTH118 + | ^^^^^^^^ 29 | sep.join([p, q]) 30 | basename(p) | -import_from.py:29:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_from.py:29:1 | 27 | join(p, q) 28 | sep.join((p, q)) 29 | sep.join([p, q]) - | ^^^^^^^^ PTH118 + | ^^^^^^^^ 30 | basename(p) 31 | dirname(p) | -import_from.py:30:1: PTH119 `os.path.basename()` should be replaced by `Path.name` +PTH119 `os.path.basename()` should be replaced by `Path.name` + --> import_from.py:30:1 | 28 | sep.join((p, q)) 29 | sep.join([p, q]) 30 | basename(p) - | ^^^^^^^^ PTH119 + | ^^^^^^^^ 31 | dirname(p) 32 | samefile(p) | - = help: Replace with `Path(...).name` +help: Replace with `Path(...).name` -import_from.py:31:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` +PTH120 `os.path.dirname()` should be replaced by `Path.parent` + --> import_from.py:31:1 | 29 | sep.join([p, q]) 30 | basename(p) 31 | dirname(p) - | ^^^^^^^ PTH120 + | ^^^^^^^ 32 | samefile(p) 33 | splitext(p) | - = help: Replace with `Path(...).parent` +help: Replace with `Path(...).parent` -import_from.py:32:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` +PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + --> import_from.py:32:1 | 30 | basename(p) 31 | dirname(p) 32 | samefile(p) - | ^^^^^^^^ PTH121 + | ^^^^^^^^ 33 | splitext(p) 34 | with open(p) as fp: | - = help: Replace with `Path(...).samefile()` +help: Replace with `Path(...).samefile()` -import_from.py:33:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` +PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + --> import_from.py:33:1 | 31 | dirname(p) 32 | samefile(p) 33 | splitext(p) - | ^^^^^^^^ PTH122 + | ^^^^^^^^ 34 | with open(p) as fp: 35 | fp.read() | -import_from.py:34:6: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> import_from.py:34:6 | 32 | samefile(p) 33 | splitext(p) 34 | with open(p) as fp: - | ^^^^ PTH123 + | ^^^^ 35 | fp.read() 36 | open(p).close() | -import_from.py:36:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> import_from.py:36:1 | 34 | with open(p) as fp: 35 | fp.read() 36 | open(p).close() - | ^^^^ PTH123 + | ^^^^ | -import_from.py:43:10: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> import_from.py:43:10 | 41 | from builtins import open 42 | 43 | with open(p) as _: ... # Error - | ^^^^ PTH123 + | ^^^^ | -import_from.py:53:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_from.py:53:1 | 51 | file = "file_1.py" 52 | 53 | rename(file, "file_2.py") - | ^^^^^^ PTH104 + | ^^^^^^ 54 | 55 | rename( | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -import_from.py:55:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_from.py:55:1 | 53 | rename(file, "file_2.py") 54 | 55 | rename( - | ^^^^^^ PTH104 + | ^^^^^^ 56 | # commment 1 57 | file, # comment 2 | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -import_from.py:63:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_from.py:63:1 | 61 | ) 62 | 63 | rename(file, "file_2.py", src_dir_fd=None, dst_dir_fd=None) - | ^^^^^^ PTH104 + | ^^^^^^ 64 | 65 | rename(file, "file_2.py", src_dir_fd=1) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap index 8bc86717ac..7a85401333 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap @@ -1,266 +1,291 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -import_from_as.py:14:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` +PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` + --> import_from_as.py:14:5 | 12 | q = "bar" 13 | 14 | a = xabspath(p) - | ^^^^^^^^ PTH100 + | ^^^^^^^^ 15 | aa = xchmod(p) 16 | aaa = xmkdir(p) | - = help: Replace with `Path(...).resolve()` +help: Replace with `Path(...).resolve()` -import_from_as.py:15:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` +PTH101 `os.chmod()` should be replaced by `Path.chmod()` + --> import_from_as.py:15:6 | 14 | a = xabspath(p) 15 | aa = xchmod(p) - | ^^^^^^ PTH101 + | ^^^^^^ 16 | aaa = xmkdir(p) 17 | xmakedirs(p) | - = help: Replace with `Path(...).chmod(...)` +help: Replace with `Path(...).chmod(...)` -import_from_as.py:16:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` +PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + --> import_from_as.py:16:7 | 14 | a = xabspath(p) 15 | aa = xchmod(p) 16 | aaa = xmkdir(p) - | ^^^^^^ PTH102 + | ^^^^^^ 17 | xmakedirs(p) 18 | xrename(p) | -import_from_as.py:17:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` +PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + --> import_from_as.py:17:1 | 15 | aa = xchmod(p) 16 | aaa = xmkdir(p) 17 | xmakedirs(p) - | ^^^^^^^^^ PTH103 + | ^^^^^^^^^ 18 | xrename(p) 19 | xreplace(p) | -import_from_as.py:18:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_from_as.py:18:1 | 16 | aaa = xmkdir(p) 17 | xmakedirs(p) 18 | xrename(p) - | ^^^^^^^ PTH104 + | ^^^^^^^ 19 | xreplace(p) 20 | xrmdir(p) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -import_from_as.py:19:1: PTH105 `os.replace()` should be replaced by `Path.replace()` +PTH105 `os.replace()` should be replaced by `Path.replace()` + --> import_from_as.py:19:1 | 17 | xmakedirs(p) 18 | xrename(p) 19 | xreplace(p) - | ^^^^^^^^ PTH105 + | ^^^^^^^^ 20 | xrmdir(p) 21 | xremove(p) | - = help: Replace with `Path(...).replace(...)` +help: Replace with `Path(...).replace(...)` -import_from_as.py:20:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` +PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` + --> import_from_as.py:20:1 | 18 | xrename(p) 19 | xreplace(p) 20 | xrmdir(p) - | ^^^^^^ PTH106 + | ^^^^^^ 21 | xremove(p) 22 | xunlink(p) | - = help: Replace with `Path(...).rmdir()` +help: Replace with `Path(...).rmdir()` -import_from_as.py:21:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` +PTH107 `os.remove()` should be replaced by `Path.unlink()` + --> import_from_as.py:21:1 | 19 | xreplace(p) 20 | xrmdir(p) 21 | xremove(p) - | ^^^^^^^ PTH107 + | ^^^^^^^ 22 | xunlink(p) 23 | xgetcwd(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` -import_from_as.py:22:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` +PTH108 `os.unlink()` should be replaced by `Path.unlink()` + --> import_from_as.py:22:1 | 20 | xrmdir(p) 21 | xremove(p) 22 | xunlink(p) - | ^^^^^^^ PTH108 + | ^^^^^^^ 23 | xgetcwd(p) 24 | b = xexists(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` -import_from_as.py:23:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> import_from_as.py:23:1 | 21 | xremove(p) 22 | xunlink(p) 23 | xgetcwd(p) - | ^^^^^^^ PTH109 + | ^^^^^^^ 24 | b = xexists(p) 25 | bb = xexpanduser(p) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -import_from_as.py:24:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` +PTH110 `os.path.exists()` should be replaced by `Path.exists()` + --> import_from_as.py:24:5 | 22 | xunlink(p) 23 | xgetcwd(p) 24 | b = xexists(p) - | ^^^^^^^ PTH110 + | ^^^^^^^ 25 | bb = xexpanduser(p) 26 | bbb = xisdir(p) | - = help: Replace with `Path(...).exists()` +help: Replace with `Path(...).exists()` -import_from_as.py:25:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` +PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` + --> import_from_as.py:25:6 | 23 | xgetcwd(p) 24 | b = xexists(p) 25 | bb = xexpanduser(p) - | ^^^^^^^^^^^ PTH111 + | ^^^^^^^^^^^ 26 | bbb = xisdir(p) 27 | bbbb = xisfile(p) | - = help: Replace with `Path(...).expanduser()` +help: Replace with `Path(...).expanduser()` -import_from_as.py:26:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` +PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` + --> import_from_as.py:26:7 | 24 | b = xexists(p) 25 | bb = xexpanduser(p) 26 | bbb = xisdir(p) - | ^^^^^^ PTH112 + | ^^^^^^ 27 | bbbb = xisfile(p) 28 | bbbbb = xislink(p) | - = help: Replace with `Path(...).is_dir()` +help: Replace with `Path(...).is_dir()` -import_from_as.py:27:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` +PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` + --> import_from_as.py:27:8 | 25 | bb = xexpanduser(p) 26 | bbb = xisdir(p) 27 | bbbb = xisfile(p) - | ^^^^^^^ PTH113 + | ^^^^^^^ 28 | bbbbb = xislink(p) 29 | xreadlink(p) | - = help: Replace with `Path(...).is_file()` +help: Replace with `Path(...).is_file()` -import_from_as.py:28:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` +PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` + --> import_from_as.py:28:9 | 26 | bbb = xisdir(p) 27 | bbbb = xisfile(p) 28 | bbbbb = xislink(p) - | ^^^^^^^ PTH114 + | ^^^^^^^ 29 | xreadlink(p) 30 | xstat(p) | - = help: Replace with `Path(...).is_symlink()` +help: Replace with `Path(...).is_symlink()` -import_from_as.py:29:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` +PTH115 `os.readlink()` should be replaced by `Path.readlink()` + --> import_from_as.py:29:1 | 27 | bbbb = xisfile(p) 28 | bbbbb = xislink(p) 29 | xreadlink(p) - | ^^^^^^^^^ PTH115 + | ^^^^^^^^^ 30 | xstat(p) 31 | xisabs(p) | - = help: Replace with `Path(...).readlink()` +help: Replace with `Path(...).readlink()` -import_from_as.py:30:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` +PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + --> import_from_as.py:30:1 | 28 | bbbbb = xislink(p) 29 | xreadlink(p) 30 | xstat(p) - | ^^^^^ PTH116 + | ^^^^^ 31 | xisabs(p) 32 | xjoin(p, q) | -import_from_as.py:31:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` +PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` + --> import_from_as.py:31:1 | 29 | xreadlink(p) 30 | xstat(p) 31 | xisabs(p) - | ^^^^^^ PTH117 + | ^^^^^^ 32 | xjoin(p, q) 33 | s.join((p, q)) | - = help: Replace with `Path(...).is_absolute()` +help: Replace with `Path(...).is_absolute()` -import_from_as.py:32:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator +PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + --> import_from_as.py:32:1 | 30 | xstat(p) 31 | xisabs(p) 32 | xjoin(p, q) - | ^^^^^ PTH118 + | ^^^^^ 33 | s.join((p, q)) 34 | s.join([p, q]) | -import_from_as.py:33:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_from_as.py:33:1 | 31 | xisabs(p) 32 | xjoin(p, q) 33 | s.join((p, q)) - | ^^^^^^ PTH118 + | ^^^^^^ 34 | s.join([p, q]) 35 | xbasename(p) | -import_from_as.py:34:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_from_as.py:34:1 | 32 | xjoin(p, q) 33 | s.join((p, q)) 34 | s.join([p, q]) - | ^^^^^^ PTH118 + | ^^^^^^ 35 | xbasename(p) 36 | xdirname(p) | -import_from_as.py:35:1: PTH119 `os.path.basename()` should be replaced by `Path.name` +PTH119 `os.path.basename()` should be replaced by `Path.name` + --> import_from_as.py:35:1 | 33 | s.join((p, q)) 34 | s.join([p, q]) 35 | xbasename(p) - | ^^^^^^^^^ PTH119 + | ^^^^^^^^^ 36 | xdirname(p) 37 | xsamefile(p) | - = help: Replace with `Path(...).name` +help: Replace with `Path(...).name` -import_from_as.py:36:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` +PTH120 `os.path.dirname()` should be replaced by `Path.parent` + --> import_from_as.py:36:1 | 34 | s.join([p, q]) 35 | xbasename(p) 36 | xdirname(p) - | ^^^^^^^^ PTH120 + | ^^^^^^^^ 37 | xsamefile(p) 38 | xsplitext(p) | - = help: Replace with `Path(...).parent` +help: Replace with `Path(...).parent` -import_from_as.py:37:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` +PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + --> import_from_as.py:37:1 | 35 | xbasename(p) 36 | xdirname(p) 37 | xsamefile(p) - | ^^^^^^^^^ PTH121 + | ^^^^^^^^^ 38 | xsplitext(p) | - = help: Replace with `Path(...).samefile()` +help: Replace with `Path(...).samefile()` -import_from_as.py:38:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` +PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + --> import_from_as.py:38:1 | 36 | xdirname(p) 37 | xsamefile(p) 38 | xsplitext(p) - | ^^^^^^^^^ PTH122 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH201_PTH201.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH201_PTH201.py.snap index cd95f5f7d3..7819dbb198 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH201_PTH201.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH201_PTH201.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs -assertion_line: 144 --- -PTH201.py:6:10: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:6:10 | 5 | # match 6 | _ = Path(".") - | ^^^ PTH201 + | ^^^ 7 | _ = pth(".") 8 | _ = PurePath(".") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 3 3 | @@ -22,16 +22,17 @@ PTH201.py:6:10: PTH201 [*] Do not pass the current directory explicitly to `Path 8 8 | _ = PurePath(".") 9 9 | _ = Path("") -PTH201.py:7:9: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:7:9 | 5 | # match 6 | _ = Path(".") 7 | _ = pth(".") - | ^^^ PTH201 + | ^^^ 8 | _ = PurePath(".") 9 | _ = Path("") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 4 4 | @@ -43,15 +44,16 @@ PTH201.py:7:9: PTH201 [*] Do not pass the current directory explicitly to `Path` 9 9 | _ = Path("") 10 10 | -PTH201.py:8:14: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:8:14 | 6 | _ = Path(".") 7 | _ = pth(".") 8 | _ = PurePath(".") - | ^^^ PTH201 + | ^^^ 9 | _ = Path("") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 5 5 | # match @@ -63,16 +65,17 @@ PTH201.py:8:14: PTH201 [*] Do not pass the current directory explicitly to `Path 10 10 | 11 11 | Path('', ) -PTH201.py:9:10: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:9:10 | 7 | _ = pth(".") 8 | _ = PurePath(".") 9 | _ = Path("") - | ^^ PTH201 + | ^^ 10 | 11 | Path('', ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 6 6 | _ = Path(".") @@ -84,16 +87,17 @@ PTH201.py:9:10: PTH201 [*] Do not pass the current directory explicitly to `Path 11 11 | Path('', ) 12 12 | -PTH201.py:11:6: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:11:6 | 9 | _ = Path("") 10 | 11 | Path('', ) - | ^^ PTH201 + | ^^ 12 | 13 | Path( | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 8 8 | _ = PurePath(".") @@ -105,14 +109,15 @@ PTH201.py:11:6: PTH201 [*] Do not pass the current directory explicitly to `Path 13 13 | Path( 14 14 | '', -PTH201.py:14:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:14:5 | 13 | Path( 14 | '', - | ^^ PTH201 + | ^^ 15 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 10 10 | @@ -126,14 +131,15 @@ PTH201.py:14:5: PTH201 [*] Do not pass the current directory explicitly to `Path 17 15 | Path( # Comment before argument 18 16 | '', -PTH201.py:18:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:18:5 | 17 | Path( # Comment before argument 18 | '', - | ^^ PTH201 + | ^^ 19 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 14 14 | '', @@ -147,14 +153,15 @@ PTH201.py:18:5: PTH201 [*] Do not pass the current directory explicitly to `Path 21 19 | Path( 22 20 | '', # EOL comment -PTH201.py:22:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:22:5 | 21 | Path( 22 | '', # EOL comment - | ^^ PTH201 + | ^^ 23 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 18 18 | '', @@ -168,15 +175,16 @@ PTH201.py:22:5: PTH201 [*] Do not pass the current directory explicitly to `Path 25 23 | Path( 26 24 | '' # Comment in the middle of implicitly concatenated string -PTH201.py:26:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:26:5 | 25 | Path( 26 | / '' # Comment in the middle of implicitly concatenated string 27 | | ".", - | |_______^ PTH201 + | |_______^ 28 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 22 22 | '', # EOL comment @@ -191,15 +199,16 @@ PTH201.py:26:5: PTH201 [*] Do not pass the current directory explicitly to `Path 30 27 | Path( 31 28 | '' # Comment before comma -PTH201.py:31:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:31:5 | 30 | Path( 31 | '' # Comment before comma - | ^^ PTH201 + | ^^ 32 | , 33 | ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 27 27 | ".", @@ -214,14 +223,15 @@ PTH201.py:31:5: PTH201 [*] Do not pass the current directory explicitly to `Path 35 32 | Path( 36 33 | '', -PTH201.py:36:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:36:5 | 35 | Path( 36 | '', - | ^^ PTH201 + | ^^ 37 | ) / "bare" | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 33 33 | ) @@ -235,14 +245,15 @@ PTH201.py:36:5: PTH201 [*] Do not pass the current directory explicitly to `Path 39 39 | Path( # Comment before argument 40 40 | '', -PTH201.py:40:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:40:5 | 39 | Path( # Comment before argument 40 | '', - | ^^ PTH201 + | ^^ 41 | ) / ("parenthesized") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 37 37 | ) / "bare" @@ -256,14 +267,15 @@ PTH201.py:40:5: PTH201 [*] Do not pass the current directory explicitly to `Path 43 43 | Path( 44 44 | '', # EOL comment -PTH201.py:44:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:44:5 | 43 | Path( 44 | '', # EOL comment - | ^^ PTH201 + | ^^ 45 | ) / ( ("double parenthesized" ) ) | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 41 41 | ) / ("parenthesized") @@ -277,16 +289,17 @@ PTH201.py:44:5: PTH201 [*] Do not pass the current directory explicitly to `Path 47 47 | ( Path( 48 48 | '' # Comment in the middle of implicitly concatenated string -PTH201.py:48:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:48:5 | 47 | ( Path( 48 | / '' # Comment in the middle of implicitly concatenated string 49 | | ".", - | |_______^ PTH201 + | |_______^ 50 | ) )/ (("parenthesized path call") 51 | # Comment between closing parentheses | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 44 44 | '', # EOL comment @@ -304,15 +317,16 @@ PTH201.py:48:5: PTH201 [*] Do not pass the current directory explicitly to `Path 53 52 | 54 53 | Path( -PTH201.py:55:5: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:55:5 | 54 | Path( 55 | '' # Comment before comma - | ^^ PTH201 + | ^^ 56 | , 57 | ) / "multiple" / ( | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Unsafe fix 52 52 | ) @@ -327,16 +341,17 @@ PTH201.py:55:5: PTH201 [*] Do not pass the current directory explicitly to `Path 59 59 | 'ment' 60 60 | ) -PTH201.py:74:15: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:74:15 | 72 | from importlib.metadata import PackagePath 73 | 74 | _ = PosixPath(".") - | ^^^ PTH201 + | ^^^ 75 | _ = PurePosixPath(".") 76 | _ = WindowsPath(".") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 71 71 | @@ -348,15 +363,16 @@ PTH201.py:74:15: PTH201 [*] Do not pass the current directory explicitly to `Pat 76 76 | _ = WindowsPath(".") 77 77 | _ = PureWindowsPath(".") -PTH201.py:75:19: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:75:19 | 74 | _ = PosixPath(".") 75 | _ = PurePosixPath(".") - | ^^^ PTH201 + | ^^^ 76 | _ = WindowsPath(".") 77 | _ = PureWindowsPath(".") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 72 72 | from importlib.metadata import PackagePath @@ -368,16 +384,17 @@ PTH201.py:75:19: PTH201 [*] Do not pass the current directory explicitly to `Pat 77 77 | _ = PureWindowsPath(".") 78 78 | _ = PackagePath(".") -PTH201.py:76:17: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:76:17 | 74 | _ = PosixPath(".") 75 | _ = PurePosixPath(".") 76 | _ = WindowsPath(".") - | ^^^ PTH201 + | ^^^ 77 | _ = PureWindowsPath(".") 78 | _ = PackagePath(".") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 73 73 | @@ -388,15 +405,16 @@ PTH201.py:76:17: PTH201 [*] Do not pass the current directory explicitly to `Pat 77 77 | _ = PureWindowsPath(".") 78 78 | _ = PackagePath(".") -PTH201.py:77:21: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:77:21 | 75 | _ = PurePosixPath(".") 76 | _ = WindowsPath(".") 77 | _ = PureWindowsPath(".") - | ^^^ PTH201 + | ^^^ 78 | _ = PackagePath(".") | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 74 74 | _ = PosixPath(".") @@ -406,14 +424,15 @@ PTH201.py:77:21: PTH201 [*] Do not pass the current directory explicitly to `Pat 77 |+_ = PureWindowsPath() 78 78 | _ = PackagePath(".") -PTH201.py:78:17: PTH201 [*] Do not pass the current directory explicitly to `Path` +PTH201 [*] Do not pass the current directory explicitly to `Path` + --> PTH201.py:78:17 | 76 | _ = WindowsPath(".") 77 | _ = PureWindowsPath(".") 78 | _ = PackagePath(".") - | ^^^ PTH201 + | ^^^ | - = help: Remove the current directory argument +help: Remove the current directory argument ℹ Safe fix 75 75 | _ = PurePosixPath(".") diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH202_PTH202.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH202_PTH202.py.snap index 35a650e9db..107a4da2c0 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH202_PTH202.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH202_PTH202.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH202.py:10:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:10:1 | 10 | os.path.getsize("filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 11 | os.path.getsize(b"filename") 12 | os.path.getsize(Path("filename")) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 7 7 | filename2 = Path("filename") @@ -20,15 +21,16 @@ PTH202.py:10:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 12 12 | os.path.getsize(Path("filename")) 13 13 | os.path.getsize(__file__) -PTH202.py:11:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:11:1 | 10 | os.path.getsize("filename") 11 | os.path.getsize(b"filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 12 | os.path.getsize(Path("filename")) 13 | os.path.getsize(__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 8 8 | @@ -40,15 +42,16 @@ PTH202.py:11:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 13 13 | os.path.getsize(__file__) 14 14 | -PTH202.py:12:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:12:1 | 10 | os.path.getsize("filename") 11 | os.path.getsize(b"filename") 12 | os.path.getsize(Path("filename")) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 13 | os.path.getsize(__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 9 9 | @@ -60,16 +63,17 @@ PTH202.py:12:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 14 14 | 15 15 | os.path.getsize(filename) -PTH202.py:13:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:13:1 | 11 | os.path.getsize(b"filename") 12 | os.path.getsize(Path("filename")) 13 | os.path.getsize(__file__) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 14 | 15 | os.path.getsize(filename) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 10 10 | os.path.getsize("filename") @@ -81,16 +85,17 @@ PTH202.py:13:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 15 15 | os.path.getsize(filename) 16 16 | os.path.getsize(filename1) -PTH202.py:15:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:15:1 | 13 | os.path.getsize(__file__) 14 | 15 | os.path.getsize(filename) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 16 | os.path.getsize(filename1) 17 | os.path.getsize(filename2) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 12 12 | os.path.getsize(Path("filename")) @@ -102,14 +107,15 @@ PTH202.py:15:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 17 17 | os.path.getsize(filename2) 18 18 | -PTH202.py:16:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:16:1 | 15 | os.path.getsize(filename) 16 | os.path.getsize(filename1) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 17 | os.path.getsize(filename2) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 13 13 | os.path.getsize(__file__) @@ -121,16 +127,17 @@ PTH202.py:16:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 18 18 | 19 19 | os.path.getsize(filename="filename") -PTH202.py:17:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:17:1 | 15 | os.path.getsize(filename) 16 | os.path.getsize(filename1) 17 | os.path.getsize(filename2) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 18 | 19 | os.path.getsize(filename="filename") | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 14 14 | @@ -142,16 +149,17 @@ PTH202.py:17:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 19 19 | os.path.getsize(filename="filename") 20 20 | os.path.getsize(filename=b"filename") -PTH202.py:19:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:19:1 | 17 | os.path.getsize(filename2) 18 | 19 | os.path.getsize(filename="filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 20 | os.path.getsize(filename=b"filename") 21 | os.path.getsize(filename=Path("filename")) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 16 16 | os.path.getsize(filename1) @@ -163,15 +171,16 @@ PTH202.py:19:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 21 21 | os.path.getsize(filename=Path("filename")) 22 22 | os.path.getsize(filename=__file__) -PTH202.py:20:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:20:1 | 19 | os.path.getsize(filename="filename") 20 | os.path.getsize(filename=b"filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 21 | os.path.getsize(filename=Path("filename")) 22 | os.path.getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 17 17 | os.path.getsize(filename2) @@ -183,15 +192,16 @@ PTH202.py:20:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 22 22 | os.path.getsize(filename=__file__) 23 23 | -PTH202.py:21:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:21:1 | 19 | os.path.getsize(filename="filename") 20 | os.path.getsize(filename=b"filename") 21 | os.path.getsize(filename=Path("filename")) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 22 | os.path.getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 18 18 | @@ -203,16 +213,17 @@ PTH202.py:21:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 23 23 | 24 24 | getsize("filename") -PTH202.py:22:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:22:1 | 20 | os.path.getsize(filename=b"filename") 21 | os.path.getsize(filename=Path("filename")) 22 | os.path.getsize(filename=__file__) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 23 | 24 | getsize("filename") | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 19 19 | os.path.getsize(filename="filename") @@ -224,16 +235,17 @@ PTH202.py:22:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 24 24 | getsize("filename") 25 25 | getsize(b"filename") -PTH202.py:24:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:24:1 | 22 | os.path.getsize(filename=__file__) 23 | 24 | getsize("filename") - | ^^^^^^^ PTH202 + | ^^^^^^^ 25 | getsize(b"filename") 26 | getsize(Path("filename")) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 21 21 | os.path.getsize(filename=Path("filename")) @@ -245,15 +257,16 @@ PTH202.py:24:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 26 26 | getsize(Path("filename")) 27 27 | getsize(__file__) -PTH202.py:25:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:25:1 | 24 | getsize("filename") 25 | getsize(b"filename") - | ^^^^^^^ PTH202 + | ^^^^^^^ 26 | getsize(Path("filename")) 27 | getsize(__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 22 22 | os.path.getsize(filename=__file__) @@ -265,15 +278,16 @@ PTH202.py:25:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 27 27 | getsize(__file__) 28 28 | -PTH202.py:26:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:26:1 | 24 | getsize("filename") 25 | getsize(b"filename") 26 | getsize(Path("filename")) - | ^^^^^^^ PTH202 + | ^^^^^^^ 27 | getsize(__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 23 23 | @@ -285,16 +299,17 @@ PTH202.py:26:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 28 28 | 29 29 | getsize(filename="filename") -PTH202.py:27:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:27:1 | 25 | getsize(b"filename") 26 | getsize(Path("filename")) 27 | getsize(__file__) - | ^^^^^^^ PTH202 + | ^^^^^^^ 28 | 29 | getsize(filename="filename") | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 24 24 | getsize("filename") @@ -306,16 +321,17 @@ PTH202.py:27:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 29 29 | getsize(filename="filename") 30 30 | getsize(filename=b"filename") -PTH202.py:29:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:29:1 | 27 | getsize(__file__) 28 | 29 | getsize(filename="filename") - | ^^^^^^^ PTH202 + | ^^^^^^^ 30 | getsize(filename=b"filename") 31 | getsize(filename=Path("filename")) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 26 26 | getsize(Path("filename")) @@ -327,15 +343,16 @@ PTH202.py:29:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 31 31 | getsize(filename=Path("filename")) 32 32 | getsize(filename=__file__) -PTH202.py:30:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:30:1 | 29 | getsize(filename="filename") 30 | getsize(filename=b"filename") - | ^^^^^^^ PTH202 + | ^^^^^^^ 31 | getsize(filename=Path("filename")) 32 | getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 27 27 | getsize(__file__) @@ -347,15 +364,16 @@ PTH202.py:30:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 32 32 | getsize(filename=__file__) 33 33 | -PTH202.py:31:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:31:1 | 29 | getsize(filename="filename") 30 | getsize(filename=b"filename") 31 | getsize(filename=Path("filename")) - | ^^^^^^^ PTH202 + | ^^^^^^^ 32 | getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 28 28 | @@ -367,16 +385,17 @@ PTH202.py:31:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 33 33 | 34 34 | getsize(filename) -PTH202.py:32:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:32:1 | 30 | getsize(filename=b"filename") 31 | getsize(filename=Path("filename")) 32 | getsize(filename=__file__) - | ^^^^^^^ PTH202 + | ^^^^^^^ 33 | 34 | getsize(filename) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 29 29 | getsize(filename="filename") @@ -388,16 +407,17 @@ PTH202.py:32:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 34 34 | getsize(filename) 35 35 | getsize(filename1) -PTH202.py:34:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:34:1 | 32 | getsize(filename=__file__) 33 | 34 | getsize(filename) - | ^^^^^^^ PTH202 + | ^^^^^^^ 35 | getsize(filename1) 36 | getsize(filename2) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 31 31 | getsize(filename=Path("filename")) @@ -409,14 +429,15 @@ PTH202.py:34:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 36 36 | getsize(filename2) 37 37 | -PTH202.py:35:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:35:1 | 34 | getsize(filename) 35 | getsize(filename1) - | ^^^^^^^ PTH202 + | ^^^^^^^ 36 | getsize(filename2) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 32 32 | getsize(filename=__file__) @@ -428,14 +449,15 @@ PTH202.py:35:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 37 37 | 38 38 | -PTH202.py:36:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:36:1 | 34 | getsize(filename) 35 | getsize(filename1) 36 | getsize(filename2) - | ^^^^^^^ PTH202 + | ^^^^^^^ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 33 33 | @@ -447,14 +469,15 @@ PTH202.py:36:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 38 38 | 39 39 | os.path.getsize( -PTH202.py:39:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:39:1 | 39 | os.path.getsize( - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 40 | "filename", # comment 41 | ) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Unsafe fix 36 36 | getsize(filename2) @@ -468,16 +491,17 @@ PTH202.py:39:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 43 41 | os.path.getsize( 44 42 | # comment -PTH202.py:43:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:43:1 | 41 | ) 42 | 43 | os.path.getsize( - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 44 | # comment 45 | "filename" | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Unsafe fix 40 40 | "filename", # comment @@ -494,16 +518,17 @@ PTH202.py:43:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 50 45 | os.path.getsize( 51 46 | # comment -PTH202.py:50:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:50:1 | 48 | ) 49 | 50 | os.path.getsize( - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 51 | # comment 52 | b"filename" | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Unsafe fix 47 47 | # comment @@ -519,16 +544,17 @@ PTH202.py:50:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 56 52 | os.path.getsize( # comment 57 53 | Path(__file__) -PTH202.py:56:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:56:1 | 54 | ) 55 | 56 | os.path.getsize( # comment - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 57 | Path(__file__) 58 | # comment | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Unsafe fix 53 53 | # comment @@ -543,15 +569,16 @@ PTH202.py:56:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 61 58 | getsize( # comment 62 59 | "filename") -PTH202.py:61:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:61:1 | 59 | ) # comment 60 | 61 | getsize( # comment - | ^^^^^^^ PTH202 + | ^^^^^^^ 62 | "filename") | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Unsafe fix 58 58 | # comment @@ -564,16 +591,17 @@ PTH202.py:61:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 64 63 | getsize( # comment 65 64 | b"filename", -PTH202.py:64:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:64:1 | 62 | "filename") 63 | 64 | getsize( # comment - | ^^^^^^^ PTH202 + | ^^^^^^^ 65 | b"filename", 66 | #comment | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Unsafe fix 61 61 | getsize( # comment @@ -588,16 +616,17 @@ PTH202.py:64:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 69 66 | os.path.getsize("file" + "name") 70 67 | -PTH202.py:69:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:69:1 | 67 | ) 68 | 69 | os.path.getsize("file" + "name") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 70 | 71 | getsize \ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 66 66 | #comment @@ -609,16 +638,17 @@ PTH202.py:69:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 71 71 | getsize \ 72 72 | \ -PTH202.py:71:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:71:1 | 69 | os.path.getsize("file" + "name") 70 | 71 | getsize \ - | ^^^^^^^ PTH202 + | ^^^^^^^ 72 | \ 73 | \ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Unsafe fix 68 68 | @@ -635,16 +665,17 @@ PTH202.py:71:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 78 73 | getsize(Path("filename").resolve()) 79 74 | -PTH202.py:78:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:78:1 | 76 | ) 77 | 78 | getsize(Path("filename").resolve()) - | ^^^^^^^ PTH202 + | ^^^^^^^ 79 | 80 | import pathlib | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 75 75 | "filename", @@ -656,14 +687,15 @@ PTH202.py:78:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat(). 80 80 | import pathlib 81 81 | -PTH202.py:82:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202.py:82:1 | 80 | import pathlib 81 | 82 | os.path.getsize(pathlib.Path("filename")) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 79 79 | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH202_PTH202_2.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH202_PTH202_2.py.snap index a61e87ae2d..95dc695ee6 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH202_PTH202_2.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH202_PTH202_2.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH202_2.py:3:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202_2.py:3:1 | 1 | import os 2 | 3 | os.path.getsize(filename="filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 4 | os.path.getsize(filename=b"filename") 5 | os.path.getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 1 1 | import os @@ -21,14 +22,15 @@ PTH202_2.py:3:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat() 4 5 | os.path.getsize(filename=b"filename") 5 6 | os.path.getsize(filename=__file__) -PTH202_2.py:4:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202_2.py:4:1 | 3 | os.path.getsize(filename="filename") 4 | os.path.getsize(filename=b"filename") - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ 5 | os.path.getsize(filename=__file__) | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 1 1 | import os @@ -39,14 +41,15 @@ PTH202_2.py:4:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat() 5 |+pathlib.Path(b"filename").stat().st_size 5 6 | os.path.getsize(filename=__file__) -PTH202_2.py:5:1: PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` +PTH202 [*] `os.path.getsize` should be replaced by `Path.stat().st_size` + --> PTH202_2.py:5:1 | 3 | os.path.getsize(filename="filename") 4 | os.path.getsize(filename=b"filename") 5 | os.path.getsize(filename=__file__) - | ^^^^^^^^^^^^^^^ PTH202 + | ^^^^^^^^^^^^^^^ | - = help: Replace with `Path(...).stat().st_size` +help: Replace with `Path(...).stat().st_size` ℹ Safe fix 1 1 | import os diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH203_PTH203.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH203_PTH203.py.snap index 8a02cfe4ff..81109e01bd 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH203_PTH203.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH203_PTH203.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH203.py:5:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:5:1 | 3 | from os.path import getatime 4 | 5 | os.path.getatime("filename") - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 6 | os.path.getatime(b"filename") 7 | os.path.getatime(Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 2 2 | from pathlib import Path @@ -22,14 +23,15 @@ PTH203.py:5:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat(). 7 7 | os.path.getatime(Path("filename")) 8 8 | -PTH203.py:6:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:6:1 | 5 | os.path.getatime("filename") 6 | os.path.getatime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 7 | os.path.getatime(Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 3 3 | from os.path import getatime @@ -41,14 +43,15 @@ PTH203.py:6:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat(). 8 8 | 9 9 | -PTH203.py:7:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:7:1 | 5 | os.path.getatime("filename") 6 | os.path.getatime(b"filename") 7 | os.path.getatime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 4 4 | @@ -60,14 +63,15 @@ PTH203.py:7:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat(). 9 9 | 10 10 | getatime("filename") -PTH203.py:10:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:10:1 | 10 | getatime("filename") - | ^^^^^^^^ PTH203 + | ^^^^^^^^ 11 | getatime(b"filename") 12 | getatime(Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 7 7 | os.path.getatime(Path("filename")) @@ -79,14 +83,15 @@ PTH203.py:10:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 12 12 | getatime(Path("filename")) 13 13 | -PTH203.py:11:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:11:1 | 10 | getatime("filename") 11 | getatime(b"filename") - | ^^^^^^^^ PTH203 + | ^^^^^^^^ 12 | getatime(Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 8 8 | @@ -98,14 +103,15 @@ PTH203.py:11:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 13 13 | 14 14 | -PTH203.py:12:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:12:1 | 10 | getatime("filename") 11 | getatime(b"filename") 12 | getatime(Path("filename")) - | ^^^^^^^^ PTH203 + | ^^^^^^^^ | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 9 9 | @@ -117,16 +123,17 @@ PTH203.py:12:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 14 14 | 15 15 | file = __file__ -PTH203.py:17:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:17:1 | 15 | file = __file__ 16 | 17 | os.path.getatime(file) - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 18 | os.path.getatime(filename="filename") 19 | os.path.getatime(filename=Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 14 14 | @@ -138,14 +145,15 @@ PTH203.py:17:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 19 19 | os.path.getatime(filename=Path("filename")) 20 20 | -PTH203.py:18:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:18:1 | 17 | os.path.getatime(file) 18 | os.path.getatime(filename="filename") - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 19 | os.path.getatime(filename=Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 15 15 | file = __file__ @@ -157,16 +165,17 @@ PTH203.py:18:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 20 20 | 21 21 | os.path.getatime( # comment 1 -PTH203.py:19:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:19:1 | 17 | os.path.getatime(file) 18 | os.path.getatime(filename="filename") 19 | os.path.getatime(filename=Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 20 | 21 | os.path.getatime( # comment 1 | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 16 16 | @@ -178,16 +187,17 @@ PTH203.py:19:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 21 21 | os.path.getatime( # comment 1 22 22 | # comment 2 -PTH203.py:21:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:21:1 | 19 | os.path.getatime(filename=Path("filename")) 20 | 21 | os.path.getatime( # comment 1 - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 22 | # comment 2 23 | "filename" # comment 3 | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Unsafe fix 18 18 | os.path.getatime(filename="filename") @@ -205,16 +215,17 @@ PTH203.py:21:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 29 23 | os.path.getatime("file" + "name") 30 24 | -PTH203.py:29:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:29:1 | 27 | ) # comment 7 28 | 29 | os.path.getatime("file" + "name") - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 30 | 31 | getatime(Path("filename").resolve()) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 26 26 | # comment 6 @@ -226,16 +237,17 @@ PTH203.py:29:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 31 31 | getatime(Path("filename").resolve()) 32 32 | -PTH203.py:31:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:31:1 | 29 | os.path.getatime("file" + "name") 30 | 31 | getatime(Path("filename").resolve()) - | ^^^^^^^^ PTH203 + | ^^^^^^^^ 32 | 33 | os.path.getatime(pathlib.Path("filename")) | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 28 28 | @@ -247,16 +259,17 @@ PTH203.py:31:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 33 33 | os.path.getatime(pathlib.Path("filename")) 34 34 | -PTH203.py:33:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:33:1 | 31 | getatime(Path("filename").resolve()) 32 | 33 | os.path.getatime(pathlib.Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH203 + | ^^^^^^^^^^^^^^^^ 34 | 35 | getatime(Path("dir") / "file.txt") | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 30 30 | @@ -267,14 +280,15 @@ PTH203.py:33:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat() 34 34 | 35 35 | getatime(Path("dir") / "file.txt") -PTH203.py:35:1: PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` +PTH203 [*] `os.path.getatime` should be replaced by `Path.stat().st_atime` + --> PTH203.py:35:1 | 33 | os.path.getatime(pathlib.Path("filename")) 34 | 35 | getatime(Path("dir") / "file.txt") - | ^^^^^^^^ PTH203 + | ^^^^^^^^ | - = help: Replace with `Path.stat(...).st_atime` +help: Replace with `Path.stat(...).st_atime` ℹ Safe fix 32 32 | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH204_PTH204.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH204_PTH204.py.snap index b63229a19b..023f059ab3 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH204_PTH204.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH204_PTH204.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH204.py:6:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:6:1 | 6 | os.path.getmtime("filename") - | ^^^^^^^^^^^^^^^^ PTH204 + | ^^^^^^^^^^^^^^^^ 7 | os.path.getmtime(b"filename") 8 | os.path.getmtime(Path("filename")) | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` ℹ Safe fix 3 3 | from os.path import getmtime @@ -20,14 +21,15 @@ PTH204.py:6:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat(). 8 8 | os.path.getmtime(Path("filename")) 9 9 | -PTH204.py:7:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:7:1 | 6 | os.path.getmtime("filename") 7 | os.path.getmtime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH204 + | ^^^^^^^^^^^^^^^^ 8 | os.path.getmtime(Path("filename")) | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` ℹ Safe fix 4 4 | @@ -39,14 +41,15 @@ PTH204.py:7:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat(). 9 9 | 10 10 | -PTH204.py:8:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:8:1 | 6 | os.path.getmtime("filename") 7 | os.path.getmtime(b"filename") 8 | os.path.getmtime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH204 + | ^^^^^^^^^^^^^^^^ | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` ℹ Safe fix 5 5 | @@ -58,14 +61,15 @@ PTH204.py:8:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat(). 10 10 | 11 11 | getmtime("filename") -PTH204.py:11:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:11:1 | 11 | getmtime("filename") - | ^^^^^^^^ PTH204 + | ^^^^^^^^ 12 | getmtime(b"filename") 13 | getmtime(Path("filename")) | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` ℹ Safe fix 8 8 | os.path.getmtime(Path("filename")) @@ -76,14 +80,15 @@ PTH204.py:11:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat() 12 12 | getmtime(b"filename") 13 13 | getmtime(Path("filename")) -PTH204.py:12:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:12:1 | 11 | getmtime("filename") 12 | getmtime(b"filename") - | ^^^^^^^^ PTH204 + | ^^^^^^^^ 13 | getmtime(Path("filename")) | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` ℹ Safe fix 9 9 | @@ -93,14 +98,15 @@ PTH204.py:12:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat() 12 |+Path(b"filename").stat().st_mtime 13 13 | getmtime(Path("filename")) -PTH204.py:13:1: PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` +PTH204 [*] `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + --> PTH204.py:13:1 | 11 | getmtime("filename") 12 | getmtime(b"filename") 13 | getmtime(Path("filename")) - | ^^^^^^^^ PTH204 + | ^^^^^^^^ | - = help: Replace with `Path.stat(...).st_mtime` +help: Replace with `Path.stat(...).st_mtime` ℹ Safe fix 10 10 | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH205_PTH205.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH205_PTH205.py.snap index 3d675e9241..858f75f1ed 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH205_PTH205.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview__PTH205_PTH205.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -PTH205.py:6:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:6:1 | 6 | os.path.getctime("filename") - | ^^^^^^^^^^^^^^^^ PTH205 + | ^^^^^^^^^^^^^^^^ 7 | os.path.getctime(b"filename") 8 | os.path.getctime(Path("filename")) | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` ℹ Safe fix 3 3 | from os.path import getctime @@ -20,14 +21,15 @@ PTH205.py:6:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat(). 8 8 | os.path.getctime(Path("filename")) 9 9 | -PTH205.py:7:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:7:1 | 6 | os.path.getctime("filename") 7 | os.path.getctime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH205 + | ^^^^^^^^^^^^^^^^ 8 | os.path.getctime(Path("filename")) | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` ℹ Safe fix 4 4 | @@ -39,16 +41,17 @@ PTH205.py:7:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat(). 9 9 | 10 10 | getctime("filename") -PTH205.py:8:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:8:1 | 6 | os.path.getctime("filename") 7 | os.path.getctime(b"filename") 8 | os.path.getctime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH205 + | ^^^^^^^^^^^^^^^^ 9 | 10 | getctime("filename") | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` ℹ Safe fix 5 5 | @@ -60,16 +63,17 @@ PTH205.py:8:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat(). 10 10 | getctime("filename") 11 11 | getctime(b"filename") -PTH205.py:10:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:10:1 | 8 | os.path.getctime(Path("filename")) 9 | 10 | getctime("filename") - | ^^^^^^^^ PTH205 + | ^^^^^^^^ 11 | getctime(b"filename") 12 | getctime(Path("filename")) | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` ℹ Safe fix 7 7 | os.path.getctime(b"filename") @@ -80,14 +84,15 @@ PTH205.py:10:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat() 11 11 | getctime(b"filename") 12 12 | getctime(Path("filename")) -PTH205.py:11:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:11:1 | 10 | getctime("filename") 11 | getctime(b"filename") - | ^^^^^^^^ PTH205 + | ^^^^^^^^ 12 | getctime(Path("filename")) | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` ℹ Safe fix 8 8 | os.path.getctime(Path("filename")) @@ -97,14 +102,15 @@ PTH205.py:11:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat() 11 |+Path(b"filename").stat().st_ctime 12 12 | getctime(Path("filename")) -PTH205.py:12:1: PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` +PTH205 [*] `os.path.getctime` should be replaced by `Path.stat().st_ctime` + --> PTH205.py:12:1 | 10 | getctime("filename") 11 | getctime(b"filename") 12 | getctime(Path("filename")) - | ^^^^^^^^ PTH205 + | ^^^^^^^^ | - = help: Replace with `Path.stat(...).st_ctime` +help: Replace with `Path.stat(...).st_ctime` ℹ Safe fix 9 9 | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_full_name.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_full_name.py.snap index ca7f6d6967..e3a23ed180 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_full_name.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_full_name.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -full_name.py:7:5: PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()` +PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()` + --> full_name.py:7:5 | 5 | q = "bar" 6 | 7 | a = os.path.abspath(p) - | ^^^^^^^^^^^^^^^ PTH100 + | ^^^^^^^^^^^^^^^ 8 | aa = os.chmod(p) 9 | aaa = os.mkdir(p) | - = help: Replace with `Path(...).resolve()` +help: Replace with `Path(...).resolve()` ℹ Safe fix 1 1 | import os @@ -26,68 +27,74 @@ full_name.py:7:5: PTH100 [*] `os.path.abspath()` should be replaced by `Path.res 9 10 | aaa = os.mkdir(p) 10 11 | os.makedirs(p) -full_name.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` +PTH101 `os.chmod()` should be replaced by `Path.chmod()` + --> full_name.py:8:6 | 7 | a = os.path.abspath(p) 8 | aa = os.chmod(p) - | ^^^^^^^^ PTH101 + | ^^^^^^^^ 9 | aaa = os.mkdir(p) 10 | os.makedirs(p) | - = help: Replace with `Path(...).chmod(...)` +help: Replace with `Path(...).chmod(...)` -full_name.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` +PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + --> full_name.py:9:7 | 7 | a = os.path.abspath(p) 8 | aa = os.chmod(p) 9 | aaa = os.mkdir(p) - | ^^^^^^^^ PTH102 + | ^^^^^^^^ 10 | os.makedirs(p) 11 | os.rename(p) | -full_name.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` +PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + --> full_name.py:10:1 | 8 | aa = os.chmod(p) 9 | aaa = os.mkdir(p) 10 | os.makedirs(p) - | ^^^^^^^^^^^ PTH103 + | ^^^^^^^^^^^ 11 | os.rename(p) 12 | os.replace(p) | -full_name.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> full_name.py:11:1 | 9 | aaa = os.mkdir(p) 10 | os.makedirs(p) 11 | os.rename(p) - | ^^^^^^^^^ PTH104 + | ^^^^^^^^^ 12 | os.replace(p) 13 | os.rmdir(p) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -full_name.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()` +PTH105 `os.replace()` should be replaced by `Path.replace()` + --> full_name.py:12:1 | 10 | os.makedirs(p) 11 | os.rename(p) 12 | os.replace(p) - | ^^^^^^^^^^ PTH105 + | ^^^^^^^^^^ 13 | os.rmdir(p) 14 | os.remove(p) | - = help: Replace with `Path(...).replace(...)` +help: Replace with `Path(...).replace(...)` -full_name.py:13:1: PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` +PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` + --> full_name.py:13:1 | 11 | os.rename(p) 12 | os.replace(p) 13 | os.rmdir(p) - | ^^^^^^^^ PTH106 + | ^^^^^^^^ 14 | os.remove(p) 15 | os.unlink(p) | - = help: Replace with `Path(...).rmdir()` +help: Replace with `Path(...).rmdir()` ℹ Safe fix 1 1 | import os @@ -106,16 +113,17 @@ full_name.py:13:1: PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` 15 16 | os.unlink(p) 16 17 | os.getcwd(p) -full_name.py:14:1: PTH107 [*] `os.remove()` should be replaced by `Path.unlink()` +PTH107 [*] `os.remove()` should be replaced by `Path.unlink()` + --> full_name.py:14:1 | 12 | os.replace(p) 13 | os.rmdir(p) 14 | os.remove(p) - | ^^^^^^^^^ PTH107 + | ^^^^^^^^^ 15 | os.unlink(p) 16 | os.getcwd(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` ℹ Safe fix 1 1 | import os @@ -134,16 +142,17 @@ full_name.py:14:1: PTH107 [*] `os.remove()` should be replaced by `Path.unlink() 16 17 | os.getcwd(p) 17 18 | b = os.path.exists(p) -full_name.py:15:1: PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()` +PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()` + --> full_name.py:15:1 | 13 | os.rmdir(p) 14 | os.remove(p) 15 | os.unlink(p) - | ^^^^^^^^^ PTH108 + | ^^^^^^^^^ 16 | os.getcwd(p) 17 | b = os.path.exists(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` ℹ Safe fix 1 1 | import os @@ -162,27 +171,29 @@ full_name.py:15:1: PTH108 [*] `os.unlink()` should be replaced by `Path.unlink() 17 18 | b = os.path.exists(p) 18 19 | bb = os.path.expanduser(p) -full_name.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> full_name.py:16:1 | 14 | os.remove(p) 15 | os.unlink(p) 16 | os.getcwd(p) - | ^^^^^^^^^ PTH109 + | ^^^^^^^^^ 17 | b = os.path.exists(p) 18 | bb = os.path.expanduser(p) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -full_name.py:17:5: PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()` +PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()` + --> full_name.py:17:5 | 15 | os.unlink(p) 16 | os.getcwd(p) 17 | b = os.path.exists(p) - | ^^^^^^^^^^^^^^ PTH110 + | ^^^^^^^^^^^^^^ 18 | bb = os.path.expanduser(p) 19 | bbb = os.path.isdir(p) | - = help: Replace with `Path(...).exists()` +help: Replace with `Path(...).exists()` ℹ Safe fix 1 1 | import os @@ -201,16 +212,17 @@ full_name.py:17:5: PTH110 [*] `os.path.exists()` should be replaced by `Path.exi 19 20 | bbb = os.path.isdir(p) 20 21 | bbbb = os.path.isfile(p) -full_name.py:18:6: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()` +PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()` + --> full_name.py:18:6 | 16 | os.getcwd(p) 17 | b = os.path.exists(p) 18 | bb = os.path.expanduser(p) - | ^^^^^^^^^^^^^^^^^^ PTH111 + | ^^^^^^^^^^^^^^^^^^ 19 | bbb = os.path.isdir(p) 20 | bbbb = os.path.isfile(p) | - = help: Replace with `Path(...).expanduser()` +help: Replace with `Path(...).expanduser()` ℹ Safe fix 1 1 | import os @@ -229,16 +241,17 @@ full_name.py:18:6: PTH111 [*] `os.path.expanduser()` should be replaced by `Path 20 21 | bbbb = os.path.isfile(p) 21 22 | bbbbb = os.path.islink(p) -full_name.py:19:7: PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()` +PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()` + --> full_name.py:19:7 | 17 | b = os.path.exists(p) 18 | bb = os.path.expanduser(p) 19 | bbb = os.path.isdir(p) - | ^^^^^^^^^^^^^ PTH112 + | ^^^^^^^^^^^^^ 20 | bbbb = os.path.isfile(p) 21 | bbbbb = os.path.islink(p) | - = help: Replace with `Path(...).is_dir()` +help: Replace with `Path(...).is_dir()` ℹ Safe fix 1 1 | import os @@ -257,16 +270,17 @@ full_name.py:19:7: PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_d 21 22 | bbbbb = os.path.islink(p) 22 23 | os.readlink(p) -full_name.py:20:8: PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()` +PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()` + --> full_name.py:20:8 | 18 | bb = os.path.expanduser(p) 19 | bbb = os.path.isdir(p) 20 | bbbb = os.path.isfile(p) - | ^^^^^^^^^^^^^^ PTH113 + | ^^^^^^^^^^^^^^ 21 | bbbbb = os.path.islink(p) 22 | os.readlink(p) | - = help: Replace with `Path(...).is_file()` +help: Replace with `Path(...).is_file()` ℹ Safe fix 1 1 | import os @@ -285,16 +299,17 @@ full_name.py:20:8: PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_ 22 23 | os.readlink(p) 23 24 | os.stat(p) -full_name.py:21:9: PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()` +PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()` + --> full_name.py:21:9 | 19 | bbb = os.path.isdir(p) 20 | bbbb = os.path.isfile(p) 21 | bbbbb = os.path.islink(p) - | ^^^^^^^^^^^^^^ PTH114 + | ^^^^^^^^^^^^^^ 22 | os.readlink(p) 23 | os.stat(p) | - = help: Replace with `Path(...).is_symlink()` +help: Replace with `Path(...).is_symlink()` ℹ Safe fix 1 1 | import os @@ -313,16 +328,17 @@ full_name.py:21:9: PTH114 [*] `os.path.islink()` should be replaced by `Path.is_ 23 24 | os.stat(p) 24 25 | os.path.isabs(p) -full_name.py:22:1: PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` +PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` + --> full_name.py:22:1 | 20 | bbbb = os.path.isfile(p) 21 | bbbbb = os.path.islink(p) 22 | os.readlink(p) - | ^^^^^^^^^^^ PTH115 + | ^^^^^^^^^^^ 23 | os.stat(p) 24 | os.path.isabs(p) | - = help: Replace with `Path(...).readlink()` +help: Replace with `Path(...).readlink()` ℹ Safe fix 1 1 | import os @@ -341,26 +357,28 @@ full_name.py:22:1: PTH115 [*] `os.readlink()` should be replaced by `Path.readli 24 25 | os.path.isabs(p) 25 26 | os.path.join(p, q) -full_name.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` +PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + --> full_name.py:23:1 | 21 | bbbbb = os.path.islink(p) 22 | os.readlink(p) 23 | os.stat(p) - | ^^^^^^^ PTH116 + | ^^^^^^^ 24 | os.path.isabs(p) 25 | os.path.join(p, q) | -full_name.py:24:1: PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()` +PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()` + --> full_name.py:24:1 | 22 | os.readlink(p) 23 | os.stat(p) 24 | os.path.isabs(p) - | ^^^^^^^^^^^^^ PTH117 + | ^^^^^^^^^^^^^ 25 | os.path.join(p, q) 26 | os.sep.join([p, q]) | - = help: Replace with `Path(...).is_absolute()` +help: Replace with `Path(...).is_absolute()` ℹ Safe fix 1 1 | import os @@ -379,46 +397,50 @@ full_name.py:24:1: PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_a 26 27 | os.sep.join([p, q]) 27 28 | os.sep.join((p, q)) -full_name.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator +PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + --> full_name.py:25:1 | 23 | os.stat(p) 24 | os.path.isabs(p) 25 | os.path.join(p, q) - | ^^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^^ 26 | os.sep.join([p, q]) 27 | os.sep.join((p, q)) | -full_name.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> full_name.py:26:1 | 24 | os.path.isabs(p) 25 | os.path.join(p, q) 26 | os.sep.join([p, q]) - | ^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^ 27 | os.sep.join((p, q)) 28 | os.path.basename(p) | -full_name.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> full_name.py:27:1 | 25 | os.path.join(p, q) 26 | os.sep.join([p, q]) 27 | os.sep.join((p, q)) - | ^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^ 28 | os.path.basename(p) 29 | os.path.dirname(p) | -full_name.py:28:1: PTH119 [*] `os.path.basename()` should be replaced by `Path.name` +PTH119 [*] `os.path.basename()` should be replaced by `Path.name` + --> full_name.py:28:1 | 26 | os.sep.join([p, q]) 27 | os.sep.join((p, q)) 28 | os.path.basename(p) - | ^^^^^^^^^^^^^^^^ PTH119 + | ^^^^^^^^^^^^^^^^ 29 | os.path.dirname(p) 30 | os.path.samefile(p) | - = help: Replace with `Path(...).name` +help: Replace with `Path(...).name` ℹ Safe fix 1 1 | import os @@ -437,16 +459,17 @@ full_name.py:28:1: PTH119 [*] `os.path.basename()` should be replaced by `Path.n 30 31 | os.path.samefile(p) 31 32 | os.path.splitext(p) -full_name.py:29:1: PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent` +PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent` + --> full_name.py:29:1 | 27 | os.sep.join((p, q)) 28 | os.path.basename(p) 29 | os.path.dirname(p) - | ^^^^^^^^^^^^^^^ PTH120 + | ^^^^^^^^^^^^^^^ 30 | os.path.samefile(p) 31 | os.path.splitext(p) | - = help: Replace with `Path(...).parent` +help: Replace with `Path(...).parent` ℹ Safe fix 1 1 | import os @@ -465,135 +488,148 @@ full_name.py:29:1: PTH120 [*] `os.path.dirname()` should be replaced by `Path.pa 31 32 | os.path.splitext(p) 32 33 | with open(p) as fp: -full_name.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` +PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + --> full_name.py:30:1 | 28 | os.path.basename(p) 29 | os.path.dirname(p) 30 | os.path.samefile(p) - | ^^^^^^^^^^^^^^^^ PTH121 + | ^^^^^^^^^^^^^^^^ 31 | os.path.splitext(p) 32 | with open(p) as fp: | - = help: Replace with `Path(...).samefile()` +help: Replace with `Path(...).samefile()` -full_name.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` +PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + --> full_name.py:31:1 | 29 | os.path.dirname(p) 30 | os.path.samefile(p) 31 | os.path.splitext(p) - | ^^^^^^^^^^^^^^^^ PTH122 + | ^^^^^^^^^^^^^^^^ 32 | with open(p) as fp: 33 | fp.read() | -full_name.py:32:6: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:32:6 | 30 | os.path.samefile(p) 31 | os.path.splitext(p) 32 | with open(p) as fp: - | ^^^^ PTH123 + | ^^^^ 33 | fp.read() 34 | open(p).close() | -full_name.py:34:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:34:1 | 32 | with open(p) as fp: 33 | fp.read() 34 | open(p).close() - | ^^^^ PTH123 + | ^^^^ 35 | os.getcwdb(p) 36 | os.path.join(p, *q) | -full_name.py:35:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> full_name.py:35:1 | 33 | fp.read() 34 | open(p).close() 35 | os.getcwdb(p) - | ^^^^^^^^^^ PTH109 + | ^^^^^^^^^^ 36 | os.path.join(p, *q) 37 | os.sep.join(p, *q) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -full_name.py:36:1: PTH118 `os.path.join()` should be replaced by `Path.joinpath()` +PTH118 `os.path.join()` should be replaced by `Path.joinpath()` + --> full_name.py:36:1 | 34 | open(p).close() 35 | os.getcwdb(p) 36 | os.path.join(p, *q) - | ^^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^^ 37 | os.sep.join(p, *q) | -full_name.py:37:1: PTH118 `os.sep.join()` should be replaced by `Path.joinpath()` +PTH118 `os.sep.join()` should be replaced by `Path.joinpath()` + --> full_name.py:37:1 | 35 | os.getcwdb(p) 36 | os.path.join(p, *q) 37 | os.sep.join(p, *q) - | ^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^ 38 | 39 | # https://github.com/astral-sh/ruff/issues/7620 | -full_name.py:46:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:46:1 | 44 | open(p, closefd=False) 45 | open(p, opener=opener) 46 | open(p, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^^ PTH123 + | ^^^^ 47 | open(p, 'r', - 1, None, None, None, True, None) 48 | open(p, 'r', - 1, None, None, None, False, opener) | -full_name.py:47:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:47:1 | 45 | open(p, opener=opener) 46 | open(p, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 47 | open(p, 'r', - 1, None, None, None, True, None) - | ^^^^ PTH123 + | ^^^^ 48 | open(p, 'r', - 1, None, None, None, False, opener) | -full_name.py:65:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:65:1 | 63 | open(f()) 64 | 65 | open(b"foo") - | ^^^^ PTH123 + | ^^^^ 66 | byte_str = b"bar" 67 | open(byte_str) | -full_name.py:67:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:67:1 | 65 | open(b"foo") 66 | byte_str = b"bar" 67 | open(byte_str) - | ^^^^ PTH123 + | ^^^^ 68 | 69 | def bytes_str_func() -> bytes: | -full_name.py:71:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> full_name.py:71:1 | 69 | def bytes_str_func() -> bytes: 70 | return b"foo" 71 | open(bytes_str_func()) - | ^^^^ PTH123 + | ^^^^ 72 | 73 | # https://github.com/astral-sh/ruff/issues/17693 | -full_name.py:108:1: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()` + --> full_name.py:108:1 | 106 | os.replace("src", "dst", dst_dir_fd=2) 107 | 108 | os.getcwd() - | ^^^^^^^^^ PTH109 + | ^^^^^^^^^ 109 | os.getcwdb() | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` ℹ Safe fix 1 1 | import os @@ -610,13 +646,14 @@ full_name.py:108:1: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()` 109 |+pathlib.Path.cwd() 109 110 | os.getcwdb() -full_name.py:109:1: PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()` + --> full_name.py:109:1 | 108 | os.getcwd() 109 | os.getcwdb() - | ^^^^^^^^^^ PTH109 + | ^^^^^^^^^^ | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` ℹ Safe fix 1 1 | import os diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_as.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_as.py.snap index bd5e1ca5ba..5a32aa5f53 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_as.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_as.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -import_as.py:7:5: PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()` +PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()` + --> import_as.py:7:5 | 5 | q = "bar" 6 | 7 | a = foo_p.abspath(p) - | ^^^^^^^^^^^^^ PTH100 + | ^^^^^^^^^^^^^ 8 | aa = foo.chmod(p) 9 | aaa = foo.mkdir(p) | - = help: Replace with `Path(...).resolve()` +help: Replace with `Path(...).resolve()` ℹ Safe fix 1 1 | import os as foo @@ -26,68 +27,74 @@ import_as.py:7:5: PTH100 [*] `os.path.abspath()` should be replaced by `Path.res 9 10 | aaa = foo.mkdir(p) 10 11 | foo.makedirs(p) -import_as.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` +PTH101 `os.chmod()` should be replaced by `Path.chmod()` + --> import_as.py:8:6 | 7 | a = foo_p.abspath(p) 8 | aa = foo.chmod(p) - | ^^^^^^^^^ PTH101 + | ^^^^^^^^^ 9 | aaa = foo.mkdir(p) 10 | foo.makedirs(p) | - = help: Replace with `Path(...).chmod(...)` +help: Replace with `Path(...).chmod(...)` -import_as.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` +PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + --> import_as.py:9:7 | 7 | a = foo_p.abspath(p) 8 | aa = foo.chmod(p) 9 | aaa = foo.mkdir(p) - | ^^^^^^^^^ PTH102 + | ^^^^^^^^^ 10 | foo.makedirs(p) 11 | foo.rename(p) | -import_as.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` +PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + --> import_as.py:10:1 | 8 | aa = foo.chmod(p) 9 | aaa = foo.mkdir(p) 10 | foo.makedirs(p) - | ^^^^^^^^^^^^ PTH103 + | ^^^^^^^^^^^^ 11 | foo.rename(p) 12 | foo.replace(p) | -import_as.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_as.py:11:1 | 9 | aaa = foo.mkdir(p) 10 | foo.makedirs(p) 11 | foo.rename(p) - | ^^^^^^^^^^ PTH104 + | ^^^^^^^^^^ 12 | foo.replace(p) 13 | foo.rmdir(p) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -import_as.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()` +PTH105 `os.replace()` should be replaced by `Path.replace()` + --> import_as.py:12:1 | 10 | foo.makedirs(p) 11 | foo.rename(p) 12 | foo.replace(p) - | ^^^^^^^^^^^ PTH105 + | ^^^^^^^^^^^ 13 | foo.rmdir(p) 14 | foo.remove(p) | - = help: Replace with `Path(...).replace(...)` +help: Replace with `Path(...).replace(...)` -import_as.py:13:1: PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` +PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` + --> import_as.py:13:1 | 11 | foo.rename(p) 12 | foo.replace(p) 13 | foo.rmdir(p) - | ^^^^^^^^^ PTH106 + | ^^^^^^^^^ 14 | foo.remove(p) 15 | foo.unlink(p) | - = help: Replace with `Path(...).rmdir()` +help: Replace with `Path(...).rmdir()` ℹ Safe fix 1 1 | import os as foo @@ -106,16 +113,17 @@ import_as.py:13:1: PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` 15 16 | foo.unlink(p) 16 17 | foo.getcwd(p) -import_as.py:14:1: PTH107 [*] `os.remove()` should be replaced by `Path.unlink()` +PTH107 [*] `os.remove()` should be replaced by `Path.unlink()` + --> import_as.py:14:1 | 12 | foo.replace(p) 13 | foo.rmdir(p) 14 | foo.remove(p) - | ^^^^^^^^^^ PTH107 + | ^^^^^^^^^^ 15 | foo.unlink(p) 16 | foo.getcwd(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` ℹ Safe fix 1 1 | import os as foo @@ -134,16 +142,17 @@ import_as.py:14:1: PTH107 [*] `os.remove()` should be replaced by `Path.unlink() 16 17 | foo.getcwd(p) 17 18 | b = foo_p.exists(p) -import_as.py:15:1: PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()` +PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()` + --> import_as.py:15:1 | 13 | foo.rmdir(p) 14 | foo.remove(p) 15 | foo.unlink(p) - | ^^^^^^^^^^ PTH108 + | ^^^^^^^^^^ 16 | foo.getcwd(p) 17 | b = foo_p.exists(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` ℹ Safe fix 1 1 | import os as foo @@ -162,27 +171,29 @@ import_as.py:15:1: PTH108 [*] `os.unlink()` should be replaced by `Path.unlink() 17 18 | b = foo_p.exists(p) 18 19 | bb = foo_p.expanduser(p) -import_as.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> import_as.py:16:1 | 14 | foo.remove(p) 15 | foo.unlink(p) 16 | foo.getcwd(p) - | ^^^^^^^^^^ PTH109 + | ^^^^^^^^^^ 17 | b = foo_p.exists(p) 18 | bb = foo_p.expanduser(p) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -import_as.py:17:5: PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()` +PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()` + --> import_as.py:17:5 | 15 | foo.unlink(p) 16 | foo.getcwd(p) 17 | b = foo_p.exists(p) - | ^^^^^^^^^^^^ PTH110 + | ^^^^^^^^^^^^ 18 | bb = foo_p.expanduser(p) 19 | bbb = foo_p.isdir(p) | - = help: Replace with `Path(...).exists()` +help: Replace with `Path(...).exists()` ℹ Safe fix 1 1 | import os as foo @@ -201,16 +212,17 @@ import_as.py:17:5: PTH110 [*] `os.path.exists()` should be replaced by `Path.exi 19 20 | bbb = foo_p.isdir(p) 20 21 | bbbb = foo_p.isfile(p) -import_as.py:18:6: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()` +PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()` + --> import_as.py:18:6 | 16 | foo.getcwd(p) 17 | b = foo_p.exists(p) 18 | bb = foo_p.expanduser(p) - | ^^^^^^^^^^^^^^^^ PTH111 + | ^^^^^^^^^^^^^^^^ 19 | bbb = foo_p.isdir(p) 20 | bbbb = foo_p.isfile(p) | - = help: Replace with `Path(...).expanduser()` +help: Replace with `Path(...).expanduser()` ℹ Safe fix 1 1 | import os as foo @@ -229,16 +241,17 @@ import_as.py:18:6: PTH111 [*] `os.path.expanduser()` should be replaced by `Path 20 21 | bbbb = foo_p.isfile(p) 21 22 | bbbbb = foo_p.islink(p) -import_as.py:19:7: PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()` +PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()` + --> import_as.py:19:7 | 17 | b = foo_p.exists(p) 18 | bb = foo_p.expanduser(p) 19 | bbb = foo_p.isdir(p) - | ^^^^^^^^^^^ PTH112 + | ^^^^^^^^^^^ 20 | bbbb = foo_p.isfile(p) 21 | bbbbb = foo_p.islink(p) | - = help: Replace with `Path(...).is_dir()` +help: Replace with `Path(...).is_dir()` ℹ Safe fix 1 1 | import os as foo @@ -257,16 +270,17 @@ import_as.py:19:7: PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_d 21 22 | bbbbb = foo_p.islink(p) 22 23 | foo.readlink(p) -import_as.py:20:8: PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()` +PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()` + --> import_as.py:20:8 | 18 | bb = foo_p.expanduser(p) 19 | bbb = foo_p.isdir(p) 20 | bbbb = foo_p.isfile(p) - | ^^^^^^^^^^^^ PTH113 + | ^^^^^^^^^^^^ 21 | bbbbb = foo_p.islink(p) 22 | foo.readlink(p) | - = help: Replace with `Path(...).is_file()` +help: Replace with `Path(...).is_file()` ℹ Safe fix 1 1 | import os as foo @@ -285,16 +299,17 @@ import_as.py:20:8: PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_ 22 23 | foo.readlink(p) 23 24 | foo.stat(p) -import_as.py:21:9: PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()` +PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()` + --> import_as.py:21:9 | 19 | bbb = foo_p.isdir(p) 20 | bbbb = foo_p.isfile(p) 21 | bbbbb = foo_p.islink(p) - | ^^^^^^^^^^^^ PTH114 + | ^^^^^^^^^^^^ 22 | foo.readlink(p) 23 | foo.stat(p) | - = help: Replace with `Path(...).is_symlink()` +help: Replace with `Path(...).is_symlink()` ℹ Safe fix 1 1 | import os as foo @@ -313,16 +328,17 @@ import_as.py:21:9: PTH114 [*] `os.path.islink()` should be replaced by `Path.is_ 23 24 | foo.stat(p) 24 25 | foo_p.isabs(p) -import_as.py:22:1: PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` +PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` + --> import_as.py:22:1 | 20 | bbbb = foo_p.isfile(p) 21 | bbbbb = foo_p.islink(p) 22 | foo.readlink(p) - | ^^^^^^^^^^^^ PTH115 + | ^^^^^^^^^^^^ 23 | foo.stat(p) 24 | foo_p.isabs(p) | - = help: Replace with `Path(...).readlink()` +help: Replace with `Path(...).readlink()` ℹ Safe fix 1 1 | import os as foo @@ -341,26 +357,28 @@ import_as.py:22:1: PTH115 [*] `os.readlink()` should be replaced by `Path.readli 24 25 | foo_p.isabs(p) 25 26 | foo_p.join(p, q) -import_as.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` +PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + --> import_as.py:23:1 | 21 | bbbbb = foo_p.islink(p) 22 | foo.readlink(p) 23 | foo.stat(p) - | ^^^^^^^^ PTH116 + | ^^^^^^^^ 24 | foo_p.isabs(p) 25 | foo_p.join(p, q) | -import_as.py:24:1: PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()` +PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()` + --> import_as.py:24:1 | 22 | foo.readlink(p) 23 | foo.stat(p) 24 | foo_p.isabs(p) - | ^^^^^^^^^^^ PTH117 + | ^^^^^^^^^^^ 25 | foo_p.join(p, q) 26 | foo.sep.join([p, q]) | - = help: Replace with `Path(...).is_absolute()` +help: Replace with `Path(...).is_absolute()` ℹ Safe fix 1 1 | import os as foo @@ -379,46 +397,50 @@ import_as.py:24:1: PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_a 26 27 | foo.sep.join([p, q]) 27 28 | foo.sep.join((p, q)) -import_as.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator +PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + --> import_as.py:25:1 | 23 | foo.stat(p) 24 | foo_p.isabs(p) 25 | foo_p.join(p, q) - | ^^^^^^^^^^ PTH118 + | ^^^^^^^^^^ 26 | foo.sep.join([p, q]) 27 | foo.sep.join((p, q)) | -import_as.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_as.py:26:1 | 24 | foo_p.isabs(p) 25 | foo_p.join(p, q) 26 | foo.sep.join([p, q]) - | ^^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^^ 27 | foo.sep.join((p, q)) 28 | foo_p.basename(p) | -import_as.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_as.py:27:1 | 25 | foo_p.join(p, q) 26 | foo.sep.join([p, q]) 27 | foo.sep.join((p, q)) - | ^^^^^^^^^^^^ PTH118 + | ^^^^^^^^^^^^ 28 | foo_p.basename(p) 29 | foo_p.dirname(p) | -import_as.py:28:1: PTH119 [*] `os.path.basename()` should be replaced by `Path.name` +PTH119 [*] `os.path.basename()` should be replaced by `Path.name` + --> import_as.py:28:1 | 26 | foo.sep.join([p, q]) 27 | foo.sep.join((p, q)) 28 | foo_p.basename(p) - | ^^^^^^^^^^^^^^ PTH119 + | ^^^^^^^^^^^^^^ 29 | foo_p.dirname(p) 30 | foo_p.samefile(p) | - = help: Replace with `Path(...).name` +help: Replace with `Path(...).name` ℹ Safe fix 1 1 | import os as foo @@ -437,16 +459,17 @@ import_as.py:28:1: PTH119 [*] `os.path.basename()` should be replaced by `Path.n 30 31 | foo_p.samefile(p) 31 32 | foo_p.splitext(p) -import_as.py:29:1: PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent` +PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent` + --> import_as.py:29:1 | 27 | foo.sep.join((p, q)) 28 | foo_p.basename(p) 29 | foo_p.dirname(p) - | ^^^^^^^^^^^^^ PTH120 + | ^^^^^^^^^^^^^ 30 | foo_p.samefile(p) 31 | foo_p.splitext(p) | - = help: Replace with `Path(...).parent` +help: Replace with `Path(...).parent` ℹ Safe fix 1 1 | import os as foo @@ -464,20 +487,22 @@ import_as.py:29:1: PTH120 [*] `os.path.dirname()` should be replaced by `Path.pa 30 31 | foo_p.samefile(p) 31 32 | foo_p.splitext(p) -import_as.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` +PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + --> import_as.py:30:1 | 28 | foo_p.basename(p) 29 | foo_p.dirname(p) 30 | foo_p.samefile(p) - | ^^^^^^^^^^^^^^ PTH121 + | ^^^^^^^^^^^^^^ 31 | foo_p.splitext(p) | - = help: Replace with `Path(...).samefile()` +help: Replace with `Path(...).samefile()` -import_as.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` +PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + --> import_as.py:31:1 | 29 | foo_p.dirname(p) 30 | foo_p.samefile(p) 31 | foo_p.splitext(p) - | ^^^^^^^^^^^^^^ PTH122 + | ^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_from.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_from.py.snap index d4087514c9..1d295095d3 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_from.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_from.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -import_from.py:9:5: PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()` +PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()` + --> import_from.py:9:5 | 7 | q = "bar" 8 | 9 | a = abspath(p) - | ^^^^^^^ PTH100 + | ^^^^^^^ 10 | aa = chmod(p) 11 | aaa = mkdir(p) | - = help: Replace with `Path(...).resolve()` +help: Replace with `Path(...).resolve()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -27,68 +28,74 @@ import_from.py:9:5: PTH100 [*] `os.path.abspath()` should be replaced by `Path.r 11 12 | aaa = mkdir(p) 12 13 | makedirs(p) -import_from.py:10:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` +PTH101 `os.chmod()` should be replaced by `Path.chmod()` + --> import_from.py:10:6 | 9 | a = abspath(p) 10 | aa = chmod(p) - | ^^^^^ PTH101 + | ^^^^^ 11 | aaa = mkdir(p) 12 | makedirs(p) | - = help: Replace with `Path(...).chmod(...)` +help: Replace with `Path(...).chmod(...)` -import_from.py:11:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` +PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + --> import_from.py:11:7 | 9 | a = abspath(p) 10 | aa = chmod(p) 11 | aaa = mkdir(p) - | ^^^^^ PTH102 + | ^^^^^ 12 | makedirs(p) 13 | rename(p) | -import_from.py:12:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` +PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + --> import_from.py:12:1 | 10 | aa = chmod(p) 11 | aaa = mkdir(p) 12 | makedirs(p) - | ^^^^^^^^ PTH103 + | ^^^^^^^^ 13 | rename(p) 14 | replace(p) | -import_from.py:13:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_from.py:13:1 | 11 | aaa = mkdir(p) 12 | makedirs(p) 13 | rename(p) - | ^^^^^^ PTH104 + | ^^^^^^ 14 | replace(p) 15 | rmdir(p) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -import_from.py:14:1: PTH105 `os.replace()` should be replaced by `Path.replace()` +PTH105 `os.replace()` should be replaced by `Path.replace()` + --> import_from.py:14:1 | 12 | makedirs(p) 13 | rename(p) 14 | replace(p) - | ^^^^^^^ PTH105 + | ^^^^^^^ 15 | rmdir(p) 16 | remove(p) | - = help: Replace with `Path(...).replace(...)` +help: Replace with `Path(...).replace(...)` -import_from.py:15:1: PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` +PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` + --> import_from.py:15:1 | 13 | rename(p) 14 | replace(p) 15 | rmdir(p) - | ^^^^^ PTH106 + | ^^^^^ 16 | remove(p) 17 | unlink(p) | - = help: Replace with `Path(...).rmdir()` +help: Replace with `Path(...).rmdir()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -108,16 +115,17 @@ import_from.py:15:1: PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir() 17 18 | unlink(p) 18 19 | getcwd(p) -import_from.py:16:1: PTH107 [*] `os.remove()` should be replaced by `Path.unlink()` +PTH107 [*] `os.remove()` should be replaced by `Path.unlink()` + --> import_from.py:16:1 | 14 | replace(p) 15 | rmdir(p) 16 | remove(p) - | ^^^^^^ PTH107 + | ^^^^^^ 17 | unlink(p) 18 | getcwd(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -137,16 +145,17 @@ import_from.py:16:1: PTH107 [*] `os.remove()` should be replaced by `Path.unlink 18 19 | getcwd(p) 19 20 | b = exists(p) -import_from.py:17:1: PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()` +PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()` + --> import_from.py:17:1 | 15 | rmdir(p) 16 | remove(p) 17 | unlink(p) - | ^^^^^^ PTH108 + | ^^^^^^ 18 | getcwd(p) 19 | b = exists(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -166,27 +175,29 @@ import_from.py:17:1: PTH108 [*] `os.unlink()` should be replaced by `Path.unlink 19 20 | b = exists(p) 20 21 | bb = expanduser(p) -import_from.py:18:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> import_from.py:18:1 | 16 | remove(p) 17 | unlink(p) 18 | getcwd(p) - | ^^^^^^ PTH109 + | ^^^^^^ 19 | b = exists(p) 20 | bb = expanduser(p) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -import_from.py:19:5: PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()` +PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()` + --> import_from.py:19:5 | 17 | unlink(p) 18 | getcwd(p) 19 | b = exists(p) - | ^^^^^^ PTH110 + | ^^^^^^ 20 | bb = expanduser(p) 21 | bbb = isdir(p) | - = help: Replace with `Path(...).exists()` +help: Replace with `Path(...).exists()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -206,16 +217,17 @@ import_from.py:19:5: PTH110 [*] `os.path.exists()` should be replaced by `Path.e 21 22 | bbb = isdir(p) 22 23 | bbbb = isfile(p) -import_from.py:20:6: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()` +PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()` + --> import_from.py:20:6 | 18 | getcwd(p) 19 | b = exists(p) 20 | bb = expanduser(p) - | ^^^^^^^^^^ PTH111 + | ^^^^^^^^^^ 21 | bbb = isdir(p) 22 | bbbb = isfile(p) | - = help: Replace with `Path(...).expanduser()` +help: Replace with `Path(...).expanduser()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -235,16 +247,17 @@ import_from.py:20:6: PTH111 [*] `os.path.expanduser()` should be replaced by `Pa 22 23 | bbbb = isfile(p) 23 24 | bbbbb = islink(p) -import_from.py:21:7: PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()` +PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()` + --> import_from.py:21:7 | 19 | b = exists(p) 20 | bb = expanduser(p) 21 | bbb = isdir(p) - | ^^^^^ PTH112 + | ^^^^^ 22 | bbbb = isfile(p) 23 | bbbbb = islink(p) | - = help: Replace with `Path(...).is_dir()` +help: Replace with `Path(...).is_dir()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -264,16 +277,17 @@ import_from.py:21:7: PTH112 [*] `os.path.isdir()` should be replaced by `Path.is 23 24 | bbbbb = islink(p) 24 25 | readlink(p) -import_from.py:22:8: PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()` +PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()` + --> import_from.py:22:8 | 20 | bb = expanduser(p) 21 | bbb = isdir(p) 22 | bbbb = isfile(p) - | ^^^^^^ PTH113 + | ^^^^^^ 23 | bbbbb = islink(p) 24 | readlink(p) | - = help: Replace with `Path(...).is_file()` +help: Replace with `Path(...).is_file()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -293,16 +307,17 @@ import_from.py:22:8: PTH113 [*] `os.path.isfile()` should be replaced by `Path.i 24 25 | readlink(p) 25 26 | stat(p) -import_from.py:23:9: PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()` +PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()` + --> import_from.py:23:9 | 21 | bbb = isdir(p) 22 | bbbb = isfile(p) 23 | bbbbb = islink(p) - | ^^^^^^ PTH114 + | ^^^^^^ 24 | readlink(p) 25 | stat(p) | - = help: Replace with `Path(...).is_symlink()` +help: Replace with `Path(...).is_symlink()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -322,16 +337,17 @@ import_from.py:23:9: PTH114 [*] `os.path.islink()` should be replaced by `Path.i 25 26 | stat(p) 26 27 | isabs(p) -import_from.py:24:1: PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` +PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` + --> import_from.py:24:1 | 22 | bbbb = isfile(p) 23 | bbbbb = islink(p) 24 | readlink(p) - | ^^^^^^^^ PTH115 + | ^^^^^^^^ 25 | stat(p) 26 | isabs(p) | - = help: Replace with `Path(...).readlink()` +help: Replace with `Path(...).readlink()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -351,26 +367,28 @@ import_from.py:24:1: PTH115 [*] `os.readlink()` should be replaced by `Path.read 26 27 | isabs(p) 27 28 | join(p, q) -import_from.py:25:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` +PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + --> import_from.py:25:1 | 23 | bbbbb = islink(p) 24 | readlink(p) 25 | stat(p) - | ^^^^ PTH116 + | ^^^^ 26 | isabs(p) 27 | join(p, q) | -import_from.py:26:1: PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()` +PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()` + --> import_from.py:26:1 | 24 | readlink(p) 25 | stat(p) 26 | isabs(p) - | ^^^^^ PTH117 + | ^^^^^ 27 | join(p, q) 28 | sep.join((p, q)) | - = help: Replace with `Path(...).is_absolute()` +help: Replace with `Path(...).is_absolute()` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -390,46 +408,50 @@ import_from.py:26:1: PTH117 [*] `os.path.isabs()` should be replaced by `Path.is 28 29 | sep.join((p, q)) 29 30 | sep.join([p, q]) -import_from.py:27:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator +PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + --> import_from.py:27:1 | 25 | stat(p) 26 | isabs(p) 27 | join(p, q) - | ^^^^ PTH118 + | ^^^^ 28 | sep.join((p, q)) 29 | sep.join([p, q]) | -import_from.py:28:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_from.py:28:1 | 26 | isabs(p) 27 | join(p, q) 28 | sep.join((p, q)) - | ^^^^^^^^ PTH118 + | ^^^^^^^^ 29 | sep.join([p, q]) 30 | basename(p) | -import_from.py:29:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_from.py:29:1 | 27 | join(p, q) 28 | sep.join((p, q)) 29 | sep.join([p, q]) - | ^^^^^^^^ PTH118 + | ^^^^^^^^ 30 | basename(p) 31 | dirname(p) | -import_from.py:30:1: PTH119 [*] `os.path.basename()` should be replaced by `Path.name` +PTH119 [*] `os.path.basename()` should be replaced by `Path.name` + --> import_from.py:30:1 | 28 | sep.join((p, q)) 29 | sep.join([p, q]) 30 | basename(p) - | ^^^^^^^^ PTH119 + | ^^^^^^^^ 31 | dirname(p) 32 | samefile(p) | - = help: Replace with `Path(...).name` +help: Replace with `Path(...).name` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -449,16 +471,17 @@ import_from.py:30:1: PTH119 [*] `os.path.basename()` should be replaced by `Path 32 33 | samefile(p) 33 34 | splitext(p) -import_from.py:31:1: PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent` +PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent` + --> import_from.py:31:1 | 29 | sep.join([p, q]) 30 | basename(p) 31 | dirname(p) - | ^^^^^^^ PTH120 + | ^^^^^^^ 32 | samefile(p) 33 | splitext(p) | - = help: Replace with `Path(...).parent` +help: Replace with `Path(...).parent` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -478,63 +501,69 @@ import_from.py:31:1: PTH120 [*] `os.path.dirname()` should be replaced by `Path. 33 34 | splitext(p) 34 35 | with open(p) as fp: -import_from.py:32:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` +PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + --> import_from.py:32:1 | 30 | basename(p) 31 | dirname(p) 32 | samefile(p) - | ^^^^^^^^ PTH121 + | ^^^^^^^^ 33 | splitext(p) 34 | with open(p) as fp: | - = help: Replace with `Path(...).samefile()` +help: Replace with `Path(...).samefile()` -import_from.py:33:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` +PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + --> import_from.py:33:1 | 31 | dirname(p) 32 | samefile(p) 33 | splitext(p) - | ^^^^^^^^ PTH122 + | ^^^^^^^^ 34 | with open(p) as fp: 35 | fp.read() | -import_from.py:34:6: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> import_from.py:34:6 | 32 | samefile(p) 33 | splitext(p) 34 | with open(p) as fp: - | ^^^^ PTH123 + | ^^^^ 35 | fp.read() 36 | open(p).close() | -import_from.py:36:1: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> import_from.py:36:1 | 34 | with open(p) as fp: 35 | fp.read() 36 | open(p).close() - | ^^^^ PTH123 + | ^^^^ | -import_from.py:43:10: PTH123 `open()` should be replaced by `Path.open()` +PTH123 `open()` should be replaced by `Path.open()` + --> import_from.py:43:10 | 41 | from builtins import open 42 | 43 | with open(p) as _: ... # Error - | ^^^^ PTH123 + | ^^^^ | -import_from.py:53:1: PTH104 [*] `os.rename()` should be replaced by `Path.rename()` +PTH104 [*] `os.rename()` should be replaced by `Path.rename()` + --> import_from.py:53:1 | 51 | file = "file_1.py" 52 | 53 | rename(file, "file_2.py") - | ^^^^^^ PTH104 + | ^^^^^^ 54 | 55 | rename( | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -554,16 +583,17 @@ import_from.py:53:1: PTH104 [*] `os.rename()` should be replaced by `Path.rename 55 56 | rename( 56 57 | # commment 1 -import_from.py:55:1: PTH104 [*] `os.rename()` should be replaced by `Path.rename()` +PTH104 [*] `os.rename()` should be replaced by `Path.rename()` + --> import_from.py:55:1 | 53 | rename(file, "file_2.py") 54 | 55 | rename( - | ^^^^^^ PTH104 + | ^^^^^^ 56 | # commment 1 57 | file, # comment 2 | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` ℹ Unsafe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat @@ -589,16 +619,17 @@ import_from.py:55:1: PTH104 [*] `os.rename()` should be replaced by `Path.rename 63 58 | rename(file, "file_2.py", src_dir_fd=None, dst_dir_fd=None) 64 59 | -import_from.py:63:1: PTH104 [*] `os.rename()` should be replaced by `Path.rename()` +PTH104 [*] `os.rename()` should be replaced by `Path.rename()` + --> import_from.py:63:1 | 61 | ) 62 | 63 | rename(file, "file_2.py", src_dir_fd=None, dst_dir_fd=None) - | ^^^^^^ PTH104 + | ^^^^^^ 64 | 65 | rename(file, "file_2.py", src_dir_fd=1) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` ℹ Safe fix 2 2 | from os import remove, unlink, getcwd, readlink, stat diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_from_as.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_from_as.py.snap index 7bfd51c194..1d59d9f304 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_from_as.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_import_from_as.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs --- -import_from_as.py:14:5: PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()` +PTH100 [*] `os.path.abspath()` should be replaced by `Path.resolve()` + --> import_from_as.py:14:5 | 12 | q = "bar" 13 | 14 | a = xabspath(p) - | ^^^^^^^^ PTH100 + | ^^^^^^^^ 15 | aa = xchmod(p) 16 | aaa = xmkdir(p) | - = help: Replace with `Path(...).resolve()` +help: Replace with `Path(...).resolve()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -27,68 +28,74 @@ import_from_as.py:14:5: PTH100 [*] `os.path.abspath()` should be replaced by `Pa 16 17 | aaa = xmkdir(p) 17 18 | xmakedirs(p) -import_from_as.py:15:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` +PTH101 `os.chmod()` should be replaced by `Path.chmod()` + --> import_from_as.py:15:6 | 14 | a = xabspath(p) 15 | aa = xchmod(p) - | ^^^^^^ PTH101 + | ^^^^^^ 16 | aaa = xmkdir(p) 17 | xmakedirs(p) | - = help: Replace with `Path(...).chmod(...)` +help: Replace with `Path(...).chmod(...)` -import_from_as.py:16:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` +PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + --> import_from_as.py:16:7 | 14 | a = xabspath(p) 15 | aa = xchmod(p) 16 | aaa = xmkdir(p) - | ^^^^^^ PTH102 + | ^^^^^^ 17 | xmakedirs(p) 18 | xrename(p) | -import_from_as.py:17:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` +PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + --> import_from_as.py:17:1 | 15 | aa = xchmod(p) 16 | aaa = xmkdir(p) 17 | xmakedirs(p) - | ^^^^^^^^^ PTH103 + | ^^^^^^^^^ 18 | xrename(p) 19 | xreplace(p) | -import_from_as.py:18:1: PTH104 `os.rename()` should be replaced by `Path.rename()` +PTH104 `os.rename()` should be replaced by `Path.rename()` + --> import_from_as.py:18:1 | 16 | aaa = xmkdir(p) 17 | xmakedirs(p) 18 | xrename(p) - | ^^^^^^^ PTH104 + | ^^^^^^^ 19 | xreplace(p) 20 | xrmdir(p) | - = help: Replace with `Path(...).rename(...)` +help: Replace with `Path(...).rename(...)` -import_from_as.py:19:1: PTH105 `os.replace()` should be replaced by `Path.replace()` +PTH105 `os.replace()` should be replaced by `Path.replace()` + --> import_from_as.py:19:1 | 17 | xmakedirs(p) 18 | xrename(p) 19 | xreplace(p) - | ^^^^^^^^ PTH105 + | ^^^^^^^^ 20 | xrmdir(p) 21 | xremove(p) | - = help: Replace with `Path(...).replace(...)` +help: Replace with `Path(...).replace(...)` -import_from_as.py:20:1: PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` +PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdir()` + --> import_from_as.py:20:1 | 18 | xrename(p) 19 | xreplace(p) 20 | xrmdir(p) - | ^^^^^^ PTH106 + | ^^^^^^ 21 | xremove(p) 22 | xunlink(p) | - = help: Replace with `Path(...).rmdir()` +help: Replace with `Path(...).rmdir()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -108,16 +115,17 @@ import_from_as.py:20:1: PTH106 [*] `os.rmdir()` should be replaced by `Path.rmdi 22 23 | xunlink(p) 23 24 | xgetcwd(p) -import_from_as.py:21:1: PTH107 [*] `os.remove()` should be replaced by `Path.unlink()` +PTH107 [*] `os.remove()` should be replaced by `Path.unlink()` + --> import_from_as.py:21:1 | 19 | xreplace(p) 20 | xrmdir(p) 21 | xremove(p) - | ^^^^^^^ PTH107 + | ^^^^^^^ 22 | xunlink(p) 23 | xgetcwd(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -137,16 +145,17 @@ import_from_as.py:21:1: PTH107 [*] `os.remove()` should be replaced by `Path.unl 23 24 | xgetcwd(p) 24 25 | b = xexists(p) -import_from_as.py:22:1: PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()` +PTH108 [*] `os.unlink()` should be replaced by `Path.unlink()` + --> import_from_as.py:22:1 | 20 | xrmdir(p) 21 | xremove(p) 22 | xunlink(p) - | ^^^^^^^ PTH108 + | ^^^^^^^ 23 | xgetcwd(p) 24 | b = xexists(p) | - = help: Replace with `Path(...).unlink()` +help: Replace with `Path(...).unlink()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -166,27 +175,29 @@ import_from_as.py:22:1: PTH108 [*] `os.unlink()` should be replaced by `Path.unl 24 25 | b = xexists(p) 25 26 | bb = xexpanduser(p) -import_from_as.py:23:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` +PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + --> import_from_as.py:23:1 | 21 | xremove(p) 22 | xunlink(p) 23 | xgetcwd(p) - | ^^^^^^^ PTH109 + | ^^^^^^^ 24 | b = xexists(p) 25 | bb = xexpanduser(p) | - = help: Replace with `Path.cwd()` +help: Replace with `Path.cwd()` -import_from_as.py:24:5: PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()` +PTH110 [*] `os.path.exists()` should be replaced by `Path.exists()` + --> import_from_as.py:24:5 | 22 | xunlink(p) 23 | xgetcwd(p) 24 | b = xexists(p) - | ^^^^^^^ PTH110 + | ^^^^^^^ 25 | bb = xexpanduser(p) 26 | bbb = xisdir(p) | - = help: Replace with `Path(...).exists()` +help: Replace with `Path(...).exists()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -206,16 +217,17 @@ import_from_as.py:24:5: PTH110 [*] `os.path.exists()` should be replaced by `Pat 26 27 | bbb = xisdir(p) 27 28 | bbbb = xisfile(p) -import_from_as.py:25:6: PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()` +PTH111 [*] `os.path.expanduser()` should be replaced by `Path.expanduser()` + --> import_from_as.py:25:6 | 23 | xgetcwd(p) 24 | b = xexists(p) 25 | bb = xexpanduser(p) - | ^^^^^^^^^^^ PTH111 + | ^^^^^^^^^^^ 26 | bbb = xisdir(p) 27 | bbbb = xisfile(p) | - = help: Replace with `Path(...).expanduser()` +help: Replace with `Path(...).expanduser()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -235,16 +247,17 @@ import_from_as.py:25:6: PTH111 [*] `os.path.expanduser()` should be replaced by 27 28 | bbbb = xisfile(p) 28 29 | bbbbb = xislink(p) -import_from_as.py:26:7: PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()` +PTH112 [*] `os.path.isdir()` should be replaced by `Path.is_dir()` + --> import_from_as.py:26:7 | 24 | b = xexists(p) 25 | bb = xexpanduser(p) 26 | bbb = xisdir(p) - | ^^^^^^ PTH112 + | ^^^^^^ 27 | bbbb = xisfile(p) 28 | bbbbb = xislink(p) | - = help: Replace with `Path(...).is_dir()` +help: Replace with `Path(...).is_dir()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -264,16 +277,17 @@ import_from_as.py:26:7: PTH112 [*] `os.path.isdir()` should be replaced by `Path 28 29 | bbbbb = xislink(p) 29 30 | xreadlink(p) -import_from_as.py:27:8: PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()` +PTH113 [*] `os.path.isfile()` should be replaced by `Path.is_file()` + --> import_from_as.py:27:8 | 25 | bb = xexpanduser(p) 26 | bbb = xisdir(p) 27 | bbbb = xisfile(p) - | ^^^^^^^ PTH113 + | ^^^^^^^ 28 | bbbbb = xislink(p) 29 | xreadlink(p) | - = help: Replace with `Path(...).is_file()` +help: Replace with `Path(...).is_file()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -293,16 +307,17 @@ import_from_as.py:27:8: PTH113 [*] `os.path.isfile()` should be replaced by `Pat 29 30 | xreadlink(p) 30 31 | xstat(p) -import_from_as.py:28:9: PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()` +PTH114 [*] `os.path.islink()` should be replaced by `Path.is_symlink()` + --> import_from_as.py:28:9 | 26 | bbb = xisdir(p) 27 | bbbb = xisfile(p) 28 | bbbbb = xislink(p) - | ^^^^^^^ PTH114 + | ^^^^^^^ 29 | xreadlink(p) 30 | xstat(p) | - = help: Replace with `Path(...).is_symlink()` +help: Replace with `Path(...).is_symlink()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -322,16 +337,17 @@ import_from_as.py:28:9: PTH114 [*] `os.path.islink()` should be replaced by `Pat 30 31 | xstat(p) 31 32 | xisabs(p) -import_from_as.py:29:1: PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` +PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` + --> import_from_as.py:29:1 | 27 | bbbb = xisfile(p) 28 | bbbbb = xislink(p) 29 | xreadlink(p) - | ^^^^^^^^^ PTH115 + | ^^^^^^^^^ 30 | xstat(p) 31 | xisabs(p) | - = help: Replace with `Path(...).readlink()` +help: Replace with `Path(...).readlink()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -351,26 +367,28 @@ import_from_as.py:29:1: PTH115 [*] `os.readlink()` should be replaced by `Path.r 31 32 | xisabs(p) 32 33 | xjoin(p, q) -import_from_as.py:30:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` +PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + --> import_from_as.py:30:1 | 28 | bbbbb = xislink(p) 29 | xreadlink(p) 30 | xstat(p) - | ^^^^^ PTH116 + | ^^^^^ 31 | xisabs(p) 32 | xjoin(p, q) | -import_from_as.py:31:1: PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()` +PTH117 [*] `os.path.isabs()` should be replaced by `Path.is_absolute()` + --> import_from_as.py:31:1 | 29 | xreadlink(p) 30 | xstat(p) 31 | xisabs(p) - | ^^^^^^ PTH117 + | ^^^^^^ 32 | xjoin(p, q) 33 | s.join((p, q)) | - = help: Replace with `Path(...).is_absolute()` +help: Replace with `Path(...).is_absolute()` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -390,46 +408,50 @@ import_from_as.py:31:1: PTH117 [*] `os.path.isabs()` should be replaced by `Path 33 34 | s.join((p, q)) 34 35 | s.join([p, q]) -import_from_as.py:32:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator +PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + --> import_from_as.py:32:1 | 30 | xstat(p) 31 | xisabs(p) 32 | xjoin(p, q) - | ^^^^^ PTH118 + | ^^^^^ 33 | s.join((p, q)) 34 | s.join([p, q]) | -import_from_as.py:33:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_from_as.py:33:1 | 31 | xisabs(p) 32 | xjoin(p, q) 33 | s.join((p, q)) - | ^^^^^^ PTH118 + | ^^^^^^ 34 | s.join([p, q]) 35 | xbasename(p) | -import_from_as.py:34:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator +PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + --> import_from_as.py:34:1 | 32 | xjoin(p, q) 33 | s.join((p, q)) 34 | s.join([p, q]) - | ^^^^^^ PTH118 + | ^^^^^^ 35 | xbasename(p) 36 | xdirname(p) | -import_from_as.py:35:1: PTH119 [*] `os.path.basename()` should be replaced by `Path.name` +PTH119 [*] `os.path.basename()` should be replaced by `Path.name` + --> import_from_as.py:35:1 | 33 | s.join((p, q)) 34 | s.join([p, q]) 35 | xbasename(p) - | ^^^^^^^^^ PTH119 + | ^^^^^^^^^ 36 | xdirname(p) 37 | xsamefile(p) | - = help: Replace with `Path(...).name` +help: Replace with `Path(...).name` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -449,16 +471,17 @@ import_from_as.py:35:1: PTH119 [*] `os.path.basename()` should be replaced by `P 37 38 | xsamefile(p) 38 39 | xsplitext(p) -import_from_as.py:36:1: PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent` +PTH120 [*] `os.path.dirname()` should be replaced by `Path.parent` + --> import_from_as.py:36:1 | 34 | s.join([p, q]) 35 | xbasename(p) 36 | xdirname(p) - | ^^^^^^^^ PTH120 + | ^^^^^^^^ 37 | xsamefile(p) 38 | xsplitext(p) | - = help: Replace with `Path(...).parent` +help: Replace with `Path(...).parent` ℹ Safe fix 7 7 | from os.path import isfile as xisfile, islink as xislink, isabs as xisabs @@ -477,20 +500,22 @@ import_from_as.py:36:1: PTH120 [*] `os.path.dirname()` should be replaced by `Pa 37 38 | xsamefile(p) 38 39 | xsplitext(p) -import_from_as.py:37:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` +PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + --> import_from_as.py:37:1 | 35 | xbasename(p) 36 | xdirname(p) 37 | xsamefile(p) - | ^^^^^^^^^ PTH121 + | ^^^^^^^^^ 38 | xsplitext(p) | - = help: Replace with `Path(...).samefile()` +help: Replace with `Path(...).samefile()` -import_from_as.py:38:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` +PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + --> import_from_as.py:38:1 | 36 | xdirname(p) 37 | xsamefile(p) 38 | xsplitext(p) - | ^^^^^^^^^ PTH122 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap b/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap index 9a1e06585c..a05344de64 100644 --- a/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap +++ b/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/flynt/mod.rs --- -FLY002.py:5:7: FLY002 [*] Consider `f"{a} World"` instead of string join +FLY002 [*] Consider `f"{a} World"` instead of string join + --> FLY002.py:5:7 | 4 | a = "Hello" 5 | ok1 = " ".join([a, " World"]) # OK - | ^^^^^^^^^^^^^^^^^^^^^^^ FLY002 + | ^^^^^^^^^^^^^^^^^^^^^^^ 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK 7 | ok3 = "x".join(("1", "2", "3")) # OK | - = help: Replace with `f"{a} World"` +help: Replace with `f"{a} World"` ℹ Unsafe fix 2 2 | from random import random, choice @@ -21,16 +22,17 @@ FLY002.py:5:7: FLY002 [*] Consider `f"{a} World"` instead of string join 7 7 | ok3 = "x".join(("1", "2", "3")) # OK 8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -FLY002.py:6:7: FLY002 [*] Consider `f"Finally, {a} World"` instead of string join +FLY002 [*] Consider `f"Finally, {a} World"` instead of string join + --> FLY002.py:6:7 | 4 | a = "Hello" 5 | ok1 = " ".join([a, " World"]) # OK 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | ok3 = "x".join(("1", "2", "3")) # OK 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally | - = help: Replace with `f"Finally, {a} World"` +help: Replace with `f"Finally, {a} World"` ℹ Unsafe fix 3 3 | @@ -42,16 +44,17 @@ FLY002.py:6:7: FLY002 [*] Consider `f"Finally, {a} World"` instead of string joi 8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally 9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -FLY002.py:7:7: FLY002 [*] Consider `"1x2x3"` instead of string join +FLY002 [*] Consider `"1x2x3"` instead of string join + --> FLY002.py:7:7 | 5 | ok1 = " ".join([a, " World"]) # OK 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK 7 | ok3 = "x".join(("1", "2", "3")) # OK - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) | - = help: Replace with `"1x2x3"` +help: Replace with `"1x2x3"` ℹ Unsafe fix 4 4 | a = "Hello" @@ -63,16 +66,17 @@ FLY002.py:7:7: FLY002 [*] Consider `"1x2x3"` instead of string join 9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) 10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) -FLY002.py:8:7: FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join +FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join + --> FLY002.py:8:7 | 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK 7 | ok3 = "x".join(("1", "2", "3")) # OK 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally - | ^^^^^^^^^^^^^^^^^^^ FLY002 + | ^^^^^^^^^^^^^^^^^^^ 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) | - = help: Replace with `f"{1}y{2}y{3}"` +help: Replace with `f"{1}y{2}y{3}"` ℹ Unsafe fix 5 5 | ok1 = " ".join([a, " World"]) # OK @@ -84,15 +88,16 @@ FLY002.py:8:7: FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join 10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) 11 11 | -FLY002.py:9:7: FLY002 [*] Consider `f"{random()}a{random()}"` instead of string join +FLY002 [*] Consider `f"{random()}a{random()}"` instead of string join + --> FLY002.py:9:7 | 7 | ok3 = "x".join(("1", "2", "3")) # OK 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) | - = help: Replace with `f"{random()}a{random()}"` +help: Replace with `f"{random()}a{random()}"` ℹ Unsafe fix 6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK @@ -104,16 +109,17 @@ FLY002.py:9:7: FLY002 [*] Consider `f"{random()}a{random()}"` instead of string 11 11 | 12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) -FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` instead of string join +FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` instead of string join + --> FLY002.py:10:7 | 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) | - = help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` +help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` ℹ Unsafe fix 7 7 | ok3 = "x".join(("1", "2", "3")) # OK @@ -125,14 +131,15 @@ FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_ 12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) 13 13 | nok2 = a.join(["1", "2", "3"]) # Not OK (not a static joiner) -FLY002.py:23:11: FLY002 [*] Consider `f"{url}{filename}"` instead of string join +FLY002 [*] Consider `f"{url}{filename}"` instead of string join + --> FLY002.py:23:11 | 21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197 22 | def create_file_public_url(url, filename): 23 | return''.join([url, filename]) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `f"{url}{filename}"` +help: Replace with `f"{url}{filename}"` ℹ Unsafe fix 20 20 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap index b040527eaf..640f8ef45f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_subpackage_first_and_third_party_imports.py:1:1 | 1 | / import sys 2 | | import baz @@ -11,9 +12,9 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 6 | | import foo 7 | | import foo.bar 8 | | import foo.bar.baz - | |__________________^ I001 + | |__________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import sys diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap index 2ab59bd971..a112861682 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_subpackage_first_and_third_party_imports.py:1:1 | 1 | / import sys 2 | | import baz @@ -11,9 +12,9 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 6 | | import foo 7 | | import foo.bar 8 | | import foo.bar.baz - | |__________________^ I001 + | |__________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import sys diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap index 9d1391be60..7764f55c0c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> add_newline_before_comments.py:1:1 | 1 | / import os 2 | | # This is a comment in the same section, so we need to add one newline. @@ -10,9 +11,9 @@ add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-for 5 | | # This is a comment, but it starts a new section, so we don't need to add a newline 6 | | # before it. 7 | | import leading_prefix - | |_____________________^ I001 + | |_____________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap index ce014c51f8..f99d6dc880 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -as_imports_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> as_imports_comments.py:1:1 | 1 | / from foo import ( # Comment on `foo` 2 | | Member as Alias, # Comment on `Alias` @@ -18,9 +19,9 @@ as_imports_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted 13 | | from bop import ( # Comment on `bop` 14 | | Member # Comment on `Member` 15 | | ) - | |_^ I001 + | |_^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from foo import ( # Comment on `foo` diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap index 7caa0cade2..94f4c90cd0 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -bom_unsorted.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> bom_unsorted.py:1:1 | -1 | / import foo +1 | / import foo 2 | | import bar - | |__________^ I001 + | |__________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import foo diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap index bcaa385eec..dbdb4cef00 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -case_sensitive.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> case_sensitive.py:1:1 | 1 | / import A 2 | | import B @@ -12,9 +13,9 @@ case_sensitive.py:1:1: I001 [*] Import block is un-sorted or un-formatted 7 | | import f 8 | | from g import a, B, c 9 | | from h import A, b, C - | |_____________________^ I001 + | |_____________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import A diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap index 61df2c9ece..282f28db82 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -relative_imports_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> relative_imports_order.py:1:1 | 1 | / from ... import a 2 | | from .. import b 3 | | from . import c - | |_______________^ I001 + | |_______________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+from . import c diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap index e3ad645a87..c9a668a8cf 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> combine_as_imports.py:1:1 | 1 | / from module import Class as C 2 | | from module import CONSTANT 3 | | from module import function 4 | | from module import function as f - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+from module import CONSTANT, function diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap index 938f2be566..1bfabef370 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> combine_as_imports.py:1:1 | 1 | / from module import Class as C 2 | | from module import CONSTANT 3 | | from module import function 4 | | from module import function as f - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from module import Class as C diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap index 336030d66a..3277e96b8b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -combine_import_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> combine_import_from.py:1:1 | 1 | / from collections import Awaitable 2 | | from collections import AsyncIterable 3 | | from collections import Collection 4 | | from collections import ChainMap 5 | | from collections import MutableSequence, MutableMapping - | |_______________________________________________________^ I001 + | |_______________________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from collections import Awaitable diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap index c2fab23c8a..a05d2accfa 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> comments.py:3:1 | 1 | # Comment 1 2 | # Comment 2 @@ -36,9 +37,9 @@ comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted 31 | | 32 | | from F import a # Comment 1 33 | | from F import b - | |_______________^ I001 + | |_______________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | # Comment 1 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap index 330484dd87..802f717317 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -deduplicate_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> deduplicate_imports.py:1:1 | 1 | / import os 2 | | import os 3 | | import os as os1 4 | | import os as os2 - | |________________^ I001 + | |________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap index 999de4a0c2..ea45f03a17 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> bar.py:1:1 | 1 | / import os 2 | | import pandas 3 | | import foo.baz - | |______________^ I001 + | |______________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap index 2a2ad9b3c5..71e291594f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -fit_line_length.py:7:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> fit_line_length.py:7:5 | 6 | if indented: 7 | / from line_with_88 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa @@ -12,9 +13,9 @@ fit_line_length.py:7:5: I001 [*] Import block is un-sorted or un-formatted 12 | | from line_with_93 import ( 13 | | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 14 | | ) - | |_____^ I001 + | |_____^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 5 5 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap index 830674f130..1e9aa5cab2 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> fit_line_length_comment.py:1:1 | 1 | / import a 2 | | # Don't take this comment into account when determining whether the next import can fit on one line. @@ -11,9 +12,9 @@ fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatt 6 | | from f import g # 012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ 7 | | # The next import doesn't fit on one line. 8 | | from h import i # 012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9 - | |_______________^ I001 + | |_______________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import a diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap index a13e203531..0e39739f5d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_single_line.py:1:1 | 1 | / import sys, math 2 | | from os import path, uname @@ -30,9 +31,9 @@ force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted 25 | | 26 | | # comment 9 27 | | from baz import * # comment 10 - | |_________________^ I001 + | |_________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import sys, math diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap index 6e4fabaa91..c691b2aefe 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_sort_within_sections.py:1:1 | 1 | / from a import a1 # import_from 2 | | from c import * # import_from_star @@ -16,9 +17,9 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form 11 | | from . import my 12 | | from .my.nested import fn2 13 | | from ...grandparent import fn3 - | |______________________________^ I001 + | |______________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from a import a1 # import_from diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap index 1df72338f5..62d7a8d8ef 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_sort_within_sections.py:1:1 | 1 | / from a import a1 # import_from 2 | | from c import * # import_from_star @@ -16,9 +17,9 @@ force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-form 11 | | from . import my 12 | | from .my.nested import fn2 13 | | from ...grandparent import fn3 - | |______________________________^ I001 + | |______________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from a import a1 # import_from diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap index 269e175c04..94212f25e5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_future.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_sort_within_sections_future.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_sort_within_sections_future.py:1:1 | 1 | / import __future__ 2 | | from __future__ import annotations - | |__________________________________^ I001 + | |__________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap index 8ef755569c..86c1f33ecd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections_with_as_names.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_sort_within_sections_with_as_names.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_sort_within_sections_with_as_names.py:1:1 | 1 | / import encodings 2 | | from datetime import timezone as tz 3 | | from datetime import timedelta 4 | | import datetime as dt 5 | | import datetime - | |_______________^ I001 + | |_______________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import datetime diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap index fbf675285e..d13a77760b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_to_top.py:1:1 | 1 | / import lib6 2 | | import lib2 @@ -26,9 +27,9 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted 21 | | import lib3.lib4.lib5 22 | | from lib3.lib4 import foo 23 | | from lib3.lib4.lib5 import foo - | |______________________________^ I001 + | |______________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import lib6 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap index 901bb0dc67..e3b5a2578a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_to_top.py:1:1 | 1 | / import lib6 2 | | import lib2 @@ -26,9 +27,9 @@ force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted 21 | | import lib3.lib4.lib5 22 | | from lib3.lib4 import foo 23 | | from lib3.lib4.lib5 import foo - | |______________________________^ I001 + | |______________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import lib6 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap index 0d6e330375..e53adb4091 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_wrap_aliases.py:1:1 | 1 | / from .a import a1 as a1, a2 as a2 2 | | from .b import b1 as b1 3 | | from .c import c1 - | |_________________^ I001 + | |_________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from .a import a1 as a1, a2 as a2 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap index 04739f35ab..25a4bc4b1c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -force_wrap_aliases.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> force_wrap_aliases.py:1:1 | 1 | / from .a import a1 as a1, a2 as a2 2 | | from .b import b1 as b1 3 | | from .c import c1 - | |_________________^ I001 + | |_________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from .a import a1 as a1, a2 as a2 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap index e645e85d2b..b1c25d4506 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> forced_separate.py:3:1 | 1 | # office_helper and tests are both first-party, 2 | # but we want tests and experiments to be separated, in that order @@ -11,9 +12,9 @@ forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted 6 | | from experiments.starry import * 7 | | from experiments.weird import varieties 8 | | from office_helper.assistants import entity_registry as er - | |__________________________________________________________^ I001 + | |__________________________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | # office_helper and tests are both first-party, diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap index 2481bb1775..136faa2daf 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__future_from.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -future_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> future_from.py:1:1 | 1 | / import __future__ 2 | | from __future__ import annotations - | |__________________________________^ I001 + | |__________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap index b040527eaf..640f8ef45f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_subpackage_first_and_third_party_imports.py:1:1 | 1 | / import sys 2 | | import baz @@ -11,9 +12,9 @@ separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block 6 | | import foo 7 | | import foo.bar 8 | | import foo.bar.baz - | |__________________^ I001 + | |__________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import sys diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap index 3edbbf1dbd..a68ca1b639 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -if_elif_else.py:6:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> if_elif_else.py:6:5 | 4 | from setuptools.command.sdist import sdist as _sdist 5 | else: 6 | / from setuptools.command.sdist import sdist as _sdist 7 | | from distutils.command.sdist import sdist as _sdist - | |_______________________________________________________^ I001 + | |_______________________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 3 3 | elif "setuptools" in sys.modules: diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap index b1d09d2b67..549e10842a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -import_from_after_import.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> import_from_after_import.py:1:1 | 1 | / from collections import Collection 2 | | import os - | |_________^ I001 + | |_________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap index 03df06aaa5..86ef5295bd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> inline_comments.py:1:1 | 1 | / from a.prometheus.metrics import ( # type:ignore[attr-defined] 2 | | TERMINAL_CURRENTLY_RUNNING_TOTAL, @@ -14,9 +15,9 @@ inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted 9 | | from c.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL # type:ignore[attr-defined] 10 | | 11 | | from d.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL, OTHER_RUNNING_TOTAL # type:ignore[attr-defined] - | |______________________________________________________________________________________^ I001 + | |______________________________________________________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from a.prometheus.metrics import ( # type:ignore[attr-defined] diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap index abd18b22f6..76f24a7a8b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -insert_empty_lines.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> insert_empty_lines.py:1:1 | 1 | / import a 2 | | import b - | |________^ I001 + | |________^ 3 | x = 1 4 | import os | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import a @@ -19,17 +20,18 @@ insert_empty_lines.py:1:1: I001 [*] Import block is un-sorted or un-formatted 4 5 | import os 5 6 | import sys -insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> insert_empty_lines.py:4:1 | 2 | import b 3 | x = 1 4 | / import os 5 | | import sys - | |__________^ I001 + | |__________^ 6 | def f(): 7 | pass | - = help: Organize imports +help: Organize imports ℹ Safe fix 3 3 | x = 1 @@ -41,16 +43,17 @@ insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted 7 9 | pass 8 10 | if True: -insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> insert_empty_lines.py:14:1 | 12 | class X: pass 13 | y = 1 14 | / import os 15 | | import sys - | |__________^ I001 + | |__________^ 16 | """Docstring""" | - = help: Organize imports +help: Organize imports ℹ Safe fix 13 13 | y = 1 @@ -61,14 +64,15 @@ insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted 17 18 | 18 19 | if True: -insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> insert_empty_lines.py:52:1 | 52 | import os - | ^^^^^^^^^ I001 + | ^^^^^^^^^ 53 | 54 | # Comment goes here. | - = help: Organize imports +help: Organize imports ℹ Safe fix 51 51 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap index 022f3c67cf..edb2bd3578 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -insert_empty_lines.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> insert_empty_lines.pyi:1:1 | 1 | / import a 2 | | import b - | |________^ I001 + | |________^ 3 | x = 1 4 | import os | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import a @@ -19,17 +20,18 @@ insert_empty_lines.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted 4 5 | import os 5 6 | import sys -insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> insert_empty_lines.pyi:4:1 | 2 | import b 3 | x = 1 4 | / import os 5 | | import sys - | |__________^ I001 + | |__________^ 6 | def f(): 7 | pass | - = help: Organize imports +help: Organize imports ℹ Safe fix 3 3 | x = 1 @@ -40,16 +42,17 @@ insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted 7 8 | pass 8 9 | if True: -insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> insert_empty_lines.pyi:14:1 | 12 | class X: pass 13 | y = 1 14 | / import os 15 | | import sys - | |__________^ I001 + | |__________^ 16 | """Docstring""" | - = help: Organize imports +help: Organize imports ℹ Safe fix 13 13 | y = 1 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap index 598f30f26c..a0303f1be5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_closest_separate_local_folder_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_local_folder_imports.py:1:1 | 1 | / import sys 2 | | import ruff @@ -10,9 +11,9 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f 5 | | from . import leading_prefix 6 | | from .. import trailing_prefix 7 | | from ruff import check - | |______________________^ I001 + | |______________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap index 261c27be50..4ca17dda52 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_local_folder_imports.py:1:1 | 1 | / import sys 2 | | import ruff @@ -10,9 +11,9 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f 5 | | from . import leading_prefix 6 | | from .. import trailing_prefix 7 | | from ruff import check - | |______________________^ I001 + | |______________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap index 8197eb32fc..d924544c1f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap @@ -1,44 +1,48 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -leading_prefix.py:1:8: I001 Import block is un-sorted or un-formatted +I001 Import block is un-sorted or un-formatted + --> leading_prefix.py:1:8 | 1 | x = 1; import sys | ________^ 2 | | import os - | |_________^ I001 + | |_________^ 3 | 4 | if True: | - = help: Organize imports +help: Organize imports -leading_prefix.py:5:12: I001 Import block is un-sorted or un-formatted +I001 Import block is un-sorted or un-formatted + --> leading_prefix.py:5:12 | 4 | if True: 5 | x = 1; import sys | ____________^ 6 | | import os - | |_____________^ I001 + | |_____________^ 7 | 8 | if True: | - = help: Organize imports +help: Organize imports -leading_prefix.py:10:9: I001 Import block is un-sorted or un-formatted +I001 Import block is un-sorted or un-formatted + --> leading_prefix.py:10:9 | 8 | if True: 9 | x = 1; \ 10 | import os - | ^^^^^^^^^ I001 + | ^^^^^^^^^ 11 | 12 | x = 1; \ | - = help: Organize imports +help: Organize imports -leading_prefix.py:13:1: I001 Import block is un-sorted or un-formatted +I001 Import block is un-sorted or un-formatted + --> leading_prefix.py:13:1 | 12 | x = 1; \ 13 | import os - | ^^^^^^^^^ I001 + | ^^^^^^^^^ | - = help: Organize imports +help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap index 880421c107..0b48d95f99 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_from_imports.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_from_imports.py:1:1 | 1 | / from mediuuuuuuuuuuum import a 2 | | from short import b 3 | | from loooooooooooooooooooooog import c - | |______________________________________^ I001 + | |______________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+from short import b diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap index 386b16eb59..94f47e0f40 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_members.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_non_ascii_members.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_non_ascii_members.py:1:1 | 1 | / from module1 import ( 2 | | loooooooooooooong, @@ -14,9 +15,9 @@ length_sort_non_ascii_members.py:1:1: I001 [*] Import block is un-sorted or un-f 9 | | mediuuuuuum, 10 | | λοοοοοοοοοοοοοονγ, 11 | | ) - | |_^ I001 + | |_^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from module1 import ( diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap index b6081a6564..2ec6069c64 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_non_ascii_modules.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_non_ascii_modules.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_non_ascii_modules.py:1:1 | 1 | / import loooooooooooooong 2 | | import mediuuuuuum @@ -12,9 +13,9 @@ length_sort_non_ascii_modules.py:1:1: I001 [*] Import block is un-sorted or un-f 7 | | import λοοοοοοοοοοοοοονγ 8 | | import μεδιυυυυυμ 9 | | import looooooooooooooong - | |_________________________^ I001 + | |_________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import loooooooooooooong diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap index 040722c463..f6bd011af9 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_and_from_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_straight_and_from_imports.py:1:1 | 1 | / import mediuuuuuum 2 | | import short @@ -9,9 +10,9 @@ length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted 4 | | from looooooooooooooong import a 5 | | from mediuuuum import c 6 | | from short import b - | |___________________^ I001 + | |___________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import short diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap index e78d25ef38..a17b260c40 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_straight_imports.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_straight_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_straight_imports.py:1:1 | 1 | / import mediuuuuuumb 2 | | import short 3 | | import looooooooooooooooong 4 | | import mediuuuuuuma - | |___________________^ I001 + | |___________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import short diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap index c8dc6b1e84..10f86beef6 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort__length_sort_with_relative_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_with_relative_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_with_relative_imports.py:1:1 | 1 | / from ..looooooooooooooong import a 2 | | from ...mediuuuum import b @@ -10,9 +11,9 @@ length_sort_with_relative_imports.py:1:1: I001 [*] Import block is un-sorted or 5 | | from . import d 6 | | from .mediuuuum import a 7 | | from ......short import b - | |_________________________^ I001 + | |_________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from ..looooooooooooooong import a diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap index 9d4e3641c2..96a389074a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_from_imports.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_from_imports.py:1:1 | 1 | / from mediuuuuuuuuuuum import a 2 | | from short import b 3 | | from loooooooooooooooooooooog import c - | |______________________________________^ I001 + | |______________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+from loooooooooooooooooooooog import c diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap index ad3fedea0c..eede9709bd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_and_from_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_straight_and_from_imports.py:1:1 | 1 | / import mediuuuuuum 2 | | import short @@ -9,9 +10,9 @@ length_sort_straight_and_from_imports.py:1:1: I001 [*] Import block is un-sorted 4 | | from looooooooooooooong import a 5 | | from mediuuuum import c 6 | | from short import b - | |___________________^ I001 + | |___________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import short diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap index e78d25ef38..a17b260c40 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__length_sort_straight__length_sort_straight_imports.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -length_sort_straight_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> length_sort_straight_imports.py:1:1 | 1 | / import mediuuuuuumb 2 | | import short 3 | | import looooooooooooooooong 4 | | import mediuuuuuuma - | |___________________^ I001 + | |___________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import short diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap index 0a5efd8488..9822ae9a5a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_crlf.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -line_ending_crlf.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> line_ending_crlf.py:1:1 | 1 | from long_module_name import member_one, member_two, member_three, member_four, member_five - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from long_module_name import member_one, member_two, member_three, member_four, member_five diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap index 37e4e42e78..ff6cdea1d7 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__line_ending_lf.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -line_ending_lf.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> line_ending_lf.py:1:1 | 1 | from long_module_name import member_one, member_two, member_three, member_four, member_five - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from long_module_name import member_one, member_two, member_three, member_four, member_five diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap index da09ee6218..a4c209169f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports.pyi.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> lines_after_imports.pyi:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,9 +13,9 @@ lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap index 6327131ec0..c270af683c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_class_after.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> lines_after_imports_class_after.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,11 +13,11 @@ lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ 10 | class Thing(object): 11 | name: str | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap index 8ae7c8f04a..e35b6f26bb 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_func_after.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> lines_after_imports_func_after.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,9 +13,9 @@ lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un- 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap index da09ee6218..a4c209169f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports.pyi.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> lines_after_imports.pyi:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,9 +13,9 @@ lines_after_imports.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap index 2a56708eba..e6081ac492 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> lines_after_imports_class_after.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,11 +13,11 @@ lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ 10 | class Thing(object): 11 | name: str | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap index b7764817d2..448c2eb7ee 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> lines_after_imports_func_after.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,9 +13,9 @@ lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un- 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap index 2765bd970c..ff9a5bfc0a 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -lines_after_imports_nothing_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> lines_after_imports_nothing_after.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,9 +13,9 @@ lines_after_imports_nothing_after.py:1:1: I001 [*] Import block is un-sorted or 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap index b76cee73ca..0cdda30e86 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -lines_between_types.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> lines_between_types.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -19,9 +20,9 @@ lines_between_types.py:1:1: I001 [*] Import block is un-sorted or un-formatted 14 | | 15 | | from . import config 16 | | from .data import Data - | |______________________^ I001 + | |______________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 9 9 | import requests diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap index f64501a356..1351db55e3 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> magic_trailing_comma.py:2:1 | 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line 2 | / from sys import ( @@ -41,9 +42,9 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted 36 | | from module2 import ( 37 | | member3, 38 | | ) - | |_^ I001 + | |_^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap index 950f0b4016..f8c50324e8 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -match_case.py:3:9: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> match_case.py:3:9 | 1 | match 1: 2 | case 1: 3 | / import sys 4 | | import os - | |_________________^ I001 + | |_________________^ 5 | case 2: 6 | import collections | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | match 1: @@ -23,15 +24,16 @@ match_case.py:3:9: I001 [*] Import block is un-sorted or un-formatted 6 6 | import collections 7 7 | import abc -match_case.py:6:9: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> match_case.py:6:9 | 4 | import os 5 | case 2: 6 | / import collections 7 | | import abc - | |__________________^ I001 + | |__________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 3 3 | import sys diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap index 219f80d8d4..3179e36560 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> natural_order.py:1:1 | 1 | / import numpy1 2 | | import numpy10 @@ -19,9 +20,9 @@ natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted 14 | | uint32, 15 | | uint64, 16 | | ) - | |_^ I001 + | |_^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import numpy1 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap index 679e8a9e8f..d23761ecb0 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> bar.py:1:1 | 1 | / import os 2 | | import pandas 3 | | import foo.baz - | |______________^ I001 + | |______________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap index 5f032e7590..49a20edc69 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> no_lines_before.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,9 +13,9 @@ no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap index 10a2a6f878..6edb96de08 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> no_lines_before.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,9 +13,9 @@ no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted 7 | | from my_first_party import my_first_party_object 8 | | 9 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap index 68559bec6f..ccd137ad41 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -no_lines_before_with_empty_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> no_lines_before_with_empty_sections.py:1:1 | 1 | / from __future__ import annotations 2 | | from typing import Any 3 | | from . import my_local_folder_object - | |____________________________________^ I001 + | |____________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap index b860573af3..2a6ae0bc0e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_standard_library_no_standard_library.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -no_standard_library.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> no_standard_library.py:1:1 | 1 | / from __future__ import annotations 2 | | @@ -12,9 +13,9 @@ no_standard_library.py:1:1: I001 [*] Import block is un-sorted or un-formatted 7 | | 8 | | from . import local 9 | | import sys - | |__________^ I001 + | |__________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap index 5442ac6b7d..2a77df40fd 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -no_wrap_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> no_wrap_star.py:1:1 | 1 | from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from .subscription import * # type: ignore # some very long comment explaining why this needs a type ignore diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap index 598956bdd6..5d90b0269b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_by_type.py:1:1 | 1 | / import StringIO 2 | | import glob @@ -15,9 +16,9 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted 10 | | import FOO 11 | | import BAR 12 | | import bar - | |__________^ I001 + | |__________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import StringIO diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap index dcbca8a0d1..c31710b90d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_by_type.py:1:1 | 1 | / import StringIO 2 | | import glob @@ -15,9 +16,9 @@ order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted 10 | | import FOO 11 | | import BAR 12 | | import bar - | |__________^ I001 + | |__________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import StringIO diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap index cb2a44f988..829c83cdd5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_by_type_with_custom_classes.py:1:1 | 1 | / from sklearn.svm import func, SVC, CONST, Klass 2 | | from subprocess import N_CLASS, PIPE, Popen, STDOUT 3 | | from module import CLASS, Class, CONSTANT, function, BASIC, Apple 4 | | from torch.nn import SELU, AClass, A_CONSTANT - | |_____________________________________________^ I001 + | |_____________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from sklearn.svm import func, SVC, CONST, Klass diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap index 94aeabb4ad..9c80994321 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_by_type_with_custom_classes.py:1:1 | 1 | / from sklearn.svm import func, SVC, CONST, Klass 2 | | from subprocess import N_CLASS, PIPE, Popen, STDOUT 3 | | from module import CLASS, Class, CONSTANT, function, BASIC, Apple 4 | | from torch.nn import SELU, AClass, A_CONSTANT - | |_____________________________________________^ I001 + | |_____________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from sklearn.svm import func, SVC, CONST, Klass diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap index b17298eedc..4af13473df 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_by_type_with_custom_constants.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_by_type_with_custom_constants.py:1:1 | 1 | / from sklearn.svm import XYZ, func, variable, Const, Klass, constant 2 | | from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT - | |_______________________________________________________________________________^ I001 + | |_______________________________________________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap index 4d696e30ae..12652cfccf 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_by_type_with_custom_constants.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_by_type_with_custom_constants.py:1:1 | 1 | / from sklearn.svm import XYZ, func, variable, Const, Klass, constant 2 | | from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT - | |_______________________________________________________________________________^ I001 + | |_______________________________________________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap index 82ed0e2cfe..9c479a19f4 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_by_type_with_custom_variables.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_by_type_with_custom_variables.py:1:1 | 1 | / from sklearn.svm import VAR, Class, MyVar, CONST, abc 2 | | from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe - | |_____________________________________________________________________^ I001 + | |_____________________________________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap index d60ac428d1..5ba8a2a85d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_by_type_with_custom_variables.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_by_type_with_custom_variables.py:1:1 | 1 | / from sklearn.svm import VAR, Class, MyVar, CONST, abc 2 | | from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe - | |_____________________________________________________________________^ I001 + | |_____________________________________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap index 78d9a2a789..81306b136c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -order_relative_imports_by_level.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> order_relative_imports_by_level.py:1:1 | 1 | / from .a import a 2 | | from ..a import a 3 | | from ..b import a 4 | | from .b import a - | |________________^ I001 + | |________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from .a import a diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap index 576c3cda04..0e7e1444ff 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> preserve_comment_order.py:1:1 | 1 | / import io 2 | | # Old MacDonald had a farm, @@ -14,9 +15,9 @@ preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatte 9 | | # EIEIO 10 | | from errno import EIO 11 | | import abc - | |__________^ I001 + | |__________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import abc diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap index 289ceba1ac..bed68a5be3 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> preserve_import_star.py:1:1 | 1 | / from some_other_module import some_class 2 | | from some_other_module import * @@ -9,9 +10,9 @@ preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted 4 | | from some_module import some_class # Aside 5 | | # Above 6 | | from some_module import * # Aside - | |_________________________^ I001 + | |_________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from some_other_module import some_class diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap index 2ecdea73ec..cf9fa130e1 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -preserve_indentation.py:2:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> preserve_indentation.py:2:5 | 1 | if True: 2 | / import sys 3 | | import os - | |_____________^ I001 + | |_____________^ 4 | else: 5 | import sys | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | if True: @@ -21,15 +22,16 @@ preserve_indentation.py:2:5: I001 [*] Import block is un-sorted or un-formatted 5 5 | import sys 6 6 | import os -preserve_indentation.py:5:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> preserve_indentation.py:5:5 | 3 | import os 4 | else: 5 | / import sys 6 | | import os - | |_____________^ I001 + | |_____________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | import sys diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap index 40eb90e51b..66ad3162d5 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -propagate_inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> propagate_inline_comments.py:1:1 | 1 | / from mypackage.subpackage import ( # long comment that seems to be a problem 2 | | a_long_variable_name_that_causes_problems, 3 | | items, 4 | | ) - | |_^ I001 + | |_^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from mypackage.subpackage import ( # long comment that seems to be a problem diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap index eb3789a4fc..a9b7d1db9d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -reorder_within_section.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> reorder_within_section.py:1:1 | 1 | / import sys 2 | | import os - | |_________^ I001 + | |_________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap index 6cb60ee453..dd3573040b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> comment.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 1 | #!/usr/bin/env python3 2 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap index f7ba64f556..b458a05db3 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> comments_and_newlines.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 2 2 | # A copyright notice could go here 3 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap index d42aa75e7c..5f66b71778 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> docstring.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 1 | """Hello, world!""" 2 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_followed_by_continuation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_followed_by_continuation.py.snap index 56afca4d3b..69109cf945 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_followed_by_continuation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_followed_by_continuation.py.snap @@ -1,7 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -docstring_followed_by_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> docstring_followed_by_continuation.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 1 | """Hello, world!"""\ 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap index 29dd093d4a..52a950f66e 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> docstring_with_continuation.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 |-"""Hello, world!"""; x = \ 1 |+"""Hello, world!"""; from __future__ import annotations; x = \ diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap index 2d76188cec..d9c7308b79 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> docstring_with_semicolon.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 |-"""Hello, world!"""; x = 1 1 |+"""Hello, world!"""; from __future__ import annotations; x = 1 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap index b8f83954fb..1a5c82902f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> existing_import.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 |+from __future__ import annotations 1 2 | from __future__ import generator_stop diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap index 794cf1641d..49f487f419 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> multiline_docstring.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 1 | """a 2 2 | b""" diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap index 4cf37432a7..ca65feda4d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> off.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 1 | # isort: off 2 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap index 4701571f2e..e99460f814 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_unused.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -unused.py:5:8: F401 [*] `sys` imported but unused +F401 [*] `sys` imported but unused + --> unused.py:5:8 | 4 | # Unused, _not_ marked as required. 5 | import sys - | ^^^ F401 + | ^^^ 6 | 7 | # Unused, _not_ marked as required (due to the alias). | - = help: Remove unused import: `sys` +help: Remove unused import: `sys` ℹ Safe fix 2 2 | import os @@ -20,15 +21,16 @@ unused.py:5:8: F401 [*] `sys` imported but unused 7 6 | # Unused, _not_ marked as required (due to the alias). 8 7 | import pathlib as non_alias -unused.py:8:19: F401 [*] `pathlib` imported but unused +F401 [*] `pathlib` imported but unused + --> unused.py:8:19 | 7 | # Unused, _not_ marked as required (due to the alias). 8 | import pathlib as non_alias - | ^^^^^^^^^ F401 + | ^^^^^^^^^ 9 | 10 | # Unused, marked as required. | - = help: Remove unused import: `pathlib` +help: Remove unused import: `pathlib` ℹ Safe fix 5 5 | import sys diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_whitespace.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_whitespace.py.snap index 2ba62fc470..08b3cfc7ba 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_whitespace.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_whitespace.py.snap @@ -1,7 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -whitespace.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> whitespace.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 1 | # This is a regression test for https://github.com/astral-sh/ruff/issues/19310 2 2 | # there is a (potentially invisible) unicode formfeed character (000C) between "docstring" and the semicolon diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap index e2fe2c526b..ae06367b92 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> comment.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 1 1 | #!/usr/bin/env python3 2 |+from __future__ import annotations as _annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap index 168812400c..c85b5c507c 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> comments_and_newlines.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 2 2 | # A copyright notice could go here 3 3 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap index 00eff57da5..e91df9de92 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> docstring.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 1 1 | """Hello, world!""" 2 |+from __future__ import annotations as _annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_followed_by_continuation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_followed_by_continuation.py.snap index bfce198bae..711989cbfe 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_followed_by_continuation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_followed_by_continuation.py.snap @@ -1,7 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -docstring_followed_by_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> docstring_followed_by_continuation.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 1 1 | """Hello, world!"""\ 2 2 | diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap index e68324b25f..b8a3e7f2cb 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> docstring_with_continuation.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 1 |-"""Hello, world!"""; x = \ 1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = \ diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap index f6ff025e7c..d1cc50e2a8 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> docstring_with_semicolon.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 1 |-"""Hello, world!"""; x = 1 1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = 1 diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap index 122d844256..95493b80a2 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> existing_import.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 1 |+from __future__ import annotations as _annotations 1 2 | from __future__ import generator_stop diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap index 8087f019db..fca4d8f8eb 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> multiline_docstring.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 1 1 | """a 2 2 | b""" diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap index 1a194ac0cf..60be80529b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` +I002 [*] Missing required import: `from __future__ import annotations as _annotations` +--> off.py:1:1 +help: Insert required import: `from __future__ import annotations as _annotations` + ℹ Safe fix 1 1 | # isort: off 2 |+from __future__ import annotations as _annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_useless_alias_this_this.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_useless_alias_this_this.py.snap index c59adb4f32..575e4c6553 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_useless_alias_this_this.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_useless_alias_this_this.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -this_this.py:1:8: PLC0414 Required import does not rename original package. +PLC0414 Required import does not rename original package. + --> this_this.py:1:8 | 1 | import this as this - | ^^^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^^^ | - = help: Change required import or disable rule. +help: Change required import or disable rule. diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_importfrom_with_useless_alias_this_this_from.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_importfrom_with_useless_alias_this_this_from.py.snap index 50dbb294d5..a4eb5e2aaf 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_importfrom_with_useless_alias_this_this_from.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_importfrom_with_useless_alias_this_this_from.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -this_this_from.py:1:20: PLC0414 Required import does not rename original package. +PLC0414 Required import does not rename original package. + --> this_this_from.py:1:20 | 1 | from module import this as this - | ^^^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^^^ | - = help: Change required import or disable rule. +help: Change required import or disable rule. diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap index 1ce65ad21f..8bf448df89 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap @@ -1,15 +1,20 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> docstring.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 1 | """Hello, world!""" 2 |+from __future__ import annotations 2 3 | 3 4 | x = 1 -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop` +I002 [*] Missing required import: `from __future__ import generator_stop` +--> docstring.py:1:1 +help: Insert required import: `from __future__ import generator_stop` + ℹ Safe fix 1 1 | """Hello, world!""" 2 |+from __future__ import generator_stop diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_multiple_strings.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_multiple_strings.py.snap index 9e74f5cb6c..4300626f5d 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_multiple_strings.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_multiple_strings.py.snap @@ -1,7 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -multiple_strings.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` +I002 [*] Missing required import: `from __future__ import annotations` +--> multiple_strings.py:1:1 +help: Insert required import: `from __future__ import annotations` + ℹ Safe fix 1 1 | """This is a docstring.""" 2 |+from __future__ import annotations @@ -9,7 +12,10 @@ multiple_strings.py:1:1: I002 [*] Missing required import: `from __future__ impo 3 4 | "This is also not a docstring." 4 5 | -multiple_strings.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop` +I002 [*] Missing required import: `from __future__ import generator_stop` +--> multiple_strings.py:1:1 +help: Insert required import: `from __future__ import generator_stop` + ℹ Safe fix 1 1 | """This is a docstring.""" 2 |+from __future__ import generator_stop diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap index 81ba140cce..5066d975ed 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> sections.py:1:1 | 1 | / from __future__ import annotations 2 | | import os @@ -10,9 +11,9 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted 5 | | import django.settings 6 | | from library import foo 7 | | from . import local - | |___________________^ I001 + | |___________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap index 2dee10681b..608a27d50f 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_main_first_party.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -main_first_party.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> main_first_party.py:1:1 | 1 | / import os 2 | | @@ -9,11 +10,11 @@ main_first_party.py:1:1: I001 [*] Import block is un-sorted or un-formatted 4 | | import third_party 5 | | 6 | | import first_party - | |__________________^ I001 + | |__________________^ 7 | 8 | os.a | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap index 3273e24cdb..09893b2c97 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> sections.py:1:1 | 1 | / from __future__ import annotations 2 | | import os @@ -10,9 +11,9 @@ sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted 5 | | import django.settings 6 | | from library import foo 7 | | from . import local - | |___________________^ I001 + | |___________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap index 65182f7e7e..66636e6f78 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_first_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_first_party_imports.py:1:1 | 1 | / import sys 2 | | import leading_prefix 3 | | import numpy as np 4 | | import os 5 | | from leading_prefix import Class - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap index 6efad32da6..3d3dc12260 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_future_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_future_imports.py:1:1 | 1 | / import sys 2 | | import os 3 | | from __future__ import annotations - | |__________________________________^ I001 + | |__________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import sys diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap index 7ce3c297a0..553ad555bb 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_local_folder_imports.py:1:1 | 1 | / import sys 2 | | import ruff @@ -10,9 +11,9 @@ separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-f 5 | | from . import leading_prefix 6 | | from .. import trailing_prefix 7 | | from ruff import check - | |______________________^ I001 + | |______________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap index 99559f6244..16428a3868 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -separate_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> separate_third_party_imports.py:1:1 | 1 | / import pandas as pd 2 | | import sys 3 | | import numpy as np 4 | | import os - | |_________^ I001 + | |_________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-import pandas as pd diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap index 0bc57eae37..6bf22e519b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -skip.py:20:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> skip.py:20:5 | 18 | import sys 19 | import os # isort: skip 20 | / import collections 21 | | import abc - | |______________^ I001 + | |______________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 17 17 | def f(): @@ -22,15 +23,16 @@ skip.py:20:5: I001 [*] Import block is un-sorted or un-formatted 23 23 | 24 24 | def f(): -skip.py:27:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> skip.py:27:5 | 25 | import sys 26 | import os # isort:skip 27 | / import collections 28 | | import abc - | |______________^ I001 + | |______________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 24 24 | def f(): @@ -43,14 +45,15 @@ skip.py:27:5: I001 [*] Import block is un-sorted or un-formatted 30 30 | 31 31 | def f(): -skip.py:34:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> skip.py:34:5 | 32 | import sys; import os # isort:skip 33 | import sys; import os # isort:skip # isort:skip 34 | import sys; import os - | ^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 31 31 | def f(): diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap index 016fa99f05..28ac2cbf46 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> sort_similar_imports.py:1:1 | 1 | / from a import b 2 | | from a import BAD as DEF @@ -29,9 +30,9 @@ sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted 24 | | import x as Y 25 | | import x 26 | | import x as a - | |_____________^ I001 + | |_____________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |-from a import b diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap index 5b1a0f8e17..ba458c1fea 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -split.py:15:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> split.py:15:5 | 14 | if True: 15 | / import C 16 | | import A - | |____________^ I001 + | |____________^ 17 | 18 | # isort: split | - = help: Organize imports +help: Organize imports ℹ Safe fix 12 12 | import b @@ -23,15 +24,16 @@ split.py:15:5: I001 [*] Import block is un-sorted or un-formatted 18 18 | # isort: split 19 19 | -split.py:20:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> split.py:20:5 | 18 | # isort: split 19 | 20 | / import D 21 | | import B - | |____________^ I001 + | |____________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 17 17 | @@ -44,15 +46,16 @@ split.py:20:5: I001 [*] Import block is un-sorted or un-formatted 23 23 | 24 24 | import e -split.py:30:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> split.py:30:1 | 28 | # isort: split 29 | 30 | / import d 31 | | import c - | |________^ I001 + | |________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 27 27 | # isort: split diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap index bb9cd3eb1e..e8504643c3 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> magic_trailing_comma.py:2:1 | 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line 2 | / from sys import ( @@ -41,9 +42,9 @@ magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted 36 | | from module2 import ( 37 | | member3, 38 | | ) - | |_^ I001 + | |_^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap index 0a1b4331c5..0b3da48c00 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -star_before_others.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> star_before_others.py:1:1 | 1 | / from .logging import config_logging 2 | | from .settings import ENV 3 | | from .settings import * - | |_______________________^ I001 + | |_______________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from .logging import config_logging diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap index a10a6cbfdc..3aa72a1317 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring.py:1:1: I002 [*] Missing required import: `import os` +I002 [*] Missing required import: `import os` +--> docstring.py:1:1 +help: Insert required import: `import os` + ℹ Safe fix 1 1 | """Hello, world!""" 2 |+import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap index 9b7f926158..90186c1c46 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap @@ -1,8 +1,10 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs -snapshot_kind: text --- -docstring.pyi:1:1: I002 [*] Missing required import: `import os` +I002 [*] Missing required import: `import os` +--> docstring.pyi:1:1 +help: Insert required import: `import os` + ℹ Safe fix 1 1 | """Hello, world!""" 2 |+import os diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap index 07f62b85f8..95ca30c37b 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_comment.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -trailing_comment.py:8:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> trailing_comment.py:8:1 | 6 | pass 7 | @@ -11,11 +12,11 @@ trailing_comment.py:8:1: I001 [*] Import block is un-sorted or un-formatted 11 | | ); from foo import ( 12 | | bar 13 | | )# some comment - | |_^ I001 + | |_^ 14 | 15 | pass | - = help: Organize imports +help: Organize imports ℹ Safe fix 5 5 | @@ -33,7 +34,8 @@ trailing_comment.py:8:1: I001 [*] Import block is un-sorted or un-formatted 15 14 | pass 16 15 | -trailing_comment.py:17:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> trailing_comment.py:17:1 | 15 | pass 16 | @@ -45,11 +47,11 @@ trailing_comment.py:17:1: I001 [*] Import block is un-sorted or un-formatted 22 | | MyMgmtClient, 23 | | # some comment 24 | | ) - | |_^ I001 + | |_^ 25 | 26 | pass | - = help: Organize imports +help: Organize imports ℹ Safe fix 14 14 | @@ -63,7 +65,8 @@ trailing_comment.py:17:1: I001 [*] Import block is un-sorted or un-formatted 21 19 | MyClient, 22 20 | MyMgmtClient, -trailing_comment.py:35:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> trailing_comment.py:35:1 | 33 | pass 34 | @@ -71,11 +74,11 @@ trailing_comment.py:35:1: I001 [*] Import block is un-sorted or un-formatted 36 | | MyClient 37 | | # some comment 38 | | ) - | |_^ I001 + | |_^ 39 | 40 | pass | - = help: Organize imports +help: Organize imports ℹ Safe fix 32 32 | @@ -90,7 +93,8 @@ trailing_comment.py:35:1: I001 [*] Import block is un-sorted or un-formatted 40 37 | pass 41 38 | -trailing_comment.py:42:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> trailing_comment.py:42:1 | 40 | pass 41 | @@ -98,11 +102,11 @@ trailing_comment.py:42:1: I001 [*] Import block is un-sorted or un-formatted 43 | | # some comment 44 | | MyClient 45 | | ) - | |_^ I001 + | |_^ 46 | 47 | pass | - = help: Organize imports +help: Organize imports ℹ Safe fix 39 39 | @@ -117,7 +121,8 @@ trailing_comment.py:42:1: I001 [*] Import block is un-sorted or un-formatted 47 44 | pass 48 45 | -trailing_comment.py:50:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> trailing_comment.py:50:1 | 49 | # a 50 | / from mylib import ( # b @@ -125,9 +130,9 @@ trailing_comment.py:50:1: I001 [*] Import block is un-sorted or un-formatted 52 | | MyClient # d 53 | | # e 54 | | ) # f - | |_^ I001 + | |_^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 47 47 | pass diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap index df26c70eb1..db440fdd49 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap @@ -1,21 +1,23 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -trailing_suffix.py:1:1: I001 Import block is un-sorted or un-formatted +I001 Import block is un-sorted or un-formatted + --> trailing_suffix.py:1:1 | 1 | / import sys 2 | | import os; x = 1 - | |_________^ I001 + | |_________^ 3 | 4 | if True: | - = help: Organize imports +help: Organize imports -trailing_suffix.py:5:5: I001 Import block is un-sorted or un-formatted +I001 Import block is un-sorted or un-formatted + --> trailing_suffix.py:5:5 | 4 | if True: 5 | / import sys 6 | | import os; x = 1 - | |_____________^ I001 + | |_____________^ | - = help: Organize imports +help: Organize imports diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap index 2e68e28eca..65d75ac606 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__two_space.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> two_space.py:2:1 | 1 | # If the file doesn't contain a logical indent token, we should still detect two-space indentation on imports. 2 | / from math import ( @@ -11,11 +12,11 @@ two_space.py:2:1: I001 [*] Import block is un-sorted or un-formatted 6 | | nan, 7 | | pi, 8 | | ) - | |_^ I001 + | |_^ 9 | 10 | del sin, cos, tan, pi, nan | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | # If the file doesn't contain a logical indent token, we should still detect two-space indentation on imports. diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap index e6b6c53fb9..1b90e6af08 100644 --- a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__unicode.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/isort/mod.rs --- -unicode.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> unicode.py:1:1 | 1 | / from astropy.constants import hbar as ℏ 2 | | from numpy import pi as π 3 | | import numpy as ℂℇℊℋℌℍℎℐℑℒℓℕℤΩℨKÅℬℭℯℰℱℹℴ 4 | | import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio - | |________________________________________^ I001 + | |________________________________________^ 5 | 6 | h = 2 * π * ℏ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import numpy as CƐgHHHhIILlNZΩZKÅBCeEFio diff --git a/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap index 5bce1a36f6..68e613e885 100644 --- a/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap +++ b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap @@ -1,198 +1,220 @@ --- source: crates/ruff_linter/src/rules/mccabe/mod.rs --- -C901.py:2:5: C901 `trivial` is too complex (1 > 0) +C901 `trivial` is too complex (1 > 0) + --> C901.py:2:5 | 1 | # Complexity = 1 2 | def trivial(): - | ^^^^^^^ C901 + | ^^^^^^^ 3 | pass | -C901.py:7:5: C901 `expr_as_statement` is too complex (1 > 0) +C901 `expr_as_statement` is too complex (1 > 0) + --> C901.py:7:5 | 6 | # Complexity = 1 7 | def expr_as_statement(): - | ^^^^^^^^^^^^^^^^^ C901 + | ^^^^^^^^^^^^^^^^^ 8 | 0xF00D | -C901.py:12:5: C901 `sequential` is too complex (1 > 0) +C901 `sequential` is too complex (1 > 0) + --> C901.py:12:5 | 11 | # Complexity = 1 12 | def sequential(n): - | ^^^^^^^^^^ C901 + | ^^^^^^^^^^ 13 | k = n + 4 14 | s = k + n | -C901.py:19:5: C901 `if_elif_else_dead_path` is too complex (3 > 0) +C901 `if_elif_else_dead_path` is too complex (3 > 0) + --> C901.py:19:5 | 18 | # Complexity = 3 19 | def if_elif_else_dead_path(n): - | ^^^^^^^^^^^^^^^^^^^^^^ C901 + | ^^^^^^^^^^^^^^^^^^^^^^ 20 | if n > 3: 21 | return "bigger than three" | -C901.py:29:5: C901 `nested_ifs` is too complex (3 > 0) +C901 `nested_ifs` is too complex (3 > 0) + --> C901.py:29:5 | 28 | # Complexity = 3 29 | def nested_ifs(): - | ^^^^^^^^^^ C901 + | ^^^^^^^^^^ 30 | if n > 3: 31 | if n > 4: | -C901.py:40:5: C901 `for_loop` is too complex (2 > 0) +C901 `for_loop` is too complex (2 > 0) + --> C901.py:40:5 | 39 | # Complexity = 2 40 | def for_loop(): - | ^^^^^^^^ C901 + | ^^^^^^^^ 41 | for i in range(10): 42 | print(i) | -C901.py:46:5: C901 `for_else` is too complex (2 > 0) +C901 `for_else` is too complex (2 > 0) + --> C901.py:46:5 | 45 | # Complexity = 2 46 | def for_else(mylist): - | ^^^^^^^^ C901 + | ^^^^^^^^ 47 | for i in mylist: 48 | print(i) | -C901.py:54:5: C901 `recursive` is too complex (2 > 0) +C901 `recursive` is too complex (2 > 0) + --> C901.py:54:5 | 53 | # Complexity = 2 54 | def recursive(n): - | ^^^^^^^^^ C901 + | ^^^^^^^^^ 55 | if n > 4: 56 | return f(n - 1) | -C901.py:62:5: C901 `nested_functions` is too complex (3 > 0) +C901 `nested_functions` is too complex (3 > 0) + --> C901.py:62:5 | 61 | # Complexity = 3 62 | def nested_functions(): - | ^^^^^^^^^^^^^^^^ C901 + | ^^^^^^^^^^^^^^^^ 63 | def a(): 64 | def b(): | -C901.py:63:9: C901 `a` is too complex (2 > 0) +C901 `a` is too complex (2 > 0) + --> C901.py:63:9 | 61 | # Complexity = 3 62 | def nested_functions(): 63 | def a(): - | ^ C901 + | ^ 64 | def b(): 65 | pass | -C901.py:64:13: C901 `b` is too complex (1 > 0) +C901 `b` is too complex (1 > 0) + --> C901.py:64:13 | 62 | def nested_functions(): 63 | def a(): 64 | def b(): - | ^ C901 + | ^ 65 | pass | -C901.py:73:5: C901 `try_else` is too complex (4 > 0) +C901 `try_else` is too complex (4 > 0) + --> C901.py:73:5 | 72 | # Complexity = 4 73 | def try_else(): - | ^^^^^^^^ C901 + | ^^^^^^^^ 74 | try: 75 | print(1) | -C901.py:85:5: C901 `nested_try_finally` is too complex (1 > 0) +C901 `nested_try_finally` is too complex (1 > 0) + --> C901.py:85:5 | 84 | # Complexity = 3 85 | def nested_try_finally(): - | ^^^^^^^^^^^^^^^^^^ C901 + | ^^^^^^^^^^^^^^^^^^ 86 | try: 87 | try: | -C901.py:96:11: C901 `foobar` is too complex (3 > 0) +C901 `foobar` is too complex (3 > 0) + --> C901.py:96:11 | 95 | # Complexity = 3 96 | async def foobar(a, b, c): - | ^^^^^^ C901 + | ^^^^^^ 97 | await whatever(a, b, c) 98 | if await b: | -C901.py:107:5: C901 `annotated_assign` is too complex (1 > 0) +C901 `annotated_assign` is too complex (1 > 0) + --> C901.py:107:5 | 106 | # Complexity = 1 107 | def annotated_assign(): - | ^^^^^^^^^^^^^^^^ C901 + | ^^^^^^^^^^^^^^^^ 108 | x: Any = None | -C901.py:113:9: C901 `handle` is too complex (9 > 0) +C901 `handle` is too complex (9 > 0) + --> C901.py:113:9 | 111 | # Complexity = 9 112 | class Class: 113 | def handle(self, *args, **options): - | ^^^^^^ C901 + | ^^^^^^ 114 | if args: 115 | return | -C901.py:118:17: C901 `a` is too complex (1 > 0) +C901 `a` is too complex (1 > 0) + --> C901.py:118:17 | 117 | class ServiceProvider: 118 | def a(self): - | ^ C901 + | ^ 119 | pass | -C901.py:121:17: C901 `b` is too complex (2 > 0) +C901 `b` is too complex (2 > 0) + --> C901.py:121:17 | 119 | pass 120 | 121 | def b(self, data): - | ^ C901 + | ^ 122 | if not args: 123 | pass | -C901.py:126:17: C901 `c` is too complex (1 > 0) +C901 `c` is too complex (1 > 0) + --> C901.py:126:17 | 125 | class Logger: 126 | def c(*args, **kwargs): - | ^ C901 + | ^ 127 | pass | -C901.py:129:17: C901 `error` is too complex (1 > 0) +C901 `error` is too complex (1 > 0) + --> C901.py:129:17 | 127 | pass 128 | 129 | def error(self, message): - | ^^^^^ C901 + | ^^^^^ 130 | pass | -C901.py:132:17: C901 `info` is too complex (1 > 0) +C901 `info` is too complex (1 > 0) + --> C901.py:132:17 | 130 | pass 131 | 132 | def info(self, message): - | ^^^^ C901 + | ^^^^ 133 | pass | -C901.py:135:17: C901 `exception` is too complex (1 > 0) +C901 `exception` is too complex (1 > 0) + --> C901.py:135:17 | 133 | pass 134 | 135 | def exception(self): - | ^^^^^^^^^ C901 + | ^^^^^^^^^ 136 | pass | diff --git a/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_3.snap b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_3.snap index 397ba316a1..663f2e5662 100644 --- a/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_3.snap +++ b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_3.snap @@ -1,22 +1,23 @@ --- source: crates/ruff_linter/src/rules/mccabe/mod.rs -snapshot_kind: text --- -C901.py:73:5: C901 `try_else` is too complex (4 > 3) +C901 `try_else` is too complex (4 > 3) + --> C901.py:73:5 | 72 | # Complexity = 4 73 | def try_else(): - | ^^^^^^^^ C901 + | ^^^^^^^^ 74 | try: 75 | print(1) | -C901.py:113:9: C901 `handle` is too complex (9 > 3) +C901 `handle` is too complex (9 > 3) + --> C901.py:113:9 | 111 | # Complexity = 9 112 | class Class: 113 | def handle(self, *args, **options): - | ^^^^^^ C901 + | ^^^^^^ 114 | if args: 115 | return | diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap index 879eb315a4..63f0ce2588 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs --- -NPY003.py:4:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead +NPY003 [*] `np.round_` is deprecated; use `np.round` instead + --> NPY003.py:4:5 | 2 | import numpy as np 3 | 4 | np.round_(np.random.rand(5, 5), 2) - | ^^^^^^^^^ NPY003 + | ^^^^^^^^^ 5 | np.product(np.random.rand(5, 5)) 6 | np.cumproduct(np.random.rand(5, 5)) | - = help: Replace with `np.round` +help: Replace with `np.round` ℹ Safe fix 1 1 | def func(): @@ -22,15 +23,16 @@ NPY003.py:4:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead 6 6 | np.cumproduct(np.random.rand(5, 5)) 7 7 | np.sometrue(np.random.rand(5, 5)) -NPY003.py:5:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead +NPY003 [*] `np.product` is deprecated; use `np.prod` instead + --> NPY003.py:5:5 | 4 | np.round_(np.random.rand(5, 5), 2) 5 | np.product(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 + | ^^^^^^^^^^ 6 | np.cumproduct(np.random.rand(5, 5)) 7 | np.sometrue(np.random.rand(5, 5)) | - = help: Replace with `np.prod` +help: Replace with `np.prod` ℹ Safe fix 2 2 | import numpy as np @@ -42,16 +44,17 @@ NPY003.py:5:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead 7 7 | np.sometrue(np.random.rand(5, 5)) 8 8 | np.alltrue(np.random.rand(5, 5)) -NPY003.py:6:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead +NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead + --> NPY003.py:6:5 | 4 | np.round_(np.random.rand(5, 5), 2) 5 | np.product(np.random.rand(5, 5)) 6 | np.cumproduct(np.random.rand(5, 5)) - | ^^^^^^^^^^^^^ NPY003 + | ^^^^^^^^^^^^^ 7 | np.sometrue(np.random.rand(5, 5)) 8 | np.alltrue(np.random.rand(5, 5)) | - = help: Replace with `np.cumprod` +help: Replace with `np.cumprod` ℹ Safe fix 3 3 | @@ -63,15 +66,16 @@ NPY003.py:6:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instea 8 8 | np.alltrue(np.random.rand(5, 5)) 9 9 | -NPY003.py:7:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead +NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead + --> NPY003.py:7:5 | 5 | np.product(np.random.rand(5, 5)) 6 | np.cumproduct(np.random.rand(5, 5)) 7 | np.sometrue(np.random.rand(5, 5)) - | ^^^^^^^^^^^ NPY003 + | ^^^^^^^^^^^ 8 | np.alltrue(np.random.rand(5, 5)) | - = help: Replace with `np.any` +help: Replace with `np.any` ℹ Safe fix 4 4 | np.round_(np.random.rand(5, 5), 2) @@ -83,14 +87,15 @@ NPY003.py:7:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead 9 9 | 10 10 | -NPY003.py:8:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead +NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead + --> NPY003.py:8:5 | 6 | np.cumproduct(np.random.rand(5, 5)) 7 | np.sometrue(np.random.rand(5, 5)) 8 | np.alltrue(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 + | ^^^^^^^^^^ | - = help: Replace with `np.all` +help: Replace with `np.all` ℹ Safe fix 5 5 | np.product(np.random.rand(5, 5)) @@ -102,16 +107,17 @@ NPY003.py:8:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead 10 10 | 11 11 | def func(): -NPY003.py:14:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead +NPY003 [*] `np.round_` is deprecated; use `np.round` instead + --> NPY003.py:14:5 | 12 | from numpy import round_, product, cumproduct, sometrue, alltrue 13 | 14 | round_(np.random.rand(5, 5), 2) - | ^^^^^^ NPY003 + | ^^^^^^ 15 | product(np.random.rand(5, 5)) 16 | cumproduct(np.random.rand(5, 5)) | - = help: Replace with `np.round` +help: Replace with `np.round` ℹ Safe fix 1 |+from numpy import round @@ -128,15 +134,16 @@ NPY003.py:14:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead 16 17 | cumproduct(np.random.rand(5, 5)) 17 18 | sometrue(np.random.rand(5, 5)) -NPY003.py:15:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead +NPY003 [*] `np.product` is deprecated; use `np.prod` instead + --> NPY003.py:15:5 | 14 | round_(np.random.rand(5, 5), 2) 15 | product(np.random.rand(5, 5)) - | ^^^^^^^ NPY003 + | ^^^^^^^ 16 | cumproduct(np.random.rand(5, 5)) 17 | sometrue(np.random.rand(5, 5)) | - = help: Replace with `np.prod` +help: Replace with `np.prod` ℹ Safe fix 1 |+from numpy import prod @@ -153,16 +160,17 @@ NPY003.py:15:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead 17 18 | sometrue(np.random.rand(5, 5)) 18 19 | alltrue(np.random.rand(5, 5)) -NPY003.py:16:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead +NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead + --> NPY003.py:16:5 | 14 | round_(np.random.rand(5, 5), 2) 15 | product(np.random.rand(5, 5)) 16 | cumproduct(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 + | ^^^^^^^^^^ 17 | sometrue(np.random.rand(5, 5)) 18 | alltrue(np.random.rand(5, 5)) | - = help: Replace with `np.cumprod` +help: Replace with `np.cumprod` ℹ Safe fix 1 |+from numpy import cumprod @@ -178,15 +186,16 @@ NPY003.py:16:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` inste 17 18 | sometrue(np.random.rand(5, 5)) 18 19 | alltrue(np.random.rand(5, 5)) -NPY003.py:17:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead +NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead + --> NPY003.py:17:5 | 15 | product(np.random.rand(5, 5)) 16 | cumproduct(np.random.rand(5, 5)) 17 | sometrue(np.random.rand(5, 5)) - | ^^^^^^^^ NPY003 + | ^^^^^^^^ 18 | alltrue(np.random.rand(5, 5)) | - = help: Replace with `np.any` +help: Replace with `np.any` ℹ Safe fix 1 |+from numpy import any @@ -201,14 +210,15 @@ NPY003.py:17:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead 18 |+ any(np.random.rand(5, 5)) 18 19 | alltrue(np.random.rand(5, 5)) -NPY003.py:18:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead +NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead + --> NPY003.py:18:5 | 16 | cumproduct(np.random.rand(5, 5)) 17 | sometrue(np.random.rand(5, 5)) 18 | alltrue(np.random.rand(5, 5)) - | ^^^^^^^ NPY003 + | ^^^^^^^ | - = help: Replace with `np.all` +help: Replace with `np.all` ℹ Safe fix 1 |+from numpy import all diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap index b26f49ebd0..55f95252ae 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs --- -NPY001.py:6:1: NPY001 [*] Type alias `np.float` is deprecated, replace with builtin type +NPY001 [*] Type alias `np.float` is deprecated, replace with builtin type + --> NPY001.py:6:1 | 5 | # Error 6 | npy.float - | ^^^^^^^^^ NPY001 + | ^^^^^^^^^ 7 | npy.int | - = help: Replace `np.float` with builtin type +help: Replace `np.float` with builtin type ℹ Safe fix 3 3 | import numpy @@ -20,16 +21,17 @@ NPY001.py:6:1: NPY001 [*] Type alias `np.float` is deprecated, replace with buil 8 8 | 9 9 | if dtype == np.object: -NPY001.py:7:1: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type +NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type + --> NPY001.py:7:1 | 5 | # Error 6 | npy.float 7 | npy.int - | ^^^^^^^ NPY001 + | ^^^^^^^ 8 | 9 | if dtype == np.object: | - = help: Replace `np.int` with builtin type +help: Replace `np.int` with builtin type ℹ Safe fix 4 4 | @@ -41,15 +43,16 @@ NPY001.py:7:1: NPY001 [*] Type alias `np.int` is deprecated, replace with builti 9 9 | if dtype == np.object: 10 10 | ... -NPY001.py:9:13: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type +NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type + --> NPY001.py:9:13 | 7 | npy.int 8 | 9 | if dtype == np.object: - | ^^^^^^^^^ NPY001 + | ^^^^^^^^^ 10 | ... | - = help: Replace `np.object` with builtin type +help: Replace `np.object` with builtin type ℹ Safe fix 6 6 | npy.float @@ -61,16 +64,17 @@ NPY001.py:9:13: NPY001 [*] Type alias `np.object` is deprecated, replace with bu 11 11 | 12 12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex]) -NPY001.py:12:72: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type +NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type + --> NPY001.py:12:72 | 10 | ... 11 | 12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex]) - | ^^^^^^ NPY001 + | ^^^^^^ 13 | 14 | pdf = pd.DataFrame( | - = help: Replace `np.int` with builtin type +help: Replace `np.int` with builtin type ℹ Safe fix 9 9 | if dtype == np.object: @@ -82,16 +86,17 @@ NPY001.py:12:72: NPY001 [*] Type alias `np.int` is deprecated, replace with buil 14 14 | pdf = pd.DataFrame( 15 15 | data=[[1, 2, 3]], -NPY001.py:12:80: NPY001 [*] Type alias `np.complex` is deprecated, replace with builtin type +NPY001 [*] Type alias `np.complex` is deprecated, replace with builtin type + --> NPY001.py:12:80 | 10 | ... 11 | 12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex]) - | ^^^^^^^^^^ NPY001 + | ^^^^^^^^^^ 13 | 14 | pdf = pd.DataFrame( | - = help: Replace `np.complex` with builtin type +help: Replace `np.complex` with builtin type ℹ Safe fix 9 9 | if dtype == np.object: @@ -103,15 +108,16 @@ NPY001.py:12:80: NPY001 [*] Type alias `np.complex` is deprecated, replace with 14 14 | pdf = pd.DataFrame( 15 15 | data=[[1, 2, 3]], -NPY001.py:17:11: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type +NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type + --> NPY001.py:17:11 | 15 | data=[[1, 2, 3]], 16 | columns=["a", "b", "c"], 17 | dtype=numpy.object, - | ^^^^^^^^^^^^ NPY001 + | ^^^^^^^^^^^^ 18 | ) | - = help: Replace `np.object` with builtin type +help: Replace `np.object` with builtin type ℹ Safe fix 14 14 | pdf = pd.DataFrame( @@ -123,16 +129,17 @@ NPY001.py:17:11: NPY001 [*] Type alias `np.object` is deprecated, replace with b 19 19 | 20 20 | _ = arr.astype(np.int) -NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type +NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type + --> NPY001.py:20:16 | 18 | ) 19 | 20 | _ = arr.astype(np.int) - | ^^^^^^ NPY001 + | ^^^^^^ 21 | 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 | - = help: Replace `np.int` with builtin type +help: Replace `np.int` with builtin type ℹ Safe fix 17 17 | dtype=numpy.object, @@ -144,14 +151,15 @@ NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with buil 22 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 23 23 | from numpy import float -NPY001.py:25:1: NPY001 [*] Type alias `np.float` is deprecated, replace with builtin type +NPY001 [*] Type alias `np.float` is deprecated, replace with builtin type + --> NPY001.py:25:1 | 23 | from numpy import float 24 | 25 | float(1) - | ^^^^^ NPY001 + | ^^^^^ | - = help: Replace `np.float` with builtin type +help: Replace `np.float` with builtin type ℹ Safe fix 21 21 | diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap index 150b3490be..8a0bf558f0 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap @@ -1,516 +1,568 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs --- -NPY002.py:12:8: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` +NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` + --> NPY002.py:12:8 | 10 | from numpy import random 11 | 12 | vals = random.standard_normal(10) - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 13 | more_vals = random.standard_normal(10) 14 | numbers = random.integers(high, size=5) | -NPY002.py:13:13: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` +NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` + --> NPY002.py:13:13 | 12 | vals = random.standard_normal(10) 13 | more_vals = random.standard_normal(10) - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 14 | numbers = random.integers(high, size=5) | -NPY002.py:18:1: NPY002 Replace legacy `np.random.seed` call with `np.random.Generator` +NPY002 Replace legacy `np.random.seed` call with `np.random.Generator` + --> NPY002.py:18:1 | 16 | import numpy 17 | 18 | numpy.random.seed() - | ^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^ 19 | numpy.random.get_state() 20 | numpy.random.set_state() | -NPY002.py:19:1: NPY002 Replace legacy `np.random.get_state` call with `np.random.Generator` +NPY002 Replace legacy `np.random.get_state` call with `np.random.Generator` + --> NPY002.py:19:1 | 18 | numpy.random.seed() 19 | numpy.random.get_state() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 20 | numpy.random.set_state() 21 | numpy.random.rand() | -NPY002.py:20:1: NPY002 Replace legacy `np.random.set_state` call with `np.random.Generator` +NPY002 Replace legacy `np.random.set_state` call with `np.random.Generator` + --> NPY002.py:20:1 | 18 | numpy.random.seed() 19 | numpy.random.get_state() 20 | numpy.random.set_state() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 21 | numpy.random.rand() 22 | numpy.random.ranf() | -NPY002.py:21:1: NPY002 Replace legacy `np.random.rand` call with `np.random.Generator` +NPY002 Replace legacy `np.random.rand` call with `np.random.Generator` + --> NPY002.py:21:1 | 19 | numpy.random.get_state() 20 | numpy.random.set_state() 21 | numpy.random.rand() - | ^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^ 22 | numpy.random.ranf() 23 | numpy.random.sample() | -NPY002.py:22:1: NPY002 Replace legacy `np.random.ranf` call with `np.random.Generator` +NPY002 Replace legacy `np.random.ranf` call with `np.random.Generator` + --> NPY002.py:22:1 | 20 | numpy.random.set_state() 21 | numpy.random.rand() 22 | numpy.random.ranf() - | ^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^ 23 | numpy.random.sample() 24 | numpy.random.randn() | -NPY002.py:23:1: NPY002 Replace legacy `np.random.sample` call with `np.random.Generator` +NPY002 Replace legacy `np.random.sample` call with `np.random.Generator` + --> NPY002.py:23:1 | 21 | numpy.random.rand() 22 | numpy.random.ranf() 23 | numpy.random.sample() - | ^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^ 24 | numpy.random.randn() 25 | numpy.random.randint() | -NPY002.py:24:1: NPY002 Replace legacy `np.random.randn` call with `np.random.Generator` +NPY002 Replace legacy `np.random.randn` call with `np.random.Generator` + --> NPY002.py:24:1 | 22 | numpy.random.ranf() 23 | numpy.random.sample() 24 | numpy.random.randn() - | ^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^ 25 | numpy.random.randint() 26 | numpy.random.random() | -NPY002.py:25:1: NPY002 Replace legacy `np.random.randint` call with `np.random.Generator` +NPY002 Replace legacy `np.random.randint` call with `np.random.Generator` + --> NPY002.py:25:1 | 23 | numpy.random.sample() 24 | numpy.random.randn() 25 | numpy.random.randint() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^ 26 | numpy.random.random() 27 | numpy.random.random_integers() | -NPY002.py:26:1: NPY002 Replace legacy `np.random.random` call with `np.random.Generator` +NPY002 Replace legacy `np.random.random` call with `np.random.Generator` + --> NPY002.py:26:1 | 24 | numpy.random.randn() 25 | numpy.random.randint() 26 | numpy.random.random() - | ^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^ 27 | numpy.random.random_integers() 28 | numpy.random.random_sample() | -NPY002.py:27:1: NPY002 Replace legacy `np.random.random_integers` call with `np.random.Generator` +NPY002 Replace legacy `np.random.random_integers` call with `np.random.Generator` + --> NPY002.py:27:1 | 25 | numpy.random.randint() 26 | numpy.random.random() 27 | numpy.random.random_integers() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | numpy.random.random_sample() 29 | numpy.random.choice() | -NPY002.py:28:1: NPY002 Replace legacy `np.random.random_sample` call with `np.random.Generator` +NPY002 Replace legacy `np.random.random_sample` call with `np.random.Generator` + --> NPY002.py:28:1 | 26 | numpy.random.random() 27 | numpy.random.random_integers() 28 | numpy.random.random_sample() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | numpy.random.choice() 30 | numpy.random.bytes() | -NPY002.py:29:1: NPY002 Replace legacy `np.random.choice` call with `np.random.Generator` +NPY002 Replace legacy `np.random.choice` call with `np.random.Generator` + --> NPY002.py:29:1 | 27 | numpy.random.random_integers() 28 | numpy.random.random_sample() 29 | numpy.random.choice() - | ^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^ 30 | numpy.random.bytes() 31 | numpy.random.shuffle() | -NPY002.py:30:1: NPY002 Replace legacy `np.random.bytes` call with `np.random.Generator` +NPY002 Replace legacy `np.random.bytes` call with `np.random.Generator` + --> NPY002.py:30:1 | 28 | numpy.random.random_sample() 29 | numpy.random.choice() 30 | numpy.random.bytes() - | ^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^ 31 | numpy.random.shuffle() 32 | numpy.random.permutation() | -NPY002.py:31:1: NPY002 Replace legacy `np.random.shuffle` call with `np.random.Generator` +NPY002 Replace legacy `np.random.shuffle` call with `np.random.Generator` + --> NPY002.py:31:1 | 29 | numpy.random.choice() 30 | numpy.random.bytes() 31 | numpy.random.shuffle() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^ 32 | numpy.random.permutation() 33 | numpy.random.beta() | -NPY002.py:32:1: NPY002 Replace legacy `np.random.permutation` call with `np.random.Generator` +NPY002 Replace legacy `np.random.permutation` call with `np.random.Generator` + --> NPY002.py:32:1 | 30 | numpy.random.bytes() 31 | numpy.random.shuffle() 32 | numpy.random.permutation() - | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 33 | numpy.random.beta() 34 | numpy.random.binomial() | -NPY002.py:33:1: NPY002 Replace legacy `np.random.beta` call with `np.random.Generator` +NPY002 Replace legacy `np.random.beta` call with `np.random.Generator` + --> NPY002.py:33:1 | 31 | numpy.random.shuffle() 32 | numpy.random.permutation() 33 | numpy.random.beta() - | ^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^ 34 | numpy.random.binomial() 35 | numpy.random.chisquare() | -NPY002.py:34:1: NPY002 Replace legacy `np.random.binomial` call with `np.random.Generator` +NPY002 Replace legacy `np.random.binomial` call with `np.random.Generator` + --> NPY002.py:34:1 | 32 | numpy.random.permutation() 33 | numpy.random.beta() 34 | numpy.random.binomial() - | ^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^ 35 | numpy.random.chisquare() 36 | numpy.random.dirichlet() | -NPY002.py:35:1: NPY002 Replace legacy `np.random.chisquare` call with `np.random.Generator` +NPY002 Replace legacy `np.random.chisquare` call with `np.random.Generator` + --> NPY002.py:35:1 | 33 | numpy.random.beta() 34 | numpy.random.binomial() 35 | numpy.random.chisquare() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 36 | numpy.random.dirichlet() 37 | numpy.random.exponential() | -NPY002.py:36:1: NPY002 Replace legacy `np.random.dirichlet` call with `np.random.Generator` +NPY002 Replace legacy `np.random.dirichlet` call with `np.random.Generator` + --> NPY002.py:36:1 | 34 | numpy.random.binomial() 35 | numpy.random.chisquare() 36 | numpy.random.dirichlet() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 37 | numpy.random.exponential() 38 | numpy.random.f() | -NPY002.py:37:1: NPY002 Replace legacy `np.random.exponential` call with `np.random.Generator` +NPY002 Replace legacy `np.random.exponential` call with `np.random.Generator` + --> NPY002.py:37:1 | 35 | numpy.random.chisquare() 36 | numpy.random.dirichlet() 37 | numpy.random.exponential() - | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 38 | numpy.random.f() 39 | numpy.random.gamma() | -NPY002.py:38:1: NPY002 Replace legacy `np.random.f` call with `np.random.Generator` +NPY002 Replace legacy `np.random.f` call with `np.random.Generator` + --> NPY002.py:38:1 | 36 | numpy.random.dirichlet() 37 | numpy.random.exponential() 38 | numpy.random.f() - | ^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^ 39 | numpy.random.gamma() 40 | numpy.random.geometric() | -NPY002.py:39:1: NPY002 Replace legacy `np.random.gamma` call with `np.random.Generator` +NPY002 Replace legacy `np.random.gamma` call with `np.random.Generator` + --> NPY002.py:39:1 | 37 | numpy.random.exponential() 38 | numpy.random.f() 39 | numpy.random.gamma() - | ^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^ 40 | numpy.random.geometric() 41 | numpy.random.gumbel() | -NPY002.py:40:1: NPY002 Replace legacy `np.random.geometric` call with `np.random.Generator` +NPY002 Replace legacy `np.random.geometric` call with `np.random.Generator` + --> NPY002.py:40:1 | 38 | numpy.random.f() 39 | numpy.random.gamma() 40 | numpy.random.geometric() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 41 | numpy.random.gumbel() 42 | numpy.random.hypergeometric() | -NPY002.py:41:1: NPY002 Replace legacy `np.random.gumbel` call with `np.random.Generator` +NPY002 Replace legacy `np.random.gumbel` call with `np.random.Generator` + --> NPY002.py:41:1 | 39 | numpy.random.gamma() 40 | numpy.random.geometric() 41 | numpy.random.gumbel() - | ^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^ 42 | numpy.random.hypergeometric() 43 | numpy.random.laplace() | -NPY002.py:42:1: NPY002 Replace legacy `np.random.hypergeometric` call with `np.random.Generator` +NPY002 Replace legacy `np.random.hypergeometric` call with `np.random.Generator` + --> NPY002.py:42:1 | 40 | numpy.random.geometric() 41 | numpy.random.gumbel() 42 | numpy.random.hypergeometric() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | numpy.random.laplace() 44 | numpy.random.logistic() | -NPY002.py:43:1: NPY002 Replace legacy `np.random.laplace` call with `np.random.Generator` +NPY002 Replace legacy `np.random.laplace` call with `np.random.Generator` + --> NPY002.py:43:1 | 41 | numpy.random.gumbel() 42 | numpy.random.hypergeometric() 43 | numpy.random.laplace() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^ 44 | numpy.random.logistic() 45 | numpy.random.lognormal() | -NPY002.py:44:1: NPY002 Replace legacy `np.random.logistic` call with `np.random.Generator` +NPY002 Replace legacy `np.random.logistic` call with `np.random.Generator` + --> NPY002.py:44:1 | 42 | numpy.random.hypergeometric() 43 | numpy.random.laplace() 44 | numpy.random.logistic() - | ^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^ 45 | numpy.random.lognormal() 46 | numpy.random.logseries() | -NPY002.py:45:1: NPY002 Replace legacy `np.random.lognormal` call with `np.random.Generator` +NPY002 Replace legacy `np.random.lognormal` call with `np.random.Generator` + --> NPY002.py:45:1 | 43 | numpy.random.laplace() 44 | numpy.random.logistic() 45 | numpy.random.lognormal() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 46 | numpy.random.logseries() 47 | numpy.random.multinomial() | -NPY002.py:46:1: NPY002 Replace legacy `np.random.logseries` call with `np.random.Generator` +NPY002 Replace legacy `np.random.logseries` call with `np.random.Generator` + --> NPY002.py:46:1 | 44 | numpy.random.logistic() 45 | numpy.random.lognormal() 46 | numpy.random.logseries() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^ 47 | numpy.random.multinomial() 48 | numpy.random.multivariate_normal() | -NPY002.py:47:1: NPY002 Replace legacy `np.random.multinomial` call with `np.random.Generator` +NPY002 Replace legacy `np.random.multinomial` call with `np.random.Generator` + --> NPY002.py:47:1 | 45 | numpy.random.lognormal() 46 | numpy.random.logseries() 47 | numpy.random.multinomial() - | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 48 | numpy.random.multivariate_normal() 49 | numpy.random.negative_binomial() | -NPY002.py:48:1: NPY002 Replace legacy `np.random.multivariate_normal` call with `np.random.Generator` +NPY002 Replace legacy `np.random.multivariate_normal` call with `np.random.Generator` + --> NPY002.py:48:1 | 46 | numpy.random.logseries() 47 | numpy.random.multinomial() 48 | numpy.random.multivariate_normal() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 49 | numpy.random.negative_binomial() 50 | numpy.random.noncentral_chisquare() | -NPY002.py:49:1: NPY002 Replace legacy `np.random.negative_binomial` call with `np.random.Generator` +NPY002 Replace legacy `np.random.negative_binomial` call with `np.random.Generator` + --> NPY002.py:49:1 | 47 | numpy.random.multinomial() 48 | numpy.random.multivariate_normal() 49 | numpy.random.negative_binomial() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | numpy.random.noncentral_chisquare() 51 | numpy.random.noncentral_f() | -NPY002.py:50:1: NPY002 Replace legacy `np.random.noncentral_chisquare` call with `np.random.Generator` +NPY002 Replace legacy `np.random.noncentral_chisquare` call with `np.random.Generator` + --> NPY002.py:50:1 | 48 | numpy.random.multivariate_normal() 49 | numpy.random.negative_binomial() 50 | numpy.random.noncentral_chisquare() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 51 | numpy.random.noncentral_f() 52 | numpy.random.normal() | -NPY002.py:51:1: NPY002 Replace legacy `np.random.noncentral_f` call with `np.random.Generator` +NPY002 Replace legacy `np.random.noncentral_f` call with `np.random.Generator` + --> NPY002.py:51:1 | 49 | numpy.random.negative_binomial() 50 | numpy.random.noncentral_chisquare() 51 | numpy.random.noncentral_f() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | numpy.random.normal() 53 | numpy.random.pareto() | -NPY002.py:52:1: NPY002 Replace legacy `np.random.normal` call with `np.random.Generator` +NPY002 Replace legacy `np.random.normal` call with `np.random.Generator` + --> NPY002.py:52:1 | 50 | numpy.random.noncentral_chisquare() 51 | numpy.random.noncentral_f() 52 | numpy.random.normal() - | ^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^ 53 | numpy.random.pareto() 54 | numpy.random.poisson() | -NPY002.py:53:1: NPY002 Replace legacy `np.random.pareto` call with `np.random.Generator` +NPY002 Replace legacy `np.random.pareto` call with `np.random.Generator` + --> NPY002.py:53:1 | 51 | numpy.random.noncentral_f() 52 | numpy.random.normal() 53 | numpy.random.pareto() - | ^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^ 54 | numpy.random.poisson() 55 | numpy.random.power() | -NPY002.py:54:1: NPY002 Replace legacy `np.random.poisson` call with `np.random.Generator` +NPY002 Replace legacy `np.random.poisson` call with `np.random.Generator` + --> NPY002.py:54:1 | 52 | numpy.random.normal() 53 | numpy.random.pareto() 54 | numpy.random.poisson() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^ 55 | numpy.random.power() 56 | numpy.random.rayleigh() | -NPY002.py:55:1: NPY002 Replace legacy `np.random.power` call with `np.random.Generator` +NPY002 Replace legacy `np.random.power` call with `np.random.Generator` + --> NPY002.py:55:1 | 53 | numpy.random.pareto() 54 | numpy.random.poisson() 55 | numpy.random.power() - | ^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^ 56 | numpy.random.rayleigh() 57 | numpy.random.standard_cauchy() | -NPY002.py:56:1: NPY002 Replace legacy `np.random.rayleigh` call with `np.random.Generator` +NPY002 Replace legacy `np.random.rayleigh` call with `np.random.Generator` + --> NPY002.py:56:1 | 54 | numpy.random.poisson() 55 | numpy.random.power() 56 | numpy.random.rayleigh() - | ^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^ 57 | numpy.random.standard_cauchy() 58 | numpy.random.standard_exponential() | -NPY002.py:57:1: NPY002 Replace legacy `np.random.standard_cauchy` call with `np.random.Generator` +NPY002 Replace legacy `np.random.standard_cauchy` call with `np.random.Generator` + --> NPY002.py:57:1 | 55 | numpy.random.power() 56 | numpy.random.rayleigh() 57 | numpy.random.standard_cauchy() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 58 | numpy.random.standard_exponential() 59 | numpy.random.standard_gamma() | -NPY002.py:58:1: NPY002 Replace legacy `np.random.standard_exponential` call with `np.random.Generator` +NPY002 Replace legacy `np.random.standard_exponential` call with `np.random.Generator` + --> NPY002.py:58:1 | 56 | numpy.random.rayleigh() 57 | numpy.random.standard_cauchy() 58 | numpy.random.standard_exponential() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 59 | numpy.random.standard_gamma() 60 | numpy.random.standard_normal() | -NPY002.py:59:1: NPY002 Replace legacy `np.random.standard_gamma` call with `np.random.Generator` +NPY002 Replace legacy `np.random.standard_gamma` call with `np.random.Generator` + --> NPY002.py:59:1 | 57 | numpy.random.standard_cauchy() 58 | numpy.random.standard_exponential() 59 | numpy.random.standard_gamma() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | numpy.random.standard_normal() 61 | numpy.random.standard_t() | -NPY002.py:60:1: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` +NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` + --> NPY002.py:60:1 | 58 | numpy.random.standard_exponential() 59 | numpy.random.standard_gamma() 60 | numpy.random.standard_normal() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | numpy.random.standard_t() 62 | numpy.random.triangular() | -NPY002.py:61:1: NPY002 Replace legacy `np.random.standard_t` call with `np.random.Generator` +NPY002 Replace legacy `np.random.standard_t` call with `np.random.Generator` + --> NPY002.py:61:1 | 59 | numpy.random.standard_gamma() 60 | numpy.random.standard_normal() 61 | numpy.random.standard_t() - | ^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^ 62 | numpy.random.triangular() 63 | numpy.random.uniform() | -NPY002.py:62:1: NPY002 Replace legacy `np.random.triangular` call with `np.random.Generator` +NPY002 Replace legacy `np.random.triangular` call with `np.random.Generator` + --> NPY002.py:62:1 | 60 | numpy.random.standard_normal() 61 | numpy.random.standard_t() 62 | numpy.random.triangular() - | ^^^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^^^ 63 | numpy.random.uniform() 64 | numpy.random.vonmises() | -NPY002.py:63:1: NPY002 Replace legacy `np.random.uniform` call with `np.random.Generator` +NPY002 Replace legacy `np.random.uniform` call with `np.random.Generator` + --> NPY002.py:63:1 | 61 | numpy.random.standard_t() 62 | numpy.random.triangular() 63 | numpy.random.uniform() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^ 64 | numpy.random.vonmises() 65 | numpy.random.wald() | -NPY002.py:64:1: NPY002 Replace legacy `np.random.vonmises` call with `np.random.Generator` +NPY002 Replace legacy `np.random.vonmises` call with `np.random.Generator` + --> NPY002.py:64:1 | 62 | numpy.random.triangular() 63 | numpy.random.uniform() 64 | numpy.random.vonmises() - | ^^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^^ 65 | numpy.random.wald() 66 | numpy.random.weibull() | -NPY002.py:65:1: NPY002 Replace legacy `np.random.wald` call with `np.random.Generator` +NPY002 Replace legacy `np.random.wald` call with `np.random.Generator` + --> NPY002.py:65:1 | 63 | numpy.random.uniform() 64 | numpy.random.vonmises() 65 | numpy.random.wald() - | ^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^ 66 | numpy.random.weibull() 67 | numpy.random.zipf() | -NPY002.py:66:1: NPY002 Replace legacy `np.random.weibull` call with `np.random.Generator` +NPY002 Replace legacy `np.random.weibull` call with `np.random.Generator` + --> NPY002.py:66:1 | 64 | numpy.random.vonmises() 65 | numpy.random.wald() 66 | numpy.random.weibull() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^^^^ 67 | numpy.random.zipf() | -NPY002.py:67:1: NPY002 Replace legacy `np.random.zipf` call with `np.random.Generator` +NPY002 Replace legacy `np.random.zipf` call with `np.random.Generator` + --> NPY002.py:67:1 | 65 | numpy.random.wald() 66 | numpy.random.weibull() 67 | numpy.random.zipf() - | ^^^^^^^^^^^^^^^^^ NPY002 + | ^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap index 124a069953..966168f605 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs --- -NPY201.py:4:5: NPY201 [*] `np.add_docstring` will be removed in NumPy 2.0. Use `numpy.lib.add_docstring` instead. +NPY201 [*] `np.add_docstring` will be removed in NumPy 2.0. Use `numpy.lib.add_docstring` instead. + --> NPY201.py:4:5 | 2 | import numpy as np 3 | 4 | np.add_docstring - | ^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^ 5 | 6 | np.add_newdoc | - = help: Replace with `numpy.lib.add_docstring` +help: Replace with `numpy.lib.add_docstring` ℹ Safe fix 1 |+from numpy.lib import add_docstring @@ -23,16 +24,17 @@ NPY201.py:4:5: NPY201 [*] `np.add_docstring` will be removed in NumPy 2.0. Use ` 6 7 | np.add_newdoc 7 8 | -NPY201.py:6:5: NPY201 [*] `np.add_newdoc` will be removed in NumPy 2.0. Use `numpy.lib.add_newdoc` instead. +NPY201 [*] `np.add_newdoc` will be removed in NumPy 2.0. Use `numpy.lib.add_newdoc` instead. + --> NPY201.py:6:5 | 4 | np.add_docstring 5 | 6 | np.add_newdoc - | ^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^ 7 | 8 | np.add_newdoc_ufunc | - = help: Replace with `numpy.lib.add_newdoc` +help: Replace with `numpy.lib.add_newdoc` ℹ Safe fix 1 |+from numpy.lib import add_newdoc @@ -47,36 +49,39 @@ NPY201.py:6:5: NPY201 [*] `np.add_newdoc` will be removed in NumPy 2.0. Use `num 8 9 | np.add_newdoc_ufunc 9 10 | -NPY201.py:8:5: NPY201 `np.add_newdoc_ufunc` will be removed in NumPy 2.0. `add_newdoc_ufunc` is an internal function. +NPY201 `np.add_newdoc_ufunc` will be removed in NumPy 2.0. `add_newdoc_ufunc` is an internal function. + --> NPY201.py:8:5 | 6 | np.add_newdoc 7 | 8 | np.add_newdoc_ufunc - | ^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^ 9 | 10 | np.asfarray([1,2,3]) | -NPY201.py:10:5: NPY201 `np.asfarray` will be removed in NumPy 2.0. Use `np.asarray` with a `float` dtype instead. +NPY201 `np.asfarray` will be removed in NumPy 2.0. Use `np.asarray` with a `float` dtype instead. + --> NPY201.py:10:5 | 8 | np.add_newdoc_ufunc 9 | 10 | np.asfarray([1,2,3]) - | ^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^ 11 | 12 | np.byte_bounds(np.array([1,2,3])) | -NPY201.py:12:5: NPY201 [*] `np.byte_bounds` will be removed in NumPy 2.0. Use `numpy.lib.array_utils.byte_bounds` on NumPy 2.0, or ignore this warning on earlier versions. +NPY201 [*] `np.byte_bounds` will be removed in NumPy 2.0. Use `numpy.lib.array_utils.byte_bounds` on NumPy 2.0, or ignore this warning on earlier versions. + --> NPY201.py:12:5 | 10 | np.asfarray([1,2,3]) 11 | 12 | np.byte_bounds(np.array([1,2,3])) - | ^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^ 13 | 14 | np.cast | - = help: Replace with `numpy.lib.array_utils.byte_bounds` (requires NumPy 2.0 or greater) +help: Replace with `numpy.lib.array_utils.byte_bounds` (requires NumPy 2.0 or greater) ℹ Unsafe fix 1 |+from numpy.lib.array_utils import byte_bounds @@ -93,26 +98,28 @@ NPY201.py:12:5: NPY201 [*] `np.byte_bounds` will be removed in NumPy 2.0. Use `n 14 15 | np.cast 15 16 | -NPY201.py:14:5: NPY201 `np.cast` will be removed in NumPy 2.0. Use `np.asarray(arr, dtype=dtype)` instead. +NPY201 `np.cast` will be removed in NumPy 2.0. Use `np.asarray(arr, dtype=dtype)` instead. + --> NPY201.py:14:5 | 12 | np.byte_bounds(np.array([1,2,3])) 13 | 14 | np.cast - | ^^^^^^^ NPY201 + | ^^^^^^^ 15 | 16 | np.cfloat(12+34j) | -NPY201.py:16:5: NPY201 [*] `np.cfloat` will be removed in NumPy 2.0. Use `numpy.complex128` instead. +NPY201 [*] `np.cfloat` will be removed in NumPy 2.0. Use `numpy.complex128` instead. + --> NPY201.py:16:5 | 14 | np.cast 15 | 16 | np.cfloat(12+34j) - | ^^^^^^^^^ NPY201 + | ^^^^^^^^^ 17 | 18 | np.clongfloat(12+34j) | - = help: Replace with `numpy.complex128` +help: Replace with `numpy.complex128` ℹ Safe fix 13 13 | @@ -124,16 +131,17 @@ NPY201.py:16:5: NPY201 [*] `np.cfloat` will be removed in NumPy 2.0. Use `numpy. 18 18 | np.clongfloat(12+34j) 19 19 | -NPY201.py:18:5: NPY201 [*] `np.clongfloat` will be removed in NumPy 2.0. Use `numpy.clongdouble` instead. +NPY201 [*] `np.clongfloat` will be removed in NumPy 2.0. Use `numpy.clongdouble` instead. + --> NPY201.py:18:5 | 16 | np.cfloat(12+34j) 17 | 18 | np.clongfloat(12+34j) - | ^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^ 19 | 20 | np.compat | - = help: Replace with `numpy.clongdouble` +help: Replace with `numpy.clongdouble` ℹ Safe fix 15 15 | @@ -145,26 +153,28 @@ NPY201.py:18:5: NPY201 [*] `np.clongfloat` will be removed in NumPy 2.0. Use `nu 20 20 | np.compat 21 21 | -NPY201.py:20:5: NPY201 `np.compat` will be removed in NumPy 2.0. Python 2 is no longer supported. +NPY201 `np.compat` will be removed in NumPy 2.0. Python 2 is no longer supported. + --> NPY201.py:20:5 | 18 | np.clongfloat(12+34j) 19 | 20 | np.compat - | ^^^^^^^^^ NPY201 + | ^^^^^^^^^ 21 | 22 | np.complex_(12+34j) | -NPY201.py:22:5: NPY201 [*] `np.complex_` will be removed in NumPy 2.0. Use `numpy.complex128` instead. +NPY201 [*] `np.complex_` will be removed in NumPy 2.0. Use `numpy.complex128` instead. + --> NPY201.py:22:5 | 20 | np.compat 21 | 22 | np.complex_(12+34j) - | ^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^ 23 | 24 | np.DataSource | - = help: Replace with `numpy.complex128` +help: Replace with `numpy.complex128` ℹ Safe fix 19 19 | @@ -176,16 +186,17 @@ NPY201.py:22:5: NPY201 [*] `np.complex_` will be removed in NumPy 2.0. Use `nump 24 24 | np.DataSource 25 25 | -NPY201.py:24:5: NPY201 [*] `np.DataSource` will be removed in NumPy 2.0. Use `numpy.lib.npyio.DataSource` instead. +NPY201 [*] `np.DataSource` will be removed in NumPy 2.0. Use `numpy.lib.npyio.DataSource` instead. + --> NPY201.py:24:5 | 22 | np.complex_(12+34j) 23 | 24 | np.DataSource - | ^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^ 25 | 26 | np.deprecate | - = help: Replace with `numpy.lib.npyio.DataSource` +help: Replace with `numpy.lib.npyio.DataSource` ℹ Safe fix 1 |+from numpy.lib.npyio import DataSource @@ -202,76 +213,83 @@ NPY201.py:24:5: NPY201 [*] `np.DataSource` will be removed in NumPy 2.0. Use `nu 26 27 | np.deprecate 27 28 | -NPY201.py:26:5: NPY201 `np.deprecate` will be removed in NumPy 2.0. Emit `DeprecationWarning` with `warnings.warn` directly, or use `typing.deprecated`. +NPY201 `np.deprecate` will be removed in NumPy 2.0. Emit `DeprecationWarning` with `warnings.warn` directly, or use `typing.deprecated`. + --> NPY201.py:26:5 | 24 | np.DataSource 25 | 26 | np.deprecate - | ^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^ 27 | 28 | np.deprecate_with_doc | -NPY201.py:28:5: NPY201 `np.deprecate_with_doc` will be removed in NumPy 2.0. Emit `DeprecationWarning` with `warnings.warn` directly, or use `typing.deprecated`. +NPY201 `np.deprecate_with_doc` will be removed in NumPy 2.0. Emit `DeprecationWarning` with `warnings.warn` directly, or use `typing.deprecated`. + --> NPY201.py:28:5 | 26 | np.deprecate 27 | 28 | np.deprecate_with_doc - | ^^^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^^^ 29 | 30 | np.disp(10) | -NPY201.py:30:5: NPY201 `np.disp` will be removed in NumPy 2.0. Use a dedicated print function instead. +NPY201 `np.disp` will be removed in NumPy 2.0. Use a dedicated print function instead. + --> NPY201.py:30:5 | 28 | np.deprecate_with_doc 29 | 30 | np.disp(10) - | ^^^^^^^ NPY201 + | ^^^^^^^ 31 | 32 | np.fastCopyAndTranspose | -NPY201.py:32:5: NPY201 `np.fastCopyAndTranspose` will be removed in NumPy 2.0. Use `arr.T.copy()` instead. +NPY201 `np.fastCopyAndTranspose` will be removed in NumPy 2.0. Use `arr.T.copy()` instead. + --> NPY201.py:32:5 | 30 | np.disp(10) 31 | 32 | np.fastCopyAndTranspose - | ^^^^^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^^^^^ 33 | 34 | np.find_common_type | -NPY201.py:34:5: NPY201 `np.find_common_type` will be removed in NumPy 2.0. Use `numpy.promote_types` or `numpy.result_type` instead. To achieve semantics for the `scalar_types` argument, use `numpy.result_type` and pass the Python values `0`, `0.0`, or `0j`. +NPY201 `np.find_common_type` will be removed in NumPy 2.0. Use `numpy.promote_types` or `numpy.result_type` instead. To achieve semantics for the `scalar_types` argument, use `numpy.result_type` and pass the Python values `0`, `0.0`, or `0j`. + --> NPY201.py:34:5 | 32 | np.fastCopyAndTranspose 33 | 34 | np.find_common_type - | ^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^ 35 | 36 | np.get_array_wrap | -NPY201.py:36:5: NPY201 `np.get_array_wrap` will be removed without replacement in NumPy 2.0 +NPY201 `np.get_array_wrap` will be removed without replacement in NumPy 2.0 + --> NPY201.py:36:5 | 34 | np.find_common_type 35 | 36 | np.get_array_wrap - | ^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^ 37 | 38 | np.float_ | -NPY201.py:38:5: NPY201 [*] `np.float_` will be removed in NumPy 2.0. Use `numpy.float64` instead. +NPY201 [*] `np.float_` will be removed in NumPy 2.0. Use `numpy.float64` instead. + --> NPY201.py:38:5 | 36 | np.get_array_wrap 37 | 38 | np.float_ - | ^^^^^^^^^ NPY201 + | ^^^^^^^^^ 39 | 40 | np.geterrobj | - = help: Replace with `numpy.float64` +help: Replace with `numpy.float64` ℹ Safe fix 35 35 | @@ -283,26 +301,28 @@ NPY201.py:38:5: NPY201 [*] `np.float_` will be removed in NumPy 2.0. Use `numpy. 40 40 | np.geterrobj 41 41 | -NPY201.py:40:5: NPY201 `np.geterrobj` will be removed in NumPy 2.0. Use the `np.errstate` context manager instead. +NPY201 `np.geterrobj` will be removed in NumPy 2.0. Use the `np.errstate` context manager instead. + --> NPY201.py:40:5 | 38 | np.float_ 39 | 40 | np.geterrobj - | ^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^ 41 | 42 | np.Inf | -NPY201.py:42:5: NPY201 [*] `np.Inf` will be removed in NumPy 2.0. Use `numpy.inf` instead. +NPY201 [*] `np.Inf` will be removed in NumPy 2.0. Use `numpy.inf` instead. + --> NPY201.py:42:5 | 40 | np.geterrobj 41 | 42 | np.Inf - | ^^^^^^ NPY201 + | ^^^^^^ 43 | 44 | np.Infinity | - = help: Replace with `numpy.inf` +help: Replace with `numpy.inf` ℹ Safe fix 39 39 | @@ -314,16 +334,17 @@ NPY201.py:42:5: NPY201 [*] `np.Inf` will be removed in NumPy 2.0. Use `numpy.inf 44 44 | np.Infinity 45 45 | -NPY201.py:44:5: NPY201 [*] `np.Infinity` will be removed in NumPy 2.0. Use `numpy.inf` instead. +NPY201 [*] `np.Infinity` will be removed in NumPy 2.0. Use `numpy.inf` instead. + --> NPY201.py:44:5 | 42 | np.Inf 43 | 44 | np.Infinity - | ^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^ 45 | 46 | np.infty | - = help: Replace with `numpy.inf` +help: Replace with `numpy.inf` ℹ Safe fix 41 41 | @@ -335,16 +356,17 @@ NPY201.py:44:5: NPY201 [*] `np.Infinity` will be removed in NumPy 2.0. Use `nump 46 46 | np.infty 47 47 | -NPY201.py:46:5: NPY201 [*] `np.infty` will be removed in NumPy 2.0. Use `numpy.inf` instead. +NPY201 [*] `np.infty` will be removed in NumPy 2.0. Use `numpy.inf` instead. + --> NPY201.py:46:5 | 44 | np.Infinity 45 | 46 | np.infty - | ^^^^^^^^ NPY201 + | ^^^^^^^^ 47 | 48 | np.issctype | - = help: Replace with `numpy.inf` +help: Replace with `numpy.inf` ℹ Safe fix 43 43 | @@ -356,26 +378,28 @@ NPY201.py:46:5: NPY201 [*] `np.infty` will be removed in NumPy 2.0. Use `numpy.i 48 48 | np.issctype 49 49 | -NPY201.py:48:5: NPY201 `np.issctype` will be removed without replacement in NumPy 2.0 +NPY201 `np.issctype` will be removed without replacement in NumPy 2.0 + --> NPY201.py:48:5 | 46 | np.infty 47 | 48 | np.issctype - | ^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^ 49 | 50 | np.issubclass_(np.int32, np.integer) | -NPY201.py:50:5: NPY201 [*] `np.issubclass_` will be removed in NumPy 2.0. Use `issubclass` instead. +NPY201 [*] `np.issubclass_` will be removed in NumPy 2.0. Use `issubclass` instead. + --> NPY201.py:50:5 | 48 | np.issctype 49 | 50 | np.issubclass_(np.int32, np.integer) - | ^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^ 51 | 52 | np.issubsctype | - = help: Replace with `issubclass` +help: Replace with `issubclass` ℹ Safe fix 47 47 | @@ -387,16 +411,17 @@ NPY201.py:50:5: NPY201 [*] `np.issubclass_` will be removed in NumPy 2.0. Use `i 52 52 | np.issubsctype 53 53 | -NPY201.py:52:5: NPY201 [*] `np.issubsctype` will be removed in NumPy 2.0. Use `numpy.issubdtype` instead. +NPY201 [*] `np.issubsctype` will be removed in NumPy 2.0. Use `numpy.issubdtype` instead. + --> NPY201.py:52:5 | 50 | np.issubclass_(np.int32, np.integer) 51 | 52 | np.issubsctype - | ^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^ 53 | 54 | np.mat | - = help: Replace with `numpy.issubdtype` +help: Replace with `numpy.issubdtype` ℹ Safe fix 49 49 | @@ -408,16 +433,17 @@ NPY201.py:52:5: NPY201 [*] `np.issubsctype` will be removed in NumPy 2.0. Use `n 54 54 | np.mat 55 55 | -NPY201.py:54:5: NPY201 [*] `np.mat` will be removed in NumPy 2.0. Use `numpy.asmatrix` instead. +NPY201 [*] `np.mat` will be removed in NumPy 2.0. Use `numpy.asmatrix` instead. + --> NPY201.py:54:5 | 52 | np.issubsctype 53 | 54 | np.mat - | ^^^^^^ NPY201 + | ^^^^^^ 55 | 56 | np.maximum_sctype | - = help: Replace with `numpy.asmatrix` +help: Replace with `numpy.asmatrix` ℹ Safe fix 51 51 | @@ -429,26 +455,28 @@ NPY201.py:54:5: NPY201 [*] `np.mat` will be removed in NumPy 2.0. Use `numpy.asm 56 56 | np.maximum_sctype 57 57 | -NPY201.py:56:5: NPY201 `np.maximum_sctype` will be removed without replacement in NumPy 2.0 +NPY201 `np.maximum_sctype` will be removed without replacement in NumPy 2.0 + --> NPY201.py:56:5 | 54 | np.mat 55 | 56 | np.maximum_sctype - | ^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^ 57 | 58 | np.NaN | -NPY201.py:58:5: NPY201 [*] `np.NaN` will be removed in NumPy 2.0. Use `numpy.nan` instead. +NPY201 [*] `np.NaN` will be removed in NumPy 2.0. Use `numpy.nan` instead. + --> NPY201.py:58:5 | 56 | np.maximum_sctype 57 | 58 | np.NaN - | ^^^^^^ NPY201 + | ^^^^^^ 59 | 60 | np.nbytes[np.int64] | - = help: Replace with `numpy.nan` +help: Replace with `numpy.nan` ℹ Safe fix 55 55 | @@ -460,26 +488,28 @@ NPY201.py:58:5: NPY201 [*] `np.NaN` will be removed in NumPy 2.0. Use `numpy.nan 60 60 | np.nbytes[np.int64] 61 61 | -NPY201.py:60:5: NPY201 `np.nbytes` will be removed in NumPy 2.0. Use `np.dtype().itemsize` instead. +NPY201 `np.nbytes` will be removed in NumPy 2.0. Use `np.dtype().itemsize` instead. + --> NPY201.py:60:5 | 58 | np.NaN 59 | 60 | np.nbytes[np.int64] - | ^^^^^^^^^ NPY201 + | ^^^^^^^^^ 61 | 62 | np.NINF | -NPY201.py:62:5: NPY201 [*] `np.NINF` will be removed in NumPy 2.0. Use `-np.inf` instead. +NPY201 [*] `np.NINF` will be removed in NumPy 2.0. Use `-np.inf` instead. + --> NPY201.py:62:5 | 60 | np.nbytes[np.int64] 61 | 62 | np.NINF - | ^^^^^^^ NPY201 + | ^^^^^^^ 63 | 64 | np.NZERO | - = help: Replace with `-np.inf` +help: Replace with `-np.inf` ℹ Safe fix 59 59 | @@ -491,16 +521,17 @@ NPY201.py:62:5: NPY201 [*] `np.NINF` will be removed in NumPy 2.0. Use `-np.inf` 64 64 | np.NZERO 65 65 | -NPY201.py:64:5: NPY201 [*] `np.NZERO` will be removed in NumPy 2.0. Use `-0.0` instead. +NPY201 [*] `np.NZERO` will be removed in NumPy 2.0. Use `-0.0` instead. + --> NPY201.py:64:5 | 62 | np.NINF 63 | 64 | np.NZERO - | ^^^^^^^^ NPY201 + | ^^^^^^^^ 65 | 66 | np.longcomplex(12+34j) | - = help: Replace with `-0.0` +help: Replace with `-0.0` ℹ Safe fix 61 61 | @@ -512,16 +543,17 @@ NPY201.py:64:5: NPY201 [*] `np.NZERO` will be removed in NumPy 2.0. Use `-0.0` i 66 66 | np.longcomplex(12+34j) 67 67 | -NPY201.py:66:5: NPY201 [*] `np.longcomplex` will be removed in NumPy 2.0. Use `numpy.clongdouble` instead. +NPY201 [*] `np.longcomplex` will be removed in NumPy 2.0. Use `numpy.clongdouble` instead. + --> NPY201.py:66:5 | 64 | np.NZERO 65 | 66 | np.longcomplex(12+34j) - | ^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^ 67 | 68 | np.longfloat(12+34j) | - = help: Replace with `numpy.clongdouble` +help: Replace with `numpy.clongdouble` ℹ Safe fix 63 63 | @@ -533,16 +565,17 @@ NPY201.py:66:5: NPY201 [*] `np.longcomplex` will be removed in NumPy 2.0. Use `n 68 68 | np.longfloat(12+34j) 69 69 | -NPY201.py:68:5: NPY201 [*] `np.longfloat` will be removed in NumPy 2.0. Use `numpy.longdouble` instead. +NPY201 [*] `np.longfloat` will be removed in NumPy 2.0. Use `numpy.longdouble` instead. + --> NPY201.py:68:5 | 66 | np.longcomplex(12+34j) 67 | 68 | np.longfloat(12+34j) - | ^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^ 69 | 70 | np.lookfor | - = help: Replace with `numpy.longdouble` +help: Replace with `numpy.longdouble` ℹ Safe fix 65 65 | @@ -554,26 +587,28 @@ NPY201.py:68:5: NPY201 [*] `np.longfloat` will be removed in NumPy 2.0. Use `num 70 70 | np.lookfor 71 71 | -NPY201.py:70:5: NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPy’s documentation directly. +NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPy’s documentation directly. + --> NPY201.py:70:5 | 68 | np.longfloat(12+34j) 69 | 70 | np.lookfor - | ^^^^^^^^^^ NPY201 + | ^^^^^^^^^^ 71 | 72 | np.NAN | -NPY201.py:72:5: NPY201 [*] `np.NAN` will be removed in NumPy 2.0. Use `numpy.nan` instead. +NPY201 [*] `np.NAN` will be removed in NumPy 2.0. Use `numpy.nan` instead. + --> NPY201.py:72:5 | 70 | np.lookfor 71 | 72 | np.NAN - | ^^^^^^ NPY201 + | ^^^^^^ 73 | 74 | try: | - = help: Replace with `numpy.nan` +help: Replace with `numpy.nan` ℹ Safe fix 69 69 | diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap index 9350fd8d19..cc084a2158 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_2.py.snap @@ -1,26 +1,28 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs --- -NPY201_2.py:4:5: NPY201 `np.obj2sctype` will be removed without replacement in NumPy 2.0 +NPY201 `np.obj2sctype` will be removed without replacement in NumPy 2.0 + --> NPY201_2.py:4:5 | 2 | import numpy as np 3 | 4 | np.obj2sctype(int) - | ^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^ 5 | 6 | np.PINF | -NPY201_2.py:6:5: NPY201 [*] `np.PINF` will be removed in NumPy 2.0. Use `numpy.inf` instead. +NPY201 [*] `np.PINF` will be removed in NumPy 2.0. Use `numpy.inf` instead. + --> NPY201_2.py:6:5 | 4 | np.obj2sctype(int) 5 | 6 | np.PINF - | ^^^^^^^ NPY201 + | ^^^^^^^ 7 | 8 | np.PZERO | - = help: Replace with `numpy.inf` +help: Replace with `numpy.inf` ℹ Safe fix 3 3 | @@ -32,16 +34,17 @@ NPY201_2.py:6:5: NPY201 [*] `np.PINF` will be removed in NumPy 2.0. Use `numpy.i 8 8 | np.PZERO 9 9 | -NPY201_2.py:8:5: NPY201 [*] `np.PZERO` will be removed in NumPy 2.0. Use `0.0` instead. +NPY201 [*] `np.PZERO` will be removed in NumPy 2.0. Use `0.0` instead. + --> NPY201_2.py:8:5 | 6 | np.PINF 7 | 8 | np.PZERO - | ^^^^^^^^ NPY201 + | ^^^^^^^^ 9 | 10 | np.recfromcsv | - = help: Replace with `0.0` +help: Replace with `0.0` ℹ Safe fix 5 5 | @@ -53,36 +56,39 @@ NPY201_2.py:8:5: NPY201 [*] `np.PZERO` will be removed in NumPy 2.0. Use `0.0` i 10 10 | np.recfromcsv 11 11 | -NPY201_2.py:10:5: NPY201 `np.recfromcsv` will be removed in NumPy 2.0. Use `np.genfromtxt` with comma delimiter instead. +NPY201 `np.recfromcsv` will be removed in NumPy 2.0. Use `np.genfromtxt` with comma delimiter instead. + --> NPY201_2.py:10:5 | 8 | np.PZERO 9 | 10 | np.recfromcsv - | ^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^ 11 | 12 | np.recfromtxt | -NPY201_2.py:12:5: NPY201 `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead. +NPY201 `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead. + --> NPY201_2.py:12:5 | 10 | np.recfromcsv 11 | 12 | np.recfromtxt - | ^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^ 13 | 14 | np.round_(12.34) | -NPY201_2.py:14:5: NPY201 [*] `np.round_` will be removed in NumPy 2.0. Use `numpy.round` instead. +NPY201 [*] `np.round_` will be removed in NumPy 2.0. Use `numpy.round` instead. + --> NPY201_2.py:14:5 | 12 | np.recfromtxt 13 | 14 | np.round_(12.34) - | ^^^^^^^^^ NPY201 + | ^^^^^^^^^ 15 | 16 | np.safe_eval | - = help: Replace with `numpy.round` +help: Replace with `numpy.round` ℹ Safe fix 11 11 | @@ -94,16 +100,17 @@ NPY201_2.py:14:5: NPY201 [*] `np.round_` will be removed in NumPy 2.0. Use `nump 16 16 | np.safe_eval 17 17 | -NPY201_2.py:16:5: NPY201 [*] `np.safe_eval` will be removed in NumPy 2.0. Use `ast.literal_eval` instead. +NPY201 [*] `np.safe_eval` will be removed in NumPy 2.0. Use `ast.literal_eval` instead. + --> NPY201_2.py:16:5 | 14 | np.round_(12.34) 15 | 16 | np.safe_eval - | ^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^ 17 | 18 | np.sctype2char | - = help: Replace with `ast.literal_eval` +help: Replace with `ast.literal_eval` ℹ Safe fix 1 |+from ast import literal_eval @@ -120,56 +127,61 @@ NPY201_2.py:16:5: NPY201 [*] `np.safe_eval` will be removed in NumPy 2.0. Use `a 18 19 | np.sctype2char 19 20 | -NPY201_2.py:18:5: NPY201 `np.sctype2char` will be removed without replacement in NumPy 2.0 +NPY201 `np.sctype2char` will be removed without replacement in NumPy 2.0 + --> NPY201_2.py:18:5 | 16 | np.safe_eval 17 | 18 | np.sctype2char - | ^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^ 19 | 20 | np.sctypes | -NPY201_2.py:20:5: NPY201 `np.sctypes` will be removed without replacement in NumPy 2.0 +NPY201 `np.sctypes` will be removed without replacement in NumPy 2.0 + --> NPY201_2.py:20:5 | 18 | np.sctype2char 19 | 20 | np.sctypes - | ^^^^^^^^^^ NPY201 + | ^^^^^^^^^^ 21 | 22 | np.seterrobj | -NPY201_2.py:22:5: NPY201 `np.seterrobj` will be removed in NumPy 2.0. Use the `np.errstate` context manager instead. +NPY201 `np.seterrobj` will be removed in NumPy 2.0. Use the `np.errstate` context manager instead. + --> NPY201_2.py:22:5 | 20 | np.sctypes 21 | 22 | np.seterrobj - | ^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^ 23 | 24 | np.set_numeric_ops | -NPY201_2.py:26:5: NPY201 `np.set_string_function` will be removed in NumPy 2.0. Use `np.set_printoptions` for custom printing of NumPy objects. +NPY201 `np.set_string_function` will be removed in NumPy 2.0. Use `np.set_printoptions` for custom printing of NumPy objects. + --> NPY201_2.py:26:5 | 24 | np.set_numeric_ops 25 | 26 | np.set_string_function - | ^^^^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | np.singlecomplex(12+1j) | -NPY201_2.py:28:5: NPY201 [*] `np.singlecomplex` will be removed in NumPy 2.0. Use `numpy.complex64` instead. +NPY201 [*] `np.singlecomplex` will be removed in NumPy 2.0. Use `numpy.complex64` instead. + --> NPY201_2.py:28:5 | 26 | np.set_string_function 27 | 28 | np.singlecomplex(12+1j) - | ^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^ 29 | 30 | np.string_("asdf") | - = help: Replace with `numpy.complex64` +help: Replace with `numpy.complex64` ℹ Safe fix 25 25 | @@ -181,16 +193,17 @@ NPY201_2.py:28:5: NPY201 [*] `np.singlecomplex` will be removed in NumPy 2.0. Us 30 30 | np.string_("asdf") 31 31 | -NPY201_2.py:30:5: NPY201 [*] `np.string_` will be removed in NumPy 2.0. Use `numpy.bytes_` instead. +NPY201 [*] `np.string_` will be removed in NumPy 2.0. Use `numpy.bytes_` instead. + --> NPY201_2.py:30:5 | 28 | np.singlecomplex(12+1j) 29 | 30 | np.string_("asdf") - | ^^^^^^^^^^ NPY201 + | ^^^^^^^^^^ 31 | 32 | np.source | - = help: Replace with `numpy.bytes_` +help: Replace with `numpy.bytes_` ℹ Safe fix 27 27 | @@ -202,16 +215,17 @@ NPY201_2.py:30:5: NPY201 [*] `np.string_` will be removed in NumPy 2.0. Use `num 32 32 | np.source 33 33 | -NPY201_2.py:32:5: NPY201 [*] `np.source` will be removed in NumPy 2.0. Use `inspect.getsource` instead. +NPY201 [*] `np.source` will be removed in NumPy 2.0. Use `inspect.getsource` instead. + --> NPY201_2.py:32:5 | 30 | np.string_("asdf") 31 | 32 | np.source - | ^^^^^^^^^ NPY201 + | ^^^^^^^^^ 33 | 34 | np.tracemalloc_domain | - = help: Replace with `inspect.getsource` +help: Replace with `inspect.getsource` ℹ Safe fix 1 |+from inspect import getsource @@ -228,16 +242,17 @@ NPY201_2.py:32:5: NPY201 [*] `np.source` will be removed in NumPy 2.0. Use `insp 34 35 | np.tracemalloc_domain 35 36 | -NPY201_2.py:34:5: NPY201 [*] `np.tracemalloc_domain` will be removed in NumPy 2.0. Use `numpy.lib.tracemalloc_domain` instead. +NPY201 [*] `np.tracemalloc_domain` will be removed in NumPy 2.0. Use `numpy.lib.tracemalloc_domain` instead. + --> NPY201_2.py:34:5 | 32 | np.source 33 | 34 | np.tracemalloc_domain - | ^^^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | np.unicode_("asf") | - = help: Replace with `numpy.lib.tracemalloc_domain` +help: Replace with `numpy.lib.tracemalloc_domain` ℹ Safe fix 1 |+from numpy.lib import tracemalloc_domain @@ -254,16 +269,17 @@ NPY201_2.py:34:5: NPY201 [*] `np.tracemalloc_domain` will be removed in NumPy 2. 36 37 | np.unicode_("asf") 37 38 | -NPY201_2.py:36:5: NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `numpy.str_` instead. +NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `numpy.str_` instead. + --> NPY201_2.py:36:5 | 34 | np.tracemalloc_domain 35 | 36 | np.unicode_("asf") - | ^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^ 37 | 38 | np.who() | - = help: Replace with `numpy.str_` +help: Replace with `numpy.str_` ℹ Safe fix 33 33 | @@ -275,26 +291,28 @@ NPY201_2.py:36:5: NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `nu 38 38 | np.who() 39 39 | -NPY201_2.py:38:5: NPY201 `np.who` will be removed in NumPy 2.0. Use an IDE variable explorer or `locals()` instead. +NPY201 `np.who` will be removed in NumPy 2.0. Use an IDE variable explorer or `locals()` instead. + --> NPY201_2.py:38:5 | 36 | np.unicode_("asf") 37 | 38 | np.who() - | ^^^^^^ NPY201 + | ^^^^^^ 39 | 40 | np.row_stack(([1,2], [3,4])) | -NPY201_2.py:40:5: NPY201 [*] `np.row_stack` will be removed in NumPy 2.0. Use `numpy.vstack` instead. +NPY201 [*] `np.row_stack` will be removed in NumPy 2.0. Use `numpy.vstack` instead. + --> NPY201_2.py:40:5 | 38 | np.who() 39 | 40 | np.row_stack(([1,2], [3,4])) - | ^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^ 41 | 42 | np.alltrue([True, True]) | - = help: Replace with `numpy.vstack` +help: Replace with `numpy.vstack` ℹ Safe fix 37 37 | @@ -306,16 +324,17 @@ NPY201_2.py:40:5: NPY201 [*] `np.row_stack` will be removed in NumPy 2.0. Use `n 42 42 | np.alltrue([True, True]) 43 43 | -NPY201_2.py:42:5: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `numpy.all` instead. +NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `numpy.all` instead. + --> NPY201_2.py:42:5 | 40 | np.row_stack(([1,2], [3,4])) 41 | 42 | np.alltrue([True, True]) - | ^^^^^^^^^^ NPY201 + | ^^^^^^^^^^ 43 | 44 | np.sometrue([True, False]) | - = help: Replace with `numpy.all` +help: Replace with `numpy.all` ℹ Safe fix 39 39 | @@ -327,16 +346,17 @@ NPY201_2.py:42:5: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `num 44 44 | np.sometrue([True, False]) 45 45 | -NPY201_2.py:44:5: NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `numpy.any` instead. +NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `numpy.any` instead. + --> NPY201_2.py:44:5 | 42 | np.alltrue([True, True]) 43 | 44 | np.sometrue([True, False]) - | ^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^ 45 | 46 | np.cumproduct([1, 2, 3]) | - = help: Replace with `numpy.any` +help: Replace with `numpy.any` ℹ Safe fix 41 41 | @@ -348,16 +368,17 @@ NPY201_2.py:44:5: NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `nu 46 46 | np.cumproduct([1, 2, 3]) 47 47 | -NPY201_2.py:46:5: NPY201 [*] `np.cumproduct` will be removed in NumPy 2.0. Use `numpy.cumprod` instead. +NPY201 [*] `np.cumproduct` will be removed in NumPy 2.0. Use `numpy.cumprod` instead. + --> NPY201_2.py:46:5 | 44 | np.sometrue([True, False]) 45 | 46 | np.cumproduct([1, 2, 3]) - | ^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^ 47 | 48 | np.product([1, 2, 3]) | - = help: Replace with `numpy.cumprod` +help: Replace with `numpy.cumprod` ℹ Safe fix 43 43 | @@ -369,16 +390,17 @@ NPY201_2.py:46:5: NPY201 [*] `np.cumproduct` will be removed in NumPy 2.0. Use ` 48 48 | np.product([1, 2, 3]) 49 49 | -NPY201_2.py:48:5: NPY201 [*] `np.product` will be removed in NumPy 2.0. Use `numpy.prod` instead. +NPY201 [*] `np.product` will be removed in NumPy 2.0. Use `numpy.prod` instead. + --> NPY201_2.py:48:5 | 46 | np.cumproduct([1, 2, 3]) 47 | 48 | np.product([1, 2, 3]) - | ^^^^^^^^^^ NPY201 + | ^^^^^^^^^^ 49 | 50 | np.trapz([1, 2, 3]) | - = help: Replace with `numpy.prod` +help: Replace with `numpy.prod` ℹ Safe fix 45 45 | @@ -390,16 +412,17 @@ NPY201_2.py:48:5: NPY201 [*] `np.product` will be removed in NumPy 2.0. Use `num 50 50 | np.trapz([1, 2, 3]) 51 51 | -NPY201_2.py:50:5: NPY201 [*] `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions. +NPY201 [*] `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions. + --> NPY201_2.py:50:5 | 48 | np.product([1, 2, 3]) 49 | 50 | np.trapz([1, 2, 3]) - | ^^^^^^^^ NPY201 + | ^^^^^^^^ 51 | 52 | np.in1d([1, 2], [1, 3, 5]) | - = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater) +help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater) ℹ Unsafe fix 47 47 | @@ -411,16 +434,17 @@ NPY201_2.py:50:5: NPY201 [*] `np.trapz` will be removed in NumPy 2.0. Use `numpy 52 52 | np.in1d([1, 2], [1, 3, 5]) 53 53 | -NPY201_2.py:52:5: NPY201 [*] `np.in1d` will be removed in NumPy 2.0. Use `numpy.isin` instead. +NPY201 [*] `np.in1d` will be removed in NumPy 2.0. Use `numpy.isin` instead. + --> NPY201_2.py:52:5 | 50 | np.trapz([1, 2, 3]) 51 | 52 | np.in1d([1, 2], [1, 3, 5]) - | ^^^^^^^ NPY201 + | ^^^^^^^ 53 | 54 | np.AxisError | - = help: Replace with `numpy.isin` +help: Replace with `numpy.isin` ℹ Safe fix 49 49 | @@ -432,16 +456,17 @@ NPY201_2.py:52:5: NPY201 [*] `np.in1d` will be removed in NumPy 2.0. Use `numpy. 54 54 | np.AxisError 55 55 | -NPY201_2.py:54:5: NPY201 [*] `np.AxisError` will be removed in NumPy 2.0. Use `numpy.exceptions.AxisError` instead. +NPY201 [*] `np.AxisError` will be removed in NumPy 2.0. Use `numpy.exceptions.AxisError` instead. + --> NPY201_2.py:54:5 | 52 | np.in1d([1, 2], [1, 3, 5]) 53 | 54 | np.AxisError - | ^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^ 55 | 56 | np.ComplexWarning | - = help: Replace with `numpy.exceptions.AxisError` +help: Replace with `numpy.exceptions.AxisError` ℹ Safe fix 1 |+from numpy.exceptions import AxisError @@ -458,16 +483,17 @@ NPY201_2.py:54:5: NPY201 [*] `np.AxisError` will be removed in NumPy 2.0. Use `n 56 57 | np.ComplexWarning 57 58 | -NPY201_2.py:56:5: NPY201 [*] `np.ComplexWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.ComplexWarning` instead. +NPY201 [*] `np.ComplexWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.ComplexWarning` instead. + --> NPY201_2.py:56:5 | 54 | np.AxisError 55 | 56 | np.ComplexWarning - | ^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^ 57 | 58 | np.compare_chararrays | - = help: Replace with `numpy.exceptions.ComplexWarning` +help: Replace with `numpy.exceptions.ComplexWarning` ℹ Safe fix 1 |+from numpy.exceptions import ComplexWarning @@ -484,16 +510,17 @@ NPY201_2.py:56:5: NPY201 [*] `np.ComplexWarning` will be removed in NumPy 2.0. U 58 59 | np.compare_chararrays 59 60 | -NPY201_2.py:58:5: NPY201 [*] `np.compare_chararrays` will be removed in NumPy 2.0. Use `numpy.char.compare_chararrays` instead. +NPY201 [*] `np.compare_chararrays` will be removed in NumPy 2.0. Use `numpy.char.compare_chararrays` instead. + --> NPY201_2.py:58:5 | 56 | np.ComplexWarning 57 | 58 | np.compare_chararrays - | ^^^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^^^ 59 | 60 | try: | - = help: Replace with `numpy.char.compare_chararrays` +help: Replace with `numpy.char.compare_chararrays` ℹ Safe fix 1 |+from numpy.char import compare_chararrays @@ -510,16 +537,17 @@ NPY201_2.py:58:5: NPY201 [*] `np.compare_chararrays` will be removed in NumPy 2. 60 61 | try: 61 62 | np.all([True, True]) -NPY201_2.py:63:9: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `numpy.all` instead. +NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `numpy.all` instead. + --> NPY201_2.py:63:9 | 61 | np.all([True, True]) 62 | except TypeError: 63 | np.alltrue([True, True]) # Should emit a warning here (`except TypeError`, not `except AttributeError`) - | ^^^^^^^^^^ NPY201 + | ^^^^^^^^^^ 64 | 65 | try: | - = help: Replace with `numpy.all` +help: Replace with `numpy.all` ℹ Safe fix 60 60 | try: @@ -531,15 +559,16 @@ NPY201_2.py:63:9: NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `num 65 65 | try: 66 66 | np.anyyyy([True, True]) -NPY201_2.py:68:9: NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `numpy.any` instead. +NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `numpy.any` instead. + --> NPY201_2.py:68:9 | 66 | np.anyyyy([True, True]) 67 | except AttributeError: 68 | np.sometrue([True, True]) # Should emit a warning here - | ^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^ 69 | # (must have an attribute access of the undeprecated name in the `try` body for it to be ignored) | - = help: Replace with `numpy.any` +help: Replace with `numpy.any` ℹ Safe fix 65 65 | try: diff --git a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap index bcdea9554d..8b9bb6bee7 100644 --- a/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy2-deprecation_NPY201_3.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/numpy/mod.rs --- -NPY201_3.py:4:5: NPY201 [*] `np.DTypePromotionError` will be removed in NumPy 2.0. Use `numpy.exceptions.DTypePromotionError` instead. +NPY201 [*] `np.DTypePromotionError` will be removed in NumPy 2.0. Use `numpy.exceptions.DTypePromotionError` instead. + --> NPY201_3.py:4:5 | 2 | import numpy as np 3 | 4 | np.DTypePromotionError - | ^^^^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | np.ModuleDeprecationWarning | - = help: Replace with `numpy.exceptions.DTypePromotionError` +help: Replace with `numpy.exceptions.DTypePromotionError` ℹ Safe fix 1 |+from numpy.exceptions import DTypePromotionError @@ -23,16 +24,17 @@ NPY201_3.py:4:5: NPY201 [*] `np.DTypePromotionError` will be removed in NumPy 2. 6 7 | np.ModuleDeprecationWarning 7 8 | -NPY201_3.py:6:5: NPY201 [*] `np.ModuleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.ModuleDeprecationWarning` instead. +NPY201 [*] `np.ModuleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.ModuleDeprecationWarning` instead. + --> NPY201_3.py:6:5 | 4 | np.DTypePromotionError 5 | 6 | np.ModuleDeprecationWarning - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | np.RankWarning | - = help: Replace with `numpy.exceptions.ModuleDeprecationWarning` +help: Replace with `numpy.exceptions.ModuleDeprecationWarning` ℹ Safe fix 1 |+from numpy.exceptions import ModuleDeprecationWarning @@ -47,16 +49,17 @@ NPY201_3.py:6:5: NPY201 [*] `np.ModuleDeprecationWarning` will be removed in Num 8 9 | np.RankWarning 9 10 | -NPY201_3.py:8:5: NPY201 [*] `np.RankWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.RankWarning` on NumPy 2.0, or ignore this warning on earlier versions. +NPY201 [*] `np.RankWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.RankWarning` on NumPy 2.0, or ignore this warning on earlier versions. + --> NPY201_3.py:8:5 | 6 | np.ModuleDeprecationWarning 7 | 8 | np.RankWarning - | ^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^ 9 | 10 | np.TooHardError | - = help: Replace with `numpy.exceptions.RankWarning` (requires NumPy 2.0 or greater) +help: Replace with `numpy.exceptions.RankWarning` (requires NumPy 2.0 or greater) ℹ Unsafe fix 1 |+from numpy.exceptions import RankWarning @@ -73,16 +76,17 @@ NPY201_3.py:8:5: NPY201 [*] `np.RankWarning` will be removed in NumPy 2.0. Use ` 10 11 | np.TooHardError 11 12 | -NPY201_3.py:10:5: NPY201 [*] `np.TooHardError` will be removed in NumPy 2.0. Use `numpy.exceptions.TooHardError` instead. +NPY201 [*] `np.TooHardError` will be removed in NumPy 2.0. Use `numpy.exceptions.TooHardError` instead. + --> NPY201_3.py:10:5 | 8 | np.RankWarning 9 | 10 | np.TooHardError - | ^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^ 11 | 12 | np.VisibleDeprecationWarning | - = help: Replace with `numpy.exceptions.TooHardError` +help: Replace with `numpy.exceptions.TooHardError` ℹ Safe fix 1 |+from numpy.exceptions import TooHardError @@ -99,16 +103,17 @@ NPY201_3.py:10:5: NPY201 [*] `np.TooHardError` will be removed in NumPy 2.0. Use 12 13 | np.VisibleDeprecationWarning 13 14 | -NPY201_3.py:12:5: NPY201 [*] `np.VisibleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.VisibleDeprecationWarning` instead. +NPY201 [*] `np.VisibleDeprecationWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.VisibleDeprecationWarning` instead. + --> NPY201_3.py:12:5 | 10 | np.TooHardError 11 | 12 | np.VisibleDeprecationWarning - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | np.chararray | - = help: Replace with `numpy.exceptions.VisibleDeprecationWarning` +help: Replace with `numpy.exceptions.VisibleDeprecationWarning` ℹ Safe fix 1 |+from numpy.exceptions import VisibleDeprecationWarning @@ -125,16 +130,17 @@ NPY201_3.py:12:5: NPY201 [*] `np.VisibleDeprecationWarning` will be removed in N 14 15 | np.chararray 15 16 | -NPY201_3.py:14:5: NPY201 [*] `np.chararray` will be removed in NumPy 2.0. Use `numpy.char.chararray` instead. +NPY201 [*] `np.chararray` will be removed in NumPy 2.0. Use `numpy.char.chararray` instead. + --> NPY201_3.py:14:5 | 12 | np.VisibleDeprecationWarning 13 | 14 | np.chararray - | ^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^ 15 | 16 | np.format_parser | - = help: Replace with `numpy.char.chararray` +help: Replace with `numpy.char.chararray` ℹ Safe fix 1 |+from numpy.char import chararray @@ -150,14 +156,15 @@ NPY201_3.py:14:5: NPY201 [*] `np.chararray` will be removed in NumPy 2.0. Use `n 15 16 | 16 17 | np.format_parser -NPY201_3.py:16:5: NPY201 [*] `np.format_parser` will be removed in NumPy 2.0. Use `numpy.rec.format_parser` instead. +NPY201 [*] `np.format_parser` will be removed in NumPy 2.0. Use `numpy.rec.format_parser` instead. + --> NPY201_3.py:16:5 | 14 | np.chararray 15 | 16 | np.format_parser - | ^^^^^^^^^^^^^^^^ NPY201 + | ^^^^^^^^^^^^^^^^ | - = help: Replace with `numpy.rec.format_parser` +help: Replace with `numpy.rec.format_parser` ℹ Safe fix 1 |+from numpy.rec import format_parser diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap index 1d9c8f3df5..6fd2c7666c 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs --- -PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior +PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:5:23 | 3 | x = pd.DataFrame() 4 | 5 | x.drop(["a"], axis=1, inplace=True) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 6 | 7 | x.y.drop(["a"], axis=1, inplace=True) | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg ℹ Unsafe fix 2 2 | @@ -22,16 +23,17 @@ PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent b 7 7 | x.y.drop(["a"], axis=1, inplace=True) 8 8 | -PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior +PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:7:25 | 5 | x.drop(["a"], axis=1, inplace=True) 6 | 7 | x.y.drop(["a"], axis=1, inplace=True) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 8 | 9 | x["y"].drop(["a"], axis=1, inplace=True) | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg ℹ Unsafe fix 4 4 | @@ -43,16 +45,17 @@ PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent b 9 9 | x["y"].drop(["a"], axis=1, inplace=True) 10 10 | -PD002.py:9:28: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior +PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:9:28 | 7 | x.y.drop(["a"], axis=1, inplace=True) 8 | 9 | x["y"].drop(["a"], axis=1, inplace=True) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 10 | 11 | x.drop( | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg ℹ Unsafe fix 6 6 | @@ -64,15 +67,16 @@ PD002.py:9:28: PD002 [*] `inplace=True` should be avoided; it has inconsistent b 11 11 | x.drop( 12 12 | inplace=True, -PD002.py:12:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior +PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:12:5 | 11 | x.drop( 12 | inplace=True, - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 13 | columns=["a"], 14 | axis=1, | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg ℹ Unsafe fix 8 8 | @@ -85,16 +89,17 @@ PD002.py:12:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent b 14 13 | axis=1, 15 14 | ) -PD002.py:19:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior +PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:19:9 | 17 | if True: 18 | x.drop( 19 | inplace=True, - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 20 | columns=["a"], 21 | axis=1, | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg ℹ Unsafe fix 15 15 | ) @@ -107,16 +112,17 @@ PD002.py:19:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent b 21 20 | axis=1, 22 21 | ) -PD002.py:24:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior +PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:24:33 | 22 | ) 23 | 24 | x.drop(["a"], axis=1, **kwargs, inplace=True) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 25 | x.drop(["a"], axis=1, inplace=True, **kwargs) 26 | f(x.drop(["a"], axis=1, inplace=True)) | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg ℹ Unsafe fix 21 21 | axis=1, @@ -128,46 +134,50 @@ PD002.py:24:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent 26 26 | f(x.drop(["a"], axis=1, inplace=True)) 27 27 | -PD002.py:25:23: PD002 `inplace=True` should be avoided; it has inconsistent behavior +PD002 `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:25:23 | 24 | x.drop(["a"], axis=1, **kwargs, inplace=True) 25 | x.drop(["a"], axis=1, inplace=True, **kwargs) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 26 | f(x.drop(["a"], axis=1, inplace=True)) | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg -PD002.py:26:25: PD002 `inplace=True` should be avoided; it has inconsistent behavior +PD002 `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:26:25 | 24 | x.drop(["a"], axis=1, **kwargs, inplace=True) 25 | x.drop(["a"], axis=1, inplace=True, **kwargs) 26 | f(x.drop(["a"], axis=1, inplace=True)) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 27 | 28 | x.apply(lambda x: x.sort_values("a", inplace=True)) | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg -PD002.py:28:38: PD002 `inplace=True` should be avoided; it has inconsistent behavior +PD002 `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:28:38 | 26 | f(x.drop(["a"], axis=1, inplace=True)) 27 | 28 | x.apply(lambda x: x.sort_values("a", inplace=True)) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 29 | import torch | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg -PD002.py:33:24: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior +PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + --> PD002.py:33:24 | 31 | torch.m.ReLU(inplace=True) # safe because this isn't a pandas call 32 | 33 | (x.drop(["a"], axis=1, inplace=True)) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ 34 | 35 | # This method doesn't take exist in Pandas, so ignore it. | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg ℹ Unsafe fix 30 30 | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap index bca8d4d469..38ae790070 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:4:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior +PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + --> :4:23 | 2 | import pandas as pd 3 | x = pd.DataFrame() 4 | x.drop(["a"], axis=1, inplace=True) - | ^^^^^^^^^^^^ PD002 + | ^^^^^^^^^^^^ | - = help: Assign to variable; remove `inplace` arg +help: Assign to variable; remove `inplace` arg ℹ Unsafe fix 1 1 | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_fail.snap index 7026c453c9..88202b0f96 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_fail.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_fail.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:3:9: PD003 `.isna` is preferred to `.isnull`; functionality is equivalent +PD003 `.isna` is preferred to `.isnull`; functionality is equivalent + --> :3:9 | 2 | import pandas as pd 3 | nulls = pd.isnull(val) - | ^^^^^^^^^ PD003 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_fail.snap index 41259bba7f..acef589141 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_fail.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_fail.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:3:13: PD004 `.notna` is preferred to `.notnull`; functionality is equivalent +PD004 `.notna` is preferred to `.notnull`; functionality is equivalent + --> :3:13 | 2 | import pandas as pd 3 | not_nulls = pd.notnull(val) - | ^^^^^^^^^^ PD004 + | ^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_fail.snap index a97967b081..45c7779e8f 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_fail.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_fail.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:4:5: PD007 `.ix` is deprecated; use more explicit `.loc` or `.iloc` +PD007 `.ix` is deprecated; use more explicit `.loc` or `.iloc` + --> :4:5 | 2 | import pandas as pd 3 | x = pd.DataFrame() 4 | y = x.ix[[0, 2], "A"] - | ^^^^^^^^^^^^^^^^^ PD007 + | ^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_fail.snap index f82d38b5f4..9c2cfd6bad 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_fail.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_fail.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:4:9: PD008 Use `.loc` instead of `.at`. If speed is important, use NumPy. +PD008 Use `.loc` instead of `.at`. If speed is important, use NumPy. + --> :4:9 | 2 | import pandas as pd 3 | x = pd.DataFrame() 4 | index = x.at[:, ["B", "A"]] - | ^^^^^^^^^^^^^^^^^^^ PD008 + | ^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_fail.snap index ed47bb5b65..29aaa732bc 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_fail.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_fail.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:4:9: PD009 Use `.iloc` instead of `.iat`. If speed is important, use NumPy. +PD009 Use `.iloc` instead of `.iat`. If speed is important, use NumPy. + --> :4:9 | 2 | import pandas as pd 3 | x = pd.DataFrame() 4 | index = x.iat[:, 1:3] - | ^^^^^^^^^^^^^ PD009 + | ^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_fail_pivot.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_fail_pivot.snap index 7b0ac4f67d..fe55a0e40b 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_fail_pivot.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_fail_pivot.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:4:9: PD010 `.pivot_table` is preferred to `.pivot` or `.unstack`; provides same functionality +PD010 `.pivot_table` is preferred to `.pivot` or `.unstack`; provides same functionality + --> :4:9 | 2 | import pandas as pd 3 | x = pd.DataFrame() 4 | table = pd.pivot( - | ^^^^^^^^ PD010 + | ^^^^^^^^ 5 | x, 6 | index="foo", | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_fail_values.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_fail_values.snap index 4fb2da08d6..694518a31f 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_fail_values.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_fail_values.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:4:10: PD011 Use `.to_numpy()` instead of `.values` +PD011 Use `.to_numpy()` instead of `.values` + --> :4:10 | 2 | import pandas as pd 3 | x = pd.DataFrame() 4 | result = x.values - | ^^^^^^^^ PD011 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap index a9f1da574b..4757b26ca8 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs --- -pandas_use_of_dot_read_table.py:4:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files +PD012 Use `.read_csv` instead of `.read_table` to read CSV files + --> pandas_use_of_dot_read_table.py:4:6 | 3 | # Errors. 4 | df = pd.read_table("data.csv", sep=",") - | ^^^^^^^^^^^^^ PD012 + | ^^^^^^^^^^^^^ 5 | df = pd.read_table("data.csv", sep=",", header=0) 6 | filename = "data.csv" | -pandas_use_of_dot_read_table.py:5:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files +PD012 Use `.read_csv` instead of `.read_table` to read CSV files + --> pandas_use_of_dot_read_table.py:5:6 | 3 | # Errors. 4 | df = pd.read_table("data.csv", sep=",") 5 | df = pd.read_table("data.csv", sep=",", header=0) - | ^^^^^^^^^^^^^ PD012 + | ^^^^^^^^^^^^^ 6 | filename = "data.csv" 7 | df = pd.read_table(filename, sep=",") | -pandas_use_of_dot_read_table.py:7:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files +PD012 Use `.read_csv` instead of `.read_table` to read CSV files + --> pandas_use_of_dot_read_table.py:7:6 | 5 | df = pd.read_table("data.csv", sep=",", header=0) 6 | filename = "data.csv" 7 | df = pd.read_table(filename, sep=",") - | ^^^^^^^^^^^^^ PD012 + | ^^^^^^^^^^^^^ 8 | df = pd.read_table(filename, sep=",", header=0) | -pandas_use_of_dot_read_table.py:8:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files +PD012 Use `.read_csv` instead of `.read_table` to read CSV files + --> pandas_use_of_dot_read_table.py:8:6 | 6 | filename = "data.csv" 7 | df = pd.read_table(filename, sep=",") 8 | df = pd.read_table(filename, sep=",", header=0) - | ^^^^^^^^^^^^^ PD012 + | ^^^^^^^^^^^^^ 9 | 10 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_fail_stack.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_fail_stack.snap index 1d456bb8bd..00b141414e 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_fail_stack.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_fail_stack.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:4:5: PD013 `.melt` is preferred to `.stack`; provides same functionality +PD013 `.melt` is preferred to `.stack`; provides same functionality + --> :4:5 | 2 | import pandas as pd 3 | x = pd.DataFrame() 4 | y = x.stack(level=-1, dropna=True) - | ^^^^^^^ PD013 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap index 7603634701..a812e66437 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:5:1: PD015 Use `.merge` method instead of `pd.merge` function. They have equivalent functionality. +PD015 Use `.merge` method instead of `pd.merge` function. They have equivalent functionality. + --> :5:1 | 3 | x = pd.DataFrame() 4 | y = pd.DataFrame() 5 | pd.merge(x, y) - | ^^^^^^^^ PD015 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap index ec4c1808b5..123c44ea77 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap @@ -1,120 +1,132 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs --- -PD101.py:7:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:7:1 | 6 | # PD101 7 | data.nunique() <= 1 - | ^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^ 8 | data.nunique(dropna=True) <= 1 9 | data.nunique(dropna=False) <= 1 | -PD101.py:8:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:8:1 | 6 | # PD101 7 | data.nunique() <= 1 8 | data.nunique(dropna=True) <= 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | data.nunique(dropna=False) <= 1 10 | data.nunique() == 1 | -PD101.py:9:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:9:1 | 7 | data.nunique() <= 1 8 | data.nunique(dropna=True) <= 1 9 | data.nunique(dropna=False) <= 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | data.nunique() == 1 11 | data.nunique(dropna=True) == 1 | -PD101.py:10:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:10:1 | 8 | data.nunique(dropna=True) <= 1 9 | data.nunique(dropna=False) <= 1 10 | data.nunique() == 1 - | ^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^ 11 | data.nunique(dropna=True) == 1 12 | data.nunique(dropna=False) == 1 | -PD101.py:11:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:11:1 | 9 | data.nunique(dropna=False) <= 1 10 | data.nunique() == 1 11 | data.nunique(dropna=True) == 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | data.nunique(dropna=False) == 1 13 | data.nunique() != 1 | -PD101.py:12:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:12:1 | 10 | data.nunique() == 1 11 | data.nunique(dropna=True) == 1 12 | data.nunique(dropna=False) == 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | data.nunique() != 1 14 | data.nunique(dropna=True) != 1 | -PD101.py:13:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:13:1 | 11 | data.nunique(dropna=True) == 1 12 | data.nunique(dropna=False) == 1 13 | data.nunique() != 1 - | ^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^ 14 | data.nunique(dropna=True) != 1 15 | data.nunique(dropna=False) != 1 | -PD101.py:14:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:14:1 | 12 | data.nunique(dropna=False) == 1 13 | data.nunique() != 1 14 | data.nunique(dropna=True) != 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | data.nunique(dropna=False) != 1 16 | data.nunique() > 1 | -PD101.py:15:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:15:1 | 13 | data.nunique() != 1 14 | data.nunique(dropna=True) != 1 15 | data.nunique(dropna=False) != 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | data.nunique() > 1 17 | data.dropna().nunique() == 1 | -PD101.py:16:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:16:1 | 14 | data.nunique(dropna=True) != 1 15 | data.nunique(dropna=False) != 1 16 | data.nunique() > 1 - | ^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^ 17 | data.dropna().nunique() == 1 18 | data[data.notnull()].nunique() == 1 | -PD101.py:17:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:17:1 | 15 | data.nunique(dropna=False) != 1 16 | data.nunique() > 1 17 | data.dropna().nunique() == 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | data[data.notnull()].nunique() == 1 | -PD101.py:18:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient +PD101 Using `series.nunique()` for checking that a series is constant is inefficient + --> PD101.py:18:1 | 16 | data.nunique() > 1 17 | data.dropna().nunique() == 1 18 | data[data.notnull()].nunique() == 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # No violation of this rule | diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_fail_df_var.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_fail_df_var.snap index ac07ab731d..3463a135e4 100644 --- a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_fail_df_var.snap +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_fail_df_var.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pandas_vet/mod.rs -snapshot_kind: text --- -:3:1: PD901 Avoid using the generic variable name `df` for DataFrames +PD901 Avoid using the generic variable name `df` for DataFrames + --> :3:1 | 2 | import pandas as pd 3 | df = pd.DataFrame() - | ^^ PD901 + | ^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N801_N801.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N801_N801.py.snap index e24976a5fa..7df6768d60 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N801_N801.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N801_N801.py.snap @@ -1,55 +1,62 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N801.py:1:7: N801 Class name `bad` should use CapWords convention +N801 Class name `bad` should use CapWords convention + --> N801.py:1:7 | 1 | class bad: - | ^^^ N801 + | ^^^ 2 | pass | -N801.py:5:7: N801 Class name `_bad` should use CapWords convention +N801 Class name `_bad` should use CapWords convention + --> N801.py:5:7 | 5 | class _bad: - | ^^^^ N801 + | ^^^^ 6 | pass | -N801.py:9:7: N801 Class name `__bad` should use CapWords convention +N801 Class name `__bad` should use CapWords convention + --> N801.py:9:7 | 9 | class __bad: - | ^^^^^ N801 + | ^^^^^ 10 | pass | -N801.py:13:7: N801 Class name `bad_class` should use CapWords convention +N801 Class name `bad_class` should use CapWords convention + --> N801.py:13:7 | 13 | class bad_class: - | ^^^^^^^^^ N801 + | ^^^^^^^^^ 14 | pass | -N801.py:17:7: N801 Class name `Bad_Class` should use CapWords convention +N801 Class name `Bad_Class` should use CapWords convention + --> N801.py:17:7 | 17 | class Bad_Class: - | ^^^^^^^^^ N801 + | ^^^^^^^^^ 18 | pass | -N801.py:20:7: N801 Class name `Bad__Class` should use CapWords convention +N801 Class name `Bad__Class` should use CapWords convention + --> N801.py:20:7 | 18 | pass 19 | 20 | class Bad__Class: - | ^^^^^^^^^^ N801 + | ^^^^^^^^^^ 21 | pass | -N801.py:23:7: N801 Class name `BAD_CLASS` should use CapWords convention +N801 Class name `BAD_CLASS` should use CapWords convention + --> N801.py:23:7 | 21 | pass 22 | 23 | class BAD_CLASS: - | ^^^^^^^^^ N801 + | ^^^^^^^^^ 24 | pass | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap index dbcf6d8abe..a377df9606 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap @@ -1,75 +1,84 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N802.py:4:5: N802 Function name `Bad` should be lowercase +N802 Function name `Bad` should be lowercase + --> N802.py:4:5 | 4 | def Bad(): - | ^^^ N802 + | ^^^ 5 | pass | -N802.py:8:5: N802 Function name `_Bad` should be lowercase +N802 Function name `_Bad` should be lowercase + --> N802.py:8:5 | 8 | def _Bad(): - | ^^^^ N802 + | ^^^^ 9 | pass | -N802.py:12:5: N802 Function name `BAD` should be lowercase +N802 Function name `BAD` should be lowercase + --> N802.py:12:5 | 12 | def BAD(): - | ^^^ N802 + | ^^^ 13 | pass | -N802.py:16:5: N802 Function name `BAD_FUNC` should be lowercase +N802 Function name `BAD_FUNC` should be lowercase + --> N802.py:16:5 | 16 | def BAD_FUNC(): - | ^^^^^^^^ N802 + | ^^^^^^^^ 17 | pass | -N802.py:40:9: N802 Function name `testTest` should be lowercase +N802 Function name `testTest` should be lowercase + --> N802.py:40:9 | 38 | return super().tearDown() 39 | 40 | def testTest(self): - | ^^^^^^^^ N802 + | ^^^^^^^^ 41 | assert True | -N802.py:65:9: N802 Function name `bad_Name` should be lowercase +N802 Function name `bad_Name` should be lowercase + --> N802.py:65:9 | 63 | pass 64 | 65 | def bad_Name(self): - | ^^^^^^^^ N802 + | ^^^^^^^^ 66 | pass | -N802.py:84:9: N802 Function name `dont_GET` should be lowercase +N802 Function name `dont_GET` should be lowercase + --> N802.py:84:9 | 82 | pass 83 | 84 | def dont_GET(self): - | ^^^^^^^^ N802 + | ^^^^^^^^ 85 | pass | -N802.py:95:9: N802 Function name `dont_OPTIONS` should be lowercase +N802 Function name `dont_OPTIONS` should be lowercase + --> N802.py:95:9 | 93 | pass 94 | 95 | def dont_OPTIONS(self): - | ^^^^^^^^^^^^ N802 + | ^^^^^^^^^^^^ 96 | pass | -N802.py:106:9: N802 Function name `dont_OPTIONS` should be lowercase +N802 Function name `dont_OPTIONS` should be lowercase + --> N802.py:106:9 | 104 | pass 105 | 106 | def dont_OPTIONS(self): - | ^^^^^^^^^^^^ N802 + | ^^^^^^^^^^^^ 107 | pass | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N803_N803.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N803_N803.py.snap index d8f2c61cd6..b0a87e09ef 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N803_N803.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N803_N803.py.snap @@ -1,37 +1,42 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N803.py:1:16: N803 Argument name `A` should be lowercase +N803 Argument name `A` should be lowercase + --> N803.py:1:16 | 1 | def func(_, a, A): - | ^ N803 + | ^ 2 | return _, a, A | -N803.py:6:28: N803 Argument name `A` should be lowercase +N803 Argument name `A` should be lowercase + --> N803.py:6:28 | 5 | class Class: 6 | def method(self, _, a, A): - | ^ N803 + | ^ 7 | return _, a, A | -N803.py:22:16: N803 Argument name `A` should be lowercase +N803 Argument name `A` should be lowercase + --> N803.py:22:16 | 21 | @override # Incorrect usage 22 | def func(_, a, A): ... - | ^ N803 + | ^ | -N803.py:25:21: N803 Argument name `A` should be lowercase +N803 Argument name `A` should be lowercase + --> N803.py:25:21 | 25 | func = lambda _, a, A: ... - | ^ N803 + | ^ | -N803.py:29:42: N803 Argument name `A` should be lowercase +N803 Argument name `A` should be lowercase + --> N803.py:29:42 | 28 | class Extended(Class): 29 | method = override(lambda self, _, a, A: ...) # Incorrect usage - | ^ N803 + | ^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap index 79cd708650..2e7927936b 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N804.py:30:27: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:30:27 | 28 | ... 29 | 30 | def __init_subclass__(self, default_name, **kwargs): - | ^^^^ N804 + | ^^^^ 31 | ... | - = help: Rename `self` to `cls` +help: Rename `self` to `cls` ℹ Unsafe fix 27 27 | def __new__(cls, *args, **kwargs): @@ -21,14 +22,15 @@ N804.py:30:27: N804 [*] First argument of a class method should be named `cls` 32 32 | 33 33 | @classmethod -N804.py:38:56: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:38:56 | 37 | @classmethod 38 | def bad_class_method_with_positional_only_argument(self, x, /, other): - | ^^^^ N804 + | ^^^^ 39 | ... | - = help: Rename `self` to `cls` +help: Rename `self` to `cls` ℹ Unsafe fix 35 35 | ... @@ -40,14 +42,15 @@ N804.py:38:56: N804 [*] First argument of a class method should be named `cls` 40 40 | 41 41 | -N804.py:43:20: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:43:20 | 42 | class MetaClass(ABCMeta): 43 | def bad_method(self): - | ^^^^ N804 + | ^^^^ 44 | pass | - = help: Rename `self` to `cls` +help: Rename `self` to `cls` ℹ Unsafe fix 40 40 | @@ -59,64 +62,70 @@ N804.py:43:20: N804 [*] First argument of a class method should be named `cls` 45 45 | 46 46 | def good_method(cls): -N804.py:54:25: N804 First argument of a class method should be named `cls` +N804 First argument of a class method should be named `cls` + --> N804.py:54:25 | 53 | class ClsInArgsClass(ABCMeta): 54 | def cls_as_argument(this, cls): - | ^^^^ N804 + | ^^^^ 55 | pass | - = help: Rename `this` to `cls` +help: Rename `this` to `cls` -N804.py:57:34: N804 First argument of a class method should be named `cls` +N804 First argument of a class method should be named `cls` + --> N804.py:57:34 | 55 | pass 56 | 57 | def cls_as_pos_only_argument(this, cls, /): - | ^^^^ N804 + | ^^^^ 58 | pass | - = help: Rename `this` to `cls` +help: Rename `this` to `cls` -N804.py:60:33: N804 First argument of a class method should be named `cls` +N804 First argument of a class method should be named `cls` + --> N804.py:60:33 | 58 | pass 59 | 60 | def cls_as_kw_only_argument(this, *, cls): - | ^^^^ N804 + | ^^^^ 61 | pass | - = help: Rename `this` to `cls` +help: Rename `this` to `cls` -N804.py:63:23: N804 First argument of a class method should be named `cls` +N804 First argument of a class method should be named `cls` + --> N804.py:63:23 | 61 | pass 62 | 63 | def cls_as_varags(this, *cls): - | ^^^^ N804 + | ^^^^ 64 | pass | - = help: Rename `this` to `cls` +help: Rename `this` to `cls` -N804.py:66:23: N804 First argument of a class method should be named `cls` +N804 First argument of a class method should be named `cls` + --> N804.py:66:23 | 64 | pass 65 | 66 | def cls_as_kwargs(this, **cls): - | ^^^^ N804 + | ^^^^ 67 | pass | - = help: Rename `this` to `cls` +help: Rename `this` to `cls` -N804.py:70:20: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:70:20 | 69 | class RenamingInMethodBodyClass(ABCMeta): 70 | def bad_method(this): - | ^^^^ N804 + | ^^^^ 71 | this = this 72 | this | - = help: Rename `this` to `cls` +help: Rename `this` to `cls` ℹ Unsafe fix 67 67 | pass @@ -132,15 +141,16 @@ N804.py:70:20: N804 [*] First argument of a class method should be named `cls` 74 74 | def bad_method(this): 75 75 | self = this -N804.py:74:20: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:74:20 | 72 | this 73 | 74 | def bad_method(this): - | ^^^^ N804 + | ^^^^ 75 | self = this | - = help: Rename `this` to `cls` +help: Rename `this` to `cls` ℹ Unsafe fix 71 71 | this = this @@ -154,12 +164,13 @@ N804.py:74:20: N804 [*] First argument of a class method should be named `cls` 77 77 | def func(x): 78 78 | return x -N804.py:88:18: N804 First argument of a class method should be named `cls` +N804 First argument of a class method should be named `cls` + --> N804.py:88:18 | 86 | class Example: 87 | @classmethod 88 | def function(this): - | ^^^^ N804 + | ^^^^ 89 | cls = 1234 | - = help: Rename `this` to `cls` +help: Rename `this` to `cls` diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap index 27e3b3262c..67d2b6cb40 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N805.py:7:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:7:20 | 6 | class Class: 7 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 8 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 4 4 | @@ -20,14 +21,15 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` 9 9 | 10 10 | if False: -N805.py:11:30: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:11:30 | 10 | if False: 11 | def extra_bad_method(this): - | ^^^^ N805 + | ^^^^ 12 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 8 8 | pass @@ -39,14 +41,15 @@ N805.py:11:30: N805 [*] First argument of a method should be named `self` 13 13 | 14 14 | def good_method(self): -N805.py:30:15: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:30:15 | 29 | @pydantic.validator 30 | def lower(cls, my_field: str) -> str: - | ^^^ N805 + | ^^^ 31 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 27 27 | return x @@ -58,14 +61,15 @@ N805.py:30:15: N805 [*] First argument of a method should be named `self` 32 32 | 33 33 | @pydantic.validator("my_field") -N805.py:34:15: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:34:15 | 33 | @pydantic.validator("my_field") 34 | def lower(cls, my_field: str) -> str: - | ^^^ N805 + | ^^^ 35 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 31 31 | pass @@ -77,15 +81,16 @@ N805.py:34:15: N805 [*] First argument of a method should be named `self` 36 36 | 37 37 | def __init__(self): -N805.py:63:29: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:63:29 | 61 | pass 62 | 63 | def bad_method_pos_only(this, blah, /, something: str): - | ^^^^ N805 + | ^^^^ 64 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 60 60 | def good_method_pos_only(self, blah, /, something: str): @@ -97,15 +102,16 @@ N805.py:63:29: N805 [*] First argument of a method should be named `self` 65 65 | 66 66 | -N805.py:69:13: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:69:13 | 67 | class ModelClass: 68 | @hybrid_property 69 | def bad(cls): - | ^^^ N805 + | ^^^ 70 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 66 66 | @@ -117,14 +123,15 @@ N805.py:69:13: N805 [*] First argument of a method should be named `self` 71 71 | 72 72 | @bad.expression -N805.py:77:13: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:77:13 | 76 | @bad.wtf 77 | def bad(cls): - | ^^^ N805 + | ^^^ 78 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 74 74 | pass @@ -136,14 +143,15 @@ N805.py:77:13: N805 [*] First argument of a method should be named `self` 79 79 | 80 80 | @hybrid_property -N805.py:85:14: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:85:14 | 84 | @good.expression 85 | def good(cls): - | ^^^ N805 + | ^^^ 86 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 82 82 | pass @@ -155,14 +163,15 @@ N805.py:85:14: N805 [*] First argument of a method should be named `self` 87 87 | 88 88 | @good.wtf -N805.py:93:19: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:93:19 | 92 | @foobar.thisisstatic 93 | def badstatic(foo): - | ^^^ N805 + | ^^^ 94 | pass | - = help: Rename `foo` to `self` +help: Rename `foo` to `self` ℹ Unsafe fix 90 90 | pass @@ -174,64 +183,70 @@ N805.py:93:19: N805 [*] First argument of a method should be named `self` 95 95 | 96 96 | -N805.py:98:26: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:98:26 | 97 | class SelfInArgsClass: 98 | def self_as_argument(this, self): - | ^^^^ N805 + | ^^^^ 99 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:101:35: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:101:35 | 99 | pass 100 | 101 | def self_as_pos_only_argument(this, self, /): - | ^^^^ N805 + | ^^^^ 102 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:104:34: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:104:34 | 102 | pass 103 | 104 | def self_as_kw_only_argument(this, *, self): - | ^^^^ N805 + | ^^^^ 105 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:107:24: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:107:24 | 105 | pass 106 | 107 | def self_as_varags(this, *self): - | ^^^^ N805 + | ^^^^ 108 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:110:24: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:110:24 | 108 | pass 109 | 110 | def self_as_kwargs(this, **self): - | ^^^^ N805 + | ^^^^ 111 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:115:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:115:20 | 114 | class RenamingInMethodBodyClass: 115 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 116 | this = this 117 | this | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 112 112 | @@ -247,24 +262,26 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` 119 119 | def bad_method(this): 120 120 | self = this -N805.py:119:20: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:119:20 | 117 | this 118 | 119 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 120 | self = this | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:124:17: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:124:17 | 123 | class RenamingWithNFKC: 124 | def formula(household): - | ^^^^^^^^^ N805 + | ^^^^^^^^^ 125 | hºusehold(1) | - = help: Rename `household` to `self` +help: Rename `household` to `self` ℹ Unsafe fix 121 121 | @@ -278,12 +295,13 @@ N805.py:124:17: N805 [*] First argument of a method should be named `self` 127 127 | 128 128 | from typing import Protocol -N805.py:141:11: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:141:11 | 139 | # https://github.com/astral-sh/ruff/issues/18459 140 | class C: 141 | def f(this): - | ^^^^ N805 + | ^^^^ 142 | self = 123 | - = help: Rename `this` to `self` +help: Rename `this` to `self` diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap index 1dbb26dd54..78a1a7352e 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap @@ -1,64 +1,71 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N806.py:12:5: N806 Variable `Camel` in function should be lowercase +N806 Variable `Camel` in function should be lowercase + --> N806.py:12:5 | 10 | GLOBAL = "bar" 11 | lower = 0 12 | Camel = 0 - | ^^^^^ N806 + | ^^^^^ 13 | CONSTANT = 0 14 | _ = 0 | -N806.py:13:5: N806 Variable `CONSTANT` in function should be lowercase +N806 Variable `CONSTANT` in function should be lowercase + --> N806.py:13:5 | 11 | lower = 0 12 | Camel = 0 13 | CONSTANT = 0 - | ^^^^^^^^ N806 + | ^^^^^^^^ 14 | _ = 0 | -N806.py:46:5: N806 Variable `Bad` in function should be lowercase +N806 Variable `Bad` in function should be lowercase + --> N806.py:46:5 | 45 | def model_assign() -> None: 46 | Bad = apps.get_model("zerver", "Stream") # N806 - | ^^^ N806 + | ^^^ 47 | Attachment = apps.get_model("zerver", "Attachment") # OK 48 | Recipient = apps.get_model("zerver", model_name="Recipient") # OK | -N806.py:53:5: N806 Variable `Bad` in function should be lowercase +N806 Variable `Bad` in function should be lowercase + --> N806.py:53:5 | 51 | from django.utils.module_loading import import_string 52 | 53 | Bad = import_string("django.core.exceptions.ValidationError") # N806 - | ^^^ N806 + | ^^^ 54 | ValidationError = import_string("django.core.exceptions.ValidationError") # OK | -N806.py:56:5: N806 Variable `Bad` in function should be lowercase +N806 Variable `Bad` in function should be lowercase + --> N806.py:56:5 | 54 | ValidationError = import_string("django.core.exceptions.ValidationError") # OK 55 | 56 | Bad = apps.get_model() # N806 - | ^^^ N806 + | ^^^ 57 | Bad = apps.get_model(model_name="Stream") # N806 | -N806.py:57:5: N806 Variable `Bad` in function should be lowercase +N806 Variable `Bad` in function should be lowercase + --> N806.py:57:5 | 56 | Bad = apps.get_model() # N806 57 | Bad = apps.get_model(model_name="Stream") # N806 - | ^^^ N806 + | ^^^ 58 | 59 | Address: Type = apps.get_model("zerver", variable) # OK | -N806.py:60:5: N806 Variable `ValidationError` in function should be lowercase +N806 Variable `ValidationError` in function should be lowercase + --> N806.py:60:5 | 59 | Address: Type = apps.get_model("zerver", variable) # OK 60 | ValidationError = import_string(variable) # N806 - | ^^^^^^^^^^^^^^^ N806 + | ^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N807_N807.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N807_N807.py.snap index e6b7da8dbe..c132ee7cd6 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N807_N807.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N807_N807.py.snap @@ -1,18 +1,19 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -N807.py:1:5: N807 Function name should not start and end with `__` +N807 Function name should not start and end with `__` + --> N807.py:1:5 | 1 | def __bad__(): - | ^^^^^^^ N807 + | ^^^^^^^ 2 | pass | -N807.py:14:9: N807 Function name should not start and end with `__` +N807 Function name should not start and end with `__` + --> N807.py:14:9 | 13 | def nested(): 14 | def __bad__(): - | ^^^^^^^ N807 + | ^^^^^^^ 15 | pass | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap index c874ee2ad8..eb276a3c35 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap @@ -1,48 +1,53 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N811.py:1:8: N811 Constant `CONST` imported as non-constant `const` +N811 Constant `CONST` imported as non-constant `const` + --> N811.py:1:8 | 1 | import mod.CONST as const - | ^^^^^^^^^^^^^^^^^^ N811 + | ^^^^^^^^^^^^^^^^^^ 2 | from mod import CONSTANT as constant 3 | from mod import ANOTHER_CONSTANT as another_constant | -N811.py:2:17: N811 Constant `CONSTANT` imported as non-constant `constant` +N811 Constant `CONSTANT` imported as non-constant `constant` + --> N811.py:2:17 | 1 | import mod.CONST as const 2 | from mod import CONSTANT as constant - | ^^^^^^^^^^^^^^^^^^^^ N811 + | ^^^^^^^^^^^^^^^^^^^^ 3 | from mod import ANOTHER_CONSTANT as another_constant 4 | import mod.CON as c | -N811.py:3:17: N811 Constant `ANOTHER_CONSTANT` imported as non-constant `another_constant` +N811 Constant `ANOTHER_CONSTANT` imported as non-constant `another_constant` + --> N811.py:3:17 | 1 | import mod.CONST as const 2 | from mod import CONSTANT as constant 3 | from mod import ANOTHER_CONSTANT as another_constant - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N811 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | import mod.CON as c 5 | from mod import C as c | -N811.py:4:8: N811 Constant `CON` imported as non-constant `c` +N811 Constant `CON` imported as non-constant `c` + --> N811.py:4:8 | 2 | from mod import CONSTANT as constant 3 | from mod import ANOTHER_CONSTANT as another_constant 4 | import mod.CON as c - | ^^^^^^^^^^^^ N811 + | ^^^^^^^^^^^^ 5 | from mod import C as c | -N811.py:5:17: N811 Constant `C` imported as non-constant `c` +N811 Constant `C` imported as non-constant `c` + --> N811.py:5:17 | 3 | from mod import ANOTHER_CONSTANT as another_constant 4 | import mod.CON as c 5 | from mod import C as c - | ^^^^^^ N811 + | ^^^^^^ 6 | 7 | # These are all OK: | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N812_N812.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N812_N812.py.snap index 3c82aa5167..b59c063630 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N812_N812.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N812_N812.py.snap @@ -1,27 +1,29 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -N812.py:1:8: N812 Lowercase `lowercase` imported as non-lowercase `Lower` +N812 Lowercase `lowercase` imported as non-lowercase `Lower` + --> N812.py:1:8 | 1 | import modl.lowercase as Lower - | ^^^^^^^^^^^^^^^^^^^^^^^ N812 + | ^^^^^^^^^^^^^^^^^^^^^^^ 2 | from mod import lowercase as Lowercase 3 | from mod import another_lowercase as AnotherLowercase | -N812.py:2:17: N812 Lowercase `lowercase` imported as non-lowercase `Lowercase` +N812 Lowercase `lowercase` imported as non-lowercase `Lowercase` + --> N812.py:2:17 | 1 | import modl.lowercase as Lower 2 | from mod import lowercase as Lowercase - | ^^^^^^^^^^^^^^^^^^^^^^ N812 + | ^^^^^^^^^^^^^^^^^^^^^^ 3 | from mod import another_lowercase as AnotherLowercase | -N812.py:3:17: N812 Lowercase `another_lowercase` imported as non-lowercase `AnotherLowercase` +N812 Lowercase `another_lowercase` imported as non-lowercase `AnotherLowercase` + --> N812.py:3:17 | 1 | import modl.lowercase as Lower 2 | from mod import lowercase as Lowercase 3 | from mod import another_lowercase as AnotherLowercase - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N812 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N813_N813.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N813_N813.py.snap index b98af29bf0..1441706089 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N813_N813.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N813_N813.py.snap @@ -1,27 +1,29 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -N813.py:1:8: N813 Camelcase `Camel` imported as lowercase `camel` +N813 Camelcase `Camel` imported as lowercase `camel` + --> N813.py:1:8 | 1 | import mod.Camel as camel - | ^^^^^^^^^^^^^^^^^^ N813 + | ^^^^^^^^^^^^^^^^^^ 2 | from mod import CamelCase as camelcase 3 | from mod import AnotherCamelCase as another_camelcase | -N813.py:2:17: N813 Camelcase `CamelCase` imported as lowercase `camelcase` +N813 Camelcase `CamelCase` imported as lowercase `camelcase` + --> N813.py:2:17 | 1 | import mod.Camel as camel 2 | from mod import CamelCase as camelcase - | ^^^^^^^^^^^^^^^^^^^^^^ N813 + | ^^^^^^^^^^^^^^^^^^^^^^ 3 | from mod import AnotherCamelCase as another_camelcase | -N813.py:3:17: N813 Camelcase `AnotherCamelCase` imported as lowercase `another_camelcase` +N813 Camelcase `AnotherCamelCase` imported as lowercase `another_camelcase` + --> N813.py:3:17 | 1 | import mod.Camel as camel 2 | from mod import CamelCase as camelcase 3 | from mod import AnotherCamelCase as another_camelcase - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N813 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap index ab73bb36f1..1b5d2ed966 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap @@ -1,28 +1,31 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N814.py:1:8: N814 Camelcase `Camel` imported as constant `CAMEL` +N814 Camelcase `Camel` imported as constant `CAMEL` + --> N814.py:1:8 | 1 | import mod.Camel as CAMEL - | ^^^^^^^^^^^^^^^^^^ N814 + | ^^^^^^^^^^^^^^^^^^ 2 | from mod import CamelCase as CAMELCASE 3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE | -N814.py:2:17: N814 Camelcase `CamelCase` imported as constant `CAMELCASE` +N814 Camelcase `CamelCase` imported as constant `CAMELCASE` + --> N814.py:2:17 | 1 | import mod.Camel as CAMEL 2 | from mod import CamelCase as CAMELCASE - | ^^^^^^^^^^^^^^^^^^^^^^ N814 + | ^^^^^^^^^^^^^^^^^^^^^^ 3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE | -N814.py:3:17: N814 Camelcase `AnotherCamelCase` imported as constant `ANOTHER_CAMELCASE` +N814 Camelcase `AnotherCamelCase` imported as constant `ANOTHER_CAMELCASE` + --> N814.py:3:17 | 1 | import mod.Camel as CAMEL 2 | from mod import CamelCase as CAMELCASE 3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N814 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | # These are all OK: | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N815_N815.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N815_N815.py.snap index 1add362957..cece8df290 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N815_N815.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N815_N815.py.snap @@ -1,33 +1,35 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -N815.py:9:5: N815 Variable `mixedCase` in class scope should not be mixedCase +N815 Variable `mixedCase` in class scope should not be mixedCase + --> N815.py:9:5 | 7 | lower = 0 8 | CONSTANT = 0 9 | mixedCase = 0 - | ^^^^^^^^^ N815 + | ^^^^^^^^^ 10 | _mixedCase = 0 11 | mixed_Case = 0 | -N815.py:10:5: N815 Variable `_mixedCase` in class scope should not be mixedCase +N815 Variable `_mixedCase` in class scope should not be mixedCase + --> N815.py:10:5 | 8 | CONSTANT = 0 9 | mixedCase = 0 10 | _mixedCase = 0 - | ^^^^^^^^^^ N815 + | ^^^^^^^^^^ 11 | mixed_Case = 0 12 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) | -N815.py:11:5: N815 Variable `mixed_Case` in class scope should not be mixedCase +N815 Variable `mixed_Case` in class scope should not be mixedCase + --> N815.py:11:5 | 9 | mixedCase = 0 10 | _mixedCase = 0 11 | mixed_Case = 0 - | ^^^^^^^^^^ N815 + | ^^^^^^^^^^ 12 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) 13 | myObj2 = namedtuple("MyObj2", ["a", "b"]) | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N816_N816.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N816_N816.py.snap index 3f49a15856..17cc81d0cb 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N816_N816.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N816_N816.py.snap @@ -1,33 +1,35 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -N816.py:7:1: N816 Variable `mixedCase` in global scope should not be mixedCase +N816 Variable `mixedCase` in global scope should not be mixedCase + --> N816.py:7:1 | 5 | lower = 0 6 | CONSTANT = 0 7 | mixedCase = 0 - | ^^^^^^^^^ N816 + | ^^^^^^^^^ 8 | _mixedCase = 0 9 | mixed_Case = 0 | -N816.py:8:1: N816 Variable `_mixedCase` in global scope should not be mixedCase +N816 Variable `_mixedCase` in global scope should not be mixedCase + --> N816.py:8:1 | 6 | CONSTANT = 0 7 | mixedCase = 0 8 | _mixedCase = 0 - | ^^^^^^^^^^ N816 + | ^^^^^^^^^^ 9 | mixed_Case = 0 10 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) | -N816.py:9:1: N816 Variable `mixed_Case` in global scope should not be mixedCase +N816 Variable `mixed_Case` in global scope should not be mixedCase + --> N816.py:9:1 | 7 | mixedCase = 0 8 | _mixedCase = 0 9 | mixed_Case = 0 - | ^^^^^^^^^^ N816 + | ^^^^^^^^^^ 10 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) 11 | myObj2 = namedtuple("MyObj2", ["a", "b"]) | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N817_N817.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N817_N817.py.snap index 5d2eee85fe..0d905c23c3 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N817_N817.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N817_N817.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -N817.py:1:8: N817 CamelCase `CaMel` imported as acronym `CM` +N817 CamelCase `CaMel` imported as acronym `CM` + --> N817.py:1:8 | 1 | import mod.CaMel as CM - | ^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^ 2 | from mod import CamelCase as CC | -N817.py:2:17: N817 CamelCase `CamelCase` imported as acronym `CC` +N817 CamelCase `CamelCase` imported as acronym `CC` + --> N817.py:2:17 | 1 | import mod.CaMel as CM 2 | from mod import CamelCase as CC - | ^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^ | -N817.py:10:26: N817 CamelCase `ElementTree` imported as acronym `ET` +N817 CamelCase `ElementTree` imported as acronym `ET` + --> N817.py:10:26 | 9 | # Always an error (relative import) 10 | from ..xml.eltree import ElementTree as ET - | ^^^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N818_N818.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N818_N818.py.snap index ce8fa62812..e57941048b 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N818_N818.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N818_N818.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -N818.py:9:7: N818 Exception name `C` should be named with an Error suffix +N818 Exception name `C` should be named with an Error suffix + --> N818.py:9:7 | 9 | class C(Exception): - | ^ N818 + | ^ 10 | pass | -N818.py:17:7: N818 Exception name `E` should be named with an Error suffix +N818 Exception name `E` should be named with an Error suffix + --> N818.py:17:7 | 17 | class E(AnotherError): - | ^ N818 + | ^ 18 | pass | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap index 6bd42f3740..18fa0c4057 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -__init__.py:1:1: N999 Invalid module name: 'MODULE' +N999 Invalid module name: 'MODULE' +--> __init__.py:1:1 diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap index 84b2c0d8c4..c5ca542998 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -0001_initial.py:1:1: N999 Invalid module name: '0001_initial' +N999 Invalid module name: '0001_initial' +--> 0001_initial.py:1:1 diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap index 6515383d63..addc24aa57 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -import.py:1:1: N999 Invalid module name: 'import' +N999 Invalid module name: 'import' +--> import.py:1:1 diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap index b0c2fe5f67..1d39aa6a2f 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -__init__.py:1:1: N999 Invalid module name: 'mod with spaces' +N999 Invalid module name: 'mod with spaces' +--> __init__.py:1:1 diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap index 2a8ef3bd53..b3175a462c 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -__init__.py:1:1: N999 Invalid module name: 'mod-with-dashes' +N999 Invalid module name: 'mod-with-dashes' +--> __init__.py:1:1 diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap index 85da15535d..df30fdded7 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs -snapshot_kind: text --- -file-with-dashes.py:1:1: N999 Invalid module name: 'file-with-dashes' +N999 Invalid module name: 'file-with-dashes' +--> file-with-dashes.py:1:1 diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__camelcase_imported_as_incorrect_convention.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__camelcase_imported_as_incorrect_convention.snap index dfcf9d31f5..4899f2a8c7 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__camelcase_imported_as_incorrect_convention.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__camelcase_imported_as_incorrect_convention.snap @@ -1,41 +1,46 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N817.py:1:8: N817 CamelCase `CaMel` imported as acronym `CM` +N817 CamelCase `CaMel` imported as acronym `CM` + --> N817.py:1:8 | 1 | import mod.CaMel as CM - | ^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^ 2 | from mod import CamelCase as CC | -N817.py:2:17: N817 CamelCase `CamelCase` imported as acronym `CC` +N817 CamelCase `CamelCase` imported as acronym `CC` + --> N817.py:2:17 | 1 | import mod.CaMel as CM 2 | from mod import CamelCase as CC - | ^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^ | -N817.py:6:8: N817 CamelCase `ElementTree` imported as acronym `ET` +N817 CamelCase `ElementTree` imported as acronym `ET` + --> N817.py:6:8 | 5 | # OK depending on configured import convention 6 | import xml.etree.ElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | from xml.etree import ElementTree as ET | -N817.py:7:23: N817 CamelCase `ElementTree` imported as acronym `ET` +N817 CamelCase `ElementTree` imported as acronym `ET` + --> N817.py:7:23 | 5 | # OK depending on configured import convention 6 | import xml.etree.ElementTree as ET 7 | from xml.etree import ElementTree as ET - | ^^^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^^^ 8 | 9 | # Always an error (relative import) | -N817.py:10:26: N817 CamelCase `ElementTree` imported as acronym `ET` +N817 CamelCase `ElementTree` imported as acronym `ET` + --> N817.py:10:26 | 9 | # Always an error (relative import) 10 | from ..xml.eltree import ElementTree as ET - | ^^^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap index 94befdac59..ade14cb4e6 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N805.py:7:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:7:20 | 6 | class Class: 7 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 8 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 4 4 | @@ -20,14 +21,15 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` 9 9 | 10 10 | if False: -N805.py:11:30: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:11:30 | 10 | if False: 11 | def extra_bad_method(this): - | ^^^^ N805 + | ^^^^ 12 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 8 8 | pass @@ -39,15 +41,16 @@ N805.py:11:30: N805 [*] First argument of a method should be named `self` 13 13 | 14 14 | def good_method(self): -N805.py:63:29: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:63:29 | 61 | pass 62 | 63 | def bad_method_pos_only(this, blah, /, something: str): - | ^^^^ N805 + | ^^^^ 64 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 60 60 | def good_method_pos_only(self, blah, /, something: str): @@ -59,15 +62,16 @@ N805.py:63:29: N805 [*] First argument of a method should be named `self` 65 65 | 66 66 | -N805.py:69:13: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:69:13 | 67 | class ModelClass: 68 | @hybrid_property 69 | def bad(cls): - | ^^^ N805 + | ^^^ 70 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 66 66 | @@ -79,14 +83,15 @@ N805.py:69:13: N805 [*] First argument of a method should be named `self` 71 71 | 72 72 | @bad.expression -N805.py:77:13: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:77:13 | 76 | @bad.wtf 77 | def bad(cls): - | ^^^ N805 + | ^^^ 78 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 74 74 | pass @@ -98,14 +103,15 @@ N805.py:77:13: N805 [*] First argument of a method should be named `self` 79 79 | 80 80 | @hybrid_property -N805.py:93:19: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:93:19 | 92 | @foobar.thisisstatic 93 | def badstatic(foo): - | ^^^ N805 + | ^^^ 94 | pass | - = help: Rename `foo` to `self` +help: Rename `foo` to `self` ℹ Unsafe fix 90 90 | pass @@ -117,64 +123,70 @@ N805.py:93:19: N805 [*] First argument of a method should be named `self` 95 95 | 96 96 | -N805.py:98:26: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:98:26 | 97 | class SelfInArgsClass: 98 | def self_as_argument(this, self): - | ^^^^ N805 + | ^^^^ 99 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:101:35: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:101:35 | 99 | pass 100 | 101 | def self_as_pos_only_argument(this, self, /): - | ^^^^ N805 + | ^^^^ 102 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:104:34: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:104:34 | 102 | pass 103 | 104 | def self_as_kw_only_argument(this, *, self): - | ^^^^ N805 + | ^^^^ 105 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:107:24: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:107:24 | 105 | pass 106 | 107 | def self_as_varags(this, *self): - | ^^^^ N805 + | ^^^^ 108 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:110:24: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:110:24 | 108 | pass 109 | 110 | def self_as_kwargs(this, **self): - | ^^^^ N805 + | ^^^^ 111 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:115:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:115:20 | 114 | class RenamingInMethodBodyClass: 115 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 116 | this = this 117 | this | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 112 112 | @@ -190,24 +202,26 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` 119 119 | def bad_method(this): 120 120 | self = this -N805.py:119:20: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:119:20 | 117 | this 118 | 119 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 120 | self = this | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:124:17: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:124:17 | 123 | class RenamingWithNFKC: 124 | def formula(household): - | ^^^^^^^^^ N805 + | ^^^^^^^^^ 125 | hºusehold(1) | - = help: Rename `household` to `self` +help: Rename `household` to `self` ℹ Unsafe fix 121 121 | @@ -221,12 +235,13 @@ N805.py:124:17: N805 [*] First argument of a method should be named `self` 127 127 | 128 128 | from typing import Protocol -N805.py:141:11: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:141:11 | 139 | # https://github.com/astral-sh/ruff/issues/18459 140 | class C: 141 | def f(this): - | ^^^^ N805 + | ^^^^ 142 | self = 123 | - = help: Rename `this` to `self` +help: Rename `this` to `self` diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap index 24d123032c..851ef71704 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N801.py:4:7: N801 Class name `stillBad` should use CapWords convention +N801 Class name `stillBad` should use CapWords convention + --> N801.py:4:7 | 2 | pass 3 | 4 | class stillBad: - | ^^^^^^^^ N801 + | ^^^^^^^^ 5 | pass | -N801.py:10:7: N801 Class name `STILL_BAD` should use CapWords convention +N801 Class name `STILL_BAD` should use CapWords convention + --> N801.py:10:7 | 8 | pass 9 | 10 | class STILL_BAD: - | ^^^^^^^^^ N801 + | ^^^^^^^^^ 11 | pass | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap index 223636244b..9e74ba98da 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N802.py:6:5: N802 Function name `stillBad` should be lowercase +N802 Function name `stillBad` should be lowercase + --> N802.py:6:5 | 4 | pass 5 | 6 | def stillBad(): - | ^^^^^^^^ N802 + | ^^^^^^^^ 7 | pass | -N802.py:13:9: N802 Function name `stillBad` should be lowercase +N802 Function name `stillBad` should be lowercase + --> N802.py:13:9 | 11 | return super().tearDown() 12 | 13 | def stillBad(self): - | ^^^^^^^^ N802 + | ^^^^^^^^ 14 | return super().tearDown() | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap index 6eac6d5d8d..17512192fb 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N803.py:4:16: N803 Argument name `stillBad` should be lowercase +N803 Argument name `stillBad` should be lowercase + --> N803.py:4:16 | 2 | return _, a, badAllowed 3 | 4 | def func(_, a, stillBad): - | ^^^^^^^^ N803 + | ^^^^^^^^ 5 | return _, a, stillBad | -N803.py:11:28: N803 Argument name `stillBad` should be lowercase +N803 Argument name `stillBad` should be lowercase + --> N803.py:11:28 | 9 | return _, a, badAllowed 10 | 11 | def method(self, _, a, stillBad): - | ^^^^^^^^ N803 + | ^^^^^^^^ 12 | return _, a, stillBad | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap index 8afa86cd06..4f123be2e7 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N804.py:5:27: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:5:27 | 4 | class Class: 5 | def __init_subclass__(self, default_name, **kwargs): - | ^^^^ N804 + | ^^^^ 6 | ... | - = help: Rename `self` to `cls` +help: Rename `self` to `cls` ℹ Unsafe fix 2 2 | @@ -20,14 +21,15 @@ N804.py:5:27: N804 [*] First argument of a class method should be named `cls` 7 7 | 8 8 | @classmethod -N804.py:9:20: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:9:20 | 8 | @classmethod 9 | def badAllowed(self, x, /, other): - | ^^^^ N804 + | ^^^^ 10 | ... | - = help: Rename `self` to `cls` +help: Rename `self` to `cls` ℹ Unsafe fix 6 6 | ... @@ -39,14 +41,15 @@ N804.py:9:20: N804 [*] First argument of a class method should be named `cls` 11 11 | 12 12 | @classmethod -N804.py:13:18: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:13:18 | 12 | @classmethod 13 | def stillBad(self, x, /, other): - | ^^^^ N804 + | ^^^^ 14 | ... | - = help: Rename `self` to `cls` +help: Rename `self` to `cls` ℹ Unsafe fix 10 10 | ... @@ -58,14 +61,15 @@ N804.py:13:18: N804 [*] First argument of a class method should be named `cls` 15 15 | 16 16 | -N804.py:18:20: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:18:20 | 17 | class MetaClass(ABCMeta): 18 | def badAllowed(self): - | ^^^^ N804 + | ^^^^ 19 | pass | - = help: Rename `self` to `cls` +help: Rename `self` to `cls` ℹ Unsafe fix 15 15 | @@ -77,15 +81,16 @@ N804.py:18:20: N804 [*] First argument of a class method should be named `cls` 20 20 | 21 21 | def stillBad(self): -N804.py:21:18: N804 [*] First argument of a class method should be named `cls` +N804 [*] First argument of a class method should be named `cls` + --> N804.py:21:18 | 19 | pass 20 | 21 | def stillBad(self): - | ^^^^ N804 + | ^^^^ 22 | pass | - = help: Rename `self` to `cls` +help: Rename `self` to `cls` ℹ Unsafe fix 18 18 | def badAllowed(self): diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap index f6ed863145..94c5871ea8 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N805.py:7:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:7:20 | 6 | class Class: 7 | def badAllowed(this): - | ^^^^ N805 + | ^^^^ 8 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 4 4 | @@ -20,15 +21,16 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` 9 9 | 10 10 | def stillBad(this): -N805.py:10:18: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:10:18 | 8 | pass 9 | 10 | def stillBad(this): - | ^^^^ N805 + | ^^^^ 11 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 7 7 | def badAllowed(this): @@ -40,15 +42,16 @@ N805.py:10:18: N805 [*] First argument of a method should be named `self` 12 12 | 13 13 | if False: -N805.py:15:24: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:15:24 | 13 | if False: 14 | 15 | def badAllowed(this): - | ^^^^ N805 + | ^^^^ 16 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 12 12 | @@ -60,15 +63,16 @@ N805.py:15:24: N805 [*] First argument of a method should be named `self` 17 17 | 18 18 | def stillBad(this): -N805.py:18:22: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:18:22 | 16 | pass 17 | 18 | def stillBad(this): - | ^^^^ N805 + | ^^^^ 19 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 15 15 | def badAllowed(this): @@ -80,14 +84,15 @@ N805.py:18:22: N805 [*] First argument of a method should be named `self` 20 20 | 21 21 | @pydantic.validator -N805.py:22:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:22:20 | 21 | @pydantic.validator 22 | def badAllowed(cls, my_field: str) -> str: - | ^^^ N805 + | ^^^ 23 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 19 19 | pass @@ -99,14 +104,15 @@ N805.py:22:20: N805 [*] First argument of a method should be named `self` 24 24 | 25 25 | @pydantic.validator -N805.py:26:18: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:26:18 | 25 | @pydantic.validator 26 | def stillBad(cls, my_field: str) -> str: - | ^^^ N805 + | ^^^ 27 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 23 23 | pass @@ -118,14 +124,15 @@ N805.py:26:18: N805 [*] First argument of a method should be named `self` 28 28 | 29 29 | @pydantic.validator("my_field") -N805.py:30:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:30:20 | 29 | @pydantic.validator("my_field") 30 | def badAllowed(cls, my_field: str) -> str: - | ^^^ N805 + | ^^^ 31 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 27 27 | pass @@ -137,14 +144,15 @@ N805.py:30:20: N805 [*] First argument of a method should be named `self` 32 32 | 33 33 | @pydantic.validator("my_field") -N805.py:34:18: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:34:18 | 33 | @pydantic.validator("my_field") 34 | def stillBad(cls, my_field: str) -> str: - | ^^^ N805 + | ^^^ 35 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 31 31 | pass @@ -156,21 +164,23 @@ N805.py:34:18: N805 [*] First argument of a method should be named `self` 36 36 | 37 37 | @classmethod -N805.py:55:20: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:55:20 | 54 | class PosOnlyClass: 55 | def badAllowed(this, blah, /, self, something: str): - | ^^^^ N805 + | ^^^^ 56 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:58:18: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:58:18 | 56 | pass 57 | 58 | def stillBad(this, blah, /, self, something: str): - | ^^^^ N805 + | ^^^^ 59 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap index d5a3d42215..c23a98ed80 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap @@ -1,19 +1,21 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N806.py:3:5: N806 Variable `stillBad` in function should be lowercase +N806 Variable `stillBad` in function should be lowercase + --> N806.py:3:5 | 1 | def assign(): 2 | badAllowed = 0 3 | stillBad = 0 - | ^^^^^^^^ N806 + | ^^^^^^^^ 4 | 5 | BAD_ALLOWED = 0 | -N806.py:6:5: N806 Variable `STILL_BAD` in function should be lowercase +N806 Variable `STILL_BAD` in function should be lowercase + --> N806.py:6:5 | 5 | BAD_ALLOWED = 0 6 | STILL_BAD = 0 - | ^^^^^^^^^ N806 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap index c5de6c4f1f..0480b3a749 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N807.py:4:5: N807 Function name should not start and end with `__` +N807 Function name should not start and end with `__` + --> N807.py:4:5 | 2 | pass 3 | 4 | def __stillBad__(): - | ^^^^^^^^^^^^ N807 + | ^^^^^^^^^^^^ 5 | pass | -N807.py:12:9: N807 Function name should not start and end with `__` +N807 Function name should not start and end with `__` + --> N807.py:12:9 | 10 | pass 11 | 12 | def __stillBad__(): - | ^^^^^^^^^^^^ N807 + | ^^^^^^^^^^^^ 13 | pass | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap index bcd0ed596c..10ac76e53f 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N811.py:2:8: N811 Constant `STILL_BAD` imported as non-constant `stillBad` +N811 Constant `STILL_BAD` imported as non-constant `stillBad` + --> N811.py:2:8 | 1 | import mod.BAD_ALLOWED as badAllowed 2 | import mod.STILL_BAD as stillBad - | ^^^^^^^^^^^^^^^^^^^^^^^^^ N811 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | from mod import BAD_ALLOWED as badAllowed | -N811.py:5:17: N811 Constant `STILL_BAD` imported as non-constant `stillBad` +N811 Constant `STILL_BAD` imported as non-constant `stillBad` + --> N811.py:5:17 | 4 | from mod import BAD_ALLOWED as badAllowed 5 | from mod import STILL_BAD as stillBad - | ^^^^^^^^^^^^^^^^^^^^^ N811 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap index d198c0546e..326c27cf59 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N812.py:2:8: N812 Lowercase `stillbad` imported as non-lowercase `stillBad` +N812 Lowercase `stillbad` imported as non-lowercase `stillBad` + --> N812.py:2:8 | 1 | import mod.badallowed as badAllowed 2 | import mod.stillbad as stillBad - | ^^^^^^^^^^^^^^^^^^^^^^^^ N812 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | from mod import badallowed as BadAllowed | -N812.py:5:17: N812 Lowercase `stillbad` imported as non-lowercase `StillBad` +N812 Lowercase `stillbad` imported as non-lowercase `StillBad` + --> N812.py:5:17 | 4 | from mod import badallowed as BadAllowed 5 | from mod import stillbad as StillBad - | ^^^^^^^^^^^^^^^^^^^^ N812 + | ^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap index 021d450283..7c25edab92 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap @@ -1,27 +1,30 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N813.py:2:8: N813 Camelcase `stillBad` imported as lowercase `stillbad` +N813 Camelcase `stillBad` imported as lowercase `stillbad` + --> N813.py:2:8 | 1 | import mod.BadAllowed as badallowed 2 | import mod.stillBad as stillbad - | ^^^^^^^^^^^^^^^^^^^^^^^^ N813 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | from mod import BadAllowed as badallowed | -N813.py:5:17: N813 Camelcase `StillBad` imported as lowercase `stillbad` +N813 Camelcase `StillBad` imported as lowercase `stillbad` + --> N813.py:5:17 | 4 | from mod import BadAllowed as badallowed 5 | from mod import StillBad as stillbad - | ^^^^^^^^^^^^^^^^^^^^ N813 + | ^^^^^^^^^^^^^^^^^^^^ 6 | 7 | from mod import BadAllowed as bad_allowed | -N813.py:8:17: N813 Camelcase `StillBad` imported as lowercase `still_bad` +N813 Camelcase `StillBad` imported as lowercase `still_bad` + --> N813.py:8:17 | 7 | from mod import BadAllowed as bad_allowed 8 | from mod import StillBad as still_bad - | ^^^^^^^^^^^^^^^^^^^^^ N813 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap index d5b4ef9e74..6fe30f7180 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap @@ -1,27 +1,30 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N814.py:2:8: N814 Camelcase `StillBad` imported as constant `STILLBAD` +N814 Camelcase `StillBad` imported as constant `STILLBAD` + --> N814.py:2:8 | 1 | import mod.BadAllowed as BADALLOWED 2 | import mod.StillBad as STILLBAD - | ^^^^^^^^^^^^^^^^^^^^^^^^ N814 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | from mod import BadAllowed as BADALLOWED | -N814.py:5:17: N814 Camelcase `StillBad` imported as constant `STILLBAD` +N814 Camelcase `StillBad` imported as constant `STILLBAD` + --> N814.py:5:17 | 4 | from mod import BadAllowed as BADALLOWED 5 | from mod import StillBad as STILLBAD - | ^^^^^^^^^^^^^^^^^^^^ N814 + | ^^^^^^^^^^^^^^^^^^^^ 6 | 7 | from mod import BadAllowed as BAD_ALLOWED | -N814.py:8:17: N814 Camelcase `StillBad` imported as constant `STILL_BAD` +N814 Camelcase `StillBad` imported as constant `STILL_BAD` + --> N814.py:8:17 | 7 | from mod import BadAllowed as BAD_ALLOWED 8 | from mod import StillBad as STILL_BAD - | ^^^^^^^^^^^^^^^^^^^^^ N814 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap index 6712a94c4e..a4f746e425 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap @@ -1,56 +1,62 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N815.py:3:5: N815 Variable `stillBad` in class scope should not be mixedCase +N815 Variable `stillBad` in class scope should not be mixedCase + --> N815.py:3:5 | 1 | class C: 2 | badAllowed = 0 3 | stillBad = 0 - | ^^^^^^^^ N815 + | ^^^^^^^^ 4 | 5 | _badAllowed = 0 | -N815.py:6:5: N815 Variable `_stillBad` in class scope should not be mixedCase +N815 Variable `_stillBad` in class scope should not be mixedCase + --> N815.py:6:5 | 5 | _badAllowed = 0 6 | _stillBad = 0 - | ^^^^^^^^^ N815 + | ^^^^^^^^^ 7 | 8 | bad_Allowed = 0 | -N815.py:9:5: N815 Variable `still_Bad` in class scope should not be mixedCase +N815 Variable `still_Bad` in class scope should not be mixedCase + --> N815.py:9:5 | 8 | bad_Allowed = 0 9 | still_Bad = 0 - | ^^^^^^^^^ N815 + | ^^^^^^^^^ 10 | 11 | class D(TypedDict): | -N815.py:13:5: N815 Variable `stillBad` in class scope should not be mixedCase +N815 Variable `stillBad` in class scope should not be mixedCase + --> N815.py:13:5 | 11 | class D(TypedDict): 12 | badAllowed: bool 13 | stillBad: bool - | ^^^^^^^^ N815 + | ^^^^^^^^ 14 | 15 | _badAllowed: list | -N815.py:16:5: N815 Variable `_stillBad` in class scope should not be mixedCase +N815 Variable `_stillBad` in class scope should not be mixedCase + --> N815.py:16:5 | 15 | _badAllowed: list 16 | _stillBad: list - | ^^^^^^^^^ N815 + | ^^^^^^^^^ 17 | 18 | bad_Allowed: set | -N815.py:19:5: N815 Variable `still_Bad` in class scope should not be mixedCase +N815 Variable `still_Bad` in class scope should not be mixedCase + --> N815.py:19:5 | 18 | bad_Allowed: set 19 | still_Bad: set - | ^^^^^^^^^ N815 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap index 779cd8fd65..9be58b1c56 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap @@ -1,27 +1,30 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N816.py:2:1: N816 Variable `stillBad` in global scope should not be mixedCase +N816 Variable `stillBad` in global scope should not be mixedCase + --> N816.py:2:1 | 1 | badAllowed = 0 2 | stillBad = 0 - | ^^^^^^^^ N816 + | ^^^^^^^^ 3 | 4 | _badAllowed = 0 | -N816.py:5:1: N816 Variable `_stillBad` in global scope should not be mixedCase +N816 Variable `_stillBad` in global scope should not be mixedCase + --> N816.py:5:1 | 4 | _badAllowed = 0 5 | _stillBad = 0 - | ^^^^^^^^^ N816 + | ^^^^^^^^^ 6 | 7 | bad_Allowed = 0 | -N816.py:8:1: N816 Variable `still_Bad` in global scope should not be mixedCase +N816 Variable `still_Bad` in global scope should not be mixedCase + --> N816.py:8:1 | 7 | bad_Allowed = 0 8 | still_Bad = 0 - | ^^^^^^^^^ N816 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap index 605e62924b..b2284aba6f 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N817.py:2:8: N817 CamelCase `StillBad` imported as acronym `SB` +N817 CamelCase `StillBad` imported as acronym `SB` + --> N817.py:2:8 | 1 | import mod.BadAllowed as BA 2 | import mod.StillBad as SB - | ^^^^^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^^^^^ 3 | 4 | from mod import BadAllowed as BA | -N817.py:5:17: N817 CamelCase `StillBad` imported as acronym `SB` +N817 CamelCase `StillBad` imported as acronym `SB` + --> N817.py:5:17 | 4 | from mod import BadAllowed as BA 5 | from mod import StillBad as SB - | ^^^^^^^^^^^^^^ N817 + | ^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap index 3a27ac47f0..02487f215a 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N818.py:4:7: N818 Exception name `StillBad` should be named with an Error suffix +N818 Exception name `StillBad` should be named with an Error suffix + --> N818.py:4:7 | 2 | pass 3 | 4 | class StillBad(Exception): - | ^^^^^^^^ N818 + | ^^^^^^^^ 5 | pass | -N818.py:10:7: N818 Exception name `StillBad` should be named with an Error suffix +N818 Exception name `StillBad` should be named with an Error suffix + --> N818.py:10:7 | 8 | pass 9 | 10 | class StillBad(AnotherError): - | ^^^^^^^^ N818 + | ^^^^^^^^ 11 | pass | diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap index 7ba83b01fd..d7d332471d 100644 --- a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__staticmethod_decorators.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pep8_naming/mod.rs --- -N805.py:7:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:7:20 | 6 | class Class: 7 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 8 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 4 4 | @@ -20,14 +21,15 @@ N805.py:7:20: N805 [*] First argument of a method should be named `self` 9 9 | 10 10 | if False: -N805.py:11:30: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:11:30 | 10 | if False: 11 | def extra_bad_method(this): - | ^^^^ N805 + | ^^^^ 12 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 8 8 | pass @@ -39,14 +41,15 @@ N805.py:11:30: N805 [*] First argument of a method should be named `self` 13 13 | 14 14 | def good_method(self): -N805.py:30:15: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:30:15 | 29 | @pydantic.validator 30 | def lower(cls, my_field: str) -> str: - | ^^^ N805 + | ^^^ 31 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 27 27 | return x @@ -58,14 +61,15 @@ N805.py:30:15: N805 [*] First argument of a method should be named `self` 32 32 | 33 33 | @pydantic.validator("my_field") -N805.py:34:15: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:34:15 | 33 | @pydantic.validator("my_field") 34 | def lower(cls, my_field: str) -> str: - | ^^^ N805 + | ^^^ 35 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 31 31 | pass @@ -77,15 +81,16 @@ N805.py:34:15: N805 [*] First argument of a method should be named `self` 36 36 | 37 37 | def __init__(self): -N805.py:63:29: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:63:29 | 61 | pass 62 | 63 | def bad_method_pos_only(this, blah, /, something: str): - | ^^^^ N805 + | ^^^^ 64 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 60 60 | def good_method_pos_only(self, blah, /, something: str): @@ -97,15 +102,16 @@ N805.py:63:29: N805 [*] First argument of a method should be named `self` 65 65 | 66 66 | -N805.py:69:13: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:69:13 | 67 | class ModelClass: 68 | @hybrid_property 69 | def bad(cls): - | ^^^ N805 + | ^^^ 70 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 66 66 | @@ -117,14 +123,15 @@ N805.py:69:13: N805 [*] First argument of a method should be named `self` 71 71 | 72 72 | @bad.expression -N805.py:77:13: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:77:13 | 76 | @bad.wtf 77 | def bad(cls): - | ^^^ N805 + | ^^^ 78 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 74 74 | pass @@ -136,14 +143,15 @@ N805.py:77:13: N805 [*] First argument of a method should be named `self` 79 79 | 80 80 | @hybrid_property -N805.py:85:14: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:85:14 | 84 | @good.expression 85 | def good(cls): - | ^^^ N805 + | ^^^ 86 | pass | - = help: Rename `cls` to `self` +help: Rename `cls` to `self` ℹ Unsafe fix 82 82 | pass @@ -155,64 +163,70 @@ N805.py:85:14: N805 [*] First argument of a method should be named `self` 87 87 | 88 88 | @good.wtf -N805.py:98:26: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:98:26 | 97 | class SelfInArgsClass: 98 | def self_as_argument(this, self): - | ^^^^ N805 + | ^^^^ 99 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:101:35: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:101:35 | 99 | pass 100 | 101 | def self_as_pos_only_argument(this, self, /): - | ^^^^ N805 + | ^^^^ 102 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:104:34: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:104:34 | 102 | pass 103 | 104 | def self_as_kw_only_argument(this, *, self): - | ^^^^ N805 + | ^^^^ 105 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:107:24: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:107:24 | 105 | pass 106 | 107 | def self_as_varags(this, *self): - | ^^^^ N805 + | ^^^^ 108 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:110:24: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:110:24 | 108 | pass 109 | 110 | def self_as_kwargs(this, **self): - | ^^^^ N805 + | ^^^^ 111 | pass | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:115:20: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:115:20 | 114 | class RenamingInMethodBodyClass: 115 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 116 | this = this 117 | this | - = help: Rename `this` to `self` +help: Rename `this` to `self` ℹ Unsafe fix 112 112 | @@ -228,24 +242,26 @@ N805.py:115:20: N805 [*] First argument of a method should be named `self` 119 119 | def bad_method(this): 120 120 | self = this -N805.py:119:20: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:119:20 | 117 | this 118 | 119 | def bad_method(this): - | ^^^^ N805 + | ^^^^ 120 | self = this | - = help: Rename `this` to `self` +help: Rename `this` to `self` -N805.py:124:17: N805 [*] First argument of a method should be named `self` +N805 [*] First argument of a method should be named `self` + --> N805.py:124:17 | 123 | class RenamingWithNFKC: 124 | def formula(household): - | ^^^^^^^^^ N805 + | ^^^^^^^^^ 125 | hºusehold(1) | - = help: Rename `household` to `self` +help: Rename `household` to `self` ℹ Unsafe fix 121 121 | @@ -259,12 +275,13 @@ N805.py:124:17: N805 [*] First argument of a method should be named `self` 127 127 | 128 128 | from typing import Protocol -N805.py:141:11: N805 First argument of a method should be named `self` +N805 First argument of a method should be named `self` + --> N805.py:141:11 | 139 | # https://github.com/astral-sh/ruff/issues/18459 140 | class C: 141 | def f(this): - | ^^^^ N805 + | ^^^^ 142 | self = 123 | - = help: Rename `this` to `self` +help: Rename `this` to `self` diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap index 25fc58e80c..60a71ae175 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs --- -PERF101.py:7:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:7:10 | 5 | foo_int = 123 6 | 7 | for i in list(foo_tuple): # PERF101 - | ^^^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^^^ 8 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 4 4 | foo_dict = {1: 2, 3: 4} @@ -21,15 +22,16 @@ PERF101.py:7:10: PERF101 [*] Do not cast an iterable to `list` before iterating 9 9 | 10 10 | for i in list(foo_list): # PERF101 -PERF101.py:10:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:10:10 | 8 | pass 9 | 10 | for i in list(foo_list): # PERF101 - | ^^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^^ 11 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 7 7 | for i in list(foo_tuple): # PERF101 @@ -41,15 +43,16 @@ PERF101.py:10:10: PERF101 [*] Do not cast an iterable to `list` before iterating 12 12 | 13 13 | for i in list(foo_set): # PERF101 -PERF101.py:13:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:13:10 | 11 | pass 12 | 13 | for i in list(foo_set): # PERF101 - | ^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^ 14 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 10 10 | for i in list(foo_list): # PERF101 @@ -61,15 +64,16 @@ PERF101.py:13:10: PERF101 [*] Do not cast an iterable to `list` before iterating 15 15 | 16 16 | for i in list((1, 2, 3)): # PERF101 -PERF101.py:16:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:16:10 | 14 | pass 15 | 16 | for i in list((1, 2, 3)): # PERF101 - | ^^^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^^^ 17 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 13 13 | for i in list(foo_set): # PERF101 @@ -81,15 +85,16 @@ PERF101.py:16:10: PERF101 [*] Do not cast an iterable to `list` before iterating 18 18 | 19 19 | for i in list([1, 2, 3]): # PERF101 -PERF101.py:19:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:19:10 | 17 | pass 18 | 19 | for i in list([1, 2, 3]): # PERF101 - | ^^^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^^^ 20 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 16 16 | for i in list((1, 2, 3)): # PERF101 @@ -101,15 +106,16 @@ PERF101.py:19:10: PERF101 [*] Do not cast an iterable to `list` before iterating 21 21 | 22 22 | for i in list({1, 2, 3}): # PERF101 -PERF101.py:22:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:22:10 | 20 | pass 21 | 22 | for i in list({1, 2, 3}): # PERF101 - | ^^^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^^^ 23 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 19 19 | for i in list([1, 2, 3]): # PERF101 @@ -121,7 +127,8 @@ PERF101.py:22:10: PERF101 [*] Do not cast an iterable to `list` before iterating 24 24 | 25 25 | for i in list( -PERF101.py:25:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:25:10 | 23 | pass 24 | @@ -133,10 +140,10 @@ PERF101.py:25:10: PERF101 [*] Do not cast an iterable to `list` before iterating 29 | | 3, 30 | | } 31 | | ): - | |_^ PERF101 + | |_^ 32 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 22 22 | for i in list({1, 2, 3}): # PERF101 @@ -155,7 +162,8 @@ PERF101.py:25:10: PERF101 [*] Do not cast an iterable to `list` before iterating 33 31 | 34 32 | for i in list( # Comment -PERF101.py:34:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:34:10 | 32 | pass 33 | @@ -163,10 +171,10 @@ PERF101.py:34:10: PERF101 [*] Do not cast an iterable to `list` before iterating | __________^ 35 | | {1, 2, 3} 36 | | ): # PERF101 - | |_^ PERF101 + | |_^ 37 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Unsafe fix 31 31 | ): @@ -180,16 +188,17 @@ PERF101.py:34:10: PERF101 [*] Do not cast an iterable to `list` before iterating 38 36 | 39 37 | for i in list(foo_dict): # OK -PERF101.py:57:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:57:10 | 55 | foo_list.append(i + 1) 56 | 57 | for i in list(foo_list): # PERF101 - | ^^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^^ 58 | # Make sure we match the correct list 59 | other_list.append(i + 1) | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 54 54 | for i in list(foo_list): # OK @@ -201,15 +210,16 @@ PERF101.py:57:10: PERF101 [*] Do not cast an iterable to `list` before iterating 59 59 | other_list.append(i + 1) 60 60 | -PERF101.py:69:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:69:10 | 67 | x, y, nested_tuple = (1, 2, (3, 4, 5)) 68 | 69 | for i in list(nested_tuple): # PERF101 - | ^^^^^^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^^^^^^ 70 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 66 66 | @@ -221,15 +231,16 @@ PERF101.py:69:10: PERF101 [*] Do not cast an iterable to `list` before iterating 71 71 | 72 72 | for i in list(foo_list): # OK -PERF101.py:86:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:86:10 | 84 | import builtins 85 | 86 | for i in builtins.list(nested_tuple): # PERF101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 | pass | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 83 83 | @@ -241,15 +252,16 @@ PERF101.py:86:10: PERF101 [*] Do not cast an iterable to `list` before iterating 88 88 | 89 89 | # https://github.com/astral-sh/ruff/issues/18783 -PERF101.py:91:9: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:91:9 | 89 | # https://github.com/astral-sh/ruff/issues/18783 90 | items = (1, 2, 3) 91 | for i in(list)(items): - | ^^^^^^^^^^^^^ PERF101 + | ^^^^^^^^^^^^^ 92 | print(i) | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Safe fix 88 88 | @@ -261,7 +273,8 @@ PERF101.py:91:9: PERF101 [*] Do not cast an iterable to `list` before iterating 93 93 | 94 94 | # https://github.com/astral-sh/ruff/issues/18784 -PERF101.py:96:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it +PERF101 [*] Do not cast an iterable to `list` before iterating over it + --> PERF101.py:96:10 | 94 | # https://github.com/astral-sh/ruff/issues/18784 95 | items = (1, 2, 3) @@ -273,10 +286,10 @@ PERF101.py:96:10: PERF101 [*] Do not cast an iterable to `list` before iterating 100 | | items # 5 101 | | # 6 102 | | ): - | |_^ PERF101 + | |_^ 103 | print(i) | - = help: Remove `list()` cast +help: Remove `list()` cast ℹ Unsafe fix 93 93 | diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap index 8598ae0e0b..e7b8eb93f3 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs -snapshot_kind: text --- -PERF102.py:5:21: PERF102 [*] When using only the values of a dict use the `values()` method +PERF102 [*] When using only the values of a dict use the `values()` method + --> PERF102.py:5:21 | 4 | def f(): 5 | for _, value in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 6 | print(value) | - = help: Replace `.items()` with `.values()` +help: Replace `.items()` with `.values()` ℹ Unsafe fix 2 2 | @@ -21,14 +21,15 @@ PERF102.py:5:21: PERF102 [*] When using only the values of a dict use the `value 7 7 | 8 8 | -PERF102.py:10:19: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:10:19 | 9 | def f(): 10 | for key, _ in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 11 | print(key) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 7 7 | @@ -40,14 +41,15 @@ PERF102.py:10:19: PERF102 [*] When using only the keys of a dict use the `keys() 12 12 | 13 13 | -PERF102.py:15:30: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:15:30 | 14 | def f(): 15 | for weird_arg_name, _ in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 16 | print(weird_arg_name) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 12 12 | @@ -59,14 +61,15 @@ PERF102.py:15:30: PERF102 [*] When using only the keys of a dict use the `keys() 17 17 | 18 18 | -PERF102.py:20:25: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:20:25 | 19 | def f(): 20 | for name, (_, _) in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 21 | print(name) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 17 17 | @@ -78,14 +81,15 @@ PERF102.py:20:25: PERF102 [*] When using only the keys of a dict use the `keys() 22 22 | 23 23 | -PERF102.py:30:30: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:30:30 | 29 | def f(): 30 | for (key1, _), (_, _) in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 31 | print(key1) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 27 27 | @@ -97,14 +101,15 @@ PERF102.py:30:30: PERF102 [*] When using only the keys of a dict use the `keys() 32 32 | 33 33 | -PERF102.py:35:36: PERF102 [*] When using only the values of a dict use the `values()` method +PERF102 [*] When using only the values of a dict use the `values()` method + --> PERF102.py:35:36 | 34 | def f(): 35 | for (_, (_, _)), (value, _) in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 36 | print(value) | - = help: Replace `.items()` with `.values()` +help: Replace `.items()` with `.values()` ℹ Unsafe fix 32 32 | @@ -116,14 +121,15 @@ PERF102.py:35:36: PERF102 [*] When using only the values of a dict use the `valu 37 37 | 38 38 | -PERF102.py:50:32: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:50:32 | 49 | def f(): 50 | for ((_, key2), (_, _)) in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 51 | print(key2) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 47 47 | @@ -135,14 +141,15 @@ PERF102.py:50:32: PERF102 [*] When using only the keys of a dict use the `keys() 52 52 | 53 53 | -PERF102.py:85:25: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:85:25 | 84 | def f(): 85 | for name, (_, _) in (some_function()).items(): # PERF102 - | ^^^^^^^^^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^^^^^^^^^ 86 | print(name) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 82 82 | @@ -154,14 +161,15 @@ PERF102.py:85:25: PERF102 [*] When using only the keys of a dict use the `keys() 87 87 | 88 88 | -PERF102.py:90:25: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:90:25 | 89 | def f(): 90 | for name, (_, _) in (some_function().some_attribute).items(): # PERF102 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 91 | print(name) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 87 87 | @@ -173,14 +181,15 @@ PERF102.py:90:25: PERF102 [*] When using only the keys of a dict use the `keys() 92 92 | 93 93 | -PERF102.py:95:31: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:95:31 | 94 | def f(): 95 | for name, unused_value in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 96 | print(name) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 92 92 | @@ -192,14 +201,15 @@ PERF102.py:95:31: PERF102 [*] When using only the keys of a dict use the `keys() 97 97 | 98 98 | -PERF102.py:100:31: PERF102 [*] When using only the values of a dict use the `values()` method +PERF102 [*] When using only the values of a dict use the `values()` method + --> PERF102.py:100:31 | 99 | def f(): 100 | for unused_name, value in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 + | ^^^^^^^^^^^^^^^ 101 | print(value) | - = help: Replace `.items()` with `.values()` +help: Replace `.items()` with `.values()` ℹ Unsafe fix 97 97 | @@ -211,15 +221,16 @@ PERF102.py:100:31: PERF102 [*] When using only the values of a dict use the `val 102 102 | 103 103 | -PERF102.py:106:16: PERF102 [*] When using only the keys of a dict use the `keys()` method +PERF102 [*] When using only the keys of a dict use the `keys()` method + --> PERF102.py:106:16 | 104 | # Regression test for: https://github.com/astral-sh/ruff/issues/7097 105 | def _create_context(name_to_value): 106 | for(B,D)in A.items(): - | ^^^^^^^ PERF102 + | ^^^^^^^ 107 | if(C:=name_to_value.get(B.name)):A.run(B.set,C) | - = help: Replace `.items()` with `.keys()` +help: Replace `.items()` with `.keys()` ℹ Unsafe fix 103 103 | diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap index f0cc3e1d1f..833aee00b2 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs --- -PERF203.py:5:5: PERF203 `try`-`except` within a loop incurs performance overhead +PERF203 `try`-`except` within a loop incurs performance overhead + --> PERF203.py:5:5 | 3 | try: 4 | print(f"{i}") 5 | / except: 6 | | print("error") - | |______________________^ PERF203 + | |______________________^ 7 | 8 | # OK | diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap index e3ce964cde..e884d51837 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap @@ -1,153 +1,170 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs --- -PERF401.py:6:13: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:6:13 | 4 | for i in items: 5 | if i % 2: 6 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:13:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:13:9 | 11 | result = [] 12 | for i in items: 13 | result.append(i * i) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:82:13: PERF401 Use an async list comprehension to create a transformed list +PERF401 Use an async list comprehension to create a transformed list + --> PERF401.py:82:13 | 80 | async for i in items: 81 | if i % 2: 82 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:89:9: PERF401 Use an async list comprehension to create a transformed list +PERF401 Use an async list comprehension to create a transformed list + --> PERF401.py:89:9 | 87 | result = [] 88 | async for i in items: 89 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:96:9: PERF401 Use `list.extend` with an async comprehension to create a transformed list +PERF401 Use `list.extend` with an async comprehension to create a transformed list + --> PERF401.py:96:9 | 94 | result = [1, 2] 95 | async for i in items: 96 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend -PERF401.py:102:9: PERF401 Use `list.extend` to create a transformed list +PERF401 Use `list.extend` to create a transformed list + --> PERF401.py:102:9 | 100 | result, _ = [1, 2, 3, 4], ... 101 | for i in range(10): 102 | result.append(i * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend -PERF401.py:111:17: PERF401 Use `list.extend` to create a transformed list +PERF401 Use `list.extend` to create a transformed list + --> PERF401.py:111:17 | 109 | # single-line comment 2 should be protected 110 | if i % 2: # single-line comment 3 should be protected 111 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend -PERF401.py:119:13: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:119:13 | 117 | # single-line comment 2 should be protected 118 | if i % 2: # single-line comment 3 should be protected 119 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:135:13: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:135:13 | 133 | new_layers = [] 134 | for value in param: 135 | new_layers.append(value * 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:142:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:142:9 | 140 | var = 1 141 | for _ in range(10): 142 | result.append(var + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:149:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:149:9 | 147 | tmp = 1; result = [] # comment should be protected 148 | for i in range(10): 149 | result.append(i + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:156:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:156:9 | 154 | result = []; tmp = 1 # comment should be protected 155 | for i in range(10): 156 | result.append(i + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:162:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:162:9 | 160 | result = [] # comment should be protected 161 | for i in range(10): 162 | result.append(i * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:169:9: PERF401 Use `list.extend` to create a transformed list +PERF401 Use `list.extend` to create a transformed list + --> PERF401.py:169:9 | 167 | result.append(1) 168 | for i in range(10): 169 | result.append(i * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend -PERF401.py:189:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:189:9 | 187 | result = [] 188 | for val in range(5): 189 | result.append(val * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^ 190 | val = 1 191 | print(val) | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:198:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:198:9 | 196 | result = [] 197 | for i in i: 198 | result.append(i + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:210:13: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:210:13 | 208 | ): # Comment 3 209 | if i % 2: # Comment 4 @@ -158,112 +175,122 @@ PERF401.py:210:13: PERF401 Use a list comprehension to create a transformed list 214 | | 2, 215 | | ) 216 | | ) # PERF401 - | |_____________^ PERF401 + | |_____________^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:222:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:222:9 | 220 | result: list[int] = [] 221 | for i in range(10): 222 | result.append(i * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:229:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:229:9 | 227 | result = [] 228 | for i in a, b: 229 | result.append(i[0] + i[1]) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 230 | return result | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:239:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:239:9 | 237 | print(a) 238 | for a in values: 239 | result.append(a + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ 240 | 241 | def f(): | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:245:13: PERF401 Use `list.extend` to create a transformed list +PERF401 Use `list.extend` to create a transformed list + --> PERF401.py:245:13 | 243 | def g(): 244 | for a in values: 245 | result.append(a + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ 246 | result = [] | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend -PERF401.py:262:13: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:262:13 | 260 | for i in range(5): 261 | if j := i: 262 | items.append(j) - | ^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^ 263 | 264 | def f(): | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:268:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:268:9 | 266 | result = list() # this should be replaced with a comprehension 267 | for i in values: 268 | result.append(i + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ 269 | 270 | def f(): | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:276:13: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:276:13 | 274 | for i in src: 275 | if True if True else False: 276 | dst.append(i) - | ^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^ 277 | 278 | for i in src: | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:280:13: PERF401 Use `list.extend` to create a transformed list +PERF401 Use `list.extend` to create a transformed list + --> PERF401.py:280:13 | 278 | for i in src: 279 | if lambda: 0: 280 | dst.append(i) - | ^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^ 281 | 282 | def f(): | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend -PERF401.py:286:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:286:9 | 284 | result = [] 285 | for i in range(3): 286 | result.append(x for x in [i]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 287 | 288 | def f(): | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension -PERF401.py:292:9: PERF401 Use a list comprehension to create a transformed list +PERF401 Use a list comprehension to create a transformed list + --> PERF401.py:292:9 | 290 | result = [] 291 | for i in range(3): 292 | result.append((x for x in [i])) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 293 | 294 | G_INDEX = None | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF402_PERF402.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF402_PERF402.py.snap index e064b13123..670d80e933 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF402_PERF402.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF402_PERF402.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs -snapshot_kind: text --- -PERF402.py:5:9: PERF402 Use `list` or `list.copy` to create a copy of a list +PERF402 Use `list` or `list.copy` to create a copy of a list + --> PERF402.py:5:9 | 3 | result = [] 4 | for i in items: 5 | result.append(i) # PERF402 - | ^^^^^^^^^^^^^^^^ PERF402 + | ^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF403_PERF403.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF403_PERF403.py.snap index 6cfe2b486d..30a30469eb 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF403_PERF403.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF403_PERF403.py.snap @@ -1,161 +1,178 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs --- -PERF403.py:5:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:5:9 | 3 | result = {} 4 | for idx, name in enumerate(fruit): 5 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:13:13: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:13:13 | 11 | for idx, name in enumerate(fruit): 12 | if idx % 2: 13 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:33:13: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:33:13 | 31 | for idx, name in enumerate(fruit): 32 | if idx % 2: 33 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:63:13: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:63:13 | 61 | for idx, name in enumerate(fruit): 62 | if idx % 2: 63 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:78:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:78:9 | 76 | result = {} 77 | for name in fruit: 78 | result[name] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:85:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:85:9 | 83 | result = {} 84 | for idx, name in enumerate(fruit): 85 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:94:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:94:9 | 92 | result = SneakyDict() 93 | for idx, name in enumerate(fruit): 94 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:106:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:106:9 | 104 | ): 105 | # comment 3 106 | / result[ 107 | | name # comment 4 108 | | ] = idx # PERF403 - | |_______________^ PERF403 + | |_______________^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:115:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:115:9 | 113 | a = 1; result = {}; b = 2 114 | for idx, name in enumerate(fruit): 115 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:122:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:122:9 | 120 | result = {"kiwi": 3} 121 | for idx, name in enumerate(fruit): 122 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:129:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:129:9 | 127 | (_, result) = (None, {"kiwi": 3}) 128 | for idx, name in enumerate(fruit): 129 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:137:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:137:9 | 135 | print(len(result)) 136 | for idx, name in enumerate(fruit): 137 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:145:13: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:145:13 | 143 | for idx, name in enumerate(fruit): 144 | if last_idx := idx % 3: 145 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:153:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:153:9 | 151 | result = {} 152 | for idx, name in indices, fruit: 153 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:162:13: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:162:13 | 160 | for k, v in src: 161 | if True if True else False: 162 | dst[k] = v - | ^^^^^^^^^^ PERF403 + | ^^^^^^^^^^ 163 | 164 | for k, v in src: | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:166:13: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:166:13 | 164 | for k, v in src: 165 | if lambda: 0: 166 | dst[k] = v - | ^^^^^^^^^^ PERF403 + | ^^^^^^^^^^ 167 | 168 | # https://github.com/astral-sh/ruff/issues/18859 | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension -PERF403.py:172:9: PERF403 Use a dictionary comprehension instead of a for-loop +PERF403 Use a dictionary comprehension instead of a for-loop + --> PERF403.py:172:9 | 170 | v = {} 171 | for o,(x,)in(): 172 | v[x,]=o - | ^^^^^^^ PERF403 + | ^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF401_PERF401.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF401_PERF401.py.snap index 0d0762d22e..c625975738 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF401_PERF401.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF401_PERF401.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs --- -PERF401.py:6:13: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:6:13 | 4 | for i in items: 5 | if i % 2: 6 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 1 1 | def f(): @@ -22,14 +23,15 @@ PERF401.py:6:13: PERF401 [*] Use a list comprehension to create a transformed li 8 5 | 9 6 | def f(): -PERF401.py:13:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:13:9 | 11 | result = [] 12 | for i in items: 13 | result.append(i * i) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 8 8 | @@ -43,14 +45,15 @@ PERF401.py:13:9: PERF401 [*] Use a list comprehension to create a transformed li 15 13 | 16 14 | def f(): -PERF401.py:82:13: PERF401 [*] Use an async list comprehension to create a transformed list +PERF401 [*] Use an async list comprehension to create a transformed list + --> PERF401.py:82:13 | 80 | async for i in items: 81 | if i % 2: 82 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 76 76 | @@ -65,14 +68,15 @@ PERF401.py:82:13: PERF401 [*] Use an async list comprehension to create a transf 84 81 | 85 82 | async def f(): -PERF401.py:89:9: PERF401 [*] Use an async list comprehension to create a transformed list +PERF401 [*] Use an async list comprehension to create a transformed list + --> PERF401.py:89:9 | 87 | result = [] 88 | async for i in items: 89 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 84 84 | @@ -86,14 +90,15 @@ PERF401.py:89:9: PERF401 [*] Use an async list comprehension to create a transfo 91 89 | 92 90 | async def f(): -PERF401.py:96:9: PERF401 [*] Use `list.extend` with an async comprehension to create a transformed list +PERF401 [*] Use `list.extend` with an async comprehension to create a transformed list + --> PERF401.py:96:9 | 94 | result = [1, 2] 95 | async for i in items: 96 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend ℹ Unsafe fix 92 92 | async def f(): @@ -106,14 +111,15 @@ PERF401.py:96:9: PERF401 [*] Use `list.extend` with an async comprehension to cr 98 97 | 99 98 | def f(): -PERF401.py:102:9: PERF401 [*] Use `list.extend` to create a transformed list +PERF401 [*] Use `list.extend` to create a transformed list + --> PERF401.py:102:9 | 100 | result, _ = [1, 2, 3, 4], ... 101 | for i in range(10): 102 | result.append(i * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend ℹ Unsafe fix 98 98 | @@ -126,14 +132,15 @@ PERF401.py:102:9: PERF401 [*] Use `list.extend` to create a transformed list 104 103 | 105 104 | def f(): -PERF401.py:111:17: PERF401 [*] Use `list.extend` to create a transformed list +PERF401 [*] Use `list.extend` to create a transformed list + --> PERF401.py:111:17 | 109 | # single-line comment 2 should be protected 110 | if i % 2: # single-line comment 3 should be protected 111 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend ℹ Unsafe fix 105 105 | def f(): @@ -151,14 +158,15 @@ PERF401.py:111:17: PERF401 [*] Use `list.extend` to create a transformed list 113 113 | 114 114 | def f(): -PERF401.py:119:13: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:119:13 | 117 | # single-line comment 2 should be protected 118 | if i % 2: # single-line comment 3 should be protected 119 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 112 112 | @@ -178,14 +186,15 @@ PERF401.py:119:13: PERF401 [*] Use a list comprehension to create a transformed 121 121 | 122 122 | def f(): -PERF401.py:135:13: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:135:13 | 133 | new_layers = [] 134 | for value in param: 135 | new_layers.append(value * 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 130 130 | # PERF401 @@ -199,14 +208,15 @@ PERF401.py:135:13: PERF401 [*] Use a list comprehension to create a transformed 137 135 | 138 136 | def f(): -PERF401.py:142:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:142:9 | 140 | var = 1 141 | for _ in range(10): 142 | result.append(var + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 136 136 | @@ -221,14 +231,15 @@ PERF401.py:142:9: PERF401 [*] Use a list comprehension to create a transformed l 144 142 | 145 143 | def f(): -PERF401.py:149:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:149:9 | 147 | tmp = 1; result = [] # comment should be protected 148 | for i in range(10): 149 | result.append(i + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 144 144 | @@ -243,14 +254,15 @@ PERF401.py:149:9: PERF401 [*] Use a list comprehension to create a transformed l 151 150 | 152 151 | def f(): -PERF401.py:156:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:156:9 | 154 | result = []; tmp = 1 # comment should be protected 155 | for i in range(10): 156 | result.append(i + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 151 151 | @@ -265,14 +277,15 @@ PERF401.py:156:9: PERF401 [*] Use a list comprehension to create a transformed l 158 157 | 159 158 | def f(): -PERF401.py:162:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:162:9 | 160 | result = [] # comment should be protected 161 | for i in range(10): 162 | result.append(i * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 157 157 | @@ -287,14 +300,15 @@ PERF401.py:162:9: PERF401 [*] Use a list comprehension to create a transformed l 164 163 | 165 164 | def f(): -PERF401.py:169:9: PERF401 [*] Use `list.extend` to create a transformed list +PERF401 [*] Use `list.extend` to create a transformed list + --> PERF401.py:169:9 | 167 | result.append(1) 168 | for i in range(10): 169 | result.append(i * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend ℹ Unsafe fix 165 165 | def f(): @@ -307,16 +321,17 @@ PERF401.py:169:9: PERF401 [*] Use `list.extend` to create a transformed list 171 170 | 172 171 | def f(): -PERF401.py:189:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:189:9 | 187 | result = [] 188 | for val in range(5): 189 | result.append(val * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^ 190 | val = 1 191 | print(val) | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 184 184 | @@ -330,14 +345,15 @@ PERF401.py:189:9: PERF401 [*] Use a list comprehension to create a transformed l 191 189 | print(val) 192 190 | -PERF401.py:198:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:198:9 | 196 | result = [] 197 | for i in i: 198 | result.append(i + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 193 193 | @@ -351,7 +367,8 @@ PERF401.py:198:9: PERF401 [*] Use a list comprehension to create a transformed l 200 198 | 201 199 | def f(): -PERF401.py:210:13: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:210:13 | 208 | ): # Comment 3 209 | if i % 2: # Comment 4 @@ -362,9 +379,9 @@ PERF401.py:210:13: PERF401 [*] Use a list comprehension to create a transformed 214 | | 2, 215 | | ) 216 | | ) # PERF401 - | |_____________^ PERF401 + | |_____________^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 199 199 | @@ -397,14 +414,15 @@ PERF401.py:210:13: PERF401 [*] Use a list comprehension to create a transformed 218 215 | 219 216 | def f(): -PERF401.py:222:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:222:9 | 220 | result: list[int] = [] 221 | for i in range(10): 222 | result.append(i * 2) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 217 217 | @@ -418,15 +436,16 @@ PERF401.py:222:9: PERF401 [*] Use a list comprehension to create a transformed l 224 222 | 225 223 | def f(): -PERF401.py:229:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:229:9 | 227 | result = [] 228 | for i in a, b: 229 | result.append(i[0] + i[1]) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 230 | return result | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 224 224 | @@ -440,16 +459,17 @@ PERF401.py:229:9: PERF401 [*] Use a list comprehension to create a transformed l 231 229 | 232 230 | -PERF401.py:239:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:239:9 | 237 | print(a) 238 | for a in values: 239 | result.append(a + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ 240 | 241 | def f(): | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 232 232 | @@ -465,15 +485,16 @@ PERF401.py:239:9: PERF401 [*] Use a list comprehension to create a transformed l 241 239 | def f(): 242 240 | values = [1, 2, 3] -PERF401.py:245:13: PERF401 [*] Use `list.extend` to create a transformed list +PERF401 [*] Use `list.extend` to create a transformed list + --> PERF401.py:245:13 | 243 | def g(): 244 | for a in values: 245 | result.append(a + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ 246 | result = [] | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend ℹ Unsafe fix 241 241 | def f(): @@ -486,16 +507,17 @@ PERF401.py:245:13: PERF401 [*] Use `list.extend` to create a transformed list 247 246 | 248 247 | def f(): -PERF401.py:262:13: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:262:13 | 260 | for i in range(5): 261 | if j := i: 262 | items.append(j) - | ^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^ 263 | 264 | def f(): | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 255 255 | # The fix here must parenthesize the walrus operator @@ -511,16 +533,17 @@ PERF401.py:262:13: PERF401 [*] Use a list comprehension to create a transformed 264 261 | def f(): 265 262 | values = [1, 2, 3] -PERF401.py:268:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:268:9 | 266 | result = list() # this should be replaced with a comprehension 267 | for i in values: 268 | result.append(i + 1) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^ 269 | 270 | def f(): | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 263 263 | @@ -535,16 +558,17 @@ PERF401.py:268:9: PERF401 [*] Use a list comprehension to create a transformed l 270 269 | def f(): 271 270 | src = [1] -PERF401.py:276:13: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:276:13 | 274 | for i in src: 275 | if True if True else False: 276 | dst.append(i) - | ^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^ 277 | 278 | for i in src: | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 269 269 | @@ -560,16 +584,17 @@ PERF401.py:276:13: PERF401 [*] Use a list comprehension to create a transformed 278 275 | for i in src: 279 276 | if lambda: 0: -PERF401.py:280:13: PERF401 [*] Use `list.extend` to create a transformed list +PERF401 [*] Use `list.extend` to create a transformed list + --> PERF401.py:280:13 | 278 | for i in src: 279 | if lambda: 0: 280 | dst.append(i) - | ^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^ 281 | 282 | def f(): | - = help: Replace for loop with list.extend +help: Replace for loop with list.extend ℹ Unsafe fix 275 275 | if True if True else False: @@ -583,16 +608,17 @@ PERF401.py:280:13: PERF401 [*] Use `list.extend` to create a transformed list 282 280 | def f(): 283 281 | i = "xyz" -PERF401.py:286:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:286:9 | 284 | result = [] 285 | for i in range(3): 286 | result.append(x for x in [i]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 287 | 288 | def f(): | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 281 281 | @@ -606,16 +632,17 @@ PERF401.py:286:9: PERF401 [*] Use a list comprehension to create a transformed l 288 286 | def f(): 289 287 | i = "xyz" -PERF401.py:292:9: PERF401 [*] Use a list comprehension to create a transformed list +PERF401 [*] Use a list comprehension to create a transformed list + --> PERF401.py:292:9 | 290 | result = [] 291 | for i in range(3): 292 | result.append((x for x in [i])) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 293 | 294 | G_INDEX = None | - = help: Replace for loop with list comprehension +help: Replace for loop with list comprehension ℹ Unsafe fix 287 287 | diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF403_PERF403.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF403_PERF403.py.snap index 4c3a99b81f..c4e3cf3033 100644 --- a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF403_PERF403.py.snap +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__preview__PERF403_PERF403.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/perflint/mod.rs --- -PERF403.py:5:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:5:9 | 3 | result = {} 4 | for idx, name in enumerate(fruit): 5 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 1 1 | def foo(): @@ -21,14 +22,15 @@ PERF403.py:5:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop 7 5 | 8 6 | def foo(): -PERF403.py:13:13: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:13:13 | 11 | for idx, name in enumerate(fruit): 12 | if idx % 2: 13 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 7 7 | @@ -43,14 +45,15 @@ PERF403.py:13:13: PERF403 [*] Use a dictionary comprehension instead of a for-lo 15 12 | 16 13 | def foo(): -PERF403.py:33:13: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:33:13 | 31 | for idx, name in enumerate(fruit): 32 | if idx % 2: 33 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 26 26 | @@ -66,14 +69,15 @@ PERF403.py:33:13: PERF403 [*] Use a dictionary comprehension instead of a for-lo 35 32 | 36 33 | def foo(): -PERF403.py:63:13: PERF403 [*] Use `dict.update` instead of a for-loop +PERF403 [*] Use `dict.update` instead of a for-loop + --> PERF403.py:63:13 | 61 | for idx, name in enumerate(fruit): 62 | if idx % 2: 63 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with `dict.update` +help: Replace for loop with `dict.update` ℹ Unsafe fix 58 58 | def foo(): @@ -87,14 +91,15 @@ PERF403.py:63:13: PERF403 [*] Use `dict.update` instead of a for-loop 65 63 | 66 64 | def foo(): -PERF403.py:78:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:78:9 | 76 | result = {} 77 | for name in fruit: 78 | result[name] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 73 73 | @@ -108,14 +113,15 @@ PERF403.py:78:9: PERF403 [*] Use a dictionary comprehension instead of a for-loo 80 78 | 81 79 | def foo(): -PERF403.py:85:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:85:9 | 83 | result = {} 84 | for idx, name in enumerate(fruit): 85 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 80 80 | @@ -129,14 +135,15 @@ PERF403.py:85:9: PERF403 [*] Use a dictionary comprehension instead of a for-loo 87 85 | 88 86 | def foo(): -PERF403.py:94:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:94:9 | 92 | result = SneakyDict() 93 | for idx, name in enumerate(fruit): 94 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 89 89 | from builtins import dict as SneakyDict @@ -150,16 +157,17 @@ PERF403.py:94:9: PERF403 [*] Use a dictionary comprehension instead of a for-loo 96 94 | 97 95 | def foo(): -PERF403.py:106:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:106:9 | 104 | ): 105 | # comment 3 106 | / result[ 107 | | name # comment 4 108 | | ] = idx # PERF403 - | |_______________^ PERF403 + | |_______________^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 96 96 | @@ -184,14 +192,15 @@ PERF403.py:106:9: PERF403 [*] Use a dictionary comprehension instead of a for-lo 110 106 | 111 107 | def foo(): -PERF403.py:115:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:115:9 | 113 | a = 1; result = {}; b = 2 114 | for idx, name in enumerate(fruit): 115 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 110 110 | @@ -206,14 +215,15 @@ PERF403.py:115:9: PERF403 [*] Use a dictionary comprehension instead of a for-lo 117 116 | 118 117 | def foo(): -PERF403.py:122:9: PERF403 [*] Use `dict.update` instead of a for-loop +PERF403 [*] Use `dict.update` instead of a for-loop + --> PERF403.py:122:9 | 120 | result = {"kiwi": 3} 121 | for idx, name in enumerate(fruit): 122 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with `dict.update` +help: Replace for loop with `dict.update` ℹ Unsafe fix 118 118 | def foo(): @@ -226,14 +236,15 @@ PERF403.py:122:9: PERF403 [*] Use `dict.update` instead of a for-loop 124 123 | 125 124 | def foo(): -PERF403.py:129:9: PERF403 [*] Use `dict.update` instead of a for-loop +PERF403 [*] Use `dict.update` instead of a for-loop + --> PERF403.py:129:9 | 127 | (_, result) = (None, {"kiwi": 3}) 128 | for idx, name in enumerate(fruit): 129 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with `dict.update` +help: Replace for loop with `dict.update` ℹ Unsafe fix 125 125 | def foo(): @@ -246,14 +257,15 @@ PERF403.py:129:9: PERF403 [*] Use `dict.update` instead of a for-loop 131 130 | 132 131 | def foo(): -PERF403.py:137:9: PERF403 [*] Use `dict.update` instead of a for-loop +PERF403 [*] Use `dict.update` instead of a for-loop + --> PERF403.py:137:9 | 135 | print(len(result)) 136 | for idx, name in enumerate(fruit): 137 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with `dict.update` +help: Replace for loop with `dict.update` ℹ Unsafe fix 133 133 | fruit = ["apple", "pear", "orange"] @@ -266,14 +278,15 @@ PERF403.py:137:9: PERF403 [*] Use `dict.update` instead of a for-loop 139 138 | 140 139 | def foo(): -PERF403.py:145:13: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:145:13 | 143 | for idx, name in enumerate(fruit): 144 | if last_idx := idx % 3: 145 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 139 139 | @@ -288,14 +301,15 @@ PERF403.py:145:13: PERF403 [*] Use a dictionary comprehension instead of a for-l 147 144 | 148 145 | def foo(): -PERF403.py:153:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:153:9 | 151 | result = {} 152 | for idx, name in indices, fruit: 153 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 148 148 | def foo(): @@ -309,16 +323,17 @@ PERF403.py:153:9: PERF403 [*] Use a dictionary comprehension instead of a for-lo 155 153 | 156 154 | def foo(): -PERF403.py:162:13: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:162:13 | 160 | for k, v in src: 161 | if True if True else False: 162 | dst[k] = v - | ^^^^^^^^^^ PERF403 + | ^^^^^^^^^^ 163 | 164 | for k, v in src: | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 155 155 | @@ -334,16 +349,17 @@ PERF403.py:162:13: PERF403 [*] Use a dictionary comprehension instead of a for-l 164 161 | for k, v in src: 165 162 | if lambda: 0: -PERF403.py:166:13: PERF403 [*] Use `dict.update` instead of a for-loop +PERF403 [*] Use `dict.update` instead of a for-loop + --> PERF403.py:166:13 | 164 | for k, v in src: 165 | if lambda: 0: 166 | dst[k] = v - | ^^^^^^^^^^ PERF403 + | ^^^^^^^^^^ 167 | 168 | # https://github.com/astral-sh/ruff/issues/18859 | - = help: Replace for loop with `dict.update` +help: Replace for loop with `dict.update` ℹ Unsafe fix 161 161 | if True if True else False: @@ -357,14 +373,15 @@ PERF403.py:166:13: PERF403 [*] Use `dict.update` instead of a for-loop 168 166 | # https://github.com/astral-sh/ruff/issues/18859 169 167 | def foo(): -PERF403.py:172:9: PERF403 [*] Use a dictionary comprehension instead of a for-loop +PERF403 [*] Use a dictionary comprehension instead of a for-loop + --> PERF403.py:172:9 | 170 | v = {} 171 | for o,(x,)in(): 172 | v[x,]=o - | ^^^^^^^ PERF403 + | ^^^^^^^ | - = help: Replace for loop with dict comprehension +help: Replace for loop with dict comprehension ℹ Unsafe fix 167 167 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap index 2fd666a3a2..8f4ea63379 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E101.py:11:1: E101 Indentation contains mixed spaces and tabs +E101 Indentation contains mixed spaces and tabs + --> E101.py:11:1 | 9 | def func_mixed_start_with_tab(): 10 | # E101 11 | print("mixed starts with tab") - | ^^^^^^ E101 + | ^^^^^^ 12 | 13 | def func_mixed_start_with_space(): | -E101.py:15:1: E101 Indentation contains mixed spaces and tabs +E101 Indentation contains mixed spaces and tabs + --> E101.py:15:1 | 13 | def func_mixed_start_with_space(): 14 | # E101 15 | print("mixed starts with space") - | ^^^^^^^^^^^^^^^^^^^^ E101 + | ^^^^^^^^^^^^^^^^^^^^ 16 | 17 | def xyz(): | -E101.py:19:1: E101 Indentation contains mixed spaces and tabs +E101 Indentation contains mixed spaces and tabs + --> E101.py:19:1 | 17 | def xyz(): 18 | # E101 19 | print("xyz"); - | ^^^^^^^ E101 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E111_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E111_E11.py.snap index e1cccc2580..45ab478836 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E111_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E111_E11.py.snap @@ -1,27 +1,30 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E11.py:3:1: E111 Indentation is not a multiple of 4 +E111 Indentation is not a multiple of 4 + --> E11.py:3:1 | 1 | #: E111 2 | if x > 2: 3 | print(x) - | ^^ E111 + | ^^ 4 | #: E111 E117 5 | if True: | -E11.py:6:1: E111 Indentation is not a multiple of 4 +E111 Indentation is not a multiple of 4 + --> E11.py:6:1 | 4 | #: E111 E117 5 | if True: 6 | print() - | ^^^^^ E111 + | ^^^^^ 7 | #: E112 8 | if False: | -E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:9:1 | 7 | #: E112 8 | if False: @@ -31,7 +34,8 @@ E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement 11 | print() | -E11.py:12:1: invalid-syntax: Unexpected indentation +invalid-syntax: Unexpected indentation + --> E11.py:12:1 | 10 | #: E113 11 | print() @@ -41,7 +45,8 @@ E11.py:12:1: invalid-syntax: Unexpected indentation 14 | mimetype = 'application/x-directory' | -E11.py:14:1: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> E11.py:14:1 | 12 | print() 13 | #: E114 E116 @@ -51,7 +56,8 @@ E11.py:14:1: invalid-syntax: Expected a statement 16 | create_date = False | -E11.py:45:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:45:1 | 43 | #: E112 44 | if False: # diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap index d0f4156303..b2544e4212 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap @@ -1,17 +1,19 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E11.py:9:1: E112 Expected an indented block +E112 Expected an indented block + --> E11.py:9:1 | 7 | #: E112 8 | if False: 9 | print() - | ^ E112 + | ^ 10 | #: E113 11 | print() | -E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:9:1 | 7 | #: E112 8 | if False: @@ -21,7 +23,8 @@ E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement 11 | print() | -E11.py:12:1: invalid-syntax: Unexpected indentation +invalid-syntax: Unexpected indentation + --> E11.py:12:1 | 10 | #: E113 11 | print() @@ -31,7 +34,8 @@ E11.py:12:1: invalid-syntax: Unexpected indentation 14 | mimetype = 'application/x-directory' | -E11.py:14:1: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> E11.py:14:1 | 12 | print() 13 | #: E114 E116 @@ -41,17 +45,19 @@ E11.py:14:1: invalid-syntax: Expected a statement 16 | create_date = False | -E11.py:45:1: E112 Expected an indented block +E112 Expected an indented block + --> E11.py:45:1 | 43 | #: E112 44 | if False: # 45 | print() - | ^ E112 + | ^ 46 | #: 47 | if False: | -E11.py:45:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:45:1 | 43 | #: E112 44 | if False: # diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E113_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E113_E11.py.snap index af7b677a47..4fdbcf5e3c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E113_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E113_E11.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:9:1 | 7 | #: E112 8 | if False: @@ -11,17 +12,8 @@ E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement 11 | print() | -E11.py:12:1: E113 Unexpected indentation - | -10 | #: E113 -11 | print() -12 | print() - | ^^^^ E113 -13 | #: E114 E116 -14 | mimetype = 'application/x-directory' - | - -E11.py:12:1: invalid-syntax: Unexpected indentation +E113 Unexpected indentation + --> E11.py:12:1 | 10 | #: E113 11 | print() @@ -31,7 +23,19 @@ E11.py:12:1: invalid-syntax: Unexpected indentation 14 | mimetype = 'application/x-directory' | -E11.py:14:1: invalid-syntax: Expected a statement +invalid-syntax: Unexpected indentation + --> E11.py:12:1 + | +10 | #: E113 +11 | print() +12 | print() + | ^^^^ +13 | #: E114 E116 +14 | mimetype = 'application/x-directory' + | + +invalid-syntax: Expected a statement + --> E11.py:14:1 | 12 | print() 13 | #: E114 E116 @@ -41,7 +45,8 @@ E11.py:14:1: invalid-syntax: Expected a statement 16 | create_date = False | -E11.py:45:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:45:1 | 43 | #: E112 44 | if False: # diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E114_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E114_E11.py.snap index c607a40024..06eb01f682 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E114_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E114_E11.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:9:1 | 7 | #: E112 8 | if False: @@ -11,7 +12,8 @@ E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement 11 | print() | -E11.py:12:1: invalid-syntax: Unexpected indentation +invalid-syntax: Unexpected indentation + --> E11.py:12:1 | 10 | #: E113 11 | print() @@ -21,7 +23,8 @@ E11.py:12:1: invalid-syntax: Unexpected indentation 14 | mimetype = 'application/x-directory' | -E11.py:14:1: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> E11.py:14:1 | 12 | print() 13 | #: E114 E116 @@ -31,17 +34,19 @@ E11.py:14:1: invalid-syntax: Expected a statement 16 | create_date = False | -E11.py:15:1: E114 Indentation is not a multiple of 4 (comment) +E114 Indentation is not a multiple of 4 (comment) + --> E11.py:15:1 | 13 | #: E114 E116 14 | mimetype = 'application/x-directory' 15 | # 'httpd/unix-directory' - | ^^^^^ E114 + | ^^^^^ 16 | create_date = False 17 | #: E116 E116 E116 | -E11.py:45:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:45:1 | 43 | #: E112 44 | if False: # diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap index ac2d406eaf..b4655dd131 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:9:1 | 7 | #: E112 8 | if False: @@ -11,7 +12,8 @@ E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement 11 | print() | -E11.py:12:1: invalid-syntax: Unexpected indentation +invalid-syntax: Unexpected indentation + --> E11.py:12:1 | 10 | #: E113 11 | print() @@ -21,7 +23,8 @@ E11.py:12:1: invalid-syntax: Unexpected indentation 14 | mimetype = 'application/x-directory' | -E11.py:14:1: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> E11.py:14:1 | 12 | print() 13 | #: E114 E116 @@ -31,67 +34,74 @@ E11.py:14:1: invalid-syntax: Expected a statement 16 | create_date = False | -E11.py:30:1: E115 Expected an indented block (comment) +E115 Expected an indented block (comment) + --> E11.py:30:1 | 28 | def start(self): 29 | if True: 30 | # try: - | ^ E115 + | ^ 31 | # self.master.start() 32 | # except MasterExit: | -E11.py:31:1: E115 Expected an indented block (comment) +E115 Expected an indented block (comment) + --> E11.py:31:1 | 29 | if True: 30 | # try: 31 | # self.master.start() - | ^ E115 + | ^ 32 | # except MasterExit: 33 | # self.shutdown() | -E11.py:32:1: E115 Expected an indented block (comment) +E115 Expected an indented block (comment) + --> E11.py:32:1 | 30 | # try: 31 | # self.master.start() 32 | # except MasterExit: - | ^ E115 + | ^ 33 | # self.shutdown() 34 | # finally: | -E11.py:33:1: E115 Expected an indented block (comment) +E115 Expected an indented block (comment) + --> E11.py:33:1 | 31 | # self.master.start() 32 | # except MasterExit: 33 | # self.shutdown() - | ^ E115 + | ^ 34 | # finally: 35 | # sys.exit() | -E11.py:34:1: E115 Expected an indented block (comment) +E115 Expected an indented block (comment) + --> E11.py:34:1 | 32 | # except MasterExit: 33 | # self.shutdown() 34 | # finally: - | ^ E115 + | ^ 35 | # sys.exit() 36 | self.master.start() | -E11.py:35:1: E115 Expected an indented block (comment) +E115 Expected an indented block (comment) + --> E11.py:35:1 | 33 | # self.shutdown() 34 | # finally: 35 | # sys.exit() - | ^ E115 + | ^ 36 | self.master.start() 37 | #: E117 | -E11.py:45:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:45:1 | 43 | #: E112 44 | if False: # diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E116_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E116_E11.py.snap index fce1b92cbe..f70307eaa6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E116_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E116_E11.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:9:1 | 7 | #: E112 8 | if False: @@ -11,7 +12,8 @@ E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement 11 | print() | -E11.py:12:1: invalid-syntax: Unexpected indentation +invalid-syntax: Unexpected indentation + --> E11.py:12:1 | 10 | #: E113 11 | print() @@ -21,7 +23,8 @@ E11.py:12:1: invalid-syntax: Unexpected indentation 14 | mimetype = 'application/x-directory' | -E11.py:14:1: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> E11.py:14:1 | 12 | print() 13 | #: E114 E116 @@ -31,47 +34,52 @@ E11.py:14:1: invalid-syntax: Expected a statement 16 | create_date = False | -E11.py:15:1: E116 Unexpected indentation (comment) +E116 Unexpected indentation (comment) + --> E11.py:15:1 | 13 | #: E114 E116 14 | mimetype = 'application/x-directory' 15 | # 'httpd/unix-directory' - | ^^^^^ E116 + | ^^^^^ 16 | create_date = False 17 | #: E116 E116 E116 | -E11.py:22:1: E116 Unexpected indentation (comment) +E116 Unexpected indentation (comment) + --> E11.py:22:1 | 20 | self.master.start() 21 | # try: 22 | # self.master.start() - | ^^^^^^^^^^^^ E116 + | ^^^^^^^^^^^^ 23 | # except MasterExit: 24 | # self.shutdown() | -E11.py:24:1: E116 Unexpected indentation (comment) +E116 Unexpected indentation (comment) + --> E11.py:24:1 | 22 | # self.master.start() 23 | # except MasterExit: 24 | # self.shutdown() - | ^^^^^^^^^^^^ E116 + | ^^^^^^^^^^^^ 25 | # finally: 26 | # sys.exit() | -E11.py:26:1: E116 Unexpected indentation (comment) +E116 Unexpected indentation (comment) + --> E11.py:26:1 | 24 | # self.shutdown() 25 | # finally: 26 | # sys.exit() - | ^^^^^^^^^^^^ E116 + | ^^^^^^^^^^^^ 27 | #: E115 E115 E115 E115 E115 E115 28 | def start(self): | -E11.py:45:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:45:1 | 43 | #: E112 44 | if False: # diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E117_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E117_E11.py.snap index df779d24bc..10f126e602 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E117_E11.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E117_E11.py.snap @@ -1,17 +1,19 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E11.py:6:1: E117 Over-indented +E117 Over-indented + --> E11.py:6:1 | 4 | #: E111 E117 5 | if True: 6 | print() - | ^^^^^ E117 + | ^^^^^ 7 | #: E112 8 | if False: | -E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:9:1 | 7 | #: E112 8 | if False: @@ -21,7 +23,8 @@ E11.py:9:1: invalid-syntax: Expected an indented block after `if` statement 11 | print() | -E11.py:12:1: invalid-syntax: Unexpected indentation +invalid-syntax: Unexpected indentation + --> E11.py:12:1 | 10 | #: E113 11 | print() @@ -31,7 +34,8 @@ E11.py:12:1: invalid-syntax: Unexpected indentation 14 | mimetype = 'application/x-directory' | -E11.py:14:1: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> E11.py:14:1 | 12 | print() 13 | #: E114 E116 @@ -41,27 +45,30 @@ E11.py:14:1: invalid-syntax: Expected a statement 16 | create_date = False | -E11.py:39:1: E117 Over-indented +E117 Over-indented + --> E11.py:39:1 | 37 | #: E117 38 | def start(): 39 | print() - | ^^^^^^^^ E117 + | ^^^^^^^^ 40 | #: E117 W191 41 | def start(): | -E11.py:42:1: E117 Over-indented +E117 Over-indented + --> E11.py:42:1 | 40 | #: E117 W191 41 | def start(): 42 | print() - | ^^^^^^^^ E117 + | ^^^^^^^^ 43 | #: E112 44 | if False: # | -E11.py:45:1: invalid-syntax: Expected an indented block after `if` statement +invalid-syntax: Expected an indented block after `if` statement + --> E11.py:45:1 | 43 | #: E112 44 | if False: # diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap index 565aecd3f3..c85c3b4a81 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E20.py:2:6: E201 [*] Whitespace after '(' +E201 [*] Whitespace after '(' + --> E20.py:2:6 | 1 | #: E201:1:6 2 | spam( ham[1], {eggs: 2}) - | ^ E201 + | ^ 3 | #: E201:1:10 4 | spam(ham[ 1], {eggs: 2}) | - = help: Remove whitespace before '(' +help: Remove whitespace before '(' ℹ Safe fix 1 1 | #: E201:1:6 @@ -19,16 +20,17 @@ E20.py:2:6: E201 [*] Whitespace after '(' 4 4 | spam(ham[ 1], {eggs: 2}) 5 5 | #: E201:1:15 -E20.py:4:10: E201 [*] Whitespace after '[' +E201 [*] Whitespace after '[' + --> E20.py:4:10 | 2 | spam( ham[1], {eggs: 2}) 3 | #: E201:1:10 4 | spam(ham[ 1], {eggs: 2}) - | ^ E201 + | ^ 5 | #: E201:1:15 6 | spam(ham[1], { eggs: 2}) | - = help: Remove whitespace before '[' +help: Remove whitespace before '[' ℹ Safe fix 1 1 | #: E201:1:6 @@ -40,16 +42,17 @@ E20.py:4:10: E201 [*] Whitespace after '[' 6 6 | spam(ham[1], { eggs: 2}) 7 7 | #: E201:1:6 -E20.py:6:15: E201 [*] Whitespace after '{' +E201 [*] Whitespace after '{' + --> E20.py:6:15 | 4 | spam(ham[ 1], {eggs: 2}) 5 | #: E201:1:15 6 | spam(ham[1], { eggs: 2}) - | ^ E201 + | ^ 7 | #: E201:1:6 8 | spam( ham[1], {eggs: 2}) | - = help: Remove whitespace before '{' +help: Remove whitespace before '{' ℹ Safe fix 3 3 | #: E201:1:10 @@ -61,16 +64,17 @@ E20.py:6:15: E201 [*] Whitespace after '{' 8 8 | spam( ham[1], {eggs: 2}) 9 9 | #: E201:1:10 -E20.py:8:6: E201 [*] Whitespace after '(' +E201 [*] Whitespace after '(' + --> E20.py:8:6 | 6 | spam(ham[1], { eggs: 2}) 7 | #: E201:1:6 8 | spam( ham[1], {eggs: 2}) - | ^^^^ E201 + | ^^^^ 9 | #: E201:1:10 10 | spam(ham[ 1], {eggs: 2}) | - = help: Remove whitespace before '(' +help: Remove whitespace before '(' ℹ Safe fix 5 5 | #: E201:1:15 @@ -82,16 +86,17 @@ E20.py:8:6: E201 [*] Whitespace after '(' 10 10 | spam(ham[ 1], {eggs: 2}) 11 11 | #: E201:1:15 -E20.py:10:10: E201 [*] Whitespace after '[' +E201 [*] Whitespace after '[' + --> E20.py:10:10 | 8 | spam( ham[1], {eggs: 2}) 9 | #: E201:1:10 10 | spam(ham[ 1], {eggs: 2}) - | ^^^^ E201 + | ^^^^ 11 | #: E201:1:15 12 | spam(ham[1], { eggs: 2}) | - = help: Remove whitespace before '[' +help: Remove whitespace before '[' ℹ Safe fix 7 7 | #: E201:1:6 @@ -103,16 +108,17 @@ E20.py:10:10: E201 [*] Whitespace after '[' 12 12 | spam(ham[1], { eggs: 2}) 13 13 | #: Okay -E20.py:12:15: E201 [*] Whitespace after '{' +E201 [*] Whitespace after '{' + --> E20.py:12:15 | 10 | spam(ham[ 1], {eggs: 2}) 11 | #: E201:1:15 12 | spam(ham[1], { eggs: 2}) - | ^^^^ E201 + | ^^^^ 13 | #: Okay 14 | spam(ham[1], {eggs: 2}) | - = help: Remove whitespace before '{' +help: Remove whitespace before '{' ℹ Safe fix 9 9 | #: E201:1:10 @@ -124,15 +130,16 @@ E20.py:12:15: E201 [*] Whitespace after '{' 14 14 | spam(ham[1], {eggs: 2}) 15 15 | #: -E20.py:107:6: E201 [*] Whitespace after '[' +E201 [*] Whitespace after '[' + --> E20.py:107:6 | 106 | #: E201:1:6 107 | spam[ ~ham] - | ^ E201 + | ^ 108 | 109 | #: Okay | - = help: Remove whitespace before '[' +help: Remove whitespace before '[' ℹ Safe fix 104 104 | #: @@ -144,15 +151,16 @@ E20.py:107:6: E201 [*] Whitespace after '[' 109 109 | #: Okay 110 110 | x = [ # -E20.py:116:5: E201 [*] Whitespace after '[' +E201 [*] Whitespace after '[' + --> E20.py:116:5 | 114 | # F-strings 115 | f"{ {'a': 1} }" 116 | f"{[ { {'a': 1} } ]}" - | ^ E201 + | ^ 117 | f"normal { {f"{ { [1, 2] } }" } } normal" | - = help: Remove whitespace before '[' +help: Remove whitespace before '[' ℹ Safe fix 113 113 | @@ -164,15 +172,16 @@ E20.py:116:5: E201 [*] Whitespace after '[' 118 118 | 119 119 | #: Okay -E20.py:145:5: E201 [*] Whitespace after '[' +E201 [*] Whitespace after '[' + --> E20.py:145:5 | 144 | #: E201:1:5 145 | ham[ : upper] - | ^ E201 + | ^ 146 | 147 | #: Okay | - = help: Remove whitespace before '[' +help: Remove whitespace before '[' ℹ Safe fix 142 142 | ham[lower + offset : upper + offset] @@ -184,15 +193,16 @@ E20.py:145:5: E201 [*] Whitespace after '[' 147 147 | #: Okay 148 148 | ham[lower + offset :: upper + offset] -E20.py:195:5: E201 [*] Whitespace after '[' +E201 [*] Whitespace after '[' + --> E20.py:195:5 | 193 | # t-strings 194 | t"{ {'a': 1} }" 195 | t"{[ { {'a': 1} } ]}" - | ^ E201 + | ^ 196 | t"normal { {t"{ { [1, 2] } }" } } normal" | - = help: Remove whitespace before '[' +help: Remove whitespace before '[' ℹ Safe fix 192 192 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap index 75a7c14205..839db34d56 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E20.py:19:23: E202 [*] Whitespace before ')' +E202 [*] Whitespace before ')' + --> E20.py:19:23 | 18 | #: E202:1:23 19 | spam(ham[1], {eggs: 2} ) - | ^ E202 + | ^ 20 | #: E202:1:22 21 | spam(ham[1], {eggs: 2 }) | - = help: Remove whitespace before ')' +help: Remove whitespace before ')' ℹ Safe fix 16 16 | @@ -21,16 +22,17 @@ E20.py:19:23: E202 [*] Whitespace before ')' 21 21 | spam(ham[1], {eggs: 2 }) 22 22 | #: E202:1:11 -E20.py:21:22: E202 [*] Whitespace before '}' +E202 [*] Whitespace before '}' + --> E20.py:21:22 | 19 | spam(ham[1], {eggs: 2} ) 20 | #: E202:1:22 21 | spam(ham[1], {eggs: 2 }) - | ^ E202 + | ^ 22 | #: E202:1:11 23 | spam(ham[1 ], {eggs: 2}) | - = help: Remove whitespace before '}' +help: Remove whitespace before '}' ℹ Safe fix 18 18 | #: E202:1:23 @@ -42,16 +44,17 @@ E20.py:21:22: E202 [*] Whitespace before '}' 23 23 | spam(ham[1 ], {eggs: 2}) 24 24 | #: E202:1:23 -E20.py:23:11: E202 [*] Whitespace before ']' +E202 [*] Whitespace before ']' + --> E20.py:23:11 | 21 | spam(ham[1], {eggs: 2 }) 22 | #: E202:1:11 23 | spam(ham[1 ], {eggs: 2}) - | ^ E202 + | ^ 24 | #: E202:1:23 25 | spam(ham[1], {eggs: 2} ) | - = help: Remove whitespace before ']' +help: Remove whitespace before ']' ℹ Safe fix 20 20 | #: E202:1:22 @@ -63,16 +66,17 @@ E20.py:23:11: E202 [*] Whitespace before ']' 25 25 | spam(ham[1], {eggs: 2} ) 26 26 | #: E202:1:22 -E20.py:25:23: E202 [*] Whitespace before ')' +E202 [*] Whitespace before ')' + --> E20.py:25:23 | 23 | spam(ham[1 ], {eggs: 2}) 24 | #: E202:1:23 25 | spam(ham[1], {eggs: 2} ) - | ^^^^ E202 + | ^^^^ 26 | #: E202:1:22 27 | spam(ham[1], {eggs: 2 }) | - = help: Remove whitespace before ')' +help: Remove whitespace before ')' ℹ Safe fix 22 22 | #: E202:1:11 @@ -84,16 +88,17 @@ E20.py:25:23: E202 [*] Whitespace before ')' 27 27 | spam(ham[1], {eggs: 2 }) 28 28 | #: E202:1:11 -E20.py:27:22: E202 [*] Whitespace before '}' +E202 [*] Whitespace before '}' + --> E20.py:27:22 | 25 | spam(ham[1], {eggs: 2} ) 26 | #: E202:1:22 27 | spam(ham[1], {eggs: 2 }) - | ^^^^ E202 + | ^^^^ 28 | #: E202:1:11 29 | spam(ham[1 ], {eggs: 2}) | - = help: Remove whitespace before '}' +help: Remove whitespace before '}' ℹ Safe fix 24 24 | #: E202:1:23 @@ -105,16 +110,17 @@ E20.py:27:22: E202 [*] Whitespace before '}' 29 29 | spam(ham[1 ], {eggs: 2}) 30 30 | #: Okay -E20.py:29:11: E202 [*] Whitespace before ']' +E202 [*] Whitespace before ']' + --> E20.py:29:11 | 27 | spam(ham[1], {eggs: 2 }) 28 | #: E202:1:11 29 | spam(ham[1 ], {eggs: 2}) - | ^^^^ E202 + | ^^^^ 30 | #: Okay 31 | spam(ham[1], {eggs: 2}) | - = help: Remove whitespace before ']' +help: Remove whitespace before ']' ℹ Safe fix 26 26 | #: E202:1:22 @@ -126,15 +132,16 @@ E20.py:29:11: E202 [*] Whitespace before ']' 31 31 | spam(ham[1], {eggs: 2}) 32 32 | -E20.py:116:18: E202 [*] Whitespace before ']' +E202 [*] Whitespace before ']' + --> E20.py:116:18 | 114 | # F-strings 115 | f"{ {'a': 1} }" 116 | f"{[ { {'a': 1} } ]}" - | ^ E202 + | ^ 117 | f"normal { {f"{ { [1, 2] } }" } } normal" | - = help: Remove whitespace before ']' +help: Remove whitespace before ']' ℹ Safe fix 113 113 | @@ -146,15 +153,16 @@ E20.py:116:18: E202 [*] Whitespace before ']' 118 118 | 119 119 | #: Okay -E20.py:172:12: E202 [*] Whitespace before ']' +E202 [*] Whitespace before ']' + --> E20.py:172:12 | 171 | #: E202:1:12 172 | ham[upper : ] - | ^ E202 + | ^ 173 | 174 | #: E203:1:10 | - = help: Remove whitespace before ']' +help: Remove whitespace before ']' ℹ Safe fix 169 169 | ham[upper :] @@ -166,15 +174,16 @@ E20.py:172:12: E202 [*] Whitespace before ']' 174 174 | #: E203:1:10 175 175 | ham[upper :] -E20.py:195:18: E202 [*] Whitespace before ']' +E202 [*] Whitespace before ']' + --> E20.py:195:18 | 193 | # t-strings 194 | t"{ {'a': 1} }" 195 | t"{[ { {'a': 1} } ]}" - | ^ E202 + | ^ 196 | t"normal { {t"{ { [1, 2] } }" } } normal" | - = help: Remove whitespace before ']' +help: Remove whitespace before ']' ℹ Safe fix 192 192 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap index 0b11c2e96d..f8cd84d5de 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E20.py:51:10: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:51:10 | 50 | #: E203:1:10 51 | if x == 4 : - | ^ E203 + | ^ 52 | print(x, y) 53 | x, y = y, x | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 48 48 | @@ -21,16 +22,17 @@ E20.py:51:10: E203 [*] Whitespace before ':' 53 53 | x, y = y, x 54 54 | #: E203:1:10 -E20.py:55:10: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:55:10 | 53 | x, y = y, x 54 | #: E203:1:10 55 | if x == 4 : - | ^^^^ E203 + | ^^^^ 56 | print(x, y) 57 | x, y = y, x | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 52 52 | print(x, y) @@ -42,16 +44,17 @@ E20.py:55:10: E203 [*] Whitespace before ':' 57 57 | x, y = y, x 58 58 | #: E203:2:15 E702:2:16 -E20.py:60:16: E203 [*] Whitespace before ';' +E203 [*] Whitespace before ';' + --> E20.py:60:16 | 58 | #: E203:2:15 E702:2:16 59 | if x == 4: 60 | print(x, y) ; x, y = y, x - | ^ E203 + | ^ 61 | #: E203:2:15 E702:2:16 62 | if x == 4: | - = help: Remove whitespace before ';' +help: Remove whitespace before ';' ℹ Safe fix 57 57 | x, y = y, x @@ -63,16 +66,17 @@ E20.py:60:16: E203 [*] Whitespace before ';' 62 62 | if x == 4: 63 63 | print(x, y) ; x, y = y, x -E20.py:63:16: E203 [*] Whitespace before ';' +E203 [*] Whitespace before ';' + --> E20.py:63:16 | 61 | #: E203:2:15 E702:2:16 62 | if x == 4: 63 | print(x, y) ; x, y = y, x - | ^^^^ E203 + | ^^^^ 64 | #: E203:3:13 65 | if x == 4: | - = help: Remove whitespace before ';' +help: Remove whitespace before ';' ℹ Safe fix 60 60 | print(x, y) ; x, y = y, x @@ -84,16 +88,17 @@ E20.py:63:16: E203 [*] Whitespace before ';' 65 65 | if x == 4: 66 66 | print(x, y) -E20.py:67:13: E203 [*] Whitespace before ',' +E203 [*] Whitespace before ',' + --> E20.py:67:13 | 65 | if x == 4: 66 | print(x, y) 67 | x, y = y , x - | ^ E203 + | ^ 68 | #: E203:3:13 69 | if x == 4: | - = help: Remove whitespace before ',' +help: Remove whitespace before ',' ℹ Safe fix 64 64 | #: E203:3:13 @@ -105,16 +110,17 @@ E20.py:67:13: E203 [*] Whitespace before ',' 69 69 | if x == 4: 70 70 | print(x, y) -E20.py:71:13: E203 [*] Whitespace before ',' +E203 [*] Whitespace before ',' + --> E20.py:71:13 | 69 | if x == 4: 70 | print(x, y) 71 | x, y = y , x - | ^^^^ E203 + | ^^^^ 72 | #: Okay 73 | if x == 4: | - = help: Remove whitespace before ',' +help: Remove whitespace before ',' ℹ Safe fix 68 68 | #: E203:3:13 @@ -126,15 +132,16 @@ E20.py:71:13: E203 [*] Whitespace before ',' 73 73 | if x == 4: 74 74 | print(x, y) -E20.py:86:61: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:86:61 | 84 | #: E203 multi whitespace before : 85 | predictions = predictions[ 86 | len(past_covariates) // datamodule.hparams["downsample"] : - | ^^ E203 + | ^^ 87 | ] | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 83 83 | @@ -146,15 +153,16 @@ E20.py:86:61: E203 [*] Whitespace before ':' 88 88 | 89 89 | #: E203 tab before : -E20.py:91:61: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:91:61 | 89 | #: E203 tab before : 90 | predictions = predictions[ 91 | len(past_covariates) // datamodule.hparams["downsample"] : - | ^^^^ E203 + | ^^^^ 92 | ] | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 88 88 | @@ -166,15 +174,16 @@ E20.py:91:61: E203 [*] Whitespace before ':' 93 93 | 94 94 | #: E203 single whitespace before : with line a comment -E20.py:101:61: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:101:61 | 99 | #: E203 multi whitespace before : with line a comment 100 | predictions = predictions[ 101 | len(past_covariates) // datamodule.hparams["downsample"] : # Just some comment - | ^^ E203 + | ^^ 102 | ] | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 98 98 | @@ -186,15 +195,16 @@ E20.py:101:61: E203 [*] Whitespace before ':' 103 103 | 104 104 | #: -E20.py:126:16: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:126:16 | 125 | #: E203:1:19 126 | {lower + offset : upper + offset} - | ^ E203 + | ^ 127 | 128 | #: E203:1:19 | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 123 123 | ham[(lower + offset) : upper + offset] @@ -206,15 +216,16 @@ E20.py:126:16: E203 [*] Whitespace before ':' 128 128 | #: E203:1:19 129 129 | ham[lower + offset : upper + offset] -E20.py:129:19: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:129:19 | 128 | #: E203:1:19 129 | ham[lower + offset : upper + offset] - | ^^ E203 + | ^^ 130 | 131 | #: Okay | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 126 126 | {lower + offset : upper + offset} @@ -226,15 +237,16 @@ E20.py:129:19: E203 [*] Whitespace before ':' 131 131 | #: Okay 132 132 | release_lines = history_file_lines[history_file_lines.index('## Unreleased') + 1: -1] -E20.py:157:21: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:157:21 | 156 | #: E203:1:21 157 | ham[lower + offset : : upper + offset] - | ^ E203 + | ^ 158 | 159 | #: E203:1:20 | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 154 154 | ham[lower + offset::upper + offset] @@ -246,15 +258,16 @@ E20.py:157:21: E203 [*] Whitespace before ':' 159 159 | #: E203:1:20 160 160 | ham[lower + offset: :upper + offset] -E20.py:160:20: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:160:20 | 159 | #: E203:1:20 160 | ham[lower + offset: :upper + offset] - | ^ E203 + | ^ 161 | 162 | #: E203:1:20 | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 157 157 | ham[lower + offset : : upper + offset] @@ -266,15 +279,16 @@ E20.py:160:20: E203 [*] Whitespace before ':' 162 162 | #: E203:1:20 163 163 | ham[{lower + offset : upper + offset} : upper + offset] -E20.py:163:20: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:163:20 | 162 | #: E203:1:20 163 | ham[{lower + offset : upper + offset} : upper + offset] - | ^ E203 + | ^ 164 | 165 | #: Okay | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 160 160 | ham[lower + offset: :upper + offset] @@ -286,15 +300,16 @@ E20.py:163:20: E203 [*] Whitespace before ':' 165 165 | #: Okay 166 166 | ham[upper:] -E20.py:175:10: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:175:10 | 174 | #: E203:1:10 175 | ham[upper :] - | ^^ E203 + | ^^ 176 | 177 | #: Okay | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 172 172 | ham[upper : ] @@ -306,15 +321,16 @@ E20.py:175:10: E203 [*] Whitespace before ':' 177 177 | #: Okay 178 178 | ham[lower +1 :, "columnname"] -E20.py:181:14: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:181:14 | 180 | #: E203:1:13 181 | ham[lower + 1 :, "columnname"] - | ^^ E203 + | ^^ 182 | 183 | #: Okay | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 178 178 | ham[lower +1 :, "columnname"] @@ -326,15 +342,16 @@ E20.py:181:14: E203 [*] Whitespace before ':' 183 183 | #: Okay 184 184 | f"{ham[lower +1 :, "columnname"]}" -E20.py:187:17: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:187:17 | 186 | #: E203:1:13 187 | f"{ham[lower + 1 :, "columnname"]}" - | ^^ E203 + | ^^ 188 | 189 | #: Okay: https://github.com/astral-sh/ruff/issues/12023 | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 184 184 | f"{ham[lower +1 :, "columnname"]}" @@ -346,13 +363,14 @@ E20.py:187:17: E203 [*] Whitespace before ':' 189 189 | #: Okay: https://github.com/astral-sh/ruff/issues/12023 190 190 | f"{x = :.2f}" -E20.py:205:17: E203 [*] Whitespace before ':' +E203 [*] Whitespace before ':' + --> E20.py:205:17 | 204 | #: E203:1:13 205 | t"{ham[lower + 1 :, "columnname"]}" - | ^^ E203 + | ^^ | - = help: Remove whitespace before ':' +help: Remove whitespace before ':' ℹ Safe fix 202 202 | t"{ham[lower +1 :, "columnname"]}" diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap index 2ef347934b..47b03f8b73 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E204_E204.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E204.py:14:2: E204 [*] Whitespace after decorator +E204 [*] Whitespace after decorator + --> E204.py:14:2 | 13 | # E204 14 | @ foo - | ^ E204 + | ^ 15 | def baz(): 16 | print('baz') | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 11 11 | print('bar') @@ -21,15 +22,16 @@ E204.py:14:2: E204 [*] Whitespace after decorator 16 16 | print('baz') 17 17 | -E204.py:25:6: E204 [*] Whitespace after decorator +E204 [*] Whitespace after decorator + --> E204.py:25:6 | 24 | # E204 25 | @ foo - | ^ E204 + | ^ 26 | def baz(self): 27 | print('baz') | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 22 22 | print('bar') @@ -41,16 +43,16 @@ E204.py:25:6: E204 [*] Whitespace after decorator 27 27 | print('baz') 28 28 | -E204.py:31:2: E204 [*] Whitespace after decorator +E204 [*] Whitespace after decorator + --> E204.py:31:2 | 30 | # E204 31 | @ \ - | ^^ E204 + | ^^ 32 | foo 33 | def baz(): -34 | print('baz') | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 28 28 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap index d3f2362f78..c9307277cb 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E21.py:2:5: E211 [*] Whitespace before '(' +E211 [*] Whitespace before '(' + --> E21.py:2:5 | 1 | #: E211 2 | spam (1) - | ^ E211 + | ^ 3 | #: E211 E211 4 | dict ['key'] = list [index] | - = help: Removed whitespace before '(' +help: Removed whitespace before '(' ℹ Safe fix 1 1 | #: E211 @@ -20,16 +20,17 @@ E21.py:2:5: E211 [*] Whitespace before '(' 4 4 | dict ['key'] = list [index] 5 5 | #: E211 -E21.py:4:5: E211 [*] Whitespace before '[' +E211 [*] Whitespace before '[' + --> E21.py:4:5 | 2 | spam (1) 3 | #: E211 E211 4 | dict ['key'] = list [index] - | ^ E211 + | ^ 5 | #: E211 6 | dict['key'] ['subkey'] = list[index] | - = help: Removed whitespace before '[' +help: Removed whitespace before '[' ℹ Safe fix 1 1 | #: E211 @@ -41,16 +42,17 @@ E21.py:4:5: E211 [*] Whitespace before '[' 6 6 | dict['key'] ['subkey'] = list[index] 7 7 | #: Okay -E21.py:4:20: E211 [*] Whitespace before '[' +E211 [*] Whitespace before '[' + --> E21.py:4:20 | 2 | spam (1) 3 | #: E211 E211 4 | dict ['key'] = list [index] - | ^ E211 + | ^ 5 | #: E211 6 | dict['key'] ['subkey'] = list[index] | - = help: Removed whitespace before '[' +help: Removed whitespace before '[' ℹ Safe fix 1 1 | #: E211 @@ -62,16 +64,17 @@ E21.py:4:20: E211 [*] Whitespace before '[' 6 6 | dict['key'] ['subkey'] = list[index] 7 7 | #: Okay -E21.py:6:12: E211 [*] Whitespace before '[' +E211 [*] Whitespace before '[' + --> E21.py:6:12 | 4 | dict ['key'] = list [index] 5 | #: E211 6 | dict['key'] ['subkey'] = list[index] - | ^ E211 + | ^ 7 | #: Okay 8 | spam(1) | - = help: Removed whitespace before '[' +help: Removed whitespace before '[' ℹ Safe fix 3 3 | #: E211 E211 @@ -83,13 +86,14 @@ E21.py:6:12: E211 [*] Whitespace before '[' 8 8 | spam(1) 9 9 | dict['key'] = list[index] -E21.py:17:15: E211 [*] Whitespace before '(' +E211 [*] Whitespace before '(' + --> E21.py:17:15 | 17 | def fetch_name () -> Union[str, None]: - | ^ E211 + | ^ 18 | """Fetch name from --person-name in sys.argv. | - = help: Removed whitespace before '(' +help: Removed whitespace before '(' ℹ Safe fix 14 14 | pass @@ -101,16 +105,17 @@ E21.py:17:15: E211 [*] Whitespace before '(' 19 19 | 20 20 | Returns: -E21.py:27:19: E211 [*] Whitespace before '(' +E211 [*] Whitespace before '(' + --> E21.py:27:19 | 25 | # test commented code 26 | # Logger.info("test code") 27 | for i in range (0, len (sys.argv)) : - | ^ E211 + | ^ 28 | if sys.argv[i] == "--name" : 29 | return sys.argv[i + 1] | - = help: Removed whitespace before '(' +help: Removed whitespace before '(' ℹ Safe fix 24 24 | Logger.info(test) @@ -122,16 +127,17 @@ E21.py:27:19: E211 [*] Whitespace before '(' 29 29 | return sys.argv[i + 1] 30 30 | return None -E21.py:27:27: E211 [*] Whitespace before '(' +E211 [*] Whitespace before '(' + --> E21.py:27:27 | 25 | # test commented code 26 | # Logger.info("test code") 27 | for i in range (0, len (sys.argv)) : - | ^ E211 + | ^ 28 | if sys.argv[i] == "--name" : 29 | return sys.argv[i + 1] | - = help: Removed whitespace before '(' +help: Removed whitespace before '(' ℹ Safe fix 24 24 | Logger.info(test) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap index ed500ca29f..b8afef65c3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E22.py:3:6: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:3:6 | 1 | #: E221 2 | a = 12 + 3 3 | b = 4 + 5 - | ^^ E221 + | ^^ 4 | #: E221 E221 5 | x = 1 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 1 1 | #: E221 @@ -21,16 +22,17 @@ E22.py:3:6: E221 [*] Multiple spaces before operator 5 5 | x = 1 6 6 | y = 2 -E22.py:5:2: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:5:2 | 3 | b = 4 + 5 4 | #: E221 E221 5 | x = 1 - | ^^^^^^^^^^^^^ E221 + | ^^^^^^^^^^^^^ 6 | y = 2 7 | long_variable = 3 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 2 2 | a = 12 + 3 @@ -42,16 +44,17 @@ E22.py:5:2: E221 [*] Multiple spaces before operator 7 7 | long_variable = 3 8 8 | #: E221 E221 -E22.py:6:2: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:6:2 | 4 | #: E221 E221 5 | x = 1 6 | y = 2 - | ^^^^^^^^^^^^^ E221 + | ^^^^^^^^^^^^^ 7 | long_variable = 3 8 | #: E221 E221 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 3 3 | b = 4 + 5 @@ -63,16 +66,17 @@ E22.py:6:2: E221 [*] Multiple spaces before operator 8 8 | #: E221 E221 9 9 | x[0] = 1 -E22.py:9:5: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:9:5 | 7 | long_variable = 3 8 | #: E221 E221 9 | x[0] = 1 - | ^^^^^^^^^^ E221 + | ^^^^^^^^^^ 10 | x[1] = 2 11 | long_variable = 3 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 6 6 | y = 2 @@ -84,16 +88,17 @@ E22.py:9:5: E221 [*] Multiple spaces before operator 11 11 | long_variable = 3 12 12 | #: E221 E221 -E22.py:10:5: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:10:5 | 8 | #: E221 E221 9 | x[0] = 1 10 | x[1] = 2 - | ^^^^^^^^^^ E221 + | ^^^^^^^^^^ 11 | long_variable = 3 12 | #: E221 E221 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 7 7 | long_variable = 3 @@ -105,16 +110,17 @@ E22.py:10:5: E221 [*] Multiple spaces before operator 12 12 | #: E221 E221 13 13 | x = f(x) + 1 -E22.py:13:9: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:13:9 | 11 | long_variable = 3 12 | #: E221 E221 13 | x = f(x) + 1 - | ^^^^^^^^^^ E221 + | ^^^^^^^^^^ 14 | y = long_variable + 2 15 | z = x[0] + 3 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 10 10 | x[1] = 2 @@ -126,16 +132,17 @@ E22.py:13:9: E221 [*] Multiple spaces before operator 15 15 | z = x[0] + 3 16 16 | #: E221:3:14 -E22.py:15:9: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:15:9 | 13 | x = f(x) + 1 14 | y = long_variable + 2 15 | z = x[0] + 3 - | ^^^^^^^^^^ E221 + | ^^^^^^^^^^ 16 | #: E221:3:14 17 | text = """ | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 12 12 | #: E221 E221 @@ -147,16 +154,17 @@ E22.py:15:9: E221 [*] Multiple spaces before operator 17 17 | text = """ 18 18 | bar -E22.py:19:14: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:19:14 | 17 | text = """ 18 | bar 19 | foo %s""" % rofl - | ^^ E221 + | ^^ 20 | #: Okay 21 | x = 1 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 16 16 | #: E221:3:14 @@ -168,15 +176,16 @@ E22.py:19:14: E221 [*] Multiple spaces before operator 21 21 | x = 1 22 22 | y = 2 -E22.py:184:5: E221 [*] Multiple spaces before operator +E221 [*] Multiple spaces before operator + --> E22.py:184:5 | 182 | #: 183 | 184 | if a == 1: - | ^^ E221 + | ^^ 185 | print(a) | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 181 181 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap index 9b6879bfbe..c3fa3fd64c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E22.py:28:8: E222 [*] Multiple spaces after operator +E222 [*] Multiple spaces after operator + --> E22.py:28:8 | 27 | #: E222 28 | a = a + 1 - | ^^ E222 + | ^^ 29 | b = b + 10 30 | #: E222 E222 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 25 25 | @@ -21,16 +22,17 @@ E22.py:28:8: E222 [*] Multiple spaces after operator 30 30 | #: E222 E222 31 31 | x = -1 -E22.py:31:4: E222 [*] Multiple spaces after operator +E222 [*] Multiple spaces after operator + --> E22.py:31:4 | 29 | b = b + 10 30 | #: E222 E222 31 | x = -1 - | ^^^^^^^^^^^^ E222 + | ^^^^^^^^^^^^ 32 | y = -2 33 | long_variable = 3 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 28 28 | a = a + 1 @@ -42,16 +44,17 @@ E22.py:31:4: E222 [*] Multiple spaces after operator 33 33 | long_variable = 3 34 34 | #: E222 E222 -E22.py:32:4: E222 [*] Multiple spaces after operator +E222 [*] Multiple spaces after operator + --> E22.py:32:4 | 30 | #: E222 E222 31 | x = -1 32 | y = -2 - | ^^^^^^^^^^^^ E222 + | ^^^^^^^^^^^^ 33 | long_variable = 3 34 | #: E222 E222 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 29 29 | b = b + 10 @@ -63,16 +66,17 @@ E22.py:32:4: E222 [*] Multiple spaces after operator 34 34 | #: E222 E222 35 35 | x[0] = 1 -E22.py:35:7: E222 [*] Multiple spaces after operator +E222 [*] Multiple spaces after operator + --> E22.py:35:7 | 33 | long_variable = 3 34 | #: E222 E222 35 | x[0] = 1 - | ^^^^^^^^^^ E222 + | ^^^^^^^^^^ 36 | x[1] = 2 37 | long_variable = 3 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 32 32 | y = -2 @@ -84,16 +88,17 @@ E22.py:35:7: E222 [*] Multiple spaces after operator 37 37 | long_variable = 3 38 38 | #: -E22.py:36:7: E222 [*] Multiple spaces after operator +E222 [*] Multiple spaces after operator + --> E22.py:36:7 | 34 | #: E222 E222 35 | x[0] = 1 36 | x[1] = 2 - | ^^^^^^^^^^ E222 + | ^^^^^^^^^^ 37 | long_variable = 3 38 | #: | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 33 33 | long_variable = 3 @@ -105,15 +110,16 @@ E22.py:36:7: E222 [*] Multiple spaces after operator 38 38 | #: 39 39 | -E22.py:184:9: E222 [*] Multiple spaces after operator +E222 [*] Multiple spaces after operator + --> E22.py:184:9 | 182 | #: 183 | 184 | if a == 1: - | ^^ E222 + | ^^ 185 | print(a) | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 181 181 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap index be53d063e5..b8b17d0a49 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E22.py:43:2: E223 [*] Tab before operator +E223 [*] Tab before operator + --> E22.py:43:2 | 41 | #: E223 42 | foobart = 4 43 | a = 3 # aligned with tab - | ^^^^ E223 + | ^^^^ 44 | #: | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 40 40 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap index 0e9c6256e9..d5af8158a4 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E22.py:48:5: E224 [*] Tab after operator +E224 [*] Tab after operator + --> E22.py:48:5 | 47 | #: E224 48 | a += 1 - | ^^^^ E224 + | ^^^^ 49 | b += 1000 50 | #: | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 45 45 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap index e6dbca24d8..5c9f55037a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E22.py:54:11: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:54:11 | 53 | #: E225 54 | submitted +=1 - | ^^ E225 + | ^^ 55 | #: E225 56 | submitted+= 1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 51 51 | @@ -22,16 +22,17 @@ E22.py:54:11: E225 [*] Missing whitespace around operator 56 56 | submitted+= 1 57 57 | #: E225 -E22.py:56:10: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:56:10 | 54 | submitted +=1 55 | #: E225 56 | submitted+= 1 - | ^^ E225 + | ^^ 57 | #: E225 58 | c =-1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 53 53 | #: E225 @@ -43,16 +44,17 @@ E22.py:56:10: E225 [*] Missing whitespace around operator 58 58 | c =-1 59 59 | #: E225 -E22.py:58:3: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:58:3 | 56 | submitted+= 1 57 | #: E225 58 | c =-1 - | ^ E225 + | ^ 59 | #: E225 60 | x = x /2 - 1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 55 55 | #: E225 @@ -64,16 +66,17 @@ E22.py:58:3: E225 [*] Missing whitespace around operator 60 60 | x = x /2 - 1 61 61 | #: E225 -E22.py:76:2: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:76:2 | 74 | _1kB = _1MB>> 10 75 | #: E225 E225 76 | i=i+ 1 - | ^ E225 + | ^ 77 | #: E225 E225 78 | i=i +1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 73 73 | #: E225 @@ -85,16 +88,17 @@ E22.py:76:2: E225 [*] Missing whitespace around operator 78 78 | i=i +1 79 79 | #: E225 -E22.py:78:2: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:78:2 | 76 | i=i+ 1 77 | #: E225 E225 78 | i=i +1 - | ^ E225 + | ^ 79 | #: E225 80 | i = 1and 1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 75 75 | #: E225 E225 @@ -106,16 +110,17 @@ E22.py:78:2: E225 [*] Missing whitespace around operator 80 80 | i = 1and 1 81 81 | #: E225 -E22.py:80:6: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:80:6 | 78 | i=i +1 79 | #: E225 80 | i = 1and 1 - | ^^^ E225 + | ^^^ 81 | #: E225 82 | i = 1or 0 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 77 77 | #: E225 E225 @@ -127,16 +132,17 @@ E22.py:80:6: E225 [*] Missing whitespace around operator 82 82 | i = 1or 0 83 83 | #: E225 -E22.py:82:6: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:82:6 | 80 | i = 1and 1 81 | #: E225 82 | i = 1or 0 - | ^^ E225 + | ^^ 83 | #: E225 84 | 1is 1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 79 79 | #: E225 @@ -148,16 +154,17 @@ E22.py:82:6: E225 [*] Missing whitespace around operator 84 84 | 1is 1 85 85 | #: E225 -E22.py:84:2: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:84:2 | 82 | i = 1or 0 83 | #: E225 84 | 1is 1 - | ^^ E225 + | ^^ 85 | #: E225 86 | 1in [] | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 81 81 | #: E225 @@ -169,16 +176,17 @@ E22.py:84:2: E225 [*] Missing whitespace around operator 86 86 | 1in [] 87 87 | #: E225 -E22.py:86:2: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:86:2 | 84 | 1is 1 85 | #: E225 86 | 1in [] - | ^^ E225 + | ^^ 87 | #: E225 88 | i = 1 @2 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 83 83 | #: E225 @@ -190,16 +198,17 @@ E22.py:86:2: E225 [*] Missing whitespace around operator 88 88 | i = 1 @2 89 89 | #: E225 -E22.py:92:2: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:92:2 | 90 | i = 1@ 2 91 | #: E225 E226 92 | i=i+1 - | ^ E225 + | ^ 93 | #: E225 E226 94 | i =i+1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 89 89 | #: E225 @@ -211,16 +220,17 @@ E22.py:92:2: E225 [*] Missing whitespace around operator 94 94 | i =i+1 95 95 | #: E225 E226 -E22.py:94:3: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:94:3 | 92 | i=i+1 93 | #: E225 E226 94 | i =i+1 - | ^ E225 + | ^ 95 | #: E225 E226 96 | i= i+1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 91 91 | #: E225 E226 @@ -232,16 +242,17 @@ E22.py:94:3: E225 [*] Missing whitespace around operator 96 96 | i= i+1 97 97 | #: E225 E226 -E22.py:96:2: E225 [*] Missing whitespace around operator +E225 [*] Missing whitespace around operator + --> E22.py:96:2 | 94 | i =i+1 95 | #: E225 E226 96 | i= i+1 - | ^ E225 + | ^ 97 | #: E225 E226 98 | c = (a +b)*(a - b) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 93 93 | #: E225 E226 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap index 6e16928ddf..3545f910f4 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E22.py:60:7: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:60:7 | 58 | c =-1 59 | #: E225 60 | x = x /2 - 1 - | ^ E226 + | ^ 61 | #: E225 62 | c = alpha -4 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 57 57 | #: E225 @@ -23,16 +23,17 @@ E22.py:60:7: E226 [*] Missing whitespace around arithmetic operator 62 62 | c = alpha -4 63 63 | #: E225 -E22.py:62:11: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:62:11 | 60 | x = x /2 - 1 61 | #: E225 62 | c = alpha -4 - | ^ E226 + | ^ 63 | #: E225 64 | c = alpha- 4 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 59 59 | #: E225 @@ -44,16 +45,17 @@ E22.py:62:11: E226 [*] Missing whitespace around arithmetic operator 64 64 | c = alpha- 4 65 65 | #: E225 -E22.py:64:10: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:64:10 | 62 | c = alpha -4 63 | #: E225 64 | c = alpha- 4 - | ^ E226 + | ^ 65 | #: E225 66 | z = x **y | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | #: E225 @@ -65,16 +67,17 @@ E22.py:64:10: E226 [*] Missing whitespace around arithmetic operator 66 66 | z = x **y 67 67 | #: E225 -E22.py:66:7: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:66:7 | 64 | c = alpha- 4 65 | #: E225 66 | z = x **y - | ^^ E226 + | ^^ 67 | #: E225 68 | z = (x + 1) **y | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 63 63 | #: E225 @@ -86,16 +89,17 @@ E22.py:66:7: E226 [*] Missing whitespace around arithmetic operator 68 68 | z = (x + 1) **y 69 69 | #: E225 -E22.py:68:13: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:68:13 | 66 | z = x **y 67 | #: E225 68 | z = (x + 1) **y - | ^^ E226 + | ^^ 69 | #: E225 70 | z = (x + 1)** y | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 65 65 | #: E225 @@ -107,16 +111,17 @@ E22.py:68:13: E226 [*] Missing whitespace around arithmetic operator 70 70 | z = (x + 1)** y 71 71 | #: E225 -E22.py:70:12: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:70:12 | 68 | z = (x + 1) **y 69 | #: E225 70 | z = (x + 1)** y - | ^^ E226 + | ^^ 71 | #: E225 72 | _1kB = _1MB >>10 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 67 67 | #: E225 @@ -128,16 +133,17 @@ E22.py:70:12: E226 [*] Missing whitespace around arithmetic operator 72 72 | _1kB = _1MB >>10 73 73 | #: E225 -E22.py:76:4: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:76:4 | 74 | _1kB = _1MB>> 10 75 | #: E225 E225 76 | i=i+ 1 - | ^ E226 + | ^ 77 | #: E225 E225 78 | i=i +1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 73 73 | #: E225 @@ -149,16 +155,17 @@ E22.py:76:4: E226 [*] Missing whitespace around arithmetic operator 78 78 | i=i +1 79 79 | #: E225 -E22.py:78:5: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:78:5 | 76 | i=i+ 1 77 | #: E225 E225 78 | i=i +1 - | ^ E226 + | ^ 79 | #: E225 80 | i = 1and 1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 75 75 | #: E225 E225 @@ -170,16 +177,17 @@ E22.py:78:5: E226 [*] Missing whitespace around arithmetic operator 80 80 | i = 1and 1 81 81 | #: E225 -E22.py:88:7: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:88:7 | 86 | 1in [] 87 | #: E225 88 | i = 1 @2 - | ^ E226 + | ^ 89 | #: E225 90 | i = 1@ 2 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 85 85 | #: E225 @@ -191,16 +199,17 @@ E22.py:88:7: E226 [*] Missing whitespace around arithmetic operator 90 90 | i = 1@ 2 91 91 | #: E225 E226 -E22.py:90:6: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:90:6 | 88 | i = 1 @2 89 | #: E225 90 | i = 1@ 2 - | ^ E226 + | ^ 91 | #: E225 E226 92 | i=i+1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 87 87 | #: E225 @@ -212,16 +221,17 @@ E22.py:90:6: E226 [*] Missing whitespace around arithmetic operator 92 92 | i=i+1 93 93 | #: E225 E226 -E22.py:92:4: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:92:4 | 90 | i = 1@ 2 91 | #: E225 E226 92 | i=i+1 - | ^ E226 + | ^ 93 | #: E225 E226 94 | i =i+1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 89 89 | #: E225 @@ -233,16 +243,17 @@ E22.py:92:4: E226 [*] Missing whitespace around arithmetic operator 94 94 | i =i+1 95 95 | #: E225 E226 -E22.py:94:5: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:94:5 | 92 | i=i+1 93 | #: E225 E226 94 | i =i+1 - | ^ E226 + | ^ 95 | #: E225 E226 96 | i= i+1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 91 91 | #: E225 E226 @@ -254,16 +265,17 @@ E22.py:94:5: E226 [*] Missing whitespace around arithmetic operator 96 96 | i= i+1 97 97 | #: E225 E226 -E22.py:96:5: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:96:5 | 94 | i =i+1 95 | #: E225 E226 96 | i= i+1 - | ^ E226 + | ^ 97 | #: E225 E226 98 | c = (a +b)*(a - b) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 93 93 | #: E225 E226 @@ -275,16 +287,17 @@ E22.py:96:5: E226 [*] Missing whitespace around arithmetic operator 98 98 | c = (a +b)*(a - b) 99 99 | #: E225 E226 -E22.py:98:8: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:98:8 | 96 | i= i+1 97 | #: E225 E226 98 | c = (a +b)*(a - b) - | ^ E226 + | ^ 99 | #: E225 E226 100 | c = (a+ b)*(a - b) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 95 95 | #: E225 E226 @@ -296,16 +309,17 @@ E22.py:98:8: E226 [*] Missing whitespace around arithmetic operator 100 100 | c = (a+ b)*(a - b) 101 101 | #: -E22.py:98:11: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:98:11 | 96 | i= i+1 97 | #: E225 E226 98 | c = (a +b)*(a - b) - | ^ E226 + | ^ 99 | #: E225 E226 100 | c = (a+ b)*(a - b) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 95 95 | #: E225 E226 @@ -317,15 +331,16 @@ E22.py:98:11: E226 [*] Missing whitespace around arithmetic operator 100 100 | c = (a+ b)*(a - b) 101 101 | #: -E22.py:100:7: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:100:7 | 98 | c = (a +b)*(a - b) 99 | #: E225 E226 100 | c = (a+ b)*(a - b) - | ^ E226 + | ^ 101 | #: | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 97 97 | #: E225 E226 @@ -337,15 +352,16 @@ E22.py:100:7: E226 [*] Missing whitespace around arithmetic operator 102 102 | 103 103 | #: E226 -E22.py:100:11: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:100:11 | 98 | c = (a +b)*(a - b) 99 | #: E225 E226 100 | c = (a+ b)*(a - b) - | ^ E226 + | ^ 101 | #: | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 97 97 | #: E225 E226 @@ -357,15 +373,16 @@ E22.py:100:11: E226 [*] Missing whitespace around arithmetic operator 102 102 | 103 103 | #: E226 -E22.py:104:6: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:104:6 | 103 | #: E226 104 | z = 2//30 - | ^^ E226 + | ^^ 105 | #: E226 E226 106 | c = (a+b) * (a-b) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 101 101 | #: @@ -377,16 +394,17 @@ E22.py:104:6: E226 [*] Missing whitespace around arithmetic operator 106 106 | c = (a+b) * (a-b) 107 107 | #: E226 -E22.py:106:7: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:106:7 | 104 | z = 2//30 105 | #: E226 E226 106 | c = (a+b) * (a-b) - | ^ E226 + | ^ 107 | #: E226 108 | norman = True+False | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 103 103 | #: E226 @@ -398,16 +416,17 @@ E22.py:106:7: E226 [*] Missing whitespace around arithmetic operator 108 108 | norman = True+False 109 109 | #: E226 -E22.py:106:15: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:106:15 | 104 | z = 2//30 105 | #: E226 E226 106 | c = (a+b) * (a-b) - | ^ E226 + | ^ 107 | #: E226 108 | norman = True+False | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 103 103 | #: E226 @@ -419,16 +438,17 @@ E22.py:106:15: E226 [*] Missing whitespace around arithmetic operator 108 108 | norman = True+False 109 109 | #: E226 -E22.py:110:6: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:110:6 | 108 | norman = True+False 109 | #: E226 110 | x = x*2 - 1 - | ^ E226 + | ^ 111 | #: E226 112 | x = x/2 - 1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 107 107 | #: E226 @@ -440,16 +460,17 @@ E22.py:110:6: E226 [*] Missing whitespace around arithmetic operator 112 112 | x = x/2 - 1 113 113 | #: E226 E226 -E22.py:112:6: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:112:6 | 110 | x = x*2 - 1 111 | #: E226 112 | x = x/2 - 1 - | ^ E226 + | ^ 113 | #: E226 E226 114 | hypot2 = x*x + y*y | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 109 109 | #: E226 @@ -461,16 +482,17 @@ E22.py:112:6: E226 [*] Missing whitespace around arithmetic operator 114 114 | hypot2 = x*x + y*y 115 115 | #: E226 -E22.py:114:11: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:114:11 | 112 | x = x/2 - 1 113 | #: E226 E226 114 | hypot2 = x*x + y*y - | ^ E226 + | ^ 115 | #: E226 116 | c = (a + b)*(a - b) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 111 111 | #: E226 @@ -482,16 +504,17 @@ E22.py:114:11: E226 [*] Missing whitespace around arithmetic operator 116 116 | c = (a + b)*(a - b) 117 117 | #: E226 -E22.py:114:17: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:114:17 | 112 | x = x/2 - 1 113 | #: E226 E226 114 | hypot2 = x*x + y*y - | ^ E226 + | ^ 115 | #: E226 116 | c = (a + b)*(a - b) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 111 111 | #: E226 @@ -503,16 +526,17 @@ E22.py:114:17: E226 [*] Missing whitespace around arithmetic operator 116 116 | c = (a + b)*(a - b) 117 117 | #: E226 -E22.py:116:12: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:116:12 | 114 | hypot2 = x*x + y*y 115 | #: E226 116 | c = (a + b)*(a - b) - | ^ E226 + | ^ 117 | #: E226 118 | def halves(n): | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 113 113 | #: E226 E226 @@ -524,16 +548,17 @@ E22.py:116:12: E226 [*] Missing whitespace around arithmetic operator 118 118 | def halves(n): 119 119 | return (i//2 for i in range(n)) -E22.py:119:14: E226 [*] Missing whitespace around arithmetic operator +E226 [*] Missing whitespace around arithmetic operator + --> E22.py:119:14 | 117 | #: E226 118 | def halves(n): 119 | return (i//2 for i in range(n)) - | ^^ E226 + | ^^ 120 | #: E227 121 | _1kB = _1MB>>10 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 116 116 | c = (a + b)*(a - b) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap index c6c317e218..da81b27486 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E22.py:72:13: E227 [*] Missing whitespace around bitwise or shift operator +E227 [*] Missing whitespace around bitwise or shift operator + --> E22.py:72:13 | 70 | z = (x + 1)** y 71 | #: E225 72 | _1kB = _1MB >>10 - | ^^ E227 + | ^^ 73 | #: E225 74 | _1kB = _1MB>> 10 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 69 69 | #: E225 @@ -23,16 +23,17 @@ E22.py:72:13: E227 [*] Missing whitespace around bitwise or shift operator 74 74 | _1kB = _1MB>> 10 75 75 | #: E225 E225 -E22.py:74:12: E227 [*] Missing whitespace around bitwise or shift operator +E227 [*] Missing whitespace around bitwise or shift operator + --> E22.py:74:12 | 72 | _1kB = _1MB >>10 73 | #: E225 74 | _1kB = _1MB>> 10 - | ^^ E227 + | ^^ 75 | #: E225 E225 76 | i=i+ 1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 71 71 | #: E225 @@ -44,16 +45,17 @@ E22.py:74:12: E227 [*] Missing whitespace around bitwise or shift operator 76 76 | i=i+ 1 77 77 | #: E225 E225 -E22.py:121:12: E227 [*] Missing whitespace around bitwise or shift operator +E227 [*] Missing whitespace around bitwise or shift operator + --> E22.py:121:12 | 119 | return (i//2 for i in range(n)) 120 | #: E227 121 | _1kB = _1MB>>10 - | ^^ E227 + | ^^ 122 | #: E227 123 | _1MB = _1kB<<10 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 118 118 | def halves(n): @@ -65,16 +67,17 @@ E22.py:121:12: E227 [*] Missing whitespace around bitwise or shift operator 123 123 | _1MB = _1kB<<10 124 124 | #: E227 -E22.py:123:12: E227 [*] Missing whitespace around bitwise or shift operator +E227 [*] Missing whitespace around bitwise or shift operator + --> E22.py:123:12 | 121 | _1kB = _1MB>>10 122 | #: E227 123 | _1MB = _1kB<<10 - | ^^ E227 + | ^^ 124 | #: E227 125 | a = b|c | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 120 120 | #: E227 @@ -86,16 +89,17 @@ E22.py:123:12: E227 [*] Missing whitespace around bitwise or shift operator 125 125 | a = b|c 126 126 | #: E227 -E22.py:125:6: E227 [*] Missing whitespace around bitwise or shift operator +E227 [*] Missing whitespace around bitwise or shift operator + --> E22.py:125:6 | 123 | _1MB = _1kB<<10 124 | #: E227 125 | a = b|c - | ^ E227 + | ^ 126 | #: E227 127 | b = c&a | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 122 122 | #: E227 @@ -107,16 +111,17 @@ E22.py:125:6: E227 [*] Missing whitespace around bitwise or shift operator 127 127 | b = c&a 128 128 | #: E227 -E22.py:127:6: E227 [*] Missing whitespace around bitwise or shift operator +E227 [*] Missing whitespace around bitwise or shift operator + --> E22.py:127:6 | 125 | a = b|c 126 | #: E227 127 | b = c&a - | ^ E227 + | ^ 128 | #: E227 129 | c = b^a | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 124 124 | #: E227 @@ -128,16 +133,17 @@ E22.py:127:6: E227 [*] Missing whitespace around bitwise or shift operator 129 129 | c = b^a 130 130 | #: E228 -E22.py:129:6: E227 [*] Missing whitespace around bitwise or shift operator +E227 [*] Missing whitespace around bitwise or shift operator + --> E22.py:129:6 | 127 | b = c&a 128 | #: E227 129 | c = b^a - | ^ E227 + | ^ 130 | #: E228 131 | a = b%c | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 126 126 | #: E227 @@ -149,16 +155,17 @@ E22.py:129:6: E227 [*] Missing whitespace around bitwise or shift operator 131 131 | a = b%c 132 132 | #: E228 -E22.py:154:11: E227 [*] Missing whitespace around bitwise or shift operator +E227 [*] Missing whitespace around bitwise or shift operator + --> E22.py:154:11 | 152 | func2(lambda a, b=h[:], c=0: (a, b, c)) 153 | if not -5 < x < +5: 154 | print >>sys.stderr, "x is out of range." - | ^^ E227 + | ^^ 155 | print >> sys.stdout, "x is an integer." 156 | x = x / 2 - 1 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 151 151 | func1(lambda *args, **kw: (args, kw)) diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap index c72a3b1ae2..c6ee2bea2c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E22.py:131:6: E228 [*] Missing whitespace around modulo operator +E228 [*] Missing whitespace around modulo operator + --> E22.py:131:6 | 129 | c = b^a 130 | #: E228 131 | a = b%c - | ^ E228 + | ^ 132 | #: E228 133 | msg = fmt%(errno, errmsg) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 128 128 | #: E227 @@ -23,16 +23,17 @@ E22.py:131:6: E228 [*] Missing whitespace around modulo operator 133 133 | msg = fmt%(errno, errmsg) 134 134 | #: E228 -E22.py:133:10: E228 [*] Missing whitespace around modulo operator +E228 [*] Missing whitespace around modulo operator + --> E22.py:133:10 | 131 | a = b%c 132 | #: E228 133 | msg = fmt%(errno, errmsg) - | ^ E228 + | ^ 134 | #: E228 135 | msg = "Error %d occurred"%errno | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 130 130 | #: E228 @@ -44,15 +45,16 @@ E22.py:133:10: E228 [*] Missing whitespace around modulo operator 135 135 | msg = "Error %d occurred"%errno 136 136 | #: -E22.py:135:26: E228 [*] Missing whitespace around modulo operator +E228 [*] Missing whitespace around modulo operator + --> E22.py:135:26 | 133 | msg = fmt%(errno, errmsg) 134 | #: E228 135 | msg = "Error %d occurred"%errno - | ^ E228 + | ^ 136 | #: | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 132 132 | #: E228 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap index a1d31b52ea..df5b5a5502 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E23.py:2:7: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:2:7 | 1 | #: E231 2 | a = (1,2) - | ^ E231 + | ^ 3 | #: E231 4 | a[b1,:] | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 1 1 | #: E231 @@ -19,16 +20,17 @@ E23.py:2:7: E231 [*] Missing whitespace after ',' 4 4 | a[b1,:] 5 5 | #: E231 -E23.py:4:5: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:4:5 | 2 | a = (1,2) 3 | #: E231 4 | a[b1,:] - | ^ E231 + | ^ 5 | #: E231 6 | a = [{'a':''}] | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 1 1 | #: E231 @@ -40,16 +42,17 @@ E23.py:4:5: E231 [*] Missing whitespace after ',' 6 6 | a = [{'a':''}] 7 7 | #: Okay -E23.py:6:10: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:6:10 | 4 | a[b1,:] 5 | #: E231 6 | a = [{'a':''}] - | ^ E231 + | ^ 7 | #: Okay 8 | a = (4,) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 3 3 | #: E231 @@ -61,15 +64,16 @@ E23.py:6:10: E231 [*] Missing whitespace after ':' 8 8 | a = (4,) 9 9 | b = (5, ) -E23.py:19:10: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:19:10 | 17 | def foo() -> None: 18 | #: E231 19 | if (1,2): - | ^ E231 + | ^ 20 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 16 16 | @@ -81,15 +85,16 @@ E23.py:19:10: E231 [*] Missing whitespace after ',' 21 21 | 22 22 | #: Okay -E23.py:29:20: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:29:20 | 27 | mdtypes_template = { 28 | 'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')], 29 | 'tag_smalldata':[('byte_count_mdtype', 'u4'), ('data', 'S4')], - | ^ E231 + | ^ 30 | } | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 26 26 | #: E231:2:20 @@ -101,15 +106,16 @@ E23.py:29:20: E231 [*] Missing whitespace after ':' 31 31 | 32 32 | # E231 -E23.py:33:6: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:33:6 | 32 | # E231 33 | f"{(a,b)}" - | ^ E231 + | ^ 34 | 35 | # Okay because it's hard to differentiate between the usages of a colon in a f-string | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 30 30 | } @@ -121,15 +127,16 @@ E23.py:33:6: E231 [*] Missing whitespace after ',' 35 35 | # Okay because it's hard to differentiate between the usages of a colon in a f-string 36 36 | f"{a:=1}" -E23.py:47:37: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:47:37 | 46 | #: E231 47 | {len(f's3://{self.s3_bucket_name}/'):1} - | ^ E231 + | ^ 48 | 49 | #: Okay | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 44 44 | snapshot.file_uri[len(f's3://{self.s3_bucket_name}/'):] @@ -141,16 +148,17 @@ E23.py:47:37: E231 [*] Missing whitespace after ':' 49 49 | #: Okay 50 50 | a = (1,) -E23.py:60:13: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:60:13 | 58 | results = { 59 | "k1": [1], 60 | "k2":[2], - | ^ E231 + | ^ 61 | } 62 | results_in_tuple = ( | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 57 57 | """Primary function.""" @@ -162,16 +170,17 @@ E23.py:60:13: E231 [*] Missing whitespace after ':' 62 62 | results_in_tuple = ( 63 63 | { -E23.py:65:17: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:65:17 | 63 | { 64 | "k1": [1], 65 | "k2":[2], - | ^ E231 + | ^ 66 | }, 67 | ) | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 62 62 | results_in_tuple = ( @@ -183,16 +192,17 @@ E23.py:65:17: E231 [*] Missing whitespace after ':' 67 67 | ) 68 68 | results_in_list = [ -E23.py:71:17: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:71:17 | 69 | { 70 | "k1": [1], 71 | "k2":[2], - | ^ E231 + | ^ 72 | } 73 | ] | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 68 68 | results_in_list = [ @@ -204,16 +214,17 @@ E23.py:71:17: E231 [*] Missing whitespace after ':' 73 73 | ] 74 74 | results_in_list_first = [ -E23.py:76:17: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:76:17 | 74 | results_in_list_first = [ 75 | { 76 | "k2":[2], - | ^ E231 + | ^ 77 | } 78 | ] | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 73 73 | ] @@ -225,16 +236,17 @@ E23.py:76:17: E231 [*] Missing whitespace after ':' 78 78 | ] 79 79 | -E23.py:82:13: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:82:13 | 80 | x = [ 81 | { 82 | "k1":[2], # E231 - | ^ E231 + | ^ 83 | "k2": x[2:4], 84 | "k3":[2], # E231 | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 79 79 | @@ -246,16 +258,17 @@ E23.py:82:13: E231 [*] Missing whitespace after ':' 84 84 | "k3":[2], # E231 85 85 | "k4": [2], -E23.py:84:13: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:84:13 | 82 | "k1":[2], # E231 83 | "k2": x[2:4], 84 | "k3":[2], # E231 - | ^ E231 + | ^ 85 | "k4": [2], 86 | "k5": [2], | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 81 81 | { @@ -267,16 +280,17 @@ E23.py:84:13: E231 [*] Missing whitespace after ':' 86 86 | "k5": [2], 87 87 | "k6": [1, 2, 3, 4,5,6,7] # E231 -E23.py:87:26: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:87:26 | 85 | "k4": [2], 86 | "k5": [2], 87 | "k6": [1, 2, 3, 4,5,6,7] # E231 - | ^ E231 + | ^ 88 | }, 89 | { | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 84 84 | "k3":[2], # E231 @@ -288,16 +302,17 @@ E23.py:87:26: E231 [*] Missing whitespace after ',' 89 89 | { 90 90 | "k1": [ -E23.py:87:28: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:87:28 | 85 | "k4": [2], 86 | "k5": [2], 87 | "k6": [1, 2, 3, 4,5,6,7] # E231 - | ^ E231 + | ^ 88 | }, 89 | { | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 84 84 | "k3":[2], # E231 @@ -309,16 +324,17 @@ E23.py:87:28: E231 [*] Missing whitespace after ',' 89 89 | { 90 90 | "k1": [ -E23.py:87:30: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:87:30 | 85 | "k4": [2], 86 | "k5": [2], 87 | "k6": [1, 2, 3, 4,5,6,7] # E231 - | ^ E231 + | ^ 88 | }, 89 | { | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 84 84 | "k3":[2], # E231 @@ -330,16 +346,17 @@ E23.py:87:30: E231 [*] Missing whitespace after ',' 89 89 | { 90 90 | "k1": [ -E23.py:92:21: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:92:21 | 90 | "k1": [ 91 | { 92 | "ka":[2,3], # E231 - | ^ E231 + | ^ 93 | }, 94 | { | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 89 89 | { @@ -351,16 +368,17 @@ E23.py:92:21: E231 [*] Missing whitespace after ':' 94 94 | { 95 95 | "kb": [2,3], # E231 -E23.py:92:24: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:92:24 | 90 | "k1": [ 91 | { 92 | "ka":[2,3], # E231 - | ^ E231 + | ^ 93 | }, 94 | { | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 89 89 | { @@ -372,16 +390,17 @@ E23.py:92:24: E231 [*] Missing whitespace after ',' 94 94 | { 95 95 | "kb": [2,3], # E231 -E23.py:95:25: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:95:25 | 93 | }, 94 | { 95 | "kb": [2,3], # E231 - | ^ E231 + | ^ 96 | }, 97 | { | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 92 92 | "ka":[2,3], # E231 @@ -393,16 +412,17 @@ E23.py:95:25: E231 [*] Missing whitespace after ',' 97 97 | { 98 98 | "ka":[2, 3], # E231 -E23.py:98:21: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:98:21 | 96 | }, 97 | { 98 | "ka":[2, 3], # E231 - | ^ E231 + | ^ 99 | "kb": [2, 3], # Ok 100 | "kc": [2, 3], # Ok | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 95 95 | "kb": [2,3], # E231 @@ -414,16 +434,17 @@ E23.py:98:21: E231 [*] Missing whitespace after ':' 100 100 | "kc": [2, 3], # Ok 101 101 | "kd": [2,3], # E231 -E23.py:101:25: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:101:25 | 99 | "kb": [2, 3], # Ok 100 | "kc": [2, 3], # Ok 101 | "kd": [2,3], # E231 - | ^ E231 + | ^ 102 | "ke":[2,3], # E231 103 | }, | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 98 98 | "ka":[2, 3], # E231 @@ -435,16 +456,17 @@ E23.py:101:25: E231 [*] Missing whitespace after ',' 103 103 | }, 104 104 | ] -E23.py:102:21: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:102:21 | 100 | "kc": [2, 3], # Ok 101 | "kd": [2,3], # E231 102 | "ke":[2,3], # E231 - | ^ E231 + | ^ 103 | }, 104 | ] | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 99 99 | "kb": [2, 3], # Ok @@ -456,16 +478,17 @@ E23.py:102:21: E231 [*] Missing whitespace after ':' 104 104 | ] 105 105 | } -E23.py:102:24: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:102:24 | 100 | "kc": [2, 3], # Ok 101 | "kd": [2,3], # E231 102 | "ke":[2,3], # E231 - | ^ E231 + | ^ 103 | }, 104 | ] | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 99 99 | "kb": [2, 3], # Ok @@ -477,15 +500,16 @@ E23.py:102:24: E231 [*] Missing whitespace after ',' 104 104 | ] 105 105 | } -E23.py:109:18: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:109:18 | 108 | # Should be E231 errors on all of these type parameters and function parameters, but not on their (strange) defaults 109 | def pep_696_bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( - | ^ E231 + | ^ 110 | x:A = "foo"[::-1], 111 | y:B = [[["foo", "bar"]]], | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 106 106 | ] @@ -497,15 +521,16 @@ E23.py:109:18: E231 [*] Missing whitespace after ':' 111 111 | y:B = [[["foo", "bar"]]], 112 112 | z:object = "fooo", -E23.py:109:40: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:109:40 | 108 | # Should be E231 errors on all of these type parameters and function parameters, but not on their (strange) defaults 109 | def pep_696_bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( - | ^ E231 + | ^ 110 | x:A = "foo"[::-1], 111 | y:B = [[["foo", "bar"]]], | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 106 106 | ] @@ -517,15 +542,16 @@ E23.py:109:40: E231 [*] Missing whitespace after ':' 111 111 | y:B = [[["foo", "bar"]]], 112 112 | z:object = "fooo", -E23.py:109:70: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:109:70 | 108 | # Should be E231 errors on all of these type parameters and function parameters, but not on their (strange) defaults 109 | def pep_696_bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( - | ^ E231 + | ^ 110 | x:A = "foo"[::-1], 111 | y:B = [[["foo", "bar"]]], | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 106 106 | ] @@ -537,16 +563,17 @@ E23.py:109:70: E231 [*] Missing whitespace after ':' 111 111 | y:B = [[["foo", "bar"]]], 112 112 | z:object = "fooo", -E23.py:110:6: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:110:6 | 108 | # Should be E231 errors on all of these type parameters and function parameters, but not on their (strange) defaults 109 | def pep_696_bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( 110 | x:A = "foo"[::-1], - | ^ E231 + | ^ 111 | y:B = [[["foo", "bar"]]], 112 | z:object = "fooo", | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 107 107 | @@ -558,16 +585,17 @@ E23.py:110:6: E231 [*] Missing whitespace after ':' 112 112 | z:object = "fooo", 113 113 | ): -E23.py:111:6: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:111:6 | 109 | def pep_696_bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( 110 | x:A = "foo"[::-1], 111 | y:B = [[["foo", "bar"]]], - | ^ E231 + | ^ 112 | z:object = "fooo", 113 | ): | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 108 108 | # Should be E231 errors on all of these type parameters and function parameters, but not on their (strange) defaults @@ -579,16 +607,17 @@ E23.py:111:6: E231 [*] Missing whitespace after ':' 113 113 | ): 114 114 | pass -E23.py:112:6: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:112:6 | 110 | x:A = "foo"[::-1], 111 | y:B = [[["foo", "bar"]]], 112 | z:object = "fooo", - | ^ E231 + | ^ 113 | ): 114 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 109 109 | def pep_696_bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( @@ -600,16 +629,17 @@ E23.py:112:6: E231 [*] Missing whitespace after ':' 114 114 | pass 115 115 | -E23.py:116:18: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:116:18 | 114 | pass 115 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: - | ^ E231 + | ^ 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( 118 | self, | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 113 113 | ): @@ -621,16 +651,17 @@ E23.py:116:18: E231 [*] Missing whitespace after ':' 118 118 | self, 119 119 | x:A = "foo"[::-1], -E23.py:116:40: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:116:40 | 114 | pass 115 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: - | ^ E231 + | ^ 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( 118 | self, | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 113 113 | ): @@ -642,16 +673,17 @@ E23.py:116:40: E231 [*] Missing whitespace after ':' 118 118 | self, 119 119 | x:A = "foo"[::-1], -E23.py:116:70: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:116:70 | 114 | pass 115 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: - | ^ E231 + | ^ 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( 118 | self, | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 113 113 | ): @@ -663,15 +695,16 @@ E23.py:116:70: E231 [*] Missing whitespace after ':' 118 118 | self, 119 119 | x:A = "foo"[::-1], -E23.py:117:29: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:117:29 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( - | ^ E231 + | ^ 118 | self, 119 | x:A = "foo"[::-1], | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 114 114 | pass @@ -683,15 +716,16 @@ E23.py:117:29: E231 [*] Missing whitespace after ':' 119 119 | x:A = "foo"[::-1], 120 120 | y:B = [[["foo", "bar"]]], -E23.py:117:51: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:117:51 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( - | ^ E231 + | ^ 118 | self, 119 | x:A = "foo"[::-1], | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 114 114 | pass @@ -703,15 +737,16 @@ E23.py:117:51: E231 [*] Missing whitespace after ':' 119 119 | x:A = "foo"[::-1], 120 120 | y:B = [[["foo", "bar"]]], -E23.py:117:81: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:117:81 | 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( - | ^ E231 + | ^ 118 | self, 119 | x:A = "foo"[::-1], | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 114 114 | pass @@ -723,16 +758,17 @@ E23.py:117:81: E231 [*] Missing whitespace after ':' 119 119 | x:A = "foo"[::-1], 120 120 | y:B = [[["foo", "bar"]]], -E23.py:119:10: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:119:10 | 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( 118 | self, 119 | x:A = "foo"[::-1], - | ^ E231 + | ^ 120 | y:B = [[["foo", "bar"]]], 121 | z:object = "fooo", | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 116 116 | class PEP696Bad[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]: @@ -744,16 +780,17 @@ E23.py:119:10: E231 [*] Missing whitespace after ':' 121 121 | z:object = "fooo", 122 122 | ): -E23.py:120:10: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:120:10 | 118 | self, 119 | x:A = "foo"[::-1], 120 | y:B = [[["foo", "bar"]]], - | ^ E231 + | ^ 121 | z:object = "fooo", 122 | ): | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 117 117 | def pep_696_bad_method[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes]( @@ -765,16 +802,17 @@ E23.py:120:10: E231 [*] Missing whitespace after ':' 122 122 | ): 123 123 | pass -E23.py:121:10: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:121:10 | 119 | x:A = "foo"[::-1], 120 | y:B = [[["foo", "bar"]]], 121 | z:object = "fooo", - | ^ E231 + | ^ 122 | ): 123 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 118 118 | self, @@ -786,16 +824,17 @@ E23.py:121:10: E231 [*] Missing whitespace after ':' 123 123 | pass 124 124 | -E23.py:125:32: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:125:32 | 123 | pass 124 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): - | ^ E231 + | ^ 126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… 127 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 122 122 | ): @@ -807,16 +846,17 @@ E23.py:125:32: E231 [*] Missing whitespace after ':' 127 127 | pass 128 128 | -E23.py:125:54: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:125:54 | 123 | pass 124 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): - | ^ E231 + | ^ 126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… 127 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 122 122 | ): @@ -828,16 +868,17 @@ E23.py:125:54: E231 [*] Missing whitespace after ':' 127 127 | pass 128 128 | -E23.py:125:84: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:125:84 | 123 | pass 124 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): - | ^ E231 + | ^ 126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… 127 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 122 122 | ): @@ -849,14 +890,15 @@ E23.py:125:84: E231 [*] Missing whitespace after ':' 127 127 | pass 128 128 | -E23.py:126:47: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:126:47 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): 126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… - | ^ E231 + | ^ 127 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 123 123 | pass @@ -868,14 +910,15 @@ E23.py:126:47: E231 [*] Missing whitespace after ':' 128 128 | 129 129 | # Should be no E231 errors on any of these: -E23.py:126:69: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:126:69 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): 126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… - | ^ E231 + | ^ 127 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 123 123 | pass @@ -887,14 +930,15 @@ E23.py:126:69: E231 [*] Missing whitespace after ':' 128 128 | 129 129 | # Should be no E231 errors on any of these: -E23.py:126:99: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:126:99 | 125 | class PEP696BadWithEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](): 126 | class IndentedPEP696BadWithNonEmptyBases[A:object="foo"[::-1], B:object =[[["foo", "bar"]]], C:object= bytes](object, something_d… - | ^ E231 + | ^ 127 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 123 123 | pass @@ -906,15 +950,16 @@ E23.py:126:99: E231 [*] Missing whitespace after ':' 128 128 | 129 129 | # Should be no E231 errors on any of these: -E23.py:147:6: E231 [*] Missing whitespace after ',' +E231 [*] Missing whitespace after ',' + --> E23.py:147:6 | 146 | # E231 147 | t"{(a,b)}" - | ^ E231 + | ^ 148 | 149 | # Okay because it's hard to differentiate between the usages of a colon in a t-string | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 144 144 | pass @@ -926,13 +971,14 @@ E23.py:147:6: E231 [*] Missing whitespace after ',' 149 149 | # Okay because it's hard to differentiate between the usages of a colon in a t-string 150 150 | t"{a:=1}" -E23.py:161:37: E231 [*] Missing whitespace after ':' +E231 [*] Missing whitespace after ':' + --> E23.py:161:37 | 160 | #: E231 161 | {len(t's3://{self.s3_bucket_name}/'):1} - | ^ E231 + | ^ | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 158 158 | snapshot.file_uri[len(t's3://{self.s3_bucket_name}/'):] diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap index f649c78530..15b4ba7da7 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E24.py:2:8: E241 [*] Multiple spaces after comma +E241 [*] Multiple spaces after comma + --> E24.py:2:8 | 1 | #: E241 2 | a = (1, 2) - | ^^ E241 + | ^^ 3 | #: Okay 4 | b = (1, 20) | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 1 1 | #: E241 @@ -20,16 +20,17 @@ E24.py:2:8: E241 [*] Multiple spaces after comma 4 4 | b = (1, 20) 5 5 | #: E242 -E24.py:11:18: E241 [*] Multiple spaces after comma +E241 [*] Multiple spaces after comma + --> E24.py:11:18 | 9 | #: E241 E241 E241 10 | # issue 135 11 | more_spaces = [a, b, - | ^^^^ E241 + | ^^^^ 12 | ef, +h, 13 | c, -d] | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 8 8 | b = (1, 20) # space before 20 @@ -40,15 +41,16 @@ E24.py:11:18: E241 [*] Multiple spaces after comma 12 12 | ef, +h, 13 13 | c, -d] -E24.py:12:19: E241 [*] Multiple spaces after comma +E241 [*] Multiple spaces after comma + --> E24.py:12:19 | 10 | # issue 135 11 | more_spaces = [a, b, 12 | ef, +h, - | ^^ E241 + | ^^ 13 | c, -d] | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 9 9 | #: E241 E241 E241 @@ -58,14 +60,15 @@ E24.py:12:19: E241 [*] Multiple spaces after comma 12 |+ ef, +h, 13 13 | c, -d] -E24.py:13:18: E241 [*] Multiple spaces after comma +E241 [*] Multiple spaces after comma + --> E24.py:13:18 | 11 | more_spaces = [a, b, 12 | ef, +h, 13 | c, -d] - | ^^^ E241 + | ^^^ | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 10 10 | # issue 135 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap index e0f6804ae8..a77f70cb0b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E24.py:6:8: E242 [*] Tab after comma +E242 [*] Tab after comma + --> E24.py:6:8 | 4 | b = (1, 20) 5 | #: E242 6 | a = (1, 2) # tab before 2 - | ^^^^ E242 + | ^^^^ 7 | #: Okay 8 | b = (1, 20) # space before 20 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 3 3 | #: Okay diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap index ae5584a4b3..542413bf0a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E25.py:2:12: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:2:12 | 1 | #: E251 E251 2 | def foo(bar = False): - | ^ E251 + | ^ 3 | '''Test function with an error in declaration''' 4 | pass | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 1 1 | #: E251 E251 @@ -20,15 +20,16 @@ E25.py:2:12: E251 [*] Unexpected spaces around keyword / parameter equals 4 4 | pass 5 5 | #: E251 -E25.py:2:14: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:2:14 | 1 | #: E251 E251 2 | def foo(bar = False): - | ^ E251 + | ^ 3 | '''Test function with an error in declaration''' 4 | pass | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 1 1 | #: E251 E251 @@ -38,16 +39,17 @@ E25.py:2:14: E251 [*] Unexpected spaces around keyword / parameter equals 4 4 | pass 5 5 | #: E251 -E25.py:6:9: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:6:9 | 4 | pass 5 | #: E251 6 | foo(bar= True) - | ^ E251 + | ^ 7 | #: E251 8 | foo(bar =True) | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 3 3 | '''Test function with an error in declaration''' @@ -59,16 +61,17 @@ E25.py:6:9: E251 [*] Unexpected spaces around keyword / parameter equals 8 8 | foo(bar =True) 9 9 | #: E251 E251 -E25.py:8:8: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:8:8 | 6 | foo(bar= True) 7 | #: E251 8 | foo(bar =True) - | ^ E251 + | ^ 9 | #: E251 E251 10 | foo(bar = True) | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 5 5 | #: E251 @@ -80,16 +83,17 @@ E25.py:8:8: E251 [*] Unexpected spaces around keyword / parameter equals 10 10 | foo(bar = True) 11 11 | #: E251 -E25.py:10:8: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:10:8 | 8 | foo(bar =True) 9 | #: E251 E251 10 | foo(bar = True) - | ^ E251 + | ^ 11 | #: E251 12 | y = bar(root= "sdasd") | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 7 7 | #: E251 @@ -101,16 +105,17 @@ E25.py:10:8: E251 [*] Unexpected spaces around keyword / parameter equals 12 12 | y = bar(root= "sdasd") 13 13 | #: E251:2:29 -E25.py:10:10: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:10:10 | 8 | foo(bar =True) 9 | #: E251 E251 10 | foo(bar = True) - | ^ E251 + | ^ 11 | #: E251 12 | y = bar(root= "sdasd") | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 7 7 | #: E251 @@ -122,16 +127,17 @@ E25.py:10:10: E251 [*] Unexpected spaces around keyword / parameter equals 12 12 | y = bar(root= "sdasd") 13 13 | #: E251:2:29 -E25.py:12:14: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:12:14 | 10 | foo(bar = True) 11 | #: E251 12 | y = bar(root= "sdasd") - | ^ E251 + | ^ 13 | #: E251:2:29 14 | parser.add_argument('--long-option', | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 9 9 | #: E251 E251 @@ -143,18 +149,19 @@ E25.py:12:14: E251 [*] Unexpected spaces around keyword / parameter equals 14 14 | parser.add_argument('--long-option', 15 15 | default= -E25.py:15:29: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:15:29 | 13 | #: E251:2:29 14 | parser.add_argument('--long-option', 15 | default= | _____________________________^ 16 | | "/rather/long/filesystem/path/here/blah/blah/blah") - | |____________________^ E251 + | |____________________^ 17 | #: E251:1:45 18 | parser.add_argument('--long-option', default | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 12 12 | y = bar(root= "sdasd") @@ -167,18 +174,19 @@ E25.py:15:29: E251 [*] Unexpected spaces around keyword / parameter equals 18 17 | parser.add_argument('--long-option', default 19 18 | ="/rather/long/filesystem/path/here/blah/blah/blah") -E25.py:18:45: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:18:45 | 16 | "/rather/long/filesystem/path/here/blah/blah/blah") 17 | #: E251:1:45 18 | parser.add_argument('--long-option', default | _____________________________________________^ 19 | | ="/rather/long/filesystem/path/here/blah/blah/blah") - | |____________________^ E251 + | |____________________^ 20 | #: E251:3:8 E251:3:10 21 | foo(True, | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 15 15 | default= @@ -191,16 +199,17 @@ E25.py:18:45: E251 [*] Unexpected spaces around keyword / parameter equals 21 20 | foo(True, 22 21 | baz=(1, 2), -E25.py:23:8: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:23:8 | 21 | foo(True, 22 | baz=(1, 2), 23 | biz = 'foo' - | ^ E251 + | ^ 24 | ) 25 | #: Okay | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 20 20 | #: E251:3:8 E251:3:10 @@ -212,16 +221,17 @@ E25.py:23:8: E251 [*] Unexpected spaces around keyword / parameter equals 25 25 | #: Okay 26 26 | foo(bar=(1 == 1)) -E25.py:23:10: E251 [*] Unexpected spaces around keyword / parameter equals +E251 [*] Unexpected spaces around keyword / parameter equals + --> E25.py:23:10 | 21 | foo(True, 22 | baz=(1, 2), 23 | biz = 'foo' - | ^ E251 + | ^ 24 | ) 25 | #: Okay | - = help: Remove whitespace +help: Remove whitespace ℹ Safe fix 20 20 | #: E251:3:8 E251:3:10 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap index 5765ad2908..ced0599eb2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E25.py:46:15: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:46:15 | 44 | return a + b 45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 46 | def add(a: int=0, b: int =0, c: int= 0) -> int: - | ^ E252 + | ^ 47 | return a + b + c 48 | #: Okay | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 43 43 | async def add(a: int = 0, b: int = 0) -> int: @@ -22,16 +23,17 @@ E25.py:46:15: E252 [*] Missing whitespace around parameter equals 48 48 | #: Okay 49 49 | def add(a: int = _default(name='f')): -E25.py:46:15: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:46:15 | 44 | return a + b 45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 46 | def add(a: int=0, b: int =0, c: int= 0) -> int: - | ^ E252 + | ^ 47 | return a + b + c 48 | #: Okay | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 43 43 | async def add(a: int = 0, b: int = 0) -> int: @@ -43,16 +45,17 @@ E25.py:46:15: E252 [*] Missing whitespace around parameter equals 48 48 | #: Okay 49 49 | def add(a: int = _default(name='f')): -E25.py:46:26: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:46:26 | 44 | return a + b 45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 46 | def add(a: int=0, b: int =0, c: int= 0) -> int: - | ^ E252 + | ^ 47 | return a + b + c 48 | #: Okay | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 43 43 | async def add(a: int = 0, b: int = 0) -> int: @@ -64,16 +67,17 @@ E25.py:46:26: E252 [*] Missing whitespace around parameter equals 48 48 | #: Okay 49 49 | def add(a: int = _default(name='f')): -E25.py:46:36: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:46:36 | 44 | return a + b 45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 46 | def add(a: int=0, b: int =0, c: int= 0) -> int: - | ^ E252 + | ^ 47 | return a + b + c 48 | #: Okay | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 43 43 | async def add(a: int = 0, b: int = 0) -> int: @@ -85,14 +89,15 @@ E25.py:46:36: E252 [*] Missing whitespace around parameter equals 48 48 | #: Okay 49 49 | def add(a: int = _default(name='f')): -E25.py:64:18: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:18 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -104,14 +109,15 @@ E25.py:64:18: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:18: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:18 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -123,14 +129,15 @@ E25.py:64:18: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:26: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:26 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -142,14 +149,15 @@ E25.py:64:26: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:33: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:33 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -161,14 +169,15 @@ E25.py:64:33: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:49: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:49 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -180,14 +189,15 @@ E25.py:64:49: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:49: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:49 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -199,14 +209,15 @@ E25.py:64:49: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:64: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:64 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -218,14 +229,15 @@ E25.py:64:64: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:64: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:64 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -237,14 +249,15 @@ E25.py:64:64: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:80: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:80 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -256,14 +269,15 @@ E25.py:64:80: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:64:96: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:64:96 | 63 | # There should be at least one E251 diagnostic for each type parameter here: 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): - | ^ E252 + | ^ 65 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 61 61 | print(f"{foo(a = 1)}") @@ -275,15 +289,16 @@ E25.py:64:96: E252 [*] Missing whitespace around parameter equals 66 66 | 67 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: -E25.py:67:18: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:18 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -295,15 +310,16 @@ E25.py:67:18: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:18: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:18 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -315,15 +331,16 @@ E25.py:67:18: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:26: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:26 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -335,15 +352,16 @@ E25.py:67:26: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:33: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:33 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -355,15 +373,16 @@ E25.py:67:33: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:49: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:49 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -375,15 +394,16 @@ E25.py:67:49: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:49: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:49 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -395,15 +415,16 @@ E25.py:67:49: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:64: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:64 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -415,15 +436,16 @@ E25.py:67:64: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:64: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:64 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -435,15 +457,16 @@ E25.py:67:64: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:80: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:80 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): @@ -455,15 +478,16 @@ E25.py:67:80: E252 [*] Missing whitespace around parameter equals 69 69 | 70 70 | # The last of these should cause us to emit E231, -E25.py:67:96: E252 [*] Missing whitespace around parameter equals +E252 [*] Missing whitespace around parameter equals + --> E25.py:67:96 | 65 | pass 66 | 67 | class PEP696Bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes]: - | ^ E252 + | ^ 68 | pass | - = help: Add missing whitespace +help: Add missing whitespace ℹ Safe fix 64 64 | def pep_696_bad[A=int, B =str, C= bool, D:object=int, E: object=str, F: object =bool, G: object= bytes](): diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap index c0199f8794..2970034f65 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E26.py:2:5: E261 [*] Insert at least two spaces before an inline comment +E261 [*] Insert at least two spaces before an inline comment + --> E26.py:2:5 | 1 | #: E261:1:5 2 | pass # an inline comment - | ^ E261 + | ^ 3 | #: E262:1:12 4 | x = x + 1 #Increment x | - = help: Insert spaces +help: Insert spaces ℹ Safe fix 1 1 | #: E261:1:5 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap index a20957b68d..b3a33831ca 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E26.py:4:12: E262 [*] Inline comment should start with `# ` +E262 [*] Inline comment should start with `# ` + --> E26.py:4:12 | 2 | pass # an inline comment 3 | #: E262:1:12 4 | x = x + 1 #Increment x - | ^^^^^^^^^^^^ E262 + | ^^^^^^^^^^^^ 5 | #: E262:1:12 6 | x = x + 1 # Increment x | - = help: Format space +help: Format space ℹ Safe fix 1 1 | #: E261:1:5 @@ -22,16 +23,17 @@ E26.py:4:12: E262 [*] Inline comment should start with `# ` 6 6 | x = x + 1 # Increment x 7 7 | #: E262:1:12 -E26.py:6:12: E262 [*] Inline comment should start with `# ` +E262 [*] Inline comment should start with `# ` + --> E26.py:6:12 | 4 | x = x + 1 #Increment x 5 | #: E262:1:12 6 | x = x + 1 # Increment x - | ^^^^^^^^^^^^^^ E262 + | ^^^^^^^^^^^^^^ 7 | #: E262:1:12 8 | x = y + 1 #: Increment x | - = help: Format space +help: Format space ℹ Safe fix 3 3 | #: E262:1:12 @@ -43,16 +45,17 @@ E26.py:6:12: E262 [*] Inline comment should start with `# ` 8 8 | x = y + 1 #: Increment x 9 9 | #: E265:1:1 -E26.py:8:12: E262 [*] Inline comment should start with `# ` +E262 [*] Inline comment should start with `# ` + --> E26.py:8:12 | 6 | x = x + 1 # Increment x 7 | #: E262:1:12 8 | x = y + 1 #: Increment x - | ^^^^^^^^^^^^^^^ E262 + | ^^^^^^^^^^^^^^^ 9 | #: E265:1:1 10 | #Block comment | - = help: Format space +help: Format space ℹ Safe fix 5 5 | #: E262:1:12 @@ -64,16 +67,17 @@ E26.py:8:12: E262 [*] Inline comment should start with `# ` 10 10 | #Block comment 11 11 | a = 1 -E26.py:63:9: E262 [*] Inline comment should start with `# ` +E262 [*] Inline comment should start with `# ` + --> E26.py:63:9 | 61 | # -*- coding: utf8 -*- 62 | #  (One space one NBSP) Ok for block comment 63 | a = 42 #  (One space one NBSP) - | ^^^^^^^^^^^^^^^^^^^^^^^ E262 + | ^^^^^^^^^^^^^^^^^^^^^^^ 64 | #: E262:2:9 65 | # (Two spaces) Ok for block comment | - = help: Format space +help: Format space ℹ Safe fix 60 60 | #: E262:3:9 @@ -85,16 +89,17 @@ E26.py:63:9: E262 [*] Inline comment should start with `# ` 65 65 | # (Two spaces) Ok for block comment 66 66 | a = 42 # (Two spaces) -E26.py:66:9: E262 [*] Inline comment should start with `# ` +E262 [*] Inline comment should start with `# ` + --> E26.py:66:9 | 64 | #: E262:2:9 65 | # (Two spaces) Ok for block comment 66 | a = 42 # (Two spaces) - | ^^^^^^^^^^^^^^^ E262 + | ^^^^^^^^^^^^^^^ 67 | 68 | #: E265:5:1 | - = help: Format space +help: Format space ℹ Safe fix 63 63 | a = 42 #  (One space one NBSP) @@ -106,16 +111,17 @@ E26.py:66:9: E262 [*] Inline comment should start with `# ` 68 68 | #: E265:5:1 69 69 | ### Means test is not done yet -E26.py:84:8: E262 [*] Inline comment should start with `# ` +E262 [*] Inline comment should start with `# ` + --> E26.py:84:8 | 82 | ## Foo 83 | 84 | a = 1 ## Foo - | ^^^^^^ E262 + | ^^^^^^ 85 | 86 | a = 1 #:Foo | - = help: Format space +help: Format space ℹ Safe fix 81 81 | #: E266:1:3 @@ -126,14 +132,15 @@ E26.py:84:8: E262 [*] Inline comment should start with `# ` 85 85 | 86 86 | a = 1 #:Foo -E26.py:86:8: E262 [*] Inline comment should start with `# ` +E262 [*] Inline comment should start with `# ` + --> E26.py:86:8 | 84 | a = 1 ## Foo 85 | 86 | a = 1 #:Foo - | ^^^^^ E262 + | ^^^^^ | - = help: Format space +help: Format space ℹ Safe fix 83 83 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap index d20b25b5c0..f2af89f9d4 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E26.py:10:1: E265 [*] Block comment should start with `# ` +E265 [*] Block comment should start with `# ` + --> E26.py:10:1 | 8 | x = y + 1 #: Increment x 9 | #: E265:1:1 10 | #Block comment - | ^^^^^^^^^^^^^^ E265 + | ^^^^^^^^^^^^^^ 11 | a = 1 12 | #: E265:2:1 | - = help: Format space +help: Format space ℹ Safe fix 7 7 | #: E262:1:12 @@ -22,16 +23,17 @@ E26.py:10:1: E265 [*] Block comment should start with `# ` 12 12 | #: E265:2:1 13 13 | m = 42 -E26.py:14:1: E265 [*] Block comment should start with `# ` +E265 [*] Block comment should start with `# ` + --> E26.py:14:1 | 12 | #: E265:2:1 13 | m = 42 14 | #! This is important - | ^^^^^^^^^^^^^^^^^^^^ E265 + | ^^^^^^^^^^^^^^^^^^^^ 15 | mx = 42 - 42 16 | #: E266:3:5 E266:6:5 | - = help: Format space +help: Format space ℹ Safe fix 11 11 | a = 1 @@ -43,16 +45,17 @@ E26.py:14:1: E265 [*] Block comment should start with `# ` 16 16 | #: E266:3:5 E266:6:5 17 17 | def how_it_feel(r): -E26.py:25:1: E265 [*] Block comment should start with `# ` +E265 [*] Block comment should start with `# ` + --> E26.py:25:1 | 23 | return 24 | #: E265:1:1 E266:2:1 25 | ##if DEBUG: - | ^^^^^^^^^^^ E265 + | ^^^^^^^^^^^ 26 | ## logging.error() 27 | #: W291:1:42 | - = help: Format space +help: Format space ℹ Safe fix 22 22 | ### Of course it is unused @@ -64,15 +67,16 @@ E26.py:25:1: E265 [*] Block comment should start with `# ` 27 27 | #: W291:1:42 28 28 | ######################################### -E26.py:32:1: E265 [*] Block comment should start with `# ` +E265 [*] Block comment should start with `# ` + --> E26.py:32:1 | 31 | #: Okay 32 | #!/usr/bin/env python - | ^^^^^^^^^^^^^^^^^^^^^ E265 + | ^^^^^^^^^^^^^^^^^^^^^ 33 | 34 | pass # an inline comment | - = help: Format space +help: Format space ℹ Safe fix 29 29 | #: @@ -84,15 +88,16 @@ E26.py:32:1: E265 [*] Block comment should start with `# ` 34 34 | pass # an inline comment 35 35 | x = x + 1 # Increment x -E26.py:73:1: E265 [*] Block comment should start with `# ` +E265 [*] Block comment should start with `# ` + --> E26.py:73:1 | 71 | # F Means test is failing (F) 72 | # EF Means test is giving error and Failing 73 | #! Means test is segfaulting - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E265 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 74 | # 8 Means test runs forever | - = help: Format space +help: Format space ℹ Safe fix 70 70 | # E Means test is giving error (E) @@ -104,16 +109,17 @@ E26.py:73:1: E265 [*] Block comment should start with `# ` 75 75 | 76 76 | #: Colon prefix is okay -E26.py:78:1: E265 [*] Block comment should start with `# ` +E265 [*] Block comment should start with `# ` + --> E26.py:78:1 | 76 | #: Colon prefix is okay 77 | 78 | ###This is a variable ### - | ^^^^^^^^^^^^^^^^^^^^^^^^^ E265 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 79 | 80 | # We should strip the space, but preserve the hashes. | - = help: Format space +help: Format space ℹ Safe fix 75 75 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap index b32057f337..e1d348254b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E26.py:19:5: E266 [*] Too many leading `#` before block comment +E266 [*] Too many leading `#` before block comment + --> E26.py:19:5 | 17 | def how_it_feel(r): 18 | 19 | ### This is a variable ### - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | a = 42 | - = help: Remove leading `#` +help: Remove leading `#` ℹ Safe fix 16 16 | #: E266:3:5 E266:6:5 @@ -21,16 +22,17 @@ E26.py:19:5: E266 [*] Too many leading `#` before block comment 21 21 | 22 22 | ### Of course it is unused -E26.py:22:5: E266 [*] Too many leading `#` before block comment +E266 [*] Too many leading `#` before block comment + --> E26.py:22:5 | 20 | a = 42 21 | 22 | ### Of course it is unused - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | return 24 | #: E265:1:1 E266:2:1 | - = help: Remove leading `#` +help: Remove leading `#` ℹ Safe fix 19 19 | ### This is a variable ### @@ -42,16 +44,17 @@ E26.py:22:5: E266 [*] Too many leading `#` before block comment 24 24 | #: E265:1:1 E266:2:1 25 25 | ##if DEBUG: -E26.py:26:1: E266 [*] Too many leading `#` before block comment +E266 [*] Too many leading `#` before block comment + --> E26.py:26:1 | 24 | #: E265:1:1 E266:2:1 25 | ##if DEBUG: 26 | ## logging.error() - | ^^^^^^^^^^^^^^^^^^^^^ E266 + | ^^^^^^^^^^^^^^^^^^^^^ 27 | #: W291:1:42 28 | ######################################### | - = help: Remove leading `#` +help: Remove leading `#` ℹ Safe fix 23 23 | return @@ -63,15 +66,16 @@ E26.py:26:1: E266 [*] Too many leading `#` before block comment 28 28 | ######################################### 29 29 | #: -E26.py:69:1: E266 [*] Too many leading `#` before block comment +E266 [*] Too many leading `#` before block comment + --> E26.py:69:1 | 68 | #: E265:5:1 69 | ### Means test is not done yet - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | # E Means test is giving error (E) 71 | # F Means test is failing (F) | - = help: Remove leading `#` +help: Remove leading `#` ℹ Safe fix 66 66 | a = 42 # (Two spaces) @@ -83,16 +87,17 @@ E26.py:69:1: E266 [*] Too many leading `#` before block comment 71 71 | # F Means test is failing (F) 72 72 | # EF Means test is giving error and Failing -E26.py:82:1: E266 [*] Too many leading `#` before block comment +E266 [*] Too many leading `#` before block comment + --> E26.py:82:1 | 80 | # We should strip the space, but preserve the hashes. 81 | #: E266:1:3 82 | ## Foo - | ^^^^^^^ E266 + | ^^^^^^^ 83 | 84 | a = 1 ## Foo | - = help: Remove leading `#` +help: Remove leading `#` ℹ Safe fix 79 79 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap index 7692a3a9ec..55cdd05b70 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E27.py:4:9: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:4:9 | 2 | True and False 3 | #: E271 4 | True and False - | ^^ E271 + | ^^ 5 | #: E272 6 | True and False | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 1 1 | #: Okay @@ -22,16 +23,17 @@ E27.py:4:9: E271 [*] Multiple spaces after keyword 6 6 | True and False 7 7 | #: E271 -E27.py:6:5: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:6:5 | 4 | True and False 5 | #: E272 6 | True and False - | ^^ E271 + | ^^ 7 | #: E271 8 | if 1: | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 3 3 | #: E271 @@ -43,16 +45,17 @@ E27.py:6:5: E271 [*] Multiple spaces after keyword 8 8 | if 1: 9 9 | pass -E27.py:8:3: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:8:3 | 6 | True and False 7 | #: E271 8 | if 1: - | ^^^ E271 + | ^^^ 9 | pass 10 | #: E273 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 5 5 | #: E272 @@ -64,16 +67,17 @@ E27.py:8:3: E271 [*] Multiple spaces after keyword 10 10 | #: E273 11 11 | True and False -E27.py:15:6: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:15:6 | 13 | True and False 14 | #: E271 15 | a and b - | ^^ E271 + | ^^ 16 | #: E271 17 | 1 and b | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 12 12 | #: E273 E274 @@ -85,16 +89,17 @@ E27.py:15:6: E271 [*] Multiple spaces after keyword 17 17 | 1 and b 18 18 | #: E271 -E27.py:17:6: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:17:6 | 15 | a and b 16 | #: E271 17 | 1 and b - | ^^ E271 + | ^^ 18 | #: E271 19 | a and 2 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 14 14 | #: E271 @@ -106,16 +111,17 @@ E27.py:17:6: E271 [*] Multiple spaces after keyword 19 19 | a and 2 20 20 | #: E271 E272 -E27.py:19:6: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:19:6 | 17 | 1 and b 18 | #: E271 19 | a and 2 - | ^^ E271 + | ^^ 20 | #: E271 E272 21 | 1 and b | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 16 16 | #: E271 @@ -127,16 +133,17 @@ E27.py:19:6: E271 [*] Multiple spaces after keyword 21 21 | 1 and b 22 22 | #: E271 E272 -E27.py:21:7: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:21:7 | 19 | a and 2 20 | #: E271 E272 21 | 1 and b - | ^^ E271 + | ^^ 22 | #: E271 E272 23 | a and 2 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 18 18 | #: E271 @@ -148,16 +155,17 @@ E27.py:21:7: E271 [*] Multiple spaces after keyword 23 23 | a and 2 24 24 | #: E272 -E27.py:23:7: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:23:7 | 21 | 1 and b 22 | #: E271 E272 23 | a and 2 - | ^^ E271 + | ^^ 24 | #: E272 25 | this and False | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 20 20 | #: E271 E272 @@ -169,16 +177,17 @@ E27.py:23:7: E271 [*] Multiple spaces after keyword 25 25 | this and False 26 26 | #: E273 -E27.py:36:14: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:36:14 | 34 | from v import c, d 35 | #: E271 36 | from w import (e, f) - | ^^ E271 + | ^^ 37 | #: E275 38 | from w import(e, f) | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 33 33 | from u import (a, b) @@ -190,15 +199,16 @@ E27.py:36:14: E271 [*] Multiple spaces after keyword 38 38 | from w import(e, f) 39 39 | #: E275 -E27.py:71:5: E271 [*] Multiple spaces after keyword +E271 [*] Multiple spaces after keyword + --> E27.py:71:5 | 70 | #: E271 71 | type Number = int - | ^^ E271 + | ^^ 72 | 73 | #: E273 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 68 68 | # Soft keywords diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap index d28ad425b0..f01d5aa72f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E27.py:21:2: E272 [*] Multiple spaces before keyword +E272 [*] Multiple spaces before keyword + --> E27.py:21:2 | 19 | a and 2 20 | #: E271 E272 21 | 1 and b - | ^^ E272 + | ^^ 22 | #: E271 E272 23 | a and 2 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 18 18 | #: E271 @@ -22,16 +23,17 @@ E27.py:21:2: E272 [*] Multiple spaces before keyword 23 23 | a and 2 24 24 | #: E272 -E27.py:23:2: E272 [*] Multiple spaces before keyword +E272 [*] Multiple spaces before keyword + --> E27.py:23:2 | 21 | 1 and b 22 | #: E271 E272 23 | a and 2 - | ^^ E272 + | ^^ 24 | #: E272 25 | this and False | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 20 20 | #: E271 E272 @@ -43,16 +45,17 @@ E27.py:23:2: E272 [*] Multiple spaces before keyword 25 25 | this and False 26 26 | #: E273 -E27.py:25:5: E272 [*] Multiple spaces before keyword +E272 [*] Multiple spaces before keyword + --> E27.py:25:5 | 23 | a and 2 24 | #: E272 25 | this and False - | ^^ E272 + | ^^ 26 | #: E273 27 | a and b | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 22 22 | #: E271 E272 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap index 93ba99a400..f48e5fa931 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E27.py:11:9: E273 [*] Tab after keyword +E273 [*] Tab after keyword + --> E27.py:11:9 | 9 | pass 10 | #: E273 11 | True and False - | ^^^^^^^^ E273 + | ^^^^^^^^ 12 | #: E273 E274 13 | True and False | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 8 8 | if 1: @@ -22,16 +23,17 @@ E27.py:11:9: E273 [*] Tab after keyword 13 13 | True and False 14 14 | #: E271 -E27.py:13:5: E273 [*] Tab after keyword +E273 [*] Tab after keyword + --> E27.py:13:5 | 11 | True and False 12 | #: E273 E274 13 | True and False - | ^^^^^^^^ E273 + | ^^^^^^^^ 14 | #: E271 15 | a and b | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 10 10 | #: E273 @@ -43,16 +45,17 @@ E27.py:13:5: E273 [*] Tab after keyword 15 15 | a and b 16 16 | #: E271 -E27.py:13:10: E273 [*] Tab after keyword +E273 [*] Tab after keyword + --> E27.py:13:10 | 11 | True and False 12 | #: E273 E274 13 | True and False - | ^^^^ E273 + | ^^^^ 14 | #: E271 15 | a and b | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 10 10 | #: E273 @@ -64,16 +67,17 @@ E27.py:13:10: E273 [*] Tab after keyword 15 15 | a and b 16 16 | #: E271 -E27.py:27:6: E273 [*] Tab after keyword +E273 [*] Tab after keyword + --> E27.py:27:6 | 25 | this and False 26 | #: E273 27 | a and b - | ^^^^ E273 + | ^^^^ 28 | #: E274 29 | a and b | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 24 24 | #: E272 @@ -85,16 +89,17 @@ E27.py:27:6: E273 [*] Tab after keyword 29 29 | a and b 30 30 | #: E273 E274 -E27.py:31:10: E273 [*] Tab after keyword +E273 [*] Tab after keyword + --> E27.py:31:10 | 29 | a and b 30 | #: E273 E274 31 | this and False - | ^^^^ E273 + | ^^^^ 32 | #: Okay 33 | from u import (a, b) | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 28 28 | #: E274 @@ -106,15 +111,16 @@ E27.py:31:10: E273 [*] Tab after keyword 33 33 | from u import (a, b) 34 34 | from v import c, d -E27.py:74:5: E273 [*] Tab after keyword +E273 [*] Tab after keyword + --> E27.py:74:5 | 73 | #: E273 74 | type Number = int - | ^^^^ E273 + | ^^^^ 75 | 76 | #: E275 | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 71 71 | type Number = int diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap index 8920d5fe81..b77370136a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E27.py:29:2: E274 [*] Tab before keyword +E274 [*] Tab before keyword + --> E27.py:29:2 | 27 | a and b 28 | #: E274 29 | a and b - | ^^^^^^^^ E274 + | ^^^^^^^^ 30 | #: E273 E274 31 | this and False | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 26 26 | #: E273 @@ -22,16 +23,17 @@ E27.py:29:2: E274 [*] Tab before keyword 31 31 | this and False 32 32 | #: Okay -E27.py:31:5: E274 [*] Tab before keyword +E274 [*] Tab before keyword + --> E27.py:31:5 | 29 | a and b 30 | #: E273 E274 31 | this and False - | ^^^^^^^^ E274 + | ^^^^^^^^ 32 | #: Okay 33 | from u import (a, b) | - = help: Replace with single space +help: Replace with single space ℹ Safe fix 28 28 | #: E274 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap index 0504b5be50..ce4802d928 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E27.py:38:8: E275 [*] Missing whitespace after keyword +E275 [*] Missing whitespace after keyword + --> E27.py:38:8 | 36 | from w import (e, f) 37 | #: E275 38 | from w import(e, f) - | ^^^^^^ E275 + | ^^^^^^ 39 | #: E275 40 | from importable.module import(e, f) | - = help: Added missing whitespace after keyword +help: Added missing whitespace after keyword ℹ Safe fix 35 35 | #: E271 @@ -23,16 +23,17 @@ E27.py:38:8: E275 [*] Missing whitespace after keyword 40 40 | from importable.module import(e, f) 41 41 | #: E275 -E27.py:40:24: E275 [*] Missing whitespace after keyword +E275 [*] Missing whitespace after keyword + --> E27.py:40:24 | 38 | from w import(e, f) 39 | #: E275 40 | from importable.module import(e, f) - | ^^^^^^ E275 + | ^^^^^^ 41 | #: E275 42 | try: | - = help: Added missing whitespace after keyword +help: Added missing whitespace after keyword ℹ Safe fix 37 37 | #: E275 @@ -44,16 +45,17 @@ E27.py:40:24: E275 [*] Missing whitespace after keyword 42 42 | try: 43 43 | from importable.module import(e, f) -E27.py:43:28: E275 [*] Missing whitespace after keyword +E275 [*] Missing whitespace after keyword + --> E27.py:43:28 | 41 | #: E275 42 | try: 43 | from importable.module import(e, f) - | ^^^^^^ E275 + | ^^^^^^ 44 | except ImportError: 45 | pass | - = help: Added missing whitespace after keyword +help: Added missing whitespace after keyword ℹ Safe fix 40 40 | from importable.module import(e, f) @@ -65,16 +67,17 @@ E27.py:43:28: E275 [*] Missing whitespace after keyword 45 45 | pass 46 46 | #: E275 -E27.py:47:1: E275 [*] Missing whitespace after keyword +E275 [*] Missing whitespace after keyword + --> E27.py:47:1 | 45 | pass 46 | #: E275 47 | if(foo): - | ^^ E275 + | ^^ 48 | pass 49 | else: | - = help: Added missing whitespace after keyword +help: Added missing whitespace after keyword ℹ Safe fix 44 44 | except ImportError: @@ -86,16 +89,17 @@ E27.py:47:1: E275 [*] Missing whitespace after keyword 49 49 | else: 50 50 | pass -E27.py:55:5: E275 [*] Missing whitespace after keyword +E275 [*] Missing whitespace after keyword + --> E27.py:55:5 | 53 | #: E275:2:11 54 | if True: 55 | assert(1) - | ^^^^^^ E275 + | ^^^^^^ 56 | #: Okay 57 | def f(): | - = help: Added missing whitespace after keyword +help: Added missing whitespace after keyword ℹ Safe fix 52 52 | matched = {"true": True, "false": False} @@ -107,15 +111,16 @@ E27.py:55:5: E275 [*] Missing whitespace after keyword 57 57 | def f(): 58 58 | print((yield)) -E27.py:77:1: E275 [*] Missing whitespace after keyword +E275 [*] Missing whitespace after keyword + --> E27.py:77:1 | 76 | #: E275 77 | match(foo): - | ^^^^^ E275 + | ^^^^^ 78 | case(1): 79 | pass | - = help: Added missing whitespace after keyword +help: Added missing whitespace after keyword ℹ Safe fix 74 74 | type Number = int @@ -127,15 +132,16 @@ E27.py:77:1: E275 [*] Missing whitespace after keyword 79 79 | pass 80 80 | -E27.py:78:5: E275 [*] Missing whitespace after keyword +E275 [*] Missing whitespace after keyword + --> E27.py:78:5 | 76 | #: E275 77 | match(foo): 78 | case(1): - | ^^^^ E275 + | ^^^^ 79 | pass | - = help: Added missing whitespace after keyword +help: Added missing whitespace after keyword ℹ Safe fix 75 75 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap index 7c7fb04469..f72f81c611 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E30.py:478:5: E301 [*] Expected 1 blank line, found 0 +E301 [*] Expected 1 blank line, found 0 + --> E30.py:478:5 | 476 | def func1(): 477 | pass 478 | def func2(): - | ^^^ E301 + | ^^^ 479 | pass 480 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 475 475 | @@ -22,16 +22,17 @@ E30.py:478:5: E301 [*] Expected 1 blank line, found 0 479 480 | pass 480 481 | # end -E30.py:489:5: E301 [*] Expected 1 blank line, found 0 +E301 [*] Expected 1 blank line, found 0 + --> E30.py:489:5 | 487 | pass 488 | # comment 489 | def fn2(): - | ^^^ E301 + | ^^^ 490 | pass 491 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 485 485 | @@ -42,15 +43,16 @@ E30.py:489:5: E301 [*] Expected 1 blank line, found 0 489 490 | def fn2(): 490 491 | pass -E30.py:499:5: E301 [*] Expected 1 blank line, found 0 +E301 [*] Expected 1 blank line, found 0 + --> E30.py:499:5 | 498 | columns = [] 499 | @classmethod - | ^ E301 + | ^ 500 | def cls_method(cls) -> None: 501 | pass | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 496 496 | """Class for minimal repo.""" @@ -61,16 +63,17 @@ E30.py:499:5: E301 [*] Expected 1 blank line, found 0 500 501 | def cls_method(cls) -> None: 501 502 | pass -E30.py:511:5: E301 [*] Expected 1 blank line, found 0 +E301 [*] Expected 1 blank line, found 0 + --> E30.py:511:5 | 509 | def method(cls) -> None: 510 | pass 511 | @classmethod - | ^ E301 + | ^ 512 | def cls_method(cls) -> None: 513 | pass | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 508 508 | @@ -81,16 +84,17 @@ E30.py:511:5: E301 [*] Expected 1 blank line, found 0 512 513 | def cls_method(cls) -> None: 513 514 | pass -E30.py:526:5: E301 [*] Expected 1 blank line, found 0 +E301 [*] Expected 1 blank line, found 0 + --> E30.py:526:5 | 524 | def bar(self, x: str) -> str: 525 | ... 526 | def bar(self, x: int | str) -> int | str: - | ^^^ E301 + | ^^^ 527 | return x 528 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 523 523 | @overload diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap index 7bb80342d1..7cf04e5cc7 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E301_E30_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' +invalid-syntax: Expected ']', found '(' + --> E30_syntax_error.py:4:15 | 2 | # parenthesis. 3 | @@ -10,42 +11,41 @@ E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' 5 | pass | -E30_syntax_error.py:13:18: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:13:18 | 12 | class Foo: 13 | def __init__( | ^ 14 | pass 15 | def method(): -16 | pass | -E30_syntax_error.py:15:5: E301 Expected 1 blank line, found 0 +E301 Expected 1 blank line, found 0 + --> E30_syntax_error.py:15:5 | 13 | def __init__( 14 | pass 15 | def method(): - | ^^^ E301 + | ^^^ 16 | pass | - = help: Add missing blank line +help: Add missing blank line -E30_syntax_error.py:18:11: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:18:11 | 16 | pass 17 | 18 | foo = Foo( | ^ -19 | -20 | -21 | def top( | -E30_syntax_error.py:21:9: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:21:9 | 21 | def top( | ^ 22 | def nested1(): 23 | pass -24 | def nested2(): | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap index 5c422baa3d..83da023604 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:533:1: E302 [*] Expected 2 blank lines, found 0 +E302 [*] Expected 2 blank lines, found 0 + --> E30.py:533:1 | 531 | # E302 532 | """Main module.""" 533 | def fn(): - | ^^^ E302 + | ^^^ 534 | pass 535 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 530 530 | @@ -22,16 +23,17 @@ E30.py:533:1: E302 [*] Expected 2 blank lines, found 0 534 536 | pass 535 537 | # end -E30.py:540:1: E302 [*] Expected 2 blank lines, found 0 +E302 [*] Expected 2 blank lines, found 0 + --> E30.py:540:1 | 538 | # E302 539 | import sys 540 | def get_sys_path(): - | ^^^ E302 + | ^^^ 541 | return sys.path 542 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 537 537 | @@ -43,16 +45,17 @@ E30.py:540:1: E302 [*] Expected 2 blank lines, found 0 541 543 | return sys.path 542 544 | # end -E30.py:549:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30.py:549:1 | 547 | pass 548 | 549 | def b(): - | ^^^ E302 + | ^^^ 550 | pass 551 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 546 546 | def a(): @@ -63,16 +66,17 @@ E30.py:549:1: E302 [*] Expected 2 blank lines, found 1 550 551 | pass 551 552 | # end -E30.py:560:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30.py:560:1 | 558 | # comment 559 | 560 | def b(): - | ^^^ E302 + | ^^^ 561 | pass 562 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 557 557 | @@ -83,16 +87,17 @@ E30.py:560:1: E302 [*] Expected 2 blank lines, found 1 561 562 | pass 562 563 | # end -E30.py:569:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30.py:569:1 | 567 | pass 568 | 569 | async def b(): - | ^^^^^ E302 + | ^^^^^ 570 | pass 571 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 566 566 | def a(): @@ -103,16 +108,17 @@ E30.py:569:1: E302 [*] Expected 2 blank lines, found 1 570 571 | pass 571 572 | # end -E30.py:578:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30.py:578:1 | 576 | pass 577 | 578 | async def x(y: int = 1): - | ^^^^^ E302 + | ^^^^^ 579 | pass 580 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 575 575 | async def x(): @@ -123,15 +129,16 @@ E30.py:578:1: E302 [*] Expected 2 blank lines, found 1 579 580 | pass 580 581 | # end -E30.py:586:1: E302 [*] Expected 2 blank lines, found 0 +E302 [*] Expected 2 blank lines, found 0 + --> E30.py:586:1 | 584 | def bar(): 585 | pass 586 | def baz(): pass - | ^^^ E302 + | ^^^ 587 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 583 583 | # E302 @@ -143,16 +150,17 @@ E30.py:586:1: E302 [*] Expected 2 blank lines, found 0 587 589 | # end 588 590 | -E30.py:592:1: E302 [*] Expected 2 blank lines, found 0 +E302 [*] Expected 2 blank lines, found 0 + --> E30.py:592:1 | 590 | # E302 591 | def bar(): pass 592 | def baz(): - | ^^^ E302 + | ^^^ 593 | pass 594 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 589 589 | @@ -164,15 +172,16 @@ E30.py:592:1: E302 [*] Expected 2 blank lines, found 0 593 595 | pass 594 596 | # end -E30.py:602:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30.py:602:1 | 601 | # comment 602 | @decorator - | ^ E302 + | ^ 603 | def g(): 604 | pass | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 598 598 | def f(): @@ -183,15 +192,16 @@ E30.py:602:1: E302 [*] Expected 2 blank lines, found 1 602 603 | @decorator 603 604 | def g(): -E30.py:624:1: E302 [*] Expected 2 blank lines, found 0 +E302 [*] Expected 2 blank lines, found 0 + --> E30.py:624:1 | 622 | # E302 623 | class A:... 624 | class B: ... - | ^^^^^ E302 + | ^^^^^ 625 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 621 621 | @@ -203,16 +213,17 @@ E30.py:624:1: E302 [*] Expected 2 blank lines, found 0 625 627 | # end 626 628 | -E30.py:634:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30.py:634:1 | 632 | def fn(a: str) -> str: ... 633 | 634 | def fn(a: int | str) -> int | str: - | ^^^ E302 + | ^^^ 635 | ... 636 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 631 631 | @overload @@ -223,16 +234,17 @@ E30.py:634:1: E302 [*] Expected 2 blank lines, found 1 635 636 | ... 636 637 | # end -E30.py:944:1: E302 [*] Expected 2 blank lines, found 0 +E302 [*] Expected 2 blank lines, found 0 + --> E30.py:944:1 | 942 | pass 943 | # comment 944 | def test_clientmodel(): - | ^^^ E302 + | ^^^ 945 | pass 946 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 941 941 | def test_update(): @@ -244,16 +256,17 @@ E30.py:944:1: E302 [*] Expected 2 blank lines, found 0 945 947 | pass 946 948 | # end -E30.py:953:1: E302 [*] Expected 2 blank lines, found 0 +E302 [*] Expected 2 blank lines, found 0 + --> E30.py:953:1 | 951 | pass 952 | # comment 953 | def test_clientmodel(): - | ^^^ E302 + | ^^^ 954 | pass 955 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 950 950 | def test_update(): @@ -265,16 +278,17 @@ E30.py:953:1: E302 [*] Expected 2 blank lines, found 0 954 956 | pass 955 957 | # end -E30.py:962:1: E302 [*] Expected 2 blank lines, found 0 +E302 [*] Expected 2 blank lines, found 0 + --> E30.py:962:1 | 960 | pass 961 | # comment 962 | def test_clientmodel(): - | ^^^ E302 + | ^^^ 963 | pass 964 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 958 958 | # E302 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap index 9e725801e0..236d2a724f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_docstring.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E302_first_line_docstring.py:3:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E302_first_line_docstring.py:3:1 | 1 | """Test where the error is after the module's docstring.""" 2 | 3 | def fn(): - | ^^^ E302 + | ^^^ 4 | pass | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 1 1 | """Test where the error is after the module's docstring.""" diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap index ecbe189c76..9bce5adbdc 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_expression.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E302_first_line_expression.py:3:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E302_first_line_expression.py:3:1 | 1 | "Test where the first line is a comment, " + "and the rule violation follows it." 2 | 3 | def fn(): - | ^^^ E302 + | ^^^ 4 | pass | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 1 1 | "Test where the first line is a comment, " + "and the rule violation follows it." diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap index cd03aac657..dae5f7c98a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_function.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E302_first_line_function.py:4:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E302_first_line_function.py:4:1 | 2 | pass 3 | 4 | def fn2(): - | ^^^ E302 + | ^^^ 5 | pass | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 1 1 | def fn1(): diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap index ac0bdf5e2e..3951c67b86 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E302_first_line_statement.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E302_first_line_statement.py:3:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E302_first_line_statement.py:3:1 | 1 | print("Test where the first line is a statement, and the rule violation follows it.") 2 | 3 | def fn(): - | ^^^ E302 + | ^^^ 4 | pass | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 1 1 | print("Test where the first line is a statement, and the rule violation follows it.") diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap index 822fb79e6b..e28bb8562d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E302_E30_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' +invalid-syntax: Expected ']', found '(' + --> E30_syntax_error.py:4:15 | 2 | # parenthesis. 3 | @@ -10,42 +11,41 @@ E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' 5 | pass | -E30_syntax_error.py:7:1: E302 Expected 2 blank lines, found 1 +E302 Expected 2 blank lines, found 1 + --> E30_syntax_error.py:7:1 | 5 | pass 6 | 7 | def bar(): - | ^^^ E302 + | ^^^ 8 | pass | - = help: Add missing blank line(s) +help: Add missing blank line(s) -E30_syntax_error.py:13:18: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:13:18 | 12 | class Foo: 13 | def __init__( | ^ 14 | pass 15 | def method(): -16 | pass | -E30_syntax_error.py:18:11: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:18:11 | 16 | pass 17 | 18 | foo = Foo( | ^ -19 | -20 | -21 | def top( | -E30_syntax_error.py:21:9: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:21:9 | 21 | def top( | ^ 22 | def nested1(): 23 | pass -24 | def nested2(): | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap index 5e8f5f9e9c..1551b0be0d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:617:2: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:617:2 | 617 | def method2(): - | ^^^ E303 + | ^^^ 618 | return 22 619 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 613 613 | def method1(): @@ -19,14 +20,15 @@ E30.py:617:2: E303 [*] Too many blank lines (2) 618 617 | return 22 619 618 | # end -E30.py:644:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:644:5 | 644 | # arbitrary comment - | ^^^^^^^^^^^^^^^^^^^ E303 + | ^^^^^^^^^^^^^^^^^^^ 645 | 646 | def inner(): # E306 not expected (pycodestyle detects E306) | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 640 640 | def fn(): @@ -37,14 +39,15 @@ E30.py:644:5: E303 [*] Too many blank lines (2) 645 644 | 646 645 | def inner(): # E306 not expected (pycodestyle detects E306) -E30.py:656:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:656:5 | 656 | # arbitrary comment - | ^^^^^^^^^^^^^^^^^^^ E303 + | ^^^^^^^^^^^^^^^^^^^ 657 | def inner(): # E306 not expected (pycodestyle detects E306) 658 | pass | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 652 652 | def fn(): @@ -55,13 +58,14 @@ E30.py:656:5: E303 [*] Too many blank lines (2) 657 656 | def inner(): # E306 not expected (pycodestyle detects E306) 658 657 | pass -E30.py:667:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30.py:667:1 | 667 | print() - | ^^^^^ E303 + | ^^^^^ 668 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 663 663 | print() @@ -72,14 +76,15 @@ E30.py:667:1: E303 [*] Too many blank lines (3) 668 667 | # end 669 668 | -E30.py:676:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30.py:676:1 | 676 | # comment - | ^^^^^^^^^ E303 + | ^^^^^^^^^ 677 | 678 | print() | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 672 672 | print() @@ -90,12 +95,13 @@ E30.py:676:1: E303 [*] Too many blank lines (3) 677 676 | 678 677 | print() -E30.py:687:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:687:5 | 687 | # comment - | ^^^^^^^^^ E303 + | ^^^^^^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 683 683 | def a(): @@ -106,14 +112,15 @@ E30.py:687:5: E303 [*] Too many blank lines (2) 688 687 | 689 688 | -E30.py:690:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:690:5 | 690 | # another comment - | ^^^^^^^^^^^^^^^^^ E303 + | ^^^^^^^^^^^^^^^^^ 691 | 692 | print() | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 686 686 | @@ -124,15 +131,16 @@ E30.py:690:5: E303 [*] Too many blank lines (2) 691 690 | 692 691 | print() -E30.py:701:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30.py:701:1 | 701 | / """This class docstring comes on line 5. 702 | | It gives error E303: too many blank lines (3) 703 | | """ - | |___^ E303 + | |___^ 704 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 697 697 | #!python @@ -143,14 +151,15 @@ E30.py:701:1: E303 [*] Too many blank lines (3) 702 701 | It gives error E303: too many blank lines (3) 703 702 | """ -E30.py:713:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:713:5 | 713 | def b(self): - | ^^^ E303 + | ^^^ 714 | pass 715 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 709 709 | def a(self): @@ -161,13 +170,14 @@ E30.py:713:5: E303 [*] Too many blank lines (2) 714 713 | pass 715 714 | # end -E30.py:723:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:723:5 | 723 | a = 2 - | ^ E303 + | ^ 724 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 719 719 | if True: @@ -178,12 +188,13 @@ E30.py:723:5: E303 [*] Too many blank lines (2) 724 723 | # end 725 724 | -E30.py:731:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:731:5 | 731 | # comment - | ^^^^^^^^^ E303 + | ^^^^^^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 727 727 | # E303 @@ -194,14 +205,15 @@ E30.py:731:5: E303 [*] Too many blank lines (2) 732 731 | 733 732 | -E30.py:734:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:734:5 | 734 | # another comment - | ^^^^^^^^^^^^^^^^^ E303 + | ^^^^^^^^^^^^^^^^^ 735 | 736 | def test(self): pass | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 730 730 | @@ -212,14 +224,15 @@ E30.py:734:5: E303 [*] Too many blank lines (2) 735 734 | 736 735 | def test(self): pass -E30.py:748:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:748:5 | 748 | def b(self): - | ^^^ E303 + | ^^^ 749 | pass 750 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 744 744 | @@ -230,13 +243,14 @@ E30.py:748:5: E303 [*] Too many blank lines (2) 749 748 | pass 750 749 | # end -E30.py:758:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.py:758:5 | 758 | pass - | ^^^^ E303 + | ^^^^ 759 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 754 754 | def fn(): diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_comment.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_comment.py.snap index 368a0521a3..69abdc2255 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_comment.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_comment.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E303_first_line_comment.py:5:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E303_first_line_comment.py:5:1 | 5 | def fn(): - | ^^^ E303 + | ^^^ 6 | pass | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 1 1 | # Test where the first line is a comment, and the rule violation follows it. diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_docstring.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_docstring.py.snap index d1994e7275..a17b0e2583 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_docstring.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_docstring.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E303_first_line_docstring.py:5:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E303_first_line_docstring.py:5:1 | 5 | def fn(): - | ^^^ E303 + | ^^^ 6 | pass | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 1 1 | """Test where the error is after the module's docstring.""" diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_expression.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_expression.py.snap index de3e3df25c..5b5949a0ad 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_expression.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_expression.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E303_first_line_expression.py:5:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E303_first_line_expression.py:5:1 | 5 | def fn(): - | ^^^ E303 + | ^^^ 6 | pass | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 1 1 | "Test where the first line is a comment, " + "and the rule violation follows it." diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_statement.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_statement.py.snap index fef2b71f83..76cd66baf6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_statement.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E303_first_line_statement.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E303_first_line_statement.py:5:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E303_first_line_statement.py:5:1 | 5 | def fn(): - | ^^^ E303 + | ^^^ 6 | pass | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 1 1 | print("Test where the first line is a statement, and the rule violation follows it.") diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap index 655694ea0a..c70c94baad 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E303_E30_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' +invalid-syntax: Expected ']', found '(' + --> E30_syntax_error.py:4:15 | 2 | # parenthesis. 3 | @@ -10,41 +11,40 @@ E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' 5 | pass | -E30_syntax_error.py:12:1: E303 Too many blank lines (3) +E303 Too many blank lines (3) + --> E30_syntax_error.py:12:1 | 12 | class Foo: - | ^^^^^ E303 + | ^^^^^ 13 | def __init__( 14 | pass | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) -E30_syntax_error.py:13:18: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:13:18 | 12 | class Foo: 13 | def __init__( | ^ 14 | pass 15 | def method(): -16 | pass | -E30_syntax_error.py:18:11: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:18:11 | 16 | pass 17 | 18 | foo = Foo( | ^ -19 | -20 | -21 | def top( | -E30_syntax_error.py:21:9: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:21:9 | 21 | def top( | ^ 22 | def nested1(): 23 | pass -24 | def nested2(): | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap index fe68174f76..8600852a29 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E304_E30.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:765:1: E304 [*] Blank lines found after function decorator (1) +E304 [*] Blank lines found after function decorator (1) + --> E30.py:765:1 | 763 | @decorator 764 | 765 | def function(): - | ^^^ E304 + | ^^^ 766 | pass 767 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 761 761 | @@ -21,15 +22,16 @@ E30.py:765:1: E304 [*] Blank lines found after function decorator (1) 766 765 | pass 767 766 | # end -E30.py:774:1: E304 [*] Blank lines found after function decorator (1) +E304 [*] Blank lines found after function decorator (1) + --> E30.py:774:1 | 773 | # comment E304 not expected 774 | def function(): - | ^^^ E304 + | ^^^ 775 | pass 776 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 769 769 | @@ -40,15 +42,16 @@ E30.py:774:1: E304 [*] Blank lines found after function decorator (1) 774 773 | def function(): 775 774 | pass -E30.py:786:1: E304 [*] Blank lines found after function decorator (2) +E304 [*] Blank lines found after function decorator (2) + --> E30.py:786:1 | 785 | # second comment E304 not expected 786 | def function(): - | ^^^ E304 + | ^^^ 787 | pass 788 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 778 778 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap index 482f2d428e..4991548cac 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.py:798:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) +E305 [*] Expected 2 blank lines after class or function definition, found (1) + --> E30.py:798:1 | 797 | # another comment 798 | fn() - | ^^ E305 + | ^^ 799 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 795 795 | # comment @@ -19,14 +20,15 @@ E30.py:798:1: E305 [*] Expected 2 blank lines after class or function definition 799 800 | # end 800 801 | -E30.py:809:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) +E305 [*] Expected 2 blank lines after class or function definition, found (1) + --> E30.py:809:1 | 808 | # another comment 809 | a = 1 - | ^ E305 + | ^ 810 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 806 806 | # comment @@ -37,16 +39,17 @@ E30.py:809:1: E305 [*] Expected 2 blank lines after class or function definition 810 811 | # end 811 812 | -E30.py:821:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) +E305 [*] Expected 2 blank lines after class or function definition, found (1) + --> E30.py:821:1 | 819 | # another comment 820 | 821 | try: - | ^^^ E305 + | ^^^ 822 | fn() 823 | except Exception: | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 818 818 | @@ -57,15 +60,16 @@ E30.py:821:1: E305 [*] Expected 2 blank lines after class or function definition 822 823 | fn() 823 824 | except Exception: -E30.py:833:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) +E305 [*] Expected 2 blank lines after class or function definition, found (1) + --> E30.py:833:1 | 832 | # Two spaces before comments, too. 833 | if a(): - | ^^ E305 + | ^^ 834 | a() 835 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 829 829 | def a(): @@ -76,16 +80,17 @@ E30.py:833:1: E305 [*] Expected 2 blank lines after class or function definition 833 834 | if a(): 834 835 | a() -E30.py:846:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) +E305 [*] Expected 2 blank lines after class or function definition, found (1) + --> E30.py:846:1 | 844 | blah, blah 845 | 846 | if __name__ == '__main__': - | ^^ E305 + | ^^ 847 | main() 848 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 843 843 | def main(): @@ -96,14 +101,15 @@ E30.py:846:1: E305 [*] Expected 2 blank lines after class or function definition 847 848 | main() 848 849 | # end -E30.py:973:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) +E305 [*] Expected 2 blank lines after class or function definition, found (1) + --> E30.py:973:1 | 972 | # ====== Cool constants ======== 973 | BANANA = 100 - | ^^^^^^ E305 + | ^^^^^^ 974 | APPLE = 200 | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 969 969 | class A: diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap index ed1dfa66f6..dd97fe9010 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E305_E30_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' +invalid-syntax: Expected ']', found '(' + --> E30_syntax_error.py:4:15 | 2 | # parenthesis. 3 | @@ -10,41 +11,40 @@ E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' 5 | pass | -E30_syntax_error.py:13:18: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:13:18 | 12 | class Foo: 13 | def __init__( | ^ 14 | pass 15 | def method(): -16 | pass | -E30_syntax_error.py:18:1: E305 Expected 2 blank lines after class or function definition, found (1) +E305 Expected 2 blank lines after class or function definition, found (1) + --> E30_syntax_error.py:18:1 | 16 | pass 17 | 18 | foo = Foo( - | ^^^ E305 + | ^^^ | - = help: Add missing blank line(s) +help: Add missing blank line(s) -E30_syntax_error.py:18:11: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:18:11 | 16 | pass 17 | 18 | foo = Foo( | ^ -19 | -20 | -21 | def top( | -E30_syntax_error.py:21:9: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:21:9 | 21 | def top( | ^ 22 | def nested1(): 23 | pass -24 | def nested2(): | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap index 6833baa68c..b322886e7d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E30.py:854:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:854:5 | 852 | def a(): 853 | x = 1 854 | def b(): - | ^^^ E306 + | ^^^ 855 | pass 856 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 851 851 | # E306:3:5 @@ -22,16 +22,17 @@ E30.py:854:5: E306 [*] Expected 1 blank line before a nested definition, found 0 855 856 | pass 856 857 | # end -E30.py:862:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:862:5 | 860 | async def a(): 861 | x = 1 862 | def b(): - | ^^^ E306 + | ^^^ 863 | pass 864 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 859 859 | #: E306:3:5 @@ -42,16 +43,17 @@ E30.py:862:5: E306 [*] Expected 1 blank line before a nested definition, found 0 863 864 | pass 864 865 | # end -E30.py:870:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:870:5 | 868 | def a(): 869 | x = 2 870 | def b(): - | ^^^ E306 + | ^^^ 871 | x = 1 872 | def c(): | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 867 867 | #: E306:3:5 E306:5:9 @@ -62,16 +64,17 @@ E30.py:870:5: E306 [*] Expected 1 blank line before a nested definition, found 0 871 872 | x = 1 872 873 | def c(): -E30.py:872:9: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:872:9 | 870 | def b(): 871 | x = 1 872 | def c(): - | ^^^ E306 + | ^^^ 873 | pass 874 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 869 869 | x = 2 @@ -82,16 +85,17 @@ E30.py:872:9: E306 [*] Expected 1 blank line before a nested definition, found 0 873 874 | pass 874 875 | # end -E30.py:880:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:880:5 | 878 | def a(): 879 | x = 1 880 | class C: - | ^^^^^ E306 + | ^^^^^ 881 | pass 882 | x = 2 | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 877 877 | # E306:3:5 E306:6:5 @@ -102,16 +106,17 @@ E30.py:880:5: E306 [*] Expected 1 blank line before a nested definition, found 0 881 882 | pass 882 883 | x = 2 -E30.py:883:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:883:5 | 881 | pass 882 | x = 2 883 | def b(): - | ^^^ E306 + | ^^^ 884 | pass 885 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 880 880 | class C: @@ -122,15 +127,16 @@ E30.py:883:5: E306 [*] Expected 1 blank line before a nested definition, found 0 884 885 | pass 885 886 | # end -E30.py:892:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:892:5 | 890 | def bar(): 891 | pass 892 | def baz(): pass - | ^^^ E306 + | ^^^ 893 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 889 889 | def foo(): @@ -141,16 +147,17 @@ E30.py:892:5: E306 [*] Expected 1 blank line before a nested definition, found 0 893 894 | # end 894 895 | -E30.py:899:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:899:5 | 897 | def foo(): 898 | def bar(): pass 899 | def baz(): - | ^^^ E306 + | ^^^ 900 | pass 901 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 896 896 | # E306:3:5 @@ -161,16 +168,17 @@ E30.py:899:5: E306 [*] Expected 1 blank line before a nested definition, found 0 900 901 | pass 901 902 | # end -E30.py:907:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:907:5 | 905 | def a(): 906 | x = 2 907 | @decorator - | ^ E306 + | ^ 908 | def b(): 909 | pass | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 904 904 | # E306 @@ -181,16 +189,17 @@ E30.py:907:5: E306 [*] Expected 1 blank line before a nested definition, found 0 908 909 | def b(): 909 910 | pass -E30.py:916:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:916:5 | 914 | def a(): 915 | x = 2 916 | @decorator - | ^ E306 + | ^ 917 | async def b(): 918 | pass | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 913 913 | # E306 @@ -201,16 +210,17 @@ E30.py:916:5: E306 [*] Expected 1 blank line before a nested definition, found 0 917 918 | async def b(): 918 919 | pass -E30.py:925:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.py:925:5 | 923 | def a(): 924 | x = 2 925 | async def b(): - | ^^^^^ E306 + | ^^^^^ 926 | pass 927 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 922 922 | # E306 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap index 2389bcb644..d3a6b15d4e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E306_E30_syntax_error.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' +invalid-syntax: Expected ']', found '(' + --> E30_syntax_error.py:4:15 | 2 | # parenthesis. 3 | @@ -10,42 +11,41 @@ E30_syntax_error.py:4:15: invalid-syntax: Expected ']', found '(' 5 | pass | -E30_syntax_error.py:13:18: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:13:18 | 12 | class Foo: 13 | def __init__( | ^ 14 | pass 15 | def method(): -16 | pass | -E30_syntax_error.py:18:11: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:18:11 | 16 | pass 17 | 18 | foo = Foo( | ^ -19 | -20 | -21 | def top( | -E30_syntax_error.py:21:9: invalid-syntax: Expected ')', found newline +invalid-syntax: Expected ')', found newline + --> E30_syntax_error.py:21:9 | 21 | def top( | ^ 22 | def nested1(): 23 | pass -24 | def nested2(): | -E30_syntax_error.py:24:5: E306 Expected 1 blank line before a nested definition, found 0 +E306 Expected 1 blank line before a nested definition, found 0 + --> E30_syntax_error.py:24:5 | 22 | def nested1(): 23 | pass 24 | def nested2(): - | ^^^ E306 + | ^^^ 25 | pass | - = help: Add missing blank line +help: Add missing blank line diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap index 86b9b31306..d9b8910ed4 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E40.py:2:1: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:2:1 | 1 | #: E401 2 | import os, sys - | ^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^ 3 | 4 | #: Okay | - = help: Split imports +help: Split imports ℹ Safe fix 1 1 | #: E401 @@ -20,14 +21,15 @@ E40.py:2:1: E401 [*] Multiple imports on one line 4 5 | #: Okay 5 6 | import os -E40.py:65:1: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:65:1 | 64 | #: E401 65 | import re as regex, string # also with a comment! - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | import re as regex, string; x = 1 | - = help: Split imports +help: Split imports ℹ Safe fix 62 62 | import bar @@ -40,16 +42,17 @@ E40.py:65:1: E401 [*] Multiple imports on one line 67 68 | 68 69 | x = 1; import re as regex, string -E40.py:66:1: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:66:1 | 64 | #: E401 65 | import re as regex, string # also with a comment! 66 | import re as regex, string; x = 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 | 68 | x = 1; import re as regex, string | - = help: Split imports +help: Split imports ℹ Safe fix 63 63 | @@ -61,14 +64,15 @@ E40.py:66:1: E401 [*] Multiple imports on one line 68 68 | x = 1; import re as regex, string 69 69 | -E40.py:68:8: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:68:8 | 66 | import re as regex, string; x = 1 67 | 68 | x = 1; import re as regex, string - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Split imports +help: Split imports ℹ Safe fix 65 65 | import re as regex, string # also with a comment! @@ -80,15 +84,16 @@ E40.py:68:8: E401 [*] Multiple imports on one line 70 70 | 71 71 | def blah(): -E40.py:72:5: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:72:5 | 71 | def blah(): 72 | import datetime as dt, copy - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 73 | 74 | def nested_and_tested(): | - = help: Split imports +help: Split imports ℹ Safe fix 69 69 | @@ -101,15 +106,16 @@ E40.py:72:5: E401 [*] Multiple imports on one line 74 75 | def nested_and_tested(): 75 76 | import builtins, textwrap as tw -E40.py:75:9: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:75:9 | 74 | def nested_and_tested(): 75 | import builtins, textwrap as tw - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 76 | 77 | x = 1; import re as regex, string | - = help: Split imports +help: Split imports ℹ Safe fix 72 72 | import datetime as dt, copy @@ -122,15 +128,16 @@ E40.py:75:9: E401 [*] Multiple imports on one line 77 78 | x = 1; import re as regex, string 78 79 | import re as regex, string; x = 1 -E40.py:77:16: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:77:16 | 75 | import builtins, textwrap as tw 76 | 77 | x = 1; import re as regex, string - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 78 | import re as regex, string; x = 1 | - = help: Split imports +help: Split imports ℹ Safe fix 74 74 | def nested_and_tested(): @@ -142,15 +149,16 @@ E40.py:77:16: E401 [*] Multiple imports on one line 79 79 | 80 80 | if True: import re as regex, string -E40.py:78:9: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:78:9 | 77 | x = 1; import re as regex, string 78 | import re as regex, string; x = 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 79 | 80 | if True: import re as regex, string | - = help: Split imports +help: Split imports ℹ Safe fix 75 75 | import builtins, textwrap as tw @@ -161,14 +169,15 @@ E40.py:78:9: E401 [*] Multiple imports on one line 79 79 | 80 80 | if True: import re as regex, string -E40.py:80:14: E401 [*] Multiple imports on one line +E401 [*] Multiple imports on one line + --> E40.py:80:14 | 78 | import re as regex, string; x = 1 79 | 80 | if True: import re as regex, string - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Split imports +help: Split imports ℹ Safe fix 77 77 | x = 1; import re as regex, string diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap index bbf2e510a7..137665e69c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap @@ -1,58 +1,64 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E40.py:56:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E40.py:56:1 | 54 | VERSION = '1.2.3' 55 | 56 | import foo - | ^^^^^^^^^^ E402 + | ^^^^^^^^^^ 57 | #: E402 58 | import foo | -E40.py:58:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E40.py:58:1 | 56 | import foo 57 | #: E402 58 | import foo - | ^^^^^^^^^^ E402 + | ^^^^^^^^^^ 59 | 60 | a = 1 | -E40.py:62:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E40.py:62:1 | 60 | a = 1 61 | 62 | import bar - | ^^^^^^^^^^ E402 + | ^^^^^^^^^^ 63 | 64 | #: E401 | -E40.py:65:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E40.py:65:1 | 64 | #: E401 65 | import re as regex, string # also with a comment! - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | import re as regex, string; x = 1 | -E40.py:66:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E40.py:66:1 | 64 | #: E401 65 | import re as regex, string # also with a comment! 66 | import re as regex, string; x = 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 | 68 | x = 1; import re as regex, string | -E40.py:68:8: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E40.py:68:8 | 66 | import re as regex, string; x = 1 67 | 68 | x = 1; import re as regex, string - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.ipynb.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.ipynb.snap index 9cbf106ef9..470676927d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.ipynb.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.ipynb.snap @@ -1,29 +1,32 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E402.ipynb:9:1: E402 Module level import not at top of cell +E402 Module level import not at top of cell + --> E402.ipynb:9:1 | 7 | os.path 8 | 9 | import pathlib - | ^^^^^^^^^^^^^^ E402 + | ^^^^^^^^^^^^^^ 10 | 11 | import a | -E402.ipynb:22:1: E402 Module level import not at top of cell +E402 Module level import not at top of cell + --> E402.ipynb:22:1 | 20 | __some__magic = 1 21 | 22 | import c - | ^^^^^^^^ E402 + | ^^^^^^^^ 23 | import ok | -E402.ipynb:30:1: E402 Module level import not at top of cell +E402 Module level import not at top of cell + --> E402.ipynb:30:1 | 30 | import no_ok - | ^^^^^^^^^^^^ E402 + | ^^^^^^^^^^^^ 31 | 32 | %%time | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_0.py.snap index dff5430ecb..f3a5e4f3f1 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_0.py.snap @@ -1,26 +1,29 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E402_0.py:35:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E402_0.py:35:1 | 33 | __some__magic = 1 34 | 35 | import h - | ^^^^^^^^ E402 + | ^^^^^^^^ | -E402_0.py:45:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E402_0.py:45:1 | 43 | import j 44 | 45 | import k; import l - | ^^^^^^^^ E402 + | ^^^^^^^^ | -E402_0.py:45:11: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E402_0.py:45:11 | 43 | import j 44 | 45 | import k; import l - | ^^^^^^^^ E402 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.py.snap index a035c4d914..2e45cb19b6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402_1.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E402_1.py:5:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E402_1.py:5:1 | 3 | """Some other docstring.""" 4 | 5 | import b - | ^^^^^^^^ E402 + | ^^^^^^^^ 6 | 7 | """Some other docstring.""" | -E402_1.py:9:1: E402 Module level import not at top of file +E402 Module level import not at top of file + --> E402_1.py:9:1 | 7 | """Some other docstring.""" 8 | 9 | import c - | ^^^^^^^^ E402 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap index b7eab7d015..52d785c025 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap @@ -1,57 +1,63 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E501.py:5:89: E501 Line too long (123 > 88) +E501 Line too long (123 > 88) + --> E501.py:5:89 | 3 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 4 | 5 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | """ | -E501.py:16:85: E501 Line too long (95 > 88) +E501 Line too long (95 > 88) + --> E501.py:16:85 | 15 | _ = "---------------------------------------------------------------------------AAAAAAA" 16 | _ = "---------------------------------------------------------------------------亜亜亜亜亜亜亜" - | ^^^^^^^ E501 + | ^^^^^^^ | -E501.py:25:89: E501 Line too long (127 > 88) +E501 Line too long (127 > 88) + --> E501.py:25:89 | 23 | caller( 24 | """ 25 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | """, 27 | ) | -E501.py:40:89: E501 Line too long (132 > 88) +E501 Line too long (132 > 88) + --> E501.py:40:89 | 38 | "Lorem ipsum dolor": "sit amet", 39 | # E501 Line too long 40 | "Lorem ipsum dolor": "sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | # E501 Line too long 42 | "Lorem ipsum dolor": """ | -E501.py:43:89: E501 Line too long (105 > 88) +E501 Line too long (105 > 88) + --> E501.py:43:89 | 41 | # E501 Line too long 42 | "Lorem ipsum dolor": """ 43 | sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - | ^^^^^^^^^^^^^^^^^ E501 + | ^^^^^^^^^^^^^^^^^ 44 | """, 45 | # OK | -E501.py:83:89: E501 Line too long (147 > 88) +E501 Line too long (147 > 88) + --> E501.py:83:89 | 81 | … 82 | … -83 | … URL and, therefore, could easily be broken across multiple lines ([source](https://ruff.rs)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +83 | …ned URL and, therefore, could easily be broken across multiple lines ([source](https://ruff.rs)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | … | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501_3.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501_3.py.snap index 7166e26560..36509badc2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501_3.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501_3.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E501_3.py:11:89: E501 Line too long (89 > 88) +E501 Line too long (89 > 88) + --> E501_3.py:11:89 | 10 | # Error (89 characters) 11 | "shape:" + "shape:" + "shape:" + "shape:" + "shape:" + "shape:" + "shape:" + "shape:aaaa" # type: ignore - | ^ E501 + | ^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501_4.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501_4.py.snap index 2334712b503a0c53388921b78d241c6e69ab7717..8729718f1c29870269276807f5ab9cae642e8a4b 100644 GIT binary patch literal 9132 zcmeI$O>crQ7zc3Ae2OR8xt8L~l*4Xj_k93O2UW4sL5QRrl zeyQ}|5<()Q8l8z0GR>_pR5!=tp(>>nni`$C@0B}Sx0%X?v27*jS>UE zIWeuY{F1`%Qj5%r9JmB=skJbsR5AiWUSPM1*N`+S;U)o=RIZ@AFKZDK}R0ikPD7A}x(+T*p|#7IBog8}X3_?lvQr_^fZ7&-#zU zb+@XY+FwQAPXgm@zwaLPj_OreXrx2x!L0fa5@z>QtHr}m{ekFdxI{zn9fvD4^fp|h zp||1VOda9ghZ`J+-s5nKhQ5aD1P$Gv+;e7LW4h_yl)j7@a3*2Ij57%%#+*qQG3iXf zxMes|caDPx&xvP?DQJ+jKk18$+h+lBF?j~W#XK4i7gK6LT+FTkaWT;b#Kld$aJVdv faTPJn>lt)ejBB)UT;Dxb7ULozgF zPD<4>34&v;PR;u~t5FRUf>B*}q}>0}%0BlHWMkUHNs%2({a_b>M&UP z1ZDxbh8Qe$madvs9R^GNrUm30VzAVOx@uZ=7%cUs7LaR*!BWTSs%h0>u=HWh0&)!z m*eDEXh2ZLG>QGr)dl?|-2$iM9m$RoSL}h99Wq_QcPWB7qT#MiU diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E701_E70.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E701_E70.py.snap index a4bf3aaaf1..dcbcaa47a5 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E701_E70.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E701_E70.py.snap @@ -1,142 +1,155 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E70.py:2:5: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:2:5 | 1 | #: E701:1:5 2 | if a: a = False - | ^ E701 + | ^ 3 | #: E701:1:40 4 | if not header or header[:6] != 'bytes=': return | -E70.py:4:40: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:4:40 | 2 | if a: a = False 3 | #: E701:1:40 4 | if not header or header[:6] != 'bytes=': return - | ^ E701 + | ^ 5 | #: E702:1:10 6 | a = False; b = True | -E70.py:25:8: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:25:8 | 23 | def f(x): return 2*x 24 | #: E704:1:8 E702:1:11 E703:1:14 25 | if True: x; y; - | ^ E701 + | ^ 26 | #: E701:1:8 27 | if True: lambda a: b | -E70.py:27:8: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:27:8 | 25 | if True: x; y; 26 | #: E701:1:8 27 | if True: lambda a: b - | ^ E701 + | ^ 28 | #: E701:1:10 29 | if a := 1: pass | -E70.py:29:10: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:29:10 | 27 | if True: lambda a: b 28 | #: E701:1:10 29 | if a := 1: pass - | ^ E701 + | ^ 30 | # E701:1:4 E701:2:18 E701:3:8 31 | try: lambda foo: bar | -E70.py:31:4: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:31:4 | 29 | if a := 1: pass 30 | # E701:1:4 E701:2:18 E701:3:8 31 | try: lambda foo: bar - | ^ E701 + | ^ 32 | except ValueError: pass 33 | finally: pass | -E70.py:32:18: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:32:18 | 30 | # E701:1:4 E701:2:18 E701:3:8 31 | try: lambda foo: bar 32 | except ValueError: pass - | ^ E701 + | ^ 33 | finally: pass 34 | # E701:1:7 | -E70.py:33:8: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:33:8 | 31 | try: lambda foo: bar 32 | except ValueError: pass 33 | finally: pass - | ^ E701 + | ^ 34 | # E701:1:7 35 | class C: pass | -E70.py:35:8: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:35:8 | 33 | finally: pass 34 | # E701:1:7 35 | class C: pass - | ^ E701 + | ^ 36 | # E701:1:7 37 | with C(): pass | -E70.py:37:9: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:37:9 | 35 | class C: pass 36 | # E701:1:7 37 | with C(): pass - | ^ E701 + | ^ 38 | # E701:1:14 39 | async with C(): pass | -E70.py:39:15: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:39:15 | 37 | with C(): pass 38 | # E701:1:14 39 | async with C(): pass - | ^ E701 + | ^ 40 | #: 41 | lambda a: b | -E70.py:54:8: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:54:8 | 52 | def f(): ... 53 | #: E701:1:8 E702:1:13 54 | class C: ...; x = 1 - | ^ E701 + | ^ 55 | #: E701:1:8 E702:1:13 56 | class C: ...; ... | -E70.py:56:8: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:56:8 | 54 | class C: ...; x = 1 55 | #: E701:1:8 E702:1:13 56 | class C: ...; ... - | ^ E701 + | ^ 57 | #: E701:2:12 58 | match *0, 1, *2: | -E70.py:59:12: E701 Multiple statements on one line (colon) +E701 Multiple statements on one line (colon) + --> E70.py:59:12 | 57 | #: E701:2:12 58 | match *0, 1, *2: 59 | case 0,: y = 0 - | ^ E701 + | ^ 60 | #: 61 | class Foo: | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E702_E70.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E702_E70.py.snap index d3232a1b9c..272b2e4550 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E702_E70.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E702_E70.py.snap @@ -1,73 +1,79 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E70.py:6:10: E702 Multiple statements on one line (semicolon) +E702 Multiple statements on one line (semicolon) + --> E70.py:6:10 | 4 | if not header or header[:6] != 'bytes=': return 5 | #: E702:1:10 6 | a = False; b = True - | ^ E702 + | ^ 7 | #: E702:1:17 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) | -E70.py:8:17: E702 Multiple statements on one line (semicolon) +E702 Multiple statements on one line (semicolon) + --> E70.py:8:17 | 6 | a = False; b = True 7 | #: E702:1:17 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) - | ^ E702 + | ^ 9 | #: E703:1:13 10 | import shlex; | -E70.py:12:9: E702 Multiple statements on one line (semicolon) +E702 Multiple statements on one line (semicolon) + --> E70.py:12:9 | 10 | import shlex; 11 | #: E702:1:9 E703:1:23 12 | del a[:]; a.append(42); - | ^ E702 + | ^ 13 | #: E704:1:1 14 | def f(x): return 2 | -E70.py:25:11: E702 Multiple statements on one line (semicolon) +E702 Multiple statements on one line (semicolon) + --> E70.py:25:11 | 23 | def f(x): return 2*x 24 | #: E704:1:8 E702:1:11 E703:1:14 25 | if True: x; y; - | ^ E702 + | ^ 26 | #: E701:1:8 27 | if True: lambda a: b | -E70.py:54:13: E702 Multiple statements on one line (semicolon) +E702 Multiple statements on one line (semicolon) + --> E70.py:54:13 | 52 | def f(): ... 53 | #: E701:1:8 E702:1:13 54 | class C: ...; x = 1 - | ^ E702 + | ^ 55 | #: E701:1:8 E702:1:13 56 | class C: ...; ... | -E70.py:56:13: E702 Multiple statements on one line (semicolon) +E702 Multiple statements on one line (semicolon) + --> E70.py:56:13 | 54 | class C: ...; x = 1 55 | #: E701:1:8 E702:1:13 56 | class C: ...; ... - | ^ E702 + | ^ 57 | #: E701:2:12 58 | match *0, 1, *2: | -E70.py:65:4: E702 Multiple statements on one line (semicolon) +E702 Multiple statements on one line (semicolon) + --> E70.py:65:4 | 63 | #: E702:2:4 64 | while 1: 65 | 1;... - | ^ E702 + | ^ 66 | #: E703:2:1 67 | 0\ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap index 399f4bfbb5..9b62eb2ee9 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E70.py:10:13: E703 [*] Statement ends with an unnecessary semicolon +E703 [*] Statement ends with an unnecessary semicolon + --> E70.py:10:13 | 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) 9 | #: E703:1:13 10 | import shlex; - | ^ E703 + | ^ 11 | #: E702:1:9 E703:1:23 12 | del a[:]; a.append(42); | - = help: Remove unnecessary semicolon +help: Remove unnecessary semicolon ℹ Safe fix 7 7 | #: E702:1:17 @@ -23,16 +23,17 @@ E70.py:10:13: E703 [*] Statement ends with an unnecessary semicolon 12 12 | del a[:]; a.append(42); 13 13 | #: E704:1:1 -E70.py:12:23: E703 [*] Statement ends with an unnecessary semicolon +E703 [*] Statement ends with an unnecessary semicolon + --> E70.py:12:23 | 10 | import shlex; 11 | #: E702:1:9 E703:1:23 12 | del a[:]; a.append(42); - | ^ E703 + | ^ 13 | #: E704:1:1 14 | def f(x): return 2 | - = help: Remove unnecessary semicolon +help: Remove unnecessary semicolon ℹ Safe fix 9 9 | #: E703:1:13 @@ -44,16 +45,17 @@ E70.py:12:23: E703 [*] Statement ends with an unnecessary semicolon 14 14 | def f(x): return 2 15 15 | #: E704:1:1 -E70.py:25:14: E703 [*] Statement ends with an unnecessary semicolon +E703 [*] Statement ends with an unnecessary semicolon + --> E70.py:25:14 | 23 | def f(x): return 2*x 24 | #: E704:1:8 E702:1:11 E703:1:14 25 | if True: x; y; - | ^ E703 + | ^ 26 | #: E701:1:8 27 | if True: lambda a: b | - = help: Remove unnecessary semicolon +help: Remove unnecessary semicolon ℹ Safe fix 22 22 | while all is round: @@ -65,16 +67,17 @@ E70.py:25:14: E703 [*] Statement ends with an unnecessary semicolon 27 27 | if True: lambda a: b 28 28 | #: E701:1:10 -E70.py:68:1: E703 [*] Statement ends with an unnecessary semicolon +E703 [*] Statement ends with an unnecessary semicolon + --> E70.py:68:1 | 66 | #: E703:2:1 67 | 0\ 68 | ; - | ^ E703 + | ^ 69 | #: E701:2:3 70 | a = \ | - = help: Remove unnecessary semicolon +help: Remove unnecessary semicolon ℹ Safe fix 64 64 | while 1: @@ -87,16 +90,17 @@ E70.py:68:1: E703 [*] Statement ends with an unnecessary semicolon 70 69 | a = \ 71 70 | 5; -E70.py:71:4: E703 [*] Statement ends with an unnecessary semicolon +E703 [*] Statement ends with an unnecessary semicolon + --> E70.py:71:4 | 69 | #: E701:2:3 70 | a = \ 71 | 5; - | ^ E703 + | ^ 72 | #: 73 | with x(y) as z: ... | - = help: Remove unnecessary semicolon +help: Remove unnecessary semicolon ℹ Safe fix 68 68 | ; diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E703.ipynb.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E703.ipynb.snap index 902265b169..03e8193c87 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E703.ipynb.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E703.ipynb.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E703.ipynb:5:2: E703 [*] Statement ends with an unnecessary semicolon +E703 [*] Statement ends with an unnecessary semicolon + --> E703.ipynb:5:2 | 3 | x; 4 | # Only skip the last expression 5 | x; # E703 - | ^ E703 + | ^ 6 | x; 7 | # Nested expressions isn't relevant | - = help: Remove unnecessary semicolon +help: Remove unnecessary semicolon ℹ Safe fix 2 2 | # Simple case @@ -23,16 +23,17 @@ E703.ipynb:5:2: E703 [*] Statement ends with an unnecessary semicolon 7 7 | # Nested expressions isn't relevant 8 8 | if True: -E703.ipynb:9:6: E703 [*] Statement ends with an unnecessary semicolon +E703 [*] Statement ends with an unnecessary semicolon + --> E703.ipynb:9:6 | 7 | # Nested expressions isn't relevant 8 | if True: 9 | x; - | ^ E703 + | ^ 10 | # Semicolons with multiple expressions 11 | x; x; | - = help: Remove unnecessary semicolon +help: Remove unnecessary semicolon ℹ Safe fix 6 6 | x; diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap index 133712eea9..ea67cff398 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E711.py:2:11: E711 [*] Comparison to `None` should be `cond is None` +E711 [*] Comparison to `None` should be `cond is None` + --> E711.py:2:11 | 1 | #: E711 2 | if res == None: - | ^^^^ E711 + | ^^^^ 3 | pass 4 | #: E711 | - = help: Replace with `cond is None` +help: Replace with `cond is None` ℹ Unsafe fix 1 1 | #: E711 @@ -19,16 +20,17 @@ E711.py:2:11: E711 [*] Comparison to `None` should be `cond is None` 4 4 | #: E711 5 5 | if res != None: -E711.py:5:11: E711 [*] Comparison to `None` should be `cond is not None` +E711 [*] Comparison to `None` should be `cond is not None` + --> E711.py:5:11 | 3 | pass 4 | #: E711 5 | if res != None: - | ^^^^ E711 + | ^^^^ 6 | pass 7 | #: E711 | - = help: Replace with `cond is not None` +help: Replace with `cond is not None` ℹ Unsafe fix 2 2 | if res == None: @@ -40,16 +42,17 @@ E711.py:5:11: E711 [*] Comparison to `None` should be `cond is not None` 7 7 | #: E711 8 8 | if None == res: -E711.py:8:4: E711 [*] Comparison to `None` should be `cond is None` +E711 [*] Comparison to `None` should be `cond is None` + --> E711.py:8:4 | 6 | pass 7 | #: E711 8 | if None == res: - | ^^^^ E711 + | ^^^^ 9 | pass 10 | #: E711 | - = help: Replace with `cond is None` +help: Replace with `cond is None` ℹ Unsafe fix 5 5 | if res != None: @@ -61,16 +64,17 @@ E711.py:8:4: E711 [*] Comparison to `None` should be `cond is None` 10 10 | #: E711 11 11 | if None != res: -E711.py:11:4: E711 [*] Comparison to `None` should be `cond is not None` +E711 [*] Comparison to `None` should be `cond is not None` + --> E711.py:11:4 | 9 | pass 10 | #: E711 11 | if None != res: - | ^^^^ E711 + | ^^^^ 12 | pass 13 | #: E711 | - = help: Replace with `cond is not None` +help: Replace with `cond is not None` ℹ Unsafe fix 8 8 | if None == res: @@ -82,16 +86,17 @@ E711.py:11:4: E711 [*] Comparison to `None` should be `cond is not None` 13 13 | #: E711 14 14 | if res[1] == None: -E711.py:14:14: E711 [*] Comparison to `None` should be `cond is None` +E711 [*] Comparison to `None` should be `cond is None` + --> E711.py:14:14 | 12 | pass 13 | #: E711 14 | if res[1] == None: - | ^^^^ E711 + | ^^^^ 15 | pass 16 | #: E711 | - = help: Replace with `cond is None` +help: Replace with `cond is None` ℹ Unsafe fix 11 11 | if None != res: @@ -103,16 +108,17 @@ E711.py:14:14: E711 [*] Comparison to `None` should be `cond is None` 16 16 | #: E711 17 17 | if res[1] != None: -E711.py:17:14: E711 [*] Comparison to `None` should be `cond is not None` +E711 [*] Comparison to `None` should be `cond is not None` + --> E711.py:17:14 | 15 | pass 16 | #: E711 17 | if res[1] != None: - | ^^^^ E711 + | ^^^^ 18 | pass 19 | #: E711 | - = help: Replace with `cond is not None` +help: Replace with `cond is not None` ℹ Unsafe fix 14 14 | if res[1] == None: @@ -124,16 +130,17 @@ E711.py:17:14: E711 [*] Comparison to `None` should be `cond is not None` 19 19 | #: E711 20 20 | if None != res[1]: -E711.py:20:4: E711 [*] Comparison to `None` should be `cond is not None` +E711 [*] Comparison to `None` should be `cond is not None` + --> E711.py:20:4 | 18 | pass 19 | #: E711 20 | if None != res[1]: - | ^^^^ E711 + | ^^^^ 21 | pass 22 | #: E711 | - = help: Replace with `cond is not None` +help: Replace with `cond is not None` ℹ Unsafe fix 17 17 | if res[1] != None: @@ -145,15 +152,16 @@ E711.py:20:4: E711 [*] Comparison to `None` should be `cond is not None` 22 22 | #: E711 23 23 | if None == res[1]: -E711.py:23:4: E711 [*] Comparison to `None` should be `cond is None` +E711 [*] Comparison to `None` should be `cond is None` + --> E711.py:23:4 | 21 | pass 22 | #: E711 23 | if None == res[1]: - | ^^^^ E711 + | ^^^^ 24 | pass | - = help: Replace with `cond is None` +help: Replace with `cond is None` ℹ Unsafe fix 20 20 | if None != res[1]: @@ -165,15 +173,16 @@ E711.py:23:4: E711 [*] Comparison to `None` should be `cond is None` 25 25 | 26 26 | if x == None != None: -E711.py:26:9: E711 [*] Comparison to `None` should be `cond is None` +E711 [*] Comparison to `None` should be `cond is None` + --> E711.py:26:9 | 24 | pass 25 | 26 | if x == None != None: - | ^^^^ E711 + | ^^^^ 27 | pass | - = help: Replace with `cond is None` +help: Replace with `cond is None` ℹ Unsafe fix 23 23 | if None == res[1]: @@ -185,15 +194,16 @@ E711.py:26:9: E711 [*] Comparison to `None` should be `cond is None` 28 28 | 29 29 | #: Okay -E711.py:26:17: E711 [*] Comparison to `None` should be `cond is not None` +E711 [*] Comparison to `None` should be `cond is not None` + --> E711.py:26:17 | 24 | pass 25 | 26 | if x == None != None: - | ^^^^ E711 + | ^^^^ 27 | pass | - = help: Replace with `cond is not None` +help: Replace with `cond is not None` ℹ Unsafe fix 23 23 | if None == res[1]: diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap index b540850623..502c3b1e2c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E712.py:2:4: E712 [*] Avoid equality comparisons to `True`; use `res:` for truth checks +E712 [*] Avoid equality comparisons to `True`; use `res:` for truth checks + --> E712.py:2:4 | 1 | #: E712 2 | if res == True: - | ^^^^^^^^^^^ E712 + | ^^^^^^^^^^^ 3 | pass 4 | #: E712 | - = help: Replace with `res` +help: Replace with `res` ℹ Unsafe fix 1 1 | #: E712 @@ -19,16 +20,17 @@ E712.py:2:4: E712 [*] Avoid equality comparisons to `True`; use `res:` for truth 4 4 | #: E712 5 5 | if res != False: -E712.py:5:4: E712 [*] Avoid inequality comparisons to `False`; use `res:` for truth checks +E712 [*] Avoid inequality comparisons to `False`; use `res:` for truth checks + --> E712.py:5:4 | 3 | pass 4 | #: E712 5 | if res != False: - | ^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^ 6 | pass 7 | #: E712 | - = help: Replace with `res` +help: Replace with `res` ℹ Unsafe fix 2 2 | if res == True: @@ -40,16 +42,17 @@ E712.py:5:4: E712 [*] Avoid inequality comparisons to `False`; use `res:` for tr 7 7 | #: E712 8 8 | if True != res: -E712.py:8:4: E712 [*] Avoid inequality comparisons to `True`; use `not res:` for false checks +E712 [*] Avoid inequality comparisons to `True`; use `not res:` for false checks + --> E712.py:8:4 | 6 | pass 7 | #: E712 8 | if True != res: - | ^^^^^^^^^^^ E712 + | ^^^^^^^^^^^ 9 | pass 10 | #: E712 | - = help: Replace with `not res` +help: Replace with `not res` ℹ Unsafe fix 5 5 | if res != False: @@ -61,16 +64,17 @@ E712.py:8:4: E712 [*] Avoid inequality comparisons to `True`; use `not res:` for 10 10 | #: E712 11 11 | if False == res: -E712.py:11:4: E712 [*] Avoid equality comparisons to `False`; use `not res:` for false checks +E712 [*] Avoid equality comparisons to `False`; use `not res:` for false checks + --> E712.py:11:4 | 9 | pass 10 | #: E712 11 | if False == res: - | ^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^ 12 | pass 13 | #: E712 | - = help: Replace with `not res` +help: Replace with `not res` ℹ Unsafe fix 8 8 | if True != res: @@ -82,16 +86,17 @@ E712.py:11:4: E712 [*] Avoid equality comparisons to `False`; use `not res:` for 13 13 | #: E712 14 14 | if res[1] == True: -E712.py:14:4: E712 [*] Avoid equality comparisons to `True`; use `res[1]:` for truth checks +E712 [*] Avoid equality comparisons to `True`; use `res[1]:` for truth checks + --> E712.py:14:4 | 12 | pass 13 | #: E712 14 | if res[1] == True: - | ^^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^^ 15 | pass 16 | #: E712 | - = help: Replace with `res[1]` +help: Replace with `res[1]` ℹ Unsafe fix 11 11 | if False == res: @@ -103,16 +108,17 @@ E712.py:14:4: E712 [*] Avoid equality comparisons to `True`; use `res[1]:` for t 16 16 | #: E712 17 17 | if res[1] != False: -E712.py:17:4: E712 [*] Avoid inequality comparisons to `False`; use `res[1]:` for truth checks +E712 [*] Avoid inequality comparisons to `False`; use `res[1]:` for truth checks + --> E712.py:17:4 | 15 | pass 16 | #: E712 17 | if res[1] != False: - | ^^^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^^^ 18 | pass 19 | #: E712 | - = help: Replace with `res[1]` +help: Replace with `res[1]` ℹ Unsafe fix 14 14 | if res[1] == True: @@ -124,16 +130,17 @@ E712.py:17:4: E712 [*] Avoid inequality comparisons to `False`; use `res[1]:` fo 19 19 | #: E712 20 20 | var = 1 if cond == True else -1 if cond == False else cond -E712.py:20:12: E712 [*] Avoid equality comparisons to `True`; use `cond:` for truth checks +E712 [*] Avoid equality comparisons to `True`; use `cond:` for truth checks + --> E712.py:20:12 | 18 | pass 19 | #: E712 20 | var = 1 if cond == True else -1 if cond == False else cond - | ^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^ 21 | #: E712 22 | if (True) == TrueElement or x == TrueElement: | - = help: Replace with `cond` +help: Replace with `cond` ℹ Unsafe fix 17 17 | if res[1] != False: @@ -145,16 +152,17 @@ E712.py:20:12: E712 [*] Avoid equality comparisons to `True`; use `cond:` for tr 22 22 | if (True) == TrueElement or x == TrueElement: 23 23 | pass -E712.py:20:36: E712 [*] Avoid equality comparisons to `False`; use `not cond:` for false checks +E712 [*] Avoid equality comparisons to `False`; use `not cond:` for false checks + --> E712.py:20:36 | 18 | pass 19 | #: E712 20 | var = 1 if cond == True else -1 if cond == False else cond - | ^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^ 21 | #: E712 22 | if (True) == TrueElement or x == TrueElement: | - = help: Replace with `not cond` +help: Replace with `not cond` ℹ Unsafe fix 17 17 | if res[1] != False: @@ -166,15 +174,16 @@ E712.py:20:36: E712 [*] Avoid equality comparisons to `False`; use `not cond:` f 22 22 | if (True) == TrueElement or x == TrueElement: 23 23 | pass -E712.py:22:4: E712 [*] Avoid equality comparisons to `True`; use `TrueElement:` for truth checks +E712 [*] Avoid equality comparisons to `True`; use `TrueElement:` for truth checks + --> E712.py:22:4 | 20 | var = 1 if cond == True else -1 if cond == False else cond 21 | #: E712 22 | if (True) == TrueElement or x == TrueElement: - | ^^^^^^^^^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Replace with `TrueElement` +help: Replace with `TrueElement` ℹ Unsafe fix 19 19 | #: E712 @@ -186,15 +195,16 @@ E712.py:22:4: E712 [*] Avoid equality comparisons to `True`; use `TrueElement:` 24 24 | 25 25 | if res == True != False: -E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` +E712 [*] Avoid equality comparisons to `True` or `False` + --> E712.py:25:4 | 23 | pass 24 | 25 | if res == True != False: - | ^^^^^^^^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^^^^^^^^ 26 | pass | - = help: Replace comparison +help: Replace comparison ℹ Unsafe fix 22 22 | if (True) == TrueElement or x == TrueElement: @@ -206,15 +216,16 @@ E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` 27 27 | 28 28 | if(True) == TrueElement or x == TrueElement: -E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` +E712 [*] Avoid equality comparisons to `True` or `False` + --> E712.py:25:4 | 23 | pass 24 | 25 | if res == True != False: - | ^^^^^^^^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^^^^^^^^ 26 | pass | - = help: Replace comparison +help: Replace comparison ℹ Unsafe fix 22 22 | if (True) == TrueElement or x == TrueElement: @@ -226,15 +237,16 @@ E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False` 27 27 | 28 28 | if(True) == TrueElement or x == TrueElement: -E712.py:28:3: E712 [*] Avoid equality comparisons to `True`; use `TrueElement:` for truth checks +E712 [*] Avoid equality comparisons to `True`; use `TrueElement:` for truth checks + --> E712.py:28:3 | 26 | pass 27 | 28 | if(True) == TrueElement or x == TrueElement: - | ^^^^^^^^^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^^^^^^^^^ 29 | pass | - = help: Replace with `TrueElement` +help: Replace with `TrueElement` ℹ Unsafe fix 25 25 | if res == True != False: @@ -246,15 +258,16 @@ E712.py:28:3: E712 [*] Avoid equality comparisons to `True`; use `TrueElement:` 30 30 | 31 31 | if (yield i) == True: -E712.py:31:4: E712 [*] Avoid equality comparisons to `True`; use `yield i:` for truth checks +E712 [*] Avoid equality comparisons to `True`; use `yield i:` for truth checks + --> E712.py:31:4 | 29 | pass 30 | 31 | if (yield i) == True: - | ^^^^^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^^^^^ 32 | print("even") | - = help: Replace with `yield i` +help: Replace with `yield i` ℹ Unsafe fix 28 28 | if(True) == TrueElement or x == TrueElement: @@ -266,14 +279,15 @@ E712.py:31:4: E712 [*] Avoid equality comparisons to `True`; use `yield i:` for 33 33 | 34 34 | #: Okay -E712.py:58:4: E712 [*] Avoid equality comparisons to `True`; use `True:` for truth checks +E712 [*] Avoid equality comparisons to `True`; use `True:` for truth checks + --> E712.py:58:4 | 57 | # https://github.com/astral-sh/ruff/issues/17582 58 | if True == True: # No duplicated diagnostic - | ^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^ 59 | pass | - = help: Replace with `True` +help: Replace with `True` ℹ Unsafe fix 55 55 | assert [42, not foo] in bar diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap index 845fa441d9..a41a7572d6 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E713.py:2:8: E713 [*] Test for membership should be `not in` +E713 [*] Test for membership should be `not in` + --> E713.py:2:8 | 1 | #: E713 2 | if not X in Y: - | ^^^^^^ E713 + | ^^^^^^ 3 | pass 4 | #: E713 | - = help: Convert to `not in` +help: Convert to `not in` ℹ Safe fix 1 1 | #: E713 @@ -20,16 +20,17 @@ E713.py:2:8: E713 [*] Test for membership should be `not in` 4 4 | #: E713 5 5 | if not X.B in Y: -E713.py:5:8: E713 [*] Test for membership should be `not in` +E713 [*] Test for membership should be `not in` + --> E713.py:5:8 | 3 | pass 4 | #: E713 5 | if not X.B in Y: - | ^^^^^^^^ E713 + | ^^^^^^^^ 6 | pass 7 | #: E713 | - = help: Convert to `not in` +help: Convert to `not in` ℹ Safe fix 2 2 | if not X in Y: @@ -41,16 +42,17 @@ E713.py:5:8: E713 [*] Test for membership should be `not in` 7 7 | #: E713 8 8 | if not X in Y and Z == "zero": -E713.py:8:8: E713 [*] Test for membership should be `not in` +E713 [*] Test for membership should be `not in` + --> E713.py:8:8 | 6 | pass 7 | #: E713 8 | if not X in Y and Z == "zero": - | ^^^^^^ E713 + | ^^^^^^ 9 | pass 10 | #: E713 | - = help: Convert to `not in` +help: Convert to `not in` ℹ Safe fix 5 5 | if not X.B in Y: @@ -62,16 +64,17 @@ E713.py:8:8: E713 [*] Test for membership should be `not in` 10 10 | #: E713 11 11 | if X == "zero" or not Y in Z: -E713.py:11:23: E713 [*] Test for membership should be `not in` +E713 [*] Test for membership should be `not in` + --> E713.py:11:23 | 9 | pass 10 | #: E713 11 | if X == "zero" or not Y in Z: - | ^^^^^^ E713 + | ^^^^^^ 12 | pass 13 | #: E713 | - = help: Convert to `not in` +help: Convert to `not in` ℹ Safe fix 8 8 | if not X in Y and Z == "zero": @@ -83,15 +86,16 @@ E713.py:11:23: E713 [*] Test for membership should be `not in` 13 13 | #: E713 14 14 | if not (X in Y): -E713.py:14:9: E713 [*] Test for membership should be `not in` +E713 [*] Test for membership should be `not in` + --> E713.py:14:9 | 12 | pass 13 | #: E713 14 | if not (X in Y): - | ^^^^^^ E713 + | ^^^^^^ 15 | pass | - = help: Convert to `not in` +help: Convert to `not in` ℹ Safe fix 11 11 | if X == "zero" or not Y in Z: @@ -103,14 +107,15 @@ E713.py:14:9: E713 [*] Test for membership should be `not in` 16 16 | 17 17 | #: Okay -E713.py:40:12: E713 [*] Test for membership should be `not in` +E713 [*] Test for membership should be `not in` + --> E713.py:40:12 | 38 | assert [42, not foo] in bar 39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) 40 | assert not('name' in request)or not request['name'] - | ^^^^^^^^^^^^^^^^^ E713 + | ^^^^^^^^^^^^^^^^^ | - = help: Convert to `not in` +help: Convert to `not in` ℹ Safe fix 37 37 | assert {"x": not foo} in bar diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap index 8b5df02535..3b9bfc27f3 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E714.py:2:8: E714 [*] Test for object identity should be `is not` +E714 [*] Test for object identity should be `is not` + --> E714.py:2:8 | 1 | #: E714 2 | if not X is Y: - | ^^^^^^ E714 + | ^^^^^^ 3 | pass 4 | #: E714 | - = help: Convert to `is not` +help: Convert to `is not` ℹ Safe fix 1 1 | #: E714 @@ -20,15 +20,16 @@ E714.py:2:8: E714 [*] Test for object identity should be `is not` 4 4 | #: E714 5 5 | if not X.B is Y: -E714.py:5:8: E714 [*] Test for object identity should be `is not` +E714 [*] Test for object identity should be `is not` + --> E714.py:5:8 | 3 | pass 4 | #: E714 5 | if not X.B is Y: - | ^^^^^^^^ E714 + | ^^^^^^^^ 6 | pass | - = help: Convert to `is not` +help: Convert to `is not` ℹ Safe fix 2 2 | if not X is Y: @@ -40,14 +41,15 @@ E714.py:5:8: E714 [*] Test for object identity should be `is not` 7 7 | 8 8 | #: Okay -E714.py:39:13: E714 [*] Test for object identity should be `is not` +E714 [*] Test for object identity should be `is not` + --> E714.py:39:13 | 37 | assert {"x": not foo} in bar 38 | assert [42, not foo] in bar 39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to `is not` +help: Convert to `is not` ℹ Safe fix 36 36 | assert (not foo) in bar diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap index 0e257342a9..a41e91b05f 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap @@ -1,158 +1,174 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E721.py:2:4: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:2:4 | 1 | #: E721 2 | if type(res) == type(42): - | ^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^ 3 | pass 4 | #: E721 | -E721.py:5:4: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:5:4 | 3 | pass 4 | #: E721 5 | if type(res) != type(""): - | ^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | pass 7 | #: E721 | -E721.py:8:4: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:8:4 | 6 | pass 7 | #: E721 8 | if type(res) == memoryview: - | ^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^ 9 | pass 10 | #: Okay | -E721.py:21:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:21:8 | 19 | pass 20 | #: E721 21 | assert type(res) == type(False) or type(res) == type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 22 | #: E721 23 | assert type(res) == type([]) | -E721.py:21:36: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:21:36 | 19 | pass 20 | #: E721 21 | assert type(res) == type(False) or type(res) == type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^ 22 | #: E721 23 | assert type(res) == type([]) | -E721.py:23:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:23:8 | 21 | assert type(res) == type(False) or type(res) == type(None) 22 | #: E721 23 | assert type(res) == type([]) - | ^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^ 24 | #: E721 25 | assert type(res) == type(()) | -E721.py:25:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:25:8 | 23 | assert type(res) == type([]) 24 | #: E721 25 | assert type(res) == type(()) - | ^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^ 26 | #: E721 27 | assert type(res) == type((0,)) | -E721.py:27:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:27:8 | 25 | assert type(res) == type(()) 26 | #: E721 27 | assert type(res) == type((0,)) - | ^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^ 28 | #: E721 29 | assert type(res) == type((0)) | -E721.py:29:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:29:8 | 27 | assert type(res) == type((0,)) 28 | #: E721 29 | assert type(res) == type((0)) - | ^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^ 30 | #: E721 31 | assert type(res) != type((1, )) | -E721.py:31:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:31:8 | 29 | assert type(res) == type((0)) 30 | #: E721 31 | assert type(res) != type((1, )) - | ^^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 32 | #: Okay 33 | assert type(res) is type((1, )) | -E721.py:37:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:37:8 | 35 | assert type(res) is not type((1, )) 36 | #: E211 E721 37 | assert type(res) == type ([2, ]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | #: E201 E201 E202 E721 39 | assert type(res) == type( ( ) ) | -E721.py:39:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:39:8 | 37 | assert type(res) == type ([2, ]) 38 | #: E201 E201 E202 E721 39 | assert type(res) == type( ( ) ) - | ^^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 40 | #: E201 E202 E721 41 | assert type(res) == type( (0, ) ) | -E721.py:41:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:41:8 | 39 | assert type(res) == type( ( ) ) 40 | #: E201 E202 E721 41 | assert type(res) == type( (0, ) ) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | #: | -E721.py:59:4: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:59:4 | 57 | pass 58 | #: E721 59 | if type(res) == type: - | ^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^ 60 | pass 61 | #: Okay | -E721.py:140:1: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:140:1 | 139 | #: E721 140 | dtype == float - | ^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^ 141 | 142 | import builtins | -E721.py:144:4: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks +E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks + --> E721.py:144:4 | 142 | import builtins 143 | 144 | if builtins.type(res) == memoryview: # E721 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 145 | pass | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E722_E722.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E722_E722.py.snap index 48d10268e4..b52dcc588e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E722_E722.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E722_E722.py.snap @@ -1,33 +1,35 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E722.py:4:1: E722 Do not use bare `except` +E722 Do not use bare `except` + --> E722.py:4:1 | 2 | try: 3 | pass 4 | except: - | ^^^^^^ E722 + | ^^^^^^ 5 | pass 6 | #: E722 | -E722.py:11:1: E722 Do not use bare `except` +E722 Do not use bare `except` + --> E722.py:11:1 | 9 | except Exception: 10 | pass 11 | except: - | ^^^^^^ E722 + | ^^^^^^ 12 | pass 13 | #: E722 | -E722.py:16:1: E722 Do not use bare `except` +E722 Do not use bare `except` + --> E722.py:16:1 | 14 | try: 15 | pass 16 | except: - | ^^^^^^ E722 + | ^^^^^^ 17 | pass 18 | #: Okay | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap index d80f8fca96..9b7e9c54c8 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E731.py:3:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:3:5 | 1 | def scope(): 2 | # E731 3 | f = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 1 1 | def scope(): @@ -20,14 +21,15 @@ E731.py:3:5: E731 [*] Do not assign a `lambda` expression, use a `def` 5 6 | 6 7 | def scope(): -E731.py:8:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:8:5 | 6 | def scope(): 7 | # E731 8 | f = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 5 5 | @@ -40,14 +42,15 @@ E731.py:8:5: E731 [*] Do not assign a `lambda` expression, use a `def` 10 11 | 11 12 | def scope(): -E731.py:14:9: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:14:9 | 12 | # E731 13 | while False: 14 | this = lambda y, z: 2 * x - | ^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `this` as a `def` +help: Rewrite `this` as a `def` ℹ Unsafe fix 11 11 | def scope(): @@ -60,14 +63,15 @@ E731.py:14:9: E731 [*] Do not assign a `lambda` expression, use a `def` 16 17 | 17 18 | def scope(): -E731.py:19:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:19:5 | 17 | def scope(): 18 | # E731 19 | f = lambda: (yield 1) - | ^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 16 16 | @@ -80,14 +84,15 @@ E731.py:19:5: E731 [*] Do not assign a `lambda` expression, use a `def` 21 22 | 22 23 | def scope(): -E731.py:24:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:24:5 | 22 | def scope(): 23 | # E731 24 | f = lambda: (yield from g()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 21 21 | @@ -100,14 +105,15 @@ E731.py:24:5: E731 [*] Do not assign a `lambda` expression, use a `def` 26 27 | 27 28 | def scope(): -E731.py:57:5: E731 Do not assign a `lambda` expression, use a `def` +E731 Do not assign a `lambda` expression, use a `def` + --> E731.py:57:5 | 55 | class Scope: 56 | # E731 57 | f = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Display-only fix 54 54 | @@ -120,16 +126,17 @@ E731.py:57:5: E731 Do not assign a `lambda` expression, use a `def` 59 60 | 60 61 | class Scope: -E731.py:73:9: E731 Do not assign a `lambda` expression, use a `def` +E731 Do not assign a `lambda` expression, use a `def` + --> E731.py:73:9 | 71 | x: Callable[[int], int] 72 | if True: 73 | x = lambda: 1 - | ^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^ 74 | else: 75 | x = lambda: 2 | - = help: Rewrite `x` as a `def` +help: Rewrite `x` as a `def` ℹ Display-only fix 70 70 | @@ -142,15 +149,16 @@ E731.py:73:9: E731 Do not assign a `lambda` expression, use a `def` 75 76 | x = lambda: 2 76 77 | return x -E731.py:75:9: E731 Do not assign a `lambda` expression, use a `def` +E731 Do not assign a `lambda` expression, use a `def` + --> E731.py:75:9 | 73 | x = lambda: 1 74 | else: 75 | x = lambda: 2 - | ^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^ 76 | return x | - = help: Rewrite `x` as a `def` +help: Rewrite `x` as a `def` ℹ Display-only fix 72 72 | if True: @@ -163,14 +171,15 @@ E731.py:75:9: E731 Do not assign a `lambda` expression, use a `def` 77 78 | 78 79 | -E731.py:86:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:86:5 | 84 | # ParamSpec cannot be used in this context, so do not preserve the annotation. 85 | P = ParamSpec("P") 86 | f: Callable[P, int] = lambda *args: len(args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 83 83 | @@ -183,14 +192,15 @@ E731.py:86:5: E731 [*] Do not assign a `lambda` expression, use a `def` 88 89 | 89 90 | def scope(): -E731.py:94:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:94:5 | 92 | from typing import Callable 93 | 94 | f: Callable[[], None] = lambda: None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 91 91 | @@ -203,14 +213,15 @@ E731.py:94:5: E731 [*] Do not assign a `lambda` expression, use a `def` 96 97 | 97 98 | def scope(): -E731.py:102:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:102:5 | 100 | from typing import Callable 101 | 102 | f: Callable[..., None] = lambda a, b: None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 99 99 | @@ -223,14 +234,15 @@ E731.py:102:5: E731 [*] Do not assign a `lambda` expression, use a `def` 104 105 | 105 106 | def scope(): -E731.py:110:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:110:5 | 108 | from typing import Callable 109 | 110 | f: Callable[[int], int] = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 107 107 | @@ -243,14 +255,15 @@ E731.py:110:5: E731 [*] Do not assign a `lambda` expression, use a `def` 112 113 | 113 114 | # Let's use the `Callable` type from `collections.abc` instead. -E731.py:119:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:119:5 | 117 | from collections.abc import Callable 118 | 119 | f: Callable[[str, int], str] = lambda a, b: a * b - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 116 116 | @@ -263,14 +276,15 @@ E731.py:119:5: E731 [*] Do not assign a `lambda` expression, use a `def` 121 122 | 122 123 | def scope(): -E731.py:127:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:127:5 | 125 | from collections.abc import Callable 126 | 127 | f: Callable[[str, int], tuple[str, int]] = lambda a, b: (a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 124 124 | @@ -283,14 +297,15 @@ E731.py:127:5: E731 [*] Do not assign a `lambda` expression, use a `def` 129 130 | 130 131 | def scope(): -E731.py:135:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:135:5 | 133 | from collections.abc import Callable 134 | 135 | f: Callable[[str, int, list[str]], list[str]] = lambda a, b, /, c: [*c, a * b] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 132 132 | @@ -303,14 +318,15 @@ E731.py:135:5: E731 [*] Do not assign a `lambda` expression, use a `def` 137 138 | 138 139 | class TemperatureScales(Enum): -E731.py:139:5: E731 Do not assign a `lambda` expression, use a `def` +E731 Do not assign a `lambda` expression, use a `def` + --> E731.py:139:5 | 138 | class TemperatureScales(Enum): 139 | CELSIUS = (lambda deg_c: deg_c) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 140 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) | - = help: Rewrite `CELSIUS` as a `def` +help: Rewrite `CELSIUS` as a `def` ℹ Display-only fix 136 136 | @@ -323,14 +339,15 @@ E731.py:139:5: E731 Do not assign a `lambda` expression, use a `def` 141 142 | 142 143 | -E731.py:140:5: E731 Do not assign a `lambda` expression, use a `def` +E731 Do not assign a `lambda` expression, use a `def` + --> E731.py:140:5 | 138 | class TemperatureScales(Enum): 139 | CELSIUS = (lambda deg_c: deg_c) 140 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Rewrite `FAHRENHEIT` as a `def` +help: Rewrite `FAHRENHEIT` as a `def` ℹ Display-only fix 137 137 | @@ -343,16 +360,17 @@ E731.py:140:5: E731 Do not assign a `lambda` expression, use a `def` 142 143 | 143 144 | # Regression test for: https://github.com/astral-sh/ruff/issues/7141 -E731.py:147:5: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:147:5 | 145 | # E731 146 | 147 | / f = lambda: ( 148 | | i := 1, 149 | | ) - | |_____^ E731 + | |_____^ | - = help: Rewrite `f` as a `def` +help: Rewrite `f` as a `def` ℹ Unsafe fix 144 144 | def scope(): @@ -369,7 +387,8 @@ E731.py:147:5: E731 [*] Do not assign a `lambda` expression, use a `def` 151 152 | 152 153 | from dataclasses import dataclass -E731.py:163:1: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:163:1 | 161 | # Regression tests for: 162 | # * https://github.com/astral-sh/ruff/issues/7720 @@ -377,11 +396,11 @@ E731.py:163:1: E731 [*] Do not assign a `lambda` expression, use a `def` 164 | | a 165 | | b 166 | | """ - | |___^ E731 + | |___^ 167 | 168 | # * https://github.com/astral-sh/ruff/issues/10277 | - = help: Rewrite `x` as a `def` +help: Rewrite `x` as a `def` ℹ Unsafe fix 160 160 | @@ -394,15 +413,16 @@ E731.py:163:1: E731 [*] Do not assign a `lambda` expression, use a `def` 165 166 | b 166 167 | """ -E731.py:169:1: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:169:1 | 168 | # * https://github.com/astral-sh/ruff/issues/10277 169 | at_least_one_million = lambda _: _ >= 1_000_000 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 170 | 171 | x = lambda: ( | - = help: Rewrite `at_least_one_million` as a `def` +help: Rewrite `at_least_one_million` as a `def` ℹ Unsafe fix 166 166 | """ @@ -415,7 +435,8 @@ E731.py:169:1: E731 [*] Do not assign a `lambda` expression, use a `def` 171 172 | x = lambda: ( 172 173 | # comment -E731.py:171:1: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:171:1 | 169 | at_least_one_million = lambda _: _ >= 1_000_000 170 | @@ -423,11 +444,11 @@ E731.py:171:1: E731 [*] Do not assign a `lambda` expression, use a `def` 172 | | # comment 173 | | 5 + 10 174 | | ) - | |_^ E731 + | |_^ 175 | 176 | x = lambda: ( | - = help: Rewrite `x` as a `def` +help: Rewrite `x` as a `def` ℹ Unsafe fix 168 168 | # * https://github.com/astral-sh/ruff/issues/10277 @@ -440,7 +461,8 @@ E731.py:171:1: E731 [*] Do not assign a `lambda` expression, use a `def` 173 174 | 5 + 10 174 175 | ) -E731.py:176:1: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:176:1 | 174 | ) 175 | @@ -448,11 +470,11 @@ E731.py:176:1: E731 [*] Do not assign a `lambda` expression, use a `def` 177 | | # comment 178 | | y := 10 179 | | ) - | |_^ E731 + | |_^ 180 | 181 | # https://github.com/astral-sh/ruff/issues/18475 | - = help: Rewrite `x` as a `def` +help: Rewrite `x` as a `def` ℹ Unsafe fix 173 173 | 5 + 10 @@ -465,7 +487,8 @@ E731.py:176:1: E731 [*] Do not assign a `lambda` expression, use a `def` 178 179 | y := 10 179 180 | ) -E731.py:182:1: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:182:1 | 181 | # https://github.com/astral-sh/ruff/issues/18475 182 | / foo_tooltip = ( @@ -473,11 +496,11 @@ E731.py:182:1: E731 [*] Do not assign a `lambda` expression, use a `def` 184 | | if data["foo"] is not None 185 | | else "" 186 | | ) - | |_^ E731 + | |_^ 187 | 188 | foo_tooltip = ( | - = help: Rewrite `foo_tooltip` as a `def` +help: Rewrite `foo_tooltip` as a `def` ℹ Unsafe fix 179 179 | ) @@ -495,7 +518,8 @@ E731.py:182:1: E731 [*] Do not assign a `lambda` expression, use a `def` 188 187 | foo_tooltip = ( 189 188 | lambda x, data: f"\nfoo: {data['foo'][int(x)]}" + -E731.py:188:1: E731 [*] Do not assign a `lambda` expression, use a `def` +E731 [*] Do not assign a `lambda` expression, use a `def` + --> E731.py:188:1 | 186 | ) 187 | @@ -504,9 +528,9 @@ E731.py:188:1: E731 [*] Do not assign a `lambda` expression, use a `def` 190 | | more 191 | | 192 | | ) - | |_^ E731 + | |_^ | - = help: Rewrite `foo_tooltip` as a `def` +help: Rewrite `foo_tooltip` as a `def` ℹ Unsafe fix 185 185 | else "" diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap index 75db1277a6..70e66d2aec 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap @@ -1,211 +1,236 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E741.py:3:1: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:3:1 | 1 | from contextlib import contextmanager 2 | 3 | l = 0 - | ^ E741 + | ^ 4 | I = 0 5 | O = 0 | -E741.py:4:1: E741 Ambiguous variable name: `I` +E741 Ambiguous variable name: `I` + --> E741.py:4:1 | 3 | l = 0 4 | I = 0 - | ^ E741 + | ^ 5 | O = 0 6 | l: int = 0 | -E741.py:5:1: E741 Ambiguous variable name: `O` +E741 Ambiguous variable name: `O` + --> E741.py:5:1 | 3 | l = 0 4 | I = 0 5 | O = 0 - | ^ E741 + | ^ 6 | l: int = 0 | -E741.py:6:1: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:6:1 | 4 | I = 0 5 | O = 0 6 | l: int = 0 - | ^ E741 + | ^ 7 | 8 | a, l = 0, 1 | -E741.py:8:4: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:8:4 | 6 | l: int = 0 7 | 8 | a, l = 0, 1 - | ^ E741 + | ^ 9 | [a, l] = 0, 1 10 | a, *l = 0, 1, 2 | -E741.py:9:5: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:9:5 | 8 | a, l = 0, 1 9 | [a, l] = 0, 1 - | ^ E741 + | ^ 10 | a, *l = 0, 1, 2 11 | a = l = 0 | -E741.py:10:5: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:10:5 | 8 | a, l = 0, 1 9 | [a, l] = 0, 1 10 | a, *l = 0, 1, 2 - | ^ E741 + | ^ 11 | a = l = 0 | -E741.py:11:5: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:11:5 | 9 | [a, l] = 0, 1 10 | a, *l = 0, 1, 2 11 | a = l = 0 - | ^ E741 + | ^ 12 | 13 | o = 0 | -E741.py:16:5: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:16:5 | 14 | i = 0 15 | 16 | for l in range(3): - | ^ E741 + | ^ 17 | pass | -E741.py:20:8: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:20:8 | 20 | for a, l in zip(range(3), range(3)): - | ^ E741 + | ^ 21 | pass | -E741.py:25:12: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:25:12 | 24 | def f1(): 25 | global l - | ^ E741 + | ^ 26 | l = 0 | -E741.py:26:5: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:26:5 | 24 | def f1(): 25 | global l 26 | l = 0 - | ^ E741 + | ^ | -E741.py:30:5: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:30:5 | 29 | def f2(): 30 | l = 0 - | ^ E741 + | ^ 31 | 32 | def f3(): | -E741.py:33:18: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:33:18 | 32 | def f3(): 33 | nonlocal l - | ^ E741 + | ^ 34 | l = 1 | -E741.py:34:9: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:34:9 | 32 | def f3(): 33 | nonlocal l 34 | l = 1 - | ^ E741 + | ^ 35 | 36 | f3() | -E741.py:40:8: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:40:8 | 40 | def f4(l, /, I): - | ^ E741 + | ^ 41 | return l, I, O | -E741.py:40:14: E741 Ambiguous variable name: `I` +E741 Ambiguous variable name: `I` + --> E741.py:40:14 | 40 | def f4(l, /, I): - | ^ E741 + | ^ 41 | return l, I, O | -E741.py:44:8: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:44:8 | 44 | def f5(l=0, *, I=1): - | ^ E741 + | ^ 45 | return l, I | -E741.py:44:16: E741 Ambiguous variable name: `I` +E741 Ambiguous variable name: `I` + --> E741.py:44:16 | 44 | def f5(l=0, *, I=1): - | ^ E741 + | ^ 45 | return l, I | -E741.py:48:9: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:48:9 | 48 | def f6(*l, **I): - | ^ E741 + | ^ 49 | return l, I | -E741.py:48:14: E741 Ambiguous variable name: `I` +E741 Ambiguous variable name: `I` + --> E741.py:48:14 | 48 | def f6(*l, **I): - | ^ E741 + | ^ 49 | return l, I | -E741.py:57:16: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:57:16 | 57 | with ctx1() as l: - | ^ E741 + | ^ 58 | pass | -E741.py:66:20: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:66:20 | 66 | with ctx2() as (a, l): - | ^ E741 + | ^ 67 | pass | -E741.py:71:22: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:71:22 | 69 | try: 70 | pass 71 | except ValueError as l: - | ^ E741 + | ^ 72 | pass | -E741.py:74:5: E741 Ambiguous variable name: `l` +E741 Ambiguous variable name: `l` + --> E741.py:74:5 | 72 | pass 73 | 74 | if (l := 5) > 0: - | ^ E741 + | ^ 75 | pass | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E742_E742.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E742_E742.py.snap index abfdba447e..533d909a31 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E742_E742.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E742_E742.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E742.py:1:7: E742 Ambiguous class name: `l` +E742 Ambiguous class name: `l` + --> E742.py:1:7 | 1 | class l: - | ^ E742 + | ^ 2 | pass | -E742.py:5:7: E742 Ambiguous class name: `I` +E742 Ambiguous class name: `I` + --> E742.py:5:7 | 5 | class I: - | ^ E742 + | ^ 6 | pass | -E742.py:9:7: E742 Ambiguous class name: `O` +E742 Ambiguous class name: `O` + --> E742.py:9:7 | 9 | class O: - | ^ E742 + | ^ 10 | pass | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E743_E743.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E743_E743.py.snap index 0a80ad2cf8..702bbfa215 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E743_E743.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E743_E743.py.snap @@ -1,25 +1,27 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E743.py:1:5: E743 Ambiguous function name: `l` +E743 Ambiguous function name: `l` + --> E743.py:1:5 | 1 | def l(): - | ^ E743 + | ^ 2 | pass | -E743.py:5:5: E743 Ambiguous function name: `I` +E743 Ambiguous function name: `I` + --> E743.py:5:5 | 5 | def I(): - | ^ E743 + | ^ 6 | pass | -E743.py:10:9: E743 Ambiguous function name: `O` +E743 Ambiguous function name: `O` + --> E743.py:10:9 | 9 | class X: 10 | def O(self): - | ^ E743 + | ^ 11 | pass | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W191_W19.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W191_W19.py.snap index b1fce5b6a5..8d88eef99b 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W191_W19.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W191_W19.py.snap @@ -1,21 +1,24 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W19.py:1:1: W191 Indentation contains tabs - | -1 | '''File starts with a tab - | ^^^^ W191 -2 | multiline string with tab in it''' - | - -W19.py:1:1: invalid-syntax: Unexpected indentation +W191 Indentation contains tabs + --> W19.py:1:1 | 1 | '''File starts with a tab | ^^^^ 2 | multiline string with tab in it''' | -W19.py:5:1: invalid-syntax: Expected a statement +invalid-syntax: Unexpected indentation + --> W19.py:1:1 + | +1 | '''File starts with a tab + | ^^^^ +2 | multiline string with tab in it''' + | + +invalid-syntax: Expected a statement + --> W19.py:5:1 | 4 | #: W191 5 | if False: @@ -24,359 +27,396 @@ W19.py:5:1: invalid-syntax: Expected a statement 7 | #: | -W19.py:6:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:6:1 | 4 | #: W191 5 | if False: 6 | print # indented with 1 tab - | ^^^^ W191 + | ^^^^ 7 | #: | -W19.py:12:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:12:1 | 10 | #: W191 11 | y = x == 2 \ 12 | or x == 3 - | ^^^^ W191 + | ^^^^ 13 | #: E101 W191 W504 14 | if ( | -W19.py:19:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:19:1 | 17 | ) or 18 | y == 4): 19 | pass - | ^^^^ W191 + | ^^^^ 20 | #: E101 W191 21 | if x == 2 \ | -W19.py:24:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:24:1 | 22 | or y > 1 \ 23 | or x == 3: 24 | pass - | ^^^^ W191 + | ^^^^ 25 | #: E101 W191 26 | if x == 2 \ | -W19.py:29:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:29:1 | 27 | or y > 1 \ 28 | or x == 3: 29 | pass - | ^^^^ W191 + | ^^^^ 30 | #: | -W19.py:35:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:35:1 | 33 | if (foo == bar and 34 | baz == bop): 35 | pass - | ^^^^ W191 + | ^^^^ 36 | #: E101 W191 W504 37 | if ( | -W19.py:41:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:41:1 | 39 | baz == bop 40 | ): 41 | pass - | ^^^^ W191 + | ^^^^ 42 | #: | -W19.py:47:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:47:1 | 45 | if start[1] > end_col and not ( 46 | over_indent == 4 and indent_next): 47 | return (0, "E121 continuation line over-" - | ^^^^ W191 + | ^^^^ 48 | "indented for visual indent") 49 | #: | -W19.py:48:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:48:1 | 46 | over_indent == 4 and indent_next): 47 | return (0, "E121 continuation line over-" 48 | "indented for visual indent") - | ^^^^^^^^^^^^ W191 + | ^^^^^^^^^^^^ 49 | #: | -W19.py:57:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:57:1 | 55 | var_one, var_two, var_three, 56 | var_four): 57 | print(var_one) - | ^^^^ W191 + | ^^^^ 58 | #: E101 W191 W504 59 | if ((row < 0 or self.moduleCount <= row or | -W19.py:61:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:61:1 | 59 | if ((row < 0 or self.moduleCount <= row or 60 | col < 0 or self.moduleCount <= col)): 61 | raise Exception("%s,%s - %s" % (row, col, self.moduleCount)) - | ^^^^ W191 + | ^^^^ 62 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191 63 | if bar: | -W19.py:64:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:64:1 | 62 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191 63 | if bar: 64 | return ( - | ^^^^ W191 + | ^^^^ 65 | start, 'E121 lines starting with a ' 66 | 'closing bracket should be indented ' | -W19.py:65:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:65:1 | 63 | if bar: 64 | return ( 65 | start, 'E121 lines starting with a ' - | ^^^^^^^^ W191 + | ^^^^^^^^ 66 | 'closing bracket should be indented ' 67 | "to match that of the opening " | -W19.py:66:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:66:1 | 64 | return ( 65 | start, 'E121 lines starting with a ' 66 | 'closing bracket should be indented ' - | ^^^^^^^^ W191 + | ^^^^^^^^ 67 | "to match that of the opening " 68 | "bracket's line" | -W19.py:67:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:67:1 | 65 | start, 'E121 lines starting with a ' 66 | 'closing bracket should be indented ' 67 | "to match that of the opening " - | ^^^^^^^^ W191 + | ^^^^^^^^ 68 | "bracket's line" 69 | ) | -W19.py:68:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:68:1 | 66 | 'closing bracket should be indented ' 67 | "to match that of the opening " 68 | "bracket's line" - | ^^^^^^^^ W191 + | ^^^^^^^^ 69 | ) 70 | # | -W19.py:69:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:69:1 | 67 | "to match that of the opening " 68 | "bracket's line" 69 | ) - | ^^^^ W191 + | ^^^^ 70 | # 71 | #: E101 W191 W504 | -W19.py:76:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:76:1 | 74 | foo.bar("bop") 75 | )): 76 | print("yes") - | ^^^^ W191 + | ^^^^ 77 | #: E101 W191 W504 78 | # also ok, but starting to look like LISP | -W19.py:81:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:81:1 | 79 | if ((foo.bar("baz") and 80 | foo.bar("bop"))): 81 | print("yes") - | ^^^^ W191 + | ^^^^ 82 | #: E101 W191 W504 83 | if (a == 2 or | -W19.py:86:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:86:1 | 84 | b == "abc def ghi" 85 | "jkl mno"): 86 | return True - | ^^^^ W191 + | ^^^^ 87 | #: E101 W191 W504 88 | if (a == 2 or | -W19.py:91:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:91:1 | 89 | b == """abc def ghi 90 | jkl mno"""): 91 | return True - | ^^^^ W191 + | ^^^^ 92 | #: W191:2:1 W191:3:1 E101:3:2 93 | if length > options.max_line_length: | -W19.py:94:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:94:1 | 92 | #: W191:2:1 W191:3:1 E101:3:2 93 | if length > options.max_line_length: 94 | return options.max_line_length, \ - | ^^^^ W191 + | ^^^^ 95 | "E501 line too long (%d characters)" % length | -W19.py:95:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:95:1 | 93 | if length > options.max_line_length: 94 | return options.max_line_length, \ 95 | "E501 line too long (%d characters)" % length - | ^^^^^^^^ W191 + | ^^^^^^^^ | -W19.py:101:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:101:1 | 99 | #: E101 W191 W191 W504 100 | if os.path.exists(os.path.join(path, PEP8_BIN)): 101 | cmd = ([os.path.join(path, PEP8_BIN)] + - | ^^^^ W191 + | ^^^^ 102 | self._pep8_options(targetfile)) 103 | #: W191 - okay | -W19.py:102:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:102:1 | 100 | if os.path.exists(os.path.join(path, PEP8_BIN)): 101 | cmd = ([os.path.join(path, PEP8_BIN)] + 102 | self._pep8_options(targetfile)) - | ^^^^^^^^^^^ W191 + | ^^^^^^^^^^^ 103 | #: W191 - okay 104 | ''' | -W19.py:128:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:128:1 | 126 | if foo is None and bar is "bop" and \ 127 | blah == 'yeah': 128 | blah = 'yeahnah' - | ^^^^ W191 + | ^^^^ | -W19.py:134:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:134:1 | 132 | #: W191 W191 W191 133 | if True: 134 | foo( - | ^^^^ W191 + | ^^^^ 135 | 1, 136 | 2) | -W19.py:135:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:135:1 | 133 | if True: 134 | foo( 135 | 1, - | ^^^^^^^^ W191 + | ^^^^^^^^ 136 | 2) 137 | #: W191 W191 W191 W191 W191 | -W19.py:136:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:136:1 | 134 | foo( 135 | 1, 136 | 2) - | ^^^^^^^^ W191 + | ^^^^^^^^ 137 | #: W191 W191 W191 W191 W191 138 | def test_keys(self): | -W19.py:139:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:139:1 | 137 | #: W191 W191 W191 W191 W191 138 | def test_keys(self): 139 | """areas.json - All regions are accounted for.""" - | ^^^^ W191 + | ^^^^ 140 | expected = set([ 141 | u'Norrbotten', | -W19.py:140:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:140:1 | 138 | def test_keys(self): 139 | """areas.json - All regions are accounted for.""" 140 | expected = set([ - | ^^^^ W191 + | ^^^^ 141 | u'Norrbotten', 142 | u'V\xe4sterbotten', | -W19.py:141:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:141:1 | 139 | """areas.json - All regions are accounted for.""" 140 | expected = set([ 141 | u'Norrbotten', - | ^^^^^^^^ W191 + | ^^^^^^^^ 142 | u'V\xe4sterbotten', 143 | ]) | -W19.py:142:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:142:1 | 140 | expected = set([ 141 | u'Norrbotten', 142 | u'V\xe4sterbotten', - | ^^^^^^^^ W191 + | ^^^^^^^^ 143 | ]) 144 | #: W191 | -W19.py:143:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:143:1 | 141 | u'Norrbotten', 142 | u'V\xe4sterbotten', 143 | ]) - | ^^^^ W191 + | ^^^^ 144 | #: W191 145 | x = [ | -W19.py:146:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:146:1 | 144 | #: W191 145 | x = [ 146 | 'abc' - | ^^^^ W191 + | ^^^^ 147 | ] 148 | #: W191 - okay | -W19.py:157:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:157:1 | 156 | f"test{ 157 | tab_indented_should_be_flagged - | ^^^^ W191 + | ^^^^ 158 | } <- this tab is fine" | -W19.py:161:1: W191 Indentation contains tabs +W191 Indentation contains tabs + --> W19.py:161:1 | 160 | f"""test{ 161 | tab_indented_should_be_flagged - | ^^^^ W191 + | ^^^^ 162 | } <- this tab is fine""" | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap index caf6753099..837470c93c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -W29.py:4:6: W291 [*] Trailing whitespace +W291 [*] Trailing whitespace + --> W29.py:4:6 | 2 | # 情 3 | #: W291:1:6 4 | print - | ^ W291 + | ^ 5 | #: W293:2:1 6 | class Foo(object): | - = help: Remove trailing whitespace +help: Remove trailing whitespace ℹ Safe fix 1 1 | #: Okay @@ -23,16 +23,17 @@ W29.py:4:6: W291 [*] Trailing whitespace 6 6 | class Foo(object): 7 7 | -W29.py:11:35: W291 [*] Trailing whitespace +W291 [*] Trailing whitespace + --> W29.py:11:35 | 9 | #: W291:2:35 10 | '''multiline 11 | string with trailing whitespace''' - | ^^^ W291 + | ^^^ 12 | #: W291 W292 noeol 13 | x = 1 | - = help: Remove trailing whitespace +help: Remove trailing whitespace ℹ Safe fix 8 8 | bang = 12 @@ -44,16 +45,17 @@ W29.py:11:35: W291 [*] Trailing whitespace 13 13 | x = 1 14 14 | #: W191 W292 noeol -W29.py:13:6: W291 [*] Trailing whitespace +W291 [*] Trailing whitespace + --> W29.py:13:6 | 11 | string with trailing whitespace''' 12 | #: W291 W292 noeol 13 | x = 1 - | ^^^ W291 + | ^^^ 14 | #: W191 W292 noeol 15 | if False: | - = help: Remove trailing whitespace +help: Remove trailing whitespace ℹ Safe fix 10 10 | '''multiline diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap index 0f59c043ac..a349223f9c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W291.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W291.py:1:23: W291 [*] Trailing whitespace +W291 [*] Trailing whitespace + --> W291.py:1:23 | 1 | '''trailing whitespace - | ^ W291 + | ^ 2 | inside a multiline string''' | - = help: Remove trailing whitespace +help: Remove trailing whitespace ℹ Unsafe fix 1 |-'''trailing whitespace @@ -16,15 +17,16 @@ W291.py:1:23: W291 [*] Trailing whitespace 3 3 | 4 4 | f'''trailing whitespace -W291.py:4:24: W291 [*] Trailing whitespace +W291 [*] Trailing whitespace + --> W291.py:4:24 | 2 | inside a multiline string''' 3 | 4 | f'''trailing whitespace - | ^ W291 + | ^ 5 | inside a multiline f-string''' | - = help: Remove trailing whitespace +help: Remove trailing whitespace ℹ Unsafe fix 1 1 | '''trailing whitespace @@ -36,15 +38,16 @@ W291.py:4:24: W291 [*] Trailing whitespace 6 6 | 7 7 | # Trailing whitespace after `{` -W291.py:8:8: W291 [*] Trailing whitespace +W291 [*] Trailing whitespace + --> W291.py:8:8 | 7 | # Trailing whitespace after `{` 8 | f'abc { - | ^ W291 + | ^ 9 | 1 + 2 10 | }' | - = help: Remove trailing whitespace +help: Remove trailing whitespace ℹ Safe fix 5 5 | inside a multiline f-string''' @@ -56,15 +59,16 @@ W291.py:8:8: W291 [*] Trailing whitespace 10 10 | }' 11 11 | -W291.py:14:10: W291 [*] Trailing whitespace +W291 [*] Trailing whitespace + --> W291.py:14:10 | 12 | # Trailing whitespace after `2` 13 | f'abc { 14 | 1 + 2 - | ^ W291 + | ^ 15 | }' | - = help: Remove trailing whitespace +help: Remove trailing whitespace ℹ Safe fix 11 11 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap index 93800dbe5b..404fb9c25e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W292_0.py:2:9: W292 [*] No newline at end of file +W292 [*] No newline at end of file + --> W292_0.py:2:9 | 1 | def fn() -> None: 2 | pass - | ^ W292 + | ^ | - = help: Add trailing newline +help: Add trailing newline ℹ Safe fix 1 1 | def fn() -> None: diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap index 4818cd126b..03b3a090bc 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -W29.py:7:1: W293 [*] Blank line contains whitespace +W293 [*] Blank line contains whitespace + --> W29.py:7:1 | 5 | #: W293:2:1 6 | class Foo(object): 7 | - | ^^^^ W293 + | ^^^^ 8 | bang = 12 9 | #: W291:2:35 | - = help: Remove whitespace from blank line +help: Remove whitespace from blank line ℹ Safe fix 4 4 | print diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W293.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W293.py.snap index f94b873549..7fc13aa2f1 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W293.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W293.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -W293.py:4:1: W293 [*] Blank line contains whitespace +W293 [*] Blank line contains whitespace + --> W293.py:4:1 | 2 | class Chassis(RobotModuleTemplate): 3 | """底盘信息推送控制 4 | - | ^^^^ W293 + | ^^^^ 5 | """\ | - = help: Remove whitespace from blank line +help: Remove whitespace from blank line ℹ Unsafe fix 1 1 | # See: https://github.com/astral-sh/ruff/issues/9323 @@ -22,14 +22,15 @@ W293.py:4:1: W293 [*] Blank line contains whitespace 6 6 | 7 7 | -W293.py:10:1: W293 [*] Blank line contains whitespace +W293 [*] Blank line contains whitespace + --> W293.py:10:1 | 8 | """""" \ 9 | \ 10 | - | ^^^^ W293 + | ^^^^ | - = help: Remove whitespace from blank line +help: Remove whitespace from blank line ℹ Safe fix 5 5 | """\ @@ -43,15 +44,16 @@ W293.py:10:1: W293 [*] Blank line contains whitespace 12 10 | 13 11 | "abc\ -W293.py:16:1: W293 [*] Blank line contains whitespace +W293 [*] Blank line contains whitespace + --> W293.py:16:1 | 14 | " \ 15 | \ 16 | - | ^^^^ W293 + | ^^^^ 17 | '''blank line with whitespace | - = help: Remove whitespace from blank line +help: Remove whitespace from blank line ℹ Safe fix 11 11 | @@ -65,14 +67,15 @@ W293.py:16:1: W293 [*] Blank line contains whitespace 18 16 | 19 17 | inside a multiline string''' -W293.py:18:1: W293 [*] Blank line contains whitespace +W293 [*] Blank line contains whitespace + --> W293.py:18:1 | 17 | '''blank line with whitespace 18 | - | ^ W293 + | ^ 19 | inside a multiline string''' | - = help: Remove whitespace from blank line +help: Remove whitespace from blank line ℹ Unsafe fix 15 15 | \ diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap index 8da92669c3..6b64fdb629 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W605_0.py:2:10: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_0.py:2:10 | 1 | #: W605:1:10 2 | regex = '\.png$' - | ^^ W605 + | ^^ 3 | 4 | #: W605:2:1 | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 1 1 | #: W605:1:10 @@ -19,15 +20,16 @@ W605_0.py:2:10: W605 [*] Invalid escape sequence: `\.` 4 4 | #: W605:2:1 5 5 | regex = ''' -W605_0.py:6:1: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_0.py:6:1 | 4 | #: W605:2:1 5 | regex = ''' 6 | \.png$ - | ^^ W605 + | ^^ 7 | ''' | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 2 2 | regex = '\.png$' @@ -39,15 +41,16 @@ W605_0.py:6:1: W605 [*] Invalid escape sequence: `\.` 7 7 | ''' 8 8 | -W605_0.py:11:6: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_0.py:11:6 | 9 | #: W605:2:6 10 | f( 11 | '\_' - | ^^ W605 + | ^^ 12 | ) | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 8 8 | @@ -59,16 +62,17 @@ W605_0.py:11:6: W605 [*] Invalid escape sequence: `\_` 13 13 | 14 14 | #: W605:4:6 -W605_0.py:18:6: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_0.py:18:6 | 16 | multi-line 17 | literal 18 | with \_ somewhere - | ^^ W605 + | ^^ 19 | in the middle 20 | """ | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 12 12 | ) @@ -80,13 +84,14 @@ W605_0.py:18:6: W605 [*] Invalid escape sequence: `\_` 17 17 | literal 18 18 | with \_ somewhere -W605_0.py:23:39: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_0.py:23:39 | 22 | #: W605:1:38 23 | value = 'new line\nand invalid escape \_ here' - | ^^ W605 + | ^^ | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 20 20 | """ @@ -98,16 +103,17 @@ W605_0.py:23:39: W605 [*] Invalid escape sequence: `\_` 25 25 | 26 26 | def f(): -W605_0.py:28:12: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_0.py:28:12 | 26 | def f(): 27 | #: W605:1:11 28 | return'\.png$' - | ^^ W605 + | ^^ 29 | 30 | #: Okay | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 25 25 | @@ -119,16 +125,17 @@ W605_0.py:28:12: W605 [*] Invalid escape sequence: `\.` 30 30 | #: Okay 31 31 | regex = r'\.png$' -W605_0.py:45:12: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_0.py:45:12 | 43 | ''' # noqa 44 | 45 | regex = '\\\_' - | ^^ W605 + | ^^ 46 | 47 | #: W605:1:7 | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 42 42 | \w @@ -140,15 +147,16 @@ W605_0.py:45:12: W605 [*] Invalid escape sequence: `\_` 47 47 | #: W605:1:7 48 48 | u'foo\ bar' -W605_0.py:48:6: W605 [*] Invalid escape sequence: `\ ` +W605 [*] Invalid escape sequence: `\ ` + --> W605_0.py:48:6 | 47 | #: W605:1:7 48 | u'foo\ bar' - | ^^ W605 + | ^^ 49 | 50 | #: W605:1:13 | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 45 45 | regex = '\\\_' @@ -160,15 +168,16 @@ W605_0.py:48:6: W605 [*] Invalid escape sequence: `\ ` 50 50 | #: W605:1:13 51 51 | ( -W605_0.py:53:9: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_0.py:53:9 | 51 | ( 52 | "foo \ 53 | bar \. baz" - | ^^ W605 + | ^^ 54 | ) | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 50 50 | #: W605:1:13 @@ -180,15 +189,16 @@ W605_0.py:53:9: W605 [*] Invalid escape sequence: `\.` 55 55 | 56 56 | #: W605:1:6 -W605_0.py:57:6: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_0.py:57:6 | 56 | #: W605:1:6 57 | "foo \. bar \t" - | ^^ W605 + | ^^ 58 | 59 | #: W605:1:13 | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 54 54 | ) @@ -200,13 +210,14 @@ W605_0.py:57:6: W605 [*] Invalid escape sequence: `\.` 59 59 | #: W605:1:13 60 60 | "foo \t bar \." -W605_0.py:60:13: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_0.py:60:13 | 59 | #: W605:1:13 60 | "foo \t bar \." - | ^^ W605 + | ^^ | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 57 57 | "foo \. bar \t" diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap index 4ca58ba4ec..efee7333ef 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W605_1.py:4:11: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_1.py:4:11 | 3 | #: W605:1:10 4 | regex = f'\.png$' - | ^^ W605 + | ^^ 5 | 6 | #: W605:2:1 | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 1 1 | # Same as `W605_0.py` but using f-strings and t-strings instead. @@ -21,15 +22,16 @@ W605_1.py:4:11: W605 [*] Invalid escape sequence: `\.` 6 6 | #: W605:2:1 7 7 | regex = f''' -W605_1.py:8:1: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_1.py:8:1 | 6 | #: W605:2:1 7 | regex = f''' 8 | \.png$ - | ^^ W605 + | ^^ 9 | ''' | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 4 4 | regex = f'\.png$' @@ -41,15 +43,16 @@ W605_1.py:8:1: W605 [*] Invalid escape sequence: `\.` 9 9 | ''' 10 10 | -W605_1.py:13:7: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_1.py:13:7 | 11 | #: W605:2:6 12 | f( 13 | f'\_' - | ^^ W605 + | ^^ 14 | ) | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 10 10 | @@ -61,16 +64,17 @@ W605_1.py:13:7: W605 [*] Invalid escape sequence: `\_` 15 15 | 16 16 | #: W605:4:6 -W605_1.py:20:6: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_1.py:20:6 | 18 | multi-line 19 | literal 20 | with \_ somewhere - | ^^ W605 + | ^^ 21 | in the middle 22 | """ | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 14 14 | ) @@ -82,13 +86,14 @@ W605_1.py:20:6: W605 [*] Invalid escape sequence: `\_` 19 19 | literal 20 20 | with \_ somewhere -W605_1.py:25:40: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_1.py:25:40 | 24 | #: W605:1:38 25 | value = f'new line\nand invalid escape \_ here' - | ^^ W605 + | ^^ | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 22 22 | """ @@ -100,16 +105,17 @@ W605_1.py:25:40: W605 [*] Invalid escape sequence: `\_` 27 27 | 28 28 | #: Okay -W605_1.py:43:13: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_1.py:43:13 | 41 | ''' # noqa 42 | 43 | regex = f'\\\_' - | ^^ W605 + | ^^ 44 | value = f'\{{1}}' 45 | value = f'\{1}' | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 40 40 | \w @@ -121,15 +127,16 @@ W605_1.py:43:13: W605 [*] Invalid escape sequence: `\_` 45 45 | value = f'\{1}' 46 46 | value = f'{1:\}' -W605_1.py:44:11: W605 [*] Invalid escape sequence: `\{` +W605 [*] Invalid escape sequence: `\{` + --> W605_1.py:44:11 | 43 | regex = f'\\\_' 44 | value = f'\{{1}}' - | ^^ W605 + | ^^ 45 | value = f'\{1}' 46 | value = f'{1:\}' | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 41 41 | ''' # noqa @@ -141,16 +148,17 @@ W605_1.py:44:11: W605 [*] Invalid escape sequence: `\{` 46 46 | value = f'{1:\}' 47 47 | value = f"{f"\{1}"}" -W605_1.py:45:11: W605 [*] Invalid escape sequence: `\{` +W605 [*] Invalid escape sequence: `\{` + --> W605_1.py:45:11 | 43 | regex = f'\\\_' 44 | value = f'\{{1}}' 45 | value = f'\{1}' - | ^^ W605 + | ^^ 46 | value = f'{1:\}' 47 | value = f"{f"\{1}"}" | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 42 42 | @@ -162,16 +170,17 @@ W605_1.py:45:11: W605 [*] Invalid escape sequence: `\{` 47 47 | value = f"{f"\{1}"}" 48 48 | value = rf"{f"\{1}"}" -W605_1.py:46:14: W605 [*] Invalid escape sequence: `\}` +W605 [*] Invalid escape sequence: `\}` + --> W605_1.py:46:14 | 44 | value = f'\{{1}}' 45 | value = f'\{1}' 46 | value = f'{1:\}' - | ^^ W605 + | ^^ 47 | value = f"{f"\{1}"}" 48 | value = rf"{f"\{1}"}" | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 43 43 | regex = f'\\\_' @@ -183,15 +192,16 @@ W605_1.py:46:14: W605 [*] Invalid escape sequence: `\}` 48 48 | value = rf"{f"\{1}"}" 49 49 | -W605_1.py:47:14: W605 [*] Invalid escape sequence: `\{` +W605 [*] Invalid escape sequence: `\{` + --> W605_1.py:47:14 | 45 | value = f'\{1}' 46 | value = f'{1:\}' 47 | value = f"{f"\{1}"}" - | ^^ W605 + | ^^ 48 | value = rf"{f"\{1}"}" | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 44 44 | value = f'\{{1}}' @@ -203,16 +213,17 @@ W605_1.py:47:14: W605 [*] Invalid escape sequence: `\{` 49 49 | 50 50 | # Okay -W605_1.py:48:15: W605 [*] Invalid escape sequence: `\{` +W605 [*] Invalid escape sequence: `\{` + --> W605_1.py:48:15 | 46 | value = f'{1:\}' 47 | value = f"{f"\{1}"}" 48 | value = rf"{f"\{1}"}" - | ^^ W605 + | ^^ 49 | 50 | # Okay | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 45 45 | value = f'\{1}' @@ -224,15 +235,16 @@ W605_1.py:48:15: W605 [*] Invalid escape sequence: `\{` 50 50 | # Okay 51 51 | value = rf'\{{1}}' -W605_1.py:57:9: W605 [*] Invalid escape sequence: `\d` +W605 [*] Invalid escape sequence: `\d` + --> W605_1.py:57:9 | 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 57 | f"{{}}+-\d" - | ^^ W605 + | ^^ 58 | f"\n{{}}+-\d+" 59 | f"\n{{}}�+-\d+" | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 54 54 | value = f"{rf"\{1}"}" @@ -244,15 +256,16 @@ W605_1.py:57:9: W605 [*] Invalid escape sequence: `\d` 59 59 | f"\n{{}}�+-\d+" 60 60 | -W605_1.py:58:11: W605 [*] Invalid escape sequence: `\d` +W605 [*] Invalid escape sequence: `\d` + --> W605_1.py:58:11 | 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 57 | f"{{}}+-\d" 58 | f"\n{{}}+-\d+" - | ^^ W605 + | ^^ 59 | f"\n{{}}�+-\d+" | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 55 55 | @@ -264,16 +277,17 @@ W605_1.py:58:11: W605 [*] Invalid escape sequence: `\d` 60 60 | 61 61 | # See https://github.com/astral-sh/ruff/issues/11491 -W605_1.py:59:12: W605 [*] Invalid escape sequence: `\d` +W605 [*] Invalid escape sequence: `\d` + --> W605_1.py:59:12 | 57 | f"{{}}+-\d" 58 | f"\n{{}}+-\d+" 59 | f"\n{{}}�+-\d+" - | ^^ W605 + | ^^ 60 | 61 | # See https://github.com/astral-sh/ruff/issues/11491 | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 56 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 @@ -285,16 +299,17 @@ W605_1.py:59:12: W605 [*] Invalid escape sequence: `\d` 61 61 | # See https://github.com/astral-sh/ruff/issues/11491 62 62 | total = 10 -W605_1.py:65:31: W605 [*] Invalid escape sequence: `\I` +W605 [*] Invalid escape sequence: `\I` + --> W605_1.py:65:31 | 63 | ok = 7 64 | incomplete = 3 65 | s = f"TOTAL: {total}\nOK: {ok}\INCOMPLETE: {incomplete}\n" - | ^^ W605 + | ^^ 66 | 67 | # Debug text (should trigger) | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 62 62 | total = 10 @@ -306,13 +321,14 @@ W605_1.py:65:31: W605 [*] Invalid escape sequence: `\I` 67 67 | # Debug text (should trigger) 68 68 | t = f"{'\InHere'=}" -W605_1.py:68:9: W605 [*] Invalid escape sequence: `\I` +W605 [*] Invalid escape sequence: `\I` + --> W605_1.py:68:9 | 67 | # Debug text (should trigger) 68 | t = f"{'\InHere'=}" - | ^^ W605 + | ^^ | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 65 65 | s = f"TOTAL: {total}\nOK: {ok}\INCOMPLETE: {incomplete}\n" @@ -324,15 +340,16 @@ W605_1.py:68:9: W605 [*] Invalid escape sequence: `\I` 70 70 | 71 71 | -W605_1.py:73:11: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_1.py:73:11 | 72 | #: W605:1:10 73 | regex = t'\.png$' - | ^^ W605 + | ^^ 74 | 75 | #: W605:2:1 | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 70 70 | @@ -344,15 +361,16 @@ W605_1.py:73:11: W605 [*] Invalid escape sequence: `\.` 75 75 | #: W605:2:1 76 76 | regex = t''' -W605_1.py:77:1: W605 [*] Invalid escape sequence: `\.` +W605 [*] Invalid escape sequence: `\.` + --> W605_1.py:77:1 | 75 | #: W605:2:1 76 | regex = t''' 77 | \.png$ - | ^^ W605 + | ^^ 78 | ''' | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 73 73 | regex = t'\.png$' @@ -364,15 +382,16 @@ W605_1.py:77:1: W605 [*] Invalid escape sequence: `\.` 78 78 | ''' 79 79 | -W605_1.py:82:7: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_1.py:82:7 | 80 | #: W605:2:6 81 | f( 82 | t'\_' - | ^^ W605 + | ^^ 83 | ) | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 79 79 | @@ -384,16 +403,17 @@ W605_1.py:82:7: W605 [*] Invalid escape sequence: `\_` 84 84 | 85 85 | #: W605:4:6 -W605_1.py:89:6: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_1.py:89:6 | 87 | multi-line 88 | literal 89 | with \_ somewhere - | ^^ W605 + | ^^ 90 | in the middle 91 | """ | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 83 83 | ) @@ -405,13 +425,14 @@ W605_1.py:89:6: W605 [*] Invalid escape sequence: `\_` 88 88 | literal 89 89 | with \_ somewhere -W605_1.py:94:40: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_1.py:94:40 | 93 | #: W605:1:38 94 | value = t'new line\nand invalid escape \_ here' - | ^^ W605 + | ^^ | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 91 91 | """ @@ -423,15 +444,16 @@ W605_1.py:94:40: W605 [*] Invalid escape sequence: `\_` 96 96 | 97 97 | #: Okay -W605_1.py:109:1: W605 [*] Invalid escape sequence: `\w` +W605 [*] Invalid escape sequence: `\w` + --> W605_1.py:109:1 | 107 | regex = t'\w' # noqa 108 | regex = t''' 109 | \w - | ^^ W605 + | ^^ 110 | ''' # noqa | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 105 105 | ''' @@ -443,16 +465,17 @@ W605_1.py:109:1: W605 [*] Invalid escape sequence: `\w` 110 110 | ''' # noqa 111 111 | -W605_1.py:112:13: W605 [*] Invalid escape sequence: `\_` +W605 [*] Invalid escape sequence: `\_` + --> W605_1.py:112:13 | 110 | ''' # noqa 111 | 112 | regex = t'\\\_' - | ^^ W605 + | ^^ 113 | value = t'\{{1}}' 114 | value = t'\{1}' | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 109 109 | \w @@ -464,15 +487,16 @@ W605_1.py:112:13: W605 [*] Invalid escape sequence: `\_` 114 114 | value = t'\{1}' 115 115 | value = t'{1:\}' -W605_1.py:113:11: W605 [*] Invalid escape sequence: `\{` +W605 [*] Invalid escape sequence: `\{` + --> W605_1.py:113:11 | 112 | regex = t'\\\_' 113 | value = t'\{{1}}' - | ^^ W605 + | ^^ 114 | value = t'\{1}' 115 | value = t'{1:\}' | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 110 110 | ''' # noqa @@ -484,16 +508,17 @@ W605_1.py:113:11: W605 [*] Invalid escape sequence: `\{` 115 115 | value = t'{1:\}' 116 116 | value = t"{t"\{1}"}" -W605_1.py:114:11: W605 [*] Invalid escape sequence: `\{` +W605 [*] Invalid escape sequence: `\{` + --> W605_1.py:114:11 | 112 | regex = t'\\\_' 113 | value = t'\{{1}}' 114 | value = t'\{1}' - | ^^ W605 + | ^^ 115 | value = t'{1:\}' 116 | value = t"{t"\{1}"}" | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 111 111 | @@ -505,16 +530,17 @@ W605_1.py:114:11: W605 [*] Invalid escape sequence: `\{` 116 116 | value = t"{t"\{1}"}" 117 117 | value = rt"{t"\{1}"}" -W605_1.py:115:14: W605 [*] Invalid escape sequence: `\}` +W605 [*] Invalid escape sequence: `\}` + --> W605_1.py:115:14 | 113 | value = t'\{{1}}' 114 | value = t'\{1}' 115 | value = t'{1:\}' - | ^^ W605 + | ^^ 116 | value = t"{t"\{1}"}" 117 | value = rt"{t"\{1}"}" | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 112 112 | regex = t'\\\_' @@ -526,15 +552,16 @@ W605_1.py:115:14: W605 [*] Invalid escape sequence: `\}` 117 117 | value = rt"{t"\{1}"}" 118 118 | -W605_1.py:116:14: W605 [*] Invalid escape sequence: `\{` +W605 [*] Invalid escape sequence: `\{` + --> W605_1.py:116:14 | 114 | value = t'\{1}' 115 | value = t'{1:\}' 116 | value = t"{t"\{1}"}" - | ^^ W605 + | ^^ 117 | value = rt"{t"\{1}"}" | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 113 113 | value = t'\{{1}}' @@ -546,16 +573,17 @@ W605_1.py:116:14: W605 [*] Invalid escape sequence: `\{` 118 118 | 119 119 | # Okay -W605_1.py:117:15: W605 [*] Invalid escape sequence: `\{` +W605 [*] Invalid escape sequence: `\{` + --> W605_1.py:117:15 | 115 | value = t'{1:\}' 116 | value = t"{t"\{1}"}" 117 | value = rt"{t"\{1}"}" - | ^^ W605 + | ^^ 118 | 119 | # Okay | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 114 114 | value = t'\{1}' @@ -567,15 +595,16 @@ W605_1.py:117:15: W605 [*] Invalid escape sequence: `\{` 119 119 | # Okay 120 120 | value = rt'\{{1}}' -W605_1.py:126:9: W605 [*] Invalid escape sequence: `\d` +W605 [*] Invalid escape sequence: `\d` + --> W605_1.py:126:9 | 125 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 126 | t"{{}}+-\d" - | ^^ W605 + | ^^ 127 | t"\n{{}}+-\d+" 128 | t"\n{{}}�+-\d+" | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 123 123 | value = t"{rt"\{1}"}" @@ -587,15 +616,16 @@ W605_1.py:126:9: W605 [*] Invalid escape sequence: `\d` 128 128 | t"\n{{}}�+-\d+" 129 129 | -W605_1.py:127:11: W605 [*] Invalid escape sequence: `\d` +W605 [*] Invalid escape sequence: `\d` + --> W605_1.py:127:11 | 125 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 126 | t"{{}}+-\d" 127 | t"\n{{}}+-\d+" - | ^^ W605 + | ^^ 128 | t"\n{{}}�+-\d+" | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 124 124 | @@ -607,16 +637,17 @@ W605_1.py:127:11: W605 [*] Invalid escape sequence: `\d` 129 129 | 130 130 | # See https://github.com/astral-sh/ruff/issues/11491 -W605_1.py:128:12: W605 [*] Invalid escape sequence: `\d` +W605 [*] Invalid escape sequence: `\d` + --> W605_1.py:128:12 | 126 | t"{{}}+-\d" 127 | t"\n{{}}+-\d+" 128 | t"\n{{}}�+-\d+" - | ^^ W605 + | ^^ 129 | 130 | # See https://github.com/astral-sh/ruff/issues/11491 | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 125 125 | # Regression tests for https://github.com/astral-sh/ruff/issues/10434 @@ -628,16 +659,17 @@ W605_1.py:128:12: W605 [*] Invalid escape sequence: `\d` 130 130 | # See https://github.com/astral-sh/ruff/issues/11491 131 131 | total = 10 -W605_1.py:134:31: W605 [*] Invalid escape sequence: `\I` +W605 [*] Invalid escape sequence: `\I` + --> W605_1.py:134:31 | 132 | ok = 7 133 | incomplete = 3 134 | s = t"TOTAL: {total}\nOK: {ok}\INCOMPLETE: {incomplete}\n" - | ^^ W605 + | ^^ 135 | 136 | # Debug text (should trigger) | - = help: Add backslash to escape sequence +help: Add backslash to escape sequence ℹ Safe fix 131 131 | total = 10 @@ -649,13 +681,14 @@ W605_1.py:134:31: W605 [*] Invalid escape sequence: `\I` 136 136 | # Debug text (should trigger) 137 137 | t = t"{'\InHere'=}" -W605_1.py:137:9: W605 [*] Invalid escape sequence: `\I` +W605 [*] Invalid escape sequence: `\I` + --> W605_1.py:137:9 | 136 | # Debug text (should trigger) 137 | t = t"{'\InHere'=}" - | ^^ W605 + | ^^ | - = help: Use a raw string literal +help: Use a raw string literal ℹ Safe fix 134 134 | s = t"TOTAL: {total}\nOK: {ok}\INCOMPLETE: {incomplete}\n" diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_notebook.snap index b8baafb5cd..e7db6cbc5d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E301_notebook.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E30.ipynb:13:5: E301 [*] Expected 1 blank line, found 0 +E301 [*] Expected 1 blank line, found 0 + --> E30.ipynb:13:5 | 11 | def method(cls) -> None: 12 | pass 13 | @classmethod - | ^ E301 + | ^ 14 | def cls_method(cls) -> None: 15 | pass | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 10 10 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap index 3a2fa4505d..8a5cfb44fb 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E302_notebook.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.ipynb:21:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30.ipynb:21:1 | 19 | pass 20 | 21 | def b(): - | ^^^ E302 + | ^^^ 22 | pass 23 | # end | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 18 18 | def a(): diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap index 2ccc9b5a56..977af3e324 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_notebook.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.ipynb:29:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.ipynb:29:5 | 29 | # arbitrary comment - | ^^^^^^^^^^^^^^^^^^^ E303 + | ^^^^^^^^^^^^^^^^^^^ 30 | 31 | def inner(): # E306 not expected (pycodestyle detects E306) | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 25 25 | def fn(): @@ -19,14 +20,15 @@ E30.ipynb:29:5: E303 [*] Too many blank lines (2) 30 29 | 31 30 | def inner(): # E306 not expected (pycodestyle detects E306) -E30.ipynb:39:1: E303 [*] Too many blank lines (4) +E303 [*] Too many blank lines (4) + --> E30.ipynb:39:1 | 39 | def fn(): - | ^^^ E303 + | ^^^ 40 | pass 41 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 34 34 | # E303 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.snap index b302d784da..c8f3e76104 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E303_typing_stub.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E30.pyi:17:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.pyi:17:1 | 17 | def grouped1(): ... - | ^^^ E303 + | ^^^ 18 | def grouped2(): ... 19 | def grouped3( ): ... | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 13 13 | @overload @@ -20,14 +20,15 @@ E30.pyi:17:1: E303 [*] Too many blank lines (2) 18 17 | def grouped2(): ... 19 18 | def grouped3( ): ... -E30.pyi:22:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.pyi:22:1 | 22 | class BackendProxy: - | ^^^^^ E303 + | ^^^^^ 23 | backend_module: str 24 | backend_object: str | None | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 18 18 | def grouped2(): ... @@ -38,13 +39,14 @@ E30.pyi:22:1: E303 [*] Too many blank lines (2) 23 22 | backend_module: str 24 23 | backend_object: str | None -E30.pyi:35:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.pyi:35:5 | 35 | def ungrouped(): ... - | ^^^ E303 + | ^^^ 36 | a = "test" | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 31 31 | @@ -55,14 +57,15 @@ E30.pyi:35:5: E303 [*] Too many blank lines (2) 36 35 | a = "test" 37 36 | -E30.pyi:43:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30.pyi:43:1 | 43 | def outer(): - | ^^^ E303 + | ^^^ 44 | def inner(): 45 | pass | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 39 39 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap index 39fbc5b80f..3d9f4f8434 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_notebook.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30.ipynb:45:1: E304 [*] Blank lines found after function decorator (1) +E304 [*] Blank lines found after function decorator (1) + --> E30.ipynb:45:1 | 43 | @decorator 44 | 45 | def function(): - | ^^^ E304 + | ^^^ 46 | pass 47 | # end | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 41 41 | # end diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_typing_stub.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_typing_stub.snap index 49ab3a3246..5b83ab47b2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_typing_stub.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E304_typing_stub.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E30.pyi:32:5: E304 [*] Blank lines found after function decorator (1) +E304 [*] Blank lines found after function decorator (1) + --> E30.pyi:32:5 | 30 | @decorated 31 | 32 | def with_blank_line(): ... - | ^^^ E304 + | ^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 28 28 | def grouped2(): ... diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E305_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E305_notebook.snap index ef27833ff3..250640539c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E305_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E305_notebook.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E30.ipynb:55:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) +E305 [*] Expected 2 blank lines after class or function definition, found (1) + --> E30.ipynb:55:1 | 54 | # another comment 55 | fn() - | ^^ E305 + | ^^ 56 | # end 57 | # E306:3:5 | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 52 52 | # comment diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E306_notebook.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E306_notebook.snap index a5675e1a55..342b178c56 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E306_notebook.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_E306_notebook.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -E30.ipynb:60:5: E306 [*] Expected 1 blank line before a nested definition, found 0 +E306 [*] Expected 1 blank line before a nested definition, found 0 + --> E30.ipynb:60:5 | 58 | def a(): 59 | x = 1 60 | def b(): - | ^^^ E306 + | ^^^ 61 | pass 62 | # end | - = help: Add missing blank line +help: Add missing blank line ℹ Safe fix 57 57 | # E306:3:5 diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap index fa3511086f..8a04a07b58 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(-1)-between(0).snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import json @@ -21,16 +22,17 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted 6 3 | 7 4 | -E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:23:1 | 21 | abcd.foo() 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... - | ^^^ E302 + | ^^^ 24 | 25 | if TYPE_CHECKING: | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 20 20 | @@ -41,7 +43,8 @@ E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 24 25 | 25 26 | if TYPE_CHECKING: -E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -49,9 +52,9 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -63,15 +66,16 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:35:1 | 33 | abcd.foo() 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: - | ^^^ E302 + | ^^^ 36 | ... | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 32 32 | @@ -82,15 +86,16 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 36 37 | ... 37 38 | -E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:41:1 | 39 | from typing_extensions import TypeAlias 40 | 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: - | ^^^ E302 + | ^^^ 42 | ... | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 38 38 | if TYPE_CHECKING: @@ -101,14 +106,15 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 42 43 | ... 43 44 | -E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:60:1 | 60 | from typing import Any, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | - = help: Organize imports +help: Organize imports ℹ Safe fix 59 59 | @@ -117,14 +123,15 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted 62 |+ 62 63 | class MissingCommand(TypeError): ... # noqa: N818 -E30_isort.py:62:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:62:1 | 60 | from typing import Any, Sequence 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 - | ^^^^^ E302 + | ^^^^^ | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 59 59 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap index e66c54a48d..9c480c19a2 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(0)-between(0).snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import json @@ -24,16 +25,17 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted 9 4 | 10 5 | -E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:23:1 | 21 | abcd.foo() 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... - | ^^^ E302 + | ^^^ 24 | 25 | if TYPE_CHECKING: | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 20 20 | @@ -44,7 +46,8 @@ E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 24 25 | 25 26 | if TYPE_CHECKING: -E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -52,9 +55,9 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -66,15 +69,16 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:35:1 | 33 | abcd.foo() 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: - | ^^^ E302 + | ^^^ 36 | ... | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 32 32 | @@ -85,15 +89,16 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 36 37 | ... 37 38 | -E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:41:1 | 39 | from typing_extensions import TypeAlias 40 | 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: - | ^^^ E302 + | ^^^ 42 | ... | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 38 38 | if TYPE_CHECKING: @@ -104,14 +109,15 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 42 43 | ... 43 44 | -E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:60:1 | 60 | from typing import Any, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | - = help: Organize imports +help: Organize imports ℹ Safe fix 58 58 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap index 9434c2cc11..5c84b8e63e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(1)-between(1).snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import json @@ -23,16 +24,17 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted 8 5 | class MissingCommand(TypeError): ... # noqa: N818 9 6 | -E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:23:1 | 21 | abcd.foo() 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... - | ^^^ E302 + | ^^^ 24 | 25 | if TYPE_CHECKING: | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 20 20 | @@ -43,7 +45,8 @@ E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 24 25 | 25 26 | if TYPE_CHECKING: -E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -51,9 +54,9 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -65,15 +68,16 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:35:1 | 33 | abcd.foo() 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: - | ^^^ E302 + | ^^^ 36 | ... | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 32 32 | @@ -84,15 +88,16 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 36 37 | ... 37 38 | -E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:41:1 | 39 | from typing_extensions import TypeAlias 40 | 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: - | ^^^ E302 + | ^^^ 42 | ... | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 38 38 | if TYPE_CHECKING: diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap index 1c6425457e..b3900e15ed 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_top_level_isort_compatibility-lines-after(4)-between(4).snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | @@ -26,12 +27,13 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted 9 12 | 10 13 | -E30_isort.py:8:1: E302 [*] Expected 4 blank lines, found 2 +E302 [*] Expected 4 blank lines, found 2 + --> E30_isort.py:8:1 | 8 | class MissingCommand(TypeError): ... # noqa: N818 - | ^^^^^ E302 + | ^^^^^ | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 5 5 | from typing import Any, Sequence @@ -43,16 +45,17 @@ E30_isort.py:8:1: E302 [*] Expected 4 blank lines, found 2 9 11 | 10 12 | -E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:23:1 | 21 | abcd.foo() 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... - | ^^^ E302 + | ^^^ 24 | 25 | if TYPE_CHECKING: | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 20 20 | @@ -63,7 +66,8 @@ E30_isort.py:23:1: E302 [*] Expected 2 blank lines, found 1 24 25 | 25 26 | if TYPE_CHECKING: -E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -71,9 +75,9 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -85,15 +89,16 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:35:1 | 33 | abcd.foo() 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: - | ^^^ E302 + | ^^^ 36 | ... | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 32 32 | @@ -104,15 +109,16 @@ E30_isort.py:35:1: E302 [*] Expected 2 blank lines, found 1 36 37 | ... 37 38 | -E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 +E302 [*] Expected 2 blank lines, found 1 + --> E30_isort.py:41:1 | 39 | from typing_extensions import TypeAlias 40 | 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: - | ^^^ E302 + | ^^^ 42 | ... | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 38 38 | if TYPE_CHECKING: @@ -123,14 +129,15 @@ E30_isort.py:41:1: E302 [*] Expected 2 blank lines, found 1 42 43 | ... 43 44 | -E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:60:1 | 60 | from typing import Any, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | - = help: Organize imports +help: Organize imports ℹ Safe fix 59 59 | @@ -141,14 +148,15 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted 64 |+ 62 65 | class MissingCommand(TypeError): ... # noqa: N818 -E30_isort.py:62:1: E302 [*] Expected 4 blank lines, found 1 +E302 [*] Expected 4 blank lines, found 1 + --> E30_isort.py:62:1 | 60 | from typing import Any, Sequence 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 - | ^^^^^ E302 + | ^^^^^ | - = help: Add missing blank line(s) +help: Add missing blank line(s) ℹ Safe fix 59 59 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap index dc10a907bc..941e55ca08 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__blank_lines_typing_stub_isort.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.pyi:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import json @@ -23,12 +24,13 @@ E30_isort.pyi:1:1: I001 [*] Import block is un-sorted or un-formatted 8 4 | class MissingCommand(TypeError): ... # noqa: N818 9 5 | -E30_isort.pyi:5:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30_isort.pyi:5:1 | 5 | from typing import Any, Sequence - | ^^^^ E303 + | ^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 1 1 | import json @@ -39,12 +41,13 @@ E30_isort.pyi:5:1: E303 [*] Too many blank lines (3) 6 4 | 7 5 | -E30_isort.pyi:8:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:8:1 | 8 | class MissingCommand(TypeError): ... # noqa: N818 - | ^^^^^ E303 + | ^^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 4 4 | @@ -55,14 +58,15 @@ E30_isort.pyi:8:1: E303 [*] Too many blank lines (2) 9 8 | 10 9 | -E30_isort.pyi:11:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:11:1 | 11 | class BackendProxy: - | ^^^^^ E303 + | ^^^^^ 12 | backend_module: str 13 | backend_object: str | None | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 7 7 | @@ -73,13 +77,14 @@ E30_isort.pyi:11:1: E303 [*] Too many blank lines (2) 12 11 | backend_module: str 13 12 | backend_object: str | None -E30_isort.pyi:17:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:17:1 | 17 | if __name__ == "__main__": - | ^^ E303 + | ^^ 18 | import abcd | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 13 13 | backend_object: str | None @@ -90,14 +95,15 @@ E30_isort.pyi:17:1: E303 [*] Too many blank lines (2) 18 17 | import abcd 19 18 | -E30_isort.pyi:21:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:21:5 | 21 | abcd.foo() - | ^^^^ E303 + | ^^^^ 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 17 17 | if __name__ == "__main__": @@ -108,7 +114,8 @@ E30_isort.pyi:21:5: E303 [*] Too many blank lines (2) 22 21 | 23 22 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... -E30_isort.pyi:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.pyi:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -116,9 +123,9 @@ E30_isort.pyi:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -130,12 +137,13 @@ E30_isort.pyi:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.pyi:30:5: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30_isort.pyi:30:5 | 30 | from typing_extensions import TypeAlias - | ^^^^ E303 + | ^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -147,14 +155,15 @@ E30_isort.pyi:30:5: E303 [*] Too many blank lines (3) 31 29 | 32 30 | -E30_isort.pyi:33:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:33:5 | 33 | abcd.foo() - | ^^^^ E303 + | ^^^^ 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 29 29 | @@ -165,12 +174,13 @@ E30_isort.pyi:33:5: E303 [*] Too many blank lines (2) 34 33 | 35 34 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: -E30_isort.pyi:45:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:45:1 | 45 | def _exit(self) -> None: ... - | ^^^ E303 + | ^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 41 41 | def __call__2(self, name: str, *args: Any, **kwargs: Any) -> Any: @@ -181,12 +191,13 @@ E30_isort.pyi:45:1: E303 [*] Too many blank lines (2) 46 45 | 47 46 | -E30_isort.pyi:48:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:48:1 | 48 | def _optional_commands(self) -> dict[str, bool]: ... - | ^^^ E303 + | ^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 44 44 | @@ -197,12 +208,13 @@ E30_isort.pyi:48:1: E303 [*] Too many blank lines (2) 49 48 | 50 49 | -E30_isort.pyi:51:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:51:1 | 51 | def run(argv: Sequence[str]) -> int: ... - | ^^^ E303 + | ^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 47 47 | @@ -213,12 +225,13 @@ E30_isort.pyi:51:1: E303 [*] Too many blank lines (2) 52 51 | 53 52 | -E30_isort.pyi:54:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:54:1 | 54 | def read_line(fd: int = 0) -> bytearray: ... - | ^^^ E303 + | ^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 50 50 | @@ -229,12 +242,13 @@ E30_isort.pyi:54:1: E303 [*] Too many blank lines (2) 55 54 | 56 55 | -E30_isort.pyi:57:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:57:1 | 57 | def flush() -> None: ... - | ^^^ E303 + | ^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 53 53 | @@ -245,14 +259,15 @@ E30_isort.pyi:57:1: E303 [*] Too many blank lines (2) 58 57 | 59 58 | -E30_isort.pyi:60:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.pyi:60:1 | 60 | from typing import Any, Sequence - | ^^^^ E303 + | ^^^^ 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 56 56 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap index 89296988de..cbd129d821 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -constant_literals.py:4:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:4:4 | 2 | # Errors 3 | ### 4 | if "abc" is "def": # F632 (fix) - | ^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^ 5 | pass 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 1 1 | ### @@ -22,16 +23,17 @@ constant_literals.py:4:4: F632 [*] Use `==` to compare constant literals 6 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) 7 7 | pass -constant_literals.py:6:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:6:4 | 4 | if "abc" is "def": # F632 (fix) 5 | pass 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) - | ^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^ 7 | pass 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 3 3 | ### @@ -43,16 +45,17 @@ constant_literals.py:6:4: F632 [*] Use `==` to compare constant literals 8 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) 9 9 | pass -constant_literals.py:8:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:8:4 | 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) 7 | pass 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) - | ^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^ 9 | pass 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 5 5 | pass @@ -64,16 +67,17 @@ constant_literals.py:8:4: F632 [*] Use `==` to compare constant literals 10 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) 11 11 | pass -constant_literals.py:10:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:10:4 | 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) 9 | pass 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) - | ^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^ 11 | pass 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 7 7 | pass @@ -85,16 +89,17 @@ constant_literals.py:10:4: F632 [*] Use `==` to compare constant literals 12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) 13 13 | pass -constant_literals.py:12:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:12:4 | 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) 11 | pass 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) - | ^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^ 13 | pass 14 | if False == None: # E711, E712 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 9 9 | pass @@ -106,16 +111,17 @@ constant_literals.py:12:4: F632 [*] Use `==` to compare constant literals 14 14 | if False == None: # E711, E712 (fix) 15 15 | pass -constant_literals.py:14:4: E712 [*] Avoid equality comparisons to `False`; use `not None:` for false checks +E712 [*] Avoid equality comparisons to `False`; use `not None:` for false checks + --> constant_literals.py:14:4 | 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) 13 | pass 14 | if False == None: # E711, E712 (fix) - | ^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^ 15 | pass 16 | if None == False: # E711, E712 (fix) | - = help: Replace with `not None` +help: Replace with `not None` ℹ Unsafe fix 11 11 | pass @@ -127,16 +133,17 @@ constant_literals.py:14:4: E712 [*] Avoid equality comparisons to `False`; use ` 16 16 | if None == False: # E711, E712 (fix) 17 17 | pass -constant_literals.py:14:13: E711 [*] Comparison to `None` should be `cond is None` +E711 [*] Comparison to `None` should be `cond is None` + --> constant_literals.py:14:13 | 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) 13 | pass 14 | if False == None: # E711, E712 (fix) - | ^^^^ E711 + | ^^^^ 15 | pass 16 | if None == False: # E711, E712 (fix) | - = help: Replace with `cond is None` +help: Replace with `cond is None` ℹ Unsafe fix 11 11 | pass @@ -148,15 +155,16 @@ constant_literals.py:14:13: E711 [*] Comparison to `None` should be `cond is Non 16 16 | if None == False: # E711, E712 (fix) 17 17 | pass -constant_literals.py:16:4: E711 [*] Comparison to `None` should be `cond is None` +E711 [*] Comparison to `None` should be `cond is None` + --> constant_literals.py:16:4 | 14 | if False == None: # E711, E712 (fix) 15 | pass 16 | if None == False: # E711, E712 (fix) - | ^^^^ E711 + | ^^^^ 17 | pass | - = help: Replace with `cond is None` +help: Replace with `cond is None` ℹ Unsafe fix 13 13 | pass @@ -168,15 +176,16 @@ constant_literals.py:16:4: E711 [*] Comparison to `None` should be `cond is None 18 18 | 19 19 | named_var = [] -constant_literals.py:16:4: E712 [*] Avoid equality comparisons to `False`; use `not None:` for false checks +E712 [*] Avoid equality comparisons to `False`; use `not None:` for false checks + --> constant_literals.py:16:4 | 14 | if False == None: # E711, E712 (fix) 15 | pass 16 | if None == False: # E711, E712 (fix) - | ^^^^^^^^^^^^^ E712 + | ^^^^^^^^^^^^^ 17 | pass | - = help: Replace with `not None` +help: Replace with `not None` ℹ Unsafe fix 13 13 | pass @@ -188,15 +197,16 @@ constant_literals.py:16:4: E712 [*] Avoid equality comparisons to `False`; use ` 18 18 | 19 19 | named_var = [] -constant_literals.py:20:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:20:4 | 19 | named_var = [] 20 | if [] is []: # F632 (fix) - | ^^^^^^^^ F632 + | ^^^^^^^^ 21 | pass 22 | if named_var is []: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 17 17 | pass @@ -208,16 +218,17 @@ constant_literals.py:20:4: F632 [*] Use `==` to compare constant literals 22 22 | if named_var is []: # F632 (fix) 23 23 | pass -constant_literals.py:22:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:22:4 | 20 | if [] is []: # F632 (fix) 21 | pass 22 | if named_var is []: # F632 (fix) - | ^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^ 23 | pass 24 | if [] is named_var: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 19 19 | named_var = [] @@ -229,16 +240,17 @@ constant_literals.py:22:4: F632 [*] Use `==` to compare constant literals 24 24 | if [] is named_var: # F632 (fix) 25 25 | pass -constant_literals.py:24:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:24:4 | 22 | if named_var is []: # F632 (fix) 23 | pass 24 | if [] is named_var: # F632 (fix) - | ^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^ 25 | pass 26 | if named_var is [1]: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 21 21 | pass @@ -250,16 +262,17 @@ constant_literals.py:24:4: F632 [*] Use `==` to compare constant literals 26 26 | if named_var is [1]: # F632 (fix) 27 27 | pass -constant_literals.py:26:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:26:4 | 24 | if [] is named_var: # F632 (fix) 25 | pass 26 | if named_var is [1]: # F632 (fix) - | ^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^ 27 | pass 28 | if [1] is named_var: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 23 23 | pass @@ -271,16 +284,17 @@ constant_literals.py:26:4: F632 [*] Use `==` to compare constant literals 28 28 | if [1] is named_var: # F632 (fix) 29 29 | pass -constant_literals.py:28:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:28:4 | 26 | if named_var is [1]: # F632 (fix) 27 | pass 28 | if [1] is named_var: # F632 (fix) - | ^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^ 29 | pass 30 | if named_var is [i for i in [1]]: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 25 25 | pass @@ -292,15 +306,16 @@ constant_literals.py:28:4: F632 [*] Use `==` to compare constant literals 30 30 | if named_var is [i for i in [1]]: # F632 (fix) 31 31 | pass -constant_literals.py:30:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:30:4 | 28 | if [1] is named_var: # F632 (fix) 29 | pass 30 | if named_var is [i for i in [1]]: # F632 (fix) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | pass | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 27 27 | pass @@ -312,15 +327,16 @@ constant_literals.py:30:4: F632 [*] Use `==` to compare constant literals 32 32 | 33 33 | named_var = {} -constant_literals.py:34:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:34:4 | 33 | named_var = {} 34 | if {} is {}: # F632 (fix) - | ^^^^^^^^ F632 + | ^^^^^^^^ 35 | pass 36 | if named_var is {}: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 31 31 | pass @@ -332,16 +348,17 @@ constant_literals.py:34:4: F632 [*] Use `==` to compare constant literals 36 36 | if named_var is {}: # F632 (fix) 37 37 | pass -constant_literals.py:36:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:36:4 | 34 | if {} is {}: # F632 (fix) 35 | pass 36 | if named_var is {}: # F632 (fix) - | ^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^ 37 | pass 38 | if {} is named_var: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 33 33 | named_var = {} @@ -353,16 +370,17 @@ constant_literals.py:36:4: F632 [*] Use `==` to compare constant literals 38 38 | if {} is named_var: # F632 (fix) 39 39 | pass -constant_literals.py:38:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:38:4 | 36 | if named_var is {}: # F632 (fix) 37 | pass 38 | if {} is named_var: # F632 (fix) - | ^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^ 39 | pass 40 | if named_var is {1}: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 35 35 | pass @@ -374,16 +392,17 @@ constant_literals.py:38:4: F632 [*] Use `==` to compare constant literals 40 40 | if named_var is {1}: # F632 (fix) 41 41 | pass -constant_literals.py:40:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:40:4 | 38 | if {} is named_var: # F632 (fix) 39 | pass 40 | if named_var is {1}: # F632 (fix) - | ^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^ 41 | pass 42 | if {1} is named_var: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 37 37 | pass @@ -395,16 +414,17 @@ constant_literals.py:40:4: F632 [*] Use `==` to compare constant literals 42 42 | if {1} is named_var: # F632 (fix) 43 43 | pass -constant_literals.py:42:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:42:4 | 40 | if named_var is {1}: # F632 (fix) 41 | pass 42 | if {1} is named_var: # F632 (fix) - | ^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^ 43 | pass 44 | if named_var is {i for i in [1]}: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 39 39 | pass @@ -416,15 +436,16 @@ constant_literals.py:42:4: F632 [*] Use `==` to compare constant literals 44 44 | if named_var is {i for i in [1]}: # F632 (fix) 45 45 | pass -constant_literals.py:44:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:44:4 | 42 | if {1} is named_var: # F632 (fix) 43 | pass 44 | if named_var is {i for i in [1]}: # F632 (fix) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | pass | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 41 41 | pass @@ -436,15 +457,16 @@ constant_literals.py:44:4: F632 [*] Use `==` to compare constant literals 46 46 | 47 47 | named_var = {1: 1} -constant_literals.py:48:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:48:4 | 47 | named_var = {1: 1} 48 | if {1: 1} is {1: 1}: # F632 (fix) - | ^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^ 49 | pass 50 | if named_var is {1: 1}: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 45 45 | pass @@ -456,16 +478,17 @@ constant_literals.py:48:4: F632 [*] Use `==` to compare constant literals 50 50 | if named_var is {1: 1}: # F632 (fix) 51 51 | pass -constant_literals.py:50:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:50:4 | 48 | if {1: 1} is {1: 1}: # F632 (fix) 49 | pass 50 | if named_var is {1: 1}: # F632 (fix) - | ^^^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^^^ 51 | pass 52 | if {1: 1} is named_var: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 47 47 | named_var = {1: 1} @@ -477,16 +500,17 @@ constant_literals.py:50:4: F632 [*] Use `==` to compare constant literals 52 52 | if {1: 1} is named_var: # F632 (fix) 53 53 | pass -constant_literals.py:52:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:52:4 | 50 | if named_var is {1: 1}: # F632 (fix) 51 | pass 52 | if {1: 1} is named_var: # F632 (fix) - | ^^^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^^^ 53 | pass 54 | if named_var is {1: 1}: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 49 49 | pass @@ -498,16 +522,17 @@ constant_literals.py:52:4: F632 [*] Use `==` to compare constant literals 54 54 | if named_var is {1: 1}: # F632 (fix) 55 55 | pass -constant_literals.py:54:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:54:4 | 52 | if {1: 1} is named_var: # F632 (fix) 53 | pass 54 | if named_var is {1: 1}: # F632 (fix) - | ^^^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^^^ 55 | pass 56 | if {1: 1} is named_var: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 51 51 | pass @@ -519,16 +544,17 @@ constant_literals.py:54:4: F632 [*] Use `==` to compare constant literals 56 56 | if {1: 1} is named_var: # F632 (fix) 57 57 | pass -constant_literals.py:56:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:56:4 | 54 | if named_var is {1: 1}: # F632 (fix) 55 | pass 56 | if {1: 1} is named_var: # F632 (fix) - | ^^^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^^^ 57 | pass 58 | if named_var is {i: 1 for i in [1]}: # F632 (fix) | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 53 53 | pass @@ -540,15 +566,16 @@ constant_literals.py:56:4: F632 [*] Use `==` to compare constant literals 58 58 | if named_var is {i: 1 for i in [1]}: # F632 (fix) 59 59 | pass -constant_literals.py:58:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> constant_literals.py:58:4 | 56 | if {1: 1} is named_var: # F632 (fix) 57 | pass 58 | if named_var is {i: 1 for i in [1]}: # F632 (fix) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 59 | pass | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 55 55 | pass diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap index a5c5cd23e7..434e683b80 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap @@ -1,60 +1,67 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W505.py:2:51: W505 Doc line too long (57 > 50) +W505 Doc line too long (57 > 50) + --> W505.py:2:51 | 1 | #!/usr/bin/env python3 2 | """Here's a top-level docstring that's over the limit.""" - | ^^^^^^^ W505 + | ^^^^^^^ | -W505.py:6:51: W505 Doc line too long (56 > 50) +W505 Doc line too long (56 > 50) + --> W505.py:6:51 | 5 | def f1(): 6 | """Here's a docstring that's also over the limit.""" - | ^^^^^^ W505 + | ^^^^^^ 7 | 8 | x = 1 # Here's a comment that's over the limit, but it's not standalone. | -W505.py:10:51: W505 Doc line too long (56 > 50) +W505 Doc line too long (56 > 50) + --> W505.py:10:51 | 8 | x = 1 # Here's a comment that's over the limit, but it's not standalone. 9 | 10 | # Here's a standalone comment that's over the limit. - | ^^^^^^ W505 + | ^^^^^^ 11 | 12 | x = 2 | -W505.py:13:51: W505 Doc line too long (94 > 50) +W505 Doc line too long (94 > 50) + --> W505.py:13:51 | 12 | x = 2 13 | # Another standalone that is preceded by a newline and indent token and is over the limit. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | print("Here's a string that's over the limit, but it's not a docstring.") | -W505.py:18:51: W505 Doc line too long (61 > 50) +W505 Doc line too long (61 > 50) + --> W505.py:18:51 | 18 | "This is also considered a docstring, and is over the limit." - | ^^^^^^^^^^^ W505 + | ^^^^^^^^^^^ | -W505.py:24:51: W505 Doc line too long (82 > 50) +W505 Doc line too long (82 > 50) + --> W505.py:24:51 | 22 | """Here's a multi-line docstring. 23 | 24 | It's over the limit on this line, which isn't the first line in the docstring. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | """ | -W505.py:31:51: W505 Doc line too long (85 > 50) +W505 Doc line too long (85 > 50) + --> W505.py:31:51 | 29 | """Here's a multi-line docstring. 30 | 31 | It's over the limit on this line, which isn't the first line in the docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap index 64f4347ec6..20d826c6d5 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap @@ -1,60 +1,67 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W505_utf_8.py:2:50: W505 Doc line too long (57 > 50) +W505 Doc line too long (57 > 50) + --> W505_utf_8.py:2:50 | 1 | #!/usr/bin/env python3 2 | """Here's a top-level ß9💣2ℝing that's over theß9💣2ℝ.""" - | ^^^^^^ W505 + | ^^^^^^ | -W505_utf_8.py:6:49: W505 Doc line too long (56 > 50) +W505 Doc line too long (56 > 50) + --> W505_utf_8.py:6:49 | 5 | def f1(): 6 | """Here's a ß9💣2ℝing that's also over theß9💣2ℝ.""" - | ^^^^^^ W505 + | ^^^^^^ 7 | 8 | x = 1 # Here's a comment that's over theß9💣2ℝ, but it's not standalone. | -W505_utf_8.py:10:51: W505 Doc line too long (56 > 50) +W505 Doc line too long (56 > 50) + --> W505_utf_8.py:10:51 | 8 | x = 1 # Here's a comment that's over theß9💣2ℝ, but it's not standalone. 9 | 10 | # Here's a standalone comment that's over theß9💣2ℝ. - | ^^^^^^ W505 + | ^^^^^^ 11 | 12 | x = 2 | -W505_utf_8.py:13:51: W505 Doc line too long (94 > 50) +W505 Doc line too long (94 > 50) + --> W505_utf_8.py:13:51 | 12 | x = 2 13 | # Another standalone that is preceded by a newline and indent token and is over theß9💣2ℝ. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | print("Here's a string that's over theß9💣2ℝ, but it's not a ß9💣2ℝing.") | -W505_utf_8.py:18:50: W505 Doc line too long (61 > 50) +W505 Doc line too long (61 > 50) + --> W505_utf_8.py:18:50 | 18 | "This is also considered a ß9💣2ℝing, and is over theß9💣2ℝ." - | ^^^^^^^^^^^ W505 + | ^^^^^^^^^^^ | -W505_utf_8.py:24:50: W505 Doc line too long (82 > 50) +W505 Doc line too long (82 > 50) + --> W505_utf_8.py:24:50 | 22 | """Here's a multi-line ß9💣2ℝing. 23 | 24 | It's over theß9💣2ℝ on this line, which isn't the first line in the ß9💣2ℝing. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | """ | -W505_utf_8.py:31:50: W505 Doc line too long (85 > 50) +W505 Doc line too long (85 > 50) + --> W505_utf_8.py:31:50 | 29 | """Here's a multi-line ß9💣2ℝing. 30 | 31 | It's over theß9💣2ℝ on this line, which isn't the first line in the ß9💣2ℝing.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap index fe398c0aa1..851d6ec397 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__E502_E502.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E502.py:9:9: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:9:9 | 7 | + 4 8 | 9 | a = (3 -\ - | ^ E502 + | ^ 10 | 2 + \ 11 | 7) | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 6 6 | 3 \ @@ -22,14 +23,15 @@ E502.py:9:9: E502 [*] Redundant backslash 11 11 | 7) 12 12 | -E502.py:10:11: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:10:11 | 9 | a = (3 -\ 10 | 2 + \ - | ^ E502 + | ^ 11 | 7) | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 7 7 | + 4 @@ -41,15 +43,16 @@ E502.py:10:11: E502 [*] Redundant backslash 12 12 | 13 13 | z = 5 + \ -E502.py:14:9: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:14:9 | 13 | z = 5 + \ 14 | (3 -\ - | ^ E502 + | ^ 15 | 2 + \ 16 | 7) + \ | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 11 11 | 7) @@ -61,16 +64,17 @@ E502.py:14:9: E502 [*] Redundant backslash 16 16 | 7) + \ 17 17 | 4 -E502.py:15:11: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:15:11 | 13 | z = 5 + \ 14 | (3 -\ 15 | 2 + \ - | ^ E502 + | ^ 16 | 7) + \ 17 | 4 | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 12 12 | @@ -82,15 +86,16 @@ E502.py:15:11: E502 [*] Redundant backslash 17 17 | 4 18 18 | -E502.py:23:17: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:23:17 | 22 | b = [ 23 | 2 + 4 + 5 + \ - | ^ E502 + | ^ 24 | 44 \ 25 | - 5 | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 20 20 | 2] @@ -102,16 +107,17 @@ E502.py:23:17: E502 [*] Redundant backslash 25 25 | - 5 26 26 | ] -E502.py:24:8: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:24:8 | 22 | b = [ 23 | 2 + 4 + 5 + \ 24 | 44 \ - | ^ E502 + | ^ 25 | - 5 26 | ] | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 21 21 | @@ -123,15 +129,16 @@ E502.py:24:8: E502 [*] Redundant backslash 26 26 | ] 27 27 | -E502.py:29:11: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:29:11 | 28 | c = (True and 29 | False \ - | ^ E502 + | ^ 30 | or False \ 31 | and True \ | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 26 26 | ] @@ -143,16 +150,17 @@ E502.py:29:11: E502 [*] Redundant backslash 31 31 | and True \ 32 32 | ) -E502.py:30:14: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:30:14 | 28 | c = (True and 29 | False \ 30 | or False \ - | ^ E502 + | ^ 31 | and True \ 32 | ) | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 27 27 | @@ -164,15 +172,16 @@ E502.py:30:14: E502 [*] Redundant backslash 32 32 | ) 33 33 | -E502.py:31:14: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:31:14 | 29 | False \ 30 | or False \ 31 | and True \ - | ^ E502 + | ^ 32 | ) | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 28 28 | c = (True and @@ -184,15 +193,16 @@ E502.py:31:14: E502 [*] Redundant backslash 33 33 | 34 34 | c = (True and -E502.py:44:14: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:44:14 | 43 | s = { 44 | 'x': 2 + \ - | ^ E502 + | ^ 45 | 2 46 | } | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 41 41 | @@ -204,13 +214,14 @@ E502.py:44:14: E502 [*] Redundant backslash 46 46 | } 47 47 | -E502.py:55:12: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:55:12 | 55 | x = {2 + 4 \ - | ^ E502 + | ^ 56 | + 3} | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 52 52 | } @@ -222,16 +233,17 @@ E502.py:55:12: E502 [*] Redundant backslash 57 57 | 58 58 | y = ( -E502.py:61:9: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:61:9 | 59 | 2 + 2 # \ 60 | + 3 # \ 61 | + 4 \ - | ^ E502 + | ^ 62 | + 3 63 | ) | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 58 58 | y = ( @@ -243,15 +255,16 @@ E502.py:61:9: E502 [*] Redundant backslash 63 63 | ) 64 64 | -E502.py:82:12: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:82:12 | 80 | "xyz" 81 | 82 | x = ("abc" \ - | ^ E502 + | ^ 83 | "xyz") | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 79 79 | x = "abc" \ @@ -263,14 +276,15 @@ E502.py:82:12: E502 [*] Redundant backslash 84 84 | 85 85 | -E502.py:87:14: E502 [*] Redundant backslash +E502 [*] Redundant backslash + --> E502.py:87:14 | 86 | def foo(): 87 | x = (a + \ - | ^ E502 + | ^ 88 | 2) | - = help: Remove redundant backslash +help: Remove redundant backslash ℹ Safe fix 84 84 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap index 898237e9b4..5f15f1f97c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap @@ -1,19 +1,19 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W391.ipynb:5:1: W391 [*] Too many newlines at end of cell - | - 3 | # just a comment in this cell - 4 | # a comment and some newlines - 5 | / - 6 | | - 7 | | - | |__^ W391 - 8 | - 9 | 1 + 1 -10 | # a comment - | - = help: Remove trailing newlines +W391 [*] Too many newlines at end of cell + --> W391.ipynb:5:1 + | +3 | # just a comment in this cell +4 | # a comment and some newlines +5 | / +6 | | +7 | | + | |__^ +8 | +9 | 1 + 1 + | +help: Remove trailing newlines ℹ Safe fix 3 3 | # just a comment in this cell @@ -26,7 +26,8 @@ W391.ipynb:5:1: W391 [*] Too many newlines at end of cell 10 7 | # a comment 11 8 | -W391.ipynb:11:1: W391 [*] Too many newlines at end of cell +W391 [*] Too many newlines at end of cell + --> W391.ipynb:11:1 | 9 | 1 + 1 10 | # a comment @@ -34,11 +35,11 @@ W391.ipynb:11:1: W391 [*] Too many newlines at end of cell 12 | | 13 | | 14 | | - | |__^ W391 + | |__^ 15 | 16 | 1+1 | - = help: Remove trailing newlines +help: Remove trailing newlines ℹ Safe fix 9 9 | 1 + 1 @@ -52,17 +53,17 @@ W391.ipynb:11:1: W391 [*] Too many newlines at end of cell 17 13 | 18 14 | -W391.ipynb:17:1: W391 [*] Too many newlines at end of cell +W391 [*] Too many newlines at end of cell + --> W391.ipynb:17:1 | 16 | 1+1 17 | / 18 | | 19 | | 20 | | - | |__^ W391 -21 | + | |__^ | - = help: Remove trailing newlines +help: Remove trailing newlines ℹ Safe fix 15 15 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap index f6afa64ada..770754ec50 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_0.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W391_0.py:14:1: W391 [*] Extra newline at end of file +W391 [*] Extra newline at end of file + --> W391_0.py:14:1 | 12 | foo() 13 | bar() 14 | - | ^ W391 + | ^ | - = help: Remove trailing newline +help: Remove trailing newline ℹ Safe fix 11 11 | if __name__ == '__main__': diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap index 2bf8000654..4fee49f2de 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391_2.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W391_2.py:14:1: W391 [*] Too many newlines at end of file +W391 [*] Too many newlines at end of file + --> W391_2.py:14:1 | 12 | foo() 13 | bar() @@ -9,9 +10,9 @@ W391_2.py:14:1: W391 [*] Too many newlines at end of file 15 | | 16 | | 17 | | - | |__^ W391 + | |__^ | - = help: Remove trailing newlines +help: Remove trailing newlines ℹ Safe fix 11 11 | if __name__ == '__main__': diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap index bd5f7a287c..fd26c27315 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- -shebang.py:3:1: E265 [*] Block comment should start with `# ` +E265 [*] Block comment should start with `# ` + --> shebang.py:3:1 | 1 | #!/usr/bin/python 2 | # 3 | #! - | ^^ E265 + | ^^ 4 | #: | - = help: Format space +help: Format space ℹ Safe fix 1 1 | #!/usr/bin/python diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap index 2b5a0222b2..f9cc43321a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap @@ -1,49 +1,54 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E501_2.py:2:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:2:7 | 1 | # aaaa 2 | # aaaaa - | ^ E501 + | ^ 3 | # a 4 | # a | -E501_2.py:3:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:3:7 | 1 | # aaaa 2 | # aaaaa 3 | # a - | ^ E501 + | ^ 4 | # a 5 | # aa | -E501_2.py:7:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:7:7 | 5 | # aa 6 | # aaa 7 | # aaaa - | ^ E501 + | ^ 8 | # a 9 | # aa | -E501_2.py:10:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:10:7 | 8 | # a 9 | # aa 10 | # aaa - | ^ E501 + | ^ 11 | 12 | if True: # noqa: E501 | -E501_2.py:16:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:16:7 | 14 | [12 ] 15 | [1,2] 16 | [1, 2] - | ^ E501 + | ^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap index bfc312b4dc..ff4b41e3d8 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap @@ -1,88 +1,97 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E501_2.py:2:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:2:7 | 1 | # aaaa 2 | # aaaaa - | ^ E501 + | ^ 3 | # a 4 | # a | -E501_2.py:3:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:3:7 | 1 | # aaaa 2 | # aaaaa 3 | # a - | ^ E501 + | ^ 4 | # a 5 | # aa | -E501_2.py:6:6: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:6:6 | 4 | # a 5 | # aa 6 | # aaa - | ^ E501 + | ^ 7 | # aaaa 8 | # a | -E501_2.py:7:6: E501 Line too long (8 > 6) +E501 Line too long (8 > 6) + --> E501_2.py:7:6 | 5 | # aa 6 | # aaa 7 | # aaaa - | ^^ E501 + | ^^ 8 | # a 9 | # aa | -E501_2.py:8:5: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:8:5 | 6 | # aaa 7 | # aaaa 8 | # a - | ^ E501 + | ^ 9 | # aa 10 | # aaa | -E501_2.py:9:5: E501 Line too long (8 > 6) +E501 Line too long (8 > 6) + --> E501_2.py:9:5 | 7 | # aaaa 8 | # a 9 | # aa - | ^^ E501 + | ^^ 10 | # aaa | -E501_2.py:10:5: E501 Line too long (9 > 6) +E501 Line too long (9 > 6) + --> E501_2.py:10:5 | 8 | # a 9 | # aa 10 | # aaa - | ^^^ E501 + | ^^^ 11 | 12 | if True: # noqa: E501 | -E501_2.py:14:6: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:14:6 | 12 | if True: # noqa: E501 13 | [12] 14 | [12 ] - | ^ E501 + | ^ 15 | [1,2] 16 | [1, 2] | -E501_2.py:16:6: E501 Line too long (8 > 6) +E501 Line too long (8 > 6) + --> E501_2.py:16:6 | 14 | [12 ] 15 | [1,2] 16 | [1, 2] - | ^^ E501 + | ^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap index 9930bcbee3..6eedca02da 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap @@ -1,108 +1,119 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E501_2.py:2:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:2:7 | 1 | # aaaa 2 | # aaaaa - | ^ E501 + | ^ 3 | # a 4 | # a | -E501_2.py:3:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:3:7 | 1 | # aaaa 2 | # aaaaa 3 | # a - | ^ E501 + | ^ 4 | # a 5 | # aa | -E501_2.py:4:4: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:4:4 | 2 | # aaaaa 3 | # a 4 | # a - | ^ E501 + | ^ 5 | # aa 6 | # aaa | -E501_2.py:5:4: E501 Line too long (8 > 6) +E501 Line too long (8 > 6) + --> E501_2.py:5:4 | 3 | # a 4 | # a 5 | # aa - | ^^ E501 + | ^^ 6 | # aaa 7 | # aaaa | -E501_2.py:6:4: E501 Line too long (9 > 6) +E501 Line too long (9 > 6) + --> E501_2.py:6:4 | 4 | # a 5 | # aa 6 | # aaa - | ^^^ E501 + | ^^^ 7 | # aaaa 8 | # a | -E501_2.py:7:4: E501 Line too long (10 > 6) +E501 Line too long (10 > 6) + --> E501_2.py:7:4 | 5 | # aa 6 | # aaa 7 | # aaaa - | ^^^^ E501 + | ^^^^ 8 | # a 9 | # aa | -E501_2.py:8:3: E501 Line too long (11 > 6) +E501 Line too long (11 > 6) + --> E501_2.py:8:3 | 6 | # aaa 7 | # aaaa 8 | # a - | ^^^ E501 + | ^^^ 9 | # aa 10 | # aaa | -E501_2.py:9:3: E501 Line too long (12 > 6) +E501 Line too long (12 > 6) + --> E501_2.py:9:3 | 7 | # aaaa 8 | # a 9 | # aa - | ^^^^ E501 + | ^^^^ 10 | # aaa | -E501_2.py:10:3: E501 Line too long (13 > 6) +E501 Line too long (13 > 6) + --> E501_2.py:10:3 | 8 | # a 9 | # aa 10 | # aaa - | ^^^^^ E501 + | ^^^^^ 11 | 12 | if True: # noqa: E501 | -E501_2.py:14:4: E501 Line too long (9 > 6) +E501 Line too long (9 > 6) + --> E501_2.py:14:4 | 12 | if True: # noqa: E501 13 | [12] 14 | [12 ] - | ^^^ E501 + | ^^^ 15 | [1,2] 16 | [1, 2] | -E501_2.py:16:4: E501 Line too long (10 > 6) +E501 Line too long (10 > 6) + --> E501_2.py:16:4 | 14 | [12 ] 15 | [1,2] 16 | [1, 2] - | ^^^^ E501 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap index 2f3422d92f..d1f68fe2db 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap @@ -1,108 +1,119 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E501_2.py:2:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:2:7 | 1 | # aaaa 2 | # aaaaa - | ^ E501 + | ^ 3 | # a 4 | # a | -E501_2.py:3:7: E501 Line too long (7 > 6) +E501 Line too long (7 > 6) + --> E501_2.py:3:7 | 1 | # aaaa 2 | # aaaaa 3 | # a - | ^ E501 + | ^ 4 | # a 5 | # aa | -E501_2.py:4:2: E501 Line too long (11 > 6) +E501 Line too long (11 > 6) + --> E501_2.py:4:2 | 2 | # aaaaa 3 | # a 4 | # a - | ^^^ E501 + | ^^^ 5 | # aa 6 | # aaa | -E501_2.py:5:2: E501 Line too long (12 > 6) +E501 Line too long (12 > 6) + --> E501_2.py:5:2 | 3 | # a 4 | # a 5 | # aa - | ^^^^ E501 + | ^^^^ 6 | # aaa 7 | # aaaa | -E501_2.py:6:2: E501 Line too long (13 > 6) +E501 Line too long (13 > 6) + --> E501_2.py:6:2 | 4 | # a 5 | # aa 6 | # aaa - | ^^^^^ E501 + | ^^^^^ 7 | # aaaa 8 | # a | -E501_2.py:7:2: E501 Line too long (14 > 6) +E501 Line too long (14 > 6) + --> E501_2.py:7:2 | 5 | # aa 6 | # aaa 7 | # aaaa - | ^^^^^^ E501 + | ^^^^^^ 8 | # a 9 | # aa | -E501_2.py:8:2: E501 Line too long (19 > 6) +E501 Line too long (19 > 6) + --> E501_2.py:8:2 | 6 | # aaa 7 | # aaaa 8 | # a - | ^^^^^^^ E501 + | ^^^^^^^ 9 | # aa 10 | # aaa | -E501_2.py:9:2: E501 Line too long (20 > 6) +E501 Line too long (20 > 6) + --> E501_2.py:9:2 | 7 | # aaaa 8 | # a 9 | # aa - | ^^^^^^^^ E501 + | ^^^^^^^^ 10 | # aaa | -E501_2.py:10:2: E501 Line too long (21 > 6) +E501 Line too long (21 > 6) + --> E501_2.py:10:2 | 8 | # a 9 | # aa 10 | # aaa - | ^^^^^^^^^ E501 + | ^^^^^^^^^ 11 | 12 | if True: # noqa: E501 | -E501_2.py:14:2: E501 Line too long (13 > 6) +E501 Line too long (13 > 6) + --> E501_2.py:14:2 | 12 | if True: # noqa: E501 13 | [12] 14 | [12 ] - | ^^^^^ E501 + | ^^^^^ 15 | [1,2] 16 | [1, 2] | -E501_2.py:16:2: E501 Line too long (14 > 6) +E501 Line too long (14 > 6) + --> E501_2.py:16:2 | 14 | [12 ] 15 | [1,2] 16 | [1, 2] - | ^^^^^^ E501 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap index 6dfc2c571a..f7526d15b7 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap @@ -1,76 +1,84 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E501_1.py:1:89: E501 Line too long (149 > 88) +E501 Line too long (149 > 88) + --> E501_1.py:1:89 | -1 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -2 | …figured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -3 | …sk-tags sometimes are longer than line-length so that you can easily find them with `git grep` +1 | … task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 | …onfigured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +3 | …task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | -E501_1.py:2:89: E501 Line too long (158 > 88) +E501 Line too long (158 > 88) + --> E501_1.py:2:89 | -1 | …ags sometimes are longer than line-length so that you can easily find them with `git grep` -2 | …ed task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -3 | …gs sometimes are longer than line-length so that you can easily find them with `git grep` -4 | …task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +1 | …k-tags sometimes are longer than line-length so that you can easily find them with `git grep` +2 | …gured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 | …-tags sometimes are longer than line-length so that you can easily find them with `git grep` +4 | …ed task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | -E501_1.py:3:89: E501 Line too long (148 > 88) +E501 Line too long (148 > 88) + --> E501_1.py:3:89 | -1 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` -2 | …figured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -3 | …sk-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -4 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -5 | …task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +1 | …d task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +2 | …configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +3 | … task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4 | …figured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +5 | …ed task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | -E501_1.py:4:89: E501 Line too long (155 > 88) - | -2 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -3 | …tags sometimes are longer than line-length so that you can easily find them with `git grep` -4 | …d task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -5 | …k-tags sometimes are longer than line-length so that you can easily find them with `git grep` -6 | …-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | - -E501_1.py:5:89: E501 Line too long (150 > 88) +E501 Line too long (155 > 88) + --> E501_1.py:4:89 | +2 | …igured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` 3 | …k-tags sometimes are longer than line-length so that you can easily find them with `git grep` 4 | …red task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` +6 | …sk-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | + +E501 Line too long (150 > 88) + --> E501_1.py:5:89 + | +3 | …task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +4 | …igured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +5 | …d task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +6 | … task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +7 | …figured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | + +E501 Line too long (149 > 88) + --> E501_1.py:6:89 + | +4 | …igured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +5 | …d task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +6 | … task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 | …figured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +8 | …configured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | + +E501 Line too long (156 > 88) + --> E501_1.py:7:89 + | 5 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 6 | …sk-tags sometimes are longer than line-length so that you can easily find them with `git grep` 7 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +8 | …figured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` | -E501_1.py:6:89: E501 Line too long (149 > 88) +E501 Line too long (159 > 88) + --> E501_1.py:8:89 | -4 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -5 | …task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -6 | …ask-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -7 | …gured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -8 | …nfigured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | - -E501_1.py:7:89: E501 Line too long (156 > 88) - | -5 | …-tags sometimes are longer than line-length so that you can easily find them with `git grep` -6 | …tags sometimes are longer than line-length so that you can easily find them with `git grep` -7 | …d task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -8 | …ured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | - -E501_1.py:8:89: E501 Line too long (159 > 88) - | -6 | …ags sometimes are longer than line-length so that you can easily find them with `git grep` -7 | … task-tags sometimes are longer than line-length so that you can easily find them with `git grep` -8 | …red task-tags sometimes are longer than line-length so that you can easily find them with `git grep` - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +6 | …-tags sometimes are longer than line-length so that you can easily find them with `git grep` +7 | …ed task-tags sometimes are longer than line-length so that you can easily find them with `git grep` +8 | …gured task-tags sometimes are longer than line-length so that you can easily find them with `git grep` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap index 8d895a4453..1e0642addf 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(-1)-between(0).snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import json @@ -21,12 +22,13 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted 6 3 | 7 4 | -E30_isort.py:5:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30_isort.py:5:1 | 5 | from typing import Any, Sequence - | ^^^^ E303 + | ^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 1 1 | import json @@ -37,14 +39,15 @@ E30_isort.py:5:1: E303 [*] Too many blank lines (3) 6 5 | 7 6 | -E30_isort.py:21:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:21:5 | 21 | abcd.foo() - | ^^^^ E303 + | ^^^^ 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 17 17 | if __name__ == "__main__": @@ -55,7 +58,8 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) 22 21 | 23 22 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... -E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -63,9 +67,9 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -77,12 +81,13 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.py:30:5: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30_isort.py:30:5 | 30 | from typing_extensions import TypeAlias - | ^^^^ E303 + | ^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -94,14 +99,15 @@ E30_isort.py:30:5: E303 [*] Too many blank lines (3) 31 29 | 32 30 | -E30_isort.py:33:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:33:5 | 33 | abcd.foo() - | ^^^^ E303 + | ^^^^ 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 29 29 | @@ -112,14 +118,15 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) 34 33 | 35 34 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: -E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:60:1 | 60 | from typing import Any, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | - = help: Organize imports +help: Organize imports ℹ Safe fix 59 59 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap index 2c2e5936b9..395cce3697 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(0)-between(0).snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import json @@ -24,12 +25,13 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted 9 4 | 10 5 | -E30_isort.py:5:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30_isort.py:5:1 | 5 | from typing import Any, Sequence - | ^^^^ E303 + | ^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 1 1 | import json @@ -40,12 +42,13 @@ E30_isort.py:5:1: E303 [*] Too many blank lines (3) 6 5 | 7 6 | -E30_isort.py:8:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:8:1 | 8 | class MissingCommand(TypeError): ... # noqa: N818 - | ^^^^^ E303 + | ^^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 3 3 | @@ -57,14 +60,15 @@ E30_isort.py:8:1: E303 [*] Too many blank lines (2) 9 7 | 10 8 | -E30_isort.py:21:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:21:5 | 21 | abcd.foo() - | ^^^^ E303 + | ^^^^ 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 17 17 | if __name__ == "__main__": @@ -75,7 +79,8 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) 22 21 | 23 22 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... -E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -83,9 +88,9 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -97,12 +102,13 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.py:30:5: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30_isort.py:30:5 | 30 | from typing_extensions import TypeAlias - | ^^^^ E303 + | ^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -114,14 +120,15 @@ E30_isort.py:30:5: E303 [*] Too many blank lines (3) 31 29 | 32 30 | -E30_isort.py:33:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:33:5 | 33 | abcd.foo() - | ^^^^ E303 + | ^^^^ 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 29 29 | @@ -132,14 +139,15 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) 34 33 | 35 34 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: -E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:60:1 | 60 | from typing import Any, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | - = help: Organize imports +help: Organize imports ℹ Safe fix 58 58 | @@ -148,14 +156,15 @@ E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted 61 |- 62 61 | class MissingCommand(TypeError): ... # noqa: N818 -E30_isort.py:62:1: E303 [*] Too many blank lines (1) +E303 [*] Too many blank lines (1) + --> E30_isort.py:62:1 | 60 | from typing import Any, Sequence 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 - | ^^^^^ E303 + | ^^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 58 58 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap index 1c152584a9..7e3f1d9486 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(1)-between(1).snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | import json @@ -23,12 +24,13 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted 8 5 | class MissingCommand(TypeError): ... # noqa: N818 9 6 | -E30_isort.py:5:1: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30_isort.py:5:1 | 5 | from typing import Any, Sequence - | ^^^^ E303 + | ^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 1 1 | import json @@ -39,12 +41,13 @@ E30_isort.py:5:1: E303 [*] Too many blank lines (3) 6 5 | 7 6 | -E30_isort.py:8:1: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:8:1 | 8 | class MissingCommand(TypeError): ... # noqa: N818 - | ^^^^^ E303 + | ^^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 4 4 | @@ -55,14 +58,15 @@ E30_isort.py:8:1: E303 [*] Too many blank lines (2) 9 8 | 10 9 | -E30_isort.py:21:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:21:5 | 21 | abcd.foo() - | ^^^^ E303 + | ^^^^ 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 17 17 | if __name__ == "__main__": @@ -73,7 +77,8 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) 22 21 | 23 22 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... -E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -81,9 +86,9 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -95,12 +100,13 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.py:30:5: E303 [*] Too many blank lines (3) +E303 [*] Too many blank lines (3) + --> E30_isort.py:30:5 | 30 | from typing_extensions import TypeAlias - | ^^^^ E303 + | ^^^^ | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -112,14 +118,15 @@ E30_isort.py:30:5: E303 [*] Too many blank lines (3) 31 29 | 32 30 | -E30_isort.py:33:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:33:5 | 33 | abcd.foo() - | ^^^^ E303 + | ^^^^ 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 29 29 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap index c6db5e7df6..78d8e3cc24 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__too_many_blank_lines_isort_compatibility-lines-after(4)-between(4).snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:1:1 | 1 | / import json 2 | | 3 | | 4 | | 5 | | from typing import Any, Sequence - | |________________________________^ I001 + | |________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 2 2 | @@ -26,14 +27,15 @@ E30_isort.py:1:1: I001 [*] Import block is un-sorted or un-formatted 9 12 | 10 13 | -E30_isort.py:21:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:21:5 | 21 | abcd.foo() - | ^^^^ E303 + | ^^^^ 22 | 23 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 17 17 | if __name__ == "__main__": @@ -44,7 +46,8 @@ E30_isort.py:21:5: E303 [*] Too many blank lines (2) 22 21 | 23 22 | def __init__(self, backend_module: str, backend_obj: str | None) -> None: ... -E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:26:5 | 25 | if TYPE_CHECKING: 26 | / import os @@ -52,9 +55,9 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 28 | | 29 | | 30 | | from typing_extensions import TypeAlias - | |___________________________________________^ I001 + | |___________________________________________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 25 25 | if TYPE_CHECKING: @@ -66,14 +69,15 @@ E30_isort.py:26:5: I001 [*] Import block is un-sorted or un-formatted 31 29 | 32 30 | -E30_isort.py:33:5: E303 [*] Too many blank lines (2) +E303 [*] Too many blank lines (2) + --> E30_isort.py:33:5 | 33 | abcd.foo() - | ^^^^ E303 + | ^^^^ 34 | 35 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: | - = help: Remove extraneous blank line(s) +help: Remove extraneous blank line(s) ℹ Safe fix 29 29 | @@ -84,14 +88,15 @@ E30_isort.py:33:5: E303 [*] Too many blank lines (2) 34 33 | 35 34 | def __call__(self, name: str, *args: Any, **kwargs: Any) -> Any: -E30_isort.py:60:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> E30_isort.py:60:1 | 60 | from typing import Any, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | 62 | class MissingCommand(TypeError): ... # noqa: N818 | - = help: Organize imports +help: Organize imports ℹ Safe fix 59 59 | diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap index 31356cd79f..807eabd09c 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -W292_4.py:1:2: W292 [*] No newline at end of file +W292 [*] No newline at end of file + --> W292_4.py:1:2 | 1 | - | ^ W292 + | ^ | - = help: Add trailing newline +help: Add trailing newline ℹ Safe fix 1 |- diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__white_space_syntax_error_compatibility.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__white_space_syntax_error_compatibility.snap index d78a1c3367..447a0efd5e 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__white_space_syntax_error_compatibility.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__white_space_syntax_error_compatibility.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs --- -E2_syntax_error.py:1:10: invalid-syntax: Expected an expression +invalid-syntax: Expected an expression + --> E2_syntax_error.py:1:10 | 1 | a = (1 or) | ^ diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_google.py.snap index c847330890..80ccb2c157 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_google.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC502_google.py:7:5: DOC502 Raised exception is not explicitly raised: `FasterThanLightError` +DOC502 Raised exception is not explicitly raised: `FasterThanLightError` + --> DOC502_google.py:7:5 | 5 | # DOC502 6 | def calculate_speed(distance: float, time: float) -> float: @@ -17,12 +18,13 @@ DOC502_google.py:7:5: DOC502 Raised exception is not explicitly raised: `FasterT 16 | | Raises: 17 | | FasterThanLightError: If speed is greater than the speed of light. 18 | | """ - | |_______^ DOC502 + | |_______^ 19 | return distance / time | - = help: Remove `FasterThanLightError` from the docstring +help: Remove `FasterThanLightError` from the docstring -DOC502_google.py:24:5: DOC502 Raised exceptions are not explicitly raised: `FasterThanLightError`, `DivisionByZero` +DOC502 Raised exceptions are not explicitly raised: `FasterThanLightError`, `DivisionByZero` + --> DOC502_google.py:24:5 | 22 | # DOC502 23 | def calculate_speed(distance: float, time: float) -> float: @@ -39,12 +41,13 @@ DOC502_google.py:24:5: DOC502 Raised exceptions are not explicitly raised: `Fast 34 | | FasterThanLightError: If speed is greater than the speed of light. 35 | | DivisionByZero: Divide by zero. 36 | | """ - | |_______^ DOC502 + | |_______^ 37 | return distance / time | - = help: Remove `FasterThanLightError`, `DivisionByZero` from the docstring +help: Remove `FasterThanLightError`, `DivisionByZero` from the docstring -DOC502_google.py:42:5: DOC502 Raised exception is not explicitly raised: `DivisionByZero` +DOC502 Raised exception is not explicitly raised: `DivisionByZero` + --> DOC502_google.py:42:5 | 40 | # DOC502 41 | def calculate_speed(distance: float, time: float) -> float: @@ -61,8 +64,8 @@ DOC502_google.py:42:5: DOC502 Raised exception is not explicitly raised: `Divisi 52 | | FasterThanLightError: If speed is greater than the speed of light. 53 | | DivisionByZero: Divide by zero. 54 | | """ - | |_______^ DOC502 + | |_______^ 55 | try: 56 | return distance / time | - = help: Remove `DivisionByZero` from the docstring +help: Remove `DivisionByZero` from the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_numpy.py.snap index b007d9536b..fd28bded5d 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-exception_DOC502_numpy.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC502_numpy.py:7:5: DOC502 Raised exception is not explicitly raised: `FasterThanLightError` +DOC502 Raised exception is not explicitly raised: `FasterThanLightError` + --> DOC502_numpy.py:7:5 | 5 | # DOC502 6 | def calculate_speed(distance: float, time: float) -> float: @@ -25,12 +26,13 @@ DOC502_numpy.py:7:5: DOC502 Raised exception is not explicitly raised: `FasterTh 24 | | FasterThanLightError 25 | | If speed is greater than the speed of light. 26 | | """ - | |_______^ DOC502 + | |_______^ 27 | return distance / time | - = help: Remove `FasterThanLightError` from the docstring +help: Remove `FasterThanLightError` from the docstring -DOC502_numpy.py:32:5: DOC502 Raised exceptions are not explicitly raised: `FasterThanLightError`, `DivisionByZero` +DOC502 Raised exceptions are not explicitly raised: `FasterThanLightError`, `DivisionByZero` + --> DOC502_numpy.py:32:5 | 30 | # DOC502 31 | def calculate_speed(distance: float, time: float) -> float: @@ -56,12 +58,13 @@ DOC502_numpy.py:32:5: DOC502 Raised exceptions are not explicitly raised: `Faste 51 | | DivisionByZero 52 | | If attempting to divide by zero. 53 | | """ - | |_______^ DOC502 + | |_______^ 54 | return distance / time | - = help: Remove `FasterThanLightError`, `DivisionByZero` from the docstring +help: Remove `FasterThanLightError`, `DivisionByZero` from the docstring -DOC502_numpy.py:59:5: DOC502 Raised exception is not explicitly raised: `DivisionByZero` +DOC502 Raised exception is not explicitly raised: `DivisionByZero` + --> DOC502_numpy.py:59:5 | 57 | # DOC502 58 | def calculate_speed(distance: float, time: float) -> float: @@ -87,8 +90,8 @@ DOC502_numpy.py:59:5: DOC502 Raised exception is not explicitly raised: `Divisio 78 | | DivisionByZero 79 | | If attempting to divide by zero. 80 | | """ - | |_______^ DOC502 + | |_______^ 81 | try: 82 | return distance / time | - = help: Remove `DivisionByZero` from the docstring +help: Remove `DivisionByZero` from the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_google.py.snap index 70beeffbc1..90df7a99d8 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_google.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC202_google.py:14:5: DOC202 Docstring should not have a returns section because the function doesn't return anything +DOC202 Docstring should not have a returns section because the function doesn't return anything + --> DOC202_google.py:14:5 | 12 | # DOC202 13 | def foo(num: int) -> str: @@ -14,12 +15,13 @@ DOC202_google.py:14:5: DOC202 Docstring should not have a returns section becaus 20 | | Returns: 21 | | str: A string 22 | | """ - | |_______^ DOC202 + | |_______^ 23 | print('test') | - = help: Remove the "Returns" section +help: Remove the "Returns" section -DOC202_google.py:30:9: DOC202 Docstring should not have a returns section because the function doesn't return anything +DOC202 Docstring should not have a returns section because the function doesn't return anything + --> DOC202_google.py:30:9 | 28 | # DOC202 29 | def foo(self) -> str: @@ -32,12 +34,13 @@ DOC202_google.py:30:9: DOC202 Docstring should not have a returns section becaus 36 | | Returns: 37 | | str: A string 38 | | """ - | |___________^ DOC202 + | |___________^ 39 | print('test') | - = help: Remove the "Returns" section +help: Remove the "Returns" section -DOC202_google.py:80:5: DOC202 Docstring should not have a returns section because the function doesn't return anything +DOC202 Docstring should not have a returns section because the function doesn't return anything + --> DOC202_google.py:80:5 | 78 | # DOC202 -- never explicitly returns anything, just short-circuits 79 | def foo(s: str, condition: bool): @@ -46,8 +49,8 @@ DOC202_google.py:80:5: DOC202 Docstring should not have a returns section becaus 82 | | Returns: 83 | | None 84 | | """ - | |_______^ DOC202 + | |_______^ 85 | if not condition: 86 | return | - = help: Remove the "Returns" section +help: Remove the "Returns" section diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_numpy.py.snap index 0bb06b9b99..9cccd876ae 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-returns_DOC202_numpy.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC202_numpy.py:16:5: DOC202 Docstring should not have a returns section because the function doesn't return anything +DOC202 Docstring should not have a returns section because the function doesn't return anything + --> DOC202_numpy.py:16:5 | 14 | # DOC202 15 | def foo(num: int) -> str: @@ -18,12 +19,13 @@ DOC202_numpy.py:16:5: DOC202 Docstring should not have a returns section because 26 | | str 27 | | A string 28 | | """ - | |_______^ DOC202 + | |_______^ 29 | print('test') | - = help: Remove the "Returns" section +help: Remove the "Returns" section -DOC202_numpy.py:36:9: DOC202 Docstring should not have a returns section because the function doesn't return anything +DOC202 Docstring should not have a returns section because the function doesn't return anything + --> DOC202_numpy.py:36:9 | 34 | # DOC202 35 | def foo(self) -> str: @@ -40,7 +42,7 @@ DOC202_numpy.py:36:9: DOC202 Docstring should not have a returns section because 46 | | str 47 | | A string 48 | | """ - | |___________^ DOC202 + | |___________^ 49 | print('test') | - = help: Remove the "Returns" section +help: Remove the "Returns" section diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_google.py.snap index dccb259a11..09b88d835e 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_google.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC403_google.py:14:5: DOC403 Docstring has a "Yields" section but the function doesn't yield anything +DOC403 Docstring has a "Yields" section but the function doesn't yield anything + --> DOC403_google.py:14:5 | 12 | # DOC403 13 | def foo(num: int) -> str: @@ -14,12 +15,13 @@ DOC403_google.py:14:5: DOC403 Docstring has a "Yields" section but the function 20 | | Yields: 21 | | str: A string 22 | | """ - | |_______^ DOC403 + | |_______^ 23 | print('test') | - = help: Remove the "Yields" section +help: Remove the "Yields" section -DOC403_google.py:30:9: DOC403 Docstring has a "Yields" section but the function doesn't yield anything +DOC403 Docstring has a "Yields" section but the function doesn't yield anything + --> DOC403_google.py:30:9 | 28 | # DOC403 29 | def foo(self) -> str: @@ -32,7 +34,7 @@ DOC403_google.py:30:9: DOC403 Docstring has a "Yields" section but the function 36 | | Yields: 37 | | str: A string 38 | | """ - | |___________^ DOC403 + | |___________^ 39 | print('test') | - = help: Remove the "Yields" section +help: Remove the "Yields" section diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_numpy.py.snap index d87e8f4f27..4b2cd2954c 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-extraneous-yields_DOC403_numpy.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC403_numpy.py:16:5: DOC403 Docstring has a "Yields" section but the function doesn't yield anything +DOC403 Docstring has a "Yields" section but the function doesn't yield anything + --> DOC403_numpy.py:16:5 | 14 | # DOC403 15 | def foo(num: int) -> str: @@ -18,12 +19,13 @@ DOC403_numpy.py:16:5: DOC403 Docstring has a "Yields" section but the function d 26 | | str 27 | | A string 28 | | """ - | |_______^ DOC403 + | |_______^ 29 | print('test') | - = help: Remove the "Yields" section +help: Remove the "Yields" section -DOC403_numpy.py:36:9: DOC403 Docstring has a "Yields" section but the function doesn't yield anything +DOC403 Docstring has a "Yields" section but the function doesn't yield anything + --> DOC403_numpy.py:36:9 | 34 | # DOC403 35 | def foo(self) -> str: @@ -40,7 +42,7 @@ DOC403_numpy.py:36:9: DOC403 Docstring has a "Yields" section but the function d 46 | | str 47 | | A string 48 | | """ - | |___________^ DOC403 + | |___________^ 49 | print('test') | - = help: Remove the "Yields" section +help: Remove the "Yields" section diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py.snap index b30b47f6f7..ab13770174 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC501_google.py:34:5: DOC501 Raised exception `FasterThanLightError` missing from docstring +DOC501 Raised exception `FasterThanLightError` missing from docstring + --> DOC501_google.py:34:5 | 32 | # DOC501 33 | def calculate_speed(distance: float, time: float) -> float: @@ -14,13 +15,14 @@ DOC501_google.py:34:5: DOC501 Raised exception `FasterThanLightError` missing fr 40 | | Returns: 41 | | Speed as distance divided by time. 42 | | """ - | |_______^ DOC501 + | |_______^ 43 | try: 44 | return distance / time | - = help: Add `FasterThanLightError` to the docstring +help: Add `FasterThanLightError` to the docstring -DOC501_google.py:51:5: DOC501 Raised exception `ValueError` missing from docstring +DOC501 Raised exception `ValueError` missing from docstring + --> DOC501_google.py:51:5 | 49 | # DOC501 50 | def calculate_speed(distance: float, time: float) -> float: @@ -33,13 +35,14 @@ DOC501_google.py:51:5: DOC501 Raised exception `ValueError` missing from docstri 57 | | Returns: 58 | | Speed as distance divided by time. 59 | | """ - | |_______^ DOC501 + | |_______^ 60 | try: 61 | return distance / time | - = help: Add `ValueError` to the docstring +help: Add `ValueError` to the docstring -DOC501_google.py:51:5: DOC501 Raised exception `FasterThanLightError` missing from docstring +DOC501 Raised exception `FasterThanLightError` missing from docstring + --> DOC501_google.py:51:5 | 49 | # DOC501 50 | def calculate_speed(distance: float, time: float) -> float: @@ -52,13 +55,14 @@ DOC501_google.py:51:5: DOC501 Raised exception `FasterThanLightError` missing fr 57 | | Returns: 58 | | Speed as distance divided by time. 59 | | """ - | |_______^ DOC501 + | |_______^ 60 | try: 61 | return distance / time | - = help: Add `FasterThanLightError` to the docstring +help: Add `FasterThanLightError` to the docstring -DOC501_google.py:106:5: DOC501 Raised exception `AnotherError` missing from docstring +DOC501 Raised exception `AnotherError` missing from docstring + --> DOC501_google.py:106:5 | 104 | # DOC501 105 | def calculate_speed(distance: float, time: float) -> float: @@ -71,12 +75,13 @@ DOC501_google.py:106:5: DOC501 Raised exception `AnotherError` missing from docs 112 | | Returns: 113 | | Speed as distance divided by time. 114 | | """ - | |_______^ DOC501 + | |_______^ 115 | raise AnotherError | - = help: Add `AnotherError` to the docstring +help: Add `AnotherError` to the docstring -DOC501_google.py:120:5: DOC501 Raised exception `AnotherError` missing from docstring +DOC501 Raised exception `AnotherError` missing from docstring + --> DOC501_google.py:120:5 | 118 | # DOC501 119 | def calculate_speed(distance: float, time: float) -> float: @@ -89,12 +94,13 @@ DOC501_google.py:120:5: DOC501 Raised exception `AnotherError` missing from docs 126 | | Returns: 127 | | Speed as distance divided by time. 128 | | """ - | |_______^ DOC501 + | |_______^ 129 | raise AnotherError() | - = help: Add `AnotherError` to the docstring +help: Add `AnotherError` to the docstring -DOC501_google.py:134:5: DOC501 Raised exception `SomeError` missing from docstring +DOC501 Raised exception `SomeError` missing from docstring + --> DOC501_google.py:134:5 | 132 | # DOC501 133 | def foo(bar: int): @@ -103,12 +109,13 @@ DOC501_google.py:134:5: DOC501 Raised exception `SomeError` missing from docstri 136 | | Args: 137 | | bar: Bar. 138 | | """ - | |_______^ DOC501 + | |_______^ 139 | raise something.SomeError | - = help: Add `SomeError` to the docstring +help: Add `SomeError` to the docstring -DOC501_google.py:197:5: DOC501 Raised exception `ZeroDivisionError` missing from docstring +DOC501 Raised exception `ZeroDivisionError` missing from docstring + --> DOC501_google.py:197:5 | 195 | # DOC501 196 | def calculate_speed(distance: float, time: float) -> float: @@ -124,13 +131,14 @@ DOC501_google.py:197:5: DOC501 Raised exception `ZeroDivisionError` missing from 206 | | Raises: 207 | | TypeError: if you didn't pass a number for both parameters 208 | | """ - | |_______^ DOC501 + | |_______^ 209 | try: 210 | return distance / time | - = help: Add `ZeroDivisionError` to the docstring +help: Add `ZeroDivisionError` to the docstring -DOC501_google.py:238:5: DOC501 Raised exception `TypeError` missing from docstring +DOC501 Raised exception `TypeError` missing from docstring + --> DOC501_google.py:238:5 | 237 | def foo(): 238 | / """Foo. @@ -138,13 +146,14 @@ DOC501_google.py:238:5: DOC501 Raised exception `TypeError` missing from docstri 240 | | Returns: 241 | | 42: int. 242 | | """ - | |_______^ DOC501 + | |_______^ 243 | if True: 244 | raise TypeError # DOC501 | - = help: Add `TypeError` to the docstring +help: Add `TypeError` to the docstring -DOC501_google.py:238:5: DOC501 Raised exception `ValueError` missing from docstring +DOC501 Raised exception `ValueError` missing from docstring + --> DOC501_google.py:238:5 | 237 | def foo(): 238 | / """Foo. @@ -152,8 +161,8 @@ DOC501_google.py:238:5: DOC501 Raised exception `ValueError` missing from docstr 240 | | Returns: 241 | | 42: int. 242 | | """ - | |_______^ DOC501 + | |_______^ 243 | if True: 244 | raise TypeError # DOC501 | - = help: Add `ValueError` to the docstring +help: Add `ValueError` to the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py_ignore_one_line.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py_ignore_one_line.snap index b30b47f6f7..ab13770174 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py_ignore_one_line.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_google.py_ignore_one_line.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC501_google.py:34:5: DOC501 Raised exception `FasterThanLightError` missing from docstring +DOC501 Raised exception `FasterThanLightError` missing from docstring + --> DOC501_google.py:34:5 | 32 | # DOC501 33 | def calculate_speed(distance: float, time: float) -> float: @@ -14,13 +15,14 @@ DOC501_google.py:34:5: DOC501 Raised exception `FasterThanLightError` missing fr 40 | | Returns: 41 | | Speed as distance divided by time. 42 | | """ - | |_______^ DOC501 + | |_______^ 43 | try: 44 | return distance / time | - = help: Add `FasterThanLightError` to the docstring +help: Add `FasterThanLightError` to the docstring -DOC501_google.py:51:5: DOC501 Raised exception `ValueError` missing from docstring +DOC501 Raised exception `ValueError` missing from docstring + --> DOC501_google.py:51:5 | 49 | # DOC501 50 | def calculate_speed(distance: float, time: float) -> float: @@ -33,13 +35,14 @@ DOC501_google.py:51:5: DOC501 Raised exception `ValueError` missing from docstri 57 | | Returns: 58 | | Speed as distance divided by time. 59 | | """ - | |_______^ DOC501 + | |_______^ 60 | try: 61 | return distance / time | - = help: Add `ValueError` to the docstring +help: Add `ValueError` to the docstring -DOC501_google.py:51:5: DOC501 Raised exception `FasterThanLightError` missing from docstring +DOC501 Raised exception `FasterThanLightError` missing from docstring + --> DOC501_google.py:51:5 | 49 | # DOC501 50 | def calculate_speed(distance: float, time: float) -> float: @@ -52,13 +55,14 @@ DOC501_google.py:51:5: DOC501 Raised exception `FasterThanLightError` missing fr 57 | | Returns: 58 | | Speed as distance divided by time. 59 | | """ - | |_______^ DOC501 + | |_______^ 60 | try: 61 | return distance / time | - = help: Add `FasterThanLightError` to the docstring +help: Add `FasterThanLightError` to the docstring -DOC501_google.py:106:5: DOC501 Raised exception `AnotherError` missing from docstring +DOC501 Raised exception `AnotherError` missing from docstring + --> DOC501_google.py:106:5 | 104 | # DOC501 105 | def calculate_speed(distance: float, time: float) -> float: @@ -71,12 +75,13 @@ DOC501_google.py:106:5: DOC501 Raised exception `AnotherError` missing from docs 112 | | Returns: 113 | | Speed as distance divided by time. 114 | | """ - | |_______^ DOC501 + | |_______^ 115 | raise AnotherError | - = help: Add `AnotherError` to the docstring +help: Add `AnotherError` to the docstring -DOC501_google.py:120:5: DOC501 Raised exception `AnotherError` missing from docstring +DOC501 Raised exception `AnotherError` missing from docstring + --> DOC501_google.py:120:5 | 118 | # DOC501 119 | def calculate_speed(distance: float, time: float) -> float: @@ -89,12 +94,13 @@ DOC501_google.py:120:5: DOC501 Raised exception `AnotherError` missing from docs 126 | | Returns: 127 | | Speed as distance divided by time. 128 | | """ - | |_______^ DOC501 + | |_______^ 129 | raise AnotherError() | - = help: Add `AnotherError` to the docstring +help: Add `AnotherError` to the docstring -DOC501_google.py:134:5: DOC501 Raised exception `SomeError` missing from docstring +DOC501 Raised exception `SomeError` missing from docstring + --> DOC501_google.py:134:5 | 132 | # DOC501 133 | def foo(bar: int): @@ -103,12 +109,13 @@ DOC501_google.py:134:5: DOC501 Raised exception `SomeError` missing from docstri 136 | | Args: 137 | | bar: Bar. 138 | | """ - | |_______^ DOC501 + | |_______^ 139 | raise something.SomeError | - = help: Add `SomeError` to the docstring +help: Add `SomeError` to the docstring -DOC501_google.py:197:5: DOC501 Raised exception `ZeroDivisionError` missing from docstring +DOC501 Raised exception `ZeroDivisionError` missing from docstring + --> DOC501_google.py:197:5 | 195 | # DOC501 196 | def calculate_speed(distance: float, time: float) -> float: @@ -124,13 +131,14 @@ DOC501_google.py:197:5: DOC501 Raised exception `ZeroDivisionError` missing from 206 | | Raises: 207 | | TypeError: if you didn't pass a number for both parameters 208 | | """ - | |_______^ DOC501 + | |_______^ 209 | try: 210 | return distance / time | - = help: Add `ZeroDivisionError` to the docstring +help: Add `ZeroDivisionError` to the docstring -DOC501_google.py:238:5: DOC501 Raised exception `TypeError` missing from docstring +DOC501 Raised exception `TypeError` missing from docstring + --> DOC501_google.py:238:5 | 237 | def foo(): 238 | / """Foo. @@ -138,13 +146,14 @@ DOC501_google.py:238:5: DOC501 Raised exception `TypeError` missing from docstri 240 | | Returns: 241 | | 42: int. 242 | | """ - | |_______^ DOC501 + | |_______^ 243 | if True: 244 | raise TypeError # DOC501 | - = help: Add `TypeError` to the docstring +help: Add `TypeError` to the docstring -DOC501_google.py:238:5: DOC501 Raised exception `ValueError` missing from docstring +DOC501 Raised exception `ValueError` missing from docstring + --> DOC501_google.py:238:5 | 237 | def foo(): 238 | / """Foo. @@ -152,8 +161,8 @@ DOC501_google.py:238:5: DOC501 Raised exception `ValueError` missing from docstr 240 | | Returns: 241 | | 42: int. 242 | | """ - | |_______^ DOC501 + | |_______^ 243 | if True: 244 | raise TypeError # DOC501 | - = help: Add `ValueError` to the docstring +help: Add `ValueError` to the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_numpy.py.snap index 1a53bef11f..ceb2a0929c 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-exception_DOC501_numpy.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC501_numpy.py:35:5: DOC501 Raised exception `FasterThanLightError` missing from docstring +DOC501 Raised exception `FasterThanLightError` missing from docstring + --> DOC501_numpy.py:35:5 | 33 | # DOC501 34 | def calculate_speed(distance: float, time: float) -> float: @@ -20,13 +21,14 @@ DOC501_numpy.py:35:5: DOC501 Raised exception `FasterThanLightError` missing fro 47 | | float 48 | | Speed as distance divided by time. 49 | | """ - | |_______^ DOC501 + | |_______^ 50 | try: 51 | return distance / time | - = help: Add `FasterThanLightError` to the docstring +help: Add `FasterThanLightError` to the docstring -DOC501_numpy.py:58:5: DOC501 Raised exception `ValueError` missing from docstring +DOC501 Raised exception `ValueError` missing from docstring + --> DOC501_numpy.py:58:5 | 56 | # DOC501 57 | def calculate_speed(distance: float, time: float) -> float: @@ -45,13 +47,14 @@ DOC501_numpy.py:58:5: DOC501 Raised exception `ValueError` missing from docstrin 70 | | float 71 | | Speed as distance divided by time. 72 | | """ - | |_______^ DOC501 + | |_______^ 73 | try: 74 | return distance / time | - = help: Add `ValueError` to the docstring +help: Add `ValueError` to the docstring -DOC501_numpy.py:58:5: DOC501 Raised exception `FasterThanLightError` missing from docstring +DOC501 Raised exception `FasterThanLightError` missing from docstring + --> DOC501_numpy.py:58:5 | 56 | # DOC501 57 | def calculate_speed(distance: float, time: float) -> float: @@ -70,13 +73,14 @@ DOC501_numpy.py:58:5: DOC501 Raised exception `FasterThanLightError` missing fro 70 | | float 71 | | Speed as distance divided by time. 72 | | """ - | |_______^ DOC501 + | |_______^ 73 | try: 74 | return distance / time | - = help: Add `FasterThanLightError` to the docstring +help: Add `FasterThanLightError` to the docstring -DOC501_numpy.py:83:5: DOC501 Raised exception `TypeError` missing from docstring +DOC501 Raised exception `TypeError` missing from docstring + --> DOC501_numpy.py:83:5 | 81 | # DOC501 82 | def calculate_speed(distance: float, time: float) -> float: @@ -101,13 +105,14 @@ DOC501_numpy.py:83:5: DOC501 Raised exception `TypeError` missing from docstring 101 | | ZeroDivisionError 102 | | If attempting to divide by zero. 103 | | """ - | |_______^ DOC501 + | |_______^ 104 | try: 105 | return distance / time | - = help: Add `TypeError` to the docstring +help: Add `TypeError` to the docstring -DOC501_numpy.py:139:5: DOC501 Raised exception `TypeError` missing from docstring +DOC501 Raised exception `TypeError` missing from docstring + --> DOC501_numpy.py:139:5 | 138 | def foo(): 139 | / """Foo. @@ -117,13 +122,14 @@ DOC501_numpy.py:139:5: DOC501 Raised exception `TypeError` missing from docstrin 143 | | int 144 | | 42 145 | | """ - | |_______^ DOC501 + | |_______^ 146 | if True: 147 | raise TypeError # DOC501 | - = help: Add `TypeError` to the docstring +help: Add `TypeError` to the docstring -DOC501_numpy.py:139:5: DOC501 Raised exception `ValueError` missing from docstring +DOC501 Raised exception `ValueError` missing from docstring + --> DOC501_numpy.py:139:5 | 138 | def foo(): 139 | / """Foo. @@ -133,8 +139,8 @@ DOC501_numpy.py:139:5: DOC501 Raised exception `ValueError` missing from docstri 143 | | int 144 | | 42 145 | | """ - | |_______^ DOC501 + | |_______^ 146 | if True: 147 | raise TypeError # DOC501 | - = help: Add `ValueError` to the docstring +help: Add `ValueError` to the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py.snap index d074c17366..870a7f0dcd 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC201_google.py:3:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:3:5 | 1 | # DOC201 2 | def foo(num: int) -> str: @@ -11,12 +12,13 @@ DOC201_google.py:3:5: DOC201 `return` is not documented in docstring 6 | | Args: 7 | | num (int): A number 8 | | """ - | |_______^ DOC201 + | |_______^ 9 | return 'test' | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:44:9: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:44:9 | 42 | # DOC201 43 | def bar(self) -> str: @@ -26,32 +28,35 @@ DOC201_google.py:44:9: DOC201 `return` is not documented in docstring 47 | | Args: 48 | | num (int): A number 49 | | """ - | |___________^ DOC201 + | |___________^ 50 | return 'test' | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:70:9: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:70:9 | 68 | # DOC201 69 | def nested(): 70 | """Do something nested.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ DOC201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 71 | return 5 | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:120:9: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:120:9 | 118 | @abc.abstractmethod 119 | def f(self): 120 | """Lorem ipsum.""" - | ^^^^^^^^^^^^^^^^^^ DOC201 + | ^^^^^^^^^^^^^^^^^^ 121 | return True | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:178:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:178:5 | 176 | # DOC201 - non-early return explicit None 177 | def foo(x: int) -> int | None: @@ -60,13 +65,14 @@ DOC201_google.py:178:5: DOC201 `return` is not documented in docstring 180 | | Args: 181 | | x (int): An integer. 182 | | """ - | |_______^ DOC201 + | |_______^ 183 | if x < 0: 184 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:191:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:191:5 | 189 | # DOC201 - non-early return explicit None w/o useful type annotations 190 | def foo(x): @@ -75,13 +81,14 @@ DOC201_google.py:191:5: DOC201 `return` is not documented in docstring 193 | | Args: 194 | | x (int): An integer. 195 | | """ - | |_______^ DOC201 + | |_______^ 196 | if x < 0: 197 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:204:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:204:5 | 202 | # DOC201 - only returns None, but return annotation is not None 203 | def foo(s: str) -> str | None: @@ -90,7 +97,7 @@ DOC201_google.py:204:5: DOC201 `return` is not documented in docstring 206 | | Args: 207 | | s (str): A string. 208 | | """ - | |_______^ DOC201 + | |_______^ 209 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py_ignore_one_line.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py_ignore_one_line.snap index 87a9dd1aae..d91e58434f 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py_ignore_one_line.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_google.py_ignore_one_line.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC201_google.py:3:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:3:5 | 1 | # DOC201 2 | def foo(num: int) -> str: @@ -11,12 +12,13 @@ DOC201_google.py:3:5: DOC201 `return` is not documented in docstring 6 | | Args: 7 | | num (int): A number 8 | | """ - | |_______^ DOC201 + | |_______^ 9 | return 'test' | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:44:9: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:44:9 | 42 | # DOC201 43 | def bar(self) -> str: @@ -26,12 +28,13 @@ DOC201_google.py:44:9: DOC201 `return` is not documented in docstring 47 | | Args: 48 | | num (int): A number 49 | | """ - | |___________^ DOC201 + | |___________^ 50 | return 'test' | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:178:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:178:5 | 176 | # DOC201 - non-early return explicit None 177 | def foo(x: int) -> int | None: @@ -40,13 +43,14 @@ DOC201_google.py:178:5: DOC201 `return` is not documented in docstring 180 | | Args: 181 | | x (int): An integer. 182 | | """ - | |_______^ DOC201 + | |_______^ 183 | if x < 0: 184 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:191:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:191:5 | 189 | # DOC201 - non-early return explicit None w/o useful type annotations 190 | def foo(x): @@ -55,13 +59,14 @@ DOC201_google.py:191:5: DOC201 `return` is not documented in docstring 193 | | Args: 194 | | x (int): An integer. 195 | | """ - | |_______^ DOC201 + | |_______^ 196 | if x < 0: 197 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_google.py:204:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_google.py:204:5 | 202 | # DOC201 - only returns None, but return annotation is not None 203 | def foo(s: str) -> str | None: @@ -70,7 +75,7 @@ DOC201_google.py:204:5: DOC201 `return` is not documented in docstring 206 | | Args: 207 | | s (str): A string. 208 | | """ - | |_______^ DOC201 + | |_______^ 209 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_numpy.py.snap index b1b7071275..411fd78b08 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-returns_DOC201_numpy.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC201_numpy.py:3:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:3:5 | 1 | # DOC201 2 | def foo(num: int) -> str: @@ -13,12 +14,13 @@ DOC201_numpy.py:3:5: DOC201 `return` is not documented in docstring 8 | | num : int 9 | | A number 10 | | """ - | |_______^ DOC201 + | |_______^ 11 | return 'test' | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:54:9: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:54:9 | 52 | # DOC201 53 | def bar(self) -> str: @@ -30,22 +32,24 @@ DOC201_numpy.py:54:9: DOC201 `return` is not documented in docstring 59 | | num : int 60 | | A number 61 | | """ - | |___________^ DOC201 + | |___________^ 62 | return 'test' | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:86:9: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:86:9 | 84 | @abc.abstractmethod 85 | def f(self): 86 | """Lorem ipsum.""" - | ^^^^^^^^^^^^^^^^^^ DOC201 + | ^^^^^^^^^^^^^^^^^^ 87 | return True | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:152:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:152:5 | 150 | # DOC201 - non-early return explicit None 151 | def foo(x: int) -> int | None: @@ -56,13 +60,14 @@ DOC201_numpy.py:152:5: DOC201 `return` is not documented in docstring 156 | | x : int 157 | | An integer. 158 | | """ - | |_______^ DOC201 + | |_______^ 159 | if x < 0: 160 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:167:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:167:5 | 165 | # DOC201 - non-early return explicit None w/o useful type annotations 166 | def foo(x): @@ -73,13 +78,14 @@ DOC201_numpy.py:167:5: DOC201 `return` is not documented in docstring 171 | | x : int 172 | | An integer. 173 | | """ - | |_______^ DOC201 + | |_______^ 174 | if x < 0: 175 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:182:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:182:5 | 180 | # DOC201 - only returns None, but return annotation is not None 181 | def foo(s: str) -> str | None: @@ -90,49 +96,53 @@ DOC201_numpy.py:182:5: DOC201 `return` is not documented in docstring 186 | | x : str 187 | | A string. 188 | | """ - | |_______^ DOC201 + | |_______^ 189 | return None | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:194:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:194:5 | 192 | # DOC201 193 | def bar() -> int | None: 194 | """Bar-y method""" - | ^^^^^^^^^^^^^^^^^^ DOC201 + | ^^^^^^^^^^^^^^^^^^ 195 | return | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:220:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:220:5 | 218 | # indicates it could sometimes return `int` 219 | def generator_function_3() -> Generator[str, None, int | None]: 220 | """Generate some strings""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ DOC201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 221 | yield from "abc" 222 | return | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:228:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:228:5 | 226 | # indicates it could sometimes return `int` 227 | def generator_function_4(): 228 | """Generate some strings""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ DOC201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 229 | yield from "abc" 230 | return 42 | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring -DOC201_numpy.py:235:5: DOC201 `return` is not documented in docstring +DOC201 `return` is not documented in docstring + --> DOC201_numpy.py:235:5 | 233 | # DOC201 -- no `yield` expressions, so not a generator function 234 | def not_a_generator() -> Iterator[int]: 235 | """"No returns documented here, oh no""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DOC201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 236 | return (x for x in range(42)) | - = help: Add a "Returns" section to the docstring +help: Add a "Returns" section to the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py.snap index 0f1e8d8988..3709ce382b 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC402_google.py:3:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_google.py:3:5 | 1 | # DOC402 2 | def foo(num: int) -> str: @@ -11,12 +12,13 @@ DOC402_google.py:3:5: DOC402 `yield` is not documented in docstring 6 | | Args: 7 | | num (int): A number 8 | | """ - | |_______^ DOC402 + | |_______^ 9 | yield 'test' | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_google.py:44:9: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_google.py:44:9 | 42 | # DOC402 43 | def bar(self) -> str: @@ -26,51 +28,55 @@ DOC402_google.py:44:9: DOC402 `yield` is not documented in docstring 47 | | Args: 48 | | num (int): A number 49 | | """ - | |___________^ DOC402 + | |___________^ 50 | yield 'test' | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_google.py:58:9: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_google.py:58:9 | 56 | # DOC402 57 | def nested(): 58 | """Do something nested.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ DOC402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 59 | yield 5 | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_google.py:66:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_google.py:66:5 | 64 | # DOC402 65 | def test(): 66 | """Do something.""" - | ^^^^^^^^^^^^^^^^^^^ DOC402 + | ^^^^^^^^^^^^^^^^^^^ 67 | yield from range(10) | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_google.py:97:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_google.py:97:5 | 95 | # DOC402 96 | def foo() -> collections.abc.Generator[int | None, None, None]: 97 | / """ 98 | | Do something 99 | | """ - | |_______^ DOC402 + | |_______^ 100 | yield | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_google.py:105:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_google.py:105:5 | 103 | # DOC402 104 | def bar() -> collections.abc.Iterator[int | None]: 105 | / """ 106 | | Do something 107 | | """ - | |_______^ DOC402 + | |_______^ 108 | yield | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py_ignore_one_line.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py_ignore_one_line.snap index def7f04c9d..bf09f8e40a 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py_ignore_one_line.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_google.py_ignore_one_line.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC402_google.py:3:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_google.py:3:5 | 1 | # DOC402 2 | def foo(num: int) -> str: @@ -11,12 +12,13 @@ DOC402_google.py:3:5: DOC402 `yield` is not documented in docstring 6 | | Args: 7 | | num (int): A number 8 | | """ - | |_______^ DOC402 + | |_______^ 9 | yield 'test' | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_google.py:44:9: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_google.py:44:9 | 42 | # DOC402 43 | def bar(self) -> str: @@ -26,7 +28,7 @@ DOC402_google.py:44:9: DOC402 `yield` is not documented in docstring 47 | | Args: 48 | | num (int): A number 49 | | """ - | |___________^ DOC402 + | |___________^ 50 | yield 'test' | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring diff --git a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_numpy.py.snap b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_numpy.py.snap index 6089267205..55e444596a 100644 --- a/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_numpy.py.snap +++ b/crates/ruff_linter/src/rules/pydoclint/snapshots/ruff_linter__rules__pydoclint__tests__docstring-missing-yields_DOC402_numpy.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydoclint/mod.rs --- -DOC402_numpy.py:3:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_numpy.py:3:5 | 1 | # DOC402 2 | def foo(num: int) -> str: @@ -13,12 +14,13 @@ DOC402_numpy.py:3:5: DOC402 `yield` is not documented in docstring 8 | | num : int 9 | | A number 10 | | """ - | |_______^ DOC402 + | |_______^ 11 | yield 'test' | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_numpy.py:54:9: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_numpy.py:54:9 | 52 | # DOC402 53 | def bar(self) -> str: @@ -30,70 +32,75 @@ DOC402_numpy.py:54:9: DOC402 `yield` is not documented in docstring 59 | | num : int 60 | | A number 61 | | """ - | |___________^ DOC402 + | |___________^ 62 | yield 'test' | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_numpy.py:86:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_numpy.py:86:5 | 84 | # DOC402 85 | def foo() -> typing.Generator[int | None, None, None]: 86 | / """ 87 | | Do something 88 | | """ - | |_______^ DOC402 + | |_______^ 89 | yield None 90 | yield 1 | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_numpy.py:95:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_numpy.py:95:5 | 93 | # DOC402 94 | def foo() -> typing.Generator[int, None, None]: 95 | / """ 96 | | Do something 97 | | """ - | |_______^ DOC402 + | |_______^ 98 | yield None | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_numpy.py:119:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_numpy.py:119:5 | 117 | # DOC402 118 | def foo(): 119 | / """ 120 | | Do something 121 | | """ - | |_______^ DOC402 + | |_______^ 122 | yield None 123 | yield 1 | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_numpy.py:128:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_numpy.py:128:5 | 126 | # DOC402 127 | def foo(): 128 | / """ 129 | | Do something 130 | | """ - | |_______^ DOC402 + | |_______^ 131 | yield 1 132 | yield | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring -DOC402_numpy.py:137:5: DOC402 `yield` is not documented in docstring +DOC402 `yield` is not documented in docstring + --> DOC402_numpy.py:137:5 | 135 | # DOC402 136 | def bar() -> typing.Iterator[int | None]: 137 | / """ 138 | | Do something 139 | | """ - | |_______^ DOC402 + | |_______^ 140 | yield | - = help: Add a "Yields" section to the docstring +help: Add a "Yields" section to the docstring diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100_D.py.snap index 9c1041221e..645d4ed7a0 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100_D.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D.py:1:1: D100 Missing docstring in public module +D100 Missing docstring in public module +--> D.py:1:1 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap index ba3592fc30..91e675d4f8 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D100_pub.py:1:1: D100 Missing docstring in public module +D100 Missing docstring in public module +--> D100_pub.py:1:1 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap index c8cf6f9ab7..1997a29cc2 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:15:7: D101 Missing docstring in public class +D101 Missing docstring in public class + --> D.py:15:7 | 15 | class class_: - | ^^^^^^ D101 + | ^^^^^^ 16 | 17 | expect('meta', 'D419: Docstring is empty') | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_D.py.snap index 5528751f71..8368145076 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_D.py.snap @@ -1,45 +1,49 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D.py:23:9: D102 Missing docstring in public method +D102 Missing docstring in public method + --> D.py:23:9 | 22 | @expect('D102: Missing docstring in public method') 23 | def method(self=None): - | ^^^^^^ D102 + | ^^^^^^ 24 | pass | -D.py:56:9: D102 Missing docstring in public method +D102 Missing docstring in public method + --> D.py:56:9 | 55 | @expect('D102: Missing docstring in public method') 56 | def __new__(self=None): - | ^^^^^^^ D102 + | ^^^^^^^ 57 | pass | -D.py:68:9: D102 Missing docstring in public method +D102 Missing docstring in public method + --> D.py:68:9 | 67 | @expect('D102: Missing docstring in public method') 68 | def __call__(self=None, x=None, y=None, z=None): - | ^^^^^^^^ D102 + | ^^^^^^^^ 69 | pass | -D.py:650:9: D102 Missing docstring in public method +D102 Missing docstring in public method + --> D.py:650:9 | 648 | class StatementOnSameLineAsDocstring: 649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 650 | def sort_services(self): - | ^^^^^^^^^^^^^ D102 + | ^^^^^^^^^^^^^ 651 | pass | -D.py:659:9: D102 Missing docstring in public method +D102 Missing docstring in public method + --> D.py:659:9 | 657 | class CommentAfterDocstring: 658 | "After this docstring there's a comment." # priorities=1 659 | def sort_services(self): - | ^^^^^^^^^^^^^ D102 + | ^^^^^^^^^^^^^ 660 | pass | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_setter.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_setter.py.snap index 7a9a4a2c13..576114ab6c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_setter.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_setter.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -setter.py:16:9: D102 Missing docstring in public method +D102 Missing docstring in public method + --> setter.py:16:9 | 15 | @foo 16 | def foo(self, value: str) -> None: - | ^^^ D102 + | ^^^ 17 | pass | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D103_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D103_D.py.snap index 3d9711e703..a284864e47 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D103_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D103_D.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D.py:400:5: D103 Missing docstring in public function +D103 Missing docstring in public function + --> D.py:400:5 | 399 | @expect("D103: Missing docstring in public function") 400 | def oneliner_d102(): return - | ^^^^^^^^^^^^^ D103 + | ^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D104____init__.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D104____init__.py.snap index 25f47b66c0..6baa171cf8 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D104____init__.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D104____init__.py.snap @@ -1,5 +1,5 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -__init__.py:1:1: D104 Missing docstring in public package +D104 Missing docstring in public package +--> __init__.py:1:1 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D105_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D105_D.py.snap index 4b8945a3c2..08833a5f37 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D105_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D105_D.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D.py:64:9: D105 Missing docstring in magic method +D105 Missing docstring in magic method + --> D.py:64:9 | 63 | @expect('D105: Missing docstring in magic method') 64 | def __str__(self=None): - | ^^^^^^^ D105 + | ^^^^^^^ 65 | pass | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap index 6fd782e2ce..89e96e38d2 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap @@ -1,19 +1,21 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:60:9: D107 Missing docstring in `__init__` +D107 Missing docstring in `__init__` + --> D.py:60:9 | 59 | @expect('D107: Missing docstring in __init__') 60 | def __init__(self=None): - | ^^^^^^^^ D107 + | ^^^^^^^^ 61 | pass | -D.py:534:9: D107 Missing docstring in `__init__` +D107 Missing docstring in `__init__` + --> D.py:534:9 | 532 | """ 533 | 534 | def __init__(self, x): - | ^^^^^^^^ D107 + | ^^^^^^^^ 535 | pass | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap index da2a88322f..89eb2e2bb2 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:129:5: D200 [*] One-line docstring should fit on one line +D200 [*] One-line docstring should fit on one line + --> D.py:129:5 | 127 | @expect('D212: Multi-line docstring summary should start at the first line') 128 | def asdlkfasd(): 129 | / """ 130 | | Wrong. 131 | | """ - | |_______^ D200 + | |_______^ | - = help: Reformat to one line +help: Reformat to one line ℹ Unsafe fix 126 126 | '(found 3)') @@ -24,16 +25,17 @@ D.py:129:5: D200 [*] One-line docstring should fit on one line 133 131 | 134 132 | @expect('D201: No blank lines allowed before function docstring (found 1)') -D.py:597:5: D200 [*] One-line docstring should fit on one line +D200 [*] One-line docstring should fit on one line + --> D.py:597:5 | 595 | @expect('D212: Multi-line docstring summary should start at the first line') 596 | def one_liner(): 597 | / """ 598 | | 599 | | Wrong.""" - | |_____________^ D200 + | |_____________^ | - = help: Reformat to one line +help: Reformat to one line ℹ Unsafe fix 594 594 | '(found 3)') @@ -47,16 +49,17 @@ D.py:597:5: D200 [*] One-line docstring should fit on one line 601 599 | 602 600 | @expect('D200: One-line docstring should fit on one line with quotes ' -D.py:606:5: D200 [*] One-line docstring should fit on one line +D200 [*] One-line docstring should fit on one line + --> D.py:606:5 | 604 | @expect('D212: Multi-line docstring summary should start at the first line') 605 | def one_liner(): 606 | / r"""Wrong. 607 | | 608 | | """ - | |_______^ D200 + | |_______^ | - = help: Reformat to one line +help: Reformat to one line ℹ Unsafe fix 603 603 | '(found 3)') @@ -70,35 +73,38 @@ D.py:606:5: D200 [*] One-line docstring should fit on one line 610 608 | 611 609 | @expect('D200: One-line docstring should fit on one line with quotes ' -D.py:615:5: D200 One-line docstring should fit on one line +D200 One-line docstring should fit on one line + --> D.py:615:5 | 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 | def one_liner(): 615 | / """Wrong." 616 | | 617 | | """ - | |_______^ D200 + | |_______^ | - = help: Reformat to one line +help: Reformat to one line -D.py:624:5: D200 One-line docstring should fit on one line +D200 One-line docstring should fit on one line + --> D.py:624:5 | 622 | @expect('D212: Multi-line docstring summary should start at the first line') 623 | def one_liner(): 624 | / """ 625 | | 626 | | "Wrong.""" - | |______________^ D200 + | |______________^ | - = help: Reformat to one line +help: Reformat to one line -D.py:645:5: D200 One-line docstring should fit on one line +D200 One-line docstring should fit on one line + --> D.py:645:5 | 644 | def single_line_docstring_with_an_escaped_backslash(): 645 | / "\ 646 | | " - | |_____^ D200 + | |_____^ 647 | 648 | class StatementOnSameLineAsDocstring: | - = help: Reformat to one line +help: Reformat to one line diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap index 5a77be7454..0ab129407c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap @@ -1,23 +1,25 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D200.py:2:5: D200 One-line docstring should fit on one line +D200 One-line docstring should fit on one line + --> D200.py:2:5 | 1 | def func(): 2 | / """\ 3 | | """ - | |_______^ D200 + | |_______^ | - = help: Reformat to one line +help: Reformat to one line -D200.py:7:5: D200 [*] One-line docstring should fit on one line +D200 [*] One-line docstring should fit on one line + --> D200.py:7:5 | 6 | def func(): 7 | / """\\ 8 | | """ - | |_______^ D200 + | |_______^ | - = help: Reformat to one line +help: Reformat to one line ℹ Unsafe fix 4 4 | @@ -30,11 +32,12 @@ D200.py:7:5: D200 [*] One-line docstring should fit on one line 10 9 | 11 10 | def func(): -D200.py:12:5: D200 One-line docstring should fit on one line +D200 One-line docstring should fit on one line + --> D200.py:12:5 | 11 | def func(): 12 | / """\ \ 13 | | """ - | |_______^ D200 + | |_______^ | - = help: Reformat to one line +help: Reformat to one line diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap index 98a7e7e11e..552f29e140 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:137:5: D201 [*] No blank lines allowed before function docstring (found 1) +D201 [*] No blank lines allowed before function docstring (found 1) + --> D.py:137:5 | 135 | def leading_space(): 136 | 137 | """Leading space.""" - | ^^^^^^^^^^^^^^^^^^^^ D201 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Remove blank line(s) before function docstring +help: Remove blank line(s) before function docstring ℹ Safe fix 133 133 | @@ -19,16 +20,17 @@ D.py:137:5: D201 [*] No blank lines allowed before function docstring (found 1) 138 137 | 139 138 | -D.py:151:5: D201 [*] No blank lines allowed before function docstring (found 1) +D201 [*] No blank lines allowed before function docstring (found 1) + --> D.py:151:5 | 149 | def trailing_and_leading_space(): 150 | 151 | """Trailing and leading space.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 152 | 153 | pass | - = help: Remove blank line(s) before function docstring +help: Remove blank line(s) before function docstring ℹ Safe fix 147 147 | @expect('D201: No blank lines allowed before function docstring (found 1)') @@ -39,7 +41,8 @@ D.py:151:5: D201 [*] No blank lines allowed before function docstring (found 1) 152 151 | 153 152 | pass -D.py:546:5: D201 [*] No blank lines allowed before function docstring (found 1) +D201 [*] No blank lines allowed before function docstring (found 1) + --> D.py:546:5 | 544 | def multiline_leading_space(): 545 | @@ -47,9 +50,9 @@ D.py:546:5: D201 [*] No blank lines allowed before function docstring (found 1) 547 | | 548 | | More content. 549 | | """ - | |_______^ D201 + | |_______^ | - = help: Remove blank line(s) before function docstring +help: Remove blank line(s) before function docstring ℹ Safe fix 542 542 | @expect('D201: No blank lines allowed before function docstring (found 1)') @@ -60,7 +63,8 @@ D.py:546:5: D201 [*] No blank lines allowed before function docstring (found 1) 547 546 | 548 547 | More content. -D.py:568:5: D201 [*] No blank lines allowed before function docstring (found 1) +D201 [*] No blank lines allowed before function docstring (found 1) + --> D.py:568:5 | 566 | def multiline_trailing_and_leading_space(): 567 | @@ -68,11 +72,11 @@ D.py:568:5: D201 [*] No blank lines allowed before function docstring (found 1) 569 | | 570 | | More content. 571 | | """ - | |_______^ D201 + | |_______^ 572 | 573 | pass | - = help: Remove blank line(s) before function docstring +help: Remove blank line(s) before function docstring ℹ Safe fix 564 564 | @expect('D202: No blank lines allowed after function docstring (found 1)') @@ -83,13 +87,14 @@ D.py:568:5: D201 [*] No blank lines allowed before function docstring (found 1) 569 568 | 570 569 | More content. -D.py:729:5: D201 No blank lines allowed before function docstring (found 1) +D201 No blank lines allowed before function docstring (found 1) + --> D.py:729:5 | 727 | def line_continuation_chars():\ 728 | 729 | """No fix should be offered for D201/D202 because of the line continuation chars."""\ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 730 | 731 | ... | - = help: Remove blank line(s) before function docstring +help: Remove blank line(s) before function docstring diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap index d234ae1d62..c41685f416 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:142:5: D202 [*] No blank lines allowed after function docstring (found 1) +D202 [*] No blank lines allowed after function docstring (found 1) + --> D.py:142:5 | 140 | @expect('D202: No blank lines allowed after function docstring (found 1)') 141 | def trailing_space(): 142 | """Leading space.""" - | ^^^^^^^^^^^^^^^^^^^^ D202 + | ^^^^^^^^^^^^^^^^^^^^ 143 | 144 | pass | - = help: Remove blank line(s) after function docstring +help: Remove blank line(s) after function docstring ℹ Safe fix 140 140 | @expect('D202: No blank lines allowed after function docstring (found 1)') @@ -21,16 +22,17 @@ D.py:142:5: D202 [*] No blank lines allowed after function docstring (found 1) 145 144 | 146 145 | -D.py:151:5: D202 [*] No blank lines allowed after function docstring (found 1) +D202 [*] No blank lines allowed after function docstring (found 1) + --> D.py:151:5 | 149 | def trailing_and_leading_space(): 150 | 151 | """Trailing and leading space.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 152 | 153 | pass | - = help: Remove blank line(s) after function docstring +help: Remove blank line(s) after function docstring ℹ Safe fix 149 149 | def trailing_and_leading_space(): @@ -41,7 +43,8 @@ D.py:151:5: D202 [*] No blank lines allowed after function docstring (found 1) 154 153 | 155 154 | -D.py:555:5: D202 [*] No blank lines allowed after function docstring (found 1) +D202 [*] No blank lines allowed after function docstring (found 1) + --> D.py:555:5 | 553 | @expect('D213: Multi-line docstring summary should start at the second line') 554 | def multiline_trailing_space(): @@ -49,11 +52,11 @@ D.py:555:5: D202 [*] No blank lines allowed after function docstring (found 1) 556 | | 557 | | More content. 558 | | """ - | |_______^ D202 + | |_______^ 559 | 560 | pass | - = help: Remove blank line(s) after function docstring +help: Remove blank line(s) after function docstring ℹ Safe fix 556 556 | @@ -64,7 +67,8 @@ D.py:555:5: D202 [*] No blank lines allowed after function docstring (found 1) 561 560 | 562 561 | -D.py:568:5: D202 [*] No blank lines allowed after function docstring (found 1) +D202 [*] No blank lines allowed after function docstring (found 1) + --> D.py:568:5 | 566 | def multiline_trailing_and_leading_space(): 567 | @@ -72,11 +76,11 @@ D.py:568:5: D202 [*] No blank lines allowed after function docstring (found 1) 569 | | 570 | | More content. 571 | | """ - | |_______^ D202 + | |_______^ 572 | 573 | pass | - = help: Remove blank line(s) after function docstring +help: Remove blank line(s) after function docstring ℹ Safe fix 569 569 | @@ -87,13 +91,14 @@ D.py:568:5: D202 [*] No blank lines allowed after function docstring (found 1) 574 573 | 575 574 | -D.py:729:5: D202 No blank lines allowed after function docstring (found 1) +D202 No blank lines allowed after function docstring (found 1) + --> D.py:729:5 | 727 | def line_continuation_chars():\ 728 | 729 | """No fix should be offered for D201/D202 because of the line continuation chars."""\ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 730 | 731 | ... | - = help: Remove blank line(s) after function docstring +help: Remove blank line(s) after function docstring diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap index 5d400736ed..2212f54da7 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D202.py:57:5: D202 [*] No blank lines allowed after function docstring (found 2) +D202 [*] No blank lines allowed after function docstring (found 2) + --> D202.py:57:5 | 55 | # D202 56 | def outer(): 57 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove blank line(s) after function docstring +help: Remove blank line(s) after function docstring ℹ Safe fix 55 55 | # D202 @@ -20,14 +21,15 @@ D202.py:57:5: D202 [*] No blank lines allowed after function docstring (found 2) 61 59 | return 62 60 | -D202.py:68:5: D202 [*] No blank lines allowed after function docstring (found 2) +D202 [*] No blank lines allowed after function docstring (found 2) + --> D202.py:68:5 | 66 | # D202 67 | def outer(): 68 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove blank line(s) after function docstring +help: Remove blank line(s) after function docstring ℹ Safe fix 66 66 | # D202 @@ -39,16 +41,17 @@ D202.py:68:5: D202 [*] No blank lines allowed after function docstring (found 2) 72 70 | def inner(): 73 71 | return -D202.py:80:5: D202 [*] No blank lines allowed after function docstring (found 1) +D202 [*] No blank lines allowed after function docstring (found 1) + --> D202.py:80:5 | 78 | # D202 79 | def outer(): 80 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 81 | 82 | # This is a comment. | - = help: Remove blank line(s) after function docstring +help: Remove blank line(s) after function docstring ℹ Safe fix 78 78 | # D202 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap index 741f6b8bb2..d8aaf746a0 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:161:5: D203 [*] 1 blank line required before class docstring +D203 [*] 1 blank line required before class docstring + --> D.py:161:5 | 160 | class LeadingSpaceMissing: 161 | """Leading space missing.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Insert 1 blank line before class docstring +help: Insert 1 blank line before class docstring ℹ Safe fix 158 158 | @@ -18,14 +19,15 @@ D.py:161:5: D203 [*] 1 blank line required before class docstring 162 163 | 163 164 | -D.py:192:5: D203 [*] 1 blank line required before class docstring +D203 [*] 1 blank line required before class docstring + --> D.py:192:5 | 191 | class LeadingAndTrailingSpaceMissing: 192 | """Leading and trailing space missing.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 193 | pass | - = help: Insert 1 blank line before class docstring +help: Insert 1 blank line before class docstring ℹ Safe fix 189 189 | @@ -36,7 +38,8 @@ D.py:192:5: D203 [*] 1 blank line required before class docstring 193 194 | pass 194 195 | -D.py:526:5: D203 [*] 1 blank line required before class docstring +D203 [*] 1 blank line required before class docstring + --> D.py:526:5 | 524 | # parameters as functions for Google / Numpy conventions. 525 | class Blah: # noqa: D203,D213 @@ -47,11 +50,11 @@ D.py:526:5: D203 [*] 1 blank line required before class docstring 530 | | x : int 531 | | 532 | | """ - | |_______^ D203 + | |_______^ 533 | 534 | def __init__(self, x): | - = help: Insert 1 blank line before class docstring +help: Insert 1 blank line before class docstring ℹ Safe fix 523 523 | # This is reproducing a bug where AttributeError is raised when parsing class @@ -62,15 +65,16 @@ D.py:526:5: D203 [*] 1 blank line required before class docstring 527 528 | 528 529 | Parameters -D.py:649:5: D203 [*] 1 blank line required before class docstring +D203 [*] 1 blank line required before class docstring + --> D.py:649:5 | 648 | class StatementOnSameLineAsDocstring: 649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 650 | def sort_services(self): 651 | pass | - = help: Insert 1 blank line before class docstring +help: Insert 1 blank line before class docstring ℹ Safe fix 646 646 | " @@ -81,13 +85,14 @@ D.py:649:5: D203 [*] 1 blank line required before class docstring 650 651 | def sort_services(self): 651 652 | pass -D.py:654:5: D203 [*] 1 blank line required before class docstring +D203 [*] 1 blank line required before class docstring + --> D.py:654:5 | 653 | class StatementOnSameLineAsDocstring: 654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Insert 1 blank line before class docstring +help: Insert 1 blank line before class docstring ℹ Safe fix 651 651 | pass @@ -98,15 +103,16 @@ D.py:654:5: D203 [*] 1 blank line required before class docstring 655 656 | 656 657 | -D.py:658:5: D203 [*] 1 blank line required before class docstring +D203 [*] 1 blank line required before class docstring + --> D.py:658:5 | 657 | class CommentAfterDocstring: 658 | "After this docstring there's a comment." # priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 659 | def sort_services(self): 660 | pass | - = help: Insert 1 blank line before class docstring +help: Insert 1 blank line before class docstring ℹ Safe fix 655 655 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap index 8f7d860a3c..5bdd5f22e7 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:181:5: D204 [*] 1 blank line required after class docstring +D204 [*] 1 blank line required after class docstring + --> D.py:181:5 | 179 | class TrailingSpace: 180 | 181 | """TrailingSpace.""" - | ^^^^^^^^^^^^^^^^^^^^ D204 + | ^^^^^^^^^^^^^^^^^^^^ 182 | pass | - = help: Insert 1 blank line after class docstring +help: Insert 1 blank line after class docstring ℹ Safe fix 179 179 | class TrailingSpace: @@ -20,14 +21,15 @@ D.py:181:5: D204 [*] 1 blank line required after class docstring 183 184 | 184 185 | -D.py:192:5: D204 [*] 1 blank line required after class docstring +D204 [*] 1 blank line required after class docstring + --> D.py:192:5 | 191 | class LeadingAndTrailingSpaceMissing: 192 | """Leading and trailing space missing.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 193 | pass | - = help: Insert 1 blank line after class docstring +help: Insert 1 blank line after class docstring ℹ Safe fix 190 190 | @@ -38,15 +40,16 @@ D.py:192:5: D204 [*] 1 blank line required after class docstring 194 195 | 195 196 | -D.py:649:5: D204 [*] 1 blank line required after class docstring +D204 [*] 1 blank line required after class docstring + --> D.py:649:5 | 648 | class StatementOnSameLineAsDocstring: 649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 650 | def sort_services(self): 651 | pass | - = help: Insert 1 blank line after class docstring +help: Insert 1 blank line after class docstring ℹ Safe fix 646 646 | " @@ -60,13 +63,14 @@ D.py:649:5: D204 [*] 1 blank line required after class docstring 651 653 | pass 652 654 | -D.py:654:5: D204 [*] 1 blank line required after class docstring +D204 [*] 1 blank line required after class docstring + --> D.py:654:5 | 653 | class StatementOnSameLineAsDocstring: 654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Insert 1 blank line after class docstring +help: Insert 1 blank line after class docstring ℹ Safe fix 651 651 | pass @@ -80,15 +84,16 @@ D.py:654:5: D204 [*] 1 blank line required after class docstring 656 658 | 657 659 | class CommentAfterDocstring: -D.py:658:5: D204 [*] 1 blank line required after class docstring +D204 [*] 1 blank line required after class docstring + --> D.py:658:5 | 657 | class CommentAfterDocstring: 658 | "After this docstring there's a comment." # priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 659 | def sort_services(self): 660 | pass | - = help: Insert 1 blank line after class docstring +help: Insert 1 blank line after class docstring ℹ Safe fix 656 656 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap index 3c6ca20580..417c81ed81 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:200:5: D205 1 blank line required between summary line and description +D205 1 blank line required between summary line and description + --> D.py:200:5 | 198 | @expect('D213: Multi-line docstring summary should start at the second line') 199 | def multi_line_zero_separating_blanks(): @@ -9,11 +10,12 @@ D.py:200:5: D205 1 blank line required between summary line and description 201 | | Description. 202 | | 203 | | """ - | |_______^ D205 + | |_______^ | - = help: Insert single blank line +help: Insert single blank line -D.py:210:5: D205 [*] 1 blank line required between summary line and description (found 2) +D205 [*] 1 blank line required between summary line and description (found 2) + --> D.py:210:5 | 208 | @expect('D213: Multi-line docstring summary should start at the second line') 209 | def multi_line_two_separating_blanks(): @@ -23,9 +25,9 @@ D.py:210:5: D205 [*] 1 blank line required between summary line and description 213 | | Description. 214 | | 215 | | """ - | |_______^ D205 + | |_______^ | - = help: Insert single blank line +help: Insert single blank line ℹ Safe fix 209 209 | def multi_line_two_separating_blanks(): diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap index e06aa71405..0865368e89 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:232:1: D207 [*] Docstring is under-indented +D207 [*] Docstring is under-indented + --> D.py:232:1 | 230 | """Summary. 231 | 232 | Description. - | ^ D207 + | ^ 233 | 234 | """ | - = help: Increase indentation +help: Increase indentation ℹ Safe fix 229 229 | def asdfsdf(): @@ -22,14 +23,15 @@ D.py:232:1: D207 [*] Docstring is under-indented 234 234 | """ 235 235 | -D.py:244:1: D207 [*] Docstring is under-indented +D207 [*] Docstring is under-indented + --> D.py:244:1 | 242 | Description. 243 | 244 | """ - | ^ D207 + | ^ | - = help: Increase indentation +help: Increase indentation ℹ Safe fix 241 241 | @@ -41,15 +43,16 @@ D.py:244:1: D207 [*] Docstring is under-indented 246 246 | 247 247 | @expect('D208: Docstring is over-indented') -D.py:440:1: D207 [*] Docstring is under-indented +D207 [*] Docstring is under-indented + --> D.py:440:1 | 438 | def docstring_start_in_same_line(): """First Line. 439 | 440 | Second Line - | ^ D207 + | ^ 441 | """ | - = help: Increase indentation +help: Increase indentation ℹ Safe fix 437 437 | @expect('D213: Multi-line docstring summary should start at the second line') @@ -61,13 +64,14 @@ D.py:440:1: D207 [*] Docstring is under-indented 442 442 | 443 443 | -D.py:441:1: D207 [*] Docstring is under-indented +D207 [*] Docstring is under-indented + --> D.py:441:1 | 440 | Second Line 441 | """ - | ^ D207 + | ^ | - = help: Increase indentation +help: Increase indentation ℹ Safe fix 438 438 | def docstring_start_in_same_line(): """First Line. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap index acf0b91d6c..c54989a221 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:252:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:252:1 | 250 | """Summary. 251 | 252 | Description. - | ^ D208 + | ^ 253 | 254 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 249 249 | def asdfsdsdf24(): @@ -22,14 +23,15 @@ D.py:252:1: D208 [*] Docstring is over-indented 254 254 | """ 255 255 | -D.py:264:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:264:1 | 262 | Description. 263 | 264 | """ - | ^ D208 + | ^ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 261 261 | @@ -41,16 +43,17 @@ D.py:264:1: D208 [*] Docstring is over-indented 266 266 | 267 267 | @expect('D208: Docstring is over-indented') -D.py:272:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:272:1 | 270 | """Summary. 271 | 272 | Description. - | ^ D208 + | ^ 273 | 274 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 269 269 | def asdfsdfsdsdsdfsdf24(): @@ -62,16 +65,17 @@ D.py:272:1: D208 [*] Docstring is over-indented 274 274 | """ 275 275 | -D.py:673:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:673:1 | 671 | """Summary. 672 | 673 | This is overindented - | ^ D208 + | ^ 674 | And so is this, but it we should preserve the extra space on this line relative 675 | to the one before | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 670 670 | def retain_extra_whitespace(): @@ -83,15 +87,16 @@ D.py:673:1: D208 [*] Docstring is over-indented 675 675 | to the one before 676 676 | """ -D.py:674:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:674:1 | 673 | This is overindented 674 | And so is this, but it we should preserve the extra space on this line relative - | ^ D208 + | ^ 675 | to the one before 676 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 671 671 | """Summary. @@ -103,15 +108,16 @@ D.py:674:1: D208 [*] Docstring is over-indented 676 676 | """ 677 677 | -D.py:675:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:675:1 | 673 | This is overindented 674 | And so is this, but it we should preserve the extra space on this line relative 675 | to the one before - | ^ D208 + | ^ 676 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 672 672 | @@ -123,16 +129,17 @@ D.py:675:1: D208 [*] Docstring is over-indented 677 677 | 678 678 | -D.py:682:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:682:1 | 680 | """Summary. 681 | 682 | This is overindented - | ^ D208 + | ^ 683 | And so is this, but it we should preserve the extra space on this line relative 684 | to the one before | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 679 679 | def retain_extra_whitespace_multiple(): @@ -144,15 +151,16 @@ D.py:682:1: D208 [*] Docstring is over-indented 684 684 | to the one before 685 685 | This is also overindented -D.py:683:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:683:1 | 682 | This is overindented 683 | And so is this, but it we should preserve the extra space on this line relative - | ^ D208 + | ^ 684 | to the one before 685 | This is also overindented | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 680 680 | """Summary. @@ -164,16 +172,17 @@ D.py:683:1: D208 [*] Docstring is over-indented 685 685 | This is also overindented 686 686 | And so is this, but it we should preserve the extra space on this line relative -D.py:684:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:684:1 | 682 | This is overindented 683 | And so is this, but it we should preserve the extra space on this line relative 684 | to the one before - | ^ D208 + | ^ 685 | This is also overindented 686 | And so is this, but it we should preserve the extra space on this line relative | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 681 681 | @@ -185,16 +194,17 @@ D.py:684:1: D208 [*] Docstring is over-indented 686 686 | And so is this, but it we should preserve the extra space on this line relative 687 687 | to the one before -D.py:685:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:685:1 | 683 | And so is this, but it we should preserve the extra space on this line relative 684 | to the one before 685 | This is also overindented - | ^ D208 + | ^ 686 | And so is this, but it we should preserve the extra space on this line relative 687 | to the one before | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 682 682 | This is overindented @@ -206,16 +216,17 @@ D.py:685:1: D208 [*] Docstring is over-indented 687 687 | to the one before 688 688 | """ -D.py:686:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:686:1 | 684 | to the one before 685 | This is also overindented 686 | And so is this, but it we should preserve the extra space on this line relative - | ^ D208 + | ^ 687 | to the one before 688 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 683 683 | And so is this, but it we should preserve the extra space on this line relative @@ -227,15 +238,16 @@ D.py:686:1: D208 [*] Docstring is over-indented 688 688 | """ 689 689 | -D.py:687:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:687:1 | 685 | This is also overindented 686 | And so is this, but it we should preserve the extra space on this line relative 687 | to the one before - | ^ D208 + | ^ 688 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 684 684 | to the one before @@ -247,16 +259,17 @@ D.py:687:1: D208 [*] Docstring is over-indented 689 689 | 690 690 | -D.py:695:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:695:1 | 693 | """Summary. 694 | 695 | This is overindented - | ^ D208 + | ^ 696 | And so is this, but it we should preserve the extra space on this line relative 697 | to the one before | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 692 692 | def retain_extra_whitespace_deeper(): @@ -268,15 +281,16 @@ D.py:695:1: D208 [*] Docstring is over-indented 697 697 | to the one before 698 698 | And the relative indent here should be preserved too -D.py:696:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:696:1 | 695 | This is overindented 696 | And so is this, but it we should preserve the extra space on this line relative - | ^ D208 + | ^ 697 | to the one before 698 | And the relative indent here should be preserved too | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 693 693 | """Summary. @@ -288,16 +302,17 @@ D.py:696:1: D208 [*] Docstring is over-indented 698 698 | And the relative indent here should be preserved too 699 699 | """ -D.py:697:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:697:1 | 695 | This is overindented 696 | And so is this, but it we should preserve the extra space on this line relative 697 | to the one before - | ^ D208 + | ^ 698 | And the relative indent here should be preserved too 699 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 694 694 | @@ -309,15 +324,16 @@ D.py:697:1: D208 [*] Docstring is over-indented 699 699 | """ 700 700 | -D.py:698:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:698:1 | 696 | And so is this, but it we should preserve the extra space on this line relative 697 | to the one before 698 | And the relative indent here should be preserved too - | ^ D208 + | ^ 699 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 695 695 | This is overindented @@ -329,16 +345,17 @@ D.py:698:1: D208 [*] Docstring is over-indented 700 700 | 701 701 | def retain_extra_whitespace_followed_by_same_offset(): -D.py:704:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:704:1 | 702 | """Summary. 703 | 704 | This is overindented - | ^ D208 + | ^ 705 | And so is this, but it we should preserve the extra space on this line relative 706 | This is overindented | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 701 701 | def retain_extra_whitespace_followed_by_same_offset(): @@ -350,15 +367,16 @@ D.py:704:1: D208 [*] Docstring is over-indented 706 706 | This is overindented 707 707 | This is overindented -D.py:705:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:705:1 | 704 | This is overindented 705 | And so is this, but it we should preserve the extra space on this line relative - | ^ D208 + | ^ 706 | This is overindented 707 | This is overindented | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 702 702 | """Summary. @@ -370,16 +388,17 @@ D.py:705:1: D208 [*] Docstring is over-indented 707 707 | This is overindented 708 708 | """ -D.py:706:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:706:1 | 704 | This is overindented 705 | And so is this, but it we should preserve the extra space on this line relative 706 | This is overindented - | ^ D208 + | ^ 707 | This is overindented 708 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 703 703 | @@ -391,15 +410,16 @@ D.py:706:1: D208 [*] Docstring is over-indented 708 708 | """ 709 709 | -D.py:707:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:707:1 | 705 | And so is this, but it we should preserve the extra space on this line relative 706 | This is overindented 707 | This is overindented - | ^ D208 + | ^ 708 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 704 704 | This is overindented @@ -411,15 +431,16 @@ D.py:707:1: D208 [*] Docstring is over-indented 709 709 | 710 710 | -D.py:723:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D.py:723:1 | 721 | """There's a non-breaking space (2-bytes) after 3 spaces (https://github.com/astral-sh/ruff/issues/9080). 722 | 723 |     Returns: - | ^ D208 + | ^ 724 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 720 720 | def inconsistent_indent_byte_size(): diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap index afcfd6d347..e6a1707a5b 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D208.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D208.py:2:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:2:1 | 1 | """ 2 | Author - | ^ D208 + | ^ 3 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 1 1 | """ @@ -18,16 +19,17 @@ D208.py:2:1: D208 [*] Docstring is over-indented 4 4 | 5 5 | -D208.py:8:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:8:1 | 6 | class Platform: 7 | """ Remove sampler 8 | Args: - | ^ D208 + | ^ 9 |     Returns: 10 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 5 5 | @@ -39,15 +41,16 @@ D208.py:8:1: D208 [*] Docstring is over-indented 10 10 | """ 11 11 | -D208.py:9:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:9:1 | 7 | """ Remove sampler 8 | Args: 9 |     Returns: - | ^ D208 + | ^ 10 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 6 6 | class Platform: @@ -59,14 +62,15 @@ D208.py:9:1: D208 [*] Docstring is over-indented 11 11 | 12 12 | -D208.py:10:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:10:1 | 8 | Args: 9 |     Returns: 10 | """ - | ^ D208 + | ^ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 7 7 | """ Remove sampler @@ -78,14 +82,15 @@ D208.py:10:1: D208 [*] Docstring is over-indented 12 12 | 13 13 | def memory_test(): -D208.py:24:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:24:1 | 22 | Args: 23 | Returns: 24 | """ - | ^ D208 + | ^ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 21 21 | """Over indented last line @@ -97,16 +102,17 @@ D208.py:24:1: D208 [*] Docstring is over-indented 26 26 | 27 27 | class Platform: -D208.py:29:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:29:1 | 27 | class Platform: 28 | """All lines are over indented including the last containing the closing quotes 29 | Args: - | ^ D208 + | ^ 30 | Returns: 31 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 26 26 | @@ -118,15 +124,16 @@ D208.py:29:1: D208 [*] Docstring is over-indented 31 31 | """ 32 32 | -D208.py:30:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:30:1 | 28 | """All lines are over indented including the last containing the closing quotes 29 | Args: 30 | Returns: - | ^ D208 + | ^ 31 | """ | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 27 27 | class Platform: @@ -138,16 +145,17 @@ D208.py:30:1: D208 [*] Docstring is over-indented 32 32 | 33 33 | class Platform: -D208.py:31:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:31:1 | 29 | Args: 30 | Returns: 31 | """ - | ^ D208 + | ^ 32 | 33 | class Platform: | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 28 28 | """All lines are over indented including the last containing the closing quotes @@ -159,15 +167,16 @@ D208.py:31:1: D208 [*] Docstring is over-indented 33 33 | class Platform: 34 34 | """All lines are over indented including the last -D208.py:35:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:35:1 | 33 | class Platform: 34 | """All lines are over indented including the last 35 | Args: - | ^ D208 + | ^ 36 | Returns""" | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 32 32 | @@ -179,16 +188,17 @@ D208.py:35:1: D208 [*] Docstring is over-indented 37 37 | 38 38 | # OK: This doesn't get flagged because it is accepted when the closing quotes are on a separate line (see next test). Raises D209 -D208.py:36:1: D208 [*] Docstring is over-indented +D208 [*] Docstring is over-indented + --> D208.py:36:1 | 34 | """All lines are over indented including the last 35 | Args: 36 | Returns""" - | ^ D208 + | ^ 37 | 38 | # OK: This doesn't get flagged because it is accepted when the closing quotes are on a separate line (see next test). Raises D209 | - = help: Remove over-indentation +help: Remove over-indentation ℹ Safe fix 33 33 | class Platform: diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap index abaf49d7af..fcfd42cb1a 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:281:5: D209 [*] Multi-line docstring closing quotes should be on a separate line +D209 [*] Multi-line docstring closing quotes should be on a separate line + --> D.py:281:5 | 279 | @expect('D213: Multi-line docstring summary should start at the second line') 280 | def asdfljdf24(): 281 | / """Summary. 282 | | 283 | | Description.""" - | |___________________^ D209 + | |___________________^ | - = help: Move closing quotes to new line +help: Move closing quotes to new line ℹ Safe fix 280 280 | def asdfljdf24(): @@ -23,16 +24,17 @@ D.py:281:5: D209 [*] Multi-line docstring closing quotes should be on a separate 285 286 | 286 287 | @expect('D210: No whitespaces allowed surrounding docstring text') -D.py:588:5: D209 [*] Multi-line docstring closing quotes should be on a separate line +D209 [*] Multi-line docstring closing quotes should be on a separate line + --> D.py:588:5 | 586 | @expect('D213: Multi-line docstring summary should start at the second line') 587 | def asdfljdjgf24(): 588 | / """Summary. 589 | | 590 | | Description. """ - | |_____________________^ D209 + | |_____________________^ | - = help: Move closing quotes to new line +help: Move closing quotes to new line ℹ Safe fix 587 587 | def asdfljdjgf24(): diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap index a964004890..4a65482cfe 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:288:5: D210 [*] No whitespaces allowed surrounding docstring text +D210 [*] No whitespaces allowed surrounding docstring text + --> D.py:288:5 | 286 | @expect('D210: No whitespaces allowed surrounding docstring text') 287 | def endswith(): 288 | """Whitespace at the end. """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Trim surrounding whitespace +help: Trim surrounding whitespace ℹ Safe fix 285 285 | @@ -20,14 +21,15 @@ D.py:288:5: D210 [*] No whitespaces allowed surrounding docstring text 290 290 | 291 291 | @expect('D210: No whitespaces allowed surrounding docstring text') -D.py:293:5: D210 [*] No whitespaces allowed surrounding docstring text +D210 [*] No whitespaces allowed surrounding docstring text + --> D.py:293:5 | 291 | @expect('D210: No whitespaces allowed surrounding docstring text') 292 | def around(): 293 | """ Whitespace at everywhere. """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Trim surrounding whitespace +help: Trim surrounding whitespace ℹ Safe fix 290 290 | @@ -39,7 +41,8 @@ D.py:293:5: D210 [*] No whitespaces allowed surrounding docstring text 295 295 | 296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') -D.py:299:5: D210 [*] No whitespaces allowed surrounding docstring text +D210 [*] No whitespaces allowed surrounding docstring text + --> D.py:299:5 | 297 | @expect('D213: Multi-line docstring summary should start at the second line') 298 | def multiline(): @@ -47,9 +50,9 @@ D.py:299:5: D210 [*] No whitespaces allowed surrounding docstring text 300 | | 301 | | This is the end. 302 | | """ - | |_______^ D210 + | |_______^ | - = help: Trim surrounding whitespace +help: Trim surrounding whitespace ℹ Safe fix 296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') @@ -61,11 +64,12 @@ D.py:299:5: D210 [*] No whitespaces allowed surrounding docstring text 301 301 | This is the end. 302 302 | """ -D.py:581:5: D210 No whitespaces allowed surrounding docstring text +D210 No whitespaces allowed surrounding docstring text + --> D.py:581:5 | 579 | "or exclamation point (not '\"')") 580 | def endswith_quote(): 581 | """Whitespace at the end, but also a quote" """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Trim surrounding whitespace +help: Trim surrounding whitespace diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap index affb5b409e..7826cc5fb1 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:170:5: D211 [*] No blank lines allowed before class docstring +D211 [*] No blank lines allowed before class docstring + --> D.py:170:5 | 168 | class WithLeadingSpace: 169 | 170 | """With leading space.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ D211 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove blank line(s) before class docstring +help: Remove blank line(s) before class docstring ℹ Safe fix 166 166 | @@ -19,15 +20,16 @@ D.py:170:5: D211 [*] No blank lines allowed before class docstring 171 170 | 172 171 | -D.py:181:5: D211 [*] No blank lines allowed before class docstring +D211 [*] No blank lines allowed before class docstring + --> D.py:181:5 | 179 | class TrailingSpace: 180 | 181 | """TrailingSpace.""" - | ^^^^^^^^^^^^^^^^^^^^ D211 + | ^^^^^^^^^^^^^^^^^^^^ 182 | pass | - = help: Remove blank line(s) before class docstring +help: Remove blank line(s) before class docstring ℹ Safe fix 177 177 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap index 5e8b8881c2..b934ae897e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:129:5: D212 [*] Multi-line docstring summary should start at the first line +D212 [*] Multi-line docstring summary should start at the first line + --> D.py:129:5 | 127 | @expect('D212: Multi-line docstring summary should start at the first line') 128 | def asdlkfasd(): 129 | / """ 130 | | Wrong. 131 | | """ - | |_______^ D212 + | |_______^ | - = help: Remove whitespace after opening quotes +help: Remove whitespace after opening quotes ℹ Safe fix 126 126 | '(found 3)') @@ -23,16 +24,17 @@ D.py:129:5: D212 [*] Multi-line docstring summary should start at the first line 132 131 | 133 132 | -D.py:597:5: D212 [*] Multi-line docstring summary should start at the first line +D212 [*] Multi-line docstring summary should start at the first line + --> D.py:597:5 | 595 | @expect('D212: Multi-line docstring summary should start at the first line') 596 | def one_liner(): 597 | / """ 598 | | 599 | | Wrong.""" - | |_____________^ D212 + | |_____________^ | - = help: Remove whitespace after opening quotes +help: Remove whitespace after opening quotes ℹ Safe fix 594 594 | '(found 3)') @@ -46,16 +48,17 @@ D.py:597:5: D212 [*] Multi-line docstring summary should start at the first line 601 599 | 602 600 | @expect('D200: One-line docstring should fit on one line with quotes ' -D.py:624:5: D212 [*] Multi-line docstring summary should start at the first line +D212 [*] Multi-line docstring summary should start at the first line + --> D.py:624:5 | 622 | @expect('D212: Multi-line docstring summary should start at the first line') 623 | def one_liner(): 624 | / """ 625 | | 626 | | "Wrong.""" - | |______________^ D212 + | |______________^ | - = help: Remove whitespace after opening quotes +help: Remove whitespace after opening quotes ℹ Safe fix 621 621 | '(found 3)') diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap index 66aa330b5a..7b1de443da 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:200:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:200:5 | 198 | @expect('D213: Multi-line docstring summary should start at the second line') 199 | def multi_line_zero_separating_blanks(): @@ -9,9 +10,9 @@ D.py:200:5: D213 [*] Multi-line docstring summary should start at the second lin 201 | | Description. 202 | | 203 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 197 197 | '(found 0)') @@ -24,7 +25,8 @@ D.py:200:5: D213 [*] Multi-line docstring summary should start at the second lin 202 203 | 203 204 | """ -D.py:210:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:210:5 | 208 | @expect('D213: Multi-line docstring summary should start at the second line') 209 | def multi_line_two_separating_blanks(): @@ -34,9 +36,9 @@ D.py:210:5: D213 [*] Multi-line docstring summary should start at the second lin 213 | | Description. 214 | | 215 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 207 207 | '(found 2)') @@ -49,7 +51,8 @@ D.py:210:5: D213 [*] Multi-line docstring summary should start at the second lin 212 213 | 213 214 | Description. -D.py:220:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:220:5 | 218 | @expect('D213: Multi-line docstring summary should start at the second line') 219 | def multi_line_one_separating_blanks(): @@ -58,9 +61,9 @@ D.py:220:5: D213 [*] Multi-line docstring summary should start at the second lin 222 | | Description. 223 | | 224 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 217 217 | @@ -73,7 +76,8 @@ D.py:220:5: D213 [*] Multi-line docstring summary should start at the second lin 222 223 | Description. 223 224 | -D.py:230:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:230:5 | 228 | @expect('D213: Multi-line docstring summary should start at the second line') 229 | def asdfsdf(): @@ -82,9 +86,9 @@ D.py:230:5: D213 [*] Multi-line docstring summary should start at the second lin 232 | | Description. 233 | | 234 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 227 227 | @expect('D207: Docstring is under-indented') @@ -97,7 +101,8 @@ D.py:230:5: D213 [*] Multi-line docstring summary should start at the second lin 232 233 | Description. 233 234 | -D.py:240:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:240:5 | 238 | @expect('D213: Multi-line docstring summary should start at the second line') 239 | def asdsdfsdffsdf(): @@ -106,9 +111,9 @@ D.py:240:5: D213 [*] Multi-line docstring summary should start at the second lin 242 | | Description. 243 | | 244 | | """ - | |___^ D213 + | |___^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 237 237 | @expect('D207: Docstring is under-indented') @@ -121,7 +126,8 @@ D.py:240:5: D213 [*] Multi-line docstring summary should start at the second lin 242 243 | Description. 243 244 | -D.py:250:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:250:5 | 248 | @expect('D213: Multi-line docstring summary should start at the second line') 249 | def asdfsdsdf24(): @@ -130,9 +136,9 @@ D.py:250:5: D213 [*] Multi-line docstring summary should start at the second lin 252 | | Description. 253 | | 254 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 247 247 | @expect('D208: Docstring is over-indented') @@ -145,7 +151,8 @@ D.py:250:5: D213 [*] Multi-line docstring summary should start at the second lin 252 253 | Description. 253 254 | -D.py:260:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:260:5 | 258 | @expect('D213: Multi-line docstring summary should start at the second line') 259 | def asdfsdsdfsdf24(): @@ -154,9 +161,9 @@ D.py:260:5: D213 [*] Multi-line docstring summary should start at the second lin 262 | | Description. 263 | | 264 | | """ - | |___________^ D213 + | |___________^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 257 257 | @expect('D208: Docstring is over-indented') @@ -169,7 +176,8 @@ D.py:260:5: D213 [*] Multi-line docstring summary should start at the second lin 262 263 | Description. 263 264 | -D.py:270:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:270:5 | 268 | @expect('D213: Multi-line docstring summary should start at the second line') 269 | def asdfsdfsdsdsdfsdf24(): @@ -178,9 +186,9 @@ D.py:270:5: D213 [*] Multi-line docstring summary should start at the second lin 272 | | Description. 273 | | 274 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 267 267 | @expect('D208: Docstring is over-indented') @@ -193,16 +201,17 @@ D.py:270:5: D213 [*] Multi-line docstring summary should start at the second lin 272 273 | Description. 273 274 | -D.py:281:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:281:5 | 279 | @expect('D213: Multi-line docstring summary should start at the second line') 280 | def asdfljdf24(): 281 | / """Summary. 282 | | 283 | | Description.""" - | |___________________^ D213 + | |___________________^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 278 278 | 'line') @@ -215,7 +224,8 @@ D.py:281:5: D213 [*] Multi-line docstring summary should start at the second lin 283 284 | Description.""" 284 285 | -D.py:299:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:299:5 | 297 | @expect('D213: Multi-line docstring summary should start at the second line') 298 | def multiline(): @@ -223,9 +233,9 @@ D.py:299:5: D213 [*] Multi-line docstring summary should start at the second lin 300 | | 301 | | This is the end. 302 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') @@ -238,7 +248,8 @@ D.py:299:5: D213 [*] Multi-line docstring summary should start at the second lin 301 302 | This is the end. 302 303 | """ -D.py:343:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:343:5 | 341 | @expect('D213: Multi-line docstring summary should start at the second line') 342 | def exceptions_of_D301(): @@ -248,9 +259,9 @@ D.py:343:5: D213 [*] Multi-line docstring summary should start at the second lin 346 | | and unicode literals \u0394 and \N{GREEK CAPITAL LETTER DELTA}. 347 | | They are considered to be intentionally unescaped. 348 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 340 340 | @@ -263,7 +274,8 @@ D.py:343:5: D213 [*] Multi-line docstring summary should start at the second lin 345 346 | In particular, line continuations \ 346 347 | and unicode literals \u0394 and \N{GREEK CAPITAL LETTER DELTA}. -D.py:383:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:383:5 | 381 | @expect('D213: Multi-line docstring summary should start at the second line') 382 | def new_209(): @@ -271,10 +283,10 @@ D.py:383:5: D213 [*] Multi-line docstring summary should start at the second lin 384 | | 385 | | More lines. 386 | | """ - | |_______^ D213 + | |_______^ 387 | pass | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 380 380 | @@ -287,7 +299,8 @@ D.py:383:5: D213 [*] Multi-line docstring summary should start at the second lin 385 386 | More lines. 386 387 | """ -D.py:392:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:392:5 | 390 | @expect('D213: Multi-line docstring summary should start at the second line') 391 | def old_209(): @@ -296,9 +309,9 @@ D.py:392:5: D213 [*] Multi-line docstring summary should start at the second lin 394 | | Multi-line comments. OK to have extra blank line 395 | | 396 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 389 389 | @@ -311,7 +324,8 @@ D.py:392:5: D213 [*] Multi-line docstring summary should start at the second lin 394 395 | Multi-line comments. OK to have extra blank line 395 396 | -D.py:438:37: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:438:37 | 436 | @expect("D207: Docstring is under-indented") 437 | @expect('D213: Multi-line docstring summary should start at the second line') @@ -320,9 +334,9 @@ D.py:438:37: D213 [*] Multi-line docstring summary should start at the second li 439 | | 440 | | Second Line 441 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 435 435 | @@ -335,7 +349,8 @@ D.py:438:37: D213 [*] Multi-line docstring summary should start at the second li 440 441 | Second Line 441 442 | """ -D.py:450:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:450:5 | 448 | @expect('D213: Multi-line docstring summary should start at the second line') 449 | def a_following_valid_function(x=None): @@ -344,9 +359,9 @@ D.py:450:5: D213 [*] Multi-line docstring summary should start at the second lin 452 | | The assertion was caused in the next function, so this one is necessary. 453 | | 454 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 447 447 | @@ -359,7 +374,8 @@ D.py:450:5: D213 [*] Multi-line docstring summary should start at the second lin 452 453 | The assertion was caused in the next function, so this one is necessary. 453 454 | -D.py:526:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:526:5 | 524 | # parameters as functions for Google / Numpy conventions. 525 | class Blah: # noqa: D203,D213 @@ -370,11 +386,11 @@ D.py:526:5: D213 [*] Multi-line docstring summary should start at the second lin 530 | | x : int 531 | | 532 | | """ - | |_______^ D213 + | |_______^ 533 | 534 | def __init__(self, x): | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 523 523 | # This is reproducing a bug where AttributeError is raised when parsing class @@ -387,7 +403,8 @@ D.py:526:5: D213 [*] Multi-line docstring summary should start at the second lin 528 529 | Parameters 529 530 | ---------- -D.py:546:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:546:5 | 544 | def multiline_leading_space(): 545 | @@ -395,9 +412,9 @@ D.py:546:5: D213 [*] Multi-line docstring summary should start at the second lin 547 | | 548 | | More content. 549 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 543 543 | @expect('D213: Multi-line docstring summary should start at the second line') @@ -410,7 +427,8 @@ D.py:546:5: D213 [*] Multi-line docstring summary should start at the second lin 548 549 | More content. 549 550 | """ -D.py:555:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:555:5 | 553 | @expect('D213: Multi-line docstring summary should start at the second line') 554 | def multiline_trailing_space(): @@ -418,11 +436,11 @@ D.py:555:5: D213 [*] Multi-line docstring summary should start at the second lin 556 | | 557 | | More content. 558 | | """ - | |_______^ D213 + | |_______^ 559 | 560 | pass | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 552 552 | @expect('D202: No blank lines allowed after function docstring (found 1)') @@ -435,7 +453,8 @@ D.py:555:5: D213 [*] Multi-line docstring summary should start at the second lin 557 558 | More content. 558 559 | """ -D.py:568:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:568:5 | 566 | def multiline_trailing_and_leading_space(): 567 | @@ -443,11 +462,11 @@ D.py:568:5: D213 [*] Multi-line docstring summary should start at the second lin 569 | | 570 | | More content. 571 | | """ - | |_______^ D213 + | |_______^ 572 | 573 | pass | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 565 565 | @expect('D213: Multi-line docstring summary should start at the second line') @@ -460,16 +479,17 @@ D.py:568:5: D213 [*] Multi-line docstring summary should start at the second lin 570 571 | More content. 571 572 | """ -D.py:588:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:588:5 | 586 | @expect('D213: Multi-line docstring summary should start at the second line') 587 | def asdfljdjgf24(): 588 | / """Summary. 589 | | 590 | | Description. """ - | |_____________________^ D213 + | |_____________________^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 585 585 | 'line') @@ -482,16 +502,17 @@ D.py:588:5: D213 [*] Multi-line docstring summary should start at the second lin 590 591 | Description. """ 591 592 | -D.py:606:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:606:5 | 604 | @expect('D212: Multi-line docstring summary should start at the first line') 605 | def one_liner(): 606 | / r"""Wrong. 607 | | 608 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 603 603 | '(found 3)') @@ -504,16 +525,17 @@ D.py:606:5: D213 [*] Multi-line docstring summary should start at the second lin 608 609 | """ 609 610 | -D.py:615:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:615:5 | 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 | def one_liner(): 615 | / """Wrong." 616 | | 617 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 612 612 | '(found 3)') @@ -526,7 +548,8 @@ D.py:615:5: D213 [*] Multi-line docstring summary should start at the second lin 617 618 | """ 618 619 | -D.py:671:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:671:5 | 670 | def retain_extra_whitespace(): 671 | / """Summary. @@ -535,9 +558,9 @@ D.py:671:5: D213 [*] Multi-line docstring summary should start at the second lin 674 | | And so is this, but it we should preserve the extra space on this line relative 675 | | to the one before 676 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 668 668 | @@ -550,7 +573,8 @@ D.py:671:5: D213 [*] Multi-line docstring summary should start at the second lin 673 674 | This is overindented 674 675 | And so is this, but it we should preserve the extra space on this line relative -D.py:680:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:680:5 | 679 | def retain_extra_whitespace_multiple(): 680 | / """Summary. @@ -562,9 +586,9 @@ D.py:680:5: D213 [*] Multi-line docstring summary should start at the second lin 686 | | And so is this, but it we should preserve the extra space on this line relative 687 | | to the one before 688 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 677 677 | @@ -577,7 +601,8 @@ D.py:680:5: D213 [*] Multi-line docstring summary should start at the second lin 682 683 | This is overindented 683 684 | And so is this, but it we should preserve the extra space on this line relative -D.py:693:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:693:5 | 692 | def retain_extra_whitespace_deeper(): 693 | / """Summary. @@ -587,11 +612,11 @@ D.py:693:5: D213 [*] Multi-line docstring summary should start at the second lin 697 | | to the one before 698 | | And the relative indent here should be preserved too 699 | | """ - | |_______^ D213 + | |_______^ 700 | 701 | def retain_extra_whitespace_followed_by_same_offset(): | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 690 690 | @@ -604,7 +629,8 @@ D.py:693:5: D213 [*] Multi-line docstring summary should start at the second lin 695 696 | This is overindented 696 697 | And so is this, but it we should preserve the extra space on this line relative -D.py:702:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:702:5 | 701 | def retain_extra_whitespace_followed_by_same_offset(): 702 | / """Summary. @@ -614,9 +640,9 @@ D.py:702:5: D213 [*] Multi-line docstring summary should start at the second lin 706 | | This is overindented 707 | | This is overindented 708 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 699 699 | """ @@ -629,7 +655,8 @@ D.py:702:5: D213 [*] Multi-line docstring summary should start at the second lin 704 705 | This is overindented 705 706 | And so is this, but it we should preserve the extra space on this line relative -D.py:712:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:712:5 | 711 | def retain_extra_whitespace_not_overindented(): 712 | / """Summary. @@ -638,9 +665,9 @@ D.py:712:5: D213 [*] Multi-line docstring summary should start at the second lin 715 | | This is overindented, but since one line is not overindented this should not raise 716 | | And so is this, but it we should preserve the extra space on this line relative 717 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 709 709 | @@ -653,16 +680,17 @@ D.py:712:5: D213 [*] Multi-line docstring summary should start at the second lin 714 715 | This is not overindented 715 716 | This is overindented, but since one line is not overindented this should not raise -D.py:721:5: D213 [*] Multi-line docstring summary should start at the second line +D213 [*] Multi-line docstring summary should start at the second line + --> D.py:721:5 | 720 | def inconsistent_indent_byte_size(): 721 | / """There's a non-breaking space (2-bytes) after 3 spaces (https://github.com/astral-sh/ruff/issues/9080). 722 | | 723 | |     Returns: 724 | | """ - | |_______^ D213 + | |_______^ | - = help: Insert line break and indentation after opening quotes +help: Insert line break and indentation after opening quotes ℹ Safe fix 718 718 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap index dc344a0cc0..19876f408e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D214_module.py:3:5: D214 [*] Section is over-indented ("Returns") +D214 [*] Section is over-indented ("Returns") + --> D214_module.py:3:5 | 1 | """A module docstring with D214 violations 2 | 3 | Returns - | ^^^^^^^ D214 + | ^^^^^^^ 4 | ----- 5 | valid returns | - = help: Remove over-indentation from "Returns" +help: Remove over-indentation from "Returns" ℹ Safe fix 1 1 | """A module docstring with D214 violations @@ -21,16 +22,17 @@ D214_module.py:3:5: D214 [*] Section is over-indented ("Returns") 5 5 | valid returns 6 6 | -D214_module.py:7:5: D214 [*] Section is over-indented ("Args") +D214 [*] Section is over-indented ("Args") + --> D214_module.py:7:5 | 5 | valid returns 6 | 7 | Args - | ^^^^ D214 + | ^^^^ 8 | ----- 9 | valid args | - = help: Remove over-indentation from "Args" +help: Remove over-indentation from "Args" ℹ Safe fix 4 4 | ----- diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap index 371f690de1..d84cea76af 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:146:9: D214 [*] Section is over-indented ("Returns") +D214 [*] Section is over-indented ("Returns") + --> sections.py:146:9 | 144 | """Toggle the gizmo. 145 | 146 | Returns - | ^^^^^^^ D214 + | ^^^^^^^ 147 | ------- 148 | A value of some sort. | - = help: Remove over-indentation from "Returns" +help: Remove over-indentation from "Returns" ℹ Safe fix 143 143 | def section_overindented(): # noqa: D416 @@ -22,15 +23,16 @@ sections.py:146:9: D214 [*] Section is over-indented ("Returns") 148 148 | A value of some sort. 149 149 | -sections.py:563:9: D214 [*] Section is over-indented ("Returns") +D214 [*] Section is over-indented ("Returns") + --> sections.py:563:9 | 561 | Here's a note. 562 | 563 | Returns: - | ^^^^^^^ D214 + | ^^^^^^^ 564 | """ | - = help: Remove over-indentation from "Returns" +help: Remove over-indentation from "Returns" ℹ Safe fix 560 560 | Args: diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_D215.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_D215.py.snap index eba14e8fcb..b3d204755b 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_D215.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_D215.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D215.py:3:5: D215 [*] Section underline is over-indented ("TODO") +D215 [*] Section underline is over-indented ("TODO") + --> D215.py:3:5 | 1 | """ 2 | TODO: 3 | - - | ^ D215 + | ^ 4 | """ | - = help: Remove over-indentation from "TODO" underline +help: Remove over-indentation from "TODO" underline ℹ Safe fix 1 1 | """ diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap index c3c2adcd32..6039da3d4a 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -sections.py:159:9: D215 [*] Section underline is over-indented ("Returns") +D215 [*] Section underline is over-indented ("Returns") + --> sections.py:159:9 | 158 | Returns 159 | ------- - | ^^^^^^^ D215 + | ^^^^^^^ 160 | A value of some sort. | - = help: Remove over-indentation from "Returns" underline +help: Remove over-indentation from "Returns" underline ℹ Safe fix 156 156 | """Toggle the gizmo. @@ -21,14 +21,15 @@ sections.py:159:9: D215 [*] Section underline is over-indented ("Returns") 161 161 | 162 162 | """ -sections.py:173:9: D215 [*] Section underline is over-indented ("Returns") +D215 [*] Section underline is over-indented ("Returns") + --> sections.py:173:9 | 172 | Returns 173 | ------- - | ^^^^^^^ D215 + | ^^^^^^^ 174 | """ | - = help: Remove over-indentation from "Returns" underline +help: Remove over-indentation from "Returns" underline ℹ Safe fix 170 170 | """Toggle the gizmo. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap index 23ef163550..f2ecfcbc5e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:307:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:307:5 | 305 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') 306 | def triple_single_quotes_raw(): 307 | r'''Summary.''' - | ^^^^^^^^^^^^^^^ D300 + | ^^^^^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 304 304 | @@ -20,14 +21,15 @@ D.py:307:5: D300 [*] Use triple double quotes `"""` 309 309 | 310 310 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') -D.py:312:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:312:5 | 310 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') 311 | def triple_single_quotes_raw_uppercase(): 312 | R'''Summary.''' - | ^^^^^^^^^^^^^^^ D300 + | ^^^^^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 309 309 | @@ -39,14 +41,15 @@ D.py:312:5: D300 [*] Use triple double quotes `"""` 314 314 | 315 315 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') -D.py:317:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:317:5 | 315 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') 316 | def single_quotes_raw(): 317 | r'Summary.' - | ^^^^^^^^^^^ D300 + | ^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 314 314 | @@ -58,14 +61,15 @@ D.py:317:5: D300 [*] Use triple double quotes `"""` 319 319 | 320 320 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') -D.py:322:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:322:5 | 320 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') 321 | def single_quotes_raw_uppercase(): 322 | R'Summary.' - | ^^^^^^^^^^^ D300 + | ^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 319 319 | @@ -77,14 +81,15 @@ D.py:322:5: D300 [*] Use triple double quotes `"""` 324 324 | 325 325 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') -D.py:328:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:328:5 | 326 | @expect('D301: Use r""" if any backslashes in a docstring') 327 | def single_quotes_raw_uppercase_backslash(): 328 | R'Sum\mary.' - | ^^^^^^^^^^^^ D300 + | ^^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 325 325 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') @@ -96,16 +101,17 @@ D.py:328:5: D300 [*] Use triple double quotes `"""` 330 330 | 331 331 | @expect('D301: Use r""" if any backslashes in a docstring') -D.py:645:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:645:5 | 644 | def single_line_docstring_with_an_escaped_backslash(): 645 | / "\ 646 | | " - | |_____^ D300 + | |_____^ 647 | 648 | class StatementOnSameLineAsDocstring: | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 642 642 | @@ -119,15 +125,16 @@ D.py:645:5: D300 [*] Use triple double quotes `"""` 648 648 | class StatementOnSameLineAsDocstring: 649 649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 -D.py:649:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:649:5 | 648 | class StatementOnSameLineAsDocstring: 649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 650 | def sort_services(self): 651 | pass | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 646 646 | " @@ -139,13 +146,14 @@ D.py:649:5: D300 [*] Use triple double quotes `"""` 651 651 | pass 652 652 | -D.py:654:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:654:5 | 653 | class StatementOnSameLineAsDocstring: 654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 651 651 | pass @@ -157,15 +165,16 @@ D.py:654:5: D300 [*] Use triple double quotes `"""` 656 656 | 657 657 | class CommentAfterDocstring: -D.py:658:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:658:5 | 657 | class CommentAfterDocstring: 658 | "After this docstring there's a comment." # priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 659 | def sort_services(self): 660 | pass | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 655 655 | @@ -177,14 +186,15 @@ D.py:658:5: D300 [*] Use triple double quotes `"""` 660 660 | pass 661 661 | -D.py:664:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D.py:664:5 | 663 | def newline_after_closing_quote(self): 664 | / "We enforce a newline after the closing quote for a multi-line docstring \ 665 | | but continuations shouldn't be considered multi-line" - | |_________________________________________________________^ D300 + | |_________________________________________________________^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 661 661 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D300.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D300.py.snap index 81fcb9d3f3..8aa4ccb908 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D300.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D300.py.snap @@ -1,22 +1,23 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D300.py:6:5: D300 Use triple double quotes `"""` +D300 Use triple double quotes `"""` + --> D300.py:6:5 | 5 | def ends_in_quote(): 6 | 'Sum\\mary."' - | ^^^^^^^^^^^^^ D300 + | ^^^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes -D300.py:10:5: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> D300.py:10:5 | 9 | def contains_quote(): 10 | 'Sum"\\mary.' - | ^^^^^^^^^^^^^ D300 + | ^^^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 7 7 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap index 9da29e5fbc..72289dc8b2 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D.py:333:5: D301 [*] Use `r"""` if any backslashes in a docstring +D301 [*] Use `r"""` if any backslashes in a docstring + --> D.py:333:5 | 331 | @expect('D301: Use r""" if any backslashes in a docstring') 332 | def double_quotes_backslash(): 333 | """Sum\\mary.""" - | ^^^^^^^^^^^^^^^^ D301 + | ^^^^^^^^^^^^^^^^ | - = help: Add `r` prefix +help: Add `r` prefix ℹ Unsafe fix 330 330 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap index ffd336a556..984047111e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D301.py:2:5: D301 [*] Use `r"""` if any backslashes in a docstring +D301 [*] Use `r"""` if any backslashes in a docstring + --> D301.py:2:5 | 1 | def double_quotes_backslash(): 2 | """Sum\\mary.""" - | ^^^^^^^^^^^^^^^^ D301 + | ^^^^^^^^^^^^^^^^ | - = help: Add `r` prefix +help: Add `r` prefix ℹ Unsafe fix 1 1 | def double_quotes_backslash(): @@ -17,23 +18,25 @@ D301.py:2:5: D301 [*] Use `r"""` if any backslashes in a docstring 4 4 | 5 5 | def double_quotes_backslash_raw(): -D301.py:37:5: D301 Use `r"""` if any backslashes in a docstring +D301 Use `r"""` if any backslashes in a docstring + --> D301.py:37:5 | 36 | def shouldnt_add_raw_here2(): 37 | u"Sum\\mary." - | ^^^^^^^^^^^^^ D301 + | ^^^^^^^^^^^^^ | - = help: Add `r` prefix +help: Add `r` prefix -D301.py:93:5: D301 [*] Use `r"""` if any backslashes in a docstring +D301 [*] Use `r"""` if any backslashes in a docstring + --> D301.py:93:5 | 92 | def should_add_raw_for_single_double_quote_escape(): 93 | / """ 94 | | This is single quote escape \". 95 | | """ - | |_______^ D301 + | |_______^ | - = help: Add `r` prefix +help: Add `r` prefix ℹ Unsafe fix 90 90 | @@ -45,15 +48,16 @@ D301.py:93:5: D301 [*] Use `r"""` if any backslashes in a docstring 95 95 | """ 96 96 | -D301.py:99:5: D301 [*] Use `r"""` if any backslashes in a docstring +D301 [*] Use `r"""` if any backslashes in a docstring + --> D301.py:99:5 | 98 | def should_add_raw_for_single_single_quote_escape(): 99 | / ''' 100 | | This is single quote escape \'. 101 | | ''' - | |_______^ D301 + | |_______^ | - = help: Add `r` prefix +help: Add `r` prefix ℹ Unsafe fix 96 96 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap index f61fcc94b9..4c97147f52 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:355:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:355:5 | 353 | "or exclamation point (not 'y')") 354 | def lwnlkjl(): 355 | """Summary""" - | ^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^ | - = help: Add period +help: Add period ℹ Unsafe fix 352 352 | @expect("D415: First line should end with a period, question mark, " @@ -20,14 +21,15 @@ D.py:355:5: D400 [*] First line should end with a period 357 357 | 358 358 | @expect("D401: First line should be in imperative mood " -D.py:406:25: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:406:25 | 404 | @expect("D415: First line should end with a period, question mark," 405 | " or exclamation point (not 'r')") 406 | def oneliner_withdoc(): """One liner""" - | ^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^ | - = help: Add period +help: Add period ℹ Unsafe fix 403 403 | @expect("D400: First line should end with a period (not 'r')") @@ -39,15 +41,16 @@ D.py:406:25: D400 [*] First line should end with a period 408 408 | 409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 -D.py:410:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:410:5 | 409 | def ignored_decorator(func): # noqa: D400,D401,D415 410 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^ 411 | func() 412 | pass | - = help: Add period +help: Add period ℹ Unsafe fix 407 407 | @@ -59,15 +62,16 @@ D.py:410:5: D400 [*] First line should end with a period 412 412 | pass 413 413 | -D.py:416:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:416:5 | 415 | def decorator_for_test(func): # noqa: D400,D401,D415 416 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^ 417 | func() 418 | pass | - = help: Add period +help: Add period ℹ Unsafe fix 413 413 | @@ -79,13 +83,14 @@ D.py:416:5: D400 [*] First line should end with a period 418 418 | pass 419 419 | -D.py:422:35: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:422:35 | 421 | @ignored_decorator 422 | def oneliner_ignored_decorator(): """One liner""" - | ^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^ | - = help: Add period +help: Add period ℹ Unsafe fix 419 419 | @@ -97,14 +102,15 @@ D.py:422:35: D400 [*] First line should end with a period 424 424 | 425 425 | @decorator_for_test -D.py:429:49: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:429:49 | 427 | @expect("D415: First line should end with a period, question mark," 428 | " or exclamation point (not 'r')") 429 | def oneliner_with_decorator_expecting_errors(): """One liner""" - | ^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^ | - = help: Add period +help: Add period ℹ Unsafe fix 426 426 | @expect("D400: First line should end with a period (not 'r')") @@ -116,15 +122,16 @@ D.py:429:49: D400 [*] First line should end with a period 431 431 | 432 432 | @decorator_for_test -D.py:470:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:470:5 | 468 | "or exclamation point (not 'g')") 469 | def docstring_bad(): 470 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^ 471 | pass | - = help: Add period +help: Add period ℹ Unsafe fix 467 467 | @expect("D415: First line should end with a period, question mark, " @@ -136,14 +143,15 @@ D.py:470:5: D400 [*] First line should end with a period 472 472 | 473 473 | -D.py:475:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:475:5 | 474 | def docstring_bad_ignore_all(): # noqa 475 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^ 476 | pass | - = help: Add period +help: Add period ℹ Unsafe fix 472 472 | @@ -155,14 +163,15 @@ D.py:475:5: D400 [*] First line should end with a period 477 477 | 478 478 | -D.py:480:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:480:5 | 479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 480 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^ 481 | pass | - = help: Add period +help: Add period ℹ Unsafe fix 477 477 | @@ -174,15 +183,16 @@ D.py:480:5: D400 [*] First line should end with a period 482 482 | 483 483 | -D.py:487:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:487:5 | 485 | "(perhaps 'Run', not 'Runs')") 486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 487 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^ 488 | pass | - = help: Add period +help: Add period ℹ Unsafe fix 484 484 | @expect("D401: First line should be in imperative mood " @@ -194,22 +204,24 @@ D.py:487:5: D400 [*] First line should end with a period 489 489 | 490 490 | -D.py:514:5: D400 First line should end with a period +D400 First line should end with a period + --> D.py:514:5 | 513 | def valid_google_string(): # noqa: D400 514 | """Test a valid something!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add period +help: Add period -D.py:520:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:520:5 | 518 | "or exclamation point (not 'g')") 519 | def bad_google_string(): # noqa: D400 520 | """Test a valid something""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add period +help: Add period ℹ Unsafe fix 517 517 | @expect("D415: First line should end with a period, question mark, " @@ -221,14 +233,15 @@ D.py:520:5: D400 [*] First line should end with a period 522 522 | 523 523 | # This is reproducing a bug where AttributeError is raised when parsing class -D.py:581:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:581:5 | 579 | "or exclamation point (not '\"')") 580 | def endswith_quote(): 581 | """Whitespace at the end, but also a quote" """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add period +help: Add period ℹ Unsafe fix 578 578 | @expect("D415: First line should end with a period, question mark, " @@ -240,16 +253,17 @@ D.py:581:5: D400 [*] First line should end with a period 583 583 | 584 584 | @expect('D209: Multi-line docstring closing quotes should be on a separate ' -D.py:615:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:615:5 | 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 | def one_liner(): 615 | / """Wrong." 616 | | 617 | | """ - | |_______^ D400 + | |_______^ | - = help: Add period +help: Add period ℹ Unsafe fix 612 612 | '(found 3)') @@ -261,14 +275,15 @@ D.py:615:5: D400 [*] First line should end with a period 617 617 | """ 618 618 | -D.py:639:17: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:639:17 | 639 | class SameLine: """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 640 | 641 | def same_line(): """This is a docstring on the same line""" | - = help: Add period +help: Add period ℹ Unsafe fix 636 636 | """ This is a docstring that starts with a space.""" # noqa: D210 @@ -280,14 +295,15 @@ D.py:639:17: D400 [*] First line should end with a period 641 641 | def same_line(): """This is a docstring on the same line""" 642 642 | -D.py:641:18: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:641:18 | 639 | class SameLine: """This is a docstring on the same line""" 640 | 641 | def same_line(): """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add period +help: Add period ℹ Unsafe fix 638 638 | @@ -299,14 +315,15 @@ D.py:641:18: D400 [*] First line should end with a period 643 643 | 644 644 | def single_line_docstring_with_an_escaped_backslash(): -D.py:664:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D.py:664:5 | 663 | def newline_after_closing_quote(self): 664 | / "We enforce a newline after the closing quote for a multi-line docstring \ 665 | | but continuations shouldn't be considered multi-line" - | |_________________________________________________________^ D400 + | |_________________________________________________________^ | - = help: Add period +help: Add period ℹ Unsafe fix 662 662 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap index 752bf81900..096ffb22e5 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D400.py:2:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:2:5 | 1 | def f(): 2 | "Here's a line without a period" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 1 1 | def f(): @@ -18,14 +19,15 @@ D400.py:2:5: D400 [*] First line should end with a period 4 4 | 5 5 | -D400.py:7:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:7:5 | 6 | def f(): 7 | """Here's a line without a period""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 4 4 | @@ -37,17 +39,18 @@ D400.py:7:5: D400 [*] First line should end with a period 9 9 | 10 10 | -D400.py:12:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:12:5 | 11 | def f(): 12 | / """ 13 | | Here's a line without a period, 14 | | but here's the next line 15 | | """ - | |_______^ D400 + | |_______^ 16 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 11 11 | def f(): @@ -59,14 +62,15 @@ D400.py:12:5: D400 [*] First line should end with a period 16 16 | ... 17 17 | -D400.py:20:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:20:5 | 19 | def f(): 20 | """Here's a line without a period""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 17 17 | @@ -78,16 +82,17 @@ D400.py:20:5: D400 [*] First line should end with a period 22 22 | 23 23 | -D400.py:25:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:25:5 | 24 | def f(): 25 | / """ 26 | | Here's a line without a period, 27 | | but here's the next line""" - | |_______________________________^ D400 + | |_______________________________^ 28 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 24 24 | def f(): @@ -99,16 +104,17 @@ D400.py:25:5: D400 [*] First line should end with a period 29 29 | 30 30 | -D400.py:32:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:32:5 | 31 | def f(): 32 | / """ 33 | | Here's a line without a period, 34 | | but here's the next line with trailing space """ - | |____________________________________________________^ D400 + | |____________________________________________________^ 35 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 31 31 | def f(): @@ -120,14 +126,15 @@ D400.py:32:5: D400 [*] First line should end with a period 36 36 | 37 37 | -D400.py:39:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:39:5 | 38 | def f(): 39 | r"Here's a line without a period" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 36 36 | @@ -139,14 +146,15 @@ D400.py:39:5: D400 [*] First line should end with a period 41 41 | 42 42 | -D400.py:44:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:44:5 | 43 | def f(): 44 | r"""Here's a line without a period""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 41 41 | @@ -158,17 +166,18 @@ D400.py:44:5: D400 [*] First line should end with a period 46 46 | 47 47 | -D400.py:49:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:49:5 | 48 | def f(): 49 | / r""" 50 | | Here's a line without a period, 51 | | but here's the next line 52 | | """ - | |_______^ D400 + | |_______^ 53 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 48 48 | def f(): @@ -180,14 +189,15 @@ D400.py:49:5: D400 [*] First line should end with a period 53 53 | ... 54 54 | -D400.py:57:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:57:5 | 56 | def f(): 57 | r"""Here's a line without a period""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 58 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 54 54 | @@ -199,16 +209,17 @@ D400.py:57:5: D400 [*] First line should end with a period 59 59 | 60 60 | -D400.py:62:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:62:5 | 61 | def f(): 62 | / r""" 63 | | Here's a line without a period, 64 | | but here's the next line""" - | |_______________________________^ D400 + | |_______________________________^ 65 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 61 61 | def f(): @@ -220,16 +231,17 @@ D400.py:62:5: D400 [*] First line should end with a period 66 66 | 67 67 | -D400.py:69:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:69:5 | 68 | def f(): 69 | / r""" 70 | | Here's a line without a period, 71 | | but here's the next line with trailing space """ - | |____________________________________________________^ D400 + | |____________________________________________________^ 72 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 68 68 | def f(): @@ -241,7 +253,8 @@ D400.py:69:5: D400 [*] First line should end with a period 73 73 | 74 74 | -D400.py:97:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400.py:97:5 | 96 | def f(): 97 | / """ @@ -250,9 +263,9 @@ D400.py:97:5: D400 [*] First line should end with a period 100 | | 101 | | My example explanation 102 | | """ - | |_______^ D400 + | |_______^ | - = help: Add period +help: Add period ℹ Unsafe fix 95 95 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400_415.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400_415.py.snap index de2d6b0996..5f64adf444 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400_415.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400_415.py.snap @@ -1,51 +1,55 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D400_415.py:2:5: D400 First line should end with a period +D400 First line should end with a period + --> D400_415.py:2:5 | 1 | def f(): 2 | "Here's a line ending in a question mark?" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | ... | - = help: Add period +help: Add period -D400_415.py:7:5: D400 First line should end with a period +D400 First line should end with a period + --> D400_415.py:7:5 | 6 | def f(): 7 | """Here's a line ending in an exclamation mark!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | ... | - = help: Add period +help: Add period -D400_415.py:11:5: D400 First line should end with a period +D400 First line should end with a period + --> D400_415.py:11:5 | 10 | def f(): 11 | """Here's a line ending in a colon:""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | ... | - = help: Add period +help: Add period -D400_415.py:15:5: D400 First line should end with a period +D400 First line should end with a period + --> D400_415.py:15:5 | 14 | def f(): 15 | """Here's a line ending in a semi colon;""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | ... | - = help: Add period +help: Add period -D400_415.py:19:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D400_415.py:19:5 | 18 | def f(): 19 | """Here's a line ending with a whitespace """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | ... | - = help: Add period +help: Add period ℹ Unsafe fix 16 16 | ... diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap index d649ee60dc..55f509319c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap @@ -1,21 +1,24 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D401.py:10:5: D401 First line of docstring should be in imperative mood: "Returns foo." +D401 First line of docstring should be in imperative mood: "Returns foo." + --> D401.py:10:5 | 9 | def bad_liouiwnlkjl(): 10 | """Returns foo.""" - | ^^^^^^^^^^^^^^^^^^ D401 + | ^^^^^^^^^^^^^^^^^^ | -D401.py:14:5: D401 First line of docstring should be in imperative mood: "Constructor for a foo." +D401 First line of docstring should be in imperative mood: "Constructor for a foo." + --> D401.py:14:5 | 13 | def bad_sdgfsdg23245(): 14 | """Constructor for a foo.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -D401.py:18:5: D401 First line of docstring should be in imperative mood: "Constructor for a boa." +D401 First line of docstring should be in imperative mood: "Constructor for a boa." + --> D401.py:18:5 | 17 | def bad_sdgfsdg23245777(): 18 | / """ @@ -23,41 +26,45 @@ D401.py:18:5: D401 First line of docstring should be in imperative mood: "Constr 20 | | Constructor for a boa. 21 | | 22 | | """ - | |_______^ D401 + | |_______^ | -D401.py:26:5: D401 First line of docstring should be in imperative mood: "Runs something" +D401 First line of docstring should be in imperative mood: "Runs something" + --> D401.py:26:5 | 25 | def bad_run_something(): 26 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D401 + | ^^^^^^^^^^^^^^^^^^^^ 27 | 28 | def bad_nested(): | -D401.py:29:9: D401 First line of docstring should be in imperative mood: "Runs other things, nested" +D401 First line of docstring should be in imperative mood: "Runs other things, nested" + --> D401.py:29:9 | 28 | def bad_nested(): 29 | """Runs other things, nested""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | bad_nested() | -D401.py:35:5: D401 First line of docstring should be in imperative mood: "Writes a logical line that" +D401 First line of docstring should be in imperative mood: "Writes a logical line that" + --> D401.py:35:5 | 34 | def multi_line(): 35 | / """Writes a logical line that 36 | | extends to two physical lines. 37 | | """ - | |_______^ D401 + | |_______^ | -D401.py:74:9: D401 First line of docstring should be in imperative mood: "This method docstring should be written in imperative mood." +D401 First line of docstring should be in imperative mood: "This method docstring should be written in imperative mood." + --> D401.py:74:9 | 73 | def bad_method(self): 74 | """This method docstring should be written in imperative mood.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | 76 | @property | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D.py.snap index be6c3676b7..0f51d90a4f 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D.py:378:5: D402 First line should not be the function's signature +D402 First line should not be the function's signature + --> D.py:378:5 | 376 | @expect('D402: First line should not be the function\'s "signature"') 377 | def foobar(): 378 | """Signature: foobar().""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D402.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D402.py.snap index 1c23d91dc9..f6048d4fb5 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D402.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D402.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D402.py:2:5: D402 First line should not be the function's signature +D402 First line should not be the function's signature + --> D402.py:2:5 | 1 | def foo(): 2 | """Returns foo().""" - | ^^^^^^^^^^^^^^^^^^^^ D402 + | ^^^^^^^^^^^^^^^^^^^^ 3 | 4 | def foo(): | -D402.py:8:5: D402 First line should not be the function's signature +D402 First line should not be the function's signature + --> D402.py:8:5 | 7 | def foo(): 8 | """"Use this function; foo().""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D402 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap index 201b1f68a5..a2f48de1d4 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D403.py:2:5: D403 [*] First word of the docstring should be capitalized: `this` -> `This` +D403 [*] First word of the docstring should be capitalized: `this` -> `This` + --> D403.py:2:5 | 1 | def bad_function(): 2 | """this docstring is not capitalized""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D403 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | def good_function(): | - = help: Capitalize `this` to `This` +help: Capitalize `this` to `This` ℹ Safe fix 1 1 | def bad_function(): @@ -19,15 +20,16 @@ D403.py:2:5: D403 [*] First word of the docstring should be capitalized: `this` 4 4 | def good_function(): 5 5 | """This docstring is capitalized.""" -D403.py:30:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:30:5 | 29 | def single_word(): 30 | """singleword.""" - | ^^^^^^^^^^^^^^^^^ D403 + | ^^^^^^^^^^^^^^^^^ 31 | 32 | def single_word_no_dot(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 27 27 | """th•s is not capitalized.""" @@ -39,15 +41,16 @@ D403.py:30:5: D403 [*] First word of the docstring should be capitalized: `singl 32 32 | def single_word_no_dot(): 33 33 | """singleword""" -D403.py:33:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:33:5 | 32 | def single_word_no_dot(): 33 | """singleword""" - | ^^^^^^^^^^^^^^^^ D403 + | ^^^^^^^^^^^^^^^^ 34 | 35 | def first_word_lots_of_whitespace(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 30 30 | """singleword.""" @@ -59,7 +62,8 @@ D403.py:33:5: D403 [*] First word of the docstring should be capitalized: `singl 35 35 | def first_word_lots_of_whitespace(): 36 36 | """ -D403.py:36:5: D403 [*] First word of the docstring should be capitalized: `here` -> `Here` +D403 [*] First word of the docstring should be capitalized: `here` -> `Here` + --> D403.py:36:5 | 35 | def first_word_lots_of_whitespace(): 36 | / """ @@ -70,11 +74,11 @@ D403.py:36:5: D403 [*] First word of the docstring should be capitalized: `here` 41 | | 42 | | What do you think? 43 | | """ - | |_______^ D403 + | |_______^ 44 | 45 | def single_word_newline(): | - = help: Capitalize `here` to `Here` +help: Capitalize `here` to `Here` ℹ Safe fix 37 37 | @@ -86,17 +90,18 @@ D403.py:36:5: D403 [*] First word of the docstring should be capitalized: `here` 42 42 | What do you think? 43 43 | """ -D403.py:46:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:46:5 | 45 | def single_word_newline(): 46 | / """singleword 47 | | 48 | | """ - | |_______^ D403 + | |_______^ 49 | 50 | def single_word_dot_newline(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 43 43 | """ @@ -108,17 +113,18 @@ D403.py:46:5: D403 [*] First word of the docstring should be capitalized: `singl 48 48 | """ 49 49 | -D403.py:51:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:51:5 | 50 | def single_word_dot_newline(): 51 | / """singleword. 52 | | 53 | | """ - | |_______^ D403 + | |_______^ 54 | 55 | def single_word_second_line(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 48 48 | """ @@ -130,17 +136,18 @@ D403.py:51:5: D403 [*] First word of the docstring should be capitalized: `singl 53 53 | """ 54 54 | -D403.py:56:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:56:5 | 55 | def single_word_second_line(): 56 | / """ 57 | | singleword 58 | | """ - | |_______^ D403 + | |_______^ 59 | 60 | def single_word_dot_second_line(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 54 54 | @@ -152,17 +159,18 @@ D403.py:56:5: D403 [*] First word of the docstring should be capitalized: `singl 59 59 | 60 60 | def single_word_dot_second_line(): -D403.py:61:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:61:5 | 60 | def single_word_dot_second_line(): 61 | / """ 62 | | singleword. 63 | | """ - | |_______^ D403 + | |_______^ 64 | 65 | def single_word_then_more_text(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 59 59 | @@ -174,18 +182,19 @@ D403.py:61:5: D403 [*] First word of the docstring should be capitalized: `singl 64 64 | 65 65 | def single_word_then_more_text(): -D403.py:66:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:66:5 | 65 | def single_word_then_more_text(): 66 | / """singleword 67 | | 68 | | This is more text. 69 | | """ - | |_______^ D403 + | |_______^ 70 | 71 | def single_word_dot_then_more_text(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 63 63 | """ @@ -197,18 +206,19 @@ D403.py:66:5: D403 [*] First word of the docstring should be capitalized: `singl 68 68 | This is more text. 69 69 | """ -D403.py:72:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:72:5 | 71 | def single_word_dot_then_more_text(): 72 | / """singleword. 73 | | 74 | | This is more text. 75 | | """ - | |_______^ D403 + | |_______^ 76 | 77 | def single_word_second_line_then_more_text(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 69 69 | """ @@ -220,7 +230,8 @@ D403.py:72:5: D403 [*] First word of the docstring should be capitalized: `singl 74 74 | This is more text. 75 75 | """ -D403.py:78:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:78:5 | 77 | def single_word_second_line_then_more_text(): 78 | / """ @@ -228,11 +239,11 @@ D403.py:78:5: D403 [*] First word of the docstring should be capitalized: `singl 80 | | 81 | | This is more text. 82 | | """ - | |_______^ D403 + | |_______^ 83 | 84 | def single_word_dot_second_line_then_more_text(): | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 76 76 | @@ -244,7 +255,8 @@ D403.py:78:5: D403 [*] First word of the docstring should be capitalized: `singl 81 81 | This is more text. 82 82 | """ -D403.py:85:5: D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` +D403 [*] First word of the docstring should be capitalized: `singleword` -> `Singleword` + --> D403.py:85:5 | 84 | def single_word_dot_second_line_then_more_text(): 85 | / """ @@ -252,9 +264,9 @@ D403.py:85:5: D403 [*] First word of the docstring should be capitalized: `singl 87 | | 88 | | This is more text. 89 | | """ - | |_______^ D403 + | |_______^ | - = help: Capitalize `singleword` to `Singleword` +help: Capitalize `singleword` to `Singleword` ℹ Safe fix 83 83 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap index dec763cf08..d9f57c68d3 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap @@ -1,34 +1,38 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:631:5: D404 First word of the docstring should not be "This" +D404 First word of the docstring should not be "This" + --> D.py:631:5 | 629 | @expect('D404: First word of the docstring should not be "This"') 630 | def starts_with_this(): 631 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -D.py:636:5: D404 First word of the docstring should not be "This" +D404 First word of the docstring should not be "This" + --> D.py:636:5 | 634 | @expect('D404: First word of the docstring should not be "This"') 635 | def starts_with_space_then_this(): 636 | """ This is a docstring that starts with a space.""" # noqa: D210 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -D.py:639:17: D404 First word of the docstring should not be "This" +D404 First word of the docstring should not be "This" + --> D.py:639:17 | 639 | class SameLine: """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 640 | 641 | def same_line(): """This is a docstring on the same line""" | -D.py:641:18: D404 First word of the docstring should not be "This" +D404 First word of the docstring should not be "This" + --> D.py:641:18 | 639 | class SameLine: """This is a docstring on the same line""" 640 | 641 | def same_line(): """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap index 840beb1830..7a3cecaa19 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:19:5: D405 [*] Section name should be properly capitalized ("returns") +D405 [*] Section name should be properly capitalized ("returns") + --> sections.py:19:5 | 17 | """Toggle the gizmo. 18 | 19 | returns - | ^^^^^^^ D405 + | ^^^^^^^ 20 | ------- 21 | A value of some sort. | - = help: Capitalize "returns" +help: Capitalize "returns" ℹ Safe fix 16 16 | def not_capitalized(): # noqa: D416 @@ -22,15 +23,16 @@ sections.py:19:5: D405 [*] Section name should be properly capitalized ("returns 21 21 | A value of some sort. 22 22 | -sections.py:218:5: D405 [*] Section name should be properly capitalized ("Short summary") +D405 [*] Section name should be properly capitalized ("Short summary") + --> sections.py:218:5 | 216 | """Toggle the gizmo. 217 | 218 | Short summary - | ^^^^^^^^^^^^^ D405 + | ^^^^^^^^^^^^^ 219 | ------------- | - = help: Capitalize "Short summary" +help: Capitalize "Short summary" ℹ Safe fix 215 215 | def multiple_sections(): # noqa: D416 @@ -42,16 +44,17 @@ sections.py:218:5: D405 [*] Section name should be properly capitalized ("Short 220 220 | 221 221 | This is the function's description, which will also specify what it -sections.py:573:5: D405 [*] Section name should be properly capitalized ("returns") +D405 [*] Section name should be properly capitalized ("returns") + --> sections.py:573:5 | 571 | arg: Here's a note. 572 | 573 | returns: - | ^^^^^^^ D405 + | ^^^^^^^ 574 | Here's another note. 575 | """ | - = help: Capitalize "returns" +help: Capitalize "returns" ℹ Safe fix 570 570 | Args: diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap index d5914e8da6..d2f758e3a5 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:32:5: D406 [*] Section name should end with a newline ("Returns") +D406 [*] Section name should end with a newline ("Returns") + --> sections.py:32:5 | 30 | """Toggle the gizmo. 31 | 32 | Returns: - | ^^^^^^^ D406 + | ^^^^^^^ 33 | ------- 34 | A value of some sort. | - = help: Add newline after "Returns" +help: Add newline after "Returns" ℹ Safe fix 29 29 | def superfluous_suffix(): # noqa: D416 @@ -22,15 +23,16 @@ sections.py:32:5: D406 [*] Section name should end with a newline ("Returns") 34 34 | A value of some sort. 35 35 | -sections.py:227:5: D406 [*] Section name should end with a newline ("Raises") +D406 [*] Section name should end with a newline ("Raises") + --> sections.py:227:5 | 225 | ------ 226 | Many many wonderful things. 227 | Raises: - | ^^^^^^ D406 + | ^^^^^^ 228 | My attention. | - = help: Add newline after "Raises" +help: Add newline after "Raises" ℹ Safe fix 224 224 | Returns @@ -42,16 +44,17 @@ sections.py:227:5: D406 [*] Section name should end with a newline ("Raises") 229 229 | 230 230 | """ -sections.py:601:5: D406 [*] Section name should end with a newline ("Parameters") +D406 [*] Section name should end with a newline ("Parameters") + --> sections.py:601:5 | 599 | """Test that lower case subsection header is valid even if it has the same name as section kind. 600 | 601 | Parameters: - | ^^^^^^^^^^ D406 + | ^^^^^^^^^^ 602 | ---------- 603 | parameters: | - = help: Add newline after "Parameters" +help: Add newline after "Parameters" ℹ Safe fix 598 598 | def test_lowercase_sub_section_header_should_be_valid(parameters: list[str], value: int): # noqa: D213 diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap index 767809f849..6a46781233 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:44:5: D407 [*] Missing dashed underline after section ("Returns") +D407 [*] Missing dashed underline after section ("Returns") + --> sections.py:44:5 | 42 | """Toggle the gizmo. 43 | 44 | Returns - | ^^^^^^^ D407 + | ^^^^^^^ 45 | A value of some sort. | - = help: Add dashed line under "Returns" +help: Add dashed line under "Returns" ℹ Safe fix 42 42 | """Toggle the gizmo. @@ -20,16 +21,17 @@ sections.py:44:5: D407 [*] Missing dashed underline after section ("Returns") 46 47 | 47 48 | """ -sections.py:56:5: D407 [*] Missing dashed underline after section ("Returns") +D407 [*] Missing dashed underline after section ("Returns") + --> sections.py:56:5 | 54 | """Toggle the gizmo. 55 | 56 | Returns - | ^^^^^^^ D407 + | ^^^^^^^ 57 | 58 | """ | - = help: Add dashed line under "Returns" +help: Add dashed line under "Returns" ℹ Safe fix 54 54 | """Toggle the gizmo. @@ -40,14 +42,15 @@ sections.py:56:5: D407 [*] Missing dashed underline after section ("Returns") 58 59 | """ 59 60 | -sections.py:67:5: D407 [*] Missing dashed underline after section ("Returns") +D407 [*] Missing dashed underline after section ("Returns") + --> sections.py:67:5 | 65 | """Toggle the gizmo. 66 | 67 | Returns""" - | ^^^^^^^ D407 + | ^^^^^^^ | - = help: Add dashed line under "Returns" +help: Add dashed line under "Returns" ℹ Safe fix 64 64 | def no_underline_and_no_newline(): # noqa: D416 @@ -60,15 +63,16 @@ sections.py:67:5: D407 [*] Missing dashed underline after section ("Returns") 69 70 | 70 71 | @expect(_D213) -sections.py:227:5: D407 [*] Missing dashed underline after section ("Raises") +D407 [*] Missing dashed underline after section ("Raises") + --> sections.py:227:5 | 225 | ------ 226 | Many many wonderful things. 227 | Raises: - | ^^^^^^ D407 + | ^^^^^^ 228 | My attention. | - = help: Add dashed line under "Raises" +help: Add dashed line under "Raises" ℹ Safe fix 225 225 | ------ @@ -79,14 +83,15 @@ sections.py:227:5: D407 [*] Missing dashed underline after section ("Raises") 229 230 | 230 231 | """ -sections.py:522:5: D407 [*] Missing dashed underline after section ("Parameters") +D407 [*] Missing dashed underline after section ("Parameters") + --> sections.py:522:5 | 521 | Parameters 522 | ========== - | ^^^^^^^^^^ D407 + | ^^^^^^^^^^ 523 | """ | - = help: Add dashed line under "Parameters" +help: Add dashed line under "Parameters" ℹ Safe fix 519 519 | """Equal length equals should be replaced with dashes. @@ -98,14 +103,15 @@ sections.py:522:5: D407 [*] Missing dashed underline after section ("Parameters" 524 524 | 525 525 | -sections.py:530:5: D407 [*] Missing dashed underline after section ("Parameters") +D407 [*] Missing dashed underline after section ("Parameters") + --> sections.py:530:5 | 529 | Parameters 530 | =========== - | ^^^^^^^^^^^ D407 + | ^^^^^^^^^^^ 531 | """ | - = help: Add dashed line under "Parameters" +help: Add dashed line under "Parameters" ℹ Safe fix 527 527 | """Here, the length of equals is not the same. @@ -117,16 +123,17 @@ sections.py:530:5: D407 [*] Missing dashed underline after section ("Parameters" 532 532 | 533 533 | -sections.py:613:4: D407 [*] Missing dashed underline after section ("Parameters") +D407 [*] Missing dashed underline after section ("Parameters") + --> sections.py:613:4 | 611 | """Test that lower case subsection header is valid even if it is of a different kind. 612 | 613 | Parameters - | ^^^^^^^^^^ D407 + | ^^^^^^^^^^ 614 | -‐----------------- 615 | returns: | - = help: Add dashed line under "Parameters" +help: Add dashed line under "Parameters" ℹ Safe fix 611 611 | """Test that lower case subsection header is valid even if it is of a different kind. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap index 2bb4847569..4ebd79bda4 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:98:5: D408 [*] Section underline should be in the line following the section's name ("Returns") +D408 [*] Section underline should be in the line following the section's name ("Returns") + --> sections.py:98:5 | 96 | Returns 97 | 98 | ------- - | ^^^^^^^ D408 + | ^^^^^^^ 99 | A value of some sort. | - = help: Add underline to "Returns" +help: Add underline to "Returns" ℹ Safe fix 94 94 | """Toggle the gizmo. diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap index a456360e57..a87eb5ac32 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:111:5: D409 [*] Section underline should match the length of its name ("Returns") +D409 [*] Section underline should match the length of its name ("Returns") + --> sections.py:111:5 | 110 | Returns 111 | -- - | ^^ D409 + | ^^ 112 | A value of some sort. | - = help: Adjust underline length to match "Returns" +help: Adjust underline length to match "Returns" ℹ Safe fix 108 108 | """Toggle the gizmo. @@ -20,15 +21,16 @@ sections.py:111:5: D409 [*] Section underline should match the length of its nam 113 113 | 114 114 | """ -sections.py:225:5: D409 [*] Section underline should match the length of its name ("Returns") +D409 [*] Section underline should match the length of its name ("Returns") + --> sections.py:225:5 | 224 | Returns 225 | ------ - | ^^^^^^ D409 + | ^^^^^^ 226 | Many many wonderful things. 227 | Raises: | - = help: Adjust underline length to match "Returns" +help: Adjust underline length to match "Returns" ℹ Safe fix 222 222 | returns. @@ -40,15 +42,16 @@ sections.py:225:5: D409 [*] Section underline should match the length of its nam 227 227 | Raises: 228 228 | My attention. -sections.py:589:5: D409 [*] Section underline should match the length of its name ("Other Parameters") +D409 [*] Section underline should match the length of its name ("Other Parameters") + --> sections.py:589:5 | 588 | Other Parameters 589 | ---------- - | ^^^^^^^^^^ D409 + | ^^^^^^^^^^ 590 | other_parameters: 591 | A dictionary of string attributes | - = help: Adjust underline length to match "Other Parameters" +help: Adjust underline length to match "Other Parameters" ℹ Safe fix 586 586 | A dictionary of string attributes diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap index f95ac4dd1f..d4cba2ca9f 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D410.py:4:5: D410 [*] Missing blank line after section ("Parameters") +D410 [*] Missing blank line after section ("Parameters") + --> D410.py:4:5 | 2 | """Showcase function. 3 | 4 | Parameters - | ^^^^^^^^^^ D410 + | ^^^^^^^^^^ 5 | ---------- 6 | a : int | - = help: Add blank line after "Parameters" +help: Add blank line after "Parameters" ℹ Safe fix 7 7 | _description_ @@ -21,16 +22,17 @@ D410.py:4:5: D410 [*] Missing blank line after section ("Parameters") 11 12 | ------- 12 13 | int -D410.py:21:5: D410 [*] Missing blank line after section ("Parameters") +D410 [*] Missing blank line after section ("Parameters") + --> D410.py:21:5 | 19 | """Showcase function. 20 | 21 | Parameters - | ^^^^^^^^^^ D410 + | ^^^^^^^^^^ 22 | ---------- 23 | Returns | - = help: Add blank line after "Parameters" +help: Add blank line after "Parameters" ℹ Safe fix 20 20 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap index 389391bb46..efd8950322 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:78:5: D410 [*] Missing blank line after section ("Returns") +D410 [*] Missing blank line after section ("Returns") + --> sections.py:78:5 | 76 | """Toggle the gizmo. 77 | 78 | Returns - | ^^^^^^^ D410 + | ^^^^^^^ 79 | ------- 80 | Yields | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 77 77 | @@ -21,16 +22,17 @@ sections.py:78:5: D410 [*] Missing blank line after section ("Returns") 81 82 | ------ 82 83 | -sections.py:224:5: D410 [*] Missing blank line after section ("Returns") +D410 [*] Missing blank line after section ("Returns") + --> sections.py:224:5 | 222 | returns. 223 | 224 | Returns - | ^^^^^^^ D410 + | ^^^^^^^ 225 | ------ 226 | Many many wonderful things. | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 224 224 | Returns diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap index c893a2e059..f4b40fa690 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -sections.py:80:5: D411 [*] Missing blank line before section ("Yields") +D411 [*] Missing blank line before section ("Yields") + --> sections.py:80:5 | 78 | Returns 79 | ------- 80 | Yields - | ^^^^^^ D411 + | ^^^^^^ 81 | ------ | - = help: Add blank line before "Yields" +help: Add blank line before "Yields" ℹ Safe fix 77 77 | @@ -21,15 +21,16 @@ sections.py:80:5: D411 [*] Missing blank line before section ("Yields") 81 82 | ------ 82 83 | -sections.py:134:5: D411 [*] Missing blank line before section ("Returns") +D411 [*] Missing blank line before section ("Returns") + --> sections.py:134:5 | 133 | The function's description. 134 | Returns - | ^^^^^^^ D411 + | ^^^^^^^ 135 | ------- 136 | A value of some sort. | - = help: Add blank line before "Returns" +help: Add blank line before "Returns" ℹ Safe fix 131 131 | """Toggle the gizmo. @@ -40,15 +41,16 @@ sections.py:134:5: D411 [*] Missing blank line before section ("Returns") 135 136 | ------- 136 137 | A value of some sort. -sections.py:227:5: D411 [*] Missing blank line before section ("Raises") +D411 [*] Missing blank line before section ("Raises") + --> sections.py:227:5 | 225 | ------ 226 | Many many wonderful things. 227 | Raises: - | ^^^^^^ D411 + | ^^^^^^ 228 | My attention. | - = help: Add blank line before "Raises" +help: Add blank line before "Raises" ℹ Safe fix 224 224 | Returns diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap index 6616be7a6e..715e1abb87 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:218:5: D412 [*] No blank lines allowed between a section header and its content ("Short summary") +D412 [*] No blank lines allowed between a section header and its content ("Short summary") + --> sections.py:218:5 | 216 | """Toggle the gizmo. 217 | 218 | Short summary - | ^^^^^^^^^^^^^ D412 + | ^^^^^^^^^^^^^ 219 | ------------- | - = help: Remove blank line(s) +help: Remove blank line(s) ℹ Safe fix 217 217 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap index 5abbab23db..98b536302c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sphinx.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -sphinx.py:13:5: D412 [*] No blank lines allowed between a section header and its content ("Example") +D412 [*] No blank lines allowed between a section header and its content ("Example") + --> sphinx.py:13:5 | 11 | def func(): 12 | """ 13 | Example: - | ^^^^^^^ D412 + | ^^^^^^^ | - = help: Remove blank line(s) +help: Remove blank line(s) ℹ Safe fix 12 12 | """ @@ -20,14 +20,15 @@ sphinx.py:13:5: D412 [*] No blank lines allowed between a section header and its 17 16 | 18 17 | import foo -sphinx.py:24:5: D412 [*] No blank lines allowed between a section header and its content ("Example") +D412 [*] No blank lines allowed between a section header and its content ("Example") + --> sphinx.py:24:5 | 22 | def func(): 23 | """ 24 | Example: - | ^^^^^^^ D412 + | ^^^^^^^ | - = help: Remove blank line(s) +help: Remove blank line(s) ℹ Safe fix 23 23 | """ @@ -39,15 +40,16 @@ sphinx.py:24:5: D412 [*] No blank lines allowed between a section header and its 29 27 | 30 28 | import foo -sphinx.py:47:5: D412 [*] No blank lines allowed between a section header and its content ("Example") +D412 [*] No blank lines allowed between a section header and its content ("Example") + --> sphinx.py:47:5 | 45 | def func(): 46 | """ 47 | Example - | ^^^^^^^ D412 + | ^^^^^^^ 48 | ------- | - = help: Remove blank line(s) +help: Remove blank line(s) ℹ Safe fix 47 47 | Example @@ -58,15 +60,16 @@ sphinx.py:47:5: D412 [*] No blank lines allowed between a section header and its 52 51 | 53 52 | import foo -sphinx.py:59:5: D412 [*] No blank lines allowed between a section header and its content ("Example") +D412 [*] No blank lines allowed between a section header and its content ("Example") + --> sphinx.py:59:5 | 57 | def func(): 58 | """ 59 | Example - | ^^^^^^^ D412 + | ^^^^^^^ 60 | ------- | - = help: Remove blank line(s) +help: Remove blank line(s) ℹ Safe fix 59 59 | Example diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap index b8e6594eee..0830634d78 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_D413.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D413.py:7:1: D413 [*] Missing blank line after last section ("Returns") +D413 [*] Missing blank line after last section ("Returns") + --> D413.py:7:1 | 5 | with a hanging indent 6 | 7 | Returns: - | ^^^^^^^ D413 + | ^^^^^^^ 8 | the value 9 | """ | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 6 6 | @@ -21,16 +22,17 @@ D413.py:7:1: D413 [*] Missing blank line after last section ("Returns") 10 11 | 11 12 | -D413.py:19:5: D413 [*] Missing blank line after last section ("Returns") +D413 [*] Missing blank line after last section ("Returns") + --> D413.py:19:5 | 17 | with a hanging indent 18 | 19 | Returns: - | ^^^^^^^ D413 + | ^^^^^^^ 20 | the value 21 | """ | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 18 18 | @@ -41,15 +43,16 @@ D413.py:19:5: D413 [*] Missing blank line after last section ("Returns") 22 23 | 23 24 | -D413.py:58:5: D413 [*] Missing blank line after last section ("Returns") +D413 [*] Missing blank line after last section ("Returns") + --> D413.py:58:5 | 56 | with a hanging indent 57 | 58 | Returns: - | ^^^^^^^ D413 + | ^^^^^^^ 59 | the value""" | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 56 56 | with a hanging indent @@ -63,16 +66,17 @@ D413.py:58:5: D413 [*] Missing blank line after last section ("Returns") 61 63 | 62 64 | def func(): -D413.py:69:5: D413 [*] Missing blank line after last section ("Returns") +D413 [*] Missing blank line after last section ("Returns") + --> D413.py:69:5 | 67 | with a hanging indent 68 | 69 | Returns: - | ^^^^^^^ D413 + | ^^^^^^^ 70 | the value 71 | """ | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 68 68 | @@ -86,16 +90,17 @@ D413.py:69:5: D413 [*] Missing blank line after last section ("Returns") 74 75 | def func(): 75 76 | ("""Docstring. -D413.py:77:5: D413 [*] Missing blank line after last section ("Raises") +D413 [*] Missing blank line after last section ("Raises") + --> D413.py:77:5 | 75 | ("""Docstring. 76 | 77 | Raises: - | ^^^^^^ D413 + | ^^^^^^ 78 | ValueError: An error. 79 | """) | - = help: Add blank line after "Raises" +help: Add blank line after "Raises" ℹ Safe fix 76 76 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap index c8e9fd19ae..ac2dba9162 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:67:5: D413 [*] Missing blank line after last section ("Returns") +D413 [*] Missing blank line after last section ("Returns") + --> sections.py:67:5 | 65 | """Toggle the gizmo. 66 | 67 | Returns""" - | ^^^^^^^ D413 + | ^^^^^^^ | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 64 64 | def no_underline_and_no_newline(): # noqa: D416 @@ -22,16 +23,17 @@ sections.py:67:5: D413 [*] Missing blank line after last section ("Returns") 69 71 | 70 72 | @expect(_D213) -sections.py:122:5: D413 [*] Missing blank line after last section ("Returns") +D413 [*] Missing blank line after last section ("Returns") + --> sections.py:122:5 | 120 | """Toggle the gizmo. 121 | 122 | Returns - | ^^^^^^^ D413 + | ^^^^^^^ 123 | ------- 124 | A value of some sort. | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 122 122 | Returns @@ -42,16 +44,17 @@ sections.py:122:5: D413 [*] Missing blank line after last section ("Returns") 126 127 | 127 128 | -sections.py:172:5: D413 [*] Missing blank line after last section ("Returns") +D413 [*] Missing blank line after last section ("Returns") + --> sections.py:172:5 | 170 | """Toggle the gizmo. 171 | 172 | Returns - | ^^^^^^^ D413 + | ^^^^^^^ 173 | ------- 174 | """ | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 171 171 | @@ -62,16 +65,17 @@ sections.py:172:5: D413 [*] Missing blank line after last section ("Returns") 175 176 | 176 177 | -sections.py:521:5: D413 [*] Missing blank line after last section ("Parameters") +D413 [*] Missing blank line after last section ("Parameters") + --> sections.py:521:5 | 519 | """Equal length equals should be replaced with dashes. 520 | 521 | Parameters - | ^^^^^^^^^^ D413 + | ^^^^^^^^^^ 522 | ========== 523 | """ | - = help: Add blank line after "Parameters" +help: Add blank line after "Parameters" ℹ Safe fix 520 520 | @@ -82,16 +86,17 @@ sections.py:521:5: D413 [*] Missing blank line after last section ("Parameters") 524 525 | 525 526 | -sections.py:529:5: D413 [*] Missing blank line after last section ("Parameters") +D413 [*] Missing blank line after last section ("Parameters") + --> sections.py:529:5 | 527 | """Here, the length of equals is not the same. 528 | 529 | Parameters - | ^^^^^^^^^^ D413 + | ^^^^^^^^^^ 530 | =========== 531 | """ | - = help: Add blank line after "Parameters" +help: Add blank line after "Parameters" ℹ Safe fix 528 528 | @@ -102,15 +107,16 @@ sections.py:529:5: D413 [*] Missing blank line after last section ("Parameters") 532 533 | 533 534 | -sections.py:550:5: D413 [*] Missing blank line after last section ("Args") +D413 [*] Missing blank line after last section ("Args") + --> sections.py:550:5 | 548 | """Below, `returns:` should _not_ be considered a section header. 549 | 550 | Args: - | ^^^^ D413 + | ^^^^ 551 | Here's a note. | - = help: Add blank line after "Args" +help: Add blank line after "Args" ℹ Safe fix 551 551 | Here's a note. @@ -121,15 +127,16 @@ sections.py:550:5: D413 [*] Missing blank line after last section ("Args") 555 556 | 556 557 | -sections.py:563:9: D413 [*] Missing blank line after last section ("Returns") +D413 [*] Missing blank line after last section ("Returns") + --> sections.py:563:9 | 561 | Here's a note. 562 | 563 | Returns: - | ^^^^^^^ D413 + | ^^^^^^^ 564 | """ | - = help: Add blank line after "Returns" +help: Add blank line after "Returns" ℹ Safe fix 561 561 | Here's a note. @@ -140,16 +147,17 @@ sections.py:563:9: D413 [*] Missing blank line after last section ("Returns") 565 566 | 566 567 | -sections.py:573:5: D413 [*] Missing blank line after last section ("returns") +D413 [*] Missing blank line after last section ("returns") + --> sections.py:573:5 | 571 | arg: Here's a note. 572 | 573 | returns: - | ^^^^^^^ D413 + | ^^^^^^^ 574 | Here's another note. 575 | """ | - = help: Add blank line after "returns" +help: Add blank line after "returns" ℹ Safe fix 572 572 | @@ -160,16 +168,17 @@ sections.py:573:5: D413 [*] Missing blank line after last section ("returns") 576 577 | 577 578 | -sections.py:601:5: D413 [*] Missing blank line after last section ("Parameters") +D413 [*] Missing blank line after last section ("Parameters") + --> sections.py:601:5 | 599 | """Test that lower case subsection header is valid even if it has the same name as section kind. 600 | 601 | Parameters: - | ^^^^^^^^^^ D413 + | ^^^^^^^^^^ 602 | ---------- 603 | parameters: | - = help: Add blank line after "Parameters" +help: Add blank line after "Parameters" ℹ Safe fix 604 604 | A list of string parameters diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap index c4cfd3cd33..75860e3dc3 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap @@ -1,68 +1,75 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:56:5: D414 Section has no content ("Returns") +D414 Section has no content ("Returns") + --> sections.py:56:5 | 54 | """Toggle the gizmo. 55 | 56 | Returns - | ^^^^^^^ D414 + | ^^^^^^^ 57 | 58 | """ | -sections.py:67:5: D414 Section has no content ("Returns") +D414 Section has no content ("Returns") + --> sections.py:67:5 | 65 | """Toggle the gizmo. 66 | 67 | Returns""" - | ^^^^^^^ D414 + | ^^^^^^^ | -sections.py:78:5: D414 Section has no content ("Returns") +D414 Section has no content ("Returns") + --> sections.py:78:5 | 76 | """Toggle the gizmo. 77 | 78 | Returns - | ^^^^^^^ D414 + | ^^^^^^^ 79 | ------- 80 | Yields | -sections.py:80:5: D414 Section has no content ("Yields") +D414 Section has no content ("Yields") + --> sections.py:80:5 | 78 | Returns 79 | ------- 80 | Yields - | ^^^^^^ D414 + | ^^^^^^ 81 | ------ | -sections.py:172:5: D414 Section has no content ("Returns") +D414 Section has no content ("Returns") + --> sections.py:172:5 | 170 | """Toggle the gizmo. 171 | 172 | Returns - | ^^^^^^^ D414 + | ^^^^^^^ 173 | ------- 174 | """ | -sections.py:266:5: D414 Section has no content ("Returns") +D414 Section has no content ("Returns") + --> sections.py:266:5 | 264 | note: A random string. 265 | 266 | Returns: - | ^^^^^^^ D414 + | ^^^^^^^ 267 | 268 | Raises: | -sections.py:563:9: D414 Section has no content ("Returns") +D414 Section has no content ("Returns") + --> sections.py:563:9 | 561 | Here's a note. 562 | 563 | Returns: - | ^^^^^^^ D414 + | ^^^^^^^ 564 | """ | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap index 83922317dc..f342894e32 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:355:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:355:5 | 353 | "or exclamation point (not 'y')") 354 | def lwnlkjl(): 355 | """Summary""" - | ^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 352 352 | @expect("D415: First line should end with a period, question mark, " @@ -20,14 +21,15 @@ D.py:355:5: D415 [*] First line should end with a period, question mark, or excl 357 357 | 358 358 | @expect("D401: First line should be in imperative mood " -D.py:406:25: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:406:25 | 404 | @expect("D415: First line should end with a period, question mark," 405 | " or exclamation point (not 'r')") 406 | def oneliner_withdoc(): """One liner""" - | ^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 403 403 | @expect("D400: First line should end with a period (not 'r')") @@ -39,15 +41,16 @@ D.py:406:25: D415 [*] First line should end with a period, question mark, or exc 408 408 | 409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 -D.py:410:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:410:5 | 409 | def ignored_decorator(func): # noqa: D400,D401,D415 410 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^ 411 | func() 412 | pass | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 407 407 | @@ -59,15 +62,16 @@ D.py:410:5: D415 [*] First line should end with a period, question mark, or excl 412 412 | pass 413 413 | -D.py:416:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:416:5 | 415 | def decorator_for_test(func): # noqa: D400,D401,D415 416 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^ 417 | func() 418 | pass | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 413 413 | @@ -79,13 +83,14 @@ D.py:416:5: D415 [*] First line should end with a period, question mark, or excl 418 418 | pass 419 419 | -D.py:422:35: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:422:35 | 421 | @ignored_decorator 422 | def oneliner_ignored_decorator(): """One liner""" - | ^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 419 419 | @@ -97,14 +102,15 @@ D.py:422:35: D415 [*] First line should end with a period, question mark, or exc 424 424 | 425 425 | @decorator_for_test -D.py:429:49: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:429:49 | 427 | @expect("D415: First line should end with a period, question mark," 428 | " or exclamation point (not 'r')") 429 | def oneliner_with_decorator_expecting_errors(): """One liner""" - | ^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 426 426 | @expect("D400: First line should end with a period (not 'r')") @@ -116,15 +122,16 @@ D.py:429:49: D415 [*] First line should end with a period, question mark, or exc 431 431 | 432 432 | @decorator_for_test -D.py:470:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:470:5 | 468 | "or exclamation point (not 'g')") 469 | def docstring_bad(): 470 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^ 471 | pass | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 467 467 | @expect("D415: First line should end with a period, question mark, " @@ -136,14 +143,15 @@ D.py:470:5: D415 [*] First line should end with a period, question mark, or excl 472 472 | 473 473 | -D.py:475:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:475:5 | 474 | def docstring_bad_ignore_all(): # noqa 475 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^ 476 | pass | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 472 472 | @@ -155,14 +163,15 @@ D.py:475:5: D415 [*] First line should end with a period, question mark, or excl 477 477 | 478 478 | -D.py:480:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:480:5 | 479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 480 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^ 481 | pass | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 477 477 | @@ -174,15 +183,16 @@ D.py:480:5: D415 [*] First line should end with a period, question mark, or excl 482 482 | 483 483 | -D.py:487:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:487:5 | 485 | "(perhaps 'Run', not 'Runs')") 486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 487 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^ 488 | pass | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 484 484 | @expect("D401: First line should be in imperative mood " @@ -194,14 +204,15 @@ D.py:487:5: D415 [*] First line should end with a period, question mark, or excl 489 489 | 490 490 | -D.py:520:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:520:5 | 518 | "or exclamation point (not 'g')") 519 | def bad_google_string(): # noqa: D400 520 | """Test a valid something""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 517 517 | @expect("D415: First line should end with a period, question mark, " @@ -213,14 +224,15 @@ D.py:520:5: D415 [*] First line should end with a period, question mark, or excl 522 522 | 523 523 | # This is reproducing a bug where AttributeError is raised when parsing class -D.py:581:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:581:5 | 579 | "or exclamation point (not '\"')") 580 | def endswith_quote(): 581 | """Whitespace at the end, but also a quote" """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 578 578 | @expect("D415: First line should end with a period, question mark, " @@ -232,16 +244,17 @@ D.py:581:5: D415 [*] First line should end with a period, question mark, or excl 583 583 | 584 584 | @expect('D209: Multi-line docstring closing quotes should be on a separate ' -D.py:615:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:615:5 | 613 | @expect('D212: Multi-line docstring summary should start at the first line') 614 | def one_liner(): 615 | / """Wrong." 616 | | 617 | | """ - | |_______^ D415 + | |_______^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 612 612 | '(found 3)') @@ -253,14 +266,15 @@ D.py:615:5: D415 [*] First line should end with a period, question mark, or excl 617 617 | """ 618 618 | -D.py:639:17: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:639:17 | 639 | class SameLine: """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 640 | 641 | def same_line(): """This is a docstring on the same line""" | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 636 636 | """ This is a docstring that starts with a space.""" # noqa: D210 @@ -272,14 +286,15 @@ D.py:639:17: D415 [*] First line should end with a period, question mark, or exc 641 641 | def same_line(): """This is a docstring on the same line""" 642 642 | -D.py:641:18: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:641:18 | 639 | class SameLine: """This is a docstring on the same line""" 640 | 641 | def same_line(): """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 638 638 | @@ -291,14 +306,15 @@ D.py:641:18: D415 [*] First line should end with a period, question mark, or exc 643 643 | 644 644 | def single_line_docstring_with_an_escaped_backslash(): -D.py:664:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D.py:664:5 | 663 | def newline_after_closing_quote(self): 664 | / "We enforce a newline after the closing quote for a multi-line docstring \ 665 | | but continuations shouldn't be considered multi-line" - | |_________________________________________________________^ D415 + | |_________________________________________________________^ | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 662 662 | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D400_415.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D400_415.py.snap index 2fdb5bc6c2..eba6769802 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D400_415.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D400_415.py.snap @@ -1,33 +1,35 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D400_415.py:11:5: D415 First line should end with a period, question mark, or exclamation point +D415 First line should end with a period, question mark, or exclamation point + --> D400_415.py:11:5 | 10 | def f(): 11 | """Here's a line ending in a colon:""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | ... | - = help: Add closing punctuation +help: Add closing punctuation -D400_415.py:15:5: D415 First line should end with a period, question mark, or exclamation point +D415 First line should end with a period, question mark, or exclamation point + --> D400_415.py:15:5 | 14 | def f(): 15 | """Here's a line ending in a semi colon;""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | ... | - = help: Add closing punctuation +help: Add closing punctuation -D400_415.py:19:5: D415 [*] First line should end with a period, question mark, or exclamation point +D415 [*] First line should end with a period, question mark, or exclamation point + --> D400_415.py:19:5 | 18 | def f(): 19 | """Here's a line ending with a whitespace """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | ... | - = help: Add closing punctuation +help: Add closing punctuation ℹ Unsafe fix 16 16 | ... diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap index 17d957fa2b..79fa8e46b8 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap @@ -1,101 +1,112 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -sections.py:292:9: D417 Missing argument description in the docstring for `bar`: `y` +D417 Missing argument description in the docstring for `bar`: `y` + --> sections.py:292:9 | 290 | x = 1 291 | 292 | def bar(y=2): # noqa: D207, D213, D406, D407 - | ^^^ D417 + | ^^^ 293 | """Nested function test for docstrings. | -sections.py:309:5: D417 Missing argument description in the docstring for `test_missing_google_args`: `y` +D417 Missing argument description in the docstring for `test_missing_google_args`: `y` + --> sections.py:309:5 | 307 | "(argument(s) y are missing descriptions in " 308 | "'test_missing_google_args' docstring)") 309 | def test_missing_google_args(x=1, y=2, _private=3): # noqa: D406, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 310 | """Toggle the gizmo. | -sections.py:333:9: D417 Missing argument descriptions in the docstring for `test_missing_args`: `test`, `y`, `z` +D417 Missing argument descriptions in the docstring for `test_missing_args`: `test`, `y`, `z` + --> sections.py:333:9 | 331 | "(argument(s) test, y, z are missing descriptions in " 332 | "'test_missing_args' docstring)", arg_count=5) 333 | def test_missing_args(self, test, x, y, z=3, _private_arg=3): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^ 334 | """Test a valid args section. | -sections.py:345:9: D417 Missing argument descriptions in the docstring for `test_missing_args_class_method`: `test`, `y`, `z` +D417 Missing argument descriptions in the docstring for `test_missing_args_class_method`: `test`, `y`, `z` + --> sections.py:345:9 | 343 | "(argument(s) test, y, z are missing descriptions in " 344 | "'test_missing_args_class_method' docstring)", arg_count=5) 345 | def test_missing_args_class_method(cls, test, x, y, _, z=3): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 346 | """Test a valid args section. | -sections.py:358:9: D417 Missing argument descriptions in the docstring for `test_missing_args_static_method`: `a`, `y`, `z` +D417 Missing argument descriptions in the docstring for `test_missing_args_static_method`: `a`, `y`, `z` + --> sections.py:358:9 | 356 | "(argument(s) a, y, z are missing descriptions in " 357 | "'test_missing_args_static_method' docstring)", arg_count=4) 358 | def test_missing_args_static_method(a, x, y, _test, z=3): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 359 | """Test a valid args section. | -sections.py:370:9: D417 Missing argument descriptions in the docstring for `test_missing_docstring`: `a`, `b` +D417 Missing argument descriptions in the docstring for `test_missing_docstring`: `a`, `b` + --> sections.py:370:9 | 368 | "(argument(s) a, b are missing descriptions in " 369 | "'test_missing_docstring' docstring)", arg_count=2) 370 | def test_missing_docstring(a, b): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^^^^^^ 371 | """Test a valid args section. | -sections.py:398:5: D417 Missing argument description in the docstring for `test_missing_numpy_args`: `y` +D417 Missing argument description in the docstring for `test_missing_numpy_args`: `y` + --> sections.py:398:5 | 396 | "(argument(s) y are missing descriptions in " 397 | "'test_missing_numpy_args' docstring)") 398 | def test_missing_numpy_args(_private_arg=0, x=1, y=2): # noqa: D406, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^^^^^^^ 399 | """Toggle the gizmo. | -sections.py:434:9: D417 Missing argument descriptions in the docstring for `test_missing_args`: `test`, `y`, `z` +D417 Missing argument descriptions in the docstring for `test_missing_args`: `test`, `y`, `z` + --> sections.py:434:9 | 432 | "(argument(s) test, y, z are missing descriptions in " 433 | "'test_missing_args' docstring)", arg_count=5) 434 | def test_missing_args(self, test, x, y, z=3, t=1, _private=0): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^ 435 | """Test a valid args section. | -sections.py:449:9: D417 Missing argument descriptions in the docstring for `test_missing_args_class_method`: `test`, `y`, `z` +D417 Missing argument descriptions in the docstring for `test_missing_args_class_method`: `test`, `y`, `z` + --> sections.py:449:9 | 447 | "(argument(s) test, y, z are missing descriptions in " 448 | "'test_missing_args_class_method' docstring)", arg_count=4) 449 | def test_missing_args_class_method(cls, test, x, y, z=3): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 450 | """Test a valid args section. | -sections.py:468:9: D417 Missing argument descriptions in the docstring for `test_missing_args_static_method`: `a`, `z` +D417 Missing argument descriptions in the docstring for `test_missing_args_static_method`: `a`, `z` + --> sections.py:468:9 | 466 | "(argument(s) a, z are missing descriptions in " 467 | "'test_missing_args_static_method' docstring)", arg_count=3) 468 | def test_missing_args_static_method(a, x, y, z=3, t=1): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 469 | """Test a valid args section. | -sections.py:498:9: D417 Missing argument description in the docstring for `test_incorrect_indent`: `y` +D417 Missing argument description in the docstring for `test_incorrect_indent`: `y` + --> sections.py:498:9 | 496 | "(argument(s) y are missing descriptions in " 497 | "'test_incorrect_indent' docstring)", arg_count=3) 498 | def test_incorrect_indent(self, x=1, y=2): # noqa: D207, D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^ D417 + | ^^^^^^^^^^^^^^^^^^^^^ 499 | """Reproducing issue #437. | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D418_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D418_D.py.snap index 515371cb79..850d6f3b93 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D418_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D418_D.py.snap @@ -1,30 +1,32 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -D.py:34:9: D418 Function decorated with `@overload` shouldn't contain a docstring +D418 Function decorated with `@overload` shouldn't contain a docstring + --> D.py:34:9 | 33 | @overload 34 | def overloaded_method(self, a: str) -> str: - | ^^^^^^^^^^^^^^^^^ D418 + | ^^^^^^^^^^^^^^^^^ 35 | """Foo bar documentation.""" 36 | ... | -D.py:90:9: D418 Function decorated with `@overload` shouldn't contain a docstring +D418 Function decorated with `@overload` shouldn't contain a docstring + --> D.py:90:9 | 89 | @overload 90 | def nested_overloaded_func(a: str) -> str: - | ^^^^^^^^^^^^^^^^^^^^^^ D418 + | ^^^^^^^^^^^^^^^^^^^^^^ 91 | """Foo bar documentation.""" 92 | ... | -D.py:110:5: D418 Function decorated with `@overload` shouldn't contain a docstring +D418 Function decorated with `@overload` shouldn't contain a docstring + --> D.py:110:5 | 109 | @overload 110 | def overloaded_func(a: str) -> str: - | ^^^^^^^^^^^^^^^ D418 + | ^^^^^^^^^^^^^^^ 111 | """Foo bar documentation.""" 112 | ... | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap index 18f659a0c5..e6077f93ad 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap @@ -1,29 +1,32 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D.py:20:9: D419 Docstring is empty +D419 Docstring is empty + --> D.py:20:9 | 19 | class meta: 20 | """""" - | ^^^^^^ D419 + | ^^^^^^ 21 | 22 | @expect('D102: Missing docstring in public method') | -D.py:74:5: D419 Docstring is empty +D419 Docstring is empty + --> D.py:74:5 | 72 | @expect('D419: Docstring is empty') 73 | def function(): 74 | """ """ - | ^^^^^^^ D419 + | ^^^^^^^ 75 | def ok_since_nested(): 76 | pass | -D.py:80:9: D419 Docstring is empty +D419 Docstring is empty + --> D.py:80:9 | 78 | @expect('D419: Docstring is empty') 79 | def nested(): 80 | '' - | ^^ D419 + | ^^ | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__all.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__all.snap index 4c659e417b..60a797e364 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__all.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__all.snap @@ -1,27 +1,31 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -all.py:1:1: D100 Missing docstring in public module -all.py:1:5: D103 Missing docstring in public function +D100 Missing docstring in public module +--> all.py:1:1 + +D103 Missing docstring in public function + --> all.py:1:5 | 1 | def public_func(): - | ^^^^^^^^^^^ D103 + | ^^^^^^^^^^^ 2 | pass | -all.py:9:7: D101 Missing docstring in public class +D101 Missing docstring in public class + --> all.py:9:7 | 9 | class PublicClass: - | ^^^^^^^^^^^ D101 + | ^^^^^^^^^^^ 10 | class PublicNestedClass: 11 | pass | -all.py:10:11: D106 Missing docstring in public nested class +D106 Missing docstring in public nested class + --> all.py:10:11 | 9 | class PublicClass: 10 | class PublicNestedClass: - | ^^^^^^^^^^^^^^^^^ D106 + | ^^^^^^^^^^^^^^^^^ 11 | pass | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap index 503c830dd1..5c3bf3e0bd 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs -snapshot_kind: text --- -bom.py:1:1: D300 [*] Use triple double quotes `"""` +D300 [*] Use triple double quotes `"""` + --> bom.py:1:1 | -1 | ''' SAM macro definitions ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 +1 | ''' SAM macro definitions ''' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to triple double quotes +help: Convert to triple double quotes ℹ Safe fix 1 |-''' SAM macro definitions ''' diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap index 00b6e1887d..262bc67768 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D209_D400.py:2:5: D209 [*] Multi-line docstring closing quotes should be on a separate line +D209 [*] Multi-line docstring closing quotes should be on a separate line + --> D209_D400.py:2:5 | 1 | def lorem(): 2 | / """lorem ipsum dolor sit amet consectetur adipiscing elit 3 | | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" - | |________________________________________________________________________^ D209 + | |________________________________________________________________________^ | - = help: Move closing quotes to new line +help: Move closing quotes to new line ℹ Safe fix 1 1 | def lorem(): @@ -17,14 +18,15 @@ D209_D400.py:2:5: D209 [*] Multi-line docstring closing quotes should be on a se 3 |+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua 4 |+ """ -D209_D400.py:2:5: D400 [*] First line should end with a period +D400 [*] First line should end with a period + --> D209_D400.py:2:5 | 1 | def lorem(): 2 | / """lorem ipsum dolor sit amet consectetur adipiscing elit 3 | | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" - | |________________________________________________________________________^ D400 + | |________________________________________________________________________^ | - = help: Add period +help: Add period ℹ Unsafe fix 1 1 | def lorem(): diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap index f99e5d73fb..63b975feb9 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap @@ -1,91 +1,103 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:1:5 | 1 | def f(x, y, z): - | ^ D417 + | ^ 2 | """Do something. | -D417.py:14:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:14:5 | 14 | def f(x, y, z): - | ^ D417 + | ^ 15 | """Do something. | -D417.py:27:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:27:5 | 27 | def f(x, y, z): - | ^ D417 + | ^ 28 | """Do something. | -D417.py:39:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:39:5 | 39 | def f(x, y, z): - | ^ D417 + | ^ 40 | """Do something. | -D417.py:52:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:52:5 | 52 | def f(x, y, z): - | ^ D417 + | ^ 53 | """Do something. | -D417.py:65:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:65:5 | 65 | def f(x, y, z): - | ^ D417 + | ^ 66 | """Do something. | -D417.py:77:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:77:5 | 77 | def f(x, y, z): - | ^ D417 + | ^ 78 | """Do something. | -D417.py:98:5: D417 Missing argument description in the docstring for `f`: `x` +D417 Missing argument description in the docstring for `f`: `x` + --> D417.py:98:5 | 98 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 99 | """Do something. | -D417.py:108:5: D417 Missing argument description in the docstring for `f`: `*args` +D417 Missing argument description in the docstring for `f`: `*args` + --> D417.py:108:5 | 108 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 109 | """Do something. | -D417.py:155:5: D417 Missing argument description in the docstring for `select_data`: `auto_save` +D417 Missing argument description in the docstring for `select_data`: `auto_save` + --> D417.py:155:5 | 155 | def select_data( - | ^^^^^^^^^^^ D417 + | ^^^^^^^^^^^ 156 | query: str, 157 | args: tuple, | -D417.py:172:5: D417 Missing argument description in the docstring for `f`: `**kwargs` +D417 Missing argument description in the docstring for `f`: `**kwargs` + --> D417.py:172:5 | 170 | """ 171 | 172 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 173 | """Do something. | -D417.py:199:5: D417 Missing argument description in the docstring for `should_fail`: `Args` +D417 Missing argument description in the docstring for `should_fail`: `Args` + --> D417.py:199:5 | 198 | # undocumented argument with the same name as a section 199 | def should_fail(payload, Args): - | ^^^^^^^^^^^ D417 + | ^^^^^^^^^^^ 200 | """ 201 | Send a message. | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google_ignore_var_parameters.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google_ignore_var_parameters.snap index d09b599a09..f645ff960e 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google_ignore_var_parameters.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google_ignore_var_parameters.snap @@ -1,75 +1,85 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:1:5 | 1 | def f(x, y, z): - | ^ D417 + | ^ 2 | """Do something. | -D417.py:14:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:14:5 | 14 | def f(x, y, z): - | ^ D417 + | ^ 15 | """Do something. | -D417.py:27:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:27:5 | 27 | def f(x, y, z): - | ^ D417 + | ^ 28 | """Do something. | -D417.py:39:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:39:5 | 39 | def f(x, y, z): - | ^ D417 + | ^ 40 | """Do something. | -D417.py:52:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:52:5 | 52 | def f(x, y, z): - | ^ D417 + | ^ 53 | """Do something. | -D417.py:65:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:65:5 | 65 | def f(x, y, z): - | ^ D417 + | ^ 66 | """Do something. | -D417.py:77:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:77:5 | 77 | def f(x, y, z): - | ^ D417 + | ^ 78 | """Do something. | -D417.py:98:5: D417 Missing argument description in the docstring for `f`: `x` +D417 Missing argument description in the docstring for `f`: `x` + --> D417.py:98:5 | 98 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 99 | """Do something. | -D417.py:155:5: D417 Missing argument description in the docstring for `select_data`: `auto_save` +D417 Missing argument description in the docstring for `select_data`: `auto_save` + --> D417.py:155:5 | 155 | def select_data( - | ^^^^^^^^^^^ D417 + | ^^^^^^^^^^^ 156 | query: str, 157 | args: tuple, | -D417.py:199:5: D417 Missing argument description in the docstring for `should_fail`: `Args` +D417 Missing argument description in the docstring for `should_fail`: `Args` + --> D417.py:199:5 | 198 | # undocumented argument with the same name as a section 199 | def should_fail(payload, Args): - | ^^^^^^^^^^^ D417 + | ^^^^^^^^^^^ 200 | """ 201 | Send a message. | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap index f99e5d73fb..63b975feb9 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap @@ -1,91 +1,103 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:1:5 | 1 | def f(x, y, z): - | ^ D417 + | ^ 2 | """Do something. | -D417.py:14:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:14:5 | 14 | def f(x, y, z): - | ^ D417 + | ^ 15 | """Do something. | -D417.py:27:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:27:5 | 27 | def f(x, y, z): - | ^ D417 + | ^ 28 | """Do something. | -D417.py:39:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:39:5 | 39 | def f(x, y, z): - | ^ D417 + | ^ 40 | """Do something. | -D417.py:52:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:52:5 | 52 | def f(x, y, z): - | ^ D417 + | ^ 53 | """Do something. | -D417.py:65:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:65:5 | 65 | def f(x, y, z): - | ^ D417 + | ^ 66 | """Do something. | -D417.py:77:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:77:5 | 77 | def f(x, y, z): - | ^ D417 + | ^ 78 | """Do something. | -D417.py:98:5: D417 Missing argument description in the docstring for `f`: `x` +D417 Missing argument description in the docstring for `f`: `x` + --> D417.py:98:5 | 98 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 99 | """Do something. | -D417.py:108:5: D417 Missing argument description in the docstring for `f`: `*args` +D417 Missing argument description in the docstring for `f`: `*args` + --> D417.py:108:5 | 108 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 109 | """Do something. | -D417.py:155:5: D417 Missing argument description in the docstring for `select_data`: `auto_save` +D417 Missing argument description in the docstring for `select_data`: `auto_save` + --> D417.py:155:5 | 155 | def select_data( - | ^^^^^^^^^^^ D417 + | ^^^^^^^^^^^ 156 | query: str, 157 | args: tuple, | -D417.py:172:5: D417 Missing argument description in the docstring for `f`: `**kwargs` +D417 Missing argument description in the docstring for `f`: `**kwargs` + --> D417.py:172:5 | 170 | """ 171 | 172 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 173 | """Do something. | -D417.py:199:5: D417 Missing argument description in the docstring for `should_fail`: `Args` +D417 Missing argument description in the docstring for `should_fail`: `Args` + --> D417.py:199:5 | 198 | # undocumented argument with the same name as a section 199 | def should_fail(payload, Args): - | ^^^^^^^^^^^ D417 + | ^^^^^^^^^^^ 200 | """ 201 | Send a message. | diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified_ignore_var_parameters.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified_ignore_var_parameters.snap index f99e5d73fb..63b975feb9 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified_ignore_var_parameters.snap +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified_ignore_var_parameters.snap @@ -1,91 +1,103 @@ --- source: crates/ruff_linter/src/rules/pydocstyle/mod.rs --- -D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:1:5 | 1 | def f(x, y, z): - | ^ D417 + | ^ 2 | """Do something. | -D417.py:14:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:14:5 | 14 | def f(x, y, z): - | ^ D417 + | ^ 15 | """Do something. | -D417.py:27:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:27:5 | 27 | def f(x, y, z): - | ^ D417 + | ^ 28 | """Do something. | -D417.py:39:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` +D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + --> D417.py:39:5 | 39 | def f(x, y, z): - | ^ D417 + | ^ 40 | """Do something. | -D417.py:52:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:52:5 | 52 | def f(x, y, z): - | ^ D417 + | ^ 53 | """Do something. | -D417.py:65:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:65:5 | 65 | def f(x, y, z): - | ^ D417 + | ^ 66 | """Do something. | -D417.py:77:5: D417 Missing argument description in the docstring for `f`: `y` +D417 Missing argument description in the docstring for `f`: `y` + --> D417.py:77:5 | 77 | def f(x, y, z): - | ^ D417 + | ^ 78 | """Do something. | -D417.py:98:5: D417 Missing argument description in the docstring for `f`: `x` +D417 Missing argument description in the docstring for `f`: `x` + --> D417.py:98:5 | 98 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 99 | """Do something. | -D417.py:108:5: D417 Missing argument description in the docstring for `f`: `*args` +D417 Missing argument description in the docstring for `f`: `*args` + --> D417.py:108:5 | 108 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 109 | """Do something. | -D417.py:155:5: D417 Missing argument description in the docstring for `select_data`: `auto_save` +D417 Missing argument description in the docstring for `select_data`: `auto_save` + --> D417.py:155:5 | 155 | def select_data( - | ^^^^^^^^^^^ D417 + | ^^^^^^^^^^^ 156 | query: str, 157 | args: tuple, | -D417.py:172:5: D417 Missing argument description in the docstring for `f`: `**kwargs` +D417 Missing argument description in the docstring for `f`: `**kwargs` + --> D417.py:172:5 | 170 | """ 171 | 172 | def f(x, *args, **kwargs): - | ^ D417 + | ^ 173 | """Do something. | -D417.py:199:5: D417 Missing argument description in the docstring for `should_fail`: `Args` +D417 Missing argument description in the docstring for `should_fail`: `Args` + --> D417.py:199:5 | 198 | # undocumented argument with the same name as a section 199 | def should_fail(payload, Args): - | ^^^^^^^^^^^ D417 + | ^^^^^^^^^^^ 200 | """ 201 | Send a message. | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap index 386a6e2892..68c8fc9e8a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_0.py:2:8: F401 [*] `functools` imported but unused +F401 [*] `functools` imported but unused + --> F401_0.py:2:8 | 1 | from __future__ import all_feature_names 2 | import functools, os - | ^^^^^^^^^ F401 + | ^^^^^^^^^ 3 | from datetime import datetime 4 | from collections import ( | - = help: Remove unused import: `functools` +help: Remove unused import: `functools` ℹ Safe fix 1 1 | from __future__ import all_feature_names @@ -19,16 +20,17 @@ F401_0.py:2:8: F401 [*] `functools` imported but unused 4 4 | from collections import ( 5 5 | Counter, -F401_0.py:6:5: F401 [*] `collections.OrderedDict` imported but unused +F401 [*] `collections.OrderedDict` imported but unused + --> F401_0.py:6:5 | 4 | from collections import ( 5 | Counter, 6 | OrderedDict, - | ^^^^^^^^^^^ F401 + | ^^^^^^^^^^^ 7 | namedtuple, 8 | ) | - = help: Remove unused import: `collections.OrderedDict` +help: Remove unused import: `collections.OrderedDict` ℹ Safe fix 3 3 | from datetime import datetime @@ -39,16 +41,17 @@ F401_0.py:6:5: F401 [*] `collections.OrderedDict` imported but unused 8 7 | ) 9 8 | import multiprocessing.pool -F401_0.py:12:8: F401 [*] `logging.handlers` imported but unused +F401 [*] `logging.handlers` imported but unused + --> F401_0.py:12:8 | 10 | import multiprocessing.process 11 | import logging.config 12 | import logging.handlers - | ^^^^^^^^^^^^^^^^ F401 + | ^^^^^^^^^^^^^^^^ 13 | from typing import ( 14 | TYPE_CHECKING, | - = help: Remove unused import: `logging.handlers` +help: Remove unused import: `logging.handlers` ℹ Safe fix 9 9 | import multiprocessing.pool @@ -59,14 +62,15 @@ F401_0.py:12:8: F401 [*] `logging.handlers` imported but unused 14 13 | TYPE_CHECKING, 15 14 | NamedTuple, -F401_0.py:32:12: F401 [*] `shelve` imported but unused +F401 [*] `shelve` imported but unused + --> F401_0.py:32:12 | 31 | if TYPE_CHECKING: 32 | import shelve - | ^^^^^^ F401 + | ^^^^^^ 33 | import importlib | - = help: Remove unused import: `shelve` +help: Remove unused import: `shelve` ℹ Safe fix 29 29 | from models import Fruit, Nut, Vegetable @@ -77,16 +81,17 @@ F401_0.py:32:12: F401 [*] `shelve` imported but unused 34 33 | 35 34 | if TYPE_CHECKING: -F401_0.py:33:12: F401 [*] `importlib` imported but unused +F401 [*] `importlib` imported but unused + --> F401_0.py:33:12 | 31 | if TYPE_CHECKING: 32 | import shelve 33 | import importlib - | ^^^^^^^^^ F401 + | ^^^^^^^^^ 34 | 35 | if TYPE_CHECKING: | - = help: Remove unused import: `importlib` +help: Remove unused import: `importlib` ℹ Safe fix 30 30 | @@ -97,16 +102,17 @@ F401_0.py:33:12: F401 [*] `importlib` imported but unused 35 34 | if TYPE_CHECKING: 36 35 | """Hello, world!""" -F401_0.py:37:12: F401 [*] `pathlib` imported but unused +F401 [*] `pathlib` imported but unused + --> F401_0.py:37:12 | 35 | if TYPE_CHECKING: 36 | """Hello, world!""" 37 | import pathlib - | ^^^^^^^ F401 + | ^^^^^^^ 38 | 39 | z = 1 | - = help: Remove unused import: `pathlib` +help: Remove unused import: `pathlib` ℹ Safe fix 34 34 | @@ -117,13 +123,14 @@ F401_0.py:37:12: F401 [*] `pathlib` imported but unused 39 38 | z = 1 40 39 | -F401_0.py:52:16: F401 [*] `pickle` imported but unused +F401 [*] `pickle` imported but unused + --> F401_0.py:52:16 | 51 | def b(self) -> None: 52 | import pickle - | ^^^^^^ F401 + | ^^^^^^ | - = help: Remove unused import: `pickle` +help: Remove unused import: `pickle` ℹ Safe fix 49 49 | z = multiprocessing.pool.ThreadPool() @@ -135,15 +142,16 @@ F401_0.py:52:16: F401 [*] `pickle` imported but unused 54 54 | 55 55 | __all__ = ["ClassA"] + ["ClassB"] -F401_0.py:93:16: F401 [*] `x` imported but unused +F401 [*] `x` imported but unused + --> F401_0.py:93:16 | 91 | match *0, 1, *2: 92 | case 0,: 93 | import x - | ^ F401 + | ^ 94 | import y | - = help: Remove unused import: `x` +help: Remove unused import: `x` ℹ Safe fix 90 90 | # Test: match statements. @@ -154,14 +162,15 @@ F401_0.py:93:16: F401 [*] `x` imported but unused 95 94 | 96 95 | -F401_0.py:94:16: F401 [*] `y` imported but unused +F401 [*] `y` imported but unused + --> F401_0.py:94:16 | 92 | case 0,: 93 | import x 94 | import y - | ^ F401 + | ^ | - = help: Remove unused import: `y` +help: Remove unused import: `y` ℹ Safe fix 91 91 | match *0, 1, *2: @@ -172,16 +181,17 @@ F401_0.py:94:16: F401 [*] `y` imported but unused 96 95 | 97 96 | # Test: access a sub-importation via an alias. -F401_0.py:99:8: F401 [*] `foo.bar.baz` imported but unused +F401 [*] `foo.bar.baz` imported but unused + --> F401_0.py:99:8 | 97 | # Test: access a sub-importation via an alias. 98 | import foo.bar as bop 99 | import foo.bar.baz - | ^^^^^^^^^^^ F401 + | ^^^^^^^^^^^ 100 | 101 | print(bop.baz.read_csv("test.csv")) | - = help: Remove unused import: `foo.bar.baz` +help: Remove unused import: `foo.bar.baz` ℹ Safe fix 96 96 | @@ -192,16 +202,17 @@ F401_0.py:99:8: F401 [*] `foo.bar.baz` imported but unused 101 100 | print(bop.baz.read_csv("test.csv")) 102 101 | -F401_0.py:105:12: F401 [*] `a1` imported but unused +F401 [*] `a1` imported but unused + --> F401_0.py:105:12 | 103 | # Test: isolated deletions. 104 | if TYPE_CHECKING: 105 | import a1 - | ^^ F401 + | ^^ 106 | 107 | import a2 | - = help: Remove unused import: `a1` +help: Remove unused import: `a1` ℹ Safe fix 102 102 | @@ -212,14 +223,15 @@ F401_0.py:105:12: F401 [*] `a1` imported but unused 107 106 | import a2 108 107 | -F401_0.py:107:12: F401 [*] `a2` imported but unused +F401 [*] `a2` imported but unused + --> F401_0.py:107:12 | 105 | import a1 106 | 107 | import a2 - | ^^ F401 + | ^^ | - = help: Remove unused import: `a2` +help: Remove unused import: `a2` ℹ Safe fix 104 104 | if TYPE_CHECKING: @@ -230,16 +242,17 @@ F401_0.py:107:12: F401 [*] `a2` imported but unused 109 108 | 110 109 | match *0, 1, *2: -F401_0.py:112:16: F401 [*] `b1` imported but unused +F401 [*] `b1` imported but unused + --> F401_0.py:112:16 | 110 | match *0, 1, *2: 111 | case 0,: 112 | import b1 - | ^^ F401 + | ^^ 113 | 114 | import b2 | - = help: Remove unused import: `b1` +help: Remove unused import: `b1` ℹ Safe fix 109 109 | @@ -250,14 +263,15 @@ F401_0.py:112:16: F401 [*] `b1` imported but unused 114 113 | import b2 115 114 | -F401_0.py:114:16: F401 [*] `b2` imported but unused +F401 [*] `b2` imported but unused + --> F401_0.py:114:16 | 112 | import b1 113 | 114 | import b2 - | ^^ F401 + | ^^ | - = help: Remove unused import: `b2` +help: Remove unused import: `b2` ℹ Safe fix 111 111 | case 0,: @@ -268,13 +282,14 @@ F401_0.py:114:16: F401 [*] `b2` imported but unused 116 115 | 117 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7244 -F401_0.py:122:1: F401 [*] `datameta_client_lib.model_helpers.noqa` imported but unused +F401 [*] `datameta_client_lib.model_helpers.noqa` imported but unused + --> F401_0.py:122:1 | 121 | from datameta_client_lib.model_helpers import ( 122 | noqa ) - | ^^^^ F401 + | ^^^^ | - = help: Remove unused import: `datameta_client_lib.model_helpers.noqa` +help: Remove unused import: `datameta_client_lib.model_helpers.noqa` ℹ Safe fix 118 118 | from datameta_client_lib.model_utils import ( # noqa: F401 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap index 55ff498a05..5ed90379ca 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_10.py:6:16: F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability +F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability + --> F401_10.py:6:16 | 4 | def module_not_found_error(): 5 | try: 6 | import orjson - | ^^^^^^ F401 + | ^^^^^^ 7 | 8 | return True | - = help: Remove unused import: `orjson` +help: Remove unused import: `orjson` -F401_10.py:15:16: F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability +F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability + --> F401_10.py:15:16 | 13 | def import_error(): 14 | try: 15 | import orjson - | ^^^^^^ F401 + | ^^^^^^ 16 | 17 | return True | - = help: Remove unused import: `orjson` +help: Remove unused import: `orjson` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap index 88d251d0fa..365fd6bce5 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F401_11.py:4:27: F401 [*] `pathlib.PurePath` imported but unused +F401 [*] `pathlib.PurePath` imported but unused + --> F401_11.py:4:27 | 3 | from typing import List 4 | from pathlib import Path, PurePath - | ^^^^^^^^ F401 + | ^^^^^^^^ | - = help: Remove unused import: `pathlib.PurePath` +help: Remove unused import: `pathlib.PurePath` ℹ Safe fix 1 1 | """Test: parsing of nested string annotations.""" diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap index e868e4a466..f1a83cee3e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F401_15.py:5:25: F401 [*] `pathlib.Path` imported but unused +F401 [*] `pathlib.Path` imported but unused + --> F401_15.py:5:25 | 4 | if TYPE_CHECKING: 5 | from pathlib import Path - | ^^^^ F401 + | ^^^^ | - = help: Remove unused import: `pathlib.Path` +help: Remove unused import: `pathlib.Path` ℹ Safe fix 2 2 | from django.db.models import ForeignKey diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap index 24a1dc4ff1..a3d870b502 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_17.py:12:27: F401 [*] `threading.Thread` imported but unused +F401 [*] `threading.Thread` imported but unused + --> F401_17.py:12:27 | 11 | def fn(thread: Thread): 12 | from threading import Thread - | ^^^^^^ F401 + | ^^^^^^ 13 | 14 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the | - = help: Remove unused import: `threading.Thread` +help: Remove unused import: `threading.Thread` ℹ Safe fix 9 9 | @@ -20,15 +21,16 @@ F401_17.py:12:27: F401 [*] `threading.Thread` imported but unused 14 13 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the 15 14 | # top level. -F401_17.py:20:27: F401 [*] `threading.Thread` imported but unused +F401 [*] `threading.Thread` imported but unused + --> F401_17.py:20:27 | 19 | def fn(thread: Thread): 20 | from threading import Thread - | ^^^^^^ F401 + | ^^^^^^ 21 | 22 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the | - = help: Remove unused import: `threading.Thread` +help: Remove unused import: `threading.Thread` ℹ Safe fix 17 17 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap index 031fe90e78..3bef4fd0f4 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F401_18.py:5:12: F401 [*] `__future__` imported but unused +F401 [*] `__future__` imported but unused + --> F401_18.py:5:12 | 4 | def f(): 5 | import __future__ - | ^^^^^^^^^^ F401 + | ^^^^^^^^^^ | - = help: Remove unused import: `__future__` +help: Remove unused import: `__future__` ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap index 5fabeda173..13551928bf 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_23.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F401_23.py:4:16: F401 [*] `re.RegexFlag` imported but unused +F401 [*] `re.RegexFlag` imported but unused + --> F401_23.py:4:16 | 3 | from pathlib import Path 4 | from re import RegexFlag - | ^^^^^^^^^ F401 + | ^^^^^^^^^ 5 | from typing import Annotated | - = help: Remove unused import: `re.RegexFlag` +help: Remove unused import: `re.RegexFlag` ℹ Safe fix 1 1 | """Test: ensure that we treat strings in `typing.Annotation` as type definitions.""" diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_34.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_34.py.snap index 519e21f21a..dbbc13c516 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_34.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_34.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_34.py:45:24: F401 [*] `typing.Union` imported but unused +F401 [*] `typing.Union` imported but unused + --> F401_34.py:45:24 | 43 | # expressions either!) 44 | def f(): 45 | from typing import Union - | ^^^^^ F401 + | ^^^^^ 46 | 47 | from typing_extensions import TypeAliasType | - = help: Remove unused import: `typing.Union` +help: Remove unused import: `typing.Union` ℹ Safe fix 42 42 | # expressions (and type checkers probably wouldn't understand them as type @@ -21,15 +22,16 @@ F401_34.py:45:24: F401 [*] `typing.Union` imported but unused 47 46 | from typing_extensions import TypeAliasType 48 47 | -F401_34.py:58:24: F401 [*] `typing.Union` imported but unused +F401 [*] `typing.Union` imported but unused + --> F401_34.py:58:24 | 57 | def f(): 58 | from typing import Union - | ^^^^^ F401 + | ^^^^^ 59 | 60 | from typing_extensions import TypeAliasType | - = help: Remove unused import: `typing.Union` +help: Remove unused import: `typing.Union` ℹ Safe fix 55 55 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap index 5fe20fdee4..c1e8f17a83 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F401_5.py:2:17: F401 [*] `a.b.c` imported but unused +F401 [*] `a.b.c` imported but unused + --> F401_5.py:2:17 | 1 | """Test: removal of multi-segment and aliases imports.""" 2 | from a.b import c - | ^ F401 + | ^ 3 | from d.e import f as g 4 | import h.i | - = help: Remove unused import: `a.b.c` +help: Remove unused import: `a.b.c` ℹ Safe fix 1 1 | """Test: removal of multi-segment and aliases imports.""" @@ -19,16 +19,17 @@ F401_5.py:2:17: F401 [*] `a.b.c` imported but unused 4 3 | import h.i 5 4 | import j.k as l -F401_5.py:3:22: F401 [*] `d.e.f` imported but unused +F401 [*] `d.e.f` imported but unused + --> F401_5.py:3:22 | 1 | """Test: removal of multi-segment and aliases imports.""" 2 | from a.b import c 3 | from d.e import f as g - | ^ F401 + | ^ 4 | import h.i 5 | import j.k as l | - = help: Remove unused import: `d.e.f` +help: Remove unused import: `d.e.f` ℹ Safe fix 1 1 | """Test: removal of multi-segment and aliases imports.""" @@ -37,15 +38,16 @@ F401_5.py:3:22: F401 [*] `d.e.f` imported but unused 4 3 | import h.i 5 4 | import j.k as l -F401_5.py:4:8: F401 [*] `h.i` imported but unused +F401 [*] `h.i` imported but unused + --> F401_5.py:4:8 | 2 | from a.b import c 3 | from d.e import f as g 4 | import h.i - | ^^^ F401 + | ^^^ 5 | import j.k as l | - = help: Remove unused import: `h.i` +help: Remove unused import: `h.i` ℹ Safe fix 1 1 | """Test: removal of multi-segment and aliases imports.""" @@ -54,14 +56,15 @@ F401_5.py:4:8: F401 [*] `h.i` imported but unused 4 |-import h.i 5 4 | import j.k as l -F401_5.py:5:15: F401 [*] `j.k` imported but unused +F401 [*] `j.k` imported but unused + --> F401_5.py:5:15 | 3 | from d.e import f as g 4 | import h.i 5 | import j.k as l - | ^ F401 + | ^ | - = help: Remove unused import: `j.k` +help: Remove unused import: `j.k` ℹ Safe fix 2 2 | from a.b import c diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap index 24dbe932b4..97f478faa2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_6.py:7:25: F401 [*] `.background.BackgroundTasks` imported but unused +F401 [*] `.background.BackgroundTasks` imported but unused + --> F401_6.py:7:25 | 6 | # F401 `background.BackgroundTasks` imported but unused 7 | from .background import BackgroundTasks - | ^^^^^^^^^^^^^^^ F401 + | ^^^^^^^^^^^^^^^ 8 | 9 | # F401 `datastructures.UploadFile` imported but unused | - = help: Remove unused import: `.background.BackgroundTasks` +help: Remove unused import: `.background.BackgroundTasks` ℹ Safe fix 4 4 | from .applications import FastAPI as FastAPI @@ -20,15 +21,16 @@ F401_6.py:7:25: F401 [*] `.background.BackgroundTasks` imported but unused 9 8 | # F401 `datastructures.UploadFile` imported but unused 10 9 | from .datastructures import UploadFile as FileUpload -F401_6.py:10:43: F401 [*] `.datastructures.UploadFile` imported but unused +F401 [*] `.datastructures.UploadFile` imported but unused + --> F401_6.py:10:43 | 9 | # F401 `datastructures.UploadFile` imported but unused 10 | from .datastructures import UploadFile as FileUpload - | ^^^^^^^^^^ F401 + | ^^^^^^^^^^ 11 | 12 | # OK | - = help: Remove unused import: `.datastructures.UploadFile` +help: Remove unused import: `.datastructures.UploadFile` ℹ Safe fix 7 7 | from .background import BackgroundTasks @@ -39,15 +41,16 @@ F401_6.py:10:43: F401 [*] `.datastructures.UploadFile` imported but unused 12 11 | # OK 13 12 | import applications as applications -F401_6.py:16:8: F401 [*] `background` imported but unused +F401 [*] `background` imported but unused + --> F401_6.py:16:8 | 15 | # F401 `background` imported but unused 16 | import background - | ^^^^^^^^^^ F401 + | ^^^^^^^^^^ 17 | 18 | # F401 `datastructures` imported but unused | - = help: Remove unused import: `background` +help: Remove unused import: `background` ℹ Safe fix 13 13 | import applications as applications @@ -58,13 +61,14 @@ F401_6.py:16:8: F401 [*] `background` imported but unused 18 17 | # F401 `datastructures` imported but unused 19 18 | import datastructures as structures -F401_6.py:19:26: F401 [*] `datastructures` imported but unused +F401 [*] `datastructures` imported but unused + --> F401_6.py:19:26 | 18 | # F401 `datastructures` imported but unused 19 | import datastructures as structures - | ^^^^^^^^^^ F401 + | ^^^^^^^^^^ | - = help: Remove unused import: `datastructures` +help: Remove unused import: `datastructures` ℹ Safe fix 16 16 | import background diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap index 0b27d19ff6..f269ad8657 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F401_7.py:30:5: F401 [*] `typing.Union` imported but unused +F401 [*] `typing.Union` imported but unused + --> F401_7.py:30:5 | 28 | from typing import ( 29 | Mapping, # noqa: F401 30 | Union, - | ^^^^^ F401 + | ^^^^^ 31 | ) | - = help: Remove unused import: `typing.Union` +help: Remove unused import: `typing.Union` ℹ Safe fix 27 27 | # This should ignore the first error. @@ -23,13 +23,14 @@ F401_7.py:30:5: F401 [*] `typing.Union` imported but unused 33 32 | # This should ignore both errors. 34 33 | from typing import ( # noqa -F401_7.py:66:20: F401 [*] `typing.Awaitable` imported but unused +F401 [*] `typing.Awaitable` imported but unused + --> F401_7.py:66:20 | 65 | # This should mark F501 as unused. 66 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^ F401 + | ^^^^^^^^^ | - = help: Remove unused import +help: Remove unused import ℹ Safe fix 63 63 | from typing import AsyncIterable, AsyncGenerator # noqa @@ -37,13 +38,14 @@ F401_7.py:66:20: F401 [*] `typing.Awaitable` imported but unused 65 65 | # This should mark F501 as unused. 66 |-from typing import Awaitable, AwaitableGenerator # noqa: F501 -F401_7.py:66:31: F401 [*] `typing.AwaitableGenerator` imported but unused +F401 [*] `typing.AwaitableGenerator` imported but unused + --> F401_7.py:66:31 | 65 | # This should mark F501 as unused. 66 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^^^^^^^^^^ F401 + | ^^^^^^^^^^^^^^^^^^ | - = help: Remove unused import +help: Remove unused import ℹ Safe fix 63 63 | from typing import AsyncIterable, AsyncGenerator # noqa diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap index 5c8875f802..85c2ef1cc8 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F401_9.py:4:22: F401 [*] `foo.baz` imported but unused +F401 [*] `foo.baz` imported but unused + --> F401_9.py:4:22 | 3 | __all__ = ("bar",) 4 | from foo import bar, baz - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `foo.baz` +help: Remove unused import: `foo.baz` ℹ Safe fix 1 1 | """Test: late-binding of `__all__`.""" diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_24____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_24____init__.py.snap index 895939cdf6..62d0728c6f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_24____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_24____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:19:8: F401 [*] `sys` imported but unused +F401 [*] `sys` imported but unused + --> __init__.py:19:8 | 19 | import sys # F401: remove unused - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `sys` +help: Remove unused import: `sys` ℹ Unsafe fix 16 16 | import argparse as argparse # Ok: is redundant alias @@ -18,12 +18,13 @@ __init__.py:19:8: F401 [*] `sys` imported but unused 21 20 | 22 21 | # first-party -__init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:33:15 | 33 | from . import unused # F401: change to redundant alias - | ^^^^^^ F401 + | ^^^^^^ | - = help: Remove unused import: `.unused` +help: Remove unused import: `.unused` ℹ Unsafe fix 30 30 | from . import aliased as aliased # Ok: is redundant alias @@ -34,12 +35,13 @@ __init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, ad 35 34 | 36 35 | from . import renamed as bees # F401: no fix -__init__.py:36:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:36:26 | 36 | from . import renamed as bees # F401: no fix - | ^^^^ F401 + | ^^^^ | - = help: Remove unused import: `.renamed` +help: Remove unused import: `.renamed` ℹ Unsafe fix 33 33 | from . import unused # F401: change to redundant alias diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_25__all_nonempty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_25__all_nonempty____init__.py.snap index 419a8ae236..3be84f3e29 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_25__all_nonempty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_25__all_nonempty____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:19:8: F401 [*] `sys` imported but unused +F401 [*] `sys` imported but unused + --> __init__.py:19:8 | 19 | import sys # F401: remove unused - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `sys` +help: Remove unused import: `sys` ℹ Unsafe fix 16 16 | import argparse # Ok: is exported in __all__ @@ -18,12 +18,13 @@ __init__.py:19:8: F401 [*] `sys` imported but unused 21 20 | 22 21 | # first-party -__init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:36:15 | 36 | from . import unused # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Remove unused import: `.unused` +help: Remove unused import: `.unused` ℹ Unsafe fix 33 33 | from . import exported # Ok: is exported in __all__ @@ -34,12 +35,13 @@ __init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, ad 38 37 | 39 38 | from . import renamed as bees # F401: add to __all__ -__init__.py:39:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:39:26 | 39 | from . import renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Remove unused import: `.renamed` +help: Remove unused import: `.renamed` ℹ Unsafe fix 36 36 | from . import unused # F401: add to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_26__all_empty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_26__all_empty____init__.py.snap index 165f850183..52b04aa829 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_26__all_empty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_26__all_empty____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Remove unused import: `.unused` +help: Remove unused import: `.unused` ℹ Unsafe fix 2 2 | """ @@ -18,12 +18,13 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add 7 6 | 8 7 | from . import renamed as bees # F401: add to __all__ -__init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:26 | 8 | from . import renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Remove unused import: `.renamed` +help: Remove unused import: `.renamed` ℹ Unsafe fix 5 5 | from . import unused # F401: add to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_27__all_mistyped____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_27__all_mistyped____init__.py.snap index b20f2f1cf7..5308d3121e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_27__all_mistyped____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_27__all_mistyped____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused # F401: recommend add to all w/o fix - | ^^^^^^ F401 + | ^^^^^^ | - = help: Remove unused import: `.unused` +help: Remove unused import: `.unused` ℹ Unsafe fix 2 2 | """ @@ -18,12 +18,13 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add 7 6 | 8 7 | from . import renamed as bees # F401: recommend add to all w/o fix -__init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:26 | 8 | from . import renamed as bees # F401: recommend add to all w/o fix - | ^^^^ F401 + | ^^^^ | - = help: Remove unused import: `.renamed` +help: Remove unused import: `.renamed` ℹ Unsafe fix 5 5 | from . import unused # F401: recommend add to all w/o fix diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_28__all_multiple____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_28__all_multiple____init__.py.snap index 6cde57d135..6f5291bb12 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_28__all_multiple____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_28__all_multiple____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused, renamed as bees # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Remove unused import +help: Remove unused import ℹ Unsafe fix 2 2 | """ @@ -18,12 +18,13 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add 7 6 | 8 7 | __all__ = []; -__init__.py:5:34: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:34 | 5 | from . import unused, renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Remove unused import +help: Remove unused import ℹ Unsafe fix 2 2 | """ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap index be576ca11c..8483e6b58f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_29__all_conditional____init__.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:8:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:15 | 6 | import sys 7 | 8 | from . import unused, exported, renamed as bees - | ^^^^^^ F401 + | ^^^^^^ 9 | 10 | if sys.version_info > (3, 9): | - = help: Remove unused import +help: Remove unused import ℹ Unsafe fix 5 5 | @@ -22,16 +23,17 @@ __init__.py:8:15: F401 [*] `.unused` imported but unused; consider removing, add 10 10 | if sys.version_info > (3, 9): 11 11 | from . import also_exported -__init__.py:8:44: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:44 | 6 | import sys 7 | 8 | from . import unused, exported, renamed as bees - | ^^^^ F401 + | ^^^^ 9 | 10 | if sys.version_info > (3, 9): | - = help: Remove unused import +help: Remove unused import ℹ Unsafe fix 5 5 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap index f65dc78b59..09741b40a6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_deprecated_option_F401_30.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F401_30.py:6:19: F401 [*] `.main.MaμToMan` imported but unused +F401 [*] `.main.MaμToMan` imported but unused + --> F401_30.py:6:19 | 4 | """ 5 | 6 | from .main import MaµToMan - | ^^^^^^^^ F401 + | ^^^^^^^^ | - = help: Remove unused import: `.main.MaμToMan` +help: Remove unused import: `.main.MaμToMan` ℹ Safe fix 3 3 | even if they have characters in them that undergo NFKC normalization diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_24____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_24____init__.py.snap index 52c0e6801f..e1c221c259 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_24____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_24____init__.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:19:8: F401 `sys` imported but unused +F401 `sys` imported but unused + --> __init__.py:19:8 | 19 | import sys # F401: remove unused - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `sys` +help: Remove unused import: `sys` -__init__.py:33:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:33:15 | 33 | from . import unused # F401: change to redundant alias - | ^^^^^^ F401 + | ^^^^^^ | - = help: Use an explicit re-export: `unused as unused` +help: Use an explicit re-export: `unused as unused` -__init__.py:36:26: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:36:26 | 36 | from . import renamed as bees # F401: no fix - | ^^^^ F401 + | ^^^^ | - = help: Use an explicit re-export: `renamed as renamed` +help: Use an explicit re-export: `renamed as renamed` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_25__all_nonempty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_25__all_nonempty____init__.py.snap index ccac7c81c5..778c49ba2d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_25__all_nonempty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_25__all_nonempty____init__.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:19:8: F401 `sys` imported but unused +F401 `sys` imported but unused + --> __init__.py:19:8 | 19 | import sys # F401: remove unused - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `sys` +help: Remove unused import: `sys` -__init__.py:36:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:36:15 | 36 | from . import unused # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Add unused import `unused` to __all__ +help: Add unused import `unused` to __all__ -__init__.py:39:26: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:39:26 | 39 | from . import renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Add unused import `bees` to __all__ +help: Add unused import `bees` to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_26__all_empty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_26__all_empty____init__.py.snap index c6f6913969..24e342c8ae 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_26__all_empty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_26__all_empty____init__.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Add unused import `unused` to __all__ +help: Add unused import `unused` to __all__ -__init__.py:8:26: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:26 | 8 | from . import renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Add unused import `bees` to __all__ +help: Add unused import `bees` to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_27__all_mistyped____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_27__all_mistyped____init__.py.snap index 17856067e6..f74e91a35b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_27__all_mistyped____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_27__all_mistyped____init__.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused # F401: recommend add to all w/o fix - | ^^^^^^ F401 + | ^^^^^^ | - = help: Add unused import `unused` to __all__ +help: Add unused import `unused` to __all__ -__init__.py:8:26: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:26 | 8 | from . import renamed as bees # F401: recommend add to all w/o fix - | ^^^^ F401 + | ^^^^ | - = help: Add unused import `bees` to __all__ +help: Add unused import `bees` to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_28__all_multiple____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_28__all_multiple____init__.py.snap index 0ba97b9289..011604a75c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_28__all_multiple____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_28__all_multiple____init__.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused, renamed as bees # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Add unused import `unused` to __all__ +help: Add unused import `unused` to __all__ -__init__.py:5:34: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:34 | 5 | from . import unused, renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Add unused import `bees` to __all__ +help: Add unused import `bees` to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_29__all_conditional____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_29__all_conditional____init__.py.snap index 57c17bb0c5..3cc9d9eac6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_29__all_conditional____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_stable_F401_29__all_conditional____init__.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:8:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:15 | 6 | import sys 7 | 8 | from . import unused, exported, renamed as bees - | ^^^^^^ F401 + | ^^^^^^ 9 | 10 | if sys.version_info > (3, 9): | - = help: Remove unused import +help: Remove unused import -__init__.py:8:44: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:44 | 6 | import sys 7 | 8 | from . import unused, exported, renamed as bees - | ^^^^ F401 + | ^^^^ 9 | 10 | if sys.version_info > (3, 9): | - = help: Remove unused import +help: Remove unused import diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.ipynb.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.ipynb.snap index 3681a82bf4..f306dca43e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.ipynb.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.ipynb.snap @@ -1,22 +1,23 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F402.ipynb:3:5: F402 Import `os` from cell 1, line 1 shadowed by loop variable +F402 Import `os` from cell 1, line 1 shadowed by loop variable + --> F402.ipynb:3:5 | 1 | import os 2 | import os.path as path 3 | for os in range(3): - | ^^ F402 + | ^^ 4 | pass 5 | for path in range(3): | -F402.ipynb:5:5: F402 Import `path` from cell 1, line 2 shadowed by loop variable +F402 Import `path` from cell 1, line 2 shadowed by loop variable + --> F402.ipynb:5:5 | 3 | for os in range(3): 4 | pass 5 | for path in range(3): - | ^^^^ F402 + | ^^^^ 6 | pass | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap index b6c04ece22..e077b7ad40 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F402.py:5:5: F402 Import `os` from line 1 shadowed by loop variable +F402 Import `os` from line 1 shadowed by loop variable + --> F402.py:5:5 | 5 | for os in range(3): - | ^^ F402 + | ^^ 6 | pass | -F402.py:8:5: F402 Import `path` from line 2 shadowed by loop variable +F402 Import `path` from line 2 shadowed by loop variable + --> F402.py:8:5 | 6 | pass 7 | 8 | for path in range(3): - | ^^^^ F402 + | ^^^^ 9 | pass | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap index 954899e12a..a990db7a60 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F403.py:1:1: F403 `from F634 import *` used; unable to detect undefined names +F403 `from F634 import *` used; unable to detect undefined names + --> F403.py:1:1 | 1 | from F634 import * - | ^^^^^^^^^^^^^^^^^^ F403 + | ^^^^^^^^^^^^^^^^^^ 2 | from F634 import * # noqa: E501 | -F403.py:2:1: F403 `from F634 import *` used; unable to detect undefined names +F403 `from F634 import *` used; unable to detect undefined names + --> F403.py:2:1 | 1 | from F634 import * 2 | from F634 import * # noqa: E501 - | ^^^^^^^^^^^^^^^^^^ F403 + | ^^^^^^^^^^^^^^^^^^ 3 | 4 | from F634 import * # noqa | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_0.py.snap index 0e5776e9b3..aa61d93701 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_0.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F404_0.py:6:1: F404 `from __future__` imports must occur at the beginning of the file +F404 `from __future__` imports must occur at the beginning of the file + --> F404_0.py:6:1 | 4 | from collections import namedtuple 5 | 6 | from __future__ import print_function - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | import __future__ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.py.snap index 533b95b9a7..af21b5f916 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404_1.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F404_1.py:5:1: F404 `from __future__` imports must occur at the beginning of the file +F404 `from __future__` imports must occur at the beginning of the file + --> F404_1.py:5:1 | 3 | """Non-docstring""" 4 | 5 | from __future__ import absolute_import - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap index 566ebc15bb..382d83dce7 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap @@ -1,17 +1,19 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F405.py:5:11: F405 `name` may be undefined, or defined from star imports +F405 `name` may be undefined, or defined from star imports + --> F405.py:5:11 | 4 | def print_name(): 5 | print(name) - | ^^^^ F405 + | ^^^^ | -F405.py:11:12: F405 `a` may be undefined, or defined from star imports +F405 `a` may be undefined, or defined from star imports + --> F405.py:11:12 | 9 | print(name) 10 | 11 | __all__ = ['a'] - | ^^^ F405 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F406_F406.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F406_F406.py.snap index 4b7e774e13..e09f491710 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F406_F406.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F406_F406.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F406.py:5:5: F406 `from F634 import *` only allowed at module level +F406 `from F634 import *` only allowed at module level + --> F406.py:5:5 | 4 | def f(): 5 | from F634 import * - | ^^^^^^^^^^^^^^^^^^ F406 + | ^^^^^^^^^^^^^^^^^^ | -F406.py:9:5: F406 `from F634 import *` only allowed at module level +F406 `from F634 import *` only allowed at module level + --> F406.py:9:5 | 8 | class F: 9 | from F634 import * - | ^^^^^^^^^^^^^^^^^^ F406 + | ^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F407_F407.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F407_F407.py.snap index faf0e89f01..8354bd9884 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F407_F407.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F407_F407.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F407.py:2:24: F407 Future feature `non_existent_feature` is not defined +F407 Future feature `non_existent_feature` is not defined + --> F407.py:2:24 | 1 | from __future__ import print_function 2 | from __future__ import non_existent_feature - | ^^^^^^^^^^^^^^^^^^^^ F407 + | ^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F501_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F501_F50x.py.snap index e08ce6e14b..b91dc6a2a6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F501_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F501_F50x.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F50x.py:1:1: F501 `%`-format string has invalid format string: incomplete format +F501 `%`-format string has invalid format string: incomplete format + --> F50x.py:1:1 | 1 | '%(foo)' % {'foo': 'bar'} # F501 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ F501 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | '%s %(foo)s' % {'foo': 'bar'} # F506 3 | '%(foo)s %s' % {'foo': 'bar'} # F506 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F502.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F502.py.snap index be81d392b1..25dc86c080 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F502.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F502.py.snap @@ -1,70 +1,76 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F502.py:6:1: F502 `%`-format string expected mapping but got sequence +F502 `%`-format string expected mapping but got sequence + --> F502.py:6:1 | 4 | "%(bob)s" % {"bob": "bob"} 5 | "%(bob)s" % {**{"bob": "bob"}} 6 | "%(bob)s" % ["bob"] # F202 - | ^^^^^^^^^^^^^^^^^^^ F502 + | ^^^^^^^^^^^^^^^^^^^ 7 | "%(bob)s" % ("bob",) # F202 8 | "%(bob)s" % {"bob"} # F202 | -F502.py:7:1: F502 `%`-format string expected mapping but got sequence +F502 `%`-format string expected mapping but got sequence + --> F502.py:7:1 | 5 | "%(bob)s" % {**{"bob": "bob"}} 6 | "%(bob)s" % ["bob"] # F202 7 | "%(bob)s" % ("bob",) # F202 - | ^^^^^^^^^^^^^^^^^^^^ F502 + | ^^^^^^^^^^^^^^^^^^^^ 8 | "%(bob)s" % {"bob"} # F202 9 | "%(bob)s" % [*["bob"]] # F202 | -F502.py:8:1: F502 `%`-format string expected mapping but got sequence +F502 `%`-format string expected mapping but got sequence + --> F502.py:8:1 | 6 | "%(bob)s" % ["bob"] # F202 7 | "%(bob)s" % ("bob",) # F202 8 | "%(bob)s" % {"bob"} # F202 - | ^^^^^^^^^^^^^^^^^^^ F502 + | ^^^^^^^^^^^^^^^^^^^ 9 | "%(bob)s" % [*["bob"]] # F202 10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} | -F502.py:9:1: F502 `%`-format string expected mapping but got sequence +F502 `%`-format string expected mapping but got sequence + --> F502.py:9:1 | 7 | "%(bob)s" % ("bob",) # F202 8 | "%(bob)s" % {"bob"} # F202 9 | "%(bob)s" % [*["bob"]] # F202 - | ^^^^^^^^^^^^^^^^^^^^^^ F502 + | ^^^^^^^^^^^^^^^^^^^^^^ 10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} 11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 | -F502.py:11:1: F502 `%`-format string expected mapping but got sequence +F502 `%`-format string expected mapping but got sequence + --> F502.py:11:1 | 9 | "%(bob)s" % [*["bob"]] # F202 10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} 11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 | -F502.py:12:1: F502 `%`-format string expected mapping but got sequence +F502 `%`-format string expected mapping but got sequence + --> F502.py:12:1 | 10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} 11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 | -F502.py:13:1: F502 `%`-format string expected mapping but got sequence +F502 `%`-format string expected mapping but got sequence + --> F502.py:13:1 | 11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F50x.py.snap index d95359d029..a80ee33ccd 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F50x.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F50x.py:9:1: F502 `%`-format string expected mapping but got sequence +F502 `%`-format string expected mapping but got sequence + --> F50x.py:9:1 | 7 | '%(bar)s' % {} # F505 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 9 | '%(bar)s' % (1, 2, 3) # F502 - | ^^^^^^^^^^^^^^^^^^^^^ F502 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | '%s %s' % {'k': 'v'} # F503 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F503.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F503.py.snap index f143255f41..2b42a94777 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F503.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F503.py.snap @@ -1,33 +1,35 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F503.py:17:1: F503 `%`-format string expected sequence but got mapping +F503 `%`-format string expected sequence but got mapping + --> F503.py:17:1 | 15 | # Multiple placeholders 16 | "%s %s" % dog 17 | "%s %s" % {"bob": "bob"} # F503 - | ^^^^^^^^^^^^^^^^^^^^^^^^ F503 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 18 | "%s %s" % {**{"bob": "bob"}} # F503 19 | "%s %s" % ["bob"] | -F503.py:18:1: F503 `%`-format string expected sequence but got mapping +F503 `%`-format string expected sequence but got mapping + --> F503.py:18:1 | 16 | "%s %s" % dog 17 | "%s %s" % {"bob": "bob"} # F503 18 | "%s %s" % {**{"bob": "bob"}} # F503 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F503 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | "%s %s" % ["bob"] 20 | "%s %s" % ("bob",) | -F503.py:23:1: F503 `%`-format string expected sequence but got mapping +F503 `%`-format string expected sequence but got mapping + --> F503.py:23:1 | 21 | "%s %s" % {"bob"} 22 | "%s %s" % [*["bob"]] 23 | "%s %s" % {"bob": "bob" for _ in range(1)} # F503 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F503 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | "%s %s" % ["bob" for _ in range(1)] 25 | "%s %s" % ("bob" for _ in range(1)) | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F50x.py.snap index a09a97f4a5..9bca2287bc 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F50x.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F50x.py:10:1: F503 `%`-format string expected sequence but got mapping +F503 `%`-format string expected sequence but got mapping + --> F50x.py:10:1 | 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 9 | '%(bar)s' % (1, 2, 3) # F502 10 | '%s %s' % {'k': 'v'} # F503 - | ^^^^^^^^^^^^^^^^^^^^ F503 + | ^^^^^^^^^^^^^^^^^^^^ 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap index 175af6e93b..e12ae328c0 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F504.py:3:1: F504 [*] `%`-format string has unused named argument(s): b +F504 [*] `%`-format string has unused named argument(s): b + --> F504.py:3:1 | 1 | # Ruff has no way of knowing if the following are F505s 2 | a = "wrong" 3 | "%(a)s %(c)s" % {a: "?", "b": "!"} # F504 ("b" not used) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | hidden = {"a": "!"} | - = help: Remove extra named arguments: b +help: Remove extra named arguments: b ℹ Safe fix 1 1 | # Ruff has no way of knowing if the following are F505s @@ -21,15 +22,16 @@ F504.py:3:1: F504 [*] `%`-format string has unused named argument(s): b 5 5 | hidden = {"a": "!"} 6 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) -F504.py:8:1: F504 [*] `%`-format string has unused named argument(s): b +F504 [*] `%`-format string has unused named argument(s): b + --> F504.py:8:1 | 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) 7 | 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) | - = help: Remove extra named arguments: b +help: Remove extra named arguments: b ℹ Safe fix 5 5 | hidden = {"a": "!"} @@ -41,15 +43,16 @@ F504.py:8:1: F504 [*] `%`-format string has unused named argument(s): b 10 10 | 11 11 | '' % {'a''b' : ''} # F504 ("ab" not used) -F504.py:9:1: F504 [*] `%`-format string has unused named argument(s): b +F504 [*] `%`-format string has unused named argument(s): b + --> F504.py:9:1 | 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | '' % {'a''b' : ''} # F504 ("ab" not used) | - = help: Remove extra named arguments: b +help: Remove extra named arguments: b ℹ Safe fix 6 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) @@ -61,16 +64,17 @@ F504.py:9:1: F504 [*] `%`-format string has unused named argument(s): b 11 11 | '' % {'a''b' : ''} # F504 ("ab" not used) 12 12 | -F504.py:11:1: F504 [*] `%`-format string has unused named argument(s): ab +F504 [*] `%`-format string has unused named argument(s): ab + --> F504.py:11:1 | 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) 10 | 11 | '' % {'a''b' : ''} # F504 ("ab" not used) - | ^^^^^^^^^^^^^^^^^^ F504 + | ^^^^^^^^^^^^^^^^^^ 12 | 13 | # https://github.com/astral-sh/ruff/issues/4899 | - = help: Remove extra named arguments: ab +help: Remove extra named arguments: ab ℹ Safe fix 8 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) @@ -82,17 +86,19 @@ F504.py:11:1: F504 [*] `%`-format string has unused named argument(s): ab 13 13 | # https://github.com/astral-sh/ruff/issues/4899 14 14 | "" % { -F504.py:14:1: F504 [*] `%`-format string has unused named argument(s): test1, test2 +F504 [*] `%`-format string has unused named argument(s): test1, test2 + --> F504.py:14:1 | 13 | # https://github.com/astral-sh/ruff/issues/4899 14 | / "" % { -15 | | 'test1': '', 'test2': '', -16 | | } - | |_^ F504 -17 | -18 | # https://github.com/astral-sh/ruff/issues/18806 +15 | | 'test1': '', +16 | | 'test2': '', +17 | | } + | |_^ +18 | +19 | # https://github.com/astral-sh/ruff/issues/18806 | - = help: Remove extra named arguments: test1, test2 +help: Remove extra named arguments: test1, test2 ℹ Safe fix 12 12 | @@ -104,13 +110,14 @@ F504.py:14:1: F504 [*] `%`-format string has unused named argument(s): test1, te 18 17 | 19 18 | # https://github.com/astral-sh/ruff/issues/18806 -F504.py:20:1: F504 [*] `%`-format string has unused named argument(s): greeting +F504 [*] `%`-format string has unused named argument(s): greeting + --> F504.py:20:1 | 19 | # https://github.com/astral-sh/ruff/issues/18806 20 | "Hello, %(name)s" % {"greeting": print(1), "name": "World"} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove extra named arguments: greeting +help: Remove extra named arguments: greeting ℹ Unsafe fix 17 17 | } diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap index 9aeabf5636..a20aace19c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F50x.py:8:1: F504 [*] `%`-format string has unused named argument(s): baz +F504 [*] `%`-format string has unused named argument(s): baz + --> F50x.py:8:1 | 6 | '%s %s' % (1, 2, 3) # F507 7 | '%(bar)s' % {} # F505 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | '%(bar)s' % (1, 2, 3) # F502 10 | '%s %s' % {'k': 'v'} # F503 | - = help: Remove extra named arguments: baz +help: Remove extra named arguments: baz ℹ Safe fix 5 5 | '%s %s' % (1,) # F507 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F50x.py.snap index af45048c88..89bd0a6076 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F50x.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F50x.py:7:1: F505 `%`-format string is missing argument(s) for placeholder(s): bar +F505 `%`-format string is missing argument(s) for placeholder(s): bar + --> F50x.py:7:1 | 5 | '%s %s' % (1,) # F507 6 | '%s %s' % (1, 2, 3) # F507 7 | '%(bar)s' % {} # F505 - | ^^^^^^^^^^^^^^ F505 + | ^^^^^^^^^^^^^^ 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 9 | '%(bar)s' % (1, 2, 3) # F502 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap index 8014d22098..3f3ee5f0ba 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap @@ -1,31 +1,34 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F50x.py:2:1: F506 `%`-format string has mixed positional and named placeholders +F506 `%`-format string has mixed positional and named placeholders + --> F50x.py:2:1 | 1 | '%(foo)' % {'foo': 'bar'} # F501 2 | '%s %(foo)s' % {'foo': 'bar'} # F506 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | '%(foo)s %s' % {'foo': 'bar'} # F506 4 | '%j' % (1,) # F509 | -F50x.py:3:1: F506 `%`-format string has mixed positional and named placeholders +F506 `%`-format string has mixed positional and named placeholders + --> F50x.py:3:1 | 1 | '%(foo)' % {'foo': 'bar'} # F501 2 | '%s %(foo)s' % {'foo': 'bar'} # F506 3 | '%(foo)s %s' % {'foo': 'bar'} # F506 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | '%j' % (1,) # F509 5 | '%s %s' % (1,) # F507 | -F50x.py:11:1: F506 `%`-format string has mixed positional and named placeholders +F506 `%`-format string has mixed positional and named placeholders + --> F50x.py:11:1 | 9 | '%(bar)s' % (1, 2, 3) # F502 10 | '%s %s' % {'k': 'v'} # F503 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | # ok: single %s with mapping | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F507_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F507_F50x.py.snap index 6b7efd75fe..6528dd1901 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F507_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F507_F50x.py.snap @@ -1,23 +1,24 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F50x.py:5:1: F507 `%`-format string has 2 placeholder(s) but 1 substitution(s) +F507 `%`-format string has 2 placeholder(s) but 1 substitution(s) + --> F50x.py:5:1 | 3 | '%(foo)s %s' % {'foo': 'bar'} # F506 4 | '%j' % (1,) # F509 5 | '%s %s' % (1,) # F507 - | ^^^^^^^^^^^^^^ F507 + | ^^^^^^^^^^^^^^ 6 | '%s %s' % (1, 2, 3) # F507 7 | '%(bar)s' % {} # F505 | -F50x.py:6:1: F507 `%`-format string has 2 placeholder(s) but 3 substitution(s) +F507 `%`-format string has 2 placeholder(s) but 3 substitution(s) + --> F50x.py:6:1 | 4 | '%j' % (1,) # F509 5 | '%s %s' % (1,) # F507 6 | '%s %s' % (1, 2, 3) # F507 - | ^^^^^^^^^^^^^^^^^^^ F507 + | ^^^^^^^^^^^^^^^^^^^ 7 | '%(bar)s' % {} # F505 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap index b441512343..a15979f5b0 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F50x.py:11:1: F508 `%`-format string `*` specifier requires sequence +F508 `%`-format string `*` specifier requires sequence + --> F50x.py:11:1 | 9 | '%(bar)s' % (1, 2, 3) # F502 10 | '%s %s' % {'k': 'v'} # F503 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F508 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | # ok: single %s with mapping | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F509_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F509_F50x.py.snap index fa405f0915..e3e36bd11e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F509_F50x.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F509_F50x.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F50x.py:4:1: F509 `%`-format string has unsupported format character `j` +F509 `%`-format string has unsupported format character `j` + --> F50x.py:4:1 | 2 | '%s %(foo)s' % {'foo': 'bar'} # F506 3 | '%(foo)s %s' % {'foo': 'bar'} # F506 4 | '%j' % (1,) # F509 - | ^^^^^^^^^^^ F509 + | ^^^^^^^^^^^ 5 | '%s %s' % (1,) # F507 6 | '%s %s' % (1, 2, 3) # F507 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap index c9f840f58a..6a61cb53a4 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap @@ -1,68 +1,75 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F521.py:1:1: F521 `.format` call has invalid format string: Single '{' encountered in format string +F521 `.format` call has invalid format string: Single '{' encountered in format string + --> F521.py:1:1 | 1 | "{".format(1) - | ^^^^^^^^^^^^^ F521 + | ^^^^^^^^^^^^^ 2 | "}".format(1) 3 | "{foo[}".format(foo=1) | -F521.py:2:1: F521 `.format` call has invalid format string: Single '}' encountered in format string +F521 `.format` call has invalid format string: Single '}' encountered in format string + --> F521.py:2:1 | 1 | "{".format(1) 2 | "}".format(1) - | ^^^^^^^^^^^^^ F521 + | ^^^^^^^^^^^^^ 3 | "{foo[}".format(foo=1) 4 | # too much string recursion (placeholder-in-placeholder) | -F521.py:3:1: F521 `.format` call has invalid format string: Expected '}' before end of string +F521 `.format` call has invalid format string: Expected '}' before end of string + --> F521.py:3:1 | 1 | "{".format(1) 2 | "}".format(1) 3 | "{foo[}".format(foo=1) - | ^^^^^^^^^^^^^^^^^^^^^^ F521 + | ^^^^^^^^^^^^^^^^^^^^^^ 4 | # too much string recursion (placeholder-in-placeholder) 5 | "{:{:{}}}".format(1, 2, 3) | -F521.py:5:1: F521 `.format` call has invalid format string: Max format placeholder recursion exceeded +F521 `.format` call has invalid format string: Max format placeholder recursion exceeded + --> F521.py:5:1 | 3 | "{foo[}".format(foo=1) 4 | # too much string recursion (placeholder-in-placeholder) 5 | "{:{:{}}}".format(1, 2, 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | # ruff picks these issues up, but flake8 doesn't 7 | "{foo[]}".format(foo={"": 1}) | -F521.py:7:1: F521 `.format` call has invalid format string: Empty attribute in format string +F521 `.format` call has invalid format string: Empty attribute in format string + --> F521.py:7:1 | 5 | "{:{:{}}}".format(1, 2, 3) 6 | # ruff picks these issues up, but flake8 doesn't 7 | "{foo[]}".format(foo={"": 1}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | "{foo..}".format(foo=1) 9 | "{foo..bar}".format(foo=1) | -F521.py:8:1: F521 `.format` call has invalid format string: Empty attribute in format string +F521 `.format` call has invalid format string: Empty attribute in format string + --> F521.py:8:1 | 6 | # ruff picks these issues up, but flake8 doesn't 7 | "{foo[]}".format(foo={"": 1}) 8 | "{foo..}".format(foo=1) - | ^^^^^^^^^^^^^^^^^^^^^^^ F521 + | ^^^^^^^^^^^^^^^^^^^^^^^ 9 | "{foo..bar}".format(foo=1) | -F521.py:9:1: F521 `.format` call has invalid format string: Empty attribute in format string +F521 `.format` call has invalid format string: Empty attribute in format string + --> F521.py:9:1 | 7 | "{foo[]}".format(foo={"": 1}) 8 | "{foo..}".format(foo=1) 9 | "{foo..bar}".format(foo=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # The following are all "good" uses of .format | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap index f6a9f22629..e3cd10e673 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F522.py:1:1: F522 [*] `.format` call has unused named argument(s): bar +F522 [*] `.format` call has unused named argument(s): bar + --> F522.py:1:1 | 1 | "{}".format(1, bar=2) # F522 - | ^^^^^^^^^^^^^^^^^^^^^ F522 + | ^^^^^^^^^^^^^^^^^^^^^ 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues | - = help: Remove extra named arguments: bar +help: Remove extra named arguments: bar ℹ Safe fix 1 |-"{}".format(1, bar=2) # F522 @@ -17,15 +18,16 @@ F522.py:1:1: F522 [*] `.format` call has unused named argument(s): bar 3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues 4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 -F522.py:2:1: F522 [*] `.format` call has unused named argument(s): spam +F522 [*] `.format` call has unused named argument(s): spam + --> F522.py:2:1 | 1 | "{}".format(1, bar=2) # F522 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F522 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 | - = help: Remove extra named arguments: spam +help: Remove extra named arguments: spam ℹ Safe fix 1 1 | "{}".format(1, bar=2) # F522 @@ -35,16 +37,17 @@ F522.py:2:1: F522 [*] `.format` call has unused named argument(s): spam 4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 5 5 | ('' -F522.py:4:1: F522 [*] `.format` call has unused named argument(s): eggs, ham +F522 [*] `.format` call has unused named argument(s): eggs, ham + --> F522.py:4:1 | 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F522 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | ('' 6 | .format(x=2)) # F522 | - = help: Remove extra named arguments: eggs, ham +help: Remove extra named arguments: eggs, ham ℹ Safe fix 1 1 | "{}".format(1, bar=2) # F522 @@ -56,18 +59,19 @@ F522.py:4:1: F522 [*] `.format` call has unused named argument(s): eggs, ham 6 6 | .format(x=2)) # F522 7 7 | -F522.py:5:2: F522 [*] `.format` call has unused named argument(s): x +F522 [*] `.format` call has unused named argument(s): x + --> F522.py:5:2 | 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 5 | ('' | __^ 6 | | .format(x=2)) # F522 - | |_____________^ F522 + | |_____________^ 7 | 8 | # https://github.com/astral-sh/ruff/issues/18806 | - = help: Remove extra named arguments: x +help: Remove extra named arguments: x ℹ Safe fix 3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues @@ -79,16 +83,17 @@ F522.py:5:2: F522 [*] `.format` call has unused named argument(s): x 8 8 | # https://github.com/astral-sh/ruff/issues/18806 9 9 | # The fix here is unsafe because the unused argument has side effect -F522.py:10:1: F522 [*] `.format` call has unused named argument(s): greeting +F522 [*] `.format` call has unused named argument(s): greeting + --> F522.py:10:1 | 8 | # https://github.com/astral-sh/ruff/issues/18806 9 | # The fix here is unsafe because the unused argument has side effect 10 | "Hello, {name}".format(greeting=print(1), name="World") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F522 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | # The fix here is safe because the unused argument has no side effect, | - = help: Remove extra named arguments: greeting +help: Remove extra named arguments: greeting ℹ Unsafe fix 7 7 | @@ -100,14 +105,15 @@ F522.py:10:1: F522 [*] `.format` call has unused named argument(s): greeting 12 12 | # The fix here is safe because the unused argument has no side effect, 13 13 | # even though the used argument has a side effect -F522.py:14:1: F522 [*] `.format` call has unused named argument(s): greeting +F522 [*] `.format` call has unused named argument(s): greeting + --> F522.py:14:1 | 12 | # The fix here is safe because the unused argument has no side effect, 13 | # even though the used argument has a side effect 14 | "Hello, {name}".format(greeting="Pikachu", name=print(1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F522 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove extra named arguments: greeting +help: Remove extra named arguments: greeting ℹ Safe fix 11 11 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap index 373bf431e6..73bff9f750 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F523.py:2:1: F523 [*] `.format` call has unused arguments at position(s): 1 +F523 [*] `.format` call has unused arguments at position(s): 1 + --> F523.py:2:1 | 1 | # With indexes 2 | "{0}".format(1, 2) # F523 - | ^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^ 3 | "{1}".format(1, 2, 3) # F523 4 | "{1:{0}}".format(1, 2) # No issues | - = help: Remove extra positional arguments at position(s): 1 +help: Remove extra positional arguments at position(s): 1 ℹ Safe fix 1 1 | # With indexes @@ -19,27 +20,29 @@ F523.py:2:1: F523 [*] `.format` call has unused arguments at position(s): 1 4 4 | "{1:{0}}".format(1, 2) # No issues 5 5 | "{1:{0}}".format(1, 2, 3) # F523 -F523.py:3:1: F523 `.format` call has unused arguments at position(s): 0, 2 +F523 `.format` call has unused arguments at position(s): 0, 2 + --> F523.py:3:1 | 1 | # With indexes 2 | "{0}".format(1, 2) # F523 3 | "{1}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^ 4 | "{1:{0}}".format(1, 2) # No issues 5 | "{1:{0}}".format(1, 2, 3) # F523 | - = help: Remove extra positional arguments at position(s): 0, 2 +help: Remove extra positional arguments at position(s): 0, 2 -F523.py:5:1: F523 [*] `.format` call has unused arguments at position(s): 2 +F523 [*] `.format` call has unused arguments at position(s): 2 + --> F523.py:5:1 | 3 | "{1}".format(1, 2, 3) # F523 4 | "{1:{0}}".format(1, 2) # No issues 5 | "{1:{0}}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | "{0}{2}".format(1, 2) # F523, # F524 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 | - = help: Remove extra positional arguments at position(s): 2 +help: Remove extra positional arguments at position(s): 2 ℹ Safe fix 2 2 | "{0}".format(1, 2) # F523 @@ -51,15 +54,16 @@ F523.py:5:1: F523 [*] `.format` call has unused arguments at position(s): 2 7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 8 8 | -F523.py:6:1: F523 [*] `.format` call has unused arguments at position(s): 1 +F523 [*] `.format` call has unused arguments at position(s): 1 + --> F523.py:6:1 | 4 | "{1:{0}}".format(1, 2) # No issues 5 | "{1:{0}}".format(1, 2, 3) # F523 6 | "{0}{2}".format(1, 2) # F523, # F524 - | ^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^ 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 | - = help: Remove extra positional arguments at position(s): 1 +help: Remove extra positional arguments at position(s): 1 ℹ Safe fix 3 3 | "{1}".format(1, 2, 3) # F523 @@ -71,26 +75,28 @@ F523.py:6:1: F523 [*] `.format` call has unused arguments at position(s): 1 8 8 | 9 9 | # With no indexes -F523.py:7:1: F523 `.format` call has unused arguments at position(s): 0, 3 +F523 `.format` call has unused arguments at position(s): 0, 3 + --> F523.py:7:1 | 5 | "{1:{0}}".format(1, 2, 3) # F523 6 | "{0}{2}".format(1, 2) # F523, # F524 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # With no indexes | - = help: Remove extra positional arguments at position(s): 0, 3 +help: Remove extra positional arguments at position(s): 0, 3 -F523.py:10:1: F523 [*] `.format` call has unused arguments at position(s): 1 +F523 [*] `.format` call has unused arguments at position(s): 1 + --> F523.py:10:1 | 9 | # With no indexes 10 | "{}".format(1, 2) # F523 - | ^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^ 11 | "{}".format(1, 2, 3) # F523 12 | "{:{}}".format(1, 2) # No issues | - = help: Remove extra positional arguments at position(s): 1 +help: Remove extra positional arguments at position(s): 1 ℹ Safe fix 7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 @@ -102,16 +108,17 @@ F523.py:10:1: F523 [*] `.format` call has unused arguments at position(s): 1 12 12 | "{:{}}".format(1, 2) # No issues 13 13 | "{:{}}".format(1, 2, 3) # F523 -F523.py:11:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 +F523 [*] `.format` call has unused arguments at position(s): 1, 2 + --> F523.py:11:1 | 9 | # With no indexes 10 | "{}".format(1, 2) # F523 11 | "{}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^ 12 | "{:{}}".format(1, 2) # No issues 13 | "{:{}}".format(1, 2, 3) # F523 | - = help: Remove extra positional arguments at position(s): 1, 2 +help: Remove extra positional arguments at position(s): 1, 2 ℹ Safe fix 8 8 | @@ -123,16 +130,17 @@ F523.py:11:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 13 13 | "{:{}}".format(1, 2, 3) # F523 14 14 | -F523.py:13:1: F523 [*] `.format` call has unused arguments at position(s): 2 +F523 [*] `.format` call has unused arguments at position(s): 2 + --> F523.py:13:1 | 11 | "{}".format(1, 2, 3) # F523 12 | "{:{}}".format(1, 2) # No issues 13 | "{:{}}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # With *args | - = help: Remove extra positional arguments at position(s): 2 +help: Remove extra positional arguments at position(s): 2 ℹ Safe fix 10 10 | "{}".format(1, 2) # F523 @@ -144,26 +152,28 @@ F523.py:13:1: F523 [*] `.format` call has unused arguments at position(s): 2 15 15 | # With *args 16 16 | "{0}{1}".format(*args) # No issues -F523.py:19:1: F523 `.format` call has unused arguments at position(s): 2 +F523 `.format` call has unused arguments at position(s): 2 + --> F523.py:19:1 | 17 | "{0}{1}".format(1, *args) # No issues 18 | "{0}{1}".format(1, 2, *args) # No issues 19 | "{0}{1}".format(1, 2, 3, *args) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | # With nested quotes | - = help: Remove extra positional arguments at position(s): 2 +help: Remove extra positional arguments at position(s): 2 -F523.py:22:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 +F523 [*] `.format` call has unused arguments at position(s): 1, 2 + --> F523.py:22:1 | 21 | # With nested quotes 22 | "''1{0}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 24 | '""{1}{0}'.format(1, 2, 3) # F523 | - = help: Remove extra positional arguments at position(s): 1, 2 +help: Remove extra positional arguments at position(s): 1, 2 ℹ Safe fix 19 19 | "{0}{1}".format(1, 2, 3, *args) # F523 @@ -175,15 +185,16 @@ F523.py:22:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 24 24 | '""{1}{0}'.format(1, 2, 3) # F523 25 25 | -F523.py:23:1: F523 [*] `.format` call has unused arguments at position(s): 2 +F523 [*] `.format` call has unused arguments at position(s): 2 + --> F523.py:23:1 | 21 | # With nested quotes 22 | "''1{0}".format(1, 2, 3) # F523 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | '""{1}{0}'.format(1, 2, 3) # F523 | - = help: Remove extra positional arguments at position(s): 2 +help: Remove extra positional arguments at position(s): 2 ℹ Safe fix 20 20 | @@ -195,16 +206,17 @@ F523.py:23:1: F523 [*] `.format` call has unused arguments at position(s): 2 25 25 | 26 26 | # With modified indexes -F523.py:24:1: F523 [*] `.format` call has unused arguments at position(s): 2 +F523 [*] `.format` call has unused arguments at position(s): 2 + --> F523.py:24:1 | 22 | "''1{0}".format(1, 2, 3) # F523 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 24 | '""{1}{0}'.format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | # With modified indexes | - = help: Remove extra positional arguments at position(s): 2 +help: Remove extra positional arguments at position(s): 2 ℹ Safe fix 21 21 | # With nested quotes @@ -216,48 +228,52 @@ F523.py:24:1: F523 [*] `.format` call has unused arguments at position(s): 2 26 26 | # With modified indexes 27 27 | "{1}{2}".format(1, 2, 3) # F523, # F524 -F523.py:27:1: F523 `.format` call has unused arguments at position(s): 0 +F523 `.format` call has unused arguments at position(s): 0 + --> F523.py:27:1 | 26 | # With modified indexes 27 | "{1}{2}".format(1, 2, 3) # F523, # F524 - | ^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 29 | "{1} {8}".format(0, 1) # F523, # F524 | - = help: Remove extra positional arguments at position(s): 0 +help: Remove extra positional arguments at position(s): 0 -F523.py:28:1: F523 `.format` call has unused arguments at position(s): 0, 2 +F523 `.format` call has unused arguments at position(s): 0, 2 + --> F523.py:28:1 | 26 | # With modified indexes 27 | "{1}{2}".format(1, 2, 3) # F523, # F524 28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | "{1} {8}".format(0, 1) # F523, # F524 | - = help: Remove extra positional arguments at position(s): 0, 2 +help: Remove extra positional arguments at position(s): 0, 2 -F523.py:29:1: F523 `.format` call has unused arguments at position(s): 0 +F523 `.format` call has unused arguments at position(s): 0 + --> F523.py:29:1 | 27 | "{1}{2}".format(1, 2, 3) # F523, # F524 28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 29 | "{1} {8}".format(0, 1) # F523, # F524 - | ^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | # Multiline | - = help: Remove extra positional arguments at position(s): 0 +help: Remove extra positional arguments at position(s): 0 -F523.py:32:2: F523 [*] `.format` call has unused arguments at position(s): 0 +F523 [*] `.format` call has unused arguments at position(s): 0 + --> F523.py:32:2 | 31 | # Multiline 32 | ('' | __^ 33 | | .format(2)) - | |__________^ F523 + | |__________^ 34 | 35 | # Removing the final argument. | - = help: Remove extra positional arguments at position(s): 0 +help: Remove extra positional arguments at position(s): 0 ℹ Safe fix 29 29 | "{1} {8}".format(0, 1) # F523, # F524 @@ -270,14 +286,15 @@ F523.py:32:2: F523 [*] `.format` call has unused arguments at position(s): 0 35 34 | # Removing the final argument. 36 35 | "Hello".format("world") -F523.py:36:1: F523 [*] `.format` call has unused arguments at position(s): 0 +F523 [*] `.format` call has unused arguments at position(s): 0 + --> F523.py:36:1 | 35 | # Removing the final argument. 36 | "Hello".format("world") - | ^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^ 37 | "Hello".format("world", key="value") | - = help: Remove extra positional arguments at position(s): 0 +help: Remove extra positional arguments at position(s): 0 ℹ Safe fix 33 33 | .format(2)) @@ -289,16 +306,17 @@ F523.py:36:1: F523 [*] `.format` call has unused arguments at position(s): 0 38 38 | 39 39 | # https://github.com/astral-sh/ruff/issues/18806 -F523.py:37:1: F523 [*] `.format` call has unused arguments at position(s): 0 +F523 [*] `.format` call has unused arguments at position(s): 0 + --> F523.py:37:1 | 35 | # Removing the final argument. 36 | "Hello".format("world") 37 | "Hello".format("world", key="value") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | 39 | # https://github.com/astral-sh/ruff/issues/18806 | - = help: Remove extra positional arguments at position(s): 0 +help: Remove extra positional arguments at position(s): 0 ℹ Safe fix 34 34 | @@ -310,16 +328,17 @@ F523.py:37:1: F523 [*] `.format` call has unused arguments at position(s): 0 39 39 | # https://github.com/astral-sh/ruff/issues/18806 40 40 | # The fix here is unsafe because the unused argument has side effect -F523.py:41:1: F523 [*] `.format` call has unused arguments at position(s): 1 +F523 [*] `.format` call has unused arguments at position(s): 1 + --> F523.py:41:1 | 39 | # https://github.com/astral-sh/ruff/issues/18806 40 | # The fix here is unsafe because the unused argument has side effect 41 | "Hello, {0}".format("world", print(1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | 43 | # The fix here is safe because the unused argument has no side effect, | - = help: Remove extra positional arguments at position(s): 1 +help: Remove extra positional arguments at position(s): 1 ℹ Unsafe fix 38 38 | @@ -331,14 +350,15 @@ F523.py:41:1: F523 [*] `.format` call has unused arguments at position(s): 1 43 43 | # The fix here is safe because the unused argument has no side effect, 44 44 | # even though the used argument has a side effect -F523.py:45:1: F523 [*] `.format` call has unused arguments at position(s): 1 +F523 [*] `.format` call has unused arguments at position(s): 1 + --> F523.py:45:1 | 43 | # The fix here is safe because the unused argument has no side effect, 44 | # even though the used argument has a side effect 45 | "Hello, {0}".format(print(1), "Pikachu") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove extra positional arguments at position(s): 1 +help: Remove extra positional arguments at position(s): 1 ℹ Safe fix 42 42 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F524_F524.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F524_F524.py.snap index c7b28c0dfa..fa097d75ff 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F524_F524.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F524_F524.py.snap @@ -1,67 +1,73 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F524.py:1:1: F524 `.format` call is missing argument(s) for placeholder(s): 1 +F524 `.format` call is missing argument(s) for placeholder(s): 1 + --> F524.py:1:1 | 1 | "{} {}".format(1) # F524 - | ^^^^^^^^^^^^^^^^^ F524 + | ^^^^^^^^^^^^^^^^^ 2 | "{2}".format() # F524 3 | "{bar}".format() # F524 | -F524.py:2:1: F524 `.format` call is missing argument(s) for placeholder(s): 2 +F524 `.format` call is missing argument(s) for placeholder(s): 2 + --> F524.py:2:1 | 1 | "{} {}".format(1) # F524 2 | "{2}".format() # F524 - | ^^^^^^^^^^^^^^ F524 + | ^^^^^^^^^^^^^^ 3 | "{bar}".format() # F524 4 | "{0} {bar}".format(1) # F524 | -F524.py:3:1: F524 `.format` call is missing argument(s) for placeholder(s): bar +F524 `.format` call is missing argument(s) for placeholder(s): bar + --> F524.py:3:1 | 1 | "{} {}".format(1) # F524 2 | "{2}".format() # F524 3 | "{bar}".format() # F524 - | ^^^^^^^^^^^^^^^^ F524 + | ^^^^^^^^^^^^^^^^ 4 | "{0} {bar}".format(1) # F524 5 | "{0} {bar}".format() # F524 | -F524.py:4:1: F524 `.format` call is missing argument(s) for placeholder(s): bar +F524 `.format` call is missing argument(s) for placeholder(s): bar + --> F524.py:4:1 | 2 | "{2}".format() # F524 3 | "{bar}".format() # F524 4 | "{0} {bar}".format(1) # F524 - | ^^^^^^^^^^^^^^^^^^^^^ F524 + | ^^^^^^^^^^^^^^^^^^^^^ 5 | "{0} {bar}".format() # F524 6 | "{bar} {0}".format() # F524 | -F524.py:5:1: F524 `.format` call is missing argument(s) for placeholder(s): 0, bar +F524 `.format` call is missing argument(s) for placeholder(s): 0, bar + --> F524.py:5:1 | 3 | "{bar}".format() # F524 4 | "{0} {bar}".format(1) # F524 5 | "{0} {bar}".format() # F524 - | ^^^^^^^^^^^^^^^^^^^^ F524 + | ^^^^^^^^^^^^^^^^^^^^ 6 | "{bar} {0}".format() # F524 7 | "{1} {8}".format(0, 1) | -F524.py:6:1: F524 `.format` call is missing argument(s) for placeholder(s): 0, bar +F524 `.format` call is missing argument(s) for placeholder(s): 0, bar + --> F524.py:6:1 | 4 | "{0} {bar}".format(1) # F524 5 | "{0} {bar}".format() # F524 6 | "{bar} {0}".format() # F524 - | ^^^^^^^^^^^^^^^^^^^^ F524 + | ^^^^^^^^^^^^^^^^^^^^ 7 | "{1} {8}".format(0, 1) | -F524.py:7:1: F524 `.format` call is missing argument(s) for placeholder(s): 8 +F524 `.format` call is missing argument(s) for placeholder(s): 8 + --> F524.py:7:1 | 5 | "{0} {bar}".format() # F524 6 | "{bar} {0}".format() # F524 7 | "{1} {8}".format(0, 1) - | ^^^^^^^^^^^^^^^^^^^^^^ F524 + | ^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F525_F525.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F525_F525.py.snap index c4d45bde61..c6a8823ae1 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F525_F525.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F525_F525.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F525.py:1:1: F525 `.format` string mixes automatic and manual numbering +F525 `.format` string mixes automatic and manual numbering + --> F525.py:1:1 | 1 | "{} {1}".format(1, 2) # F525 - | ^^^^^^^^^^^^^^^^^^^^^ F525 + | ^^^^^^^^^^^^^^^^^^^^^ 2 | "{0} {}".format(1, 2) # F523, F525 | -F525.py:2:1: F525 `.format` string mixes automatic and manual numbering +F525 `.format` string mixes automatic and manual numbering + --> F525.py:2:1 | 1 | "{} {1}".format(1, 2) # F525 2 | "{0} {}".format(1, 2) # F523, F525 - | ^^^^^^^^^^^^^^^^^^^^^ F525 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap index a7938d42ab..a479bd02cb 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F541.py:6:5: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:6:5 | 5 | # Errors 6 | c = f"def" - | ^^^^^^ F541 + | ^^^^^^ 7 | d = f"def" + "ghi" 8 | e = ( | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 3 3 | b = f"ghi{'jkl'}" @@ -21,16 +22,17 @@ F541.py:6:5: F541 [*] f-string without any placeholders 8 8 | e = ( 9 9 | f"def" + -F541.py:7:5: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:7:5 | 5 | # Errors 6 | c = f"def" 7 | d = f"def" + "ghi" - | ^^^^^^ F541 + | ^^^^^^ 8 | e = ( 9 | f"def" + | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 4 4 | @@ -42,16 +44,17 @@ F541.py:7:5: F541 [*] f-string without any placeholders 9 9 | f"def" + 10 10 | "ghi" -F541.py:9:5: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:9:5 | 7 | d = f"def" + "ghi" 8 | e = ( 9 | f"def" + - | ^^^^^^ F541 + | ^^^^^^ 10 | "ghi" 11 | ) | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 6 6 | c = f"def" @@ -63,16 +66,17 @@ F541.py:9:5: F541 [*] f-string without any placeholders 11 11 | ) 12 12 | f = ( -F541.py:13:5: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:13:5 | 11 | ) 12 | f = ( 13 | f"a" - | ^^^^ F541 + | ^^^^ 14 | F"b" 15 | "c" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 10 10 | "ghi" @@ -84,16 +88,17 @@ F541.py:13:5: F541 [*] f-string without any placeholders 15 15 | "c" 16 16 | rf"d" -F541.py:14:5: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:14:5 | 12 | f = ( 13 | f"a" 14 | F"b" - | ^^^^ F541 + | ^^^^ 15 | "c" 16 | rf"d" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 11 11 | ) @@ -105,16 +110,17 @@ F541.py:14:5: F541 [*] f-string without any placeholders 16 16 | rf"d" 17 17 | fr"e" -F541.py:16:5: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:16:5 | 14 | F"b" 15 | "c" 16 | rf"d" - | ^^^^^ F541 + | ^^^^^ 17 | fr"e" 18 | ) | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 13 13 | f"a" @@ -126,16 +132,17 @@ F541.py:16:5: F541 [*] f-string without any placeholders 18 18 | ) 19 19 | g = f"" -F541.py:17:5: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:17:5 | 15 | "c" 16 | rf"d" 17 | fr"e" - | ^^^^^ F541 + | ^^^^^ 18 | ) 19 | g = f"" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 14 14 | F"b" @@ -147,16 +154,17 @@ F541.py:17:5: F541 [*] f-string without any placeholders 19 19 | g = f"" 20 20 | -F541.py:19:5: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:19:5 | 17 | fr"e" 18 | ) 19 | g = f"" - | ^^^ F541 + | ^^^ 20 | 21 | # OK | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 16 16 | rf"d" @@ -168,15 +176,16 @@ F541.py:19:5: F541 [*] f-string without any placeholders 21 21 | # OK 22 22 | g = f"ghi{123:{45}}" -F541.py:25:13: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:25:13 | 24 | # Error 25 | h = "x" "y" f"z" - | ^^^^ F541 + | ^^^^ 26 | 27 | v = 23.234234 | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 22 22 | g = f"ghi{123:{45}}" @@ -188,15 +197,16 @@ F541.py:25:13: F541 [*] f-string without any placeholders 27 27 | v = 23.234234 28 28 | -F541.py:34:7: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:34:7 | 33 | # Errors 34 | f"{v:{f'0.2f'}}" - | ^^^^^^^ F541 + | ^^^^^^^ 35 | f"{f''}" 36 | f"{{test}}" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 31 31 | f"{f'{v:0.2f}'}" @@ -208,16 +218,17 @@ F541.py:34:7: F541 [*] f-string without any placeholders 36 36 | f"{{test}}" 37 37 | f'{{ 40 }}' -F541.py:35:4: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:35:4 | 33 | # Errors 34 | f"{v:{f'0.2f'}}" 35 | f"{f''}" - | ^^^ F541 + | ^^^ 36 | f"{{test}}" 37 | f'{{ 40 }}' | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 32 32 | @@ -229,16 +240,17 @@ F541.py:35:4: F541 [*] f-string without any placeholders 37 37 | f'{{ 40 }}' 38 38 | f"{{a {{x}}" -F541.py:36:1: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:36:1 | 34 | f"{v:{f'0.2f'}}" 35 | f"{f''}" 36 | f"{{test}}" - | ^^^^^^^^^^^ F541 + | ^^^^^^^^^^^ 37 | f'{{ 40 }}' 38 | f"{{a {{x}}" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 33 33 | # Errors @@ -250,16 +262,17 @@ F541.py:36:1: F541 [*] f-string without any placeholders 38 38 | f"{{a {{x}}" 39 39 | f"{{{{x}}}}" -F541.py:37:1: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:37:1 | 35 | f"{f''}" 36 | f"{{test}}" 37 | f'{{ 40 }}' - | ^^^^^^^^^^^ F541 + | ^^^^^^^^^^^ 38 | f"{{a {{x}}" 39 | f"{{{{x}}}}" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 34 34 | f"{v:{f'0.2f'}}" @@ -271,16 +284,17 @@ F541.py:37:1: F541 [*] f-string without any placeholders 39 39 | f"{{{{x}}}}" 40 40 | ""f"" -F541.py:38:1: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:38:1 | 36 | f"{{test}}" 37 | f'{{ 40 }}' 38 | f"{{a {{x}}" - | ^^^^^^^^^^^^ F541 + | ^^^^^^^^^^^^ 39 | f"{{{{x}}}}" 40 | ""f"" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 35 35 | f"{f''}" @@ -292,16 +306,17 @@ F541.py:38:1: F541 [*] f-string without any placeholders 40 40 | ""f"" 41 41 | ''f"" -F541.py:39:1: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:39:1 | 37 | f'{{ 40 }}' 38 | f"{{a {{x}}" 39 | f"{{{{x}}}}" - | ^^^^^^^^^^^^ F541 + | ^^^^^^^^^^^^ 40 | ""f"" 41 | ''f"" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 36 36 | f"{{test}}" @@ -313,16 +328,17 @@ F541.py:39:1: F541 [*] f-string without any placeholders 41 41 | ''f"" 42 42 | (""f""r"") -F541.py:40:3: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:40:3 | 38 | f"{{a {{x}}" 39 | f"{{{{x}}}}" 40 | ""f"" - | ^^^ F541 + | ^^^ 41 | ''f"" 42 | (""f""r"") | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 37 37 | f'{{ 40 }}' @@ -334,16 +350,17 @@ F541.py:40:3: F541 [*] f-string without any placeholders 42 42 | (""f""r"") 43 43 | f"{v:{f"0.2f"}}" -F541.py:41:3: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:41:3 | 39 | f"{{{{x}}}}" 40 | ""f"" 41 | ''f"" - | ^^^ F541 + | ^^^ 42 | (""f""r"") 43 | f"{v:{f"0.2f"}}" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 38 38 | f"{{a {{x}}" @@ -355,16 +372,17 @@ F541.py:41:3: F541 [*] f-string without any placeholders 43 43 | f"{v:{f"0.2f"}}" 44 44 | f"\{{x}}" -F541.py:42:4: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:42:4 | 40 | ""f"" 41 | ''f"" 42 | (""f""r"") - | ^^^ F541 + | ^^^ 43 | f"{v:{f"0.2f"}}" 44 | f"\{{x}}" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 39 39 | f"{{{{x}}}}" @@ -375,15 +393,16 @@ F541.py:42:4: F541 [*] f-string without any placeholders 43 43 | f"{v:{f"0.2f"}}" 44 44 | f"\{{x}}" -F541.py:43:7: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:43:7 | 41 | ''f"" 42 | (""f""r"") 43 | f"{v:{f"0.2f"}}" - | ^^^^^^^ F541 + | ^^^^^^^ 44 | f"\{{x}}" | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 40 40 | ""f"" @@ -393,14 +412,15 @@ F541.py:43:7: F541 [*] f-string without any placeholders 43 |+f"{v:{"0.2f"}}" 44 44 | f"\{{x}}" -F541.py:44:1: F541 [*] f-string without any placeholders +F541 [*] f-string without any placeholders + --> F541.py:44:1 | 42 | (""f""r"") 43 | f"{v:{f"0.2f"}}" 44 | f"\{{x}}" - | ^^^^^^^^^ F541 + | ^^^^^^^^^ | - = help: Remove extraneous `f` prefix +help: Remove extraneous `f` prefix ℹ Safe fix 41 41 | ''f"" diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap index b16b7bea64..adf7c6cfb2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap @@ -1,91 +1,99 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F601.py:3:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:3:5 | 1 | x = { 2 | "a": 1, 3 | "a": 2, - | ^^^ F601 + | ^^^ 4 | "b": 3, 5 | ("a", "b"): 3, | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:6:5: F601 Dictionary key literal `("a", "b")` repeated +F601 Dictionary key literal `("a", "b")` repeated + --> F601.py:6:5 | 4 | "b": 3, 5 | ("a", "b"): 3, 6 | ("a", "b"): 4, - | ^^^^^^^^^^ F601 + | ^^^^^^^^^^ 7 | 1.0: 2, 8 | 1: 0, | - = help: Remove repeated key literal `("a", "b")` +help: Remove repeated key literal `("a", "b")` -F601.py:8:5: F601 Dictionary key literal `1` repeated (`1` hashes to the same value as `1.0`) +F601 Dictionary key literal `1` repeated (`1` hashes to the same value as `1.0`) + --> F601.py:8:5 | 6 | ("a", "b"): 4, 7 | 1.0: 2, 8 | 1: 0, - | ^ F601 + | ^ 9 | 1: 3, 10 | b"123": 1, | - = help: Remove repeated key literal `1` +help: Remove repeated key literal `1` -F601.py:9:5: F601 Dictionary key literal `1` repeated (`1` hashes to the same value as `1.0`) +F601 Dictionary key literal `1` repeated (`1` hashes to the same value as `1.0`) + --> F601.py:9:5 | 7 | 1.0: 2, 8 | 1: 0, 9 | 1: 3, - | ^ F601 + | ^ 10 | b"123": 1, 11 | b"123": 4, | - = help: Remove repeated key literal `1` +help: Remove repeated key literal `1` -F601.py:11:5: F601 Dictionary key literal `b"123"` repeated +F601 Dictionary key literal `b"123"` repeated + --> F601.py:11:5 | 9 | 1: 3, 10 | b"123": 1, 11 | b"123": 4, - | ^^^^^^ F601 + | ^^^^^^ 12 | } | - = help: Remove repeated key literal `b"123"` +help: Remove repeated key literal `b"123"` -F601.py:16:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:16:5 | 14 | x = { 15 | "a": 1, 16 | "a": 2, - | ^^^ F601 + | ^^^ 17 | "a": 3, 18 | "a": 3, | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:17:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:17:5 | 15 | "a": 1, 16 | "a": 2, 17 | "a": 3, - | ^^^ F601 + | ^^^ 18 | "a": 3, 19 | } | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:18:5: F601 [*] Dictionary key literal `"a"` repeated +F601 [*] Dictionary key literal `"a"` repeated + --> F601.py:18:5 | 16 | "a": 2, 17 | "a": 3, 18 | "a": 3, - | ^^^ F601 + | ^^^ 19 | } | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` ℹ Unsafe fix 15 15 | "a": 1, @@ -96,38 +104,41 @@ F601.py:18:5: F601 [*] Dictionary key literal `"a"` repeated 20 19 | 21 20 | x = { -F601.py:23:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:23:5 | 21 | x = { 22 | "a": 1, 23 | "a": 2, - | ^^^ F601 + | ^^^ 24 | "a": 3, 25 | "a": 3, | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:24:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:24:5 | 22 | "a": 1, 23 | "a": 2, 24 | "a": 3, - | ^^^ F601 + | ^^^ 25 | "a": 3, 26 | "a": 4, | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:25:5: F601 [*] Dictionary key literal `"a"` repeated +F601 [*] Dictionary key literal `"a"` repeated + --> F601.py:25:5 | 23 | "a": 2, 24 | "a": 3, 25 | "a": 3, - | ^^^ F601 + | ^^^ 26 | "a": 4, 27 | } | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` ℹ Unsafe fix 22 22 | "a": 1, @@ -138,26 +149,28 @@ F601.py:25:5: F601 [*] Dictionary key literal `"a"` repeated 27 26 | } 28 27 | -F601.py:26:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:26:5 | 24 | "a": 3, 25 | "a": 3, 26 | "a": 4, - | ^^^ F601 + | ^^^ 27 | } | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:31:5: F601 [*] Dictionary key literal `"a"` repeated +F601 [*] Dictionary key literal `"a"` repeated + --> F601.py:31:5 | 29 | x = { 30 | "a": 1, 31 | "a": 1, - | ^^^ F601 + | ^^^ 32 | "a": 2, 33 | "a": 3, | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` ℹ Unsafe fix 28 28 | @@ -168,70 +181,76 @@ F601.py:31:5: F601 [*] Dictionary key literal `"a"` repeated 33 32 | "a": 3, 34 33 | "a": 4, -F601.py:32:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:32:5 | 30 | "a": 1, 31 | "a": 1, 32 | "a": 2, - | ^^^ F601 + | ^^^ 33 | "a": 3, 34 | "a": 4, | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:33:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:33:5 | 31 | "a": 1, 32 | "a": 2, 33 | "a": 3, - | ^^^ F601 + | ^^^ 34 | "a": 4, 35 | } | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:34:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:34:5 | 32 | "a": 2, 33 | "a": 3, 34 | "a": 4, - | ^^^ F601 + | ^^^ 35 | } | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:41:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:41:5 | 39 | "a": 1, 40 | a: 1, 41 | "a": 2, - | ^^^ F601 + | ^^^ 42 | a: 2, 43 | "a": 3, | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:43:5: F601 Dictionary key literal `"a"` repeated +F601 Dictionary key literal `"a"` repeated + --> F601.py:43:5 | 41 | "a": 2, 42 | a: 2, 43 | "a": 3, - | ^^^ F601 + | ^^^ 44 | a: 3, 45 | "a": 3, | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` -F601.py:45:5: F601 [*] Dictionary key literal `"a"` repeated +F601 [*] Dictionary key literal `"a"` repeated + --> F601.py:45:5 | 43 | "a": 3, 44 | a: 3, 45 | "a": 3, - | ^^^ F601 + | ^^^ 46 | a: 4, 47 | } | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` ℹ Unsafe fix 42 42 | a: 2, @@ -242,15 +261,16 @@ F601.py:45:5: F601 [*] Dictionary key literal `"a"` repeated 47 46 | } 48 47 | -F601.py:49:14: F601 [*] Dictionary key literal `"a"` repeated +F601 [*] Dictionary key literal `"a"` repeated + --> F601.py:49:14 | 47 | } 48 | 49 | x = {"a": 1, "a": 1} - | ^^^ F601 + | ^^^ 50 | x = {"a": 1, "b": 2, "a": 1} | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` ℹ Unsafe fix 46 46 | a: 4, @@ -262,15 +282,16 @@ F601.py:49:14: F601 [*] Dictionary key literal `"a"` repeated 51 51 | 52 52 | x = { -F601.py:50:22: F601 [*] Dictionary key literal `"a"` repeated +F601 [*] Dictionary key literal `"a"` repeated + --> F601.py:50:22 | 49 | x = {"a": 1, "a": 1} 50 | x = {"a": 1, "b": 2, "a": 1} - | ^^^ F601 + | ^^^ 51 | 52 | x = { | - = help: Remove repeated key literal `"a"` +help: Remove repeated key literal `"a"` ℹ Unsafe fix 47 47 | } @@ -282,25 +303,27 @@ F601.py:50:22: F601 [*] Dictionary key literal `"a"` repeated 52 52 | x = { 53 53 | ('a', 'b'): 'asdf', -F601.py:54:5: F601 Dictionary key literal `('a', 'b')` repeated +F601 Dictionary key literal `('a', 'b')` repeated + --> F601.py:54:5 | 52 | x = { 53 | ('a', 'b'): 'asdf', 54 | ('a', 'b'): 'qwer', - | ^^^^^^^^^^ F601 + | ^^^^^^^^^^ 55 | } | - = help: Remove repeated key literal `('a', 'b')` +help: Remove repeated key literal `('a', 'b')` -F601.py:58:19: F601 [*] Dictionary key literal `"x"` repeated +F601 [*] Dictionary key literal `"x"` repeated + --> F601.py:58:19 | 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/4897 58 | t={"x":"test123", "x":("test123")} - | ^^^ F601 + | ^^^ 59 | 60 | t={"x":("test123"), "x":"test123"} | - = help: Remove repeated key literal `"x"` +help: Remove repeated key literal `"x"` ℹ Unsafe fix 55 55 | } @@ -312,16 +335,17 @@ F601.py:58:19: F601 [*] Dictionary key literal `"x"` repeated 60 60 | t={"x":("test123"), "x":"test123"} 61 61 | -F601.py:60:21: F601 [*] Dictionary key literal `"x"` repeated +F601 [*] Dictionary key literal `"x"` repeated + --> F601.py:60:21 | 58 | t={"x":"test123", "x":("test123")} 59 | 60 | t={"x":("test123"), "x":"test123"} - | ^^^ F601 + | ^^^ 61 | 62 | # Regression test for: https://github.com/astral-sh/ruff/issues/12772 | - = help: Remove repeated key literal `"x"` +help: Remove repeated key literal `"x"` ℹ Unsafe fix 57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/4897 @@ -333,45 +357,49 @@ F601.py:60:21: F601 [*] Dictionary key literal `"x"` repeated 62 62 | # Regression test for: https://github.com/astral-sh/ruff/issues/12772 63 63 | x = { -F601.py:65:5: F601 Dictionary key literal `1` repeated +F601 Dictionary key literal `1` repeated + --> F601.py:65:5 | 63 | x = { 64 | 1: "abc", 65 | 1: "def", - | ^ F601 + | ^ 66 | True: "ghi", 67 | 0: "foo", | - = help: Remove repeated key literal `1` +help: Remove repeated key literal `1` -F601.py:66:5: F601 Dictionary key literal `True` repeated (`True` hashes to the same value as `1`) +F601 Dictionary key literal `True` repeated (`True` hashes to the same value as `1`) + --> F601.py:66:5 | 64 | 1: "abc", 65 | 1: "def", 66 | True: "ghi", - | ^^^^ F601 + | ^^^^ 67 | 0: "foo", 68 | 0: "bar", | - = help: Remove repeated key literal `True` +help: Remove repeated key literal `True` -F601.py:68:5: F601 Dictionary key literal `0` repeated +F601 Dictionary key literal `0` repeated + --> F601.py:68:5 | 66 | True: "ghi", 67 | 0: "foo", 68 | 0: "bar", - | ^ F601 + | ^ 69 | False: "baz", 70 | } | - = help: Remove repeated key literal `0` +help: Remove repeated key literal `0` -F601.py:69:5: F601 Dictionary key literal `False` repeated (`False` hashes to the same value as `0`) +F601 Dictionary key literal `False` repeated (`False` hashes to the same value as `0`) + --> F601.py:69:5 | 67 | 0: "foo", 68 | 0: "bar", 69 | False: "baz", - | ^^^^^ F601 + | ^^^^^ 70 | } | - = help: Remove repeated key literal `False` +help: Remove repeated key literal `False` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap index 6fe76f9fd0..f49f8ea2ec 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap @@ -1,48 +1,52 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F602.py:5:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:5:5 | 3 | x = { 4 | a: 1, 5 | a: 2, - | ^ F602 + | ^ 6 | b: 3, 7 | } | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:11:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:11:5 | 9 | x = { 10 | a: 1, 11 | a: 2, - | ^ F602 + | ^ 12 | a: 3, 13 | a: 3, | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:12:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:12:5 | 10 | a: 1, 11 | a: 2, 12 | a: 3, - | ^ F602 + | ^ 13 | a: 3, 14 | } | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:13:5: F602 [*] Dictionary key `a` repeated +F602 [*] Dictionary key `a` repeated + --> F602.py:13:5 | 11 | a: 2, 12 | a: 3, 13 | a: 3, - | ^ F602 + | ^ 14 | } | - = help: Remove repeated key `a` +help: Remove repeated key `a` ℹ Unsafe fix 10 10 | a: 1, @@ -53,38 +57,41 @@ F602.py:13:5: F602 [*] Dictionary key `a` repeated 15 14 | 16 15 | x = { -F602.py:18:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:18:5 | 16 | x = { 17 | a: 1, 18 | a: 2, - | ^ F602 + | ^ 19 | a: 3, 20 | a: 3, | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:19:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:19:5 | 17 | a: 1, 18 | a: 2, 19 | a: 3, - | ^ F602 + | ^ 20 | a: 3, 21 | a: 4, | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:20:5: F602 [*] Dictionary key `a` repeated +F602 [*] Dictionary key `a` repeated + --> F602.py:20:5 | 18 | a: 2, 19 | a: 3, 20 | a: 3, - | ^ F602 + | ^ 21 | a: 4, 22 | } | - = help: Remove repeated key `a` +help: Remove repeated key `a` ℹ Unsafe fix 17 17 | a: 1, @@ -95,26 +102,28 @@ F602.py:20:5: F602 [*] Dictionary key `a` repeated 22 21 | } 23 22 | -F602.py:21:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:21:5 | 19 | a: 3, 20 | a: 3, 21 | a: 4, - | ^ F602 + | ^ 22 | } | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:26:5: F602 [*] Dictionary key `a` repeated +F602 [*] Dictionary key `a` repeated + --> F602.py:26:5 | 24 | x = { 25 | a: 1, 26 | a: 1, - | ^ F602 + | ^ 27 | a: 2, 28 | a: 3, | - = help: Remove repeated key `a` +help: Remove repeated key `a` ℹ Unsafe fix 23 23 | @@ -125,48 +134,52 @@ F602.py:26:5: F602 [*] Dictionary key `a` repeated 28 27 | a: 3, 29 28 | a: 4, -F602.py:27:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:27:5 | 25 | a: 1, 26 | a: 1, 27 | a: 2, - | ^ F602 + | ^ 28 | a: 3, 29 | a: 4, | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:28:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:28:5 | 26 | a: 1, 27 | a: 2, 28 | a: 3, - | ^ F602 + | ^ 29 | a: 4, 30 | } | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:29:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:29:5 | 27 | a: 2, 28 | a: 3, 29 | a: 4, - | ^ F602 + | ^ 30 | } | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:35:5: F602 [*] Dictionary key `a` repeated +F602 [*] Dictionary key `a` repeated + --> F602.py:35:5 | 33 | a: 1, 34 | "a": 1, 35 | a: 1, - | ^ F602 + | ^ 36 | "a": 2, 37 | a: 2, | - = help: Remove repeated key `a` +help: Remove repeated key `a` ℹ Unsafe fix 32 32 | x = { @@ -177,47 +190,51 @@ F602.py:35:5: F602 [*] Dictionary key `a` repeated 37 36 | a: 2, 38 37 | "a": 3, -F602.py:37:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:37:5 | 35 | a: 1, 36 | "a": 2, 37 | a: 2, - | ^ F602 + | ^ 38 | "a": 3, 39 | a: 3, | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:39:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:39:5 | 37 | a: 2, 38 | "a": 3, 39 | a: 3, - | ^ F602 + | ^ 40 | "a": 3, 41 | a: 4, | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:41:5: F602 Dictionary key `a` repeated +F602 Dictionary key `a` repeated + --> F602.py:41:5 | 39 | a: 3, 40 | "a": 3, 41 | a: 4, - | ^ F602 + | ^ 42 | } | - = help: Remove repeated key `a` +help: Remove repeated key `a` -F602.py:44:12: F602 [*] Dictionary key `a` repeated +F602 [*] Dictionary key `a` repeated + --> F602.py:44:12 | 42 | } 43 | 44 | x = {a: 1, a: 1} - | ^ F602 + | ^ 45 | x = {a: 1, b: 2, a: 1} | - = help: Remove repeated key `a` +help: Remove repeated key `a` ℹ Unsafe fix 41 41 | a: 4, @@ -227,13 +244,14 @@ F602.py:44:12: F602 [*] Dictionary key `a` repeated 44 |+x = {a: 1} 45 45 | x = {a: 1, b: 2, a: 1} -F602.py:45:18: F602 [*] Dictionary key `a` repeated +F602 [*] Dictionary key `a` repeated + --> F602.py:45:18 | 44 | x = {a: 1, a: 1} 45 | x = {a: 1, b: 2, a: 1} - | ^ F602 + | ^ | - = help: Remove repeated key `a` +help: Remove repeated key `a` ℹ Unsafe fix 42 42 | } diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F622_F622.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F622_F622.py.snap index a99d31d8a4..9f4e6e9946 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F622_F622.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F622_F622.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F622.py:1:1: F622 Two starred expressions in assignment +F622 Two starred expressions in assignment + --> F622.py:1:1 | 1 | *a, *b, c = (1, 2, 3) - | ^^^^^^^^^ F622 + | ^^^^^^^^^ 2 | *a, b, c = (1, 2, 3) 3 | a, b, *c = (1, 2, 3) | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F631_F631.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F631_F631.py.snap index 1a7624182d..eb05b93694 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F631_F631.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F631_F631.py.snap @@ -1,20 +1,21 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F631.py:1:1: F631 Assert test is a non-empty tuple, which is always `True` +F631 Assert test is a non-empty tuple, which is always `True` + --> F631.py:1:1 | 1 | assert (False, "x") - | ^^^^^^^^^^^^^^^^^^^ F631 + | ^^^^^^^^^^^^^^^^^^^ 2 | assert (False,) 3 | assert () | -F631.py:2:1: F631 Assert test is a non-empty tuple, which is always `True` +F631 Assert test is a non-empty tuple, which is always `True` + --> F631.py:2:1 | 1 | assert (False, "x") 2 | assert (False,) - | ^^^^^^^^^^^^^^^ F631 + | ^^^^^^^^^^^^^^^ 3 | assert () 4 | assert True | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap index 0bf2cf432b..a0fc045e36 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F632.py:1:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> F632.py:1:4 | 1 | if x is "abc": - | ^^^^^^^^^^ F632 + | ^^^^^^^^^^ 2 | pass | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 1 |-if x is "abc": @@ -16,15 +17,16 @@ F632.py:1:4: F632 [*] Use `==` to compare constant literals 3 3 | 4 4 | if 123 is not y: -F632.py:4:4: F632 [*] Use `!=` to compare constant literals +F632 [*] Use `!=` to compare constant literals + --> F632.py:4:4 | 2 | pass 3 | 4 | if 123 is not y: - | ^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^ 5 | pass | - = help: Replace `is not` with `!=` +help: Replace `is not` with `!=` ℹ Safe fix 1 1 | if x is "abc": @@ -36,17 +38,18 @@ F632.py:4:4: F632 [*] Use `!=` to compare constant literals 6 6 | 7 7 | if 123 is \ -F632.py:7:4: F632 [*] Use `!=` to compare constant literals +F632 [*] Use `!=` to compare constant literals + --> F632.py:7:4 | 5 | pass 6 | 7 | if 123 is \ | ____^ 8 | | not y: - | |_____________^ F632 + | |_____________^ 9 | pass | - = help: Replace `is not` with `!=` +help: Replace `is not` with `!=` ℹ Safe fix 4 4 | if 123 is not y: @@ -59,15 +62,16 @@ F632.py:7:4: F632 [*] Use `!=` to compare constant literals 10 9 | 11 10 | if "123" is x < 3: -F632.py:11:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> F632.py:11:4 | 9 | pass 10 | 11 | if "123" is x < 3: - | ^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^ 12 | pass | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 8 8 | not y: @@ -79,15 +83,16 @@ F632.py:11:4: F632 [*] Use `==` to compare constant literals 13 13 | 14 14 | if "123" != x is 3: -F632.py:14:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> F632.py:14:4 | 12 | pass 13 | 14 | if "123" != x is 3: - | ^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^ 15 | pass | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 11 11 | if "123" is x < 3: @@ -99,15 +104,16 @@ F632.py:14:4: F632 [*] Use `==` to compare constant literals 16 16 | 17 17 | if ("123" != x) is 3: -F632.py:17:4: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> F632.py:17:4 | 15 | pass 16 | 17 | if ("123" != x) is 3: - | ^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^ 18 | pass | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 14 14 | if "123" != x is 3: @@ -119,15 +125,16 @@ F632.py:17:4: F632 [*] Use `==` to compare constant literals 19 19 | 20 20 | if "123" != (x is 3): -F632.py:20:14: F632 [*] Use `==` to compare constant literals +F632 [*] Use `==` to compare constant literals + --> F632.py:20:14 | 18 | pass 19 | 20 | if "123" != (x is 3): - | ^^^^^^ F632 + | ^^^^^^ 21 | pass | - = help: Replace `is` with `==` +help: Replace `is` with `==` ℹ Safe fix 17 17 | if ("123" != x) is 3: @@ -139,18 +146,19 @@ F632.py:20:14: F632 [*] Use `==` to compare constant literals 22 22 | 23 23 | {2 is -F632.py:23:2: F632 [*] Use `!=` to compare constant literals +F632 [*] Use `!=` to compare constant literals + --> F632.py:23:2 | 21 | pass 22 | 23 | {2 is | __^ 24 | | not ''} - | |______^ F632 + | |______^ 25 | 26 | {2 is | - = help: Replace `is not` with `!=` +help: Replace `is not` with `!=` ℹ Safe fix 20 20 | if "123" != (x is 3): @@ -163,18 +171,19 @@ F632.py:23:2: F632 [*] Use `!=` to compare constant literals 26 25 | {2 is 27 26 | not ''} -F632.py:26:2: F632 [*] Use `!=` to compare constant literals +F632 [*] Use `!=` to compare constant literals + --> F632.py:26:2 | 24 | not ''} 25 | 26 | {2 is | __^ 27 | | not ''} - | |_______^ F632 + | |_______^ 28 | 29 | # Regression test for | - = help: Replace `is not` with `!=` +help: Replace `is not` with `!=` ℹ Safe fix 23 23 | {2 is @@ -187,14 +196,15 @@ F632.py:26:2: F632 [*] Use `!=` to compare constant literals 29 28 | # Regression test for 30 29 | if values[1is not None ] is not '-': -F632.py:30:4: F632 [*] Use `!=` to compare constant literals +F632 [*] Use `!=` to compare constant literals + --> F632.py:30:4 | 29 | # Regression test for 30 | if values[1is not None ] is not '-': - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | pass | - = help: Replace `is not` with `!=` +help: Replace `is not` with `!=` ℹ Safe fix 27 27 | not ''} @@ -206,14 +216,15 @@ F632.py:30:4: F632 [*] Use `!=` to compare constant literals 32 32 | 33 33 | # Regression test for https://github.com/astral-sh/ruff/issues/11736 -F632.py:30:11: F632 [*] Use `!=` to compare constant literals +F632 [*] Use `!=` to compare constant literals + --> F632.py:30:11 | 29 | # Regression test for 30 | if values[1is not None ] is not '-': - | ^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^ 31 | pass | - = help: Replace `is not` with `!=` +help: Replace `is not` with `!=` ℹ Safe fix 27 27 | not ''} @@ -225,13 +236,14 @@ F632.py:30:11: F632 [*] Use `!=` to compare constant literals 32 32 | 33 33 | # Regression test for https://github.com/astral-sh/ruff/issues/11736 -F632.py:34:12: F632 [*] Use `!=` to compare constant literals +F632 [*] Use `!=` to compare constant literals + --> F632.py:34:12 | 33 | # Regression test for https://github.com/astral-sh/ruff/issues/11736 34 | variable: "123 is not y" - | ^^^^^^^^^^^^ F632 + | ^^^^^^^^^^^^ | - = help: Replace `is not` with `!=` +help: Replace `is not` with `!=` ℹ Safe fix 31 31 | pass diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap index 1399617c01..3e06e1bd63 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F633.py:4:1: F633 Use of `>>` is invalid with `print` function +F633 Use of `>>` is invalid with `print` function + --> F633.py:4:1 | 2 | import sys 3 | 4 | print >> sys.stderr, "Hello" - | ^^^^^ F633 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap index ce4f4be9aa..8015323bd4 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap @@ -1,29 +1,32 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F634.py:1:4: F634 If test is a tuple, which is always `True` +F634 If test is a tuple, which is always `True` + --> F634.py:1:4 | 1 | if (1, 2): - | ^^^^^^ F634 + | ^^^^^^ 2 | pass | -F634.py:4:4: F634 If test is a tuple, which is always `True` +F634 If test is a tuple, which is always `True` + --> F634.py:4:4 | 2 | pass 3 | 4 | if (3, 4): - | ^^^^^^ F634 + | ^^^^^^ 5 | pass 6 | elif foo: | -F634.py:12:10: F634 If test is a tuple, which is always `True` +F634 If test is a tuple, which is always `True` + --> F634.py:12:10 | 10 | if True: 11 | pass 12 | elif (3, 4): - | ^^^^^^ F634 + | ^^^^^^ 13 | pass 14 | elif (): | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap index 775b955209..cd32ed927c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap @@ -1,33 +1,37 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F701.py:4:5: F701 `break` outside loop +F701 `break` outside loop + --> F701.py:4:5 | 2 | break 3 | else: 4 | break - | ^^^^^ F701 + | ^^^^^ 5 | 6 | i = 0 | -F701.py:16:5: F701 `break` outside loop +F701 `break` outside loop + --> F701.py:16:5 | 14 | break 15 | 16 | break - | ^^^^^ F701 + | ^^^^^ | -F701.py:20:5: F701 `break` outside loop +F701 `break` outside loop + --> F701.py:20:5 | 19 | class Foo: 20 | break - | ^^^^^ F701 + | ^^^^^ | -F701.py:23:1: F701 `break` outside loop +F701 `break` outside loop + --> F701.py:23:1 | 23 | break - | ^^^^^ F701 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap index 89f8fd3cc0..5e121ca2c7 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap @@ -1,33 +1,37 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F702.py:4:5: F702 `continue` not properly in loop +F702 `continue` not properly in loop + --> F702.py:4:5 | 2 | continue 3 | else: 4 | continue - | ^^^^^^^^ F702 + | ^^^^^^^^ 5 | 6 | i = 0 | -F702.py:16:5: F702 `continue` not properly in loop +F702 `continue` not properly in loop + --> F702.py:16:5 | 14 | continue 15 | 16 | continue - | ^^^^^^^^ F702 + | ^^^^^^^^ | -F702.py:20:5: F702 `continue` not properly in loop +F702 `continue` not properly in loop + --> F702.py:20:5 | 19 | class Foo: 20 | continue - | ^^^^^^^^ F702 + | ^^^^^^^^ | -F702.py:23:1: F702 `continue` not properly in loop +F702 `continue` not properly in loop + --> F702.py:23:1 | 23 | continue - | ^^^^^^^^ F702 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F704_F704.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F704_F704.py.snap index 4afdfc8bb6..25a0fe321a 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F704_F704.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F704_F704.py.snap @@ -1,35 +1,39 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F704.py:6:5: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> F704.py:6:5 | 5 | class Foo: 6 | yield 2 - | ^^^^^^^ F704 + | ^^^^^^^ | -F704.py:9:1: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> F704.py:9:1 | 9 | yield 3 - | ^^^^^^^ F704 + | ^^^^^^^ 10 | yield from 3 11 | await f() | -F704.py:10:1: F704 `yield from` statement outside of a function +F704 `yield from` statement outside of a function + --> F704.py:10:1 | 9 | yield 3 10 | yield from 3 - | ^^^^^^^^^^^^ F704 + | ^^^^^^^^^^^^ 11 | await f() | -F704.py:11:1: F704 `await` statement outside of a function +F704 `await` statement outside of a function + --> F704.py:11:1 | 9 | yield 3 10 | yield from 3 11 | await f() - | ^^^^^^^^^ F704 + | ^^^^^^^^^ 12 | 13 | def _(): | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F706_F706.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F706_F706.py.snap index c6f545f5af..a547bebd4f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F706_F706.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F706_F706.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F706.py:6:5: F706 `return` statement outside of a function/method +F706 `return` statement outside of a function/method + --> F706.py:6:5 | 5 | class Foo: 6 | return 2 - | ^^^^^^^^ F706 + | ^^^^^^^^ | -F706.py:9:1: F706 `return` statement outside of a function/method +F706 `return` statement outside of a function/method + --> F706.py:9:1 | 9 | return 3 - | ^^^^^^^^ F706 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F707_F707.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F707_F707.py.snap index 7cb4461bd3..24dd7e01de 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F707_F707.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F707_F707.py.snap @@ -1,33 +1,35 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F707.py:3:1: F707 An `except` block as not the last exception handler +F707 An `except` block as not the last exception handler + --> F707.py:3:1 | 1 | try: 2 | pass 3 | except: - | ^^^^^^ F707 + | ^^^^^^ 4 | pass 5 | except ValueError: | -F707.py:10:1: F707 An `except` block as not the last exception handler +F707 An `except` block as not the last exception handler + --> F707.py:10:1 | 8 | try: 9 | pass 10 | except: - | ^^^^^^ F707 + | ^^^^^^ 11 | pass 12 | except ValueError: | -F707.py:19:1: F707 An `except` block as not the last exception handler +F707 An `except` block as not the last exception handler + --> F707.py:19:1 | 17 | try: 18 | pass 19 | except: - | ^^^^^^ F707 + | ^^^^^^ 20 | pass 21 | except ValueError: | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722.py.snap index 54646f4ff3..674c6f2bf2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722.py.snap @@ -1,22 +1,25 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F722.py:9:12: F722 Syntax error in forward annotation: Expected an expression +F722 Syntax error in forward annotation: Expected an expression + --> F722.py:9:12 | 9 | def g() -> "///": - | ^^^^^ F722 + | ^^^^^ 10 | pass | -F722.py:13:4: F722 Syntax error in forward annotation: Got unexpected token ☃ +F722 Syntax error in forward annotation: Got unexpected token ☃ + --> F722.py:13:4 | 13 | X: """List[int]"""'☃' = [] - | ^^^^^^^^^^^^^^^^^^ F722 + | ^^^^^^^^^^^^^^^^^^ 14 | 15 | # Type annotations with triple quotes can contain newlines and indentation | -F722.py:30:11: F722 Syntax error in forward annotation: Unexpected token at the end of an expression +F722 Syntax error in forward annotation: Unexpected token at the end of an expression + --> F722.py:30:11 | 28 | """ 29 | @@ -25,12 +28,13 @@ F722.py:30:11: F722 Syntax error in forward annotation: Unexpected token at the 31 | | int | 32 | | str) 33 | | """ - | |___^ F722 + | |___^ 34 | 35 | invalid2: """ | -F722.py:35:11: F722 Syntax error in forward annotation: Unexpected token at the end of an expression +F722 Syntax error in forward annotation: Unexpected token at the end of an expression + --> F722.py:35:11 | 33 | """ 34 | @@ -39,12 +43,13 @@ F722.py:35:11: F722 Syntax error in forward annotation: Unexpected token at the 36 | | int) | 37 | | str 38 | | """ - | |___^ F722 + | |___^ 39 | invalid3: """ 40 | ((int) | -F722.py:39:11: F722 Syntax error in forward annotation: unexpected EOF while parsing +F722 Syntax error in forward annotation: unexpected EOF while parsing + --> F722.py:39:11 | 37 | str 38 | """ @@ -52,12 +57,13 @@ F722.py:39:11: F722 Syntax error in forward annotation: unexpected EOF while par | ___________^ 40 | | ((int) 41 | | """ - | |___^ F722 + | |___^ 42 | invalid4: """ 43 | (int | -F722.py:42:11: F722 Syntax error in forward annotation: unexpected EOF while parsing +F722 Syntax error in forward annotation: unexpected EOF while parsing + --> F722.py:42:11 | 40 | ((int) 41 | """ @@ -65,5 +71,5 @@ F722.py:42:11: F722 Syntax error in forward annotation: unexpected EOF while par | ___________^ 43 | | (int 44 | | """ - | |___^ F722 + | |___^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722_1.py.snap index 1fd4f43abd..c01fb48cff 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722_1.py.snap @@ -1,28 +1,31 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F722_1.py:8:22: F722 Syntax error in forward annotation: Unexpected token at the end of an expression +F722 Syntax error in forward annotation: Unexpected token at the end of an expression + --> F722_1.py:8:22 | 6 | @no_type_check 7 | class C: 8 | def f(self, arg: "this isn't python") -> "this isn't python either": - | ^^^^^^^^^^^^^^^^^^^ F722 + | ^^^^^^^^^^^^^^^^^^^ 9 | x: "this also isn't python" = 1 | -F722_1.py:8:46: F722 Syntax error in forward annotation: Unexpected token at the end of an expression +F722 Syntax error in forward annotation: Unexpected token at the end of an expression + --> F722_1.py:8:46 | 6 | @no_type_check 7 | class C: 8 | def f(self, arg: "this isn't python") -> "this isn't python either": - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F722 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | x: "this also isn't python" = 1 | -F722_1.py:9:12: F722 Syntax error in forward annotation: Unexpected token at the end of an expression +F722 Syntax error in forward annotation: Unexpected token at the end of an expression + --> F722_1.py:9:12 | 7 | class C: 8 | def f(self, arg: "this isn't python") -> "this isn't python either": 9 | x: "this also isn't python" = 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^ F722 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap index 8b084ccac6..9dbabf2cf2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_0.py:10:5: F811 Redefinition of unused `bar` from line 6 +F811 Redefinition of unused `bar` from line 6 + --> F811_0.py:10:5 | 10 | def bar(): - | ^^^ F811 + | ^^^ 11 | pass | - = help: Remove definition: `bar` +help: Remove definition: `bar` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap index 7c96ecba03..e666db4b81 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_1.py:1:25: F811 Redefinition of unused `FU` from line 1 +F811 Redefinition of unused `FU` from line 1 + --> F811_1.py:1:25 | 1 | import fu as FU, bar as FU - | ^^ F811 + | ^^ | - = help: Remove definition: `FU` +help: Remove definition: `FU` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap index cd7495ada0..58f521edf0 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_12.py:6:20: F811 Redefinition of unused `mixer` from line 2 +F811 Redefinition of unused `mixer` from line 2 + --> F811_12.py:6:20 | 4 | pass 5 | else: 6 | from bb import mixer - | ^^^^^ F811 + | ^^^^^ 7 | mixer(123) | - = help: Remove definition: `mixer` +help: Remove definition: `mixer` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap index eb43408a7c..d457a39a20 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_15.py:4:5: F811 Redefinition of unused `fu` from line 1 +F811 Redefinition of unused `fu` from line 1 + --> F811_15.py:4:5 | 4 | def fu(): - | ^^ F811 + | ^^ 5 | pass | - = help: Remove definition: `fu` +help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap index af91808f2d..f8a1351dff 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_16.py:8:13: F811 Redefinition of unused `fu` from line 3 +F811 Redefinition of unused `fu` from line 3 + --> F811_16.py:8:13 | 6 | def bar(): 7 | def baz(): 8 | def fu(): - | ^^ F811 + | ^^ 9 | pass | - = help: Remove definition: `fu` +help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap index 367f5873a0..6e16f53992 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F811_17.py:6:12: F811 [*] Redefinition of unused `fu` from line 2 +F811 [*] Redefinition of unused `fu` from line 2 + --> F811_17.py:6:12 | 5 | def bar(): 6 | import fu - | ^^ F811 + | ^^ 7 | 8 | def baz(): | - = help: Remove definition: `fu` +help: Remove definition: `fu` ℹ Safe fix 3 3 | @@ -20,11 +21,12 @@ F811_17.py:6:12: F811 [*] Redefinition of unused `fu` from line 2 8 7 | def baz(): 9 8 | def fu(): -F811_17.py:9:13: F811 Redefinition of unused `fu` from line 6 +F811 Redefinition of unused `fu` from line 6 + --> F811_17.py:9:13 | 8 | def baz(): 9 | def fu(): - | ^^ F811 + | ^^ 10 | pass | - = help: Remove definition: `fu` +help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap index 3dcdb002cb..05ec31f26c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_2.py:1:34: F811 Redefinition of unused `FU` from line 1 +F811 Redefinition of unused `FU` from line 1 + --> F811_2.py:1:34 | 1 | from moo import fu as FU, bar as FU - | ^^ F811 + | ^^ | - = help: Remove definition: `FU` +help: Remove definition: `FU` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap index 8432ce531c..9cf6effbe6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F811_21.py:32:5: F811 [*] Redefinition of unused `Sequence` from line 26 +F811 [*] Redefinition of unused `Sequence` from line 26 + --> F811_21.py:32:5 | 30 | from typing import ( 31 | List, # noqa: F811 32 | Sequence, - | ^^^^^^^^ F811 + | ^^^^^^^^ 33 | ) | - = help: Remove definition: `Sequence` +help: Remove definition: `Sequence` ℹ Safe fix 27 27 | ) diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap index b503ae6f3b..d56b340e5b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_23.py:4:15: F811 Redefinition of unused `foo` from line 3 +F811 Redefinition of unused `foo` from line 3 + --> F811_23.py:4:15 | 3 | import foo as foo 4 | import bar as foo - | ^^^ F811 + | ^^^ | - = help: Remove definition: `foo` +help: Remove definition: `foo` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap index 91cacac98d..2a8febc47c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F811_26.py:5:9: F811 Redefinition of unused `func` from line 2 +F811 Redefinition of unused `func` from line 2 + --> F811_26.py:5:9 | 3 | pass 4 | 5 | def func(self): - | ^^^^ F811 + | ^^^^ 6 | pass | - = help: Remove definition: `func` +help: Remove definition: `func` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.py.snap index 69b2869a43..302c8ebf9f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_28.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F811_28.py:4:22: F811 Redefinition of unused `datetime` from line 3 +F811 Redefinition of unused `datetime` from line 3 + --> F811_28.py:4:22 | 3 | import datetime 4 | from datetime import datetime - | ^^^^^^^^ F811 + | ^^^^^^^^ 5 | 6 | datetime(1, 2, 3) | - = help: Remove definition: `datetime` +help: Remove definition: `datetime` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.pyi.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.pyi.snap index b67239e5d4..d2a1b5e0ca 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.pyi.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_29.pyi.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F811_29.pyi:8:1: F811 Redefinition of unused `Bar` from line 3 +F811 Redefinition of unused `Bar` from line 3 + --> F811_29.pyi:8:1 | 6 | Bar: int # OK 7 | 8 | Bar = 1 # F811 - | ^^^ F811 + | ^^^ | - = help: Remove definition: `Bar` +help: Remove definition: `Bar` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap index 430522582f..2e51c6831c 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_3.py:1:12: F811 Redefinition of unused `fu` from line 1 +F811 Redefinition of unused `fu` from line 1 + --> F811_3.py:1:12 | 1 | import fu; fu = 3 - | ^^ F811 + | ^^ | - = help: Remove definition: `fu` +help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_30.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_30.py.snap index b2955d6075..09bae7b514 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_30.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_30.py.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F811_30.py:12:9: F811 Redefinition of unused `bar` from line 10 +F811 Redefinition of unused `bar` from line 10 + --> F811_30.py:12:9 | 10 | bar = foo 11 | 12 | def bar(self) -> None: - | ^^^ F811 + | ^^^ 13 | """Bar.""" | - = help: Remove definition: `bar` +help: Remove definition: `bar` -F811_30.py:21:5: F811 Redefinition of unused `baz` from line 18 +F811 Redefinition of unused `baz` from line 18 + --> F811_30.py:21:5 | 19 | """Baz.""" 20 | 21 | baz = 1 - | ^^^ F811 + | ^^^ | - = help: Remove definition: `baz` +help: Remove definition: `baz` -F811_30.py:29:12: F811 Redefinition of unused `foo` from line 26 +F811 Redefinition of unused `foo` from line 26 + --> F811_30.py:29:12 | 27 | """Foo.""" 28 | 29 | bar = (foo := 1) - | ^^^ F811 + | ^^^ | - = help: Remove definition: `foo` +help: Remove definition: `foo` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_31.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_31.py.snap index bb4eb97b10..7a08ea3888 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_31.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_31.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F811_31.py:19:29: F811 Redefinition of unused `baz` from line 17 +F811 Redefinition of unused `baz` from line 17 + --> F811_31.py:19:29 | 17 | baz = None 18 | 19 | from some_module import baz - | ^^^ F811 + | ^^^ 20 | except ImportError: 21 | pass | - = help: Remove definition: `baz` +help: Remove definition: `baz` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_32.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_32.py.snap index 8424433dd2..6b00fc2d31 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_32.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_32.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F811_32.py:5:5: F811 [*] Redefinition of unused `List` from line 4 +F811 [*] Redefinition of unused `List` from line 4 + --> F811_32.py:5:5 | 3 | from typing import ( 4 | List, 5 | List, - | ^^^^ F811 + | ^^^^ 6 | ) | - = help: Remove definition: `List` +help: Remove definition: `List` ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap index dfccff0534..11bb7bd824 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_4.py:1:12: F811 Redefinition of unused `fu` from line 1 +F811 Redefinition of unused `fu` from line 1 + --> F811_4.py:1:12 | 1 | import fu; fu, bar = 3 - | ^^ F811 + | ^^ | - = help: Remove definition: `fu` +help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap index 0a44f240a5..908d45c1bb 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_5.py:1:13: F811 Redefinition of unused `fu` from line 1 +F811 Redefinition of unused `fu` from line 1 + --> F811_5.py:1:13 | 1 | import fu; [fu, bar] = 3 - | ^^ F811 + | ^^ | - = help: Remove definition: `fu` +help: Remove definition: `fu` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap index 5c2de08fd9..e2c3c0cf88 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_6.py:6:12: F811 [*] Redefinition of unused `os` from line 5 +F811 [*] Redefinition of unused `os` from line 5 + --> F811_6.py:6:12 | 4 | if i == 1: 5 | import os 6 | import os - | ^^ F811 + | ^^ 7 | os.path | - = help: Remove definition: `os` +help: Remove definition: `os` ℹ Safe fix 3 3 | i = 2 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap index 186d426ff2..a3236f8fbe 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F811_8.py:5:12: F811 [*] Redefinition of unused `os` from line 4 +F811 [*] Redefinition of unused `os` from line 4 + --> F811_8.py:5:12 | 3 | try: 4 | import os 5 | import os - | ^^ F811 + | ^^ 6 | except: 7 | pass | - = help: Remove definition: `os` +help: Remove definition: `os` ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap index ad83ffe0ac..fd16a70827 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap @@ -1,115 +1,128 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F821_0.py:2:12: F821 Undefined name `self` +F821 Undefined name `self` + --> F821_0.py:2:12 | 1 | def get_name(): 2 | return self.name - | ^^^^ F821 + | ^^^^ | -F821_0.py:6:13: F821 Undefined name `self` +F821 Undefined name `self` + --> F821_0.py:6:13 | 5 | def get_name(): 6 | return (self.name,) - | ^^^^ F821 + | ^^^^ | -F821_0.py:10:9: F821 Undefined name `self` +F821 Undefined name `self` + --> F821_0.py:10:9 | 9 | def get_name(): 10 | del self.name - | ^^^^ F821 + | ^^^^ | -F821_0.py:21:12: F821 Undefined name `numeric_string` +F821 Undefined name `numeric_string` + --> F821_0.py:21:12 | 20 | def randdec(maxprec, maxexp): 21 | return numeric_string(maxprec, maxexp) - | ^^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^^ | -F821_0.py:58:5: F821 Undefined name `Bar` +F821 Undefined name `Bar` + --> F821_0.py:58:5 | 56 | y: int = 1 57 | 58 | x: "Bar" = 1 - | ^^^ F821 + | ^^^ 59 | 60 | [first] = ["yup"] | -F821_0.py:83:11: F821 Undefined name `TOMATO` +F821 Undefined name `TOMATO` + --> F821_0.py:83:11 | 82 | def update_tomato(): 83 | print(TOMATO) - | ^^^^^^ F821 + | ^^^^^^ 84 | TOMATO = "cherry tomato" | -F821_0.py:87:8: F821 Undefined name `B` +F821 Undefined name `B` + --> F821_0.py:87:8 | 87 | A = f'{B}' - | ^ F821 + | ^ 88 | A = ( 89 | f'B' | -F821_0.py:90:8: F821 Undefined name `B` +F821 Undefined name `B` + --> F821_0.py:90:8 | 88 | A = ( 89 | f'B' 90 | f'{B}' - | ^ F821 + | ^ 91 | ) 92 | C = f'{A:{B}}' | -F821_0.py:92:11: F821 Undefined name `B` +F821 Undefined name `B` + --> F821_0.py:92:11 | 90 | f'{B}' 91 | ) 92 | C = f'{A:{B}}' - | ^ F821 + | ^ 93 | C = f'{A:{f"{B}"}}' | -F821_0.py:93:14: F821 Undefined name `B` +F821 Undefined name `B` + --> F821_0.py:93:14 | 91 | ) 92 | C = f'{A:{B}}' 93 | C = f'{A:{f"{B}"}}' - | ^ F821 + | ^ 94 | 95 | from typing import Annotated, Literal | -F821_0.py:115:10: F821 Undefined name `PEP593Test123` +F821 Undefined name `PEP593Test123` + --> F821_0.py:115:10 | 113 | ] 114 | field_with_undefined_stringified_type: Annotated[ 115 | "PEP593Test123", - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 116 | 123, 117 | ] | -F821_0.py:123:15: F821 Undefined name `foo` +F821 Undefined name `foo` + --> F821_0.py:123:15 | 121 | ] 122 | field_with_undefined_nested_subscript: Annotated[ 123 | dict["foo", "bar"], # Expected to fail as undefined. - | ^^^ F821 + | ^^^ 124 | 123, 125 | ] | -F821_0.py:123:22: F821 Undefined name `bar` +F821 Undefined name `bar` + --> F821_0.py:123:22 | 121 | ] 122 | field_with_undefined_nested_subscript: Annotated[ 123 | dict["foo", "bar"], # Expected to fail as undefined. - | ^^^ F821 + | ^^^ 124 | 123, 125 | ] | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_1.py.snap index 388a7b77a3..7df73254f3 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_1.py.snap @@ -1,31 +1,34 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_1.py:11:11: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_1.py:11:11 | 10 | # F821 Undefined name `Model` 11 | x = cast("Model", x) - | ^^^^^ F821 + | ^^^^^ | -F821_1.py:18:18: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_1.py:18:18 | 17 | # F821 Undefined name `Model` 18 | x = typing.cast("Model", x) - | ^^^^^ F821 + | ^^^^^ | -F821_1.py:24:14: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_1.py:24:14 | 23 | # F821 Undefined name `Model` 24 | x = Pattern["Model"] - | ^^^^^ F821 + | ^^^^^ | -F821_1.py:30:12: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_1.py:30:12 | 29 | # F821 Undefined name `Model` 30 | x = Match["Model"] - | ^^^^^ F821 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.py.snap index fe57c5320d..18a0d3e859 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_11.py:18:28: F821 Undefined name `os` +F821 Undefined name `os` + --> F821_11.py:18:28 | 18 | def f(x: Callable[[VarArg("os")], None]): # F821 - | ^^ F821 + | ^^ 19 | pass | -F821_11.py:23:14: F821 Undefined name `Baz` +F821 Undefined name `Baz` + --> F821_11.py:23:14 | 22 | f(Callable[["Bar"], None]) 23 | f(Callable[["Baz"], None]) - | ^^^ F821 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.pyi.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.pyi.snap index 9716d11d90..3af4836d2d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.pyi.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.pyi.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_11.pyi:15:28: F821 Undefined name `os` +F821 Undefined name `os` + --> F821_11.pyi:15:28 | 15 | def f(x: Callable[[VarArg("os")], None]): # F821 - | ^^ F821 + | ^^ 16 | pass | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_12.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_12.py.snap index d2b5a37fd2..fda19cffaf 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_12.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_12.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_12.py:20:28: F821 Undefined name `os` +F821 Undefined name `os` + --> F821_12.py:20:28 | 20 | def f(x: Callable[[VarArg("os")], None]): # F821 - | ^^ F821 + | ^^ 21 | pass | -F821_12.py:25:14: F821 Undefined name `Baz` +F821 Undefined name `Baz` + --> F821_12.py:25:14 | 24 | f(Callable[["Bar"], None]) 25 | f(Callable[["Baz"], None]) - | ^^^ F821 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap index d156dc3ea9..0b977f2213 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F821_13.py:8:19: F821 Undefined name `List` +F821 Undefined name `List` + --> F821_13.py:8:19 | 6 | Y: ForwardRef("List[int]") 7 | 8 | Z = TypeVar("X", "List[int]", "int") - | ^^^^ F821 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap index ad86315ccc..fbbd199636 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap @@ -1,267 +1,296 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F821_17.py:16:12: F821 Undefined name `DoesNotExist` +F821 Undefined name `DoesNotExist` + --> F821_17.py:16:12 | 14 | # Types used in aliased assignment must exist 15 | 16 | type Foo = DoesNotExist # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^ 17 | type Foo = list[DoesNotExist] # F821: Undefined name `DoesNotExist` | -F821_17.py:17:17: F821 Undefined name `DoesNotExist` +F821 Undefined name `DoesNotExist` + --> F821_17.py:17:17 | 16 | type Foo = DoesNotExist # F821: Undefined name `DoesNotExist` 17 | type Foo = list[DoesNotExist] # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^ 18 | 19 | # Type parameters do not escape alias scopes | -F821_17.py:22:1: F821 Undefined name `T` +F821 Undefined name `T` + --> F821_17.py:22:1 | 21 | type Foo[T] = T 22 | T # F821: Undefined name `T` - not accessible afterward alias scope - | ^ F821 + | ^ 23 | 24 | # Type parameters in functions | -F821_17.py:39:17: F821 Undefined name `T` +F821 Undefined name `T` + --> F821_17.py:39:17 | 37 | from some_library import some_decorator 38 | 39 | @some_decorator(T) # F821: Undefined name `T` - not accessible in decorators - | ^ F821 + | ^ 40 | 41 | def foo[T](t: T) -> None: ... | -F821_17.py:42:1: F821 Undefined name `T` +F821 Undefined name `T` + --> F821_17.py:42:1 | 41 | def foo[T](t: T) -> None: ... 42 | T # F821: Undefined name `T` - not accessible afterward function scope - | ^ F821 + | ^ | -F821_17.py:64:17: F821 Undefined name `T` +F821 Undefined name `T` + --> F821_17.py:64:17 | 63 | from some_library import some_decorator 64 | @some_decorator(T) # F821: Undefined name `T` - not accessible in decorators - | ^ F821 + | ^ 65 | 66 | class Foo[T](list[T]): ... | -F821_17.py:67:1: F821 Undefined name `T` +F821 Undefined name `T` + --> F821_17.py:67:1 | 66 | class Foo[T](list[T]): ... 67 | T # F821: Undefined name `T` - not accessible after class scope - | ^ F821 + | ^ 68 | 69 | # Types specified in bounds should exist | -F821_17.py:71:13: F821 Undefined name `DoesNotExist` +F821 Undefined name `DoesNotExist` + --> F821_17.py:71:13 | 69 | # Types specified in bounds should exist 70 | 71 | type Foo[T: DoesNotExist] = T # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^ 72 | def foo[T: DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` 73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` | -F821_17.py:72:12: F821 Undefined name `DoesNotExist` +F821 Undefined name `DoesNotExist` + --> F821_17.py:72:12 | 71 | type Foo[T: DoesNotExist] = T # F821: Undefined name `DoesNotExist` 72 | def foo[T: DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^ 73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` | -F821_17.py:73:14: F821 Undefined name `DoesNotExist` +F821 Undefined name `DoesNotExist` + --> F821_17.py:73:14 | 71 | type Foo[T: DoesNotExist] = T # F821: Undefined name `DoesNotExist` 72 | def foo[T: DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` 73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^ 74 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:75:14: F821 Undefined name `DoesNotExist1` +F821 Undefined name `DoesNotExist1` + --> F821_17.py:75:14 | 73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` 74 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:75:29: F821 Undefined name `DoesNotExist2` +F821 Undefined name `DoesNotExist2` + --> F821_17.py:75:29 | 73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` 74 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:76:13: F821 Undefined name `DoesNotExist1` +F821 Undefined name `DoesNotExist1` + --> F821_17.py:76:13 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:76:28: F821 Undefined name `DoesNotExist2` +F821 Undefined name `DoesNotExist2` + --> F821_17.py:76:28 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:77:15: F821 Undefined name `DoesNotExist1` +F821 Undefined name `DoesNotExist1` + --> F821_17.py:77:15 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 78 | 79 | # Same in defaults | -F821_17.py:77:30: F821 Undefined name `DoesNotExist2` +F821 Undefined name `DoesNotExist2` + --> F821_17.py:77:30 | 75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 78 | 79 | # Same in defaults | -F821_17.py:81:14: F821 Undefined name `DoesNotExist` +F821 Undefined name `DoesNotExist` + --> F821_17.py:81:14 | 79 | # Same in defaults 80 | 81 | type Foo[T = DoesNotExist] = T # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^ 82 | def foo[T = DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` 83 | class Foo[T = DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` | -F821_17.py:82:13: F821 Undefined name `DoesNotExist` +F821 Undefined name `DoesNotExist` + --> F821_17.py:82:13 | 81 | type Foo[T = DoesNotExist] = T # F821: Undefined name `DoesNotExist` 82 | def foo[T = DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^ 83 | class Foo[T = DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` | -F821_17.py:83:15: F821 Undefined name `DoesNotExist` +F821 Undefined name `DoesNotExist` + --> F821_17.py:83:15 | 81 | type Foo[T = DoesNotExist] = T # F821: Undefined name `DoesNotExist` 82 | def foo[T = DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` 83 | class Foo[T = DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^ 84 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:85:15: F821 Undefined name `DoesNotExist1` +F821 Undefined name `DoesNotExist1` + --> F821_17.py:85:15 | 83 | class Foo[T = DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` 84 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:85:30: F821 Undefined name `DoesNotExist2` +F821 Undefined name `DoesNotExist2` + --> F821_17.py:85:30 | 83 | class Foo[T = DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` 84 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:86:14: F821 Undefined name `DoesNotExist1` +F821 Undefined name `DoesNotExist1` + --> F821_17.py:86:14 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:86:29: F821 Undefined name `DoesNotExist2` +F821 Undefined name `DoesNotExist2` + --> F821_17.py:86:29 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` | -F821_17.py:87:16: F821 Undefined name `DoesNotExist1` +F821 Undefined name `DoesNotExist1` + --> F821_17.py:87:16 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 88 | 89 | # Type parameters in nested classes | -F821_17.py:87:31: F821 Undefined name `DoesNotExist2` +F821 Undefined name `DoesNotExist2` + --> F821_17.py:87:31 | 85 | type Foo[T = (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` 86 | def foo[T = (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist… 87 | class Foo[T = (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^ 88 | 89 | # Type parameters in nested classes | -F821_17.py:102:52: F821 Undefined name `t` +F821 Undefined name `t` + --> F821_17.py:102:52 | 100 | return x 101 | 102 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` - | ^ F821 + | ^ 103 | t # F821: Undefined name `t` 104 | return x | -F821_17.py:102:58: F821 Undefined name `t` +F821 Undefined name `t` + --> F821_17.py:102:58 | 100 | return x 101 | 102 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` - | ^ F821 + | ^ 103 | t # F821: Undefined name `t` 104 | return x | -F821_17.py:103:17: F821 Undefined name `t` +F821 Undefined name `t` + --> F821_17.py:103:17 | 102 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` 103 | t # F821: Undefined name `t` - | ^ F821 + | ^ 104 | return x | -F821_17.py:116:40: F821 Undefined name `T` +F821 Undefined name `T` + --> F821_17.py:116:40 | 116 | def cannot_access_in_default[T](t: T = T): # F821 - | ^ F821 + | ^ 117 | pass | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_19.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_19.py.snap index 65844fc9f6..022fe287ba 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_19.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_19.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_19.py:21:7: F821 Undefined name `y` +F821 Undefined name `y` + --> F821_19.py:21:7 | 19 | # Error: `y` is not defined. 20 | x: (y := 1) 21 | print(y) - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap index 643cc2a4cb..89dd2df81f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F821_2.py:5:13: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_2.py:5:13 | 4 | # F821 Undefined name `Model` 5 | x: Literal["Model"] - | ^^^^^ F821 + | ^^^^^ 6 | 7 | from typing_extensions import Literal | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_20.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_20.py.snap index f791abbfcc..9cdeb20f40 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_20.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_20.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F821_20.py:3:24: F821 Undefined name `Record` +F821 Undefined name `Record` + --> F821_20.py:3:24 | 1 | """Test lazy evaluation of type alias values.""" 2 | 3 | type RecordCallback[R: Record] = Callable[[R], None] - | ^^^^^^ F821 + | ^^^^^^ 4 | 5 | from collections.abc import Callable | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_21.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_21.py.snap index dd8c65c608..4e5196ca9d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_21.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_21.py.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_21.py:4:1: F821 Undefined name `display` +F821 Undefined name `display` + --> F821_21.py:4:1 | 3 | x = 1 4 | display(x) - | ^^^^^^^ F821 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_26.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_26.py.snap index 0fe9ae3d00..9bb838ffff 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_26.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_26.py.snap @@ -1,84 +1,92 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_26.py:9:33: F821 Undefined name `CStr` +F821 Undefined name `CStr` + --> F821_26.py:9:33 | 8 | # Forward references: 9 | MaybeCStr: TypeAlias = Optional[CStr] # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^^^^ F821 + | ^^^^ 10 | MaybeCStr2: TypeAlias = Optional["CStr"] # always okay 11 | CStr: TypeAlias = Union[C, str] # valid in a `.pyi` stub file, not in a `.py` runtime file | -F821_26.py:11:25: F821 Undefined name `C` +F821 Undefined name `C` + --> F821_26.py:11:25 | 9 | MaybeCStr: TypeAlias = Optional[CStr] # valid in a `.pyi` stub file, not in a `.py` runtime file 10 | MaybeCStr2: TypeAlias = Optional["CStr"] # always okay 11 | CStr: TypeAlias = Union[C, str] # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^ F821 + | ^ 12 | CStr2: TypeAlias = Union["C", str] # always okay | -F821_26.py:16:12: F821 Undefined name `C` +F821 Undefined name `C` + --> F821_26.py:16:12 | 14 | # References to a class from inside the class: 15 | class C: 16 | other: C = ... # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^ F821 + | ^ 17 | other2: "C" = ... # always okay 18 | def from_str(self, s: str) -> C: ... # valid in a `.pyi` stub file, not in a `.py` runtime file | -F821_26.py:18:35: F821 Undefined name `C` +F821 Undefined name `C` + --> F821_26.py:18:35 | 16 | other: C = ... # valid in a `.pyi` stub file, not in a `.py` runtime file 17 | other2: "C" = ... # always okay 18 | def from_str(self, s: str) -> C: ... # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^ F821 + | ^ 19 | def from_str2(self, s: str) -> "C": ... # always okay | -F821_26.py:23:10: F821 Undefined name `B` +F821 Undefined name `B` + --> F821_26.py:23:10 | 21 | # Circular references: 22 | class A: 23 | foo: B # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^ F821 + | ^ 24 | foo2: "B" # always okay 25 | bar: dict[str, B] # valid in a `.pyi` stub file, not in a `.py` runtime file | -F821_26.py:25:20: F821 Undefined name `B` +F821 Undefined name `B` + --> F821_26.py:25:20 | 23 | foo: B # valid in a `.pyi` stub file, not in a `.py` runtime file 24 | foo2: "B" # always okay 25 | bar: dict[str, B] # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^ F821 + | ^ 26 | bar2: dict[str, "A"] # always okay | -F821_26.py:33:17: F821 Undefined name `Tree` +F821 Undefined name `Tree` + --> F821_26.py:33:17 | 32 | class Leaf: ... 33 | class Tree(list[Tree | Leaf]): ... # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^^^^ F821 + | ^^^^ 34 | class Tree2(list["Tree | Leaf"]): ... # always okay | -F821_26.py:39:11: F821 Undefined name `foo` +F821 Undefined name `foo` + --> F821_26.py:39:11 | 37 | class MyClass: 38 | foo: int 39 | bar = foo # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^^^ F821 + | ^^^ 40 | bar = "foo" # always okay | -F821_26.py:43:8: F821 Undefined name `baz` +F821 Undefined name `baz` + --> F821_26.py:43:8 | 42 | baz: MyClass 43 | eggs = baz # valid in a `.pyi` stub file, not in a `.py` runtime file - | ^^^ F821 + | ^^^ 44 | eggs = "baz" # always okay | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_27.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_27.py.snap index eb74e0d2aa..ba6f4776a6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_27.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_27.py.snap @@ -1,47 +1,51 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_27.py:30:11: F821 Undefined name `foo` +F821 Undefined name `foo` + --> F821_27.py:30:11 | 28 | class MyClass: 29 | foo: int 30 | bar = foo # Still invalid even when `__future__.annotations` are enabled - | ^^^ F821 + | ^^^ 31 | bar = "foo" # always okay | -F821_27.py:34:8: F821 Undefined name `baz` +F821 Undefined name `baz` + --> F821_27.py:34:8 | 33 | baz: MyClass 34 | eggs = baz # Still invalid even when `__future__.annotations` are enabled - | ^^^ F821 + | ^^^ 35 | eggs = "baz" # always okay | -F821_27.py:38:33: F821 Undefined name `DStr` +F821 Undefined name `DStr` + --> F821_27.py:38:33 | 37 | # Forward references: 38 | MaybeDStr: TypeAlias = Optional[DStr] # Still invalid even when `__future__.annotations` are enabled - | ^^^^ F821 + | ^^^^ 39 | MaybeDStr2: TypeAlias = Optional["DStr"] # always okay 40 | DStr: TypeAlias = Union[D, str] # Still invalid even when `__future__.annotations` are enabled | -F821_27.py:40:25: F821 Undefined name `D` +F821 Undefined name `D` + --> F821_27.py:40:25 | 38 | MaybeDStr: TypeAlias = Optional[DStr] # Still invalid even when `__future__.annotations` are enabled 39 | MaybeDStr2: TypeAlias = Optional["DStr"] # always okay 40 | DStr: TypeAlias = Union[D, str] # Still invalid even when `__future__.annotations` are enabled - | ^ F821 + | ^ 41 | DStr2: TypeAlias = Union["D", str] # always okay | -F821_27.py:47:17: F821 Undefined name `Tree` +F821 Undefined name `Tree` + --> F821_27.py:47:17 | 45 | # More circular references 46 | class Leaf: ... 47 | class Tree(list[Tree | Leaf]): ... # Still invalid even when `__future__.annotations` are enabled - | ^^^^ F821 + | ^^^^ 48 | class Tree2(list["Tree | Leaf"]): ... # always okay | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_28.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_28.py.snap index 56103d85ad..348d12a438 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_28.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_28.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F821_28.py:9:7: F821 Undefined name `𝒟` +F821 Undefined name `𝒟` + --> F821_28.py:9:7 | 7 | print(C == 𝑪 == 𝒞 == 𝓒 == 𝕮) 8 | 9 | print(𝒟) # F821 - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap index 2f06a91e4c..32833e46d4 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap @@ -1,22 +1,24 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F821_3.py:11:10: F821 Undefined name `key` +F821 Undefined name `key` + --> F821_3.py:11:10 | 9 | # F821 Undefined name `key` 10 | # F821 Undefined name `value` 11 | x: dict["key", "value"] - | ^^^ F821 + | ^^^ 12 | 13 | # OK | -F821_3.py:11:17: F821 Undefined name `value` +F821 Undefined name `value` + --> F821_3.py:11:17 | 9 | # F821 Undefined name `key` 10 | # F821 Undefined name `value` 11 | x: dict["key", "value"] - | ^^^^^ F821 + | ^^^^^ 12 | 13 | # OK | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_30.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_30.py.snap index d39ce19805..b7fa1df5bf 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_30.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_30.py.snap @@ -1,50 +1,54 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_30.py:13:18: F821 Undefined name `qux` +F821 Undefined name `qux` + --> F821_30.py:13:18 | 11 | multiple: TypedDict[{ 12 | "bar": str, 13 | "baz": list["qux"], - | ^^^ F821 + | ^^^ 14 | }] | -F821_30.py:19:19: F821 Undefined name `dolor` +F821 Undefined name `dolor` + --> F821_30.py:19:19 | 17 | nested: TypedDict[ 18 | "lorem": TypedDict[{ 19 | "ipsum": "dolor" - | ^^^^^ F821 + | ^^^^^ 20 | }], 21 | "sit": Literal["amet"] | -F821_30.py:26:31: F821 Undefined name `adipiscing` +F821 Undefined name `adipiscing` + --> F821_30.py:26:31 | 24 | # Error at `adipiscing`, `eiusmod`, `tempor` 25 | unpack: TypedDict[{ 26 | "consectetur": Annotated["adipiscing", "elit"] - | ^^^^^^^^^^ F821 + | ^^^^^^^^^^ 27 | **{"sed do": str, int: "eiusmod", **tempor} 28 | }] | -F821_30.py:27:29: F821 Undefined name `eiusmod` +F821 Undefined name `eiusmod` + --> F821_30.py:27:29 | 25 | unpack: TypedDict[{ 26 | "consectetur": Annotated["adipiscing", "elit"] 27 | **{"sed do": str, int: "eiusmod", **tempor} - | ^^^^^^^ F821 + | ^^^^^^^ 28 | }] | -F821_30.py:27:41: F821 Undefined name `tempor` +F821 Undefined name `tempor` + --> F821_30.py:27:41 | 25 | unpack: TypedDict[{ 26 | "consectetur": Annotated["adipiscing", "elit"] 27 | **{"sed do": str, int: "eiusmod", **tempor} - | ^^^^^^ F821 + | ^^^^^^ 28 | }] | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_31.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_31.py.snap index c2a8132015..c1a10a41ff 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_31.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_31.py.snap @@ -1,53 +1,58 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_31.py:8:23: F821 Undefined name `B` +F821 Undefined name `B` + --> F821_31.py:8:23 | 6 | @typing.no_type_check 7 | class C: 8 | def f(self, arg: "B") -> "S": - | ^ F821 + | ^ 9 | x: "B" = 1 | -F821_31.py:8:31: F821 Undefined name `S` +F821 Undefined name `S` + --> F821_31.py:8:31 | 6 | @typing.no_type_check 7 | class C: 8 | def f(self, arg: "B") -> "S": - | ^ F821 + | ^ 9 | x: "B" = 1 | -F821_31.py:9:13: F821 Undefined name `B` +F821 Undefined name `B` + --> F821_31.py:9:13 | 7 | class C: 8 | def f(self, arg: "B") -> "S": 9 | x: "B" = 1 - | ^ F821 + | ^ | -F821_31.py:15:13: F821 Undefined name `A` +F821 Undefined name `A` + --> F821_31.py:15:13 | 14 | @typing.no_type_check 15 | def f(arg: "A") -> "R": - | ^ F821 + | ^ 16 | x: "A" = 1 | -F821_31.py:15:21: F821 Undefined name `R` +F821 Undefined name `R` + --> F821_31.py:15:21 | 14 | @typing.no_type_check 15 | def f(arg: "A") -> "R": - | ^ F821 + | ^ 16 | x: "A" = 1 | -F821_31.py:16:9: F821 Undefined name `A` +F821 Undefined name `A` + --> F821_31.py:16:9 | 14 | @typing.no_type_check 15 | def f(arg: "A") -> "R": 16 | x: "A" = 1 - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap index 9077bbc312..dc5ceec156 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap @@ -1,42 +1,47 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F821_4.py:4:11: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_4.py:4:11 | 2 | from typing import List 3 | 4 | _ = List["Model"] - | ^^^^^ F821 + | ^^^^^ | -F821_4.py:9:12: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_4.py:9:12 | 7 | from typing import List as IList 8 | 9 | _ = IList["Model"] - | ^^^^^ F821 + | ^^^^^ | -F821_4.py:14:16: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_4.py:14:16 | 12 | from collections.abc import ItemsView 13 | 14 | _ = ItemsView["Model"] - | ^^^^^ F821 + | ^^^^^ | -F821_4.py:19:32: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_4.py:19:32 | 17 | import collections.abc 18 | 19 | _ = collections.abc.ItemsView["Model"] - | ^^^^^ F821 + | ^^^^^ | -F821_4.py:24:20: F821 Undefined name `Model` +F821 Undefined name `Model` + --> F821_4.py:24:20 | 22 | from collections import abc 23 | 24 | _ = abc.ItemsView["Model"] - | ^^^^^ F821 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.py.snap index bbd0104185..bed48f547e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_5.py:5:31: F821 Undefined name `InnerClass` +F821 Undefined name `InnerClass` + --> F821_5.py:5:31 | 4 | class RandomClass: 5 | def random_func(self) -> "InnerClass": - | ^^^^^^^^^^ F821 + | ^^^^^^^^^^ 6 | pass | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.pyi.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.pyi.snap index a7d8933102..b827875c1d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.pyi.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.pyi.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_5.pyi:4:27: F821 Undefined name `InnerClass` +F821 Undefined name `InnerClass` + --> F821_5.pyi:4:27 | 3 | class RandomClass: 4 | def bad_func(self) -> InnerClass: ... # F821 - | ^^^^^^^^^^ F821 + | ^^^^^^^^^^ 5 | def good_func(self) -> OuterClass.InnerClass: ... # Okay | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_7.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_7.py.snap index 727e8cd87a..a818f1c1f9 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_7.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_7.py.snap @@ -1,29 +1,31 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_7.py:11:22: F821 Undefined name `Undefined` +F821 Undefined name `Undefined` + --> F821_7.py:11:22 | 10 | # Not OK 11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") - | ^^^^^^^^^ F821 + | ^^^^^^^^^ 12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") 13 | _ = DefaultNamedArg("Undefined", "some_prop_name") | -F821_7.py:12:27: F821 Undefined name `Undefined` +F821 Undefined name `Undefined` + --> F821_7.py:12:27 | 10 | # Not OK 11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") 12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") - | ^^^^^^^^^ F821 + | ^^^^^^^^^ 13 | _ = DefaultNamedArg("Undefined", "some_prop_name") | -F821_7.py:13:22: F821 Undefined name `Undefined` +F821 Undefined name `Undefined` + --> F821_7.py:13:22 | 11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") 12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") 13 | _ = DefaultNamedArg("Undefined", "some_prop_name") - | ^^^^^^^^^ F821 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_9.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_9.py.snap index 976d74866a..ce557ed224 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_9.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_9.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F821_9.py:22:20: F821 Undefined name `captured` +F821 Undefined name `captured` + --> F821_9.py:22:20 | 20 | match provided: 21 | case True: 22 | return captured # F821 - | ^^^^^^^^ F821 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap index 10d1e6f4e0..f75fb59fdd 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F822_0.py:3:17: F822 Undefined name `b` in `__all__` +F822 Undefined name `b` in `__all__` + --> F822_0.py:3:17 | 1 | a = 1 2 | 3 | __all__ = ["a", "b"] - | ^^^ F822 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.pyi.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.pyi.snap index 4810ad4608..761c68b678 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.pyi.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.pyi.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F822_0.pyi:4:22: F822 Undefined name `c` in `__all__` +F822 Undefined name `c` in `__all__` + --> F822_0.pyi:4:22 | 2 | b: int # Considered a binding in a `.pyi` stub file, not in a `.py` runtime file 3 | 4 | __all__ = ["a", "b", "c"] # c is flagged as missing; b is not - | ^^^ F822 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap index 5486326ac9..ead94dbcaa 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F822_1.py:3:22: F822 Undefined name `b` in `__all__` +F822 Undefined name `b` in `__all__` + --> F822_1.py:3:22 | 1 | a = 1 2 | 3 | __all__ = list(["a", "b"]) - | ^^^ F822 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1b.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1b.py.snap index a52632a6a8..aa41c02a6f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1b.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1b.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F822_1b.py:4:31: F822 Undefined name `b` in `__all__` +F822 Undefined name `b` in `__all__` + --> F822_1b.py:4:31 | 2 | a = 1 3 | 4 | __all__ = builtins.list(["a", "b"]) - | ^^^ F822 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_3.py.snap index ffc2b35cf8..83c20b0893 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_3.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_3.py.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F822_3.py:12:5: F822 Undefined name `ExponentialFamily` in `__all__` +F822 Undefined name `ExponentialFamily` in `__all__` + --> F822_3.py:12:5 | 10 | __all__ += [ 11 | "ContinuousBernoulli", # noqa: F822 12 | "ExponentialFamily", - | ^^^^^^^^^^^^^^^^^^^ F822 + | ^^^^^^^^^^^^^^^^^^^ 13 | ] | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap index 75fd12222a..4fded2b2fb 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap @@ -1,44 +1,49 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F823.py:6:5: F823 Local variable `my_var` referenced before assignment +F823 Local variable `my_var` referenced before assignment + --> F823.py:6:5 | 5 | def foo(): 6 | my_var += 1 - | ^^^^^^ F823 + | ^^^^^^ | -F823.py:32:15: F823 Local variable `my_var` referenced before assignment +F823 Local variable `my_var` referenced before assignment + --> F823.py:32:15 | 30 | class Class: 31 | def f(self): 32 | print(my_var) - | ^^^^^^ F823 + | ^^^^^^ 33 | my_var = 1 | -F823.py:40:15: F823 Local variable `my_var` referenced before assignment +F823 Local variable `my_var` referenced before assignment + --> F823.py:40:15 | 39 | def f(self): 40 | print(my_var) - | ^^^^^^ F823 + | ^^^^^^ 41 | my_var = 1 | -F823.py:48:11: F823 Local variable `sys` referenced before assignment +F823 Local variable `sys` referenced before assignment + --> F823.py:48:11 | 47 | def main(): 48 | print(sys.argv) - | ^^^ F823 + | ^^^ 49 | 50 | try: | -F823.py:62:11: F823 Local variable `sys` referenced before assignment +F823 Local variable `sys` referenced before assignment + --> F823.py:62:11 | 61 | def main(): 62 | print(sys.argv) - | ^^^ F823 + | ^^^ 63 | 64 | for sys in range(5): | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap index a8a860e83c..2361f61f36 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used +F841 [*] Local variable `e` is assigned to but never used + --> F841_0.py:3:22 | 1 | try: 2 | 1 / 0 3 | except ValueError as e: - | ^ F841 + | ^ 4 | pass | - = help: Remove assignment to unused variable `e` +help: Remove assignment to unused variable `e` ℹ Safe fix 1 1 | try: @@ -20,14 +21,15 @@ F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used 5 5 | 6 6 | -F841_0.py:16:5: F841 [*] Local variable `z` is assigned to but never used +F841 [*] Local variable `z` is assigned to but never used + --> F841_0.py:16:5 | 14 | x = 1 15 | y = 2 16 | z = x + y - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `z` +help: Remove assignment to unused variable `z` ℹ Unsafe fix 13 13 | def f(): @@ -39,14 +41,15 @@ F841_0.py:16:5: F841 [*] Local variable `z` is assigned to but never used 18 18 | 19 19 | def f(): -F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used +F841 [*] Local variable `foo` is assigned to but never used + --> F841_0.py:20:5 | 19 | def f(): 20 | foo = (1, 2) - | ^^^ F841 + | ^^^ 21 | (a, b) = (1, 2) | - = help: Remove assignment to unused variable `foo` +help: Remove assignment to unused variable `foo` ℹ Unsafe fix 17 17 | @@ -57,16 +60,17 @@ F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used 22 21 | 23 22 | bar = (1, 2) -F841_0.py:21:6: F841 [*] Local variable `a` is assigned to but never used +F841 [*] Local variable `a` is assigned to but never used + --> F841_0.py:21:6 | 19 | def f(): 20 | foo = (1, 2) 21 | (a, b) = (1, 2) - | ^ F841 + | ^ 22 | 23 | bar = (1, 2) | - = help: Remove assignment to unused variable `a` +help: Remove assignment to unused variable `a` ℹ Unsafe fix 18 18 | @@ -78,16 +82,17 @@ F841_0.py:21:6: F841 [*] Local variable `a` is assigned to but never used 23 23 | bar = (1, 2) 24 24 | (c, d) = bar -F841_0.py:21:9: F841 [*] Local variable `b` is assigned to but never used +F841 [*] Local variable `b` is assigned to but never used + --> F841_0.py:21:9 | 19 | def f(): 20 | foo = (1, 2) 21 | (a, b) = (1, 2) - | ^ F841 + | ^ 22 | 23 | bar = (1, 2) | - = help: Remove assignment to unused variable `b` +help: Remove assignment to unused variable `b` ℹ Unsafe fix 18 18 | @@ -99,14 +104,15 @@ F841_0.py:21:9: F841 [*] Local variable `b` is assigned to but never used 23 23 | bar = (1, 2) 24 24 | (c, d) = bar -F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used +F841 [*] Local variable `baz` is assigned to but never used + --> F841_0.py:26:14 | 24 | (c, d) = bar 25 | 26 | (x, y) = baz = bar - | ^^^ F841 + | ^^^ | - = help: Remove assignment to unused variable `baz` +help: Remove assignment to unused variable `baz` ℹ Unsafe fix 23 23 | bar = (1, 2) @@ -118,16 +124,17 @@ F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used 28 28 | 29 29 | def f(): -F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used +F841 [*] Local variable `b` is assigned to but never used + --> F841_0.py:51:9 | 49 | def c(): 50 | # F841 51 | b = 1 - | ^ F841 + | ^ 52 | 53 | def d(): | - = help: Remove assignment to unused variable `b` +help: Remove assignment to unused variable `b` ℹ Unsafe fix 48 48 | @@ -139,14 +146,15 @@ F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used 53 53 | def d(): 54 54 | nonlocal b -F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used +F841 [*] Local variable `my_file` is assigned to but never used + --> F841_0.py:79:26 | 78 | def f(): 79 | with open("file") as my_file, open("") as ((this, that)): - | ^^^^^^^ F841 + | ^^^^^^^ 80 | print("hello") | - = help: Remove assignment to unused variable `my_file` +help: Remove assignment to unused variable `my_file` ℹ Unsafe fix 76 76 | @@ -158,16 +166,17 @@ F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used 81 81 | 82 82 | -F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used +F841 [*] Local variable `my_file` is assigned to but never used + --> F841_0.py:85:25 | 83 | def f(): 84 | with ( 85 | open("file") as my_file, - | ^^^^^^^ F841 + | ^^^^^^^ 86 | open("") as ((this, that)), 87 | ): | - = help: Remove assignment to unused variable `my_file` +help: Remove assignment to unused variable `my_file` ℹ Unsafe fix 82 82 | @@ -179,16 +188,17 @@ F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used 87 87 | ): 88 88 | print("hello") -F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used +F841 [*] Local variable `msg3` is assigned to but never used + --> F841_0.py:102:5 | 100 | msg1 = "Hello, world!" 101 | msg2 = "Hello, world!" 102 | msg3 = "Hello, world!" - | ^^^^ F841 + | ^^^^ 103 | match x: 104 | case 1: | - = help: Remove assignment to unused variable `msg3` +help: Remove assignment to unused variable `msg3` ℹ Unsafe fix 99 99 | def f(x: int): @@ -199,16 +209,17 @@ F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used 104 103 | case 1: 105 104 | print(msg1) -F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used +F841 [*] Local variable `Baz` is assigned to but never used + --> F841_0.py:115:5 | 113 | Foo = enum.Enum("Foo", "A B") 114 | Bar = enum.Enum("Bar", "A B") 115 | Baz = enum.Enum("Baz", "A B") - | ^^^ F841 + | ^^^ 116 | 117 | match x: | - = help: Remove assignment to unused variable `Baz` +help: Remove assignment to unused variable `Baz` ℹ Unsafe fix 112 112 | @@ -220,21 +231,23 @@ F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used 117 117 | match x: 118 118 | case (Foo.A): -F841_0.py:122:14: F841 Local variable `y` is assigned to but never used +F841 Local variable `y` is assigned to but never used + --> F841_0.py:122:14 | 120 | case [Bar.A, *_]: 121 | print("A") 122 | case y: - | ^ F841 + | ^ 123 | pass | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` -F841_0.py:127:21: F841 Local variable `value` is assigned to but never used +F841 Local variable `value` is assigned to but never used + --> F841_0.py:127:21 | 126 | def f(): 127 | if any((key := (value := x)) for x in ["ok"]): - | ^^^^^ F841 + | ^^^^^ 128 | print(key) | - = help: Remove assignment to unused variable `value` +help: Remove assignment to unused variable `value` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap index e82e2bb4e0..f1b8ea02c3 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F841_1.py:6:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_1.py:6:5 | 5 | def f(): 6 | x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 3 3 | @@ -20,13 +20,14 @@ F841_1.py:6:5: F841 [*] Local variable `x` is assigned to but never used 8 8 | 9 9 | def f(): -F841_1.py:6:8: F841 [*] Local variable `y` is assigned to but never used +F841 [*] Local variable `y` is assigned to but never used + --> F841_1.py:6:8 | 5 | def f(): 6 | x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` ℹ Unsafe fix 3 3 | @@ -38,13 +39,14 @@ F841_1.py:6:8: F841 [*] Local variable `y` is assigned to but never used 8 8 | 9 9 | def f(): -F841_1.py:16:14: F841 [*] Local variable `coords` is assigned to but never used +F841 [*] Local variable `coords` is assigned to but never used + --> F841_1.py:16:14 | 15 | def f(): 16 | (x, y) = coords = 1, 2 - | ^^^^^^ F841 + | ^^^^^^ | - = help: Remove assignment to unused variable `coords` +help: Remove assignment to unused variable `coords` ℹ Unsafe fix 13 13 | @@ -56,13 +58,14 @@ F841_1.py:16:14: F841 [*] Local variable `coords` is assigned to but never used 18 18 | 19 19 | def f(): -F841_1.py:20:5: F841 [*] Local variable `coords` is assigned to but never used +F841 [*] Local variable `coords` is assigned to but never used + --> F841_1.py:20:5 | 19 | def f(): 20 | coords = (x, y) = 1, 2 - | ^^^^^^ F841 + | ^^^^^^ | - = help: Remove assignment to unused variable `coords` +help: Remove assignment to unused variable `coords` ℹ Unsafe fix 17 17 | @@ -74,13 +77,14 @@ F841_1.py:20:5: F841 [*] Local variable `coords` is assigned to but never used 22 22 | 23 23 | def f(): -F841_1.py:24:6: F841 [*] Local variable `a` is assigned to but never used +F841 [*] Local variable `a` is assigned to but never used + --> F841_1.py:24:6 | 23 | def f(): 24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `a` +help: Remove assignment to unused variable `a` ℹ Unsafe fix 21 21 | @@ -89,13 +93,14 @@ F841_1.py:24:6: F841 [*] Local variable `a` is assigned to but never used 24 |- (a, b) = (x, y) = 1, 2 # this triggers F841 on everything 24 |+ (_a, b) = (x, y) = 1, 2 # this triggers F841 on everything -F841_1.py:24:9: F841 [*] Local variable `b` is assigned to but never used +F841 [*] Local variable `b` is assigned to but never used + --> F841_1.py:24:9 | 23 | def f(): 24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `b` +help: Remove assignment to unused variable `b` ℹ Unsafe fix 21 21 | @@ -104,13 +109,14 @@ F841_1.py:24:9: F841 [*] Local variable `b` is assigned to but never used 24 |- (a, b) = (x, y) = 1, 2 # this triggers F841 on everything 24 |+ (a, _b) = (x, y) = 1, 2 # this triggers F841 on everything -F841_1.py:24:15: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_1.py:24:15 | 23 | def f(): 24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 21 21 | @@ -119,13 +125,14 @@ F841_1.py:24:15: F841 [*] Local variable `x` is assigned to but never used 24 |- (a, b) = (x, y) = 1, 2 # this triggers F841 on everything 24 |+ (a, b) = (_x, y) = 1, 2 # this triggers F841 on everything -F841_1.py:24:18: F841 [*] Local variable `y` is assigned to but never used +F841 [*] Local variable `y` is assigned to but never used + --> F841_1.py:24:18 | 23 | def f(): 24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` ℹ Unsafe fix 21 21 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap index c3250b8451..9ddc03a282 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F841_3.py:5:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_3.py:5:5 | 4 | def f(): 5 | x = 1 - | ^ F841 + | ^ 6 | y = 2 | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 2 2 | @@ -19,16 +20,17 @@ F841_3.py:5:5: F841 [*] Local variable `x` is assigned to but never used 7 6 | 8 7 | z = 3 -F841_3.py:6:5: F841 [*] Local variable `y` is assigned to but never used +F841 [*] Local variable `y` is assigned to but never used + --> F841_3.py:6:5 | 4 | def f(): 5 | x = 1 6 | y = 2 - | ^ F841 + | ^ 7 | 8 | z = 3 | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` ℹ Unsafe fix 3 3 | @@ -39,14 +41,15 @@ F841_3.py:6:5: F841 [*] Local variable `y` is assigned to but never used 8 7 | z = 3 9 8 | print(z) -F841_3.py:13:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_3.py:13:5 | 12 | def f(): 13 | x: int = 1 - | ^ F841 + | ^ 14 | y: int = 2 | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 10 10 | @@ -57,16 +60,17 @@ F841_3.py:13:5: F841 [*] Local variable `x` is assigned to but never used 15 14 | 16 15 | z: int = 3 -F841_3.py:14:5: F841 [*] Local variable `y` is assigned to but never used +F841 [*] Local variable `y` is assigned to but never used + --> F841_3.py:14:5 | 12 | def f(): 13 | x: int = 1 14 | y: int = 2 - | ^ F841 + | ^ 15 | 16 | z: int = 3 | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` ℹ Unsafe fix 11 11 | @@ -77,14 +81,15 @@ F841_3.py:14:5: F841 [*] Local variable `y` is assigned to but never used 16 15 | z: int = 3 17 16 | print(z) -F841_3.py:21:19: F841 [*] Local variable `x1` is assigned to but never used +F841 [*] Local variable `x1` is assigned to but never used + --> F841_3.py:21:19 | 20 | def f(): 21 | with foo() as x1: - | ^^ F841 + | ^^ 22 | pass | - = help: Remove assignment to unused variable `x1` +help: Remove assignment to unused variable `x1` ℹ Unsafe fix 18 18 | @@ -96,15 +101,16 @@ F841_3.py:21:19: F841 [*] Local variable `x1` is assigned to but never used 23 23 | 24 24 | with foo() as (x2, y2): -F841_3.py:27:20: F841 [*] Local variable `x3` is assigned to but never used +F841 [*] Local variable `x3` is assigned to but never used + --> F841_3.py:27:20 | 25 | pass 26 | 27 | with (foo() as x3, foo() as y3, foo() as z3): - | ^^ F841 + | ^^ 28 | pass | - = help: Remove assignment to unused variable `x3` +help: Remove assignment to unused variable `x3` ℹ Unsafe fix 24 24 | with foo() as (x2, y2): @@ -116,15 +122,16 @@ F841_3.py:27:20: F841 [*] Local variable `x3` is assigned to but never used 29 29 | 30 30 | -F841_3.py:27:33: F841 [*] Local variable `y3` is assigned to but never used +F841 [*] Local variable `y3` is assigned to but never used + --> F841_3.py:27:33 | 25 | pass 26 | 27 | with (foo() as x3, foo() as y3, foo() as z3): - | ^^ F841 + | ^^ 28 | pass | - = help: Remove assignment to unused variable `y3` +help: Remove assignment to unused variable `y3` ℹ Unsafe fix 24 24 | with foo() as (x2, y2): @@ -136,15 +143,16 @@ F841_3.py:27:33: F841 [*] Local variable `y3` is assigned to but never used 29 29 | 30 30 | -F841_3.py:27:46: F841 [*] Local variable `z3` is assigned to but never used +F841 [*] Local variable `z3` is assigned to but never used + --> F841_3.py:27:46 | 25 | pass 26 | 27 | with (foo() as x3, foo() as y3, foo() as z3): - | ^^ F841 + | ^^ 28 | pass | - = help: Remove assignment to unused variable `z3` +help: Remove assignment to unused variable `z3` ℹ Unsafe fix 24 24 | with foo() as (x2, y2): @@ -156,15 +164,16 @@ F841_3.py:27:46: F841 [*] Local variable `z3` is assigned to but never used 29 29 | 30 30 | -F841_3.py:32:6: F841 [*] Local variable `x1` is assigned to but never used +F841 [*] Local variable `x1` is assigned to but never used + --> F841_3.py:32:6 | 31 | def f(): 32 | (x1, y1) = (1, 2) - | ^^ F841 + | ^^ 33 | (x2, y2) = coords2 = (1, 2) 34 | coords3 = (x3, y3) = (1, 2) | - = help: Remove assignment to unused variable `x1` +help: Remove assignment to unused variable `x1` ℹ Unsafe fix 29 29 | @@ -176,15 +185,16 @@ F841_3.py:32:6: F841 [*] Local variable `x1` is assigned to but never used 34 34 | coords3 = (x3, y3) = (1, 2) 35 35 | -F841_3.py:32:10: F841 [*] Local variable `y1` is assigned to but never used +F841 [*] Local variable `y1` is assigned to but never used + --> F841_3.py:32:10 | 31 | def f(): 32 | (x1, y1) = (1, 2) - | ^^ F841 + | ^^ 33 | (x2, y2) = coords2 = (1, 2) 34 | coords3 = (x3, y3) = (1, 2) | - = help: Remove assignment to unused variable `y1` +help: Remove assignment to unused variable `y1` ℹ Unsafe fix 29 29 | @@ -196,15 +206,16 @@ F841_3.py:32:10: F841 [*] Local variable `y1` is assigned to but never used 34 34 | coords3 = (x3, y3) = (1, 2) 35 35 | -F841_3.py:33:16: F841 [*] Local variable `coords2` is assigned to but never used +F841 [*] Local variable `coords2` is assigned to but never used + --> F841_3.py:33:16 | 31 | def f(): 32 | (x1, y1) = (1, 2) 33 | (x2, y2) = coords2 = (1, 2) - | ^^^^^^^ F841 + | ^^^^^^^ 34 | coords3 = (x3, y3) = (1, 2) | - = help: Remove assignment to unused variable `coords2` +help: Remove assignment to unused variable `coords2` ℹ Unsafe fix 30 30 | @@ -216,14 +227,15 @@ F841_3.py:33:16: F841 [*] Local variable `coords2` is assigned to but never used 35 35 | 36 36 | -F841_3.py:34:5: F841 [*] Local variable `coords3` is assigned to but never used +F841 [*] Local variable `coords3` is assigned to but never used + --> F841_3.py:34:5 | 32 | (x1, y1) = (1, 2) 33 | (x2, y2) = coords2 = (1, 2) 34 | coords3 = (x3, y3) = (1, 2) - | ^^^^^^^ F841 + | ^^^^^^^ | - = help: Remove assignment to unused variable `coords3` +help: Remove assignment to unused variable `coords3` ℹ Unsafe fix 31 31 | def f(): @@ -235,15 +247,16 @@ F841_3.py:34:5: F841 [*] Local variable `coords3` is assigned to but never used 36 36 | 37 37 | def f(): -F841_3.py:40:26: F841 [*] Local variable `x1` is assigned to but never used +F841 [*] Local variable `x1` is assigned to but never used + --> F841_3.py:40:26 | 38 | try: 39 | 1 / 0 40 | except ValueError as x1: - | ^^ F841 + | ^^ 41 | pass | - = help: Remove assignment to unused variable `x1` +help: Remove assignment to unused variable `x1` ℹ Safe fix 37 37 | def f(): @@ -255,15 +268,16 @@ F841_3.py:40:26: F841 [*] Local variable `x1` is assigned to but never used 42 42 | 43 43 | try: -F841_3.py:45:47: F841 [*] Local variable `x2` is assigned to but never used +F841 [*] Local variable `x2` is assigned to but never used + --> F841_3.py:45:47 | 43 | try: 44 | 1 / 0 45 | except (ValueError, ZeroDivisionError) as x2: - | ^^ F841 + | ^^ 46 | pass | - = help: Remove assignment to unused variable `x2` +help: Remove assignment to unused variable `x2` ℹ Safe fix 42 42 | @@ -275,15 +289,16 @@ F841_3.py:45:47: F841 [*] Local variable `x2` is assigned to but never used 47 47 | 48 48 | -F841_3.py:50:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_3.py:50:5 | 49 | def f(a, b): 50 | x = ( - | ^ F841 + | ^ 51 | a() 52 | if a is not None | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 47 47 | @@ -295,15 +310,16 @@ F841_3.py:50:5: F841 [*] Local variable `x` is assigned to but never used 52 52 | if a is not None 53 53 | else b -F841_3.py:56:5: F841 [*] Local variable `y` is assigned to but never used +F841 [*] Local variable `y` is assigned to but never used + --> F841_3.py:56:5 | 54 | ) 55 | 56 | y = \ - | ^ F841 + | ^ 57 | a() if a is not None else b | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` ℹ Unsafe fix 53 53 | else b @@ -316,15 +332,16 @@ F841_3.py:56:5: F841 [*] Local variable `y` is assigned to but never used 59 58 | 60 59 | def f(a, b): -F841_3.py:61:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_3.py:61:5 | 60 | def f(a, b): 61 | x = ( - | ^ F841 + | ^ 62 | a 63 | if a is not None | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 58 58 | @@ -339,15 +356,16 @@ F841_3.py:61:5: F841 [*] Local variable `x` is assigned to but never used 67 62 | y = \ 68 63 | a if a is not None else b -F841_3.py:67:5: F841 [*] Local variable `y` is assigned to but never used +F841 [*] Local variable `y` is assigned to but never used + --> F841_3.py:67:5 | 65 | ) 66 | 67 | y = \ - | ^ F841 + | ^ 68 | a if a is not None else b | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` ℹ Unsafe fix 64 64 | else b @@ -359,14 +377,15 @@ F841_3.py:67:5: F841 [*] Local variable `y` is assigned to but never used 70 68 | 71 69 | def f(): -F841_3.py:72:24: F841 [*] Local variable `cm` is assigned to but never used +F841 [*] Local variable `cm` is assigned to but never used + --> F841_3.py:72:24 | 71 | def f(): 72 | with Nested(m) as (cm): - | ^^ F841 + | ^^ 73 | pass | - = help: Remove assignment to unused variable `cm` +help: Remove assignment to unused variable `cm` ℹ Unsafe fix 69 69 | @@ -378,14 +397,15 @@ F841_3.py:72:24: F841 [*] Local variable `cm` is assigned to but never used 74 74 | 75 75 | -F841_3.py:77:25: F841 [*] Local variable `cm` is assigned to but never used +F841 [*] Local variable `cm` is assigned to but never used + --> F841_3.py:77:25 | 76 | def f(): 77 | with (Nested(m) as (cm),): - | ^^ F841 + | ^^ 78 | pass | - = help: Remove assignment to unused variable `cm` +help: Remove assignment to unused variable `cm` ℹ Unsafe fix 74 74 | @@ -397,14 +417,15 @@ F841_3.py:77:25: F841 [*] Local variable `cm` is assigned to but never used 79 79 | 80 80 | -F841_3.py:87:26: F841 [*] Local variable `cm` is assigned to but never used +F841 [*] Local variable `cm` is assigned to but never used + --> F841_3.py:87:26 | 86 | def f(): 87 | with (Nested(m)) as (cm): - | ^^ F841 + | ^^ 88 | pass | - = help: Remove assignment to unused variable `cm` +help: Remove assignment to unused variable `cm` ℹ Unsafe fix 84 84 | @@ -416,15 +437,16 @@ F841_3.py:87:26: F841 [*] Local variable `cm` is assigned to but never used 89 89 | 90 90 | -F841_3.py:92:5: F841 [*] Local variable `toplevel` is assigned to but never used +F841 [*] Local variable `toplevel` is assigned to but never used + --> F841_3.py:92:5 | 91 | def f(): 92 | toplevel = tt = lexer.get_token() - | ^^^^^^^^ F841 + | ^^^^^^^^ 93 | if not tt: 94 | break | - = help: Remove assignment to unused variable `toplevel` +help: Remove assignment to unused variable `toplevel` ℹ Unsafe fix 89 89 | @@ -436,13 +458,14 @@ F841_3.py:92:5: F841 [*] Local variable `toplevel` is assigned to but never used 94 94 | break 95 95 | -F841_3.py:98:5: F841 [*] Local variable `toplevel` is assigned to but never used +F841 [*] Local variable `toplevel` is assigned to but never used + --> F841_3.py:98:5 | 97 | def f(): 98 | toplevel = tt = lexer.get_token() - | ^^^^^^^^ F841 + | ^^^^^^^^ | - = help: Remove assignment to unused variable `toplevel` +help: Remove assignment to unused variable `toplevel` ℹ Unsafe fix 95 95 | @@ -454,13 +477,14 @@ F841_3.py:98:5: F841 [*] Local variable `toplevel` is assigned to but never used 100 100 | 101 101 | def f(): -F841_3.py:98:16: F841 [*] Local variable `tt` is assigned to but never used +F841 [*] Local variable `tt` is assigned to but never used + --> F841_3.py:98:16 | 97 | def f(): 98 | toplevel = tt = lexer.get_token() - | ^^ F841 + | ^^ | - = help: Remove assignment to unused variable `tt` +help: Remove assignment to unused variable `tt` ℹ Unsafe fix 95 95 | @@ -472,13 +496,14 @@ F841_3.py:98:16: F841 [*] Local variable `tt` is assigned to but never used 100 100 | 101 101 | def f(): -F841_3.py:102:5: F841 [*] Local variable `toplevel` is assigned to but never used +F841 [*] Local variable `toplevel` is assigned to but never used + --> F841_3.py:102:5 | 101 | def f(): 102 | toplevel = (a, b) = lexer.get_token() - | ^^^^^^^^ F841 + | ^^^^^^^^ | - = help: Remove assignment to unused variable `toplevel` +help: Remove assignment to unused variable `toplevel` ℹ Unsafe fix 99 99 | @@ -490,13 +515,14 @@ F841_3.py:102:5: F841 [*] Local variable `toplevel` is assigned to but never use 104 104 | 105 105 | def f(): -F841_3.py:106:14: F841 [*] Local variable `toplevel` is assigned to but never used +F841 [*] Local variable `toplevel` is assigned to but never used + --> F841_3.py:106:14 | 105 | def f(): 106 | (a, b) = toplevel = lexer.get_token() - | ^^^^^^^^ F841 + | ^^^^^^^^ | - = help: Remove assignment to unused variable `toplevel` +help: Remove assignment to unused variable `toplevel` ℹ Unsafe fix 103 103 | @@ -508,13 +534,14 @@ F841_3.py:106:14: F841 [*] Local variable `toplevel` is assigned to but never us 108 108 | 109 109 | def f(): -F841_3.py:110:5: F841 [*] Local variable `toplevel` is assigned to but never used +F841 [*] Local variable `toplevel` is assigned to but never used + --> F841_3.py:110:5 | 109 | def f(): 110 | toplevel = tt = 1 - | ^^^^^^^^ F841 + | ^^^^^^^^ | - = help: Remove assignment to unused variable `toplevel` +help: Remove assignment to unused variable `toplevel` ℹ Unsafe fix 107 107 | @@ -526,13 +553,14 @@ F841_3.py:110:5: F841 [*] Local variable `toplevel` is assigned to but never use 112 112 | 113 113 | def f(provided: int) -> int: -F841_3.py:110:16: F841 [*] Local variable `tt` is assigned to but never used +F841 [*] Local variable `tt` is assigned to but never used + --> F841_3.py:110:16 | 109 | def f(): 110 | toplevel = tt = 1 - | ^^ F841 + | ^^ | - = help: Remove assignment to unused variable `tt` +help: Remove assignment to unused variable `tt` ℹ Unsafe fix 107 107 | @@ -544,75 +572,82 @@ F841_3.py:110:16: F841 [*] Local variable `tt` is assigned to but never used 112 112 | 113 113 | def f(provided: int) -> int: -F841_3.py:115:19: F841 Local variable `x` is assigned to but never used +F841 Local variable `x` is assigned to but never used + --> F841_3.py:115:19 | 113 | def f(provided: int) -> int: 114 | match provided: 115 | case [_, *x]: - | ^ F841 + | ^ 116 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` -F841_3.py:121:14: F841 Local variable `x` is assigned to but never used +F841 Local variable `x` is assigned to but never used + --> F841_3.py:121:14 | 119 | def f(provided: int) -> int: 120 | match provided: 121 | case x: - | ^ F841 + | ^ 122 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` -F841_3.py:127:18: F841 Local variable `bar` is assigned to but never used +F841 Local variable `bar` is assigned to but never used + --> F841_3.py:127:18 | 125 | def f(provided: int) -> int: 126 | match provided: 127 | case Foo(bar) as x: - | ^^^ F841 + | ^^^ 128 | pass | - = help: Remove assignment to unused variable `bar` +help: Remove assignment to unused variable `bar` -F841_3.py:127:26: F841 Local variable `x` is assigned to but never used +F841 Local variable `x` is assigned to but never used + --> F841_3.py:127:26 | 125 | def f(provided: int) -> int: 126 | match provided: 127 | case Foo(bar) as x: - | ^ F841 + | ^ 128 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` -F841_3.py:133:27: F841 Local variable `x` is assigned to but never used +F841 Local variable `x` is assigned to but never used + --> F841_3.py:133:27 | 131 | def f(provided: int) -> int: 132 | match provided: 133 | case {"foo": 0, **x}: - | ^ F841 + | ^ 134 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` -F841_3.py:139:17: F841 Local variable `x` is assigned to but never used +F841 Local variable `x` is assigned to but never used + --> F841_3.py:139:17 | 137 | def f(provided: int) -> int: 138 | match provided: 139 | case {**x}: - | ^ F841 + | ^ 140 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` -F841_3.py:155:17: F841 [*] Local variable `e` is assigned to but never used +F841 [*] Local variable `e` is assigned to but never used + --> F841_3.py:155:17 | 153 | try: 154 | print("hello") 155 | except A as e : - | ^ F841 + | ^ 156 | print("oh no!") | - = help: Remove assignment to unused variable `e` +help: Remove assignment to unused variable `e` ℹ Safe fix 152 152 | def f() -> None: @@ -624,14 +659,15 @@ F841_3.py:155:17: F841 [*] Local variable `e` is assigned to but never used 157 157 | 158 158 | -F841_3.py:160:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_3.py:160:5 | 159 | def f(): 160 | x = 1 - | ^ F841 + | ^ 161 | y = 2 | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 157 157 | @@ -642,14 +678,15 @@ F841_3.py:160:5: F841 [*] Local variable `x` is assigned to but never used 162 161 | 163 162 | -F841_3.py:161:5: F841 [*] Local variable `y` is assigned to but never used +F841 [*] Local variable `y` is assigned to but never used + --> F841_3.py:161:5 | 159 | def f(): 160 | x = 1 161 | y = 2 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` ℹ Unsafe fix 158 158 | @@ -660,15 +697,16 @@ F841_3.py:161:5: F841 [*] Local variable `y` is assigned to but never used 163 162 | 164 163 | def f(): -F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_3.py:165:5 | 164 | def f(): 165 | x = 1 - | ^ F841 + | ^ 166 | 167 | y = 2 | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 162 162 | @@ -679,14 +717,15 @@ F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used 167 166 | y = 2 168 167 | -F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used +F841 [*] Local variable `y` is assigned to but never used + --> F841_3.py:167:5 | 165 | x = 1 166 | 167 | y = 2 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` ℹ Unsafe fix 164 164 | def f(): @@ -697,14 +736,15 @@ F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used 169 168 | 170 169 | def f(): -F841_3.py:173:6: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> F841_3.py:173:6 | 171 | (x) = foo() 172 | ((x)) = foo() 173 | (x) = (y.z) = foo() - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 170 170 | def f(): diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F842_F842.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F842_F842.py.snap index 5f6e6dbd9d..49b28284d8 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F842_F842.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F842_F842.py.snap @@ -1,19 +1,20 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F842.py:2:5: F842 Local variable `name` is annotated but never used +F842 Local variable `name` is annotated but never used + --> F842.py:2:5 | 1 | def f(): 2 | name: str - | ^^^^ F842 + | ^^^^ 3 | age: int | -F842.py:3:5: F842 Local variable `age` is annotated but never used +F842 Local variable `age` is annotated but never used + --> F842.py:3:5 | 1 | def f(): 2 | name: str 3 | age: int - | ^^^ F842 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap index 3e25ce03fa..689aab5390 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F901.py:2:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedError` +F901 [*] `raise NotImplemented` should be `raise NotImplementedError` + --> F901.py:2:11 | 1 | def f() -> None: 2 | raise NotImplemented() - | ^^^^^^^^^^^^^^ F901 + | ^^^^^^^^^^^^^^ | - = help: Use `raise NotImplementedError` +help: Use `raise NotImplementedError` ℹ Safe fix 1 1 | def f() -> None: @@ -18,13 +18,14 @@ F901.py:2:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedErr 4 4 | 5 5 | def g() -> None: -F901.py:6:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedError` +F901 [*] `raise NotImplemented` should be `raise NotImplementedError` + --> F901.py:6:11 | 5 | def g() -> None: 6 | raise NotImplemented - | ^^^^^^^^^^^^^^ F901 + | ^^^^^^^^^^^^^^ | - = help: Use `raise NotImplementedError` +help: Use `raise NotImplementedError` ℹ Safe fix 3 3 | @@ -36,14 +37,15 @@ F901.py:6:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedErr 8 8 | 9 9 | def h() -> None: -F901.py:11:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedError` +F901 [*] `raise NotImplemented` should be `raise NotImplementedError` + --> F901.py:11:11 | 9 | def h() -> None: 10 | NotImplementedError = "foo" 11 | raise NotImplemented - | ^^^^^^^^^^^^^^ F901 + | ^^^^^^^^^^^^^^ | - = help: Use `raise NotImplementedError` +help: Use `raise NotImplementedError` ℹ Safe fix 1 |+import builtins diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__augmented_assignment_after_del.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__augmented_assignment_after_del.snap index 18501498a2..bebb611006 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__augmented_assignment_after_del.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__augmented_assignment_after_del.snap @@ -1,20 +1,21 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:10:5: F821 Undefined name `x` +F821 Undefined name `x` + --> :10:5 | 8 | # entirely after the `del` statement. However, it should be an F821 9 | # error, because the name is defined in the scope, but unbound. 10 | x += 1 - | ^ F821 + | ^ | -:10:5: F841 Local variable `x` is assigned to but never used +F841 Local variable `x` is assigned to but never used + --> :10:5 | 8 | # entirely after the `del` statement. However, it should be an F821 9 | # error, because the name is defined in the scope, but unbound. 10 | x += 1 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_builtins.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_builtins.snap index cf1be266bc..3f863c9e60 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_builtins.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_builtins.snap @@ -1,9 +1,9 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -builtins.py:1:1: F821 Undefined name `_` +F821 Undefined name `_` + --> builtins.py:1:1 | 1 | _("Translations") - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_typing_modules.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_typing_modules.snap index ff0ffaecb3..e4c3561b87 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_typing_modules.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_typing_modules.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -typing_modules.py:6:36: F821 Undefined name `db` +F821 Undefined name `db` + --> typing_modules.py:6:36 | 6 | X = Union[Literal[False], Literal["db"]] - | ^^ F821 + | ^^ 7 | y = Optional["Class"] | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap index 9d08e6b818..772f183bbe 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -:5:12: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> :5:12 | 4 | def f(): 5 | import os - | ^^ F401 + | ^^ 6 | 7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused | - = help: Remove unused import: `os` +help: Remove unused import: `os` ℹ Safe fix 2 2 | import os diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap index f2a3fb29b2..e7ed86bd46 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -:2:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> :2:8 | 2 | import os - | ^^ F401 + | ^^ 3 | 4 | def f(): | - = help: Remove unused import: `os` +help: Remove unused import: `os` ℹ Safe fix 1 1 | @@ -17,15 +18,16 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 4 3 | def f(): 5 4 | import os -:5:12: F811 [*] Redefinition of unused `os` from line 2 +F811 [*] Redefinition of unused `os` from line 2 + --> :5:12 | 4 | def f(): 5 | import os - | ^^ F811 + | ^^ 6 | 7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused | - = help: Remove definition: `os` +help: Remove definition: `os` ℹ Safe fix 2 2 | import os diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap index 38f194e157..7076d53708 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -:2:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> :2:8 | 2 | import os - | ^^ F401 + | ^^ 3 | 4 | def f(): | - = help: Remove unused import: `os` +help: Remove unused import: `os` ℹ Safe fix 1 1 | @@ -17,11 +18,12 @@ source: crates/ruff_linter/src/rules/pyflakes/mod.rs 4 3 | def f(): 5 4 | os = 1 -:5:5: F811 Redefinition of unused `os` from line 2 +F811 Redefinition of unused `os` from line 2 + --> :5:5 | 4 | def f(): 5 | os = 1 - | ^^ F811 + | ^^ 6 | print(os) | - = help: Remove definition: `os` +help: Remove definition: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap index 2177b874a1..e96cdc07f7 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -:4:12: F811 [*] Redefinition of unused `os` from line 3 +F811 [*] Redefinition of unused `os` from line 3 + --> :4:12 | 2 | def f(): 3 | import os 4 | import os - | ^^ F811 + | ^^ 5 | 6 | # Despite this `del`, `import os` should still be flagged as shadowing an unused | - = help: Remove definition: `os` +help: Remove definition: `os` ℹ Safe fix 1 1 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__double_del.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__double_del.snap index 4f3cf22aa7..51dc063477 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__double_del.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__double_del.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:5:9: F821 Undefined name `x` +F821 Undefined name `x` + --> :5:9 | 3 | x = 1 4 | del x 5 | del x - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_typing_modules.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_typing_modules.snap index 585455e718..3fcb7752c8 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_typing_modules.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_typing_modules.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -typing_modules.py:7:15: F821 Undefined name `Class` +F821 Undefined name `Class` + --> typing_modules.py:7:15 | 6 | X = Union[Literal[False], Literal["db"]] 7 | y = Optional["Class"] - | ^^^^^ F821 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_allowed_unused_imports_option.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_allowed_unused_imports_option.snap index 3d331d7884..8a0e8d0ebb 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_allowed_unused_imports_option.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_allowed_unused_imports_option.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -F401_31.py:12:33: F401 [*] `hvplot.pandas_alias.scatter_matrix` imported but unused +F401 [*] `hvplot.pandas_alias.scatter_matrix` imported but unused + --> F401_31.py:12:33 | 11 | # Errors 12 | from hvplot.pandas_alias import scatter_matrix - | ^^^^^^^^^^^^^^ F401 + | ^^^^^^^^^^^^^^ | - = help: Remove unused import: `hvplot.pandas_alias.scatter_matrix` +help: Remove unused import: `hvplot.pandas_alias.scatter_matrix` ℹ Safe fix 9 9 | from hvplot.pandas.plots import scatter_matrix diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_dunder_all.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_dunder_all.snap index b20246f56c..a51f6d418d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_dunder_all.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_dunder_all.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:2:8: F401 [*] `submodule.a` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `submodule.a` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:2:8 | 2 | import submodule.a - | ^^^^^^^^^^^ F401 + | ^^^^^^^^^^^ 3 | __all__ = ['FOO'] 4 | FOO = 42 | - = help: Add `submodule` to __all__ +help: Add `submodule` to __all__ ℹ Safe fix 1 1 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_no_dunder_all.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_no_dunder_all.snap index 55922fe49d..1c463aa7e2 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_no_dunder_all.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f401_preview_first_party_submodule_no_dunder_all.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:1:8: F401 `submodule.a` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `submodule.a` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:1:8 | 1 | import submodule.a - | ^^^^^^^^^^^ F401 + | ^^^^^^^^^^^ | - = help: Use an explicit re-export: `import submodule as submodule; import submodule.a` +help: Use an explicit re-export: `import submodule as submodule; import submodule.a` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f821_with_builtin_added_on_new_py_version_but_old_target_version_specified.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f821_with_builtin_added_on_new_py_version_but_old_target_version_specified.snap index 3fce3fa99e..072e06e5ef 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f821_with_builtin_added_on_new_py_version_but_old_target_version_specified.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f821_with_builtin_added_on_new_py_version_but_old_target_version_specified.snap @@ -1,9 +1,9 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:1:1: F821 Undefined name `PythonFinalizationError`. Consider specifying `requires-python = ">= 3.13"` or `tool.ruff.target-version = "py313"` in your `pyproject.toml` file. +F821 Undefined name `PythonFinalizationError`. Consider specifying `requires-python = ">= 3.13"` or `tool.ruff.target-version = "py313"` in your `pyproject.toml` file. + --> :1:1 | 1 | PythonFinalizationError - | ^^^^^^^^^^^^^^^^^^^^^^^ F821 + | ^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap index c87dbb04b6..747f7ba421 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used +F841 [*] Local variable `e` is assigned to but never used + --> F841_0.py:3:22 | 1 | try: 2 | 1 / 0 3 | except ValueError as e: - | ^ F841 + | ^ 4 | pass | - = help: Remove assignment to unused variable `e` +help: Remove assignment to unused variable `e` ℹ Safe fix 1 1 | try: @@ -20,14 +21,15 @@ F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used 5 5 | 6 6 | -F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used +F841 [*] Local variable `foo` is assigned to but never used + --> F841_0.py:20:5 | 19 | def f(): 20 | foo = (1, 2) - | ^^^ F841 + | ^^^ 21 | (a, b) = (1, 2) | - = help: Remove assignment to unused variable `foo` +help: Remove assignment to unused variable `foo` ℹ Unsafe fix 17 17 | @@ -38,36 +40,39 @@ F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used 22 21 | 23 22 | bar = (1, 2) -F841_0.py:21:6: F841 Local variable `a` is assigned to but never used +F841 Local variable `a` is assigned to but never used + --> F841_0.py:21:6 | 19 | def f(): 20 | foo = (1, 2) 21 | (a, b) = (1, 2) - | ^ F841 + | ^ 22 | 23 | bar = (1, 2) | - = help: Remove assignment to unused variable `a` +help: Remove assignment to unused variable `a` -F841_0.py:21:9: F841 Local variable `b` is assigned to but never used +F841 Local variable `b` is assigned to but never used + --> F841_0.py:21:9 | 19 | def f(): 20 | foo = (1, 2) 21 | (a, b) = (1, 2) - | ^ F841 + | ^ 22 | 23 | bar = (1, 2) | - = help: Remove assignment to unused variable `b` +help: Remove assignment to unused variable `b` -F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used +F841 [*] Local variable `baz` is assigned to but never used + --> F841_0.py:26:14 | 24 | (c, d) = bar 25 | 26 | (x, y) = baz = bar - | ^^^ F841 + | ^^^ | - = help: Remove assignment to unused variable `baz` +help: Remove assignment to unused variable `baz` ℹ Unsafe fix 23 23 | bar = (1, 2) @@ -79,15 +84,16 @@ F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used 28 28 | 29 29 | def f(): -F841_0.py:35:5: F841 [*] Local variable `_` is assigned to but never used +F841 [*] Local variable `_` is assigned to but never used + --> F841_0.py:35:5 | 34 | def f(): 35 | _ = 1 - | ^ F841 + | ^ 36 | __ = 1 37 | _discarded = 1 | - = help: Remove assignment to unused variable `_` +help: Remove assignment to unused variable `_` ℹ Unsafe fix 32 32 | @@ -98,15 +104,16 @@ F841_0.py:35:5: F841 [*] Local variable `_` is assigned to but never used 37 36 | _discarded = 1 38 37 | -F841_0.py:36:5: F841 [*] Local variable `__` is assigned to but never used +F841 [*] Local variable `__` is assigned to but never used + --> F841_0.py:36:5 | 34 | def f(): 35 | _ = 1 36 | __ = 1 - | ^^ F841 + | ^^ 37 | _discarded = 1 | - = help: Remove assignment to unused variable `__` +help: Remove assignment to unused variable `__` ℹ Unsafe fix 33 33 | @@ -117,14 +124,15 @@ F841_0.py:36:5: F841 [*] Local variable `__` is assigned to but never used 38 37 | 39 38 | -F841_0.py:37:5: F841 [*] Local variable `_discarded` is assigned to but never used +F841 [*] Local variable `_discarded` is assigned to but never used + --> F841_0.py:37:5 | 35 | _ = 1 36 | __ = 1 37 | _discarded = 1 - | ^^^^^^^^^^ F841 + | ^^^^^^^^^^ | - = help: Remove assignment to unused variable `_discarded` +help: Remove assignment to unused variable `_discarded` ℹ Unsafe fix 34 34 | def f(): @@ -135,16 +143,17 @@ F841_0.py:37:5: F841 [*] Local variable `_discarded` is assigned to but never us 39 38 | 40 39 | a = 1 -F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used +F841 [*] Local variable `b` is assigned to but never used + --> F841_0.py:51:9 | 49 | def c(): 50 | # F841 51 | b = 1 - | ^ F841 + | ^ 52 | 53 | def d(): | - = help: Remove assignment to unused variable `b` +help: Remove assignment to unused variable `b` ℹ Unsafe fix 48 48 | @@ -156,14 +165,15 @@ F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used 53 53 | def d(): 54 54 | nonlocal b -F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used +F841 [*] Local variable `my_file` is assigned to but never used + --> F841_0.py:79:26 | 78 | def f(): 79 | with open("file") as my_file, open("") as ((this, that)): - | ^^^^^^^ F841 + | ^^^^^^^ 80 | print("hello") | - = help: Remove assignment to unused variable `my_file` +help: Remove assignment to unused variable `my_file` ℹ Unsafe fix 76 76 | @@ -175,16 +185,17 @@ F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used 81 81 | 82 82 | -F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used +F841 [*] Local variable `my_file` is assigned to but never used + --> F841_0.py:85:25 | 83 | def f(): 84 | with ( 85 | open("file") as my_file, - | ^^^^^^^ F841 + | ^^^^^^^ 86 | open("") as ((this, that)), 87 | ): | - = help: Remove assignment to unused variable `my_file` +help: Remove assignment to unused variable `my_file` ℹ Unsafe fix 82 82 | @@ -196,16 +207,17 @@ F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used 87 87 | ): 88 88 | print("hello") -F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used +F841 [*] Local variable `msg3` is assigned to but never used + --> F841_0.py:102:5 | 100 | msg1 = "Hello, world!" 101 | msg2 = "Hello, world!" 102 | msg3 = "Hello, world!" - | ^^^^ F841 + | ^^^^ 103 | match x: 104 | case 1: | - = help: Remove assignment to unused variable `msg3` +help: Remove assignment to unused variable `msg3` ℹ Unsafe fix 99 99 | def f(x: int): @@ -216,16 +228,17 @@ F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used 104 103 | case 1: 105 104 | print(msg1) -F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used +F841 [*] Local variable `Baz` is assigned to but never used + --> F841_0.py:115:5 | 113 | Foo = enum.Enum("Foo", "A B") 114 | Bar = enum.Enum("Bar", "A B") 115 | Baz = enum.Enum("Baz", "A B") - | ^^^ F841 + | ^^^ 116 | 117 | match x: | - = help: Remove assignment to unused variable `Baz` +help: Remove assignment to unused variable `Baz` ℹ Unsafe fix 112 112 | @@ -237,34 +250,37 @@ F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used 117 117 | match x: 118 118 | case (Foo.A): -F841_0.py:122:14: F841 Local variable `y` is assigned to but never used +F841 Local variable `y` is assigned to but never used + --> F841_0.py:122:14 | 120 | case [Bar.A, *_]: 121 | print("A") 122 | case y: - | ^ F841 + | ^ 123 | pass | - = help: Remove assignment to unused variable `y` +help: Remove assignment to unused variable `y` -F841_0.py:127:21: F841 Local variable `value` is assigned to but never used +F841 Local variable `value` is assigned to but never used + --> F841_0.py:127:21 | 126 | def f(): 127 | if any((key := (value := x)) for x in ["ok"]): - | ^^^^^ F841 + | ^^^^^ 128 | print(key) | - = help: Remove assignment to unused variable `value` +help: Remove assignment to unused variable `value` -F841_0.py:152:25: F841 [*] Local variable `_` is assigned to but never used +F841 [*] Local variable `_` is assigned to but never used + --> F841_0.py:152:25 | 150 | try: 151 | pass 152 | except Exception as _: - | ^ F841 + | ^ 153 | pass | - = help: Remove assignment to unused variable `_` +help: Remove assignment to unused variable `_` ℹ Safe fix 149 149 | def f(): diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap index 8b35fbaf54..82363cecfc 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -future_annotations.py:8:5: F401 [*] `models.Nut` imported but unused +F401 [*] `models.Nut` imported but unused + --> future_annotations.py:8:5 | 6 | from models import ( 7 | Fruit, 8 | Nut, - | ^^^ F401 + | ^^^ 9 | ) | - = help: Remove unused import: `models.Nut` +help: Remove unused import: `models.Nut` ℹ Safe fix 5 5 | @@ -21,10 +21,11 @@ future_annotations.py:8:5: F401 [*] `models.Nut` imported but unused 10 9 | 11 10 | -future_annotations.py:26:19: F821 Undefined name `Bar` +F821 Undefined name `Bar` + --> future_annotations.py:26:19 | 25 | @classmethod 26 | def c(cls) -> Bar: - | ^^^ F821 + | ^^^ 27 | return cls(x=0, y=0) | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap index 4153aa879f..1da16d9100 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:1:8: F401 `os` imported but unused +F401 `os` imported but unused + --> __init__.py:1:8 | 1 | import os - | ^^ F401 + | ^^ 2 | 3 | print(__path__) | - = help: Remove unused import: `os` +help: Remove unused import: `os` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap index 96e7e24ad0..2972d12298 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:7:26: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :7:26 | 5 | try: 6 | pass 7 | except ValueError as x: - | ^ F841 + | ^ 8 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 4 4 | def f(): @@ -22,15 +22,16 @@ snapshot_kind: text 9 9 | 10 10 | try: -:12:26: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :12:26 | 10 | try: 11 | pass 12 | except ValueError as x: - | ^ F841 + | ^ 13 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 9 9 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap index a138818982..377df1d4a9 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:8:30: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :8:30 | 6 | try: 7 | pass 8 | except ValueError as x: - | ^ F841 + | ^ 9 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 5 5 | def f(): @@ -22,10 +22,11 @@ snapshot_kind: text 10 10 | 11 11 | # This should raise an F821 error, rather than resolving to the -:13:15: F821 Undefined name `x` +F821 Undefined name `x` + --> :13:15 | 11 | # This should raise an F821 error, rather than resolving to the 12 | # `x` in `x = 1`. 13 | print(x) - | ^ F821 + | ^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap index cc283ed4cf..fc2a79d306 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:7:26: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :7:26 | 5 | try: 6 | pass 7 | except ValueError as x: - | ^ F841 + | ^ 8 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 4 4 | def f(): diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap index 759d5b3574..ab3f650e89 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:7:26: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :7:26 | 5 | try: 6 | pass 7 | except ValueError as x: - | ^ F841 + | ^ 8 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 4 4 | def f(): @@ -22,15 +22,16 @@ snapshot_kind: text 9 9 | 10 10 | def g(): -:13:30: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :13:30 | 11 | try: 12 | pass 13 | except ValueError as x: - | ^ F841 + | ^ 14 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 10 10 | def g(): diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap index 2a79871a80..a19d8ab553 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -multi_statement_lines.py:2:12: F401 [*] `foo1` imported but unused +F401 [*] `foo1` imported but unused + --> multi_statement_lines.py:2:12 | 1 | if True: 2 | import foo1; x = 1 - | ^^^^ F401 + | ^^^^ 3 | import foo2; x = 1 | - = help: Remove unused import: `foo1` +help: Remove unused import: `foo1` ℹ Safe fix 1 1 | if True: @@ -18,16 +19,17 @@ multi_statement_lines.py:2:12: F401 [*] `foo1` imported but unused 4 4 | 5 5 | if True: -multi_statement_lines.py:3:12: F401 [*] `foo2` imported but unused +F401 [*] `foo2` imported but unused + --> multi_statement_lines.py:3:12 | 1 | if True: 2 | import foo1; x = 1 3 | import foo2; x = 1 - | ^^^^ F401 + | ^^^^ 4 | 5 | if True: | - = help: Remove unused import: `foo2` +help: Remove unused import: `foo2` ℹ Safe fix 1 1 | if True: @@ -38,14 +40,15 @@ multi_statement_lines.py:3:12: F401 [*] `foo2` imported but unused 5 5 | if True: 6 6 | import foo3; \ -multi_statement_lines.py:6:12: F401 [*] `foo3` imported but unused +F401 [*] `foo3` imported but unused + --> multi_statement_lines.py:6:12 | 5 | if True: 6 | import foo3; \ - | ^^^^ F401 + | ^^^^ 7 | x = 1 | - = help: Remove unused import: `foo3` +help: Remove unused import: `foo3` ℹ Safe fix 3 3 | import foo2; x = 1 @@ -58,14 +61,15 @@ multi_statement_lines.py:6:12: F401 [*] `foo3` imported but unused 9 8 | if True: 10 9 | import foo4 \ -multi_statement_lines.py:10:12: F401 [*] `foo4` imported but unused +F401 [*] `foo4` imported but unused + --> multi_statement_lines.py:10:12 | 9 | if True: 10 | import foo4 \ - | ^^^^ F401 + | ^^^^ 11 | ; x = 1 | - = help: Remove unused import: `foo4` +help: Remove unused import: `foo4` ℹ Safe fix 7 7 | x = 1 @@ -78,13 +82,14 @@ multi_statement_lines.py:10:12: F401 [*] `foo4` imported but unused 13 12 | if True: 14 13 | x = 1; import foo5 -multi_statement_lines.py:14:19: F401 [*] `foo5` imported but unused +F401 [*] `foo5` imported but unused + --> multi_statement_lines.py:14:19 | 13 | if True: 14 | x = 1; import foo5 - | ^^^^ F401 + | ^^^^ | - = help: Remove unused import: `foo5` +help: Remove unused import: `foo5` ℹ Safe fix 11 11 | ; x = 1 @@ -96,16 +101,17 @@ multi_statement_lines.py:14:19: F401 [*] `foo5` imported but unused 16 16 | 17 17 | if True: -multi_statement_lines.py:19:17: F401 [*] `foo6` imported but unused +F401 [*] `foo6` imported but unused + --> multi_statement_lines.py:19:17 | 17 | if True: 18 | x = 1; \ 19 | import foo6 - | ^^^^ F401 + | ^^^^ 20 | 21 | if True: | - = help: Remove unused import: `foo6` +help: Remove unused import: `foo6` ℹ Safe fix 15 15 | @@ -118,16 +124,17 @@ multi_statement_lines.py:19:17: F401 [*] `foo6` imported but unused 21 20 | if True: 22 21 | x = 1 \ -multi_statement_lines.py:23:18: F401 [*] `foo7` imported but unused +F401 [*] `foo7` imported but unused + --> multi_statement_lines.py:23:18 | 21 | if True: 22 | x = 1 \ 23 | ; import foo7 - | ^^^^ F401 + | ^^^^ 24 | 25 | if True: | - = help: Remove unused import: `foo7` +help: Remove unused import: `foo7` ℹ Safe fix 20 20 | @@ -139,14 +146,15 @@ multi_statement_lines.py:23:18: F401 [*] `foo7` imported but unused 25 25 | if True: 26 26 | x = 1; import foo8; x = 1 -multi_statement_lines.py:26:19: F401 [*] `foo8` imported but unused +F401 [*] `foo8` imported but unused + --> multi_statement_lines.py:26:19 | 25 | if True: 26 | x = 1; import foo8; x = 1 - | ^^^^ F401 + | ^^^^ 27 | x = 1; import foo9; x = 1 | - = help: Remove unused import: `foo8` +help: Remove unused import: `foo8` ℹ Safe fix 23 23 | ; import foo7 @@ -158,16 +166,17 @@ multi_statement_lines.py:26:19: F401 [*] `foo8` imported but unused 28 28 | 29 29 | if True: -multi_statement_lines.py:27:23: F401 [*] `foo9` imported but unused +F401 [*] `foo9` imported but unused + --> multi_statement_lines.py:27:23 | 25 | if True: 26 | x = 1; import foo8; x = 1 27 | x = 1; import foo9; x = 1 - | ^^^^ F401 + | ^^^^ 28 | 29 | if True: | - = help: Remove unused import: `foo9` +help: Remove unused import: `foo9` ℹ Safe fix 24 24 | @@ -179,15 +188,16 @@ multi_statement_lines.py:27:23: F401 [*] `foo9` imported but unused 29 29 | if True: 30 30 | x = 1; \ -multi_statement_lines.py:31:16: F401 [*] `foo10` imported but unused +F401 [*] `foo10` imported but unused + --> multi_statement_lines.py:31:16 | 29 | if True: 30 | x = 1; \ 31 | import foo10; \ - | ^^^^^ F401 + | ^^^^^ 32 | x = 1 | - = help: Remove unused import: `foo10` +help: Remove unused import: `foo10` ℹ Safe fix 28 28 | @@ -200,15 +210,16 @@ multi_statement_lines.py:31:16: F401 [*] `foo10` imported but unused 34 33 | if True: 35 34 | x = 1 \ -multi_statement_lines.py:36:17: F401 [*] `foo11` imported but unused +F401 [*] `foo11` imported but unused + --> multi_statement_lines.py:36:17 | 34 | if True: 35 | x = 1 \ 36 | ;import foo11 \ - | ^^^^^ F401 + | ^^^^^ 37 | ;x = 1 | - = help: Remove unused import: `foo11` +help: Remove unused import: `foo11` ℹ Safe fix 33 33 | @@ -219,16 +230,17 @@ multi_statement_lines.py:36:17: F401 [*] `foo11` imported but unused 38 37 | 39 38 | if True: -multi_statement_lines.py:42:16: F401 [*] `foo12` imported but unused +F401 [*] `foo12` imported but unused + --> multi_statement_lines.py:42:16 | 40 | x = 1; \ 41 | \ 42 | import foo12 - | ^^^^^ F401 + | ^^^^^ 43 | 44 | if True: | - = help: Remove unused import: `foo12` +help: Remove unused import: `foo12` ℹ Safe fix 37 37 | ;x = 1 @@ -242,14 +254,15 @@ multi_statement_lines.py:42:16: F401 [*] `foo12` imported but unused 44 42 | if True: 45 43 | x = 1; \ -multi_statement_lines.py:47:12: F401 [*] `foo13` imported but unused +F401 [*] `foo13` imported but unused + --> multi_statement_lines.py:47:12 | 45 | x = 1; \ 46 | \ 47 | import foo13 - | ^^^^^ F401 + | ^^^^^ | - = help: Remove unused import: `foo13` +help: Remove unused import: `foo13` ℹ Safe fix 42 42 | import foo12 @@ -263,16 +276,17 @@ multi_statement_lines.py:47:12: F401 [*] `foo13` imported but unused 49 47 | 50 48 | if True: -multi_statement_lines.py:53:12: F401 [*] `foo14` imported but unused +F401 [*] `foo14` imported but unused + --> multi_statement_lines.py:53:12 | 51 | x = 1; \ 52 | # \ 53 | import foo14 - | ^^^^^ F401 + | ^^^^^ 54 | 55 | # Continuation, but not as the last content in the file. | - = help: Remove unused import: `foo14` +help: Remove unused import: `foo14` ℹ Safe fix 50 50 | if True: @@ -283,16 +297,17 @@ multi_statement_lines.py:53:12: F401 [*] `foo14` imported but unused 55 54 | # Continuation, but not as the last content in the file. 56 55 | x = 1; \ -multi_statement_lines.py:57:8: F401 [*] `foo15` imported but unused +F401 [*] `foo15` imported but unused + --> multi_statement_lines.py:57:8 | 55 | # Continuation, but not as the last content in the file. 56 | x = 1; \ 57 | import foo15 - | ^^^^^ F401 + | ^^^^^ 58 | 59 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax | - = help: Remove unused import: `foo15` +help: Remove unused import: `foo15` ℹ Safe fix 53 53 | import foo14 @@ -305,14 +320,15 @@ multi_statement_lines.py:57:8: F401 [*] `foo15` imported but unused 59 58 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax 60 59 | # error.) -multi_statement_lines.py:62:8: F401 [*] `foo16` imported but unused +F401 [*] `foo16` imported but unused + --> multi_statement_lines.py:62:8 | 60 | # error.) 61 | x = 1; \ 62 | import foo16 - | ^^^^^ F401 + | ^^^^^ | - = help: Remove unused import: `foo16` +help: Remove unused import: `foo16` ℹ Safe fix 58 58 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__nested_relative_typing_module.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__nested_relative_typing_module.snap index b6285d774f..d9bbd4c321 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__nested_relative_typing_module.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__nested_relative_typing_module.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -baz.py:26:17: F821 Undefined name `foo` +F821 Undefined name `foo` + --> baz.py:26:17 | 25 | # F821 26 | x: Literal["foo"] - | ^^^ F821 + | ^^^ | -baz.py:33:17: F821 Undefined name `foo` +F821 Undefined name `foo` + --> baz.py:33:17 | 32 | # F821 33 | x: Literal["foo"] - | ^^^ F821 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap index ebd332ca01..dc63a9b851 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_24____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:19:8: F401 [*] `sys` imported but unused +F401 [*] `sys` imported but unused + --> __init__.py:19:8 | 19 | import sys # F401: remove unused - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `sys` +help: Remove unused import: `sys` ℹ Unsafe fix 16 16 | import argparse as argparse # Ok: is redundant alias @@ -18,12 +18,13 @@ __init__.py:19:8: F401 [*] `sys` imported but unused 21 20 | 22 21 | # first-party -__init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:33:15 | 33 | from . import unused # F401: change to redundant alias - | ^^^^^^ F401 + | ^^^^^^ | - = help: Use an explicit re-export: `unused as unused` +help: Use an explicit re-export: `unused as unused` ℹ Safe fix 30 30 | from . import aliased as aliased # Ok: is redundant alias @@ -35,9 +36,10 @@ __init__.py:33:15: F401 [*] `.unused` imported but unused; consider removing, ad 35 35 | 36 36 | from . import renamed as bees # F401: no fix -__init__.py:36:26: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:36:26 | 36 | from . import renamed as bees # F401: no fix - | ^^^^ F401 + | ^^^^ | - = help: Use an explicit re-export: `renamed as renamed` +help: Use an explicit re-export: `renamed as renamed` diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap index 6b4906ee54..ca0228f64f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_25__all_nonempty____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:19:8: F401 [*] `sys` imported but unused +F401 [*] `sys` imported but unused + --> __init__.py:19:8 | 19 | import sys # F401: remove unused - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `sys` +help: Remove unused import: `sys` ℹ Unsafe fix 16 16 | import argparse # Ok: is exported in __all__ @@ -18,12 +18,13 @@ __init__.py:19:8: F401 [*] `sys` imported but unused 21 20 | 22 21 | # first-party -__init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:36:15 | 36 | from . import unused # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Add unused import `unused` to __all__ +help: Add unused import `unused` to __all__ ℹ Safe fix 39 39 | from . import renamed as bees # F401: add to __all__ @@ -32,12 +33,13 @@ __init__.py:36:15: F401 [*] `.unused` imported but unused; consider removing, ad 42 |-__all__ = ["argparse", "exported"] 42 |+__all__ = ["argparse", "exported", "unused"] -__init__.py:39:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:39:26 | 39 | from . import renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Add unused import `bees` to __all__ +help: Add unused import `bees` to __all__ ℹ Safe fix 39 39 | from . import renamed as bees # F401: add to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap index 60d58e3597..9cdd127afb 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_26__all_empty____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Add unused import `unused` to __all__ +help: Add unused import `unused` to __all__ ℹ Safe fix 8 8 | from . import renamed as bees # F401: add to __all__ @@ -16,12 +16,13 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add 11 |-__all__ = [] 11 |+__all__ = ["unused"] -__init__.py:8:26: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:26 | 8 | from . import renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Add unused import `bees` to __all__ +help: Add unused import `bees` to __all__ ℹ Safe fix 8 8 | from . import renamed as bees # F401: add to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_27__all_mistyped____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_27__all_mistyped____init__.py.snap index 17856067e6..f74e91a35b 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_27__all_mistyped____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_27__all_mistyped____init__.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused # F401: recommend add to all w/o fix - | ^^^^^^ F401 + | ^^^^^^ | - = help: Add unused import `unused` to __all__ +help: Add unused import `unused` to __all__ -__init__.py:8:26: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:26 | 8 | from . import renamed as bees # F401: recommend add to all w/o fix - | ^^^^ F401 + | ^^^^ | - = help: Add unused import `bees` to __all__ +help: Add unused import `bees` to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap index 0a5fcedf8c..b85570c0c7 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_28__all_multiple____init__.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:15 | 5 | from . import unused, renamed as bees # F401: add to __all__ - | ^^^^^^ F401 + | ^^^^^^ | - = help: Add unused import `unused` to __all__ +help: Add unused import `unused` to __all__ ℹ Safe fix 5 5 | from . import unused, renamed as bees # F401: add to __all__ @@ -16,12 +16,13 @@ __init__.py:5:15: F401 [*] `.unused` imported but unused; consider removing, add 8 |-__all__ = []; 8 |+__all__ = ["bees", "unused"]; -__init__.py:5:34: F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 [*] `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:5:34 | 5 | from . import unused, renamed as bees # F401: add to __all__ - | ^^^^ F401 + | ^^^^ | - = help: Add unused import `bees` to __all__ +help: Add unused import `bees` to __all__ ℹ Safe fix 5 5 | from . import unused, renamed as bees # F401: add to __all__ diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap index 57c17bb0c5..3cc9d9eac6 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_29__all_conditional____init__.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:8:15: F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.unused` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:15 | 6 | import sys 7 | 8 | from . import unused, exported, renamed as bees - | ^^^^^^ F401 + | ^^^^^^ 9 | 10 | if sys.version_info > (3, 9): | - = help: Remove unused import +help: Remove unused import -__init__.py:8:44: F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias +F401 `.renamed` imported but unused; consider removing, adding to `__all__`, or using a redundant alias + --> __init__.py:8:44 | 6 | import sys 7 | 8 | from . import unused, exported, renamed as bees - | ^^^^ F401 + | ^^^^ 9 | 10 | if sys.version_info > (3, 9): | - = help: Remove unused import +help: Remove unused import diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_33____init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_33____init__.py.snap index d17deaa838..1f40e7cb69 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_33____init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401_F401_33____init__.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -__init__.py:8:35: F401 [*] `F401_33.other.Ham` imported but unused +F401 [*] `F401_33.other.Ham` imported but unused + --> __init__.py:8:35 | 6 | class Spam: 7 | def __init__(self) -> None: 8 | from F401_33.other import Ham - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `F401_33.other.Ham` +help: Remove unused import: `F401_33.other.Ham` ℹ Unsafe fix 5 5 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap index a6ec69a4a5..89b804e26f 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F401___init__.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:1:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> __init__.py:1:8 | 1 | import os - | ^^ F401 + | ^^ 2 | 3 | print(__path__) | - = help: Remove unused import: `os` +help: Remove unused import: `os` ℹ Unsafe fix 1 |-import os diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F822___init__.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F822___init__.py.snap index 40b04dfafd..fc93eac03e 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F822___init__.py.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__preview__F822___init__.py.snap @@ -1,26 +1,29 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs --- -__init__.py:5:12: F822 Undefined name `a` in `__all__` +F822 Undefined name `a` in `__all__` + --> __init__.py:5:12 | 3 | print(__path__) 4 | 5 | __all__ = ["a", "b", "c"] - | ^^^ F822 + | ^^^ | -__init__.py:5:17: F822 Undefined name `b` in `__all__` +F822 Undefined name `b` in `__all__` + --> __init__.py:5:17 | 3 | print(__path__) 4 | 5 | __all__ = ["a", "b", "c"] - | ^^^ F822 + | ^^^ | -__init__.py:5:22: F822 Undefined name `c` in `__all__` +F822 Undefined name `c` in `__all__` + --> __init__.py:5:22 | 3 | print(__path__) 4 | 5 | __all__ = ["a", "b", "c"] - | ^^^ F822 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap index 6e9134a854..30100ddb2d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:7:26: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :7:26 | 5 | try: 6 | 1 / 0 7 | except ValueError as x: - | ^ F841 + | ^ 8 | pass 9 | except ImportError as x: | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 4 4 | @@ -23,15 +23,16 @@ snapshot_kind: text 9 9 | except ImportError as x: 10 10 | pass -:9:27: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :9:27 | 7 | except ValueError as x: 8 | pass 9 | except ImportError as x: - | ^ F841 + | ^ 10 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 6 6 | 1 / 0 diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap index 1a04064c1b..2c495fdf7d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -:7:25: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> :7:25 | 5 | try: 6 | 1 / 0 7 | except Exception as x: - | ^ F841 + | ^ 8 | pass | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Safe fix 4 4 | diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__relative_typing_module.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__relative_typing_module.snap index 0b9f6a7672..bb3c7028ef 100644 --- a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__relative_typing_module.snap +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__relative_typing_module.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pyflakes/mod.rs -snapshot_kind: text --- -bar.py:26:17: F821 Undefined name `foo` +F821 Undefined name `foo` + --> bar.py:26:17 | 25 | # F821 26 | x: Literal["foo"] - | ^^^ F821 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap index 20b023cd3d..165f6598b8 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs --- -PGH003_0.py:1:8: PGH003 Use specific rule codes when ignoring type issues +PGH003 Use specific rule codes when ignoring type issues + --> PGH003_0.py:1:8 | 1 | x = 1 # type: ignore - | ^^^^^^^^^^^^^^ PGH003 + | ^^^^^^^^^^^^^^ 2 | x = 1 # type:ignore 3 | x = 1 # type: ignore[attr-defined] # type: ignore | -PGH003_0.py:2:8: PGH003 Use specific rule codes when ignoring type issues +PGH003 Use specific rule codes when ignoring type issues + --> PGH003_0.py:2:8 | 1 | x = 1 # type: ignore 2 | x = 1 # type:ignore - | ^^^^^^^^^^^^^ PGH003 + | ^^^^^^^^^^^^^ 3 | x = 1 # type: ignore[attr-defined] # type: ignore 4 | x = 1 # type: ignoreme # type: ignore | -PGH003_0.py:3:38: PGH003 Use specific rule codes when ignoring type issues +PGH003 Use specific rule codes when ignoring type issues + --> PGH003_0.py:3:38 | 1 | x = 1 # type: ignore 2 | x = 1 # type:ignore 3 | x = 1 # type: ignore[attr-defined] # type: ignore - | ^^^^^^^^^^^^^^ PGH003 + | ^^^^^^^^^^^^^^ 4 | x = 1 # type: ignoreme # type: ignore | -PGH003_0.py:4:25: PGH003 Use specific rule codes when ignoring type issues +PGH003 Use specific rule codes when ignoring type issues + --> PGH003_0.py:4:25 | 2 | x = 1 # type:ignore 3 | x = 1 # type: ignore[attr-defined] # type: ignore 4 | x = 1 # type: ignoreme # type: ignore - | ^^^^^^^^^^^^^^ PGH003 + | ^^^^^^^^^^^^^^ 5 | 6 | x = 1 | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap index 3050506086..d5efb8bd01 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap @@ -1,28 +1,31 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs --- -PGH003_1.py:1:8: PGH003 Use specific rule codes when ignoring type issues +PGH003 Use specific rule codes when ignoring type issues + --> PGH003_1.py:1:8 | 1 | x = 1 # pyright: ignore - | ^^^^^^^^^^^^^^^^^ PGH003 + | ^^^^^^^^^^^^^^^^^ 2 | x = 1 # pyright:ignore 3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore | -PGH003_1.py:2:8: PGH003 Use specific rule codes when ignoring type issues +PGH003 Use specific rule codes when ignoring type issues + --> PGH003_1.py:2:8 | 1 | x = 1 # pyright: ignore 2 | x = 1 # pyright:ignore - | ^^^^^^^^^^^^^^^^ PGH003 + | ^^^^^^^^^^^^^^^^ 3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore | -PGH003_1.py:3:41: PGH003 Use specific rule codes when ignoring type issues +PGH003 Use specific rule codes when ignoring type issues + --> PGH003_1.py:3:41 | 1 | x = 1 # pyright: ignore 2 | x = 1 # pyright:ignore 3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore - | ^^^^^^^^^^^^^^^^^ PGH003 + | ^^^^^^^^^^^^^^^^^ 4 | 5 | x = 1 | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap index 1b812d166f..86fd2f43f6 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap @@ -1,43 +1,47 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs --- -PGH004_0.py:1:8: PGH004 Use specific rule codes when using `noqa` +PGH004 Use specific rule codes when using `noqa` + --> PGH004_0.py:1:8 | 1 | x = 1 # noqa - | ^^^^^^ PGH004 + | ^^^^^^ 2 | x = 1 # NOQA:F401,W203 3 | # noqa | -PGH004_0.py:3:1: PGH004 Use specific rule codes when using `noqa` +PGH004 Use specific rule codes when using `noqa` + --> PGH004_0.py:3:1 | 1 | x = 1 # noqa 2 | x = 1 # NOQA:F401,W203 3 | # noqa - | ^^^^^^ PGH004 + | ^^^^^^ 4 | # NOQA 5 | # noqa:F401 | -PGH004_0.py:4:1: PGH004 Use specific rule codes when using `noqa` +PGH004 Use specific rule codes when using `noqa` + --> PGH004_0.py:4:1 | 2 | x = 1 # NOQA:F401,W203 3 | # noqa 4 | # NOQA - | ^^^^^^ PGH004 + | ^^^^^^ 5 | # noqa:F401 6 | # noqa:F401,W203 | -PGH004_0.py:18:8: PGH004 [*] Use a colon when specifying `noqa` rule codes +PGH004 [*] Use a colon when specifying `noqa` rule codes + --> PGH004_0.py:18:8 | 17 | # PGH004 18 | x = 2 # noqa X100 - | ^^^^^^^ PGH004 + | ^^^^^^^ 19 | 20 | # PGH004 | - = help: Add missing colon +help: Add missing colon ℹ Unsafe fix 15 15 | x = 2 # noqa:X100 @@ -49,15 +53,16 @@ PGH004_0.py:18:8: PGH004 [*] Use a colon when specifying `noqa` rule codes 20 20 | # PGH004 21 21 | x = 2 # noqa X100, X200 -PGH004_0.py:21:8: PGH004 [*] Use a colon when specifying `noqa` rule codes +PGH004 [*] Use a colon when specifying `noqa` rule codes + --> PGH004_0.py:21:8 | 20 | # PGH004 21 | x = 2 # noqa X100, X200 - | ^^^^^^^ PGH004 + | ^^^^^^^ 22 | 23 | # PGH004 | - = help: Add missing colon +help: Add missing colon ℹ Unsafe fix 18 18 | x = 2 # noqa X100 diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_1.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_1.py.snap index a4aee355b8..5edca0674a 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_1.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_1.py.snap @@ -1,9 +1,9 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs -snapshot_kind: text --- -PGH004_1.py:1:1: PGH004 Use specific rule codes when using `noqa` +PGH004 Use specific rule codes when using `noqa` + --> PGH004_1.py:1:1 | 1 | #noqa - | ^^^^^ PGH004 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_2.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_2.py.snap index 6c93b8a108..b7105655a9 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_2.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_2.py.snap @@ -1,25 +1,28 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs --- -PGH004_2.py:1:1: PGH004 Use specific rule codes when using `noqa` +PGH004 Use specific rule codes when using `noqa` + --> PGH004_2.py:1:1 | 1 | # noqa - | ^^^^^^ PGH004 + | ^^^^^^ 2 | # ruff : noqa 3 | # ruff: noqa: F401 | -PGH004_2.py:2:1: PGH004 Use specific rule codes when using `ruff: noqa` +PGH004 Use specific rule codes when using `ruff: noqa` + --> PGH004_2.py:2:1 | 1 | # noqa 2 | # ruff : noqa - | ^^^^^^^^^^^^^ PGH004 + | ^^^^^^^^^^^^^ 3 | # ruff: noqa: F401 | -PGH004_2.py:6:1: PGH004 Use specific rule codes when using `ruff: noqa` +PGH004 Use specific rule codes when using `ruff: noqa` + --> PGH004_2.py:6:1 | 6 | # flake8: noqa - | ^^^^^^^^^^^^^^ PGH004 + | ^^^^^^^^^^^^^^ 7 | import math as m | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap index f95f64df91..651f26d344 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap @@ -1,91 +1,100 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs --- -PGH005_0.py:4:8: PGH005 Non-existent mock method: `not_called` +PGH005 Non-existent mock method: `not_called` + --> PGH005_0.py:4:8 | 2 | # ============ 3 | # Errors 4 | assert my_mock.not_called() - | ^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^ 5 | assert my_mock.called_once_with() 6 | assert my_mock.not_called | -PGH005_0.py:5:8: PGH005 Non-existent mock method: `called_once_with` +PGH005 Non-existent mock method: `called_once_with` + --> PGH005_0.py:5:8 | 3 | # Errors 4 | assert my_mock.not_called() 5 | assert my_mock.called_once_with() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | assert my_mock.not_called 7 | assert my_mock.called_once_with | -PGH005_0.py:6:8: PGH005 Non-existent mock method: `not_called` +PGH005 Non-existent mock method: `not_called` + --> PGH005_0.py:6:8 | 4 | assert my_mock.not_called() 5 | assert my_mock.called_once_with() 6 | assert my_mock.not_called - | ^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^ 7 | assert my_mock.called_once_with 8 | my_mock.assert_not_called | -PGH005_0.py:7:8: PGH005 Non-existent mock method: `called_once_with` +PGH005 Non-existent mock method: `called_once_with` + --> PGH005_0.py:7:8 | 5 | assert my_mock.called_once_with() 6 | assert my_mock.not_called 7 | assert my_mock.called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 8 | my_mock.assert_not_called 9 | my_mock.assert_called | -PGH005_0.py:8:1: PGH005 Mock method should be called: `assert_not_called` +PGH005 Mock method should be called: `assert_not_called` + --> PGH005_0.py:8:1 | 6 | assert my_mock.not_called 7 | assert my_mock.called_once_with 8 | my_mock.assert_not_called - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | my_mock.assert_called 10 | my_mock.assert_called_once_with | -PGH005_0.py:9:1: PGH005 Mock method should be called: `assert_called` +PGH005 Mock method should be called: `assert_called` + --> PGH005_0.py:9:1 | 7 | assert my_mock.called_once_with 8 | my_mock.assert_not_called 9 | my_mock.assert_called - | ^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | my_mock.assert_called_once_with 11 | my_mock.assert_called_once_with | -PGH005_0.py:10:1: PGH005 Mock method should be called: `assert_called_once_with` +PGH005 Mock method should be called: `assert_called_once_with` + --> PGH005_0.py:10:1 | 8 | my_mock.assert_not_called 9 | my_mock.assert_called 10 | my_mock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | my_mock.assert_called_once_with 12 | MyMock.assert_called_once_with | -PGH005_0.py:11:1: PGH005 Mock method should be called: `assert_called_once_with` +PGH005 Mock method should be called: `assert_called_once_with` + --> PGH005_0.py:11:1 | 9 | my_mock.assert_called 10 | my_mock.assert_called_once_with 11 | my_mock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | MyMock.assert_called_once_with | -PGH005_0.py:12:1: PGH005 Mock method should be called: `assert_called_once_with` +PGH005 Mock method should be called: `assert_called_once_with` + --> PGH005_0.py:12:1 | 10 | my_mock.assert_called_once_with 11 | my_mock.assert_called_once_with 12 | MyMock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | # OK | diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__preview__PGH005_PGH005_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__preview__PGH005_PGH005_0.py.snap index e61728110c..664573f70b 100644 --- a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__preview__PGH005_PGH005_0.py.snap +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__preview__PGH005_PGH005_0.py.snap @@ -1,190 +1,209 @@ --- source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs --- -PGH005_0.py:4:8: PGH005 Non-existent mock method: `not_called` +PGH005 Non-existent mock method: `not_called` + --> PGH005_0.py:4:8 | 2 | # ============ 3 | # Errors 4 | assert my_mock.not_called() - | ^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^ 5 | assert my_mock.called_once_with() 6 | assert my_mock.not_called | -PGH005_0.py:5:8: PGH005 Non-existent mock method: `called_once_with` +PGH005 Non-existent mock method: `called_once_with` + --> PGH005_0.py:5:8 | 3 | # Errors 4 | assert my_mock.not_called() 5 | assert my_mock.called_once_with() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | assert my_mock.not_called 7 | assert my_mock.called_once_with | -PGH005_0.py:6:8: PGH005 Non-existent mock method: `not_called` +PGH005 Non-existent mock method: `not_called` + --> PGH005_0.py:6:8 | 4 | assert my_mock.not_called() 5 | assert my_mock.called_once_with() 6 | assert my_mock.not_called - | ^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^ 7 | assert my_mock.called_once_with 8 | my_mock.assert_not_called | -PGH005_0.py:7:8: PGH005 Non-existent mock method: `called_once_with` +PGH005 Non-existent mock method: `called_once_with` + --> PGH005_0.py:7:8 | 5 | assert my_mock.called_once_with() 6 | assert my_mock.not_called 7 | assert my_mock.called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 8 | my_mock.assert_not_called 9 | my_mock.assert_called | -PGH005_0.py:8:1: PGH005 Mock method should be called: `assert_not_called` +PGH005 Mock method should be called: `assert_not_called` + --> PGH005_0.py:8:1 | 6 | assert my_mock.not_called 7 | assert my_mock.called_once_with 8 | my_mock.assert_not_called - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | my_mock.assert_called 10 | my_mock.assert_called_once_with | -PGH005_0.py:9:1: PGH005 Mock method should be called: `assert_called` +PGH005 Mock method should be called: `assert_called` + --> PGH005_0.py:9:1 | 7 | assert my_mock.called_once_with 8 | my_mock.assert_not_called 9 | my_mock.assert_called - | ^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | my_mock.assert_called_once_with 11 | my_mock.assert_called_once_with | -PGH005_0.py:10:1: PGH005 Mock method should be called: `assert_called_once_with` +PGH005 Mock method should be called: `assert_called_once_with` + --> PGH005_0.py:10:1 | 8 | my_mock.assert_not_called 9 | my_mock.assert_called 10 | my_mock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | my_mock.assert_called_once_with 12 | MyMock.assert_called_once_with | -PGH005_0.py:11:1: PGH005 Mock method should be called: `assert_called_once_with` +PGH005 Mock method should be called: `assert_called_once_with` + --> PGH005_0.py:11:1 | 9 | my_mock.assert_called 10 | my_mock.assert_called_once_with 11 | my_mock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | MyMock.assert_called_once_with | -PGH005_0.py:12:1: PGH005 Mock method should be called: `assert_called_once_with` +PGH005 Mock method should be called: `assert_called_once_with` + --> PGH005_0.py:12:1 | 10 | my_mock.assert_called_once_with 11 | my_mock.assert_called_once_with 12 | MyMock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | # OK | -PGH005_0.py:26:8: PGH005 Non-existent mock method: `not_awaited` +PGH005 Non-existent mock method: `not_awaited` + --> PGH005_0.py:26:8 | 24 | # ================= 25 | # Errors 26 | assert my_mock.not_awaited() - | ^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^ 27 | assert my_mock.awaited_once_with() 28 | assert my_mock.not_awaited | -PGH005_0.py:27:8: PGH005 Non-existent mock method: `awaited_once_with` +PGH005 Non-existent mock method: `awaited_once_with` + --> PGH005_0.py:27:8 | 25 | # Errors 26 | assert my_mock.not_awaited() 27 | assert my_mock.awaited_once_with() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | assert my_mock.not_awaited 29 | assert my_mock.awaited_once_with | -PGH005_0.py:28:8: PGH005 Non-existent mock method: `not_awaited` +PGH005 Non-existent mock method: `not_awaited` + --> PGH005_0.py:28:8 | 26 | assert my_mock.not_awaited() 27 | assert my_mock.awaited_once_with() 28 | assert my_mock.not_awaited - | ^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^ 29 | assert my_mock.awaited_once_with 30 | my_mock.assert_not_awaited | -PGH005_0.py:29:8: PGH005 Non-existent mock method: `awaited_once_with` +PGH005 Non-existent mock method: `awaited_once_with` + --> PGH005_0.py:29:8 | 27 | assert my_mock.awaited_once_with() 28 | assert my_mock.not_awaited 29 | assert my_mock.awaited_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | my_mock.assert_not_awaited 31 | my_mock.assert_awaited | -PGH005_0.py:30:1: PGH005 Mock method should be called: `assert_not_awaited` +PGH005 Mock method should be called: `assert_not_awaited` + --> PGH005_0.py:30:1 | 28 | assert my_mock.not_awaited 29 | assert my_mock.awaited_once_with 30 | my_mock.assert_not_awaited - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | my_mock.assert_awaited 32 | my_mock.assert_awaited_once_with | -PGH005_0.py:31:1: PGH005 Mock method should be called: `assert_awaited` +PGH005 Mock method should be called: `assert_awaited` + --> PGH005_0.py:31:1 | 29 | assert my_mock.awaited_once_with 30 | my_mock.assert_not_awaited 31 | my_mock.assert_awaited - | ^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^ 32 | my_mock.assert_awaited_once_with 33 | my_mock.assert_awaited_once_with | -PGH005_0.py:32:1: PGH005 Mock method should be called: `assert_awaited_once_with` +PGH005 Mock method should be called: `assert_awaited_once_with` + --> PGH005_0.py:32:1 | 30 | my_mock.assert_not_awaited 31 | my_mock.assert_awaited 32 | my_mock.assert_awaited_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | my_mock.assert_awaited_once_with 34 | MyMock.assert_awaited_once_with | -PGH005_0.py:33:1: PGH005 Mock method should be called: `assert_awaited_once_with` +PGH005 Mock method should be called: `assert_awaited_once_with` + --> PGH005_0.py:33:1 | 31 | my_mock.assert_awaited 32 | my_mock.assert_awaited_once_with 33 | my_mock.assert_awaited_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | MyMock.assert_awaited_once_with 35 | assert my_mock.awaited | -PGH005_0.py:34:1: PGH005 Mock method should be called: `assert_awaited_once_with` +PGH005 Mock method should be called: `assert_awaited_once_with` + --> PGH005_0.py:34:1 | 32 | my_mock.assert_awaited_once_with 33 | my_mock.assert_awaited_once_with 34 | MyMock.assert_awaited_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | assert my_mock.awaited | -PGH005_0.py:35:8: PGH005 Non-existent mock method: `awaited` +PGH005 Non-existent mock method: `awaited` + --> PGH005_0.py:35:8 | 33 | my_mock.assert_awaited_once_with 34 | MyMock.assert_awaited_once_with 35 | assert my_mock.awaited - | ^^^^^^^^^^^^^^^ PGH005 + | ^^^^^^^^^^^^^^^ 36 | 37 | # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap index c83f17fe22..a8416f2654 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap @@ -1,316 +1,348 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -type_name_incorrect_variance.py:5:5: PLC0105 `TypeVar` name "T" does not reflect its covariance; consider renaming it to "T_co" +PLC0105 `TypeVar` name "T" does not reflect its covariance; consider renaming it to "T_co" + --> type_name_incorrect_variance.py:5:5 | 3 | # Errors. 4 | 5 | T = TypeVar("T", covariant=True) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 6 | T = TypeVar("T", covariant=True, contravariant=False) 7 | T = TypeVar("T", contravariant=True) | -type_name_incorrect_variance.py:6:5: PLC0105 `TypeVar` name "T" does not reflect its covariance; consider renaming it to "T_co" +PLC0105 `TypeVar` name "T" does not reflect its covariance; consider renaming it to "T_co" + --> type_name_incorrect_variance.py:6:5 | 5 | T = TypeVar("T", covariant=True) 6 | T = TypeVar("T", covariant=True, contravariant=False) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 7 | T = TypeVar("T", contravariant=True) 8 | T = TypeVar("T", covariant=False, contravariant=True) | -type_name_incorrect_variance.py:7:5: PLC0105 `TypeVar` name "T" does not reflect its contravariance; consider renaming it to "T_contra" +PLC0105 `TypeVar` name "T" does not reflect its contravariance; consider renaming it to "T_contra" + --> type_name_incorrect_variance.py:7:5 | 5 | T = TypeVar("T", covariant=True) 6 | T = TypeVar("T", covariant=True, contravariant=False) 7 | T = TypeVar("T", contravariant=True) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 8 | T = TypeVar("T", covariant=False, contravariant=True) 9 | P = ParamSpec("P", covariant=True) | -type_name_incorrect_variance.py:8:5: PLC0105 `TypeVar` name "T" does not reflect its contravariance; consider renaming it to "T_contra" +PLC0105 `TypeVar` name "T" does not reflect its contravariance; consider renaming it to "T_contra" + --> type_name_incorrect_variance.py:8:5 | 6 | T = TypeVar("T", covariant=True, contravariant=False) 7 | T = TypeVar("T", contravariant=True) 8 | T = TypeVar("T", covariant=False, contravariant=True) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 9 | P = ParamSpec("P", covariant=True) 10 | P = ParamSpec("P", covariant=True, contravariant=False) | -type_name_incorrect_variance.py:9:5: PLC0105 `ParamSpec` name "P" does not reflect its covariance; consider renaming it to "P_co" +PLC0105 `ParamSpec` name "P" does not reflect its covariance; consider renaming it to "P_co" + --> type_name_incorrect_variance.py:9:5 | 7 | T = TypeVar("T", contravariant=True) 8 | T = TypeVar("T", covariant=False, contravariant=True) 9 | P = ParamSpec("P", covariant=True) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 10 | P = ParamSpec("P", covariant=True, contravariant=False) 11 | P = ParamSpec("P", contravariant=True) | -type_name_incorrect_variance.py:10:5: PLC0105 `ParamSpec` name "P" does not reflect its covariance; consider renaming it to "P_co" +PLC0105 `ParamSpec` name "P" does not reflect its covariance; consider renaming it to "P_co" + --> type_name_incorrect_variance.py:10:5 | 8 | T = TypeVar("T", covariant=False, contravariant=True) 9 | P = ParamSpec("P", covariant=True) 10 | P = ParamSpec("P", covariant=True, contravariant=False) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 11 | P = ParamSpec("P", contravariant=True) 12 | P = ParamSpec("P", covariant=False, contravariant=True) | -type_name_incorrect_variance.py:11:5: PLC0105 `ParamSpec` name "P" does not reflect its contravariance; consider renaming it to "P_contra" +PLC0105 `ParamSpec` name "P" does not reflect its contravariance; consider renaming it to "P_contra" + --> type_name_incorrect_variance.py:11:5 | 9 | P = ParamSpec("P", covariant=True) 10 | P = ParamSpec("P", covariant=True, contravariant=False) 11 | P = ParamSpec("P", contravariant=True) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 12 | P = ParamSpec("P", covariant=False, contravariant=True) | -type_name_incorrect_variance.py:12:5: PLC0105 `ParamSpec` name "P" does not reflect its contravariance; consider renaming it to "P_contra" +PLC0105 `ParamSpec` name "P" does not reflect its contravariance; consider renaming it to "P_contra" + --> type_name_incorrect_variance.py:12:5 | 10 | P = ParamSpec("P", covariant=True, contravariant=False) 11 | P = ParamSpec("P", contravariant=True) 12 | P = ParamSpec("P", covariant=False, contravariant=True) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 13 | 14 | T_co = TypeVar("T_co") | -type_name_incorrect_variance.py:14:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" +PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" + --> type_name_incorrect_variance.py:14:8 | 12 | P = ParamSpec("P", covariant=False, contravariant=True) 13 | 14 | T_co = TypeVar("T_co") - | ^^^^^^^ PLC0105 + | ^^^^^^^ 15 | T_co = TypeVar("T_co", covariant=False) 16 | T_co = TypeVar("T_co", contravariant=False) | -type_name_incorrect_variance.py:15:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" +PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" + --> type_name_incorrect_variance.py:15:8 | 14 | T_co = TypeVar("T_co") 15 | T_co = TypeVar("T_co", covariant=False) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 16 | T_co = TypeVar("T_co", contravariant=False) 17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) | -type_name_incorrect_variance.py:16:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" +PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" + --> type_name_incorrect_variance.py:16:8 | 14 | T_co = TypeVar("T_co") 15 | T_co = TypeVar("T_co", covariant=False) 16 | T_co = TypeVar("T_co", contravariant=False) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) 18 | T_co = TypeVar("T_co", contravariant=True) | -type_name_incorrect_variance.py:17:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" +PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" + --> type_name_incorrect_variance.py:17:8 | 15 | T_co = TypeVar("T_co", covariant=False) 16 | T_co = TypeVar("T_co", contravariant=False) 17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 18 | T_co = TypeVar("T_co", contravariant=True) 19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) | -type_name_incorrect_variance.py:18:8: PLC0105 `TypeVar` name "T_co" does not reflect its contravariance; consider renaming it to "T_contra" +PLC0105 `TypeVar` name "T_co" does not reflect its contravariance; consider renaming it to "T_contra" + --> type_name_incorrect_variance.py:18:8 | 16 | T_co = TypeVar("T_co", contravariant=False) 17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) 18 | T_co = TypeVar("T_co", contravariant=True) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) 20 | P_co = ParamSpec("P_co") | -type_name_incorrect_variance.py:19:8: PLC0105 `TypeVar` name "T_co" does not reflect its contravariance; consider renaming it to "T_contra" +PLC0105 `TypeVar` name "T_co" does not reflect its contravariance; consider renaming it to "T_contra" + --> type_name_incorrect_variance.py:19:8 | 17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) 18 | T_co = TypeVar("T_co", contravariant=True) 19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 20 | P_co = ParamSpec("P_co") 21 | P_co = ParamSpec("P_co", covariant=False) | -type_name_incorrect_variance.py:20:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" +PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" + --> type_name_incorrect_variance.py:20:8 | 18 | T_co = TypeVar("T_co", contravariant=True) 19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) 20 | P_co = ParamSpec("P_co") - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 21 | P_co = ParamSpec("P_co", covariant=False) 22 | P_co = ParamSpec("P_co", contravariant=False) | -type_name_incorrect_variance.py:21:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" +PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" + --> type_name_incorrect_variance.py:21:8 | 19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) 20 | P_co = ParamSpec("P_co") 21 | P_co = ParamSpec("P_co", covariant=False) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 22 | P_co = ParamSpec("P_co", contravariant=False) 23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) | -type_name_incorrect_variance.py:22:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" +PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" + --> type_name_incorrect_variance.py:22:8 | 20 | P_co = ParamSpec("P_co") 21 | P_co = ParamSpec("P_co", covariant=False) 22 | P_co = ParamSpec("P_co", contravariant=False) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) 24 | P_co = ParamSpec("P_co", contravariant=True) | -type_name_incorrect_variance.py:23:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" +PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" + --> type_name_incorrect_variance.py:23:8 | 21 | P_co = ParamSpec("P_co", covariant=False) 22 | P_co = ParamSpec("P_co", contravariant=False) 23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 24 | P_co = ParamSpec("P_co", contravariant=True) 25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) | -type_name_incorrect_variance.py:24:8: PLC0105 `ParamSpec` name "P_co" does not reflect its contravariance; consider renaming it to "P_contra" +PLC0105 `ParamSpec` name "P_co" does not reflect its contravariance; consider renaming it to "P_contra" + --> type_name_incorrect_variance.py:24:8 | 22 | P_co = ParamSpec("P_co", contravariant=False) 23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) 24 | P_co = ParamSpec("P_co", contravariant=True) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) | -type_name_incorrect_variance.py:25:8: PLC0105 `ParamSpec` name "P_co" does not reflect its contravariance; consider renaming it to "P_contra" +PLC0105 `ParamSpec` name "P_co" does not reflect its contravariance; consider renaming it to "P_contra" + --> type_name_incorrect_variance.py:25:8 | 23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) 24 | P_co = ParamSpec("P_co", contravariant=True) 25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 26 | 27 | T_contra = TypeVar("T_contra") | -type_name_incorrect_variance.py:27:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" +PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" + --> type_name_incorrect_variance.py:27:12 | 25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) 26 | 27 | T_contra = TypeVar("T_contra") - | ^^^^^^^ PLC0105 + | ^^^^^^^ 28 | T_contra = TypeVar("T_contra", covariant=False) 29 | T_contra = TypeVar("T_contra", contravariant=False) | -type_name_incorrect_variance.py:28:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" +PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" + --> type_name_incorrect_variance.py:28:12 | 27 | T_contra = TypeVar("T_contra") 28 | T_contra = TypeVar("T_contra", covariant=False) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 29 | T_contra = TypeVar("T_contra", contravariant=False) 30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) | -type_name_incorrect_variance.py:29:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" +PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" + --> type_name_incorrect_variance.py:29:12 | 27 | T_contra = TypeVar("T_contra") 28 | T_contra = TypeVar("T_contra", covariant=False) 29 | T_contra = TypeVar("T_contra", contravariant=False) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) 31 | T_contra = TypeVar("T_contra", covariant=True) | -type_name_incorrect_variance.py:30:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" +PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" + --> type_name_incorrect_variance.py:30:12 | 28 | T_contra = TypeVar("T_contra", covariant=False) 29 | T_contra = TypeVar("T_contra", contravariant=False) 30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 31 | T_contra = TypeVar("T_contra", covariant=True) 32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) | -type_name_incorrect_variance.py:31:12: PLC0105 `TypeVar` name "T_contra" does not reflect its covariance; consider renaming it to "T_co" +PLC0105 `TypeVar` name "T_contra" does not reflect its covariance; consider renaming it to "T_co" + --> type_name_incorrect_variance.py:31:12 | 29 | T_contra = TypeVar("T_contra", contravariant=False) 30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) 31 | T_contra = TypeVar("T_contra", covariant=True) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) 33 | P_contra = ParamSpec("P_contra") | -type_name_incorrect_variance.py:32:12: PLC0105 `TypeVar` name "T_contra" does not reflect its covariance; consider renaming it to "T_co" +PLC0105 `TypeVar` name "T_contra" does not reflect its covariance; consider renaming it to "T_co" + --> type_name_incorrect_variance.py:32:12 | 30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) 31 | T_contra = TypeVar("T_contra", covariant=True) 32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) - | ^^^^^^^ PLC0105 + | ^^^^^^^ 33 | P_contra = ParamSpec("P_contra") 34 | P_contra = ParamSpec("P_contra", covariant=False) | -type_name_incorrect_variance.py:33:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" +PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" + --> type_name_incorrect_variance.py:33:12 | 31 | T_contra = TypeVar("T_contra", covariant=True) 32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) 33 | P_contra = ParamSpec("P_contra") - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 34 | P_contra = ParamSpec("P_contra", covariant=False) 35 | P_contra = ParamSpec("P_contra", contravariant=False) | -type_name_incorrect_variance.py:34:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" +PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" + --> type_name_incorrect_variance.py:34:12 | 32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) 33 | P_contra = ParamSpec("P_contra") 34 | P_contra = ParamSpec("P_contra", covariant=False) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 35 | P_contra = ParamSpec("P_contra", contravariant=False) 36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) | -type_name_incorrect_variance.py:35:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" +PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" + --> type_name_incorrect_variance.py:35:12 | 33 | P_contra = ParamSpec("P_contra") 34 | P_contra = ParamSpec("P_contra", covariant=False) 35 | P_contra = ParamSpec("P_contra", contravariant=False) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) 37 | P_contra = ParamSpec("P_contra", covariant=True) | -type_name_incorrect_variance.py:36:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" +PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" + --> type_name_incorrect_variance.py:36:12 | 34 | P_contra = ParamSpec("P_contra", covariant=False) 35 | P_contra = ParamSpec("P_contra", contravariant=False) 36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 37 | P_contra = ParamSpec("P_contra", covariant=True) 38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) | -type_name_incorrect_variance.py:37:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its covariance; consider renaming it to "P_co" +PLC0105 `ParamSpec` name "P_contra" does not reflect its covariance; consider renaming it to "P_co" + --> type_name_incorrect_variance.py:37:12 | 35 | P_contra = ParamSpec("P_contra", contravariant=False) 36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) 37 | P_contra = ParamSpec("P_contra", covariant=True) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) | -type_name_incorrect_variance.py:38:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its covariance; consider renaming it to "P_co" +PLC0105 `ParamSpec` name "P_contra" does not reflect its covariance; consider renaming it to "P_co" + --> type_name_incorrect_variance.py:38:12 | 36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) 37 | P_contra = ParamSpec("P_contra", covariant=True) 38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) - | ^^^^^^^^^ PLC0105 + | ^^^^^^^^^ 39 | 40 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap index f639f50c42..9a51f94be2 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -type_bivariance.py:5:5: PLC0131 `TypeVar` "T" cannot be both covariant and contravariant +PLC0131 `TypeVar` "T" cannot be both covariant and contravariant + --> type_bivariance.py:5:5 | 3 | # Errors. 4 | 5 | T = TypeVar("T", covariant=True, contravariant=True) - | ^^^^^^^ PLC0131 + | ^^^^^^^ 6 | T = TypeVar(name="T", covariant=True, contravariant=True) | -type_bivariance.py:6:5: PLC0131 `TypeVar` "T" cannot be both covariant and contravariant +PLC0131 `TypeVar` "T" cannot be both covariant and contravariant + --> type_bivariance.py:6:5 | 5 | T = TypeVar("T", covariant=True, contravariant=True) 6 | T = TypeVar(name="T", covariant=True, contravariant=True) - | ^^^^^^^ PLC0131 + | ^^^^^^^ 7 | 8 | T = ParamSpec("T", covariant=True, contravariant=True) | -type_bivariance.py:8:5: PLC0131 `ParamSpec` "T" cannot be both covariant and contravariant +PLC0131 `ParamSpec` "T" cannot be both covariant and contravariant + --> type_bivariance.py:8:5 | 6 | T = TypeVar(name="T", covariant=True, contravariant=True) 7 | 8 | T = ParamSpec("T", covariant=True, contravariant=True) - | ^^^^^^^^^ PLC0131 + | ^^^^^^^^^ 9 | T = ParamSpec(name="T", covariant=True, contravariant=True) | -type_bivariance.py:9:5: PLC0131 `ParamSpec` "T" cannot be both covariant and contravariant +PLC0131 `ParamSpec` "T" cannot be both covariant and contravariant + --> type_bivariance.py:9:5 | 8 | T = ParamSpec("T", covariant=True, contravariant=True) 9 | T = ParamSpec(name="T", covariant=True, contravariant=True) - | ^^^^^^^^^ PLC0131 + | ^^^^^^^^^ 10 | 11 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap index f2d9025bfe..b16d5496b1 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap @@ -1,74 +1,82 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -type_param_name_mismatch.py:5:5: PLC0132 `TypeVar` name `T` does not match assigned variable name `X` +PLC0132 `TypeVar` name `T` does not match assigned variable name `X` + --> type_param_name_mismatch.py:5:5 | 3 | # Errors. 4 | 5 | X = TypeVar("T") - | ^^^^^^^^^^^^ PLC0132 + | ^^^^^^^^^^^^ 6 | X = TypeVar(name="T") | -type_param_name_mismatch.py:6:5: PLC0132 `TypeVar` name `T` does not match assigned variable name `X` +PLC0132 `TypeVar` name `T` does not match assigned variable name `X` + --> type_param_name_mismatch.py:6:5 | 5 | X = TypeVar("T") 6 | X = TypeVar(name="T") - | ^^^^^^^^^^^^^^^^^ PLC0132 + | ^^^^^^^^^^^^^^^^^ 7 | 8 | Y = ParamSpec("T") | -type_param_name_mismatch.py:8:5: PLC0132 `ParamSpec` name `T` does not match assigned variable name `Y` +PLC0132 `ParamSpec` name `T` does not match assigned variable name `Y` + --> type_param_name_mismatch.py:8:5 | 6 | X = TypeVar(name="T") 7 | 8 | Y = ParamSpec("T") - | ^^^^^^^^^^^^^^ PLC0132 + | ^^^^^^^^^^^^^^ 9 | Y = ParamSpec(name="T") | -type_param_name_mismatch.py:9:5: PLC0132 `ParamSpec` name `T` does not match assigned variable name `Y` +PLC0132 `ParamSpec` name `T` does not match assigned variable name `Y` + --> type_param_name_mismatch.py:9:5 | 8 | Y = ParamSpec("T") 9 | Y = ParamSpec(name="T") - | ^^^^^^^^^^^^^^^^^^^ PLC0132 + | ^^^^^^^^^^^^^^^^^^^ 10 | 11 | Z = NewType("T", int) | -type_param_name_mismatch.py:11:5: PLC0132 `NewType` name `T` does not match assigned variable name `Z` +PLC0132 `NewType` name `T` does not match assigned variable name `Z` + --> type_param_name_mismatch.py:11:5 | 9 | Y = ParamSpec(name="T") 10 | 11 | Z = NewType("T", int) - | ^^^^^^^^^^^^^^^^^ PLC0132 + | ^^^^^^^^^^^^^^^^^ 12 | Z = NewType(name="T", tp=int) | -type_param_name_mismatch.py:12:5: PLC0132 `NewType` name `T` does not match assigned variable name `Z` +PLC0132 `NewType` name `T` does not match assigned variable name `Z` + --> type_param_name_mismatch.py:12:5 | 11 | Z = NewType("T", int) 12 | Z = NewType(name="T", tp=int) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0132 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | Ws = TypeVarTuple("Ts") | -type_param_name_mismatch.py:14:6: PLC0132 `TypeVarTuple` name `Ts` does not match assigned variable name `Ws` +PLC0132 `TypeVarTuple` name `Ts` does not match assigned variable name `Ws` + --> type_param_name_mismatch.py:14:6 | 12 | Z = NewType(name="T", tp=int) 13 | 14 | Ws = TypeVarTuple("Ts") - | ^^^^^^^^^^^^^^^^^^ PLC0132 + | ^^^^^^^^^^^^^^^^^^ 15 | Ws = TypeVarTuple(name="Ts") | -type_param_name_mismatch.py:15:6: PLC0132 `TypeVarTuple` name `Ts` does not match assigned variable name `Ws` +PLC0132 `TypeVarTuple` name `Ts` does not match assigned variable name `Ws` + --> type_param_name_mismatch.py:15:6 | 14 | Ws = TypeVarTuple("Ts") 15 | Ws = TypeVarTuple(name="Ts") - | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0132 + | ^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap index eeb9f628e5..08d72fd335 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap @@ -1,30 +1,33 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -single_string_slots.py:3:5: PLC0205 Class `__slots__` should be a non-string iterable +PLC0205 Class `__slots__` should be a non-string iterable + --> single_string_slots.py:3:5 | 1 | # Errors. 2 | class Foo: 3 | __slots__ = "bar" - | ^^^^^^^^^^^^^^^^^ PLC0205 + | ^^^^^^^^^^^^^^^^^ 4 | 5 | def __init__(self, bar): | -single_string_slots.py:10:5: PLC0205 Class `__slots__` should be a non-string iterable +PLC0205 Class `__slots__` should be a non-string iterable + --> single_string_slots.py:10:5 | 9 | class Foo: 10 | __slots__: str = "bar" - | ^^^^^^^^^^^^^^^^^^^^^^ PLC0205 + | ^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | def __init__(self, bar): | -single_string_slots.py:17:5: PLC0205 Class `__slots__` should be a non-string iterable +PLC0205 Class `__slots__` should be a non-string iterable + --> single_string_slots.py:17:5 | 16 | class Foo: 17 | __slots__: str = f"bar" - | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0205 + | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | def __init__(self, bar): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0206_dict_index_missing_items.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0206_dict_index_missing_items.py.snap index a2f87d2e5d..0979b05ae8 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0206_dict_index_missing_items.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0206_dict_index_missing_items.py.snap @@ -1,67 +1,73 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -dict_index_missing_items.py:9:1: PLC0206 Extracting value from dictionary without calling `.items()` +PLC0206 Extracting value from dictionary without calling `.items()` + --> dict_index_missing_items.py:9:1 | 8 | # Errors 9 | / for instrument in ORCHESTRA: 10 | | print(f"{instrument}: {ORCHESTRA[instrument]}") - | |___________________________________________________^ PLC0206 + | |___________________________________________________^ 11 | 12 | for instrument in ORCHESTRA: | -dict_index_missing_items.py:12:1: PLC0206 Extracting value from dictionary without calling `.items()` +PLC0206 Extracting value from dictionary without calling `.items()` + --> dict_index_missing_items.py:12:1 | 10 | print(f"{instrument}: {ORCHESTRA[instrument]}") 11 | 12 | / for instrument in ORCHESTRA: 13 | | ORCHESTRA[instrument] - | |_________________________^ PLC0206 + | |_________________________^ 14 | 15 | for instrument in ORCHESTRA.keys(): | -dict_index_missing_items.py:15:1: PLC0206 Extracting value from dictionary without calling `.items()` +PLC0206 Extracting value from dictionary without calling `.items()` + --> dict_index_missing_items.py:15:1 | 13 | ORCHESTRA[instrument] 14 | 15 | / for instrument in ORCHESTRA.keys(): 16 | | print(f"{instrument}: {ORCHESTRA[instrument]}") - | |___________________________________________________^ PLC0206 + | |___________________________________________________^ 17 | 18 | for instrument in ORCHESTRA.keys(): | -dict_index_missing_items.py:18:1: PLC0206 Extracting value from dictionary without calling `.items()` +PLC0206 Extracting value from dictionary without calling `.items()` + --> dict_index_missing_items.py:18:1 | 16 | print(f"{instrument}: {ORCHESTRA[instrument]}") 17 | 18 | / for instrument in ORCHESTRA.keys(): 19 | | ORCHESTRA[instrument] - | |_________________________^ PLC0206 + | |_________________________^ 20 | 21 | for instrument in (temp_orchestra := {"violin": "strings", "oboe": "woodwind"}): | -dict_index_missing_items.py:21:1: PLC0206 Extracting value from dictionary without calling `.items()` +PLC0206 Extracting value from dictionary without calling `.items()` + --> dict_index_missing_items.py:21:1 | 19 | ORCHESTRA[instrument] 20 | 21 | / for instrument in (temp_orchestra := {"violin": "strings", "oboe": "woodwind"}): 22 | | print(f"{instrument}: {temp_orchestra[instrument]}") - | |________________________________________________________^ PLC0206 + | |________________________________________________________^ 23 | 24 | for instrument in (temp_orchestra := {"violin": "strings", "oboe": "woodwind"}): | -dict_index_missing_items.py:24:1: PLC0206 Extracting value from dictionary without calling `.items()` +PLC0206 Extracting value from dictionary without calling `.items()` + --> dict_index_missing_items.py:24:1 | 22 | print(f"{instrument}: {temp_orchestra[instrument]}") 23 | 24 | / for instrument in (temp_orchestra := {"violin": "strings", "oboe": "woodwind"}): 25 | | temp_orchestra[instrument] - | |______________________________^ PLC0206 + | |______________________________^ 26 | 27 | # # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0207_missing_maxsplit_arg.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0207_missing_maxsplit_arg.py.snap index aed7f02a57..9e974b0905 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0207_missing_maxsplit_arg.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0207_missing_maxsplit_arg.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -missing_maxsplit_arg.py:14:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:14:1 | 12 | # Errors 13 | ## Test split called directly on string literal 14 | "1,2,3".split(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^ 15 | "1,2,3".split(",")[-1] # [missing-maxsplit-arg] 16 | "1,2,3".rsplit(",")[0] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 11 11 | @@ -22,16 +23,17 @@ missing_maxsplit_arg.py:14:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 16 16 | "1,2,3".rsplit(",")[0] # [missing-maxsplit-arg] 17 17 | "1,2,3".rsplit(",")[-1] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:15:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:15:1 | 13 | ## Test split called directly on string literal 14 | "1,2,3".split(",")[0] # [missing-maxsplit-arg] 15 | "1,2,3".split(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^ 16 | "1,2,3".rsplit(",")[0] # [missing-maxsplit-arg] 17 | "1,2,3".rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.rsplit()` and pass `maxsplit=1` +help: Use `str.rsplit()` and pass `maxsplit=1` ℹ Safe fix 12 12 | # Errors @@ -43,15 +45,16 @@ missing_maxsplit_arg.py:15:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 17 17 | "1,2,3".rsplit(",")[-1] # [missing-maxsplit-arg] 18 18 | -missing_maxsplit_arg.py:16:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:16:1 | 14 | "1,2,3".split(",")[0] # [missing-maxsplit-arg] 15 | "1,2,3".split(",")[-1] # [missing-maxsplit-arg] 16 | "1,2,3".rsplit(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^ 17 | "1,2,3".rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.split()` and pass `maxsplit=1` +help: Use `str.split()` and pass `maxsplit=1` ℹ Safe fix 13 13 | ## Test split called directly on string literal @@ -63,16 +66,17 @@ missing_maxsplit_arg.py:16:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 18 18 | 19 19 | ## Test split called on string variable -missing_maxsplit_arg.py:17:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:17:1 | 15 | "1,2,3".split(",")[-1] # [missing-maxsplit-arg] 16 | "1,2,3".rsplit(",")[0] # [missing-maxsplit-arg] 17 | "1,2,3".rsplit(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | ## Test split called on string variable | - = help: Pass `maxsplit=1` into `str.rsplit()` +help: Pass `maxsplit=1` into `str.rsplit()` ℹ Safe fix 14 14 | "1,2,3".split(",")[0] # [missing-maxsplit-arg] @@ -84,15 +88,16 @@ missing_maxsplit_arg.py:17:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 19 19 | ## Test split called on string variable 20 20 | SEQ.split(",")[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:20:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:20:1 | 19 | ## Test split called on string variable 20 | SEQ.split(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^ 21 | SEQ.split(",")[-1] # [missing-maxsplit-arg] 22 | SEQ.rsplit(",")[0] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 17 17 | "1,2,3".rsplit(",")[-1] # [missing-maxsplit-arg] @@ -104,16 +109,17 @@ missing_maxsplit_arg.py:20:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 22 22 | SEQ.rsplit(",")[0] # [missing-maxsplit-arg] 23 23 | SEQ.rsplit(",")[-1] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:21:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:21:1 | 19 | ## Test split called on string variable 20 | SEQ.split(",")[0] # [missing-maxsplit-arg] 21 | SEQ.split(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^ 22 | SEQ.rsplit(",")[0] # [missing-maxsplit-arg] 23 | SEQ.rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.rsplit()` and pass `maxsplit=1` +help: Use `str.rsplit()` and pass `maxsplit=1` ℹ Safe fix 18 18 | @@ -125,15 +131,16 @@ missing_maxsplit_arg.py:21:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 23 23 | SEQ.rsplit(",")[-1] # [missing-maxsplit-arg] 24 24 | -missing_maxsplit_arg.py:22:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:22:1 | 20 | SEQ.split(",")[0] # [missing-maxsplit-arg] 21 | SEQ.split(",")[-1] # [missing-maxsplit-arg] 22 | SEQ.rsplit(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^ 23 | SEQ.rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.split()` and pass `maxsplit=1` +help: Use `str.split()` and pass `maxsplit=1` ℹ Safe fix 19 19 | ## Test split called on string variable @@ -145,16 +152,17 @@ missing_maxsplit_arg.py:22:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 24 24 | 25 25 | ## Test split called on class attribute -missing_maxsplit_arg.py:23:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:23:1 | 21 | SEQ.split(",")[-1] # [missing-maxsplit-arg] 22 | SEQ.rsplit(",")[0] # [missing-maxsplit-arg] 23 | SEQ.rsplit(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^ 24 | 25 | ## Test split called on class attribute | - = help: Pass `maxsplit=1` into `str.rsplit()` +help: Pass `maxsplit=1` into `str.rsplit()` ℹ Safe fix 20 20 | SEQ.split(",")[0] # [missing-maxsplit-arg] @@ -166,15 +174,16 @@ missing_maxsplit_arg.py:23:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 25 25 | ## Test split called on class attribute 26 26 | Foo.class_str.split(",")[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:26:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:26:1 | 25 | ## Test split called on class attribute 26 | Foo.class_str.split(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | Foo.class_str.split(",")[-1] # [missing-maxsplit-arg] 28 | Foo.class_str.rsplit(",")[0] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 23 23 | SEQ.rsplit(",")[-1] # [missing-maxsplit-arg] @@ -186,16 +195,17 @@ missing_maxsplit_arg.py:26:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 28 28 | Foo.class_str.rsplit(",")[0] # [missing-maxsplit-arg] 29 29 | Foo.class_str.rsplit(",")[-1] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:27:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:27:1 | 25 | ## Test split called on class attribute 26 | Foo.class_str.split(",")[0] # [missing-maxsplit-arg] 27 | Foo.class_str.split(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | Foo.class_str.rsplit(",")[0] # [missing-maxsplit-arg] 29 | Foo.class_str.rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.rsplit()` and pass `maxsplit=1` +help: Use `str.rsplit()` and pass `maxsplit=1` ℹ Safe fix 24 24 | @@ -207,15 +217,16 @@ missing_maxsplit_arg.py:27:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 29 29 | Foo.class_str.rsplit(",")[-1] # [missing-maxsplit-arg] 30 30 | -missing_maxsplit_arg.py:28:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:28:1 | 26 | Foo.class_str.split(",")[0] # [missing-maxsplit-arg] 27 | Foo.class_str.split(",")[-1] # [missing-maxsplit-arg] 28 | Foo.class_str.rsplit(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | Foo.class_str.rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.split()` and pass `maxsplit=1` +help: Use `str.split()` and pass `maxsplit=1` ℹ Safe fix 25 25 | ## Test split called on class attribute @@ -227,16 +238,17 @@ missing_maxsplit_arg.py:28:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 30 30 | 31 31 | ## Test split called on sliced string -missing_maxsplit_arg.py:29:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:29:1 | 27 | Foo.class_str.split(",")[-1] # [missing-maxsplit-arg] 28 | Foo.class_str.rsplit(",")[0] # [missing-maxsplit-arg] 29 | Foo.class_str.rsplit(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | ## Test split called on sliced string | - = help: Pass `maxsplit=1` into `str.rsplit()` +help: Pass `maxsplit=1` into `str.rsplit()` ℹ Safe fix 26 26 | Foo.class_str.split(",")[0] # [missing-maxsplit-arg] @@ -248,15 +260,16 @@ missing_maxsplit_arg.py:29:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 31 31 | ## Test split called on sliced string 32 32 | "1,2,3"[::-1].split(",")[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:32:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:32:1 | 31 | ## Test split called on sliced string 32 | "1,2,3"[::-1].split(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | "1,2,3"[::-1][::-1].split(",")[0] # [missing-maxsplit-arg] 34 | SEQ[:3].split(",")[0] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 29 29 | Foo.class_str.rsplit(",")[-1] # [missing-maxsplit-arg] @@ -268,16 +281,17 @@ missing_maxsplit_arg.py:32:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 34 34 | SEQ[:3].split(",")[0] # [missing-maxsplit-arg] 35 35 | Foo.class_str[1:3].split(",")[-1] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:33:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:33:1 | 31 | ## Test split called on sliced string 32 | "1,2,3"[::-1].split(",")[0] # [missing-maxsplit-arg] 33 | "1,2,3"[::-1][::-1].split(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | SEQ[:3].split(",")[0] # [missing-maxsplit-arg] 35 | Foo.class_str[1:3].split(",")[-1] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 30 30 | @@ -289,16 +303,17 @@ missing_maxsplit_arg.py:33:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 35 35 | Foo.class_str[1:3].split(",")[-1] # [missing-maxsplit-arg] 36 36 | "1,2,3"[::-1].rsplit(",")[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:34:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:34:1 | 32 | "1,2,3"[::-1].split(",")[0] # [missing-maxsplit-arg] 33 | "1,2,3"[::-1][::-1].split(",")[0] # [missing-maxsplit-arg] 34 | SEQ[:3].split(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^ 35 | Foo.class_str[1:3].split(",")[-1] # [missing-maxsplit-arg] 36 | "1,2,3"[::-1].rsplit(",")[0] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 31 31 | ## Test split called on sliced string @@ -310,16 +325,17 @@ missing_maxsplit_arg.py:34:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 36 36 | "1,2,3"[::-1].rsplit(",")[0] # [missing-maxsplit-arg] 37 37 | SEQ[:3].rsplit(",")[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:35:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:35:1 | 33 | "1,2,3"[::-1][::-1].split(",")[0] # [missing-maxsplit-arg] 34 | SEQ[:3].split(",")[0] # [missing-maxsplit-arg] 35 | Foo.class_str[1:3].split(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | "1,2,3"[::-1].rsplit(",")[0] # [missing-maxsplit-arg] 37 | SEQ[:3].rsplit(",")[0] # [missing-maxsplit-arg] | - = help: Use `str.rsplit()` and pass `maxsplit=1` +help: Use `str.rsplit()` and pass `maxsplit=1` ℹ Safe fix 32 32 | "1,2,3"[::-1].split(",")[0] # [missing-maxsplit-arg] @@ -331,16 +347,17 @@ missing_maxsplit_arg.py:35:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 37 37 | SEQ[:3].rsplit(",")[0] # [missing-maxsplit-arg] 38 38 | Foo.class_str[1:3].rsplit(",")[-1] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:36:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:36:1 | 34 | SEQ[:3].split(",")[0] # [missing-maxsplit-arg] 35 | Foo.class_str[1:3].split(",")[-1] # [missing-maxsplit-arg] 36 | "1,2,3"[::-1].rsplit(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | SEQ[:3].rsplit(",")[0] # [missing-maxsplit-arg] 38 | Foo.class_str[1:3].rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.split()` and pass `maxsplit=1` +help: Use `str.split()` and pass `maxsplit=1` ℹ Safe fix 33 33 | "1,2,3"[::-1][::-1].split(",")[0] # [missing-maxsplit-arg] @@ -352,15 +369,16 @@ missing_maxsplit_arg.py:36:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 38 38 | Foo.class_str[1:3].rsplit(",")[-1] # [missing-maxsplit-arg] 39 39 | -missing_maxsplit_arg.py:37:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:37:1 | 35 | Foo.class_str[1:3].split(",")[-1] # [missing-maxsplit-arg] 36 | "1,2,3"[::-1].rsplit(",")[0] # [missing-maxsplit-arg] 37 | SEQ[:3].rsplit(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^ 38 | Foo.class_str[1:3].rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.split()` and pass `maxsplit=1` +help: Use `str.split()` and pass `maxsplit=1` ℹ Safe fix 34 34 | SEQ[:3].split(",")[0] # [missing-maxsplit-arg] @@ -372,16 +390,17 @@ missing_maxsplit_arg.py:37:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 39 39 | 40 40 | ## Test sep given as named argument -missing_maxsplit_arg.py:38:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:38:1 | 36 | "1,2,3"[::-1].rsplit(",")[0] # [missing-maxsplit-arg] 37 | SEQ[:3].rsplit(",")[0] # [missing-maxsplit-arg] 38 | Foo.class_str[1:3].rsplit(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | 40 | ## Test sep given as named argument | - = help: Pass `maxsplit=1` into `str.rsplit()` +help: Pass `maxsplit=1` into `str.rsplit()` ℹ Safe fix 35 35 | Foo.class_str[1:3].split(",")[-1] # [missing-maxsplit-arg] @@ -393,15 +412,16 @@ missing_maxsplit_arg.py:38:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 40 40 | ## Test sep given as named argument 41 41 | "1,2,3".split(sep=",")[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:41:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:41:1 | 40 | ## Test sep given as named argument 41 | "1,2,3".split(sep=",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | "1,2,3".split(sep=",")[-1] # [missing-maxsplit-arg] 43 | "1,2,3".rsplit(sep=",")[0] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 38 38 | Foo.class_str[1:3].rsplit(",")[-1] # [missing-maxsplit-arg] @@ -413,16 +433,17 @@ missing_maxsplit_arg.py:41:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 43 43 | "1,2,3".rsplit(sep=",")[0] # [missing-maxsplit-arg] 44 44 | "1,2,3".rsplit(sep=",")[-1] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:42:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:42:1 | 40 | ## Test sep given as named argument 41 | "1,2,3".split(sep=",")[0] # [missing-maxsplit-arg] 42 | "1,2,3".split(sep=",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | "1,2,3".rsplit(sep=",")[0] # [missing-maxsplit-arg] 44 | "1,2,3".rsplit(sep=",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.rsplit()` and pass `maxsplit=1` +help: Use `str.rsplit()` and pass `maxsplit=1` ℹ Safe fix 39 39 | @@ -434,15 +455,16 @@ missing_maxsplit_arg.py:42:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 44 44 | "1,2,3".rsplit(sep=",")[-1] # [missing-maxsplit-arg] 45 45 | -missing_maxsplit_arg.py:43:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:43:1 | 41 | "1,2,3".split(sep=",")[0] # [missing-maxsplit-arg] 42 | "1,2,3".split(sep=",")[-1] # [missing-maxsplit-arg] 43 | "1,2,3".rsplit(sep=",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | "1,2,3".rsplit(sep=",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.split()` and pass `maxsplit=1` +help: Use `str.split()` and pass `maxsplit=1` ℹ Safe fix 40 40 | ## Test sep given as named argument @@ -454,16 +476,17 @@ missing_maxsplit_arg.py:43:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 45 45 | 46 46 | ## Special cases -missing_maxsplit_arg.py:44:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:44:1 | 42 | "1,2,3".split(sep=",")[-1] # [missing-maxsplit-arg] 43 | "1,2,3".rsplit(sep=",")[0] # [missing-maxsplit-arg] 44 | "1,2,3".rsplit(sep=",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | ## Special cases | - = help: Pass `maxsplit=1` into `str.rsplit()` +help: Pass `maxsplit=1` into `str.rsplit()` ℹ Safe fix 41 41 | "1,2,3".split(sep=",")[0] # [missing-maxsplit-arg] @@ -475,15 +498,16 @@ missing_maxsplit_arg.py:44:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 46 46 | ## Special cases 47 47 | "1,2,3".split("\n")[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:47:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:47:1 | 46 | ## Special cases 47 | "1,2,3".split("\n")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^ 48 | "1,2,3".split("split")[-1] # [missing-maxsplit-arg] 49 | "1,2,3".rsplit("rsplit")[0] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 44 44 | "1,2,3".rsplit(sep=",")[-1] # [missing-maxsplit-arg] @@ -495,15 +519,16 @@ missing_maxsplit_arg.py:47:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 49 49 | "1,2,3".rsplit("rsplit")[0] # [missing-maxsplit-arg] 50 50 | -missing_maxsplit_arg.py:48:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:48:1 | 46 | ## Special cases 47 | "1,2,3".split("\n")[0] # [missing-maxsplit-arg] 48 | "1,2,3".split("split")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 49 | "1,2,3".rsplit("rsplit")[0] # [missing-maxsplit-arg] | - = help: Use `str.rsplit()` and pass `maxsplit=1` +help: Use `str.rsplit()` and pass `maxsplit=1` ℹ Safe fix 45 45 | @@ -515,16 +540,17 @@ missing_maxsplit_arg.py:48:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 50 50 | 51 51 | ## Test class attribute named split -missing_maxsplit_arg.py:49:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:49:1 | 47 | "1,2,3".split("\n")[0] # [missing-maxsplit-arg] 48 | "1,2,3".split("split")[-1] # [missing-maxsplit-arg] 49 | "1,2,3".rsplit("rsplit")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | ## Test class attribute named split | - = help: Use `str.split()` and pass `maxsplit=1` +help: Use `str.split()` and pass `maxsplit=1` ℹ Safe fix 46 46 | ## Special cases @@ -536,15 +562,16 @@ missing_maxsplit_arg.py:49:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 51 51 | ## Test class attribute named split 52 52 | Bar.split.split(",")[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:52:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:52:1 | 51 | ## Test class attribute named split 52 | Bar.split.split(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^ 53 | Bar.split.split(",")[-1] # [missing-maxsplit-arg] 54 | Bar.split.rsplit(",")[0] # [missing-maxsplit-arg] | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Safe fix 49 49 | "1,2,3".rsplit("rsplit")[0] # [missing-maxsplit-arg] @@ -556,16 +583,17 @@ missing_maxsplit_arg.py:52:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 54 54 | Bar.split.rsplit(",")[0] # [missing-maxsplit-arg] 55 55 | Bar.split.rsplit(",")[-1] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:53:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:53:1 | 51 | ## Test class attribute named split 52 | Bar.split.split(",")[0] # [missing-maxsplit-arg] 53 | Bar.split.split(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 54 | Bar.split.rsplit(",")[0] # [missing-maxsplit-arg] 55 | Bar.split.rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.rsplit()` and pass `maxsplit=1` +help: Use `str.rsplit()` and pass `maxsplit=1` ℹ Safe fix 50 50 | @@ -577,15 +605,16 @@ missing_maxsplit_arg.py:53:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 55 55 | Bar.split.rsplit(",")[-1] # [missing-maxsplit-arg] 56 56 | -missing_maxsplit_arg.py:54:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:54:1 | 52 | Bar.split.split(",")[0] # [missing-maxsplit-arg] 53 | Bar.split.split(",")[-1] # [missing-maxsplit-arg] 54 | Bar.split.rsplit(",")[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 55 | Bar.split.rsplit(",")[-1] # [missing-maxsplit-arg] | - = help: Use `str.split()` and pass `maxsplit=1` +help: Use `str.split()` and pass `maxsplit=1` ℹ Safe fix 51 51 | ## Test class attribute named split @@ -597,16 +626,17 @@ missing_maxsplit_arg.py:54:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 56 56 | 57 57 | ## Test unpacked dict literal kwargs -missing_maxsplit_arg.py:55:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. +PLC0207 [*] Replace with `rsplit(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:55:1 | 53 | Bar.split.split(",")[-1] # [missing-maxsplit-arg] 54 | Bar.split.rsplit(",")[0] # [missing-maxsplit-arg] 55 | Bar.split.rsplit(",")[-1] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | 57 | ## Test unpacked dict literal kwargs | - = help: Pass `maxsplit=1` into `str.rsplit()` +help: Pass `maxsplit=1` into `str.rsplit()` ℹ Safe fix 52 52 | Bar.split.split(",")[0] # [missing-maxsplit-arg] @@ -618,13 +648,14 @@ missing_maxsplit_arg.py:55:1: PLC0207 [*] Replace with `rsplit(..., maxsplit=1)` 57 57 | ## Test unpacked dict literal kwargs 58 58 | "1,2,3".split(**{"sep": ","})[0] # [missing-maxsplit-arg] -missing_maxsplit_arg.py:58:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:58:1 | 57 | ## Test unpacked dict literal kwargs 58 | "1,2,3".split(**{"sep": ","})[0] # [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Unsafe fix 55 55 | Bar.split.rsplit(",")[-1] # [missing-maxsplit-arg] @@ -636,16 +667,17 @@ missing_maxsplit_arg.py:58:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. 60 60 | 61 61 | # OK -missing_maxsplit_arg.py:179:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:179:1 | 177 | # Errors 178 | kwargs_without_maxsplit = {"seq": ","} 179 | "1,2,3".split(**kwargs_without_maxsplit)[0] # TODO: [missing-maxsplit-arg] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 180 | # OK 181 | kwargs_with_maxsplit = {"maxsplit": 1} | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Unsafe fix 176 176 | ## TODO: These require the ability to resolve a dict variable name to a value @@ -657,16 +689,17 @@ missing_maxsplit_arg.py:179:1: PLC0207 [*] Replace with `split(..., maxsplit=1)` 181 181 | kwargs_with_maxsplit = {"maxsplit": 1} 182 182 | "1,2,3".split(",", **kwargs_with_maxsplit)[0] # TODO: false positive -missing_maxsplit_arg.py:182:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:182:1 | 180 | # OK 181 | kwargs_with_maxsplit = {"maxsplit": 1} 182 | "1,2,3".split(",", **kwargs_with_maxsplit)[0] # TODO: false positive - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 183 | kwargs_with_maxsplit = {"sep": ",", "maxsplit": 1} 184 | "1,2,3".split(**kwargs_with_maxsplit)[0] # TODO: false positive | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Unsafe fix 179 179 | "1,2,3".split(**kwargs_without_maxsplit)[0] # TODO: [missing-maxsplit-arg] @@ -678,14 +711,15 @@ missing_maxsplit_arg.py:182:1: PLC0207 [*] Replace with `split(..., maxsplit=1)` 184 184 | "1,2,3".split(**kwargs_with_maxsplit)[0] # TODO: false positive 185 185 | -missing_maxsplit_arg.py:184:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:184:1 | 182 | "1,2,3".split(",", **kwargs_with_maxsplit)[0] # TODO: false positive 183 | kwargs_with_maxsplit = {"sep": ",", "maxsplit": 1} 184 | "1,2,3".split(**kwargs_with_maxsplit)[0] # TODO: false positive - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Unsafe fix 181 181 | kwargs_with_maxsplit = {"maxsplit": 1} @@ -697,16 +731,17 @@ missing_maxsplit_arg.py:184:1: PLC0207 [*] Replace with `split(..., maxsplit=1)` 186 186 | 187 187 | ## Test unpacked list literal args (starred expressions) -missing_maxsplit_arg.py:189:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:189:1 | 187 | ## Test unpacked list literal args (starred expressions) 188 | # Errors 189 | "1,2,3".split(",", *[-1])[0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 190 | 191 | ## Test unpacked list variable args | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Unsafe fix 186 186 | @@ -718,14 +753,15 @@ missing_maxsplit_arg.py:189:1: PLC0207 [*] Replace with `split(..., maxsplit=1)` 191 191 | ## Test unpacked list variable args 192 192 | # Errors -missing_maxsplit_arg.py:194:1: PLC0207 [*] Replace with `split(..., maxsplit=1)`. +PLC0207 [*] Replace with `split(..., maxsplit=1)`. + --> missing_maxsplit_arg.py:194:1 | 192 | # Errors 193 | args_list = [-1] 194 | "1,2,3".split(",", *args_list)[0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0207 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Pass `maxsplit=1` into `str.split()` +help: Pass `maxsplit=1` into `str.split()` ℹ Unsafe fix 191 191 | ## Test unpacked list variable args diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap index 952670e665..a8aa72f1c5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -iteration_over_set.py:3:13: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values +PLC0208 [*] Use a sequence type instead of a `set` when iterating over values + --> iteration_over_set.py:3:13 | 1 | # Errors 2 | 3 | for item in {1}: - | ^^^ PLC0208 + | ^^^ 4 | print(f"I can count to {item}!") | - = help: Convert to `tuple` +help: Convert to `tuple` ℹ Safe fix 1 1 | # Errors @@ -20,15 +21,16 @@ iteration_over_set.py:3:13: PLC0208 [*] Use a sequence type instead of a `set` w 5 5 | 6 6 | for item in {"apples", "lemons", "water"}: # flags in-line set literals -iteration_over_set.py:6:13: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values +PLC0208 [*] Use a sequence type instead of a `set` when iterating over values + --> iteration_over_set.py:6:13 | 4 | print(f"I can count to {item}!") 5 | 6 | for item in {"apples", "lemons", "water"}: # flags in-line set literals - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0208 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | print(f"I like {item}.") | - = help: Convert to `tuple` +help: Convert to `tuple` ℹ Safe fix 3 3 | for item in {1}: @@ -40,15 +42,16 @@ iteration_over_set.py:6:13: PLC0208 [*] Use a sequence type instead of a `set` w 8 8 | 9 9 | for item in {1,}: -iteration_over_set.py:9:13: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values +PLC0208 [*] Use a sequence type instead of a `set` when iterating over values + --> iteration_over_set.py:9:13 | 7 | print(f"I like {item}.") 8 | 9 | for item in {1,}: - | ^^^^ PLC0208 + | ^^^^ 10 | print(f"I can count to {item}!") | - = help: Convert to `tuple` +help: Convert to `tuple` ℹ Safe fix 6 6 | for item in {"apples", "lemons", "water"}: # flags in-line set literals @@ -60,7 +63,8 @@ iteration_over_set.py:9:13: PLC0208 [*] Use a sequence type instead of a `set` w 11 11 | 12 12 | for item in { -iteration_over_set.py:12:13: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values +PLC0208 [*] Use a sequence type instead of a `set` when iterating over values + --> iteration_over_set.py:12:13 | 10 | print(f"I can count to {item}!") 11 | @@ -68,10 +72,10 @@ iteration_over_set.py:12:13: PLC0208 [*] Use a sequence type instead of a `set` | _____________^ 13 | | "apples", "lemons", "water" 14 | | }: # flags in-line set literals - | |_^ PLC0208 + | |_^ 15 | print(f"I like {item}.") | - = help: Convert to `tuple` +help: Convert to `tuple` ℹ Safe fix 9 9 | for item in {1,}: @@ -86,16 +90,17 @@ iteration_over_set.py:12:13: PLC0208 [*] Use a sequence type instead of a `set` 16 16 | 17 17 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions -iteration_over_set.py:17:28: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values +PLC0208 [*] Use a sequence type instead of a `set` when iterating over values + --> iteration_over_set.py:17:28 | 15 | print(f"I like {item}.") 16 | 17 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions - | ^^^^^^^^^ PLC0208 + | ^^^^^^^^^ 18 | 19 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions | - = help: Convert to `tuple` +help: Convert to `tuple` ℹ Safe fix 14 14 | }: # flags in-line set literals @@ -107,16 +112,17 @@ iteration_over_set.py:17:28: PLC0208 [*] Use a sequence type instead of a `set` 19 19 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions 20 20 | -iteration_over_set.py:19:27: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values +PLC0208 [*] Use a sequence type instead of a `set` when iterating over values + --> iteration_over_set.py:19:27 | 17 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions 18 | 19 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions - | ^^^^^^^^^ PLC0208 + | ^^^^^^^^^ 20 | 21 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions | - = help: Convert to `tuple` +help: Convert to `tuple` ℹ Safe fix 16 16 | @@ -128,16 +134,17 @@ iteration_over_set.py:19:27: PLC0208 [*] Use a sequence type instead of a `set` 21 21 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions 22 22 | -iteration_over_set.py:21:36: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values +PLC0208 [*] Use a sequence type instead of a `set` when iterating over values + --> iteration_over_set.py:21:36 | 19 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions 20 | 21 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions - | ^^^^^^^^^ PLC0208 + | ^^^^^^^^^ 22 | 23 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions | - = help: Convert to `tuple` +help: Convert to `tuple` ℹ Safe fix 18 18 | @@ -149,16 +156,17 @@ iteration_over_set.py:21:36: PLC0208 [*] Use a sequence type instead of a `set` 23 23 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions 24 24 | -iteration_over_set.py:23:27: PLC0208 [*] Use a sequence type instead of a `set` when iterating over values +PLC0208 [*] Use a sequence type instead of a `set` when iterating over values + --> iteration_over_set.py:23:27 | 21 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions 22 | 23 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions - | ^^^^^^^^^ PLC0208 + | ^^^^^^^^^ 24 | 25 | # Non-errors | - = help: Convert to `tuple` +help: Convert to `tuple` ℹ Safe fix 20 20 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap index 483c266aa6..df64c6bbfb 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -import_aliasing.py:6:8: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> import_aliasing.py:6:8 | 4 | # 2. consider-using-from-import 5 | 6 | import collections as collections # [useless-import-alias] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] 8 | from collections import OrderedDict as o_dict | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 3 3 | # 1. useless-import-alias @@ -22,15 +23,16 @@ import_aliasing.py:6:8: PLC0414 [*] Import alias does not rename original packag 8 8 | from collections import OrderedDict as o_dict 9 9 | import os.path as path # [consider-using-from-import] -import_aliasing.py:7:25: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> import_aliasing.py:7:25 | 6 | import collections as collections # [useless-import-alias] 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | from collections import OrderedDict as o_dict 9 | import os.path as path # [consider-using-from-import] | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 4 4 | # 2. consider-using-from-import @@ -42,16 +44,17 @@ import_aliasing.py:7:25: PLC0414 [*] Import alias does not rename original packa 9 9 | import os.path as path # [consider-using-from-import] 10 10 | import os.path as p -import_aliasing.py:16:15: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> import_aliasing.py:16:15 | 14 | import os as OS 15 | from sys import version 16 | from . import bar as bar # [useless-import-alias] - | ^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^ 17 | from . import bar as Bar 18 | from . import bar | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 13 13 | import os @@ -63,16 +66,17 @@ import_aliasing.py:16:15: PLC0414 [*] Import alias does not rename original pack 18 18 | from . import bar 19 19 | from ..foo import bar as bar # [useless-import-alias] -import_aliasing.py:19:19: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> import_aliasing.py:19:19 | 17 | from . import bar as Bar 18 | from . import bar 19 | from ..foo import bar as bar # [useless-import-alias] - | ^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^ 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] 21 | from ..foo.bar import foobar as anotherfoobar | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 16 16 | from . import bar as bar # [useless-import-alias] @@ -84,16 +88,17 @@ import_aliasing.py:19:19: PLC0414 [*] Import alias does not rename original pack 21 21 | from ..foo.bar import foobar as anotherfoobar 22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] -import_aliasing.py:20:23: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> import_aliasing.py:20:23 | 18 | from . import bar 19 | from ..foo import bar as bar # [useless-import-alias] 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] - | ^^^^^^^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^^^^^^^ 21 | from ..foo.bar import foobar as anotherfoobar 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 17 17 | from . import bar as Bar @@ -105,16 +110,17 @@ import_aliasing.py:20:23: PLC0414 [*] Import alias does not rename original pack 22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] 23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] -import_aliasing.py:22:15: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> import_aliasing.py:22:15 | 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] 21 | from ..foo.bar import foobar as anotherfoobar 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] - | ^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^ 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] 24 | from . import foo as bar, foo2 as bar2 | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 19 19 | from ..foo import bar as bar # [useless-import-alias] @@ -126,16 +132,17 @@ import_aliasing.py:22:15: PLC0414 [*] Import alias does not rename original pack 24 24 | from . import foo as bar, foo2 as bar2 25 25 | from foo.bar import foobar as foobar # [useless-import-alias] -import_aliasing.py:23:27: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> import_aliasing.py:23:27 | 21 | from ..foo.bar import foobar as anotherfoobar 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] - | ^^^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^^^ 24 | from . import foo as bar, foo2 as bar2 25 | from foo.bar import foobar as foobar # [useless-import-alias] | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] @@ -147,16 +154,17 @@ import_aliasing.py:23:27: PLC0414 [*] Import alias does not rename original pack 25 25 | from foo.bar import foobar as foobar # [useless-import-alias] 26 26 | from foo.bar import foobar as foo -import_aliasing.py:25:21: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> import_aliasing.py:25:21 | 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] 24 | from . import foo as bar, foo2 as bar2 25 | from foo.bar import foobar as foobar # [useless-import-alias] - | ^^^^^^^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^^^^^^^ 26 | from foo.bar import foobar as foo 27 | from .foo.bar import f as foobar | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing_2____init__.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing_2____init__.py.snap index 101902f311..5ab1f223aa 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing_2____init__.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing_2____init__.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -__init__.py:1:8: PLC0414 [*] Import alias does not rename original package +PLC0414 [*] Import alias does not rename original package + --> __init__.py:1:8 | 1 | import collections as collections - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0414 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | from collections import OrderedDict as OrderedDict 3 | from . import foo as foo | - = help: Remove import alias +help: Remove import alias ℹ Unsafe fix 1 |-import collections as collections diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0415_import_outside_top_level.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0415_import_outside_top_level.py.snap index 36490ce904..7c8239ba65 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0415_import_outside_top_level.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0415_import_outside_top_level.py.snap @@ -1,74 +1,82 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -import_outside_top_level.py:10:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level.py:10:5 | 9 | def import_in_function(): 10 | import symtable # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^ 11 | import os, sys # [import-outside-toplevel] 12 | import time as thyme # [import-outside-toplevel] | -import_outside_top_level.py:11:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level.py:11:5 | 9 | def import_in_function(): 10 | import symtable # [import-outside-toplevel] 11 | import os, sys # [import-outside-toplevel] - | ^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^ 12 | import time as thyme # [import-outside-toplevel] 13 | import random as rand, socket as sock # [import-outside-toplevel] | -import_outside_top_level.py:12:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level.py:12:5 | 10 | import symtable # [import-outside-toplevel] 11 | import os, sys # [import-outside-toplevel] 12 | import time as thyme # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^ 13 | import random as rand, socket as sock # [import-outside-toplevel] 14 | from collections import defaultdict # [import-outside-toplevel] | -import_outside_top_level.py:13:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level.py:13:5 | 11 | import os, sys # [import-outside-toplevel] 12 | import time as thyme # [import-outside-toplevel] 13 | import random as rand, socket as sock # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | from collections import defaultdict # [import-outside-toplevel] 15 | from math import sin as sign, cos as cosplay # [import-outside-toplevel] | -import_outside_top_level.py:14:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level.py:14:5 | 12 | import time as thyme # [import-outside-toplevel] 13 | import random as rand, socket as sock # [import-outside-toplevel] 14 | from collections import defaultdict # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | from math import sin as sign, cos as cosplay # [import-outside-toplevel] | -import_outside_top_level.py:15:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level.py:15:5 | 13 | import random as rand, socket as sock # [import-outside-toplevel] 14 | from collections import defaultdict # [import-outside-toplevel] 15 | from math import sin as sign, cos as cosplay # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -import_outside_top_level.py:19:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level.py:19:5 | 18 | class ClassWithImports: 19 | import tokenize # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^ 20 | 21 | def __init__(self): | -import_outside_top_level.py:22:9: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level.py:22:9 | 21 | def __init__(self): 22 | import trace # [import-outside-toplevel] - | ^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1802_len_as_condition.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1802_len_as_condition.py.snap index 93d27a1605..ad3929bb35 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1802_len_as_condition.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1802_len_as_condition.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -len_as_condition.py:1:4: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:1:4 | 1 | if len('TEST'): # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 2 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 1 |-if len('TEST'): # [PLC1802] @@ -16,15 +17,16 @@ len_as_condition.py:1:4: PLC1802 [*] `len('TEST')` used as condition without com 3 3 | 4 4 | if not len('TEST'): # [PLC1802] -len_as_condition.py:4:8: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:4:8 | 2 | pass 3 | 4 | if not len('TEST'): # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 5 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 1 1 | if len('TEST'): # [PLC1802] @@ -36,14 +38,15 @@ len_as_condition.py:4:8: PLC1802 [*] `len('TEST')` used as condition without com 6 6 | 7 7 | z = [] -len_as_condition.py:8:10: PLC1802 [*] `len(['T', 'E', 'S', 'T'])` used as condition without comparison +PLC1802 [*] `len(['T', 'E', 'S', 'T'])` used as condition without comparison + --> len_as_condition.py:8:10 | 7 | z = [] 8 | if z and len(['T', 'E', 'S', 'T']): # [PLC1802] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 5 5 | pass @@ -55,15 +58,16 @@ len_as_condition.py:8:10: PLC1802 [*] `len(['T', 'E', 'S', 'T'])` used as condit 10 10 | 11 11 | if True or len('TEST'): # [PLC1802] -len_as_condition.py:11:12: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:11:12 | 9 | pass 10 | 11 | if True or len('TEST'): # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 12 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 8 8 | if z and len(['T', 'E', 'S', 'T']): # [PLC1802] @@ -75,15 +79,16 @@ len_as_condition.py:11:12: PLC1802 [*] `len('TEST')` used as condition without c 13 13 | 14 14 | if len('TEST') == 0: # Should be fine -len_as_condition.py:53:6: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:53:6 | 51 | if z: 52 | pass 53 | elif len('TEST'): # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 54 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 50 50 | @@ -95,15 +100,16 @@ len_as_condition.py:53:6: PLC1802 [*] `len('TEST')` used as condition without co 55 55 | 56 56 | if z: -len_as_condition.py:58:10: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:58:10 | 56 | if z: 57 | pass 58 | elif not len('TEST'): # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 59 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 55 55 | @@ -115,15 +121,16 @@ len_as_condition.py:58:10: PLC1802 [*] `len('TEST')` used as condition without c 60 60 | 61 61 | while len('TEST'): # [PLC1802] -len_as_condition.py:61:7: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:61:7 | 59 | pass 60 | 61 | while len('TEST'): # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 62 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 58 58 | elif not len('TEST'): # [PLC1802] @@ -135,15 +142,16 @@ len_as_condition.py:61:7: PLC1802 [*] `len('TEST')` used as condition without co 63 63 | 64 64 | while not len('TEST'): # [PLC1802] -len_as_condition.py:64:11: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:64:11 | 62 | pass 63 | 64 | while not len('TEST'): # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 65 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 61 61 | while len('TEST'): # [PLC1802] @@ -155,15 +163,16 @@ len_as_condition.py:64:11: PLC1802 [*] `len('TEST')` used as condition without c 66 66 | 67 67 | while z and len('TEST'): # [PLC1802] -len_as_condition.py:67:13: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:67:13 | 65 | pass 66 | 67 | while z and len('TEST'): # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 68 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 64 64 | while not len('TEST'): # [PLC1802] @@ -175,15 +184,16 @@ len_as_condition.py:67:13: PLC1802 [*] `len('TEST')` used as condition without c 69 69 | 70 70 | while not len('TEST') and z: # [PLC1802] -len_as_condition.py:70:11: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:70:11 | 68 | pass 69 | 70 | while not len('TEST') and z: # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 71 | pass | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 67 67 | while z and len('TEST'): # [PLC1802] @@ -195,15 +205,16 @@ len_as_condition.py:70:11: PLC1802 [*] `len('TEST')` used as condition without c 72 72 | 73 73 | assert len('TEST') > 0 # Should be fine -len_as_condition.py:93:12: PLC1802 [*] `len(args)` used as condition without comparison +PLC1802 [*] `len(args)` used as condition without comparison + --> len_as_condition.py:93:12 | 92 | def github_issue_1331_v2(*args): 93 | assert len(args), args # [PLC1802] - | ^^^^^^^^^ PLC1802 + | ^^^^^^^^^ 94 | 95 | def github_issue_1331_v3(*args): | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 90 90 | assert False, len(args) # Should be fine @@ -215,15 +226,16 @@ len_as_condition.py:93:12: PLC1802 [*] `len(args)` used as condition without com 95 95 | def github_issue_1331_v3(*args): 96 96 | assert len(args) or z, args # [PLC1802] -len_as_condition.py:96:12: PLC1802 [*] `len(args)` used as condition without comparison +PLC1802 [*] `len(args)` used as condition without comparison + --> len_as_condition.py:96:12 | 95 | def github_issue_1331_v3(*args): 96 | assert len(args) or z, args # [PLC1802] - | ^^^^^^^^^ PLC1802 + | ^^^^^^^^^ 97 | 98 | def github_issue_1331_v4(*args): | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 93 93 | assert len(args), args # [PLC1802] @@ -235,15 +247,16 @@ len_as_condition.py:96:12: PLC1802 [*] `len(args)` used as condition without com 98 98 | def github_issue_1331_v4(*args): 99 99 | assert z and len(args), args # [PLC1802] -len_as_condition.py:99:18: PLC1802 [*] `len(args)` used as condition without comparison +PLC1802 [*] `len(args)` used as condition without comparison + --> len_as_condition.py:99:18 | 98 | def github_issue_1331_v4(*args): 99 | assert z and len(args), args # [PLC1802] - | ^^^^^^^^^ PLC1802 + | ^^^^^^^^^ 100 | 101 | def github_issue_1331_v5(**args): | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 96 96 | assert len(args) or z, args # [PLC1802] @@ -255,15 +268,16 @@ len_as_condition.py:99:18: PLC1802 [*] `len(args)` used as condition without com 101 101 | def github_issue_1331_v5(**args): 102 102 | assert z and len(args), args # [PLC1802] -len_as_condition.py:102:18: PLC1802 [*] `len(args)` used as condition without comparison +PLC1802 [*] `len(args)` used as condition without comparison + --> len_as_condition.py:102:18 | 101 | def github_issue_1331_v5(**args): 102 | assert z and len(args), args # [PLC1802] - | ^^^^^^^^^ PLC1802 + | ^^^^^^^^^ 103 | 104 | b = bool(len(z)) # [PLC1802] | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 99 99 | assert z and len(args), args # [PLC1802] @@ -275,15 +289,16 @@ len_as_condition.py:102:18: PLC1802 [*] `len(args)` used as condition without co 104 104 | b = bool(len(z)) # [PLC1802] 105 105 | c = bool(len('TEST') or 42) # [PLC1802] -len_as_condition.py:104:10: PLC1802 [*] `len(z)` used as condition without comparison +PLC1802 [*] `len(z)` used as condition without comparison + --> len_as_condition.py:104:10 | 102 | assert z and len(args), args # [PLC1802] 103 | 104 | b = bool(len(z)) # [PLC1802] - | ^^^^^^ PLC1802 + | ^^^^^^ 105 | c = bool(len('TEST') or 42) # [PLC1802] | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 101 101 | def github_issue_1331_v5(**args): @@ -295,15 +310,16 @@ len_as_condition.py:104:10: PLC1802 [*] `len(z)` used as condition without compa 106 106 | 107 107 | def github_issue_1879(): -len_as_condition.py:105:10: PLC1802 [*] `len('TEST')` used as condition without comparison +PLC1802 [*] `len('TEST')` used as condition without comparison + --> len_as_condition.py:105:10 | 104 | b = bool(len(z)) # [PLC1802] 105 | c = bool(len('TEST') or 42) # [PLC1802] - | ^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^ 106 | 107 | def github_issue_1879(): | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 102 102 | assert z and len(args), args # [PLC1802] @@ -315,16 +331,17 @@ len_as_condition.py:105:10: PLC1802 [*] `len('TEST')` used as condition without 107 107 | def github_issue_1879(): 108 108 | -len_as_condition.py:126:12: PLC1802 [*] `len(range(0))` used as condition without comparison +PLC1802 [*] `len(range(0))` used as condition without comparison + --> len_as_condition.py:126:12 | 124 | assert len(ClassWithoutBool()) # unintuitive?, in pylint: [PLC1802] 125 | assert len(ChildClassWithoutBool()) # unintuitive?, in pylint: [PLC1802] 126 | assert len(range(0)) # [PLC1802] - | ^^^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^^^ 127 | assert len([t + 1 for t in []]) # [PLC1802] 128 | # assert len(u + 1 for u in []) generator has no len | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 123 123 | assert len(ChildClassWithBool()) @@ -336,16 +353,17 @@ len_as_condition.py:126:12: PLC1802 [*] `len(range(0))` used as condition withou 128 128 | # assert len(u + 1 for u in []) generator has no len 129 129 | assert len({"1":(v + 1) for v in {}}) # [PLC1802] -len_as_condition.py:127:12: PLC1802 [*] `len([t + 1 for t in []])` used as condition without comparison +PLC1802 [*] `len([t + 1 for t in []])` used as condition without comparison + --> len_as_condition.py:127:12 | 125 | assert len(ChildClassWithoutBool()) # unintuitive?, in pylint: [PLC1802] 126 | assert len(range(0)) # [PLC1802] 127 | assert len([t + 1 for t in []]) # [PLC1802] - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 128 | # assert len(u + 1 for u in []) generator has no len 129 | assert len({"1":(v + 1) for v in {}}) # [PLC1802] | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 124 124 | assert len(ClassWithoutBool()) # unintuitive?, in pylint: [PLC1802] @@ -357,15 +375,16 @@ len_as_condition.py:127:12: PLC1802 [*] `len([t + 1 for t in []])` used as condi 129 129 | assert len({"1":(v + 1) for v in {}}) # [PLC1802] 130 130 | assert len(set((w + 1) for w in set())) # [PLC1802] -len_as_condition.py:129:12: PLC1802 [*] `len({"1":(v + 1) for v in {}})` used as condition without comparison +PLC1802 [*] `len({"1":(v + 1) for v in {}})` used as condition without comparison + --> len_as_condition.py:129:12 | 127 | assert len([t + 1 for t in []]) # [PLC1802] 128 | # assert len(u + 1 for u in []) generator has no len 129 | assert len({"1":(v + 1) for v in {}}) # [PLC1802] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 130 | assert len(set((w + 1) for w in set())) # [PLC1802] | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 126 126 | assert len(range(0)) # [PLC1802] @@ -377,14 +396,15 @@ len_as_condition.py:129:12: PLC1802 [*] `len({"1":(v + 1) for v in {}})` used as 131 131 | 132 132 | -len_as_condition.py:130:12: PLC1802 [*] `len(set((w + 1) for w in set()))` used as condition without comparison +PLC1802 [*] `len(set((w + 1) for w in set()))` used as condition without comparison + --> len_as_condition.py:130:12 | 128 | # assert len(u + 1 for u in []) generator has no len 129 | assert len({"1":(v + 1) for v in {}}) # [PLC1802] 130 | assert len(set((w + 1) for w in set())) # [PLC1802] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 127 127 | assert len([t + 1 for t in []]) # [PLC1802] @@ -396,15 +416,16 @@ len_as_condition.py:130:12: PLC1802 [*] `len(set((w + 1) for w in set()))` used 132 132 | 133 133 | import numpy -len_as_condition.py:193:8: PLC1802 [*] `len(x)` used as condition without comparison +PLC1802 [*] `len(x)` used as condition without comparison + --> len_as_condition.py:193:8 | 191 | if cond: 192 | x = [4,5,6] 193 | if len(x): # this should be addressed - | ^^^^^^ PLC1802 + | ^^^^^^ 194 | print(x) | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 190 190 | x = [1,2,3] @@ -416,16 +437,17 @@ len_as_condition.py:193:8: PLC1802 [*] `len(x)` used as condition without compar 195 195 | 196 196 | def g(cond:bool): -len_as_condition.py:200:8: PLC1802 [*] `len(x)` used as condition without comparison +PLC1802 [*] `len(x)` used as condition without comparison + --> len_as_condition.py:200:8 | 198 | if cond: 199 | x = [4,5,6] 200 | if len(x): # this should be addressed - | ^^^^^^ PLC1802 + | ^^^^^^ 201 | print(x) 202 | del x | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 197 197 | x = [1,2,3] @@ -437,15 +459,16 @@ len_as_condition.py:200:8: PLC1802 [*] `len(x)` used as condition without compar 202 202 | del x 203 203 | -len_as_condition.py:214:8: PLC1802 [*] `len(x)` used as condition without comparison +PLC1802 [*] `len(x)` used as condition without comparison + --> len_as_condition.py:214:8 | 212 | def inner(x:int): 213 | return x+1 214 | if len(x): # [PLC1802] - | ^^^^^^ PLC1802 + | ^^^^^^ 215 | print(x) | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 211 211 | x = [1,2,3] @@ -457,15 +480,16 @@ len_as_condition.py:214:8: PLC1802 [*] `len(x)` used as condition without compar 216 216 | 217 217 | def redefined(): -len_as_condition.py:220:8: PLC1802 [*] `len(x)` used as condition without comparison +PLC1802 [*] `len(x)` used as condition without comparison + --> len_as_condition.py:220:8 | 218 | x = 123 219 | x = [1, 2, 3] 220 | if len(x): # this should be addressed - | ^^^^^^ PLC1802 + | ^^^^^^ 221 | print(x) | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 217 217 | def redefined(): @@ -477,15 +501,16 @@ len_as_condition.py:220:8: PLC1802 [*] `len(x)` used as condition without compar 222 222 | 223 223 | global_seq = [1, 2, 3] -len_as_condition.py:233:8: PLC1802 [*] `len(x)` used as condition without comparison +PLC1802 [*] `len(x)` used as condition without comparison + --> len_as_condition.py:233:8 | 231 | if False: 232 | x = [1, 2, 3] 233 | if len(x): # [PLC1802] should be fine - | ^^^^^^ PLC1802 + | ^^^^^^ 234 | print(x) | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 230 230 | def j(): @@ -497,14 +522,15 @@ len_as_condition.py:233:8: PLC1802 [*] `len(x)` used as condition without compar 235 235 | 236 236 | # regression tests for https://github.com/astral-sh/ruff/issues/14690 -len_as_condition.py:237:6: PLC1802 [*] `len(ascii(1))` used as condition without comparison +PLC1802 [*] `len(ascii(1))` used as condition without comparison + --> len_as_condition.py:237:6 | 236 | # regression tests for https://github.com/astral-sh/ruff/issues/14690 237 | bool(len(ascii(1))) - | ^^^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^^^ 238 | bool(len(sorted(""))) | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 234 234 | print(x) @@ -516,16 +542,17 @@ len_as_condition.py:237:6: PLC1802 [*] `len(ascii(1))` used as condition without 239 239 | 240 240 | # regression tests for https://github.com/astral-sh/ruff/issues/18811 -len_as_condition.py:238:6: PLC1802 [*] `len(sorted(""))` used as condition without comparison +PLC1802 [*] `len(sorted(""))` used as condition without comparison + --> len_as_condition.py:238:6 | 236 | # regression tests for https://github.com/astral-sh/ruff/issues/14690 237 | bool(len(ascii(1))) 238 | bool(len(sorted(""))) - | ^^^^^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^^^^^ 239 | 240 | # regression tests for https://github.com/astral-sh/ruff/issues/18811 | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 235 235 | @@ -537,15 +564,16 @@ len_as_condition.py:238:6: PLC1802 [*] `len(sorted(""))` used as condition witho 240 240 | # regression tests for https://github.com/astral-sh/ruff/issues/18811 241 241 | fruits = [] -len_as_condition.py:242:3: PLC1802 [*] `len(fruits)` used as condition without comparison +PLC1802 [*] `len(fruits)` used as condition without comparison + --> len_as_condition.py:242:3 | 240 | # regression tests for https://github.com/astral-sh/ruff/issues/18811 241 | fruits = [] 242 | if(len)(fruits): - | ^^^^^^^^^^^^^ PLC1802 + | ^^^^^^^^^^^^^ 243 | ... | - = help: Remove `len` +help: Remove `len` ℹ Safe fix 239 239 | @@ -557,7 +585,8 @@ len_as_condition.py:242:3: PLC1802 [*] `len(fruits)` used as condition without c 244 244 | 245 245 | # regression tests for https://github.com/astral-sh/ruff/issues/18812 -len_as_condition.py:247:4: PLC1802 [*] `len(fruits)` used as condition without comparison +PLC1802 [*] `len(fruits)` used as condition without comparison + --> len_as_condition.py:247:4 | 245 | # regression tests for https://github.com/astral-sh/ruff/issues/18812 246 | fruits = [] @@ -565,10 +594,10 @@ len_as_condition.py:247:4: PLC1802 [*] `len(fruits)` used as condition without c | ____^ 248 | | fruits # comment 249 | | ): - | |_^ PLC1802 + | |_^ 250 | ... | - = help: Remove `len` +help: Remove `len` ℹ Unsafe fix 244 244 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap index fefbd85ebc..7b8ee2f564 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap @@ -1,45 +1,50 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -compare_to_empty_string.py:7:13: PLC1901 `x is ""` can be simplified to `not x` as an empty string is falsey +PLC1901 `x is ""` can be simplified to `not x` as an empty string is falsey + --> compare_to_empty_string.py:7:13 | 6 | def errors(): 7 | if x is "" or x == "": - | ^^ PLC1901 + | ^^ 8 | print("x is an empty string") | -compare_to_empty_string.py:7:24: PLC1901 `x == ""` can be simplified to `not x` as an empty string is falsey +PLC1901 `x == ""` can be simplified to `not x` as an empty string is falsey + --> compare_to_empty_string.py:7:24 | 6 | def errors(): 7 | if x is "" or x == "": - | ^^ PLC1901 + | ^^ 8 | print("x is an empty string") | -compare_to_empty_string.py:10:17: PLC1901 `y is not ""` can be simplified to `y` as an empty string is falsey +PLC1901 `y is not ""` can be simplified to `y` as an empty string is falsey + --> compare_to_empty_string.py:10:17 | 8 | print("x is an empty string") 9 | 10 | if y is not "" or y != "": - | ^^ PLC1901 + | ^^ 11 | print("y is not an empty string") | -compare_to_empty_string.py:10:28: PLC1901 `y != ""` can be simplified to `y` as an empty string is falsey +PLC1901 `y != ""` can be simplified to `y` as an empty string is falsey + --> compare_to_empty_string.py:10:28 | 8 | print("x is an empty string") 9 | 10 | if y is not "" or y != "": - | ^^ PLC1901 + | ^^ 11 | print("y is not an empty string") | -compare_to_empty_string.py:13:8: PLC1901 `"" != z` can be simplified to `z` as an empty string is falsey +PLC1901 `"" != z` can be simplified to `z` as an empty string is falsey + --> compare_to_empty_string.py:13:8 | 11 | print("y is not an empty string") 12 | 13 | if "" != z: - | ^^ PLC1901 + | ^^ 14 | print("z is an empty string") | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2401_non_ascii_name.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2401_non_ascii_name.py.snap index 7cae6936b6..e5e08000a6 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2401_non_ascii_name.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2401_non_ascii_name.py.snap @@ -1,86 +1,95 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -non_ascii_name.py:1:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character +PLC2401 Variable name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:1:1 | 1 | ápple_count: int = 1 # C2401 - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ 2 | ápple_count += 2 # C2401 3 | ápple_count = 3 # C2401 | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters -non_ascii_name.py:2:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character +PLC2401 Variable name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:2:1 | 1 | ápple_count: int = 1 # C2401 2 | ápple_count += 2 # C2401 - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ 3 | ápple_count = 3 # C2401 | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters -non_ascii_name.py:3:1: PLC2401 Variable name `ápple_count` contains a non-ASCII character +PLC2401 Variable name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:3:1 | 1 | ápple_count: int = 1 # C2401 2 | ápple_count += 2 # C2401 3 | ápple_count = 3 # C2401 - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ 4 | 5 | (ápple_count for ápple_count in y) | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters -non_ascii_name.py:5:18: PLC2401 Variable name `ápple_count` contains a non-ASCII character +PLC2401 Variable name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:5:18 | 3 | ápple_count = 3 # C2401 4 | 5 | (ápple_count for ápple_count in y) - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters -non_ascii_name.py:8:10: PLC2401 Argument name `ápple_count` contains a non-ASCII character +PLC2401 Argument name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:8:10 | 8 | def func(ápple_count): - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ 9 | global ápple_count 10 | nonlocal ápple_count | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters -non_ascii_name.py:9:12: PLC2401 Global name `ápple_count` contains a non-ASCII character +PLC2401 Global name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:9:12 | 8 | def func(ápple_count): 9 | global ápple_count - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ 10 | nonlocal ápple_count | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters -non_ascii_name.py:13:5: PLC2401 Function name `ápple_count` contains a non-ASCII character +PLC2401 Function name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:13:5 | 13 | def ápple_count(): - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ 14 | pass | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters -non_ascii_name.py:18:10: PLC2401 Variable name `ápple_count` contains a non-ASCII character +PLC2401 Variable name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:18:10 | 17 | match ápple_count: 18 | case ápple_count: - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ 19 | pass | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters -non_ascii_name.py:21:1: PLC2401 Annotation name `ápple_count` contains a non-ASCII character +PLC2401 Annotation name `ápple_count` contains a non-ASCII character + --> non_ascii_name.py:21:1 | 19 | pass 20 | 21 | ápple_count: int - | ^^^^^^^^^^^ PLC2401 + | ^^^^^^^^^^^ 22 | 23 | try: | - = help: Rename the variable using ASCII characters +help: Rename the variable using ASCII characters diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2403_non_ascii_module_import.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2403_non_ascii_module_import.py.snap index c6f20b25ba..69ebf0df80 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2403_non_ascii_module_import.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2403_non_ascii_module_import.py.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -non_ascii_module_import.py:1:29: PLC2403 Module alias `łos` contains a non-ASCII character +PLC2403 Module alias `łos` contains a non-ASCII character + --> non_ascii_module_import.py:1:29 | 1 | from os.path import join as łos # Error - | ^^^ PLC2403 + | ^^^ 2 | from os.path import join as los # OK | - = help: Use an ASCII-only alias +help: Use an ASCII-only alias -non_ascii_module_import.py:4:24: PLC2403 Module alias `łos` contains a non-ASCII character +PLC2403 Module alias `łos` contains a non-ASCII character + --> non_ascii_module_import.py:4:24 | 2 | from os.path import join as los # OK 3 | 4 | import os.path.join as łos # Error - | ^^^ PLC2403 + | ^^^ 5 | import os.path.join as los # OK | - = help: Use an ASCII-only alias +help: Use an ASCII-only alias -non_ascii_module_import.py:7:8: PLC2403 Module name `os.path.łos` contains a non-ASCII character +PLC2403 Module name `os.path.łos` contains a non-ASCII character + --> non_ascii_module_import.py:7:8 | 5 | import os.path.join as los # OK 6 | 7 | import os.path.łos # Error (recommend an ASCII alias) - | ^^^^^^^^^^^ PLC2403 + | ^^^^^^^^^^^ 8 | import os.path.los # OK | - = help: Use an ASCII-only alias +help: Use an ASCII-only alias -non_ascii_module_import.py:10:21: PLC2403 Module name `łos` contains a non-ASCII character +PLC2403 Module name `łos` contains a non-ASCII character + --> non_ascii_module_import.py:10:21 | 8 | import os.path.los # OK 9 | 10 | from os.path import łos # Error (recommend an ASCII alias) - | ^^^ PLC2403 + | ^^^ 11 | from os.path import los # OK | - = help: Use an ASCII-only alias +help: Use an ASCII-only alias diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap index 2946c74128..4176de7454 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2701_import_private_name__submodule____main__.py.snap @@ -1,70 +1,77 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -__main__.py:2:16: PLC2701 Private name import `_a` +PLC2701 Private name import `_a` + --> __main__.py:2:16 | 1 | # Errors. 2 | from _a import b - | ^ PLC2701 + | ^ 3 | from c._d import e 4 | from _f.g import h | -__main__.py:3:18: PLC2701 Private name import `_d` from external module `c` +PLC2701 Private name import `_d` from external module `c` + --> __main__.py:3:18 | 1 | # Errors. 2 | from _a import b 3 | from c._d import e - | ^ PLC2701 + | ^ 4 | from _f.g import h 5 | from i import _j | -__main__.py:4:18: PLC2701 Private name import `_f` +PLC2701 Private name import `_f` + --> __main__.py:4:18 | 2 | from _a import b 3 | from c._d import e 4 | from _f.g import h - | ^ PLC2701 + | ^ 5 | from i import _j 6 | from k import _l as m | -__main__.py:5:15: PLC2701 Private name import `_j` from external module `i` +PLC2701 Private name import `_j` from external module `i` + --> __main__.py:5:15 | 3 | from c._d import e 4 | from _f.g import h 5 | from i import _j - | ^^ PLC2701 + | ^^ 6 | from k import _l as m 7 | import _aaa | -__main__.py:6:21: PLC2701 Private name import `_l` from external module `k` +PLC2701 Private name import `_l` from external module `k` + --> __main__.py:6:21 | 4 | from _f.g import h 5 | from i import _j 6 | from k import _l as m - | ^ PLC2701 + | ^ 7 | import _aaa 8 | import bbb.ccc._ddd as eee # Panicked in https://github.com/astral-sh/ruff/pull/5920 | -__main__.py:7:8: PLC2701 Private name import `_aaa` +PLC2701 Private name import `_aaa` + --> __main__.py:7:8 | 5 | from i import _j 6 | from k import _l as m 7 | import _aaa - | ^^^^ PLC2701 + | ^^^^ 8 | import bbb.ccc._ddd as eee # Panicked in https://github.com/astral-sh/ruff/pull/5920 | -__main__.py:8:24: PLC2701 Private name import `_ddd` from external module `bbb.ccc` +PLC2701 Private name import `_ddd` from external module `bbb.ccc` + --> __main__.py:8:24 | 6 | from k import _l as m 7 | import _aaa 8 | import bbb.ccc._ddd as eee # Panicked in https://github.com/astral-sh/ruff/pull/5920 - | ^^^ PLC2701 + | ^^^ 9 | 10 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap index 971cc51c39..d91c5b99fc 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC2801_unnecessary_dunder_call.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -unnecessary_dunder_call.py:4:7: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:4:7 | 3 | a = 2 4 | print((3.0).__add__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^ 5 | print((3.0).__sub__(4.0)) # PLC2801 6 | print((3.0).__mul__(4.0)) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 1 1 | from typing import Any @@ -21,16 +22,17 @@ unnecessary_dunder_call.py:4:7: PLC2801 [*] Unnecessary dunder call to `__add__` 6 6 | print((3.0).__mul__(4.0)) # PLC2801 7 7 | print((3.0).__truediv__(4.0)) # PLC2801 -unnecessary_dunder_call.py:5:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:5:7 | 3 | a = 2 4 | print((3.0).__add__(4.0)) # PLC2801 5 | print((3.0).__sub__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^ 6 | print((3.0).__mul__(4.0)) # PLC2801 7 | print((3.0).__truediv__(4.0)) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 2 2 | @@ -42,16 +44,17 @@ unnecessary_dunder_call.py:5:7: PLC2801 [*] Unnecessary dunder call to `__sub__` 7 7 | print((3.0).__truediv__(4.0)) # PLC2801 8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 -unnecessary_dunder_call.py:6:7: PLC2801 [*] Unnecessary dunder call to `__mul__`. Use `*` operator. +PLC2801 [*] Unnecessary dunder call to `__mul__`. Use `*` operator. + --> unnecessary_dunder_call.py:6:7 | 4 | print((3.0).__add__(4.0)) # PLC2801 5 | print((3.0).__sub__(4.0)) # PLC2801 6 | print((3.0).__mul__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^ 7 | print((3.0).__truediv__(4.0)) # PLC2801 8 | print((3.0).__floordiv__(4.0)) # PLC2801 | - = help: Use `*` operator +help: Use `*` operator ℹ Unsafe fix 3 3 | a = 2 @@ -63,16 +66,17 @@ unnecessary_dunder_call.py:6:7: PLC2801 [*] Unnecessary dunder call to `__mul__` 8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 9 9 | print((3.0).__mod__(4.0)) # PLC2801 -unnecessary_dunder_call.py:7:7: PLC2801 [*] Unnecessary dunder call to `__truediv__`. Use `/` operator. +PLC2801 [*] Unnecessary dunder call to `__truediv__`. Use `/` operator. + --> unnecessary_dunder_call.py:7:7 | 5 | print((3.0).__sub__(4.0)) # PLC2801 6 | print((3.0).__mul__(4.0)) # PLC2801 7 | print((3.0).__truediv__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^^^^ 8 | print((3.0).__floordiv__(4.0)) # PLC2801 9 | print((3.0).__mod__(4.0)) # PLC2801 | - = help: Use `/` operator +help: Use `/` operator ℹ Unsafe fix 4 4 | print((3.0).__add__(4.0)) # PLC2801 @@ -84,16 +88,17 @@ unnecessary_dunder_call.py:7:7: PLC2801 [*] Unnecessary dunder call to `__truedi 9 9 | print((3.0).__mod__(4.0)) # PLC2801 10 10 | print((3.0).__eq__(4.0)) # PLC2801 -unnecessary_dunder_call.py:8:7: PLC2801 [*] Unnecessary dunder call to `__floordiv__`. Use `//` operator. +PLC2801 [*] Unnecessary dunder call to `__floordiv__`. Use `//` operator. + --> unnecessary_dunder_call.py:8:7 | 6 | print((3.0).__mul__(4.0)) # PLC2801 7 | print((3.0).__truediv__(4.0)) # PLC2801 8 | print((3.0).__floordiv__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^^^^^ 9 | print((3.0).__mod__(4.0)) # PLC2801 10 | print((3.0).__eq__(4.0)) # PLC2801 | - = help: Use `//` operator +help: Use `//` operator ℹ Unsafe fix 5 5 | print((3.0).__sub__(4.0)) # PLC2801 @@ -105,16 +110,17 @@ unnecessary_dunder_call.py:8:7: PLC2801 [*] Unnecessary dunder call to `__floord 10 10 | print((3.0).__eq__(4.0)) # PLC2801 11 11 | print((3.0).__ne__(4.0)) # PLC2801 -unnecessary_dunder_call.py:9:7: PLC2801 [*] Unnecessary dunder call to `__mod__`. Use `%` operator. +PLC2801 [*] Unnecessary dunder call to `__mod__`. Use `%` operator. + --> unnecessary_dunder_call.py:9:7 | 7 | print((3.0).__truediv__(4.0)) # PLC2801 8 | print((3.0).__floordiv__(4.0)) # PLC2801 9 | print((3.0).__mod__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^ 10 | print((3.0).__eq__(4.0)) # PLC2801 11 | print((3.0).__ne__(4.0)) # PLC2801 | - = help: Use `%` operator +help: Use `%` operator ℹ Unsafe fix 6 6 | print((3.0).__mul__(4.0)) # PLC2801 @@ -126,16 +132,17 @@ unnecessary_dunder_call.py:9:7: PLC2801 [*] Unnecessary dunder call to `__mod__` 11 11 | print((3.0).__ne__(4.0)) # PLC2801 12 12 | print((3.0).__lt__(4.0)) # PLC2801 -unnecessary_dunder_call.py:10:7: PLC2801 [*] Unnecessary dunder call to `__eq__`. Use `==` operator. +PLC2801 [*] Unnecessary dunder call to `__eq__`. Use `==` operator. + --> unnecessary_dunder_call.py:10:7 | 8 | print((3.0).__floordiv__(4.0)) # PLC2801 9 | print((3.0).__mod__(4.0)) # PLC2801 10 | print((3.0).__eq__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^ 11 | print((3.0).__ne__(4.0)) # PLC2801 12 | print((3.0).__lt__(4.0)) # PLC2801 | - = help: Use `==` operator +help: Use `==` operator ℹ Unsafe fix 7 7 | print((3.0).__truediv__(4.0)) # PLC2801 @@ -147,16 +154,17 @@ unnecessary_dunder_call.py:10:7: PLC2801 [*] Unnecessary dunder call to `__eq__` 12 12 | print((3.0).__lt__(4.0)) # PLC2801 13 13 | print((3.0).__le__(4.0)) # PLC2801 -unnecessary_dunder_call.py:11:7: PLC2801 [*] Unnecessary dunder call to `__ne__`. Use `!=` operator. +PLC2801 [*] Unnecessary dunder call to `__ne__`. Use `!=` operator. + --> unnecessary_dunder_call.py:11:7 | 9 | print((3.0).__mod__(4.0)) # PLC2801 10 | print((3.0).__eq__(4.0)) # PLC2801 11 | print((3.0).__ne__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^ 12 | print((3.0).__lt__(4.0)) # PLC2801 13 | print((3.0).__le__(4.0)) # PLC2801 | - = help: Use `!=` operator +help: Use `!=` operator ℹ Unsafe fix 8 8 | print((3.0).__floordiv__(4.0)) # PLC2801 @@ -168,16 +176,17 @@ unnecessary_dunder_call.py:11:7: PLC2801 [*] Unnecessary dunder call to `__ne__` 13 13 | print((3.0).__le__(4.0)) # PLC2801 14 14 | print((3.0).__gt__(4.0)) # PLC2801 -unnecessary_dunder_call.py:12:7: PLC2801 [*] Unnecessary dunder call to `__lt__`. Use `<` operator. +PLC2801 [*] Unnecessary dunder call to `__lt__`. Use `<` operator. + --> unnecessary_dunder_call.py:12:7 | 10 | print((3.0).__eq__(4.0)) # PLC2801 11 | print((3.0).__ne__(4.0)) # PLC2801 12 | print((3.0).__lt__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^ 13 | print((3.0).__le__(4.0)) # PLC2801 14 | print((3.0).__gt__(4.0)) # PLC2801 | - = help: Use `<` operator +help: Use `<` operator ℹ Unsafe fix 9 9 | print((3.0).__mod__(4.0)) # PLC2801 @@ -189,16 +198,17 @@ unnecessary_dunder_call.py:12:7: PLC2801 [*] Unnecessary dunder call to `__lt__` 14 14 | print((3.0).__gt__(4.0)) # PLC2801 15 15 | print((3.0).__ge__(4.0)) # PLC2801 -unnecessary_dunder_call.py:13:7: PLC2801 [*] Unnecessary dunder call to `__le__`. Use `<=` operator. +PLC2801 [*] Unnecessary dunder call to `__le__`. Use `<=` operator. + --> unnecessary_dunder_call.py:13:7 | 11 | print((3.0).__ne__(4.0)) # PLC2801 12 | print((3.0).__lt__(4.0)) # PLC2801 13 | print((3.0).__le__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^ 14 | print((3.0).__gt__(4.0)) # PLC2801 15 | print((3.0).__ge__(4.0)) # PLC2801 | - = help: Use `<=` operator +help: Use `<=` operator ℹ Unsafe fix 10 10 | print((3.0).__eq__(4.0)) # PLC2801 @@ -210,16 +220,17 @@ unnecessary_dunder_call.py:13:7: PLC2801 [*] Unnecessary dunder call to `__le__` 15 15 | print((3.0).__ge__(4.0)) # PLC2801 16 16 | print((3.0).__str__()) # PLC2801 -unnecessary_dunder_call.py:14:7: PLC2801 [*] Unnecessary dunder call to `__gt__`. Use `>` operator. +PLC2801 [*] Unnecessary dunder call to `__gt__`. Use `>` operator. + --> unnecessary_dunder_call.py:14:7 | 12 | print((3.0).__lt__(4.0)) # PLC2801 13 | print((3.0).__le__(4.0)) # PLC2801 14 | print((3.0).__gt__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^ 15 | print((3.0).__ge__(4.0)) # PLC2801 16 | print((3.0).__str__()) # PLC2801 | - = help: Use `>` operator +help: Use `>` operator ℹ Unsafe fix 11 11 | print((3.0).__ne__(4.0)) # PLC2801 @@ -231,16 +242,17 @@ unnecessary_dunder_call.py:14:7: PLC2801 [*] Unnecessary dunder call to `__gt__` 16 16 | print((3.0).__str__()) # PLC2801 17 17 | print((3.0).__repr__()) # PLC2801 -unnecessary_dunder_call.py:15:7: PLC2801 [*] Unnecessary dunder call to `__ge__`. Use `>=` operator. +PLC2801 [*] Unnecessary dunder call to `__ge__`. Use `>=` operator. + --> unnecessary_dunder_call.py:15:7 | 13 | print((3.0).__le__(4.0)) # PLC2801 14 | print((3.0).__gt__(4.0)) # PLC2801 15 | print((3.0).__ge__(4.0)) # PLC2801 - | ^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^ 16 | print((3.0).__str__()) # PLC2801 17 | print((3.0).__repr__()) # PLC2801 | - = help: Use `>=` operator +help: Use `>=` operator ℹ Unsafe fix 12 12 | print((3.0).__lt__(4.0)) # PLC2801 @@ -252,16 +264,17 @@ unnecessary_dunder_call.py:15:7: PLC2801 [*] Unnecessary dunder call to `__ge__` 17 17 | print((3.0).__repr__()) # PLC2801 18 18 | print([1, 2, 3].__len__()) # PLC2801 -unnecessary_dunder_call.py:16:7: PLC2801 [*] Unnecessary dunder call to `__str__`. Use `str()` builtin. +PLC2801 [*] Unnecessary dunder call to `__str__`. Use `str()` builtin. + --> unnecessary_dunder_call.py:16:7 | 14 | print((3.0).__gt__(4.0)) # PLC2801 15 | print((3.0).__ge__(4.0)) # PLC2801 16 | print((3.0).__str__()) # PLC2801 - | ^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^ 17 | print((3.0).__repr__()) # PLC2801 18 | print([1, 2, 3].__len__()) # PLC2801 | - = help: Use `str()` builtin +help: Use `str()` builtin ℹ Unsafe fix 13 13 | print((3.0).__le__(4.0)) # PLC2801 @@ -273,16 +286,17 @@ unnecessary_dunder_call.py:16:7: PLC2801 [*] Unnecessary dunder call to `__str__ 18 18 | print([1, 2, 3].__len__()) # PLC2801 19 19 | print((1).__neg__()) # PLC2801 -unnecessary_dunder_call.py:17:7: PLC2801 [*] Unnecessary dunder call to `__repr__`. Use `repr()` builtin. +PLC2801 [*] Unnecessary dunder call to `__repr__`. Use `repr()` builtin. + --> unnecessary_dunder_call.py:17:7 | 15 | print((3.0).__ge__(4.0)) # PLC2801 16 | print((3.0).__str__()) # PLC2801 17 | print((3.0).__repr__()) # PLC2801 - | ^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^ 18 | print([1, 2, 3].__len__()) # PLC2801 19 | print((1).__neg__()) # PLC2801 | - = help: Use `repr()` builtin +help: Use `repr()` builtin ℹ Unsafe fix 14 14 | print((3.0).__gt__(4.0)) # PLC2801 @@ -294,16 +308,17 @@ unnecessary_dunder_call.py:17:7: PLC2801 [*] Unnecessary dunder call to `__repr_ 19 19 | print((1).__neg__()) # PLC2801 20 20 | print(-a.__sub__(1)) # PLC2801 -unnecessary_dunder_call.py:18:7: PLC2801 [*] Unnecessary dunder call to `__len__`. Use `len()` builtin. +PLC2801 [*] Unnecessary dunder call to `__len__`. Use `len()` builtin. + --> unnecessary_dunder_call.py:18:7 | 16 | print((3.0).__str__()) # PLC2801 17 | print((3.0).__repr__()) # PLC2801 18 | print([1, 2, 3].__len__()) # PLC2801 - | ^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^ 19 | print((1).__neg__()) # PLC2801 20 | print(-a.__sub__(1)) # PLC2801 | - = help: Use `len()` builtin +help: Use `len()` builtin ℹ Unsafe fix 15 15 | print((3.0).__ge__(4.0)) # PLC2801 @@ -315,27 +330,29 @@ unnecessary_dunder_call.py:18:7: PLC2801 [*] Unnecessary dunder call to `__len__ 20 20 | print(-a.__sub__(1)) # PLC2801 21 21 | print(-(a).__sub__(1)) # PLC2801 -unnecessary_dunder_call.py:19:7: PLC2801 Unnecessary dunder call to `__neg__`. Multiply by -1 instead. +PLC2801 Unnecessary dunder call to `__neg__`. Multiply by -1 instead. + --> unnecessary_dunder_call.py:19:7 | 17 | print((3.0).__repr__()) # PLC2801 18 | print([1, 2, 3].__len__()) # PLC2801 19 | print((1).__neg__()) # PLC2801 - | ^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^ 20 | print(-a.__sub__(1)) # PLC2801 21 | print(-(a).__sub__(1)) # PLC2801 | - = help: Multiply by -1 instead +help: Multiply by -1 instead -unnecessary_dunder_call.py:20:8: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:20:8 | 18 | print([1, 2, 3].__len__()) # PLC2801 19 | print((1).__neg__()) # PLC2801 20 | print(-a.__sub__(1)) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 21 | print(-(a).__sub__(1)) # PLC2801 22 | print(-(-a.__sub__(1))) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 17 17 | print((3.0).__repr__()) # PLC2801 @@ -347,16 +364,17 @@ unnecessary_dunder_call.py:20:8: PLC2801 [*] Unnecessary dunder call to `__sub__ 22 22 | print(-(-a.__sub__(1))) # PLC2801 23 23 | print((5 - a).__sub__(1)) # PLC2801 -unnecessary_dunder_call.py:21:8: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:21:8 | 19 | print((1).__neg__()) # PLC2801 20 | print(-a.__sub__(1)) # PLC2801 21 | print(-(a).__sub__(1)) # PLC2801 - | ^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^ 22 | print(-(-a.__sub__(1))) # PLC2801 23 | print((5 - a).__sub__(1)) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 18 18 | print([1, 2, 3].__len__()) # PLC2801 @@ -368,16 +386,17 @@ unnecessary_dunder_call.py:21:8: PLC2801 [*] Unnecessary dunder call to `__sub__ 23 23 | print((5 - a).__sub__(1)) # PLC2801 24 24 | print(-(5 - a).__sub__(1)) # PLC2801 -unnecessary_dunder_call.py:22:10: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:22:10 | 20 | print(-a.__sub__(1)) # PLC2801 21 | print(-(a).__sub__(1)) # PLC2801 22 | print(-(-a.__sub__(1))) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 23 | print((5 - a).__sub__(1)) # PLC2801 24 | print(-(5 - a).__sub__(1)) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 19 19 | print((1).__neg__()) # PLC2801 @@ -389,16 +408,17 @@ unnecessary_dunder_call.py:22:10: PLC2801 [*] Unnecessary dunder call to `__sub_ 24 24 | print(-(5 - a).__sub__(1)) # PLC2801 25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 -unnecessary_dunder_call.py:23:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:23:7 | 21 | print(-(a).__sub__(1)) # PLC2801 22 | print(-(-a.__sub__(1))) # PLC2801 23 | print((5 - a).__sub__(1)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^ 24 | print(-(5 - a).__sub__(1)) # PLC2801 25 | print(-(-5 - a).__sub__(1)) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 20 20 | print(-a.__sub__(1)) # PLC2801 @@ -410,16 +430,17 @@ unnecessary_dunder_call.py:23:7: PLC2801 [*] Unnecessary dunder call to `__sub__ 25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 -unnecessary_dunder_call.py:24:8: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:24:8 | 22 | print(-(-a.__sub__(1))) # PLC2801 23 | print((5 - a).__sub__(1)) # PLC2801 24 | print(-(5 - a).__sub__(1)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^ 25 | print(-(-5 - a).__sub__(1)) # PLC2801 26 | print(+-+-+-a.__sub__(1)) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 21 21 | print(-(a).__sub__(1)) # PLC2801 @@ -431,16 +452,17 @@ unnecessary_dunder_call.py:24:8: PLC2801 [*] Unnecessary dunder call to `__sub__ 26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 27 27 | print(a.__rsub__(2 - 1)) # PLC2801 -unnecessary_dunder_call.py:25:8: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:25:8 | 23 | print((5 - a).__sub__(1)) # PLC2801 24 | print(-(5 - a).__sub__(1)) # PLC2801 25 | print(-(-5 - a).__sub__(1)) # PLC2801 - | ^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^ 26 | print(+-+-+-a.__sub__(1)) # PLC2801 27 | print(a.__rsub__(2 - 1)) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 22 22 | print(-(-a.__sub__(1))) # PLC2801 @@ -452,16 +474,17 @@ unnecessary_dunder_call.py:25:8: PLC2801 [*] Unnecessary dunder call to `__sub__ 27 27 | print(a.__rsub__(2 - 1)) # PLC2801 28 28 | print(a.__sub__(((((1)))))) # PLC2801 -unnecessary_dunder_call.py:26:13: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:26:13 | 24 | print(-(5 - a).__sub__(1)) # PLC2801 25 | print(-(-5 - a).__sub__(1)) # PLC2801 26 | print(+-+-+-a.__sub__(1)) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 27 | print(a.__rsub__(2 - 1)) # PLC2801 28 | print(a.__sub__(((((1)))))) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 23 23 | print((5 - a).__sub__(1)) # PLC2801 @@ -473,16 +496,17 @@ unnecessary_dunder_call.py:26:13: PLC2801 [*] Unnecessary dunder call to `__sub_ 28 28 | print(a.__sub__(((((1)))))) # PLC2801 29 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 -unnecessary_dunder_call.py:27:7: PLC2801 [*] Unnecessary dunder call to `__rsub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__rsub__`. Use `-` operator. + --> unnecessary_dunder_call.py:27:7 | 25 | print(-(-5 - a).__sub__(1)) # PLC2801 26 | print(+-+-+-a.__sub__(1)) # PLC2801 27 | print(a.__rsub__(2 - 1)) # PLC2801 - | ^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^ 28 | print(a.__sub__(((((1)))))) # PLC2801 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 24 24 | print(-(5 - a).__sub__(1)) # PLC2801 @@ -494,16 +518,17 @@ unnecessary_dunder_call.py:27:7: PLC2801 [*] Unnecessary dunder call to `__rsub_ 29 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 30 30 | print(a.__sub__( -unnecessary_dunder_call.py:28:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:28:7 | 26 | print(+-+-+-a.__sub__(1)) # PLC2801 27 | print(a.__rsub__(2 - 1)) # PLC2801 28 | print(a.__sub__(((((1)))))) # PLC2801 - | ^^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^^ 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 30 | print(a.__sub__( | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 25 25 | print(-(-5 - a).__sub__(1)) # PLC2801 @@ -515,16 +540,17 @@ unnecessary_dunder_call.py:28:7: PLC2801 [*] Unnecessary dunder call to `__sub__ 30 30 | print(a.__sub__( 31 31 | 3 -unnecessary_dunder_call.py:29:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:29:7 | 27 | print(a.__rsub__(2 - 1)) # PLC2801 28 | print(a.__sub__(((((1)))))) # PLC2801 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 30 | print(a.__sub__( 31 | 3 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 26 26 | print(+-+-+-a.__sub__(1)) # PLC2801 @@ -536,7 +562,8 @@ unnecessary_dunder_call.py:29:7: PLC2801 [*] Unnecessary dunder call to `__sub__ 31 31 | 3 32 32 | + -unnecessary_dunder_call.py:30:7: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:30:7 | 28 | print(a.__sub__(((((1)))))) # PLC2801 29 | print(a.__sub__(((((2 - 1)))))) # PLC2801 @@ -546,11 +573,11 @@ unnecessary_dunder_call.py:30:7: PLC2801 [*] Unnecessary dunder call to `__sub__ 32 | | + 33 | | 4 34 | | )) - | |_^ PLC2801 + | |_^ 35 | print(a.__rsub__( 36 | 3 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 27 27 | print(a.__rsub__(2 - 1)) # PLC2801 @@ -567,7 +594,8 @@ unnecessary_dunder_call.py:30:7: PLC2801 [*] Unnecessary dunder call to `__sub__ 36 34 | 3 37 35 | + -unnecessary_dunder_call.py:35:7: PLC2801 [*] Unnecessary dunder call to `__rsub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__rsub__`. Use `-` operator. + --> unnecessary_dunder_call.py:35:7 | 33 | 4 34 | )) @@ -577,11 +605,11 @@ unnecessary_dunder_call.py:35:7: PLC2801 [*] Unnecessary dunder call to `__rsub_ 37 | | + 38 | | 4 39 | | )) - | |_^ PLC2801 + | |_^ 40 | print(2 * a.__add__(3)) # PLC2801 41 | x = 2 * a.__add__(3) # PLC2801 | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 32 32 | + @@ -598,16 +626,17 @@ unnecessary_dunder_call.py:35:7: PLC2801 [*] Unnecessary dunder call to `__rsub_ 41 39 | x = 2 * a.__add__(3) # PLC2801 42 40 | x = 2 * -a.__add__(3) # PLC2801 -unnecessary_dunder_call.py:40:11: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:40:11 | 38 | 4 39 | )) 40 | print(2 * a.__add__(3)) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 41 | x = 2 * a.__add__(3) # PLC2801 42 | x = 2 * -a.__add__(3) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 37 37 | + @@ -619,16 +648,17 @@ unnecessary_dunder_call.py:40:11: PLC2801 [*] Unnecessary dunder call to `__add_ 42 42 | x = 2 * -a.__add__(3) # PLC2801 43 43 | x = a.__add__(3) # PLC2801 -unnecessary_dunder_call.py:41:9: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:41:9 | 39 | )) 40 | print(2 * a.__add__(3)) # PLC2801 41 | x = 2 * a.__add__(3) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 42 | x = 2 * -a.__add__(3) # PLC2801 43 | x = a.__add__(3) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 38 38 | 4 @@ -640,16 +670,17 @@ unnecessary_dunder_call.py:41:9: PLC2801 [*] Unnecessary dunder call to `__add__ 43 43 | x = a.__add__(3) # PLC2801 44 44 | x = -a.__add__(3) # PLC2801 -unnecessary_dunder_call.py:42:10: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:42:10 | 40 | print(2 * a.__add__(3)) # PLC2801 41 | x = 2 * a.__add__(3) # PLC2801 42 | x = 2 * -a.__add__(3) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 43 | x = a.__add__(3) # PLC2801 44 | x = -a.__add__(3) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 39 39 | )) @@ -661,16 +692,17 @@ unnecessary_dunder_call.py:42:10: PLC2801 [*] Unnecessary dunder call to `__add_ 44 44 | x = -a.__add__(3) # PLC2801 45 45 | x = (-a).__add__(3) # PLC2801 -unnecessary_dunder_call.py:43:5: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:43:5 | 41 | x = 2 * a.__add__(3) # PLC2801 42 | x = 2 * -a.__add__(3) # PLC2801 43 | x = a.__add__(3) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 44 | x = -a.__add__(3) # PLC2801 45 | x = (-a).__add__(3) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 40 40 | print(2 * a.__add__(3)) # PLC2801 @@ -682,16 +714,17 @@ unnecessary_dunder_call.py:43:5: PLC2801 [*] Unnecessary dunder call to `__add__ 45 45 | x = (-a).__add__(3) # PLC2801 46 46 | x = -(-a).__add__(3) # PLC2801 -unnecessary_dunder_call.py:44:6: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:44:6 | 42 | x = 2 * -a.__add__(3) # PLC2801 43 | x = a.__add__(3) # PLC2801 44 | x = -a.__add__(3) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 45 | x = (-a).__add__(3) # PLC2801 46 | x = -(-a).__add__(3) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 41 41 | x = 2 * a.__add__(3) # PLC2801 @@ -703,15 +736,16 @@ unnecessary_dunder_call.py:44:6: PLC2801 [*] Unnecessary dunder call to `__add__ 46 46 | x = -(-a).__add__(3) # PLC2801 47 47 | -unnecessary_dunder_call.py:45:5: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:45:5 | 43 | x = a.__add__(3) # PLC2801 44 | x = -a.__add__(3) # PLC2801 45 | x = (-a).__add__(3) # PLC2801 - | ^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^ 46 | x = -(-a).__add__(3) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 42 42 | x = 2 * -a.__add__(3) # PLC2801 @@ -723,16 +757,17 @@ unnecessary_dunder_call.py:45:5: PLC2801 [*] Unnecessary dunder call to `__add__ 47 47 | 48 48 | # Calls -unnecessary_dunder_call.py:46:6: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:46:6 | 44 | x = -a.__add__(3) # PLC2801 45 | x = (-a).__add__(3) # PLC2801 46 | x = -(-a).__add__(3) # PLC2801 - | ^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^ 47 | 48 | # Calls | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 43 43 | x = a.__add__(3) # PLC2801 @@ -744,22 +779,24 @@ unnecessary_dunder_call.py:46:6: PLC2801 [*] Unnecessary dunder call to `__add__ 48 48 | # Calls 49 49 | print(a.__call__()) # PLC2801 (no fix, intentional) -unnecessary_dunder_call.py:49:7: PLC2801 Unnecessary dunder call to `__call__` +PLC2801 Unnecessary dunder call to `__call__` + --> unnecessary_dunder_call.py:49:7 | 48 | # Calls 49 | print(a.__call__()) # PLC2801 (no fix, intentional) - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 50 | 51 | class Foo: | -unnecessary_dunder_call.py:63:1: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:63:1 | 62 | foo = Foo(1) 63 | foo.__add__(2).get_v() # PLC2801 - | ^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^ | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 60 60 | return self.v @@ -771,15 +808,16 @@ unnecessary_dunder_call.py:63:1: PLC2801 [*] Unnecessary dunder call to `__add__ 65 65 | 66 66 | # Lambda expressions -unnecessary_dunder_call.py:67:16: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:67:16 | 66 | # Lambda expressions 67 | blah = lambda: a.__add__(1) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 68 | 69 | # If expressions | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 64 64 | @@ -791,15 +829,16 @@ unnecessary_dunder_call.py:67:16: PLC2801 [*] Unnecessary dunder call to `__add_ 69 69 | # If expressions 70 70 | print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 -unnecessary_dunder_call.py:70:7: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:70:7 | 69 | # If expressions 70 | print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 71 | 72 | # Dict/Set/List/Tuple | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 67 67 | blah = lambda: a.__add__(1) # PLC2801 @@ -811,15 +850,16 @@ unnecessary_dunder_call.py:70:7: PLC2801 [*] Unnecessary dunder call to `__add__ 72 72 | # Dict/Set/List/Tuple 73 73 | print({"a": a.__add__(1)}) # PLC2801 -unnecessary_dunder_call.py:70:34: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:70:34 | 69 | # If expressions 70 | print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 71 | 72 | # Dict/Set/List/Tuple | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 67 67 | blah = lambda: a.__add__(1) # PLC2801 @@ -831,15 +871,16 @@ unnecessary_dunder_call.py:70:34: PLC2801 [*] Unnecessary dunder call to `__sub_ 72 72 | # Dict/Set/List/Tuple 73 73 | print({"a": a.__add__(1)}) # PLC2801 -unnecessary_dunder_call.py:73:13: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:73:13 | 72 | # Dict/Set/List/Tuple 73 | print({"a": a.__add__(1)}) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 74 | print({a.__add__(1)}) # PLC2801 75 | print([a.__add__(1)]) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 70 70 | print(a.__add__(1) if a > 0 else a.__sub__(1)) # PLC2801 @@ -851,16 +892,17 @@ unnecessary_dunder_call.py:73:13: PLC2801 [*] Unnecessary dunder call to `__add_ 75 75 | print([a.__add__(1)]) # PLC2801 76 76 | print((a.__add__(1),)) # PLC2801 -unnecessary_dunder_call.py:74:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:74:8 | 72 | # Dict/Set/List/Tuple 73 | print({"a": a.__add__(1)}) # PLC2801 74 | print({a.__add__(1)}) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 75 | print([a.__add__(1)]) # PLC2801 76 | print((a.__add__(1),)) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 71 71 | @@ -872,15 +914,16 @@ unnecessary_dunder_call.py:74:8: PLC2801 [*] Unnecessary dunder call to `__add__ 76 76 | print((a.__add__(1),)) # PLC2801 77 77 | -unnecessary_dunder_call.py:75:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:75:8 | 73 | print({"a": a.__add__(1)}) # PLC2801 74 | print({a.__add__(1)}) # PLC2801 75 | print([a.__add__(1)]) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 76 | print((a.__add__(1),)) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 72 72 | # Dict/Set/List/Tuple @@ -892,16 +935,17 @@ unnecessary_dunder_call.py:75:8: PLC2801 [*] Unnecessary dunder call to `__add__ 77 77 | 78 78 | # Comprehension variants -unnecessary_dunder_call.py:76:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:76:8 | 74 | print({a.__add__(1)}) # PLC2801 75 | print([a.__add__(1)]) # PLC2801 76 | print((a.__add__(1),)) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 77 | 78 | # Comprehension variants | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 73 73 | print({"a": a.__add__(1)}) # PLC2801 @@ -913,15 +957,16 @@ unnecessary_dunder_call.py:76:8: PLC2801 [*] Unnecessary dunder call to `__add__ 78 78 | # Comprehension variants 79 79 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 -unnecessary_dunder_call.py:79:11: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:79:11 | 78 | # Comprehension variants 79 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 80 | print({i.__add__(1) for i in range(5)}) # PLC2801 81 | print([i.__add__(1) for i in range(5)]) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 76 76 | print((a.__add__(1),)) # PLC2801 @@ -933,16 +978,17 @@ unnecessary_dunder_call.py:79:11: PLC2801 [*] Unnecessary dunder call to `__add_ 81 81 | print([i.__add__(1) for i in range(5)]) # PLC2801 82 82 | print((i.__add__(1) for i in range(5))) # PLC2801 -unnecessary_dunder_call.py:80:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:80:8 | 78 | # Comprehension variants 79 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 80 | print({i.__add__(1) for i in range(5)}) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 81 | print([i.__add__(1) for i in range(5)]) # PLC2801 82 | print((i.__add__(1) for i in range(5))) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 77 77 | @@ -954,15 +1000,16 @@ unnecessary_dunder_call.py:80:8: PLC2801 [*] Unnecessary dunder call to `__add__ 82 82 | print((i.__add__(1) for i in range(5))) # PLC2801 83 83 | -unnecessary_dunder_call.py:81:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:81:8 | 79 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 80 | print({i.__add__(1) for i in range(5)}) # PLC2801 81 | print([i.__add__(1) for i in range(5)]) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 82 | print((i.__add__(1) for i in range(5))) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 78 78 | # Comprehension variants @@ -974,16 +1021,17 @@ unnecessary_dunder_call.py:81:8: PLC2801 [*] Unnecessary dunder call to `__add__ 83 83 | 84 84 | # Generators -unnecessary_dunder_call.py:82:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:82:8 | 80 | print({i.__add__(1) for i in range(5)}) # PLC2801 81 | print([i.__add__(1) for i in range(5)]) # PLC2801 82 | print((i.__add__(1) for i in range(5))) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 83 | 84 | # Generators | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 79 79 | print({i: i.__add__(1) for i in range(5)}) # PLC2801 @@ -995,14 +1043,15 @@ unnecessary_dunder_call.py:82:8: PLC2801 [*] Unnecessary dunder call to `__add__ 84 84 | # Generators 85 85 | gen = (i.__add__(1) for i in range(5)) # PLC2801 -unnecessary_dunder_call.py:85:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:85:8 | 84 | # Generators 85 | gen = (i.__add__(1) for i in range(5)) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 86 | print(next(gen)) | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 82 82 | print((i.__add__(1) for i in range(5))) # PLC2801 @@ -1014,15 +1063,16 @@ unnecessary_dunder_call.py:85:8: PLC2801 [*] Unnecessary dunder call to `__add__ 87 87 | 88 88 | # Subscripts -unnecessary_dunder_call.py:89:13: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:89:13 | 88 | # Subscripts 89 | print({"a": a.__add__(1)}["a"]) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 90 | # https://github.com/astral-sh/ruff/issues/15745 91 | print("x".__add__("y")[0]) # PLC2801 | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 86 86 | print(next(gen)) @@ -1034,16 +1084,17 @@ unnecessary_dunder_call.py:89:13: PLC2801 [*] Unnecessary dunder call to `__add_ 91 91 | print("x".__add__("y")[0]) # PLC2801 92 92 | -unnecessary_dunder_call.py:91:7: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:91:7 | 89 | print({"a": a.__add__(1)}["a"]) # PLC2801 90 | # https://github.com/astral-sh/ruff/issues/15745 91 | print("x".__add__("y")[0]) # PLC2801 - | ^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^ 92 | 93 | # Starred | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 88 88 | # Subscripts @@ -1055,15 +1106,16 @@ unnecessary_dunder_call.py:91:7: PLC2801 [*] Unnecessary dunder call to `__add__ 93 93 | # Starred 94 94 | print(*[a.__add__(1)]) # PLC2801 -unnecessary_dunder_call.py:94:9: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:94:9 | 93 | # Starred 94 | print(*[a.__add__(1)]) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 95 | 96 | list1 = [1, 2, 3] | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 91 91 | print("x".__add__("y")[0]) # PLC2801 @@ -1075,16 +1127,17 @@ unnecessary_dunder_call.py:94:9: PLC2801 [*] Unnecessary dunder call to `__add__ 96 96 | list1 = [1, 2, 3] 97 97 | list2 = [4, 5, 6] -unnecessary_dunder_call.py:98:9: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:98:9 | 96 | list1 = [1, 2, 3] 97 | list2 = [4, 5, 6] 98 | print([*list1.__add__(list2)]) # PLC2801 - | ^^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^^ 99 | 100 | # Slices | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 95 95 | @@ -1096,15 +1149,16 @@ unnecessary_dunder_call.py:98:9: PLC2801 [*] Unnecessary dunder call to `__add__ 100 100 | # Slices 101 101 | print([a.__add__(1), a.__sub__(1)][0:1]) # PLC2801 -unnecessary_dunder_call.py:101:8: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:101:8 | 100 | # Slices 101 | print([a.__add__(1), a.__sub__(1)][0:1]) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 102 | 103 | # Attribute access | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 98 98 | print([*list1.__add__(list2)]) # PLC2801 @@ -1116,15 +1170,16 @@ unnecessary_dunder_call.py:101:8: PLC2801 [*] Unnecessary dunder call to `__add_ 103 103 | # Attribute access 104 104 | # https://github.com/astral-sh/ruff/issues/15745 -unnecessary_dunder_call.py:101:22: PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. +PLC2801 [*] Unnecessary dunder call to `__sub__`. Use `-` operator. + --> unnecessary_dunder_call.py:101:22 | 100 | # Slices 101 | print([a.__add__(1), a.__sub__(1)][0:1]) # PLC2801 - | ^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^ 102 | 103 | # Attribute access | - = help: Use `-` operator +help: Use `-` operator ℹ Unsafe fix 98 98 | print([*list1.__add__(list2)]) # PLC2801 @@ -1136,16 +1191,17 @@ unnecessary_dunder_call.py:101:22: PLC2801 [*] Unnecessary dunder call to `__sub 103 103 | # Attribute access 104 104 | # https://github.com/astral-sh/ruff/issues/15745 -unnecessary_dunder_call.py:105:7: PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. +PLC2801 [*] Unnecessary dunder call to `__add__`. Use `+` operator. + --> unnecessary_dunder_call.py:105:7 | 103 | # Attribute access 104 | # https://github.com/astral-sh/ruff/issues/15745 105 | print(1j.__add__(1.0).real) # PLC2801 - | ^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^ 106 | 107 | class Thing: | - = help: Use `+` operator +help: Use `+` operator ℹ Unsafe fix 102 102 | @@ -1157,26 +1213,28 @@ unnecessary_dunder_call.py:105:7: PLC2801 [*] Unnecessary dunder call to `__add_ 107 107 | class Thing: 108 108 | def __init__(self, stuff: Any) -> None: -unnecessary_dunder_call.py:116:16: PLC2801 Unnecessary dunder call to `__getattribute__`. Access attribute directly or use getattr built-in function. +PLC2801 Unnecessary dunder call to `__getattribute__`. Access attribute directly or use getattr built-in function. + --> unnecessary_dunder_call.py:116:16 | 115 | def do_thing(self, item): 116 | return object.__getattribute__(self, item) # PLC2801 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 117 | 118 | def use_descriptor(self, item): | - = help: Access attribute directly or use getattr built-in function +help: Access attribute directly or use getattr built-in function -unnecessary_dunder_call.py:128:1: PLC2801 [*] Unnecessary dunder call to `__contains__`. Use `in` operator. +PLC2801 [*] Unnecessary dunder call to `__contains__`. Use `in` operator. + --> unnecessary_dunder_call.py:128:1 | 126 | blah = dict[{"a": 1}.__delitem__("a")] # OK 127 | 128 | "abc".__contains__("a") - | ^^^^^^^^^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^^^^^^^^^ 129 | 130 | # https://github.com/astral-sh/ruff/issues/14597 | - = help: Use `in` operator +help: Use `in` operator ℹ Unsafe fix 125 125 | @@ -1188,15 +1246,16 @@ unnecessary_dunder_call.py:128:1: PLC2801 [*] Unnecessary dunder call to `__cont 130 130 | # https://github.com/astral-sh/ruff/issues/14597 131 131 | assert "abc".__str__() == "abc" -unnecessary_dunder_call.py:131:8: PLC2801 [*] Unnecessary dunder call to `__str__`. Use `str()` builtin. +PLC2801 [*] Unnecessary dunder call to `__str__`. Use `str()` builtin. + --> unnecessary_dunder_call.py:131:8 | 130 | # https://github.com/astral-sh/ruff/issues/14597 131 | assert "abc".__str__() == "abc" - | ^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^ 132 | 133 | # https://github.com/astral-sh/ruff/issues/18813 | - = help: Use `str()` builtin +help: Use `str()` builtin ℹ Unsafe fix 128 128 | "abc".__contains__("a") @@ -1208,13 +1267,14 @@ unnecessary_dunder_call.py:131:8: PLC2801 [*] Unnecessary dunder call to `__str_ 133 133 | # https://github.com/astral-sh/ruff/issues/18813 134 134 | three = 1 if 1 else(3.0).__str__() -unnecessary_dunder_call.py:134:20: PLC2801 [*] Unnecessary dunder call to `__str__`. Use `str()` builtin. +PLC2801 [*] Unnecessary dunder call to `__str__`. Use `str()` builtin. + --> unnecessary_dunder_call.py:134:20 | 133 | # https://github.com/astral-sh/ruff/issues/18813 134 | three = 1 if 1 else(3.0).__str__() - | ^^^^^^^^^^^^^^^ PLC2801 + | ^^^^^^^^^^^^^^^ | - = help: Use `str()` builtin +help: Use `str()` builtin ℹ Unsafe fix 131 131 | assert "abc".__str__() == "abc" diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap index d80235c4b6..59968f3620 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap @@ -1,25 +1,28 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -unnecessary_direct_lambda_call.py:4:5: PLC3002 Lambda expression called directly. Execute the expression inline instead. +PLC3002 Lambda expression called directly. Execute the expression inline instead. + --> unnecessary_direct_lambda_call.py:4:5 | 2 | # pylint: disable=undefined-variable, line-too-long 3 | 4 | y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC3002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | y = max((lambda x: x**2)(a), (lambda x: x+1)(a)) # [unnecessary-direct-lambda-call,unnecessary-direct-lambda-call] | -unnecessary_direct_lambda_call.py:5:9: PLC3002 Lambda expression called directly. Execute the expression inline instead. +PLC3002 Lambda expression called directly. Execute the expression inline instead. + --> unnecessary_direct_lambda_call.py:5:9 | 4 | y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] 5 | y = max((lambda x: x**2)(a), (lambda x: x+1)(a)) # [unnecessary-direct-lambda-call,unnecessary-direct-lambda-call] - | ^^^^^^^^^^^^^^^^^^^ PLC3002 + | ^^^^^^^^^^^^^^^^^^^ | -unnecessary_direct_lambda_call.py:5:30: PLC3002 Lambda expression called directly. Execute the expression inline instead. +PLC3002 Lambda expression called directly. Execute the expression inline instead. + --> unnecessary_direct_lambda_call.py:5:30 | 4 | y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] 5 | y = max((lambda x: x**2)(a), (lambda x: x+1)(a)) # [unnecessary-direct-lambda-call,unnecessary-direct-lambda-call] - | ^^^^^^^^^^^^^^^^^^ PLC3002 + | ^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap index 7fefeeb11b..19a74bf16b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -yield_in_init.py:9:9: PLE0100 `__init__` method is a generator +PLE0100 `__init__` method is a generator + --> yield_in_init.py:9:9 | 7 | class A: 8 | def __init__(self): 9 | yield - | ^^^^^ PLE0100 + | ^^^^^ | -yield_in_init.py:14:9: PLE0100 `__init__` method is a generator +PLE0100 `__init__` method is a generator + --> yield_in_init.py:14:9 | 12 | class B: 13 | def __init__(self): 14 | yield from self.gen() - | ^^^^^^^^^^^^^^^^^^^^^ PLE0100 + | ^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | def gen(self): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap index 79ae8f1ae6..446aa7333c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap @@ -1,21 +1,23 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -return_in_init.py:14:9: PLE0101 Explicit return in `__init__` +PLE0101 Explicit return in `__init__` + --> return_in_init.py:14:9 | 12 | class B: 13 | def __init__(self): 14 | return 3 - | ^^^^^^^^ PLE0101 + | ^^^^^^^^ 15 | 16 | def gen(self): | -return_in_init.py:22:9: PLE0101 Explicit return in `__init__` +PLE0101 Explicit return in `__init__` + --> return_in_init.py:22:9 | 21 | def __init__(self): 22 | return 1 - | ^^^^^^^^ PLE0101 + | ^^^^^^^^ 23 | 24 | class MyClass2: | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0115_nonlocal_and_global.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0115_nonlocal_and_global.py.snap index 9bcbce8cff..94d0f24d68 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0115_nonlocal_and_global.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0115_nonlocal_and_global.py.snap @@ -1,38 +1,41 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -nonlocal_and_global.py:7:12: PLE0115 Name `counter` is both `nonlocal` and `global` +PLE0115 Name `counter` is both `nonlocal` and `global` + --> nonlocal_and_global.py:7:12 | 6 | def count(): 7 | global counter - | ^^^^^^^ PLE0115 + | ^^^^^^^ 8 | nonlocal counter 9 | counter += 1 | -nonlocal_and_global.py:20:20: PLE0115 Name `counter` is both `nonlocal` and `global` +PLE0115 Name `counter` is both `nonlocal` and `global` + --> nonlocal_and_global.py:20:20 | 18 | counter += 1 19 | else: 20 | global counter - | ^^^^^^^ PLE0115 + | ^^^^^^^ 21 | counter += 1 | -nonlocal_and_global.py:31:16: PLE0115 Name `counter` is both `nonlocal` and `global` +PLE0115 Name `counter` is both `nonlocal` and `global` + --> nonlocal_and_global.py:31:16 | 29 | nonlocal counter 30 | counter += 1 31 | global counter - | ^^^^^^^ PLE0115 + | ^^^^^^^ | -nonlocal_and_global.py:36:12: PLE0115 Name `counter` is both `nonlocal` and `global` +PLE0115 Name `counter` is both `nonlocal` and `global` + --> nonlocal_and_global.py:36:12 | 34 | def count(): 35 | nonlocal counter 36 | global counter - | ^^^^^^^ PLE0115 + | ^^^^^^^ 37 | counter += 1 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap index 4e375e6b6a..70e4d1609d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap @@ -1,24 +1,26 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -nonlocal_without_binding.py:5:14: PLE0117 Nonlocal name `x` found without binding +PLE0117 Nonlocal name `x` found without binding + --> nonlocal_without_binding.py:5:14 | 4 | def f(): 5 | nonlocal x - | ^ PLE0117 + | ^ | -nonlocal_without_binding.py:9:14: PLE0117 Nonlocal name `y` found without binding +PLE0117 Nonlocal name `y` found without binding + --> nonlocal_without_binding.py:9:14 | 8 | def f(): 9 | nonlocal y - | ^ PLE0117 + | ^ | -nonlocal_without_binding.py:19:18: PLE0117 Nonlocal name `y` found without binding +PLE0117 Nonlocal name `y` found without binding + --> nonlocal_without_binding.py:19:18 | 18 | def f(): 19 | nonlocal y - | ^ PLE0117 + | ^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap index adabada987..4ad920a4ff 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap @@ -1,133 +1,147 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -load_before_global_declaration.py:5:11: PLE0118 Name `x` is used prior to global declaration on line 7 +PLE0118 Name `x` is used prior to global declaration on line 7 + --> load_before_global_declaration.py:5:11 | 3 | ### 4 | def f(): 5 | print(x) - | ^ PLE0118 + | ^ 6 | 7 | global x | -load_before_global_declaration.py:15:11: PLE0118 Name `x` is used prior to global declaration on line 17 +PLE0118 Name `x` is used prior to global declaration on line 17 + --> load_before_global_declaration.py:15:11 | 13 | global x 14 | 15 | print(x) - | ^ PLE0118 + | ^ 16 | 17 | global x | -load_before_global_declaration.py:23:11: PLE0118 Name `x` is used prior to global declaration on line 25 +PLE0118 Name `x` is used prior to global declaration on line 25 + --> load_before_global_declaration.py:23:11 | 22 | def f(): 23 | print(x) - | ^ PLE0118 + | ^ 24 | 25 | global x, y | -load_before_global_declaration.py:33:11: PLE0118 Name `x` is used prior to global declaration on line 35 +PLE0118 Name `x` is used prior to global declaration on line 35 + --> load_before_global_declaration.py:33:11 | 31 | global x, y 32 | 33 | print(x) - | ^ PLE0118 + | ^ 34 | 35 | global x, y | -load_before_global_declaration.py:41:5: PLE0118 Name `x` is used prior to global declaration on line 43 +PLE0118 Name `x` is used prior to global declaration on line 43 + --> load_before_global_declaration.py:41:5 | 40 | def f(): 41 | x = 1 - | ^ PLE0118 + | ^ 42 | 43 | global x | -load_before_global_declaration.py:51:5: PLE0118 Name `x` is used prior to global declaration on line 53 +PLE0118 Name `x` is used prior to global declaration on line 53 + --> load_before_global_declaration.py:51:5 | 49 | global x 50 | 51 | x = 1 - | ^ PLE0118 + | ^ 52 | 53 | global x | -load_before_global_declaration.py:59:9: PLE0118 Name `x` is used prior to global declaration on line 61 +PLE0118 Name `x` is used prior to global declaration on line 61 + --> load_before_global_declaration.py:59:9 | 58 | def f(): 59 | del x - | ^ PLE0118 + | ^ 60 | 61 | global x, y | -load_before_global_declaration.py:69:9: PLE0118 Name `x` is used prior to global declaration on line 71 +PLE0118 Name `x` is used prior to global declaration on line 71 + --> load_before_global_declaration.py:69:9 | 67 | global x, y 68 | 69 | del x - | ^ PLE0118 + | ^ 70 | 71 | global x, y | -load_before_global_declaration.py:77:9: PLE0118 Name `x` is used prior to global declaration on line 79 +PLE0118 Name `x` is used prior to global declaration on line 79 + --> load_before_global_declaration.py:77:9 | 76 | def f(): 77 | del x - | ^ PLE0118 + | ^ 78 | 79 | global x | -load_before_global_declaration.py:87:9: PLE0118 Name `x` is used prior to global declaration on line 89 +PLE0118 Name `x` is used prior to global declaration on line 89 + --> load_before_global_declaration.py:87:9 | 85 | global x 86 | 87 | del x - | ^ PLE0118 + | ^ 88 | 89 | global x | -load_before_global_declaration.py:95:9: PLE0118 Name `x` is used prior to global declaration on line 97 +PLE0118 Name `x` is used prior to global declaration on line 97 + --> load_before_global_declaration.py:95:9 | 94 | def f(): 95 | del x - | ^ PLE0118 + | ^ 96 | 97 | global x, y | -load_before_global_declaration.py:105:9: PLE0118 Name `x` is used prior to global declaration on line 107 +PLE0118 Name `x` is used prior to global declaration on line 107 + --> load_before_global_declaration.py:105:9 | 103 | global x, y 104 | 105 | del x - | ^ PLE0118 + | ^ 106 | 107 | global x, y | -load_before_global_declaration.py:113:14: PLE0118 Name `x` is used prior to global declaration on line 114 +PLE0118 Name `x` is used prior to global declaration on line 114 + --> load_before_global_declaration.py:113:14 | 112 | def f(): 113 | print(f"{x=}") - | ^ PLE0118 + | ^ 114 | global x | -load_before_global_declaration.py:162:1: PLE0118 Name `x` is used prior to global declaration on line 163 +PLE0118 Name `x` is used prior to global declaration on line 163 + --> load_before_global_declaration.py:162:1 | 161 | # surprisingly still an error, global in module scope 162 | x = None - | ^ PLE0118 + | ^ 163 | global x | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0237_non_slot_assignment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0237_non_slot_assignment.py.snap index f053c56e66..ffa9f688bf 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0237_non_slot_assignment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0237_non_slot_assignment.py.snap @@ -1,30 +1,32 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -non_slot_assignment.py:6:9: PLE0237 Attribute `surname` is not defined in class's `__slots__` +PLE0237 Attribute `surname` is not defined in class's `__slots__` + --> non_slot_assignment.py:6:9 | 4 | def __init__(self, name, surname): 5 | self.name = name 6 | self.surname = surname # [assigning-non-slot] - | ^^^^^^^^^^^^ PLE0237 + | ^^^^^^^^^^^^ 7 | self.setup() | -non_slot_assignment.py:18:9: PLE0237 Attribute `middle_name` is not defined in class's `__slots__` +PLE0237 Attribute `middle_name` is not defined in class's `__slots__` + --> non_slot_assignment.py:18:9 | 16 | def __init__(self, name, middle_name): 17 | self.name = name 18 | self.middle_name = middle_name # [assigning-non-slot] - | ^^^^^^^^^^^^^^^^ PLE0237 + | ^^^^^^^^^^^^^^^^ 19 | self.setup() | -non_slot_assignment.py:42:9: PLE0237 Attribute `middle_name` is not defined in class's `__slots__` +PLE0237 Attribute `middle_name` is not defined in class's `__slots__` + --> non_slot_assignment.py:42:9 | 40 | def __init__(self, name, middle_name): 41 | self.name = name 42 | self.middle_name = middle_name # [assigning-non-slot] - | ^^^^^^^^^^^^^^^^ PLE0237 + | ^^^^^^^^^^^^^^^^ 43 | self.setup() | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap index 7848ac3fb6..5961b78d8e 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -duplicate_bases.py:13:13: PLE0241 [*] Duplicate base `A` for class `F1` +PLE0241 [*] Duplicate base `A` for class `F1` + --> duplicate_bases.py:13:13 | 12 | # Duplicate base class is last. 13 | class F1(A, A): - | ^ PLE0241 + | ^ 14 | ... | - = help: Remove duplicate base +help: Remove duplicate base ℹ Safe fix 10 10 | @@ -20,13 +21,14 @@ duplicate_bases.py:13:13: PLE0241 [*] Duplicate base `A` for class `F1` 15 15 | 16 16 | -duplicate_bases.py:17:13: PLE0241 [*] Duplicate base `A` for class `F2` +PLE0241 [*] Duplicate base `A` for class `F2` + --> duplicate_bases.py:17:13 | 17 | class F2(A, A,): - | ^ PLE0241 + | ^ 18 | ... | - = help: Remove duplicate base +help: Remove duplicate base ℹ Safe fix 14 14 | ... @@ -38,16 +40,17 @@ duplicate_bases.py:17:13: PLE0241 [*] Duplicate base `A` for class `F2` 19 19 | 20 20 | -duplicate_bases.py:23:5: PLE0241 [*] Duplicate base `A` for class `F3` +PLE0241 [*] Duplicate base `A` for class `F3` + --> duplicate_bases.py:23:5 | 21 | class F3( 22 | A, 23 | A - | ^ PLE0241 + | ^ 24 | ): 25 | ... | - = help: Remove duplicate base +help: Remove duplicate base ℹ Safe fix 19 19 | @@ -58,16 +61,17 @@ duplicate_bases.py:23:5: PLE0241 [*] Duplicate base `A` for class `F3` 24 23 | ): 25 24 | ... -duplicate_bases.py:30:5: PLE0241 [*] Duplicate base `A` for class `F4` +PLE0241 [*] Duplicate base `A` for class `F4` + --> duplicate_bases.py:30:5 | 28 | class F4( 29 | A, 30 | A, - | ^ PLE0241 + | ^ 31 | ): 32 | ... | - = help: Remove duplicate base +help: Remove duplicate base ℹ Safe fix 27 27 | @@ -78,14 +82,15 @@ duplicate_bases.py:30:5: PLE0241 [*] Duplicate base `A` for class `F4` 32 31 | ... 33 32 | -duplicate_bases.py:36:13: PLE0241 [*] Duplicate base `A` for class `G1` +PLE0241 [*] Duplicate base `A` for class `G1` + --> duplicate_bases.py:36:13 | 35 | # Duplicate base class is not last. 36 | class G1(A, A, B): - | ^ PLE0241 + | ^ 37 | ... | - = help: Remove duplicate base +help: Remove duplicate base ℹ Safe fix 33 33 | @@ -97,13 +102,14 @@ duplicate_bases.py:36:13: PLE0241 [*] Duplicate base `A` for class `G1` 38 38 | 39 39 | -duplicate_bases.py:40:13: PLE0241 [*] Duplicate base `A` for class `G2` +PLE0241 [*] Duplicate base `A` for class `G2` + --> duplicate_bases.py:40:13 | 40 | class G2(A, A, B,): - | ^ PLE0241 + | ^ 41 | ... | - = help: Remove duplicate base +help: Remove duplicate base ℹ Safe fix 37 37 | ... @@ -115,16 +121,17 @@ duplicate_bases.py:40:13: PLE0241 [*] Duplicate base `A` for class `G2` 42 42 | 43 43 | -duplicate_bases.py:46:5: PLE0241 [*] Duplicate base `A` for class `G3` +PLE0241 [*] Duplicate base `A` for class `G3` + --> duplicate_bases.py:46:5 | 44 | class G3( 45 | A, 46 | A, - | ^ PLE0241 + | ^ 47 | B 48 | ): | - = help: Remove duplicate base +help: Remove duplicate base ℹ Safe fix 43 43 | @@ -135,16 +142,17 @@ duplicate_bases.py:46:5: PLE0241 [*] Duplicate base `A` for class `G3` 48 47 | ): 49 48 | ... -duplicate_bases.py:54:5: PLE0241 [*] Duplicate base `A` for class `G4` +PLE0241 [*] Duplicate base `A` for class `G4` + --> duplicate_bases.py:54:5 | 52 | class G4( 53 | A, 54 | A, - | ^ PLE0241 + | ^ 55 | B, 56 | ): | - = help: Remove duplicate base +help: Remove duplicate base ℹ Safe fix 51 51 | @@ -155,16 +163,17 @@ duplicate_bases.py:54:5: PLE0241 [*] Duplicate base `A` for class `G4` 56 55 | ): 57 56 | ... -duplicate_bases.py:76:5: PLE0241 [*] Duplicate base `Foo` for class `Bar` +PLE0241 [*] Duplicate base `Foo` for class `Bar` + --> duplicate_bases.py:76:5 | 74 | # https://github.com/astral-sh/ruff/issues/18814 75 | class Bar(Foo, # 1 76 | Foo # 2 - | ^^^ PLE0241 + | ^^^ 77 | ): 78 | pass | - = help: Remove duplicate base +help: Remove duplicate base ℹ Unsafe fix 72 72 | ... diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap index c97826b90f..5a6196b824 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap @@ -1,145 +1,161 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -unexpected_special_method_signature.py:5:9: PLE0302 The special method `__bool__` expects 1 parameter, 2 were given +PLE0302 The special method `__bool__` expects 1 parameter, 2 were given + --> unexpected_special_method_signature.py:5:9 | 3 | ... 4 | 5 | def __bool__(self, x): # too many mandatory args - | ^^^^^^^^ PLE0302 + | ^^^^^^^^ 6 | ... | -unexpected_special_method_signature.py:19:9: PLE0302 The special method `__bool__` expects 0 parameters, 1 was given +PLE0302 The special method `__bool__` expects 0 parameters, 1 was given + --> unexpected_special_method_signature.py:19:9 | 18 | @staticmethod 19 | def __bool__(x): # too many mandatory args - | ^^^^^^^^ PLE0302 + | ^^^^^^^^ 20 | ... | -unexpected_special_method_signature.py:32:9: PLE0302 The special method `__eq__` expects 2 parameters, 1 was given +PLE0302 The special method `__eq__` expects 2 parameters, 1 was given + --> unexpected_special_method_signature.py:32:9 | 30 | ... 31 | 32 | def __eq__(self): # too few mandatory args - | ^^^^^^ PLE0302 + | ^^^^^^ 33 | ... | -unexpected_special_method_signature.py:35:9: PLE0302 The special method `__eq__` expects 2 parameters, 3 were given +PLE0302 The special method `__eq__` expects 2 parameters, 3 were given + --> unexpected_special_method_signature.py:35:9 | 33 | ... 34 | 35 | def __eq__(self, other, other_other): # too many mandatory args - | ^^^^^^ PLE0302 + | ^^^^^^ 36 | ... | -unexpected_special_method_signature.py:44:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given +PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given + --> unexpected_special_method_signature.py:44:9 | 42 | ... 43 | 44 | def __round__(self, x, y): # disallow 2 args - | ^^^^^^^^^ PLE0302 + | ^^^^^^^^^ 45 | ... | -unexpected_special_method_signature.py:47:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 4 were given +PLE0302 The special method `__round__` expects between 1 and 2 parameters, 4 were given + --> unexpected_special_method_signature.py:47:9 | 45 | ... 46 | 47 | def __round__(self, x, y, z=2): # disallow 3 args even when one is optional - | ^^^^^^^^^ PLE0302 + | ^^^^^^^^^ 48 | ... | -unexpected_special_method_signature.py:56:9: PLE0302 The special method `__eq__` expects 2 parameters, 3 were given +PLE0302 The special method `__eq__` expects 2 parameters, 3 were given + --> unexpected_special_method_signature.py:56:9 | 54 | ... 55 | 56 | def __eq__(self, x, y, *args): # too many args with *args - | ^^^^^^ PLE0302 + | ^^^^^^ 57 | ... | -unexpected_special_method_signature.py:65:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given +PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given + --> unexpected_special_method_signature.py:65:9 | 63 | ... 64 | 65 | def __round__(self, x, y, *args): # disallow 2 args - | ^^^^^^^^^ PLE0302 + | ^^^^^^^^^ 66 | ... | -unexpected_special_method_signature.py:89:9: PLE0302 The special method `__next__` expects 1 parameter, 2 were given +PLE0302 The special method `__next__` expects 1 parameter, 2 were given + --> unexpected_special_method_signature.py:89:9 | 87 | ... 88 | 89 | def __next__(self, x): # #16217 assert special method is linted, expects 1 parameter - | ^^^^^^^^ PLE0302 + | ^^^^^^^^ 90 | ... | -unexpected_special_method_signature.py:92:9: PLE0302 The special method `__buffer__` expects 2 parameters, 1 was given +PLE0302 The special method `__buffer__` expects 2 parameters, 1 was given + --> unexpected_special_method_signature.py:92:9 | 90 | ... 91 | 92 | def __buffer__(self): # #16217 assert special method is linted, expects 2 parameters - | ^^^^^^^^^^ PLE0302 + | ^^^^^^^^^^ 93 | ... | -unexpected_special_method_signature.py:95:9: PLE0302 The special method `__class_getitem__` expects 2 parameters, 1 was given +PLE0302 The special method `__class_getitem__` expects 2 parameters, 1 was given + --> unexpected_special_method_signature.py:95:9 | 93 | ... 94 | 95 | def __class_getitem__(self): # #16217 assert special method is linted, expects 2 parameters - | ^^^^^^^^^^^^^^^^^ PLE0302 + | ^^^^^^^^^^^^^^^^^ 96 | ... | -unexpected_special_method_signature.py:98:9: PLE0302 The special method `__mro_entries__` expects 2 parameters, 1 was given +PLE0302 The special method `__mro_entries__` expects 2 parameters, 1 was given + --> unexpected_special_method_signature.py:98:9 | 96 | ... 97 | 98 | def __mro_entries__(self): # #16217 assert special method is linted, expects 2 parameters - | ^^^^^^^^^^^^^^^ PLE0302 + | ^^^^^^^^^^^^^^^ 99 | ... | -unexpected_special_method_signature.py:101:9: PLE0302 The special method `__release_buffer__` expects 2 parameters, 1 was given +PLE0302 The special method `__release_buffer__` expects 2 parameters, 1 was given + --> unexpected_special_method_signature.py:101:9 | 99 | ... 100 | 101 | def __release_buffer__(self): # #16217 assert special method is linted, expects 2 parameters - | ^^^^^^^^^^^^^^^^^^ PLE0302 + | ^^^^^^^^^^^^^^^^^^ 102 | ... | -unexpected_special_method_signature.py:104:9: PLE0302 The special method `__subclasshook__` expects 2 parameters, 1 was given +PLE0302 The special method `__subclasshook__` expects 2 parameters, 1 was given + --> unexpected_special_method_signature.py:104:9 | 102 | ... 103 | 104 | def __subclasshook__(self): # #16217 assert special method is linted, expects 2 parameters - | ^^^^^^^^^^^^^^^^ PLE0302 + | ^^^^^^^^^^^^^^^^ 105 | ... | -unexpected_special_method_signature.py:107:9: PLE0302 The special method `__setattr__` expects 3 parameters, 2 were given +PLE0302 The special method `__setattr__` expects 3 parameters, 2 were given + --> unexpected_special_method_signature.py:107:9 | 105 | ... 106 | 107 | def __setattr__(self, /, name): # #16217 assert positional-only special method is linted, expects 3 parameters - | ^^^^^^^^^^^ PLE0302 + | ^^^^^^^^^^^ 108 | ... | -unexpected_special_method_signature.py:110:9: PLE0302 The special method `__setitem__` expects 3 parameters, 4 were given +PLE0302 The special method `__setitem__` expects 3 parameters, 4 were given + --> unexpected_special_method_signature.py:110:9 | 108 | ... 109 | 110 | def __setitem__(self, key, /, value, extra_value): # #16217 assert positional-only special method is linted, expects 3 parameters - | ^^^^^^^^^^^ PLE0302 + | ^^^^^^^^^^^ 111 | ... | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0303_invalid_return_type_length.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0303_invalid_return_type_length.py.snap index f7a85c61e5..55b8ad7aa0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0303_invalid_return_type_length.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0303_invalid_return_type_length.py.snap @@ -1,43 +1,47 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -invalid_return_type_length.py:6:16: PLE0303 `__len__` does not return a non-negative integer +PLE0303 `__len__` does not return a non-negative integer + --> invalid_return_type_length.py:6:16 | 4 | class Bool: 5 | def __len__(self): 6 | return True # [invalid-length-return] - | ^^^^ PLE0303 + | ^^^^ | -invalid_return_type_length.py:11:16: PLE0303 `__len__` does not return a non-negative integer +PLE0303 `__len__` does not return a non-negative integer + --> invalid_return_type_length.py:11:16 | 9 | class Float: 10 | def __len__(self): 11 | return 3.05 # [invalid-length-return] - | ^^^^ PLE0303 + | ^^^^ | -invalid_return_type_length.py:16:16: PLE0303 `__len__` does not return a non-negative integer +PLE0303 `__len__` does not return a non-negative integer + --> invalid_return_type_length.py:16:16 | 14 | class Str: 15 | def __len__(self): 16 | return "ruff" # [invalid-length-return] - | ^^^^^^ PLE0303 + | ^^^^^^ | -invalid_return_type_length.py:20:9: PLE0303 `__len__` does not return a non-negative integer +PLE0303 `__len__` does not return a non-negative integer + --> invalid_return_type_length.py:20:9 | 19 | class LengthNoReturn: 20 | def __len__(self): - | ^^^^^^^ PLE0303 + | ^^^^^^^ 21 | print("ruff") # [invalid-length-return] | -invalid_return_type_length.py:26:16: PLE0303 `__len__` does not return a non-negative integer +PLE0303 `__len__` does not return a non-negative integer + --> invalid_return_type_length.py:26:16 | 24 | class LengthNegative: 25 | def __len__(self): 26 | return -42 # [invalid-length-return] - | ^^^ PLE0303 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0304_invalid_return_type_bool.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0304_invalid_return_type_bool.py.snap index 4f156b0611..efbea371b0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0304_invalid_return_type_bool.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0304_invalid_return_type_bool.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -invalid_return_type_bool.py:5:16: PLE0304 `__bool__` does not return `bool` +PLE0304 `__bool__` does not return `bool` + --> invalid_return_type_bool.py:5:16 | 3 | class Float: 4 | def __bool__(self): 5 | return 3.05 # [invalid-bool-return] - | ^^^^ PLE0304 + | ^^^^ 6 | 7 | class Int: | -invalid_return_type_bool.py:9:16: PLE0304 `__bool__` does not return `bool` +PLE0304 `__bool__` does not return `bool` + --> invalid_return_type_bool.py:9:16 | 7 | class Int: 8 | def __bool__(self): 9 | return 0 # [invalid-bool-return] - | ^ PLE0304 + | ^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0305_invalid_return_type_index.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0305_invalid_return_type_index.py.snap index 92964417da..6e707341df 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0305_invalid_return_type_index.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0305_invalid_return_type_index.py.snap @@ -1,42 +1,46 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -invalid_return_type_index.py:8:16: PLE0305 `__index__` does not return an integer +PLE0305 `__index__` does not return an integer + --> invalid_return_type_index.py:8:16 | 7 | def __index__(self): 8 | return True # [invalid-index-return] - | ^^^^ PLE0305 + | ^^^^ | -invalid_return_type_index.py:13:16: PLE0305 `__index__` does not return an integer +PLE0305 `__index__` does not return an integer + --> invalid_return_type_index.py:13:16 | 11 | class Float: 12 | def __index__(self): 13 | return 3.05 # [invalid-index-return] - | ^^^^ PLE0305 + | ^^^^ | -invalid_return_type_index.py:18:16: PLE0305 `__index__` does not return an integer +PLE0305 `__index__` does not return an integer + --> invalid_return_type_index.py:18:16 | 16 | class Dict: 17 | def __index__(self): 18 | return {"1": "1"} # [invalid-index-return] - | ^^^^^^^^^^ PLE0305 + | ^^^^^^^^^^ | -invalid_return_type_index.py:23:16: PLE0305 `__index__` does not return an integer +PLE0305 `__index__` does not return an integer + --> invalid_return_type_index.py:23:16 | 21 | class Str: 22 | def __index__(self): 23 | return "ruff" # [invalid-index-return] - | ^^^^^^ PLE0305 + | ^^^^^^ | -invalid_return_type_index.py:27:9: PLE0305 `__index__` does not return an integer +PLE0305 `__index__` does not return an integer + --> invalid_return_type_index.py:27:9 | 26 | class IndexNoReturn: 27 | def __index__(self): - | ^^^^^^^^^ PLE0305 + | ^^^^^^^^^ 28 | print("ruff") # [invalid-index-return] | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap index 31fe3edc92..779d6da34a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap @@ -1,44 +1,48 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -invalid_return_type_str.py:6:16: PLE0307 `__str__` does not return `str` +PLE0307 `__str__` does not return `str` + --> invalid_return_type_str.py:6:16 | 4 | class Float: 5 | def __str__(self): 6 | return 3.05 - | ^^^^ PLE0307 + | ^^^^ | -invalid_return_type_str.py:11:16: PLE0307 `__str__` does not return `str` +PLE0307 `__str__` does not return `str` + --> invalid_return_type_str.py:11:16 | 9 | class Int: 10 | def __str__(self): 11 | return 1 - | ^ PLE0307 + | ^ | -invalid_return_type_str.py:16:16: PLE0307 `__str__` does not return `str` +PLE0307 `__str__` does not return `str` + --> invalid_return_type_str.py:16:16 | 14 | class Int2: 15 | def __str__(self): 16 | return 0 - | ^ PLE0307 + | ^ | -invalid_return_type_str.py:21:16: PLE0307 `__str__` does not return `str` +PLE0307 `__str__` does not return `str` + --> invalid_return_type_str.py:21:16 | 19 | class Bool: 20 | def __str__(self): 21 | return False - | ^^^^^ PLE0307 + | ^^^^^ | -invalid_return_type_str.py:58:9: PLE0307 `__str__` does not return `str` +PLE0307 `__str__` does not return `str` + --> invalid_return_type_str.py:58:9 | 57 | class Str5: 58 | def __str__(self): # PLE0307 (returns None if x <= 0) - | ^^^^^^^ PLE0307 + | ^^^^^^^ 59 | if x > 0: 60 | raise RuntimeError("__str__ not allowed") | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0308_invalid_return_type_bytes.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0308_invalid_return_type_bytes.py.snap index 3f2c76c929..597bc48971 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0308_invalid_return_type_bytes.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0308_invalid_return_type_bytes.py.snap @@ -1,35 +1,38 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -invalid_return_type_bytes.py:6:16: PLE0308 `__bytes__` does not return `bytes` +PLE0308 `__bytes__` does not return `bytes` + --> invalid_return_type_bytes.py:6:16 | 4 | class Float: 5 | def __bytes__(self): 6 | return 3.05 # [invalid-bytes-return] - | ^^^^ PLE0308 + | ^^^^ | -invalid_return_type_bytes.py:11:16: PLE0308 `__bytes__` does not return `bytes` +PLE0308 `__bytes__` does not return `bytes` + --> invalid_return_type_bytes.py:11:16 | 9 | class Int: 10 | def __bytes__(self): 11 | return 0 # [invalid-bytes-return] - | ^ PLE0308 + | ^ | -invalid_return_type_bytes.py:16:16: PLE0308 `__bytes__` does not return `bytes` +PLE0308 `__bytes__` does not return `bytes` + --> invalid_return_type_bytes.py:16:16 | 14 | class Str: 15 | def __bytes__(self): 16 | return "some bytes" # [invalid-bytes-return] - | ^^^^^^^^^^^^ PLE0308 + | ^^^^^^^^^^^^ | -invalid_return_type_bytes.py:20:9: PLE0308 `__bytes__` does not return `bytes` +PLE0308 `__bytes__` does not return `bytes` + --> invalid_return_type_bytes.py:20:9 | 19 | class BytesNoReturn: 20 | def __bytes__(self): - | ^^^^^^^^^ PLE0308 + | ^^^^^^^^^ 21 | print("ruff") # [invalid-bytes-return] | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0309_invalid_return_type_hash.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0309_invalid_return_type_hash.py.snap index 23f61bc9dc..466ddc53bb 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0309_invalid_return_type_hash.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0309_invalid_return_type_hash.py.snap @@ -1,35 +1,38 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -invalid_return_type_hash.py:6:16: PLE0309 `__hash__` does not return an integer +PLE0309 `__hash__` does not return an integer + --> invalid_return_type_hash.py:6:16 | 4 | class Bool: 5 | def __hash__(self): 6 | return True # [invalid-hash-return] - | ^^^^ PLE0309 + | ^^^^ | -invalid_return_type_hash.py:11:16: PLE0309 `__hash__` does not return an integer +PLE0309 `__hash__` does not return an integer + --> invalid_return_type_hash.py:11:16 | 9 | class Float: 10 | def __hash__(self): 11 | return 3.05 # [invalid-hash-return] - | ^^^^ PLE0309 + | ^^^^ | -invalid_return_type_hash.py:16:16: PLE0309 `__hash__` does not return an integer +PLE0309 `__hash__` does not return an integer + --> invalid_return_type_hash.py:16:16 | 14 | class Str: 15 | def __hash__(self): 16 | return "ruff" # [invalid-hash-return] - | ^^^^^^ PLE0309 + | ^^^^^^ | -invalid_return_type_hash.py:20:9: PLE0309 `__hash__` does not return an integer +PLE0309 `__hash__` does not return an integer + --> invalid_return_type_hash.py:20:9 | 19 | class HashNoReturn: 20 | def __hash__(self): - | ^^^^^^^^ PLE0309 + | ^^^^^^^^ 21 | print("ruff") # [invalid-hash-return] | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap index 775afaf683..ade9450cef 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -invalid_all_object.py:1:1: PLE0604 Invalid object in `__all__`, must contain only strings +PLE0604 Invalid object in `__all__`, must contain only strings + --> invalid_all_object.py:1:1 | 1 | __all__ = ( - | ^^^^^^^ PLE0604 + | ^^^^^^^ 2 | None, # [invalid-all-object] 3 | Fruit, | -invalid_all_object.py:7:1: PLE0604 Invalid object in `__all__`, must contain only strings +PLE0604 Invalid object in `__all__`, must contain only strings + --> invalid_all_object.py:7:1 | 5 | ) 6 | 7 | __all__ = list([None, "Fruit", "Worm"]) # [invalid-all-object] - | ^^^^^^^ PLE0604 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap index f2ae393351..2e52733f9f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap @@ -1,130 +1,143 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -invalid_all_format.py:1:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:1:1 | 1 | __all__ = "CONST" # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 2 | 3 | __all__ = ["Hello"] + {"world"} # [invalid-all-format] | -invalid_all_format.py:3:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:3:1 | 1 | __all__ = "CONST" # [invalid-all-format] 2 | 3 | __all__ = ["Hello"] + {"world"} # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 4 | 5 | __all__ += {"world"} # [invalid-all-format] | -invalid_all_format.py:5:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:5:1 | 3 | __all__ = ["Hello"] + {"world"} # [invalid-all-format] 4 | 5 | __all__ += {"world"} # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 6 | 7 | __all__ = {"world"} + ["Hello"] # [invalid-all-format] | -invalid_all_format.py:7:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:7:1 | 5 | __all__ += {"world"} # [invalid-all-format] 6 | 7 | __all__ = {"world"} + ["Hello"] # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 8 | 9 | __all__ = {"world"} + list(["Hello"]) # [invalid-all-format] | -invalid_all_format.py:9:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:9:1 | 7 | __all__ = {"world"} + ["Hello"] # [invalid-all-format] 8 | 9 | __all__ = {"world"} + list(["Hello"]) # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 10 | 11 | __all__ = list(["Hello"]) + {"world"} # [invalid-all-format] | -invalid_all_format.py:11:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:11:1 | 9 | __all__ = {"world"} + list(["Hello"]) # [invalid-all-format] 10 | 11 | __all__ = list(["Hello"]) + {"world"} # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 12 | 13 | __all__ = (x for x in ["Hello", "world"]) # [invalid-all-format] | -invalid_all_format.py:13:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:13:1 | 11 | __all__ = list(["Hello"]) + {"world"} # [invalid-all-format] 12 | 13 | __all__ = (x for x in ["Hello", "world"]) # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 14 | 15 | __all__ = {x for x in ["Hello", "world"]} # [invalid-all-format] | -invalid_all_format.py:15:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:15:1 | 13 | __all__ = (x for x in ["Hello", "world"]) # [invalid-all-format] 14 | 15 | __all__ = {x for x in ["Hello", "world"]} # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 16 | 17 | __all__ = foo # [invalid-all-format] | -invalid_all_format.py:17:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:17:1 | 15 | __all__ = {x for x in ["Hello", "world"]} # [invalid-all-format] 16 | 17 | __all__ = foo # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 18 | 19 | __all__ = foo.bar # [invalid-all-format] | -invalid_all_format.py:19:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:19:1 | 17 | __all__ = foo # [invalid-all-format] 18 | 19 | __all__ = foo.bar # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 20 | 21 | __all__ = foo["bar"] # [invalid-all-format] | -invalid_all_format.py:21:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:21:1 | 19 | __all__ = foo.bar # [invalid-all-format] 20 | 21 | __all__ = foo["bar"] # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 22 | 23 | __all__ = (foo := bar) # [invalid-all-format] | -invalid_all_format.py:23:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:23:1 | 21 | __all__ = foo["bar"] # [invalid-all-format] 22 | 23 | __all__ = (foo := bar) # [invalid-all-format] - | ^^^^^^^ PLE0605 + | ^^^^^^^ 24 | 25 | __all__ = ["Hello"] | -invalid_all_format.py:23:12: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` +PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + --> invalid_all_format.py:23:12 | 21 | __all__ = foo["bar"] # [invalid-all-format] 22 | 23 | __all__ = (foo := bar) # [invalid-all-format] - | ^^^ PLE0605 + | ^^^ 24 | 25 | __all__ = ["Hello"] | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0643_potential_index_error.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0643_potential_index_error.py.snap index 78dcba4f77..0a3a7fcfab 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0643_potential_index_error.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0643_potential_index_error.py.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -potential_index_error.py:1:17: PLE0643 Expression is likely to raise `IndexError` +PLE0643 Expression is likely to raise `IndexError` + --> potential_index_error.py:1:17 | 1 | print([1, 2, 3][3]) # PLE0643 - | ^ PLE0643 + | ^ 2 | print([1, 2, 3][-4]) # PLE0643 3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643 | -potential_index_error.py:2:17: PLE0643 Expression is likely to raise `IndexError` +PLE0643 Expression is likely to raise `IndexError` + --> potential_index_error.py:2:17 | 1 | print([1, 2, 3][3]) # PLE0643 2 | print([1, 2, 3][-4]) # PLE0643 - | ^^ PLE0643 + | ^^ 3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643 4 | print([1, 2, 3][-999999999999999999999999999999999999999999]) # PLE0643 | -potential_index_error.py:3:17: PLE0643 Expression is likely to raise `IndexError` +PLE0643 Expression is likely to raise `IndexError` + --> potential_index_error.py:3:17 | 1 | print([1, 2, 3][3]) # PLE0643 2 | print([1, 2, 3][-4]) # PLE0643 3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE0643 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | print([1, 2, 3][-999999999999999999999999999999999999999999]) # PLE0643 | -potential_index_error.py:4:17: PLE0643 Expression is likely to raise `IndexError` +PLE0643 Expression is likely to raise `IndexError` + --> potential_index_error.py:4:17 | 2 | print([1, 2, 3][-4]) # PLE0643 3 | print([1, 2, 3][999999999999999999999999999999999999999999]) # PLE0643 4 | print([1, 2, 3][-999999999999999999999999999999999999999999]) # PLE0643 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE0643 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | print([1, 2, 3][2]) # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0704_misplaced_bare_raise.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0704_misplaced_bare_raise.py.snap index 560e9029f0..5d3ee1f406 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0704_misplaced_bare_raise.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0704_misplaced_bare_raise.py.snap @@ -1,88 +1,97 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -misplaced_bare_raise.py:30:5: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:30:5 | 29 | try: 30 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ 31 | except Exception: 32 | pass | -misplaced_bare_raise.py:36:9: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:36:9 | 34 | def f(): 35 | try: 36 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ 37 | except Exception: 38 | pass | -misplaced_bare_raise.py:41:5: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:41:5 | 40 | def g(): 41 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ 42 | 43 | def h(): | -misplaced_bare_raise.py:47:17: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:47:17 | 45 | if True: 46 | def i(): 47 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ 48 | except Exception: 49 | pass | -misplaced_bare_raise.py:50:5: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:50:5 | 48 | except Exception: 49 | pass 50 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ 51 | 52 | raise # [misplaced-bare-raise] | -misplaced_bare_raise.py:52:1: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:52:1 | 50 | raise # [misplaced-bare-raise] 51 | 52 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ 53 | 54 | try: | -misplaced_bare_raise.py:58:9: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:58:9 | 56 | except: 57 | def i(): 58 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ 59 | 60 | try: | -misplaced_bare_raise.py:64:9: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:64:9 | 62 | except: 63 | class C: 64 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ 65 | 66 | try: | -misplaced_bare_raise.py:71:5: PLE0704 Bare `raise` statement is not inside an exception handler +PLE0704 Bare `raise` statement is not inside an exception handler + --> misplaced_bare_raise.py:71:5 | 69 | pass 70 | finally: 71 | raise # [misplaced-bare-raise] - | ^^^^^ PLE0704 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1132_repeated_keyword_argument.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1132_repeated_keyword_argument.py.snap index 702fb4f4c9..8c677630f1 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1132_repeated_keyword_argument.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1132_repeated_keyword_argument.py.snap @@ -1,79 +1,86 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -repeated_keyword_argument.py:16:21: PLE1132 Repeated keyword argument: `c` +PLE1132 Repeated keyword argument: `c` + --> repeated_keyword_argument.py:16:21 | 15 | # Invalid 16 | func(a=11, c=31, **{"c": 41}) - | ^^^ PLE1132 + | ^^^ 17 | func(a=11, c=31, **{"c": 41, "a": 51}) 18 | func(a=11, b=21, c=31, **{"b": 22, "c": 41, "a": 51}) | -repeated_keyword_argument.py:17:21: PLE1132 Repeated keyword argument: `c` +PLE1132 Repeated keyword argument: `c` + --> repeated_keyword_argument.py:17:21 | 15 | # Invalid 16 | func(a=11, c=31, **{"c": 41}) 17 | func(a=11, c=31, **{"c": 41, "a": 51}) - | ^^^ PLE1132 + | ^^^ 18 | func(a=11, b=21, c=31, **{"b": 22, "c": 41, "a": 51}) 19 | func(a=11, b=21, **{"c": 31}, **{"c": 32}) | -repeated_keyword_argument.py:17:30: PLE1132 Repeated keyword argument: `a` +PLE1132 Repeated keyword argument: `a` + --> repeated_keyword_argument.py:17:30 | 15 | # Invalid 16 | func(a=11, c=31, **{"c": 41}) 17 | func(a=11, c=31, **{"c": 41, "a": 51}) - | ^^^ PLE1132 + | ^^^ 18 | func(a=11, b=21, c=31, **{"b": 22, "c": 41, "a": 51}) 19 | func(a=11, b=21, **{"c": 31}, **{"c": 32}) | -repeated_keyword_argument.py:18:27: PLE1132 Repeated keyword argument: `b` +PLE1132 Repeated keyword argument: `b` + --> repeated_keyword_argument.py:18:27 | 16 | func(a=11, c=31, **{"c": 41}) 17 | func(a=11, c=31, **{"c": 41, "a": 51}) 18 | func(a=11, b=21, c=31, **{"b": 22, "c": 41, "a": 51}) - | ^^^ PLE1132 + | ^^^ 19 | func(a=11, b=21, **{"c": 31}, **{"c": 32}) 20 | func(a=11, b=21, **{"c": 31, "c": 32}) | -repeated_keyword_argument.py:18:36: PLE1132 Repeated keyword argument: `c` +PLE1132 Repeated keyword argument: `c` + --> repeated_keyword_argument.py:18:36 | 16 | func(a=11, c=31, **{"c": 41}) 17 | func(a=11, c=31, **{"c": 41, "a": 51}) 18 | func(a=11, b=21, c=31, **{"b": 22, "c": 41, "a": 51}) - | ^^^ PLE1132 + | ^^^ 19 | func(a=11, b=21, **{"c": 31}, **{"c": 32}) 20 | func(a=11, b=21, **{"c": 31, "c": 32}) | -repeated_keyword_argument.py:18:45: PLE1132 Repeated keyword argument: `a` +PLE1132 Repeated keyword argument: `a` + --> repeated_keyword_argument.py:18:45 | 16 | func(a=11, c=31, **{"c": 41}) 17 | func(a=11, c=31, **{"c": 41, "a": 51}) 18 | func(a=11, b=21, c=31, **{"b": 22, "c": 41, "a": 51}) - | ^^^ PLE1132 + | ^^^ 19 | func(a=11, b=21, **{"c": 31}, **{"c": 32}) 20 | func(a=11, b=21, **{"c": 31, "c": 32}) | -repeated_keyword_argument.py:19:34: PLE1132 Repeated keyword argument: `c` +PLE1132 Repeated keyword argument: `c` + --> repeated_keyword_argument.py:19:34 | 17 | func(a=11, c=31, **{"c": 41, "a": 51}) 18 | func(a=11, b=21, c=31, **{"b": 22, "c": 41, "a": 51}) 19 | func(a=11, b=21, **{"c": 31}, **{"c": 32}) - | ^^^ PLE1132 + | ^^^ 20 | func(a=11, b=21, **{"c": 31, "c": 32}) | -repeated_keyword_argument.py:20:30: PLE1132 Repeated keyword argument: `c` +PLE1132 Repeated keyword argument: `c` + --> repeated_keyword_argument.py:20:30 | 18 | func(a=11, b=21, c=31, **{"b": 22, "c": 41, "a": 51}) 19 | func(a=11, b=21, **{"c": 31}, **{"c": 32}) 20 | func(a=11, b=21, **{"c": 31, "c": 32}) - | ^^^ PLE1132 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap index c99492114a..e50e12a1fa 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -dict_iter_missing_items.py:13:13: PLE1141 [*] Unpacking a dictionary in iteration without calling `.items()` +PLE1141 [*] Unpacking a dictionary in iteration without calling `.items()` + --> dict_iter_missing_items.py:13:13 | 12 | # Errors 13 | for k, v in d: - | ^ PLE1141 + | ^ 14 | pass | - = help: Add a call to `.items()` +help: Add a call to `.items()` ℹ Unsafe fix 10 10 | s2 = {1, 2, 3} @@ -20,15 +21,16 @@ dict_iter_missing_items.py:13:13: PLE1141 [*] Unpacking a dictionary in iteratio 15 15 | 16 16 | for k, v in d_tuple_incorrect_tuple: -dict_iter_missing_items.py:16:13: PLE1141 [*] Unpacking a dictionary in iteration without calling `.items()` +PLE1141 [*] Unpacking a dictionary in iteration without calling `.items()` + --> dict_iter_missing_items.py:16:13 | 14 | pass 15 | 16 | for k, v in d_tuple_incorrect_tuple: - | ^^^^^^^^^^^^^^^^^^^^^^^ PLE1141 + | ^^^^^^^^^^^^^^^^^^^^^^^ 17 | pass | - = help: Add a call to `.items()` +help: Add a call to `.items()` ℹ Unsafe fix 13 13 | for k, v in d: diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.ipynb.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.ipynb.snap index 4045604439..67bd86f7de 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.ipynb.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.ipynb.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -await_outside_async.ipynb:9:5: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.ipynb:9:5 | 8 | def foo(): 9 | await asyncio.sleep(1) # # [await-outside-async] - | ^^^^^^^^^^^^^^^^^^^^^^ PLE1142 + | ^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap index 05e0044833..5427508ed8 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap @@ -1,86 +1,97 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -await_outside_async.py:15:11: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:15:11 | 14 | def not_async(): 15 | print(await nested()) # [await-outside-async] - | ^^^^^^^^^^^^^^ PLE1142 + | ^^^^^^^^^^^^^^ | -await_outside_async.py:29:9: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:29:9 | 27 | async def func2(): 28 | def inner_func(): 29 | await asyncio.sleep(1) # [await-outside-async] - | ^^^^^^^^^^^^^^^^^^^^^^ PLE1142 + | ^^^^^^^^^^^^^^^^^^^^^^ | -await_outside_async.py:38:5: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:38:5 | 37 | def async_for_loop(): 38 | / async for x in foo(): 39 | | pass - | |____________^ PLE1142 + | |____________^ | -await_outside_async.py:43:5: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:43:5 | 42 | def async_with(): 43 | / async with foo(): 44 | | pass - | |____________^ PLE1142 + | |____________^ | -await_outside_async.py:54:6: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:54:6 | 52 | # See: https://github.com/astral-sh/ruff/issues/14167 53 | def async_for_list_comprehension_elt(): 54 | [await x for x in foo()] - | ^^^^^^^ PLE1142 + | ^^^^^^^ | -await_outside_async.py:59:8: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:59:8 | 57 | # See: https://github.com/astral-sh/ruff/issues/14167 58 | def async_for_list_comprehension(): 59 | [x async for x in foo()] - | ^^^^^^^^^^^^^^^^^^^^ PLE1142 + | ^^^^^^^^^^^^^^^^^^^^ | -await_outside_async.py:64:17: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:64:17 | 62 | # See: https://github.com/astral-sh/ruff/issues/14167 63 | def await_generator_iter(): 64 | (x for x in await foo()) - | ^^^^^^^^^^^ PLE1142 + | ^^^^^^^^^^^ | -await_outside_async.py:74:17: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:74:17 | 72 | # See: https://github.com/astral-sh/ruff/issues/14167 73 | def async_for_list_comprehension_target(): 74 | [x for x in await foo()] - | ^^^^^^^^^^^ PLE1142 + | ^^^^^^^^^^^ | -await_outside_async.py:78:6: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:78:6 | 77 | def async_for_dictionary_comprehension_key(): 78 | {await x: y for x, y in foo()} - | ^^^^^^^ PLE1142 + | ^^^^^^^ | -await_outside_async.py:82:9: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:82:9 | 81 | def async_for_dictionary_comprehension_value(): 82 | {y: await x for x, y in foo()} - | ^^^^^^^ PLE1142 + | ^^^^^^^ | -await_outside_async.py:86:11: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> await_outside_async.py:86:11 | 85 | def async_for_dict_comprehension(): 86 | {x: y async for x, y in foo()} - | ^^^^^^^^^^^^^^^^^^^^^^^ PLE1142 + | ^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap index d905356f3d..5c99c8e502 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap @@ -1,42 +1,46 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -logging_too_many_args.py:3:1: PLE1205 Too many arguments for `logging` format string +PLE1205 Too many arguments for `logging` format string + --> logging_too_many_args.py:3:1 | 1 | import logging 2 | 3 | logging.warning("Hello %s", "World!", "again") # [logging-too-many-args] - | ^^^^^^^^^^^^^^^ PLE1205 + | ^^^^^^^^^^^^^^^ 4 | 5 | logging.warning("Hello %s", "World!", "again", something="else") | -logging_too_many_args.py:5:1: PLE1205 Too many arguments for `logging` format string +PLE1205 Too many arguments for `logging` format string + --> logging_too_many_args.py:5:1 | 3 | logging.warning("Hello %s", "World!", "again") # [logging-too-many-args] 4 | 5 | logging.warning("Hello %s", "World!", "again", something="else") - | ^^^^^^^^^^^^^^^ PLE1205 + | ^^^^^^^^^^^^^^^ 6 | 7 | logging.warning("Hello %s", "World!") | -logging_too_many_args.py:29:1: PLE1205 Too many arguments for `logging` format string +PLE1205 Too many arguments for `logging` format string + --> logging_too_many_args.py:29:1 | 27 | from logging import info, error, warning 28 | 29 | warning("Hello %s", "World!", "again") # [logging-too-many-args] - | ^^^^^^^ PLE1205 + | ^^^^^^^ 30 | 31 | warning("Hello %s", "World!", "again", something="else") | -logging_too_many_args.py:31:1: PLE1205 Too many arguments for `logging` format string +PLE1205 Too many arguments for `logging` format string + --> logging_too_many_args.py:31:1 | 29 | warning("Hello %s", "World!", "again") # [logging-too-many-args] 30 | 31 | warning("Hello %s", "World!", "again", something="else") - | ^^^^^^^ PLE1205 + | ^^^^^^^ 32 | 33 | warning("Hello %s", "World!") | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap index 0961e1b05f..b9fe686170 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap @@ -1,22 +1,24 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -logging_too_few_args.py:3:1: PLE1206 Not enough arguments for `logging` format string +PLE1206 Not enough arguments for `logging` format string + --> logging_too_few_args.py:3:1 | 1 | import logging 2 | 3 | logging.warning("Hello %s %s", "World!") # [logging-too-few-args] - | ^^^^^^^^^^^^^^^ PLE1206 + | ^^^^^^^^^^^^^^^ 4 | 5 | # do not handle calls with kwargs (like pylint) | -logging_too_few_args.py:33:1: PLE1206 Not enough arguments for `logging` format string +PLE1206 Not enough arguments for `logging` format string + --> logging_too_few_args.py:33:1 | 31 | from logging import error, info, warning 32 | 33 | warning("Hello %s %s", "World!") # [logging-too-few-args] - | ^^^^^^^ PLE1206 + | ^^^^^^^ 34 | 35 | # do not handle calls with kwargs (like pylint) | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap index aed97848ee..8de582760c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap @@ -1,62 +1,68 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -bad_string_format_character.py:5:1: PLE1300 Unsupported format character 'z' +PLE1300 Unsupported format character 'z' + --> bad_string_format_character.py:5:1 | 3 | ## Old style formatting 4 | 5 | "%s %z" % ("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | "%s" "%z" % ("hello", "world") # [bad-format-character] | -bad_string_format_character.py:7:1: PLE1300 Unsupported format character 'z' +PLE1300 Unsupported format character 'z' + --> bad_string_format_character.py:7:1 | 5 | "%s %z" % ("hello", "world") # [bad-format-character] 6 | 7 | "%s" "%z" % ("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | """%s %z""" % ("hello", "world") # [bad-format-character] | -bad_string_format_character.py:9:1: PLE1300 Unsupported format character 'z' +PLE1300 Unsupported format character 'z' + --> bad_string_format_character.py:9:1 | 7 | "%s" "%z" % ("hello", "world") # [bad-format-character] 8 | 9 | """%s %z""" % ("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | """%s""" """%z""" % ("hello", "world") # [bad-format-character] | -bad_string_format_character.py:11:1: PLE1300 Unsupported format character 'z' +PLE1300 Unsupported format character 'z' + --> bad_string_format_character.py:11:1 | 9 | """%s %z""" % ("hello", "world") # [bad-format-character] 10 | 11 | """%s""" """%z""" % ("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | ## New style formatting | -bad_string_format_character.py:15:1: PLE1300 Unsupported format character 'y' +PLE1300 Unsupported format character 'y' + --> bad_string_format_character.py:15:1 | 13 | ## New style formatting 14 | 15 | "{:s} {:y}".format("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | "{:*^30s}".format("centered") # OK | -bad_string_format_character.py:19:1: PLE1300 Unsupported format character 'y' +PLE1300 Unsupported format character 'y' + --> bad_string_format_character.py:19:1 | 17 | "{:*^30s}".format("centered") # OK 18 | "{:{s}}".format("hello", s="s") # OK (nested placeholder value not checked) 19 | "{:{s:y}}".format("hello", s="s") # [bad-format-character] (nested placeholder format spec checked) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | "{0:.{prec}g}".format(1.23, prec=15) # OK (cannot validate after nested placeholder) 21 | "{0:.{foo}{bar}{foobar}y}".format(...) # OK (cannot validate after nested placeholders) | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap index 971f3addb6..d490b171ba 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap @@ -1,129 +1,142 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -bad_string_format_type.py:2:7: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:2:7 | 1 | # Errors 2 | print("foo %(foo)d bar %(bar)d" % {"foo": "1", "bar": "2"}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | "foo %e bar %s" % ("1", 2) | -bad_string_format_type.py:4:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:4:1 | 2 | print("foo %(foo)d bar %(bar)d" % {"foo": "1", "bar": "2"}) 3 | 4 | "foo %e bar %s" % ("1", 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | "%d" % "1" | -bad_string_format_type.py:6:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:6:1 | 4 | "foo %e bar %s" % ("1", 2) 5 | 6 | "%d" % "1" - | ^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^ 7 | "%o" % "1" 8 | "%(key)d" % {"key": "1"} | -bad_string_format_type.py:7:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:7:1 | 6 | "%d" % "1" 7 | "%o" % "1" - | ^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^ 8 | "%(key)d" % {"key": "1"} 9 | "%x" % 1.1 | -bad_string_format_type.py:8:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:8:1 | 6 | "%d" % "1" 7 | "%o" % "1" 8 | "%(key)d" % {"key": "1"} - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 9 | "%x" % 1.1 10 | "%(key)x" % {"key": 1.1} | -bad_string_format_type.py:9:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:9:1 | 7 | "%o" % "1" 8 | "%(key)d" % {"key": "1"} 9 | "%x" % 1.1 - | ^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^ 10 | "%(key)x" % {"key": 1.1} 11 | "%d" % [] | -bad_string_format_type.py:10:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:10:1 | 8 | "%(key)d" % {"key": "1"} 9 | "%x" % 1.1 10 | "%(key)x" % {"key": 1.1} - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 11 | "%d" % [] 12 | "%d" % ([],) | -bad_string_format_type.py:11:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:11:1 | 9 | "%x" % 1.1 10 | "%(key)x" % {"key": 1.1} 11 | "%d" % [] - | ^^^^^^^^^ PLE1307 + | ^^^^^^^^^ 12 | "%d" % ([],) 13 | "%(key)d" % {"key": []} | -bad_string_format_type.py:12:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:12:1 | 10 | "%(key)x" % {"key": 1.1} 11 | "%d" % [] 12 | "%d" % ([],) - | ^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^ 13 | "%(key)d" % {"key": []} 14 | print("%d" % ("%s" % ("nested",),)) | -bad_string_format_type.py:13:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:13:1 | 11 | "%d" % [] 12 | "%d" % ([],) 13 | "%(key)d" % {"key": []} - | ^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | print("%d" % ("%s" % ("nested",),)) 15 | "%d" % ((1, 2, 3),) | -bad_string_format_type.py:14:7: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:14:7 | 12 | "%d" % ([],) 13 | "%(key)d" % {"key": []} 14 | print("%d" % ("%s" % ("nested",),)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | "%d" % ((1, 2, 3),) 16 | "%d" % (1 if x > 0 else []) | -bad_string_format_type.py:15:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:15:1 | 13 | "%(key)d" % {"key": []} 14 | print("%d" % ("%s" % ("nested",),)) 15 | "%d" % ((1, 2, 3),) - | ^^^^^^^^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^^^^^^^^ 16 | "%d" % (1 if x > 0 else []) | -bad_string_format_type.py:16:1: PLE1307 Format type does not match argument type +PLE1307 Format type does not match argument type + --> bad_string_format_type.py:16:1 | 14 | print("%d" % ("%s" % ("nested",),)) 15 | "%d" % ((1, 2, 3),) 16 | "%d" % (1 if x > 0 else []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | # False negatives | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap index a3d6f646c0..5c2872ae8b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap @@ -1,210 +1,232 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -bad_str_strip_call.py:2:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:2:21 | 1 | # PLE1310 2 | "Hello World".strip("Hello") - | ^^^^^^^ PLE1310 + | ^^^^^^^ 3 | 4 | # PLE1310 | -bad_str_strip_call.py:5:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:5:21 | 4 | # PLE1310 5 | "Hello World".strip("Hello") - | ^^^^^^^ PLE1310 + | ^^^^^^^ 6 | 7 | # PLE1310 | -bad_str_strip_call.py:8:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:8:21 | 7 | # PLE1310 8 | "Hello World".strip(u"Hello") - | ^^^^^^^^ PLE1310 + | ^^^^^^^^ 9 | 10 | # PLE1310 | -bad_str_strip_call.py:11:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:11:21 | 10 | # PLE1310 11 | "Hello World".strip(r"Hello") - | ^^^^^^^^ PLE1310 + | ^^^^^^^^ 12 | 13 | # PLE1310 | -bad_str_strip_call.py:14:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:14:21 | 13 | # PLE1310 14 | "Hello World".strip("Hello\t") - | ^^^^^^^^^ PLE1310 + | ^^^^^^^^^ 15 | 16 | # PLE1310 | -bad_str_strip_call.py:17:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:17:21 | 16 | # PLE1310 17 | "Hello World".strip(r"Hello\t") - | ^^^^^^^^^^ PLE1310 + | ^^^^^^^^^^ 18 | 19 | # PLE1310 | -bad_str_strip_call.py:20:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:20:21 | 19 | # PLE1310 20 | "Hello World".strip("Hello\\") - | ^^^^^^^^^ PLE1310 + | ^^^^^^^^^ 21 | 22 | # PLE1310 | -bad_str_strip_call.py:23:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:23:21 | 22 | # PLE1310 23 | "Hello World".strip(r"Hello\\") - | ^^^^^^^^^^ PLE1310 + | ^^^^^^^^^^ 24 | 25 | # PLE1310 | -bad_str_strip_call.py:26:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:26:21 | 25 | # PLE1310 26 | "Hello World".strip("🤣🤣🤣🤣🙃👀😀") - | ^^^^^^^^^^^^^^^^ PLE1310 + | ^^^^^^^^^^^^^^^^ 27 | 28 | # PLE1310 | -bad_str_strip_call.py:30:5: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:30:5 | 28 | # PLE1310 29 | "Hello World".strip( 30 | / """ 31 | | there are a lot of characters to strip 32 | | """ - | |___^ PLE1310 + | |___^ 33 | ) | -bad_str_strip_call.py:36:21: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:36:21 | 35 | # PLE1310 36 | "Hello World".strip("can we get a long " \ | _____________________^ 37 | | "string of characters to strip " \ 38 | | "please?") - | |_____________________________^ PLE1310 + | |_____________________________^ 39 | 40 | # PLE1310 | -bad_str_strip_call.py:42:5: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:42:5 | 40 | # PLE1310 41 | "Hello World".strip( 42 | / "can we get a long " 43 | | "string of characters to strip " 44 | | "please?" - | |_____________^ PLE1310 + | |_____________^ 45 | ) | -bad_str_strip_call.py:49:5: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:49:5 | 47 | # PLE1310 48 | "Hello World".strip( 49 | / "can \t we get a long" 50 | | "string \t of characters to strip" 51 | | "please?" - | |_____________^ PLE1310 + | |_____________^ 52 | ) | -bad_str_strip_call.py:61:11: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:61:11 | 60 | # PLE1310 61 | u''.strip('http://') - | ^^^^^^^^^ PLE1310 + | ^^^^^^^^^ 62 | 63 | # PLE1310 | -bad_str_strip_call.py:64:12: PLE1310 String `lstrip` call contains duplicate characters (did you mean `removeprefix`?) +PLE1310 String `lstrip` call contains duplicate characters (did you mean `removeprefix`?) + --> bad_str_strip_call.py:64:12 | 63 | # PLE1310 64 | u''.lstrip('http://') - | ^^^^^^^^^ PLE1310 + | ^^^^^^^^^ 65 | 66 | # PLE1310 | -bad_str_strip_call.py:67:12: PLE1310 String `rstrip` call contains duplicate characters (did you mean `removesuffix`?) +PLE1310 String `rstrip` call contains duplicate characters (did you mean `removesuffix`?) + --> bad_str_strip_call.py:67:12 | 66 | # PLE1310 67 | b''.rstrip(b'http://') - | ^^^^^^^^^^ PLE1310 + | ^^^^^^^^^^ 68 | 69 | # OK | -bad_str_strip_call.py:79:10: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:79:10 | 78 | # Errors: Multiple backslashes 79 | ''.strip('\\b\\x09') - | ^^^^^^^^^^ PLE1310 + | ^^^^^^^^^^ 80 | ''.strip(r'\b\x09') 81 | ''.strip('\\\x5C') | -bad_str_strip_call.py:80:10: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:80:10 | 78 | # Errors: Multiple backslashes 79 | ''.strip('\\b\\x09') 80 | ''.strip(r'\b\x09') - | ^^^^^^^^^ PLE1310 + | ^^^^^^^^^ 81 | ''.strip('\\\x5C') | -bad_str_strip_call.py:81:10: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:81:10 | 79 | ''.strip('\\b\\x09') 80 | ''.strip(r'\b\x09') 81 | ''.strip('\\\x5C') - | ^^^^^^^^ PLE1310 + | ^^^^^^^^ 82 | 83 | # Errors: Type inference | -bad_str_strip_call.py:85:9: PLE1310 String `strip` call contains duplicate characters +PLE1310 String `strip` call contains duplicate characters + --> bad_str_strip_call.py:85:9 | 83 | # Errors: Type inference 84 | b = b'' 85 | b.strip(b'//') - | ^^^^^ PLE1310 + | ^^^^^ 86 | 87 | # Errors: Type inference (preview) | -bad_str_strip_call.py:89:12: PLE1310 String `rstrip` call contains duplicate characters (did you mean `removesuffix`?) +PLE1310 String `rstrip` call contains duplicate characters (did you mean `removesuffix`?) + --> bad_str_strip_call.py:89:12 | 87 | # Errors: Type inference (preview) 88 | foo: str = ""; bar: bytes = b"" 89 | foo.rstrip("//") - | ^^^^ PLE1310 + | ^^^^ 90 | bar.lstrip(b"//") | -bad_str_strip_call.py:90:12: PLE1310 String `lstrip` call contains duplicate characters (did you mean `removeprefix`?) +PLE1310 String `lstrip` call contains duplicate characters (did you mean `removeprefix`?) + --> bad_str_strip_call.py:90:12 | 88 | foo: str = ""; bar: bytes = b"" 89 | foo.rstrip("//") 90 | bar.lstrip(b"//") - | ^^^^^ PLE1310 + | ^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap index 79e29de638..b027830f43 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap @@ -1,52 +1,57 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -invalid_envvar_value.py:3:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` +PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + --> invalid_envvar_value.py:3:11 | 1 | import os 2 | 3 | os.getenv(1) # [invalid-envvar-value] - | ^ PLE1507 + | ^ 4 | os.getenv("a") 5 | os.getenv("test") | -invalid_envvar_value.py:7:15: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` +PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + --> invalid_envvar_value.py:7:15 | 5 | os.getenv("test") 6 | os.getenv(key="testingAgain") 7 | os.getenv(key=11) # [invalid-envvar-value] - | ^^ PLE1507 + | ^^ 8 | os.getenv(["hello"]) # [invalid-envvar-value] 9 | os.getenv(key="foo", default="bar") | -invalid_envvar_value.py:8:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` +PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + --> invalid_envvar_value.py:8:11 | 6 | os.getenv(key="testingAgain") 7 | os.getenv(key=11) # [invalid-envvar-value] 8 | os.getenv(["hello"]) # [invalid-envvar-value] - | ^^^^^^^^^ PLE1507 + | ^^^^^^^^^ 9 | os.getenv(key="foo", default="bar") 10 | os.getenv(key=f"foo", default="bar") | -invalid_envvar_value.py:12:15: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` +PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + --> invalid_envvar_value.py:12:15 | 10 | os.getenv(key=f"foo", default="bar") 11 | os.getenv(key="foo" + "bar", default=1) 12 | os.getenv(key=1 + "bar", default=1) # [invalid-envvar-value] - | ^^^^^^^^^ PLE1507 + | ^^^^^^^^^ 13 | os.getenv("PATH_TEST" if using_clear_path else "PATH_ORIG") 14 | os.getenv(1 if using_clear_path else "PATH_ORIG") | -invalid_envvar_value.py:14:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` +PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + --> invalid_envvar_value.py:14:11 | 12 | os.getenv(key=1 + "bar", default=1) # [invalid-envvar-value] 13 | os.getenv("PATH_TEST" if using_clear_path else "PATH_ORIG") 14 | os.getenv(1 if using_clear_path else "PATH_ORIG") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1507 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | AA = "aa" | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap index 4ec3382c4b..3b95a4d1db 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1519_singledispatch_method.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -singledispatch_method.py:10:5: PLE1519 [*] `@singledispatch` decorator should not be used on methods +PLE1519 [*] `@singledispatch` decorator should not be used on methods + --> singledispatch_method.py:10:5 | 9 | class Board: 10 | @singledispatch # [singledispatch-method] - | ^^^^^^^^^^^^^^^ PLE1519 + | ^^^^^^^^^^^^^^^ 11 | @classmethod 12 | def convert_position(cls, position): | - = help: Replace with `@singledispatchmethod` +help: Replace with `@singledispatchmethod` ℹ Unsafe fix 7 7 | @@ -21,16 +22,17 @@ singledispatch_method.py:10:5: PLE1519 [*] `@singledispatch` decorator should no 12 12 | def convert_position(cls, position): 13 13 | pass -singledispatch_method.py:15:5: PLE1519 [*] `@singledispatch` decorator should not be used on methods +PLE1519 [*] `@singledispatch` decorator should not be used on methods + --> singledispatch_method.py:15:5 | 13 | pass 14 | 15 | @singledispatch # [singledispatch-method] - | ^^^^^^^^^^^^^^^ PLE1519 + | ^^^^^^^^^^^^^^^ 16 | def move(self, position): 17 | pass | - = help: Replace with `@singledispatchmethod` +help: Replace with `@singledispatchmethod` ℹ Unsafe fix 12 12 | def convert_position(cls, position): @@ -42,16 +44,17 @@ singledispatch_method.py:15:5: PLE1519 [*] `@singledispatch` decorator should no 17 17 | pass 18 18 | -singledispatch_method.py:23:5: PLE1519 [*] `@singledispatch` decorator should not be used on methods +PLE1519 [*] `@singledispatch` decorator should not be used on methods + --> singledispatch_method.py:23:5 | 21 | pass 22 | 23 | @singledispatch # [singledispatch-method] - | ^^^^^^^^^^^^^^^ PLE1519 + | ^^^^^^^^^^^^^^^ 24 | @staticmethod 25 | def do(position): | - = help: Replace with `@singledispatchmethod` +help: Replace with `@singledispatchmethod` ℹ Unsafe fix 20 20 | def place(self, position): diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1520_singledispatchmethod_function.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1520_singledispatchmethod_function.py.snap index 36b591bc45..07d807862a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1520_singledispatchmethod_function.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1520_singledispatchmethod_function.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -singledispatchmethod_function.py:4:1: PLE1520 [*] `@singledispatchmethod` decorator should not be used on non-method functions +PLE1520 [*] `@singledispatchmethod` decorator should not be used on non-method functions + --> singledispatchmethod_function.py:4:1 | 4 | @singledispatchmethod # [singledispatchmethod-function] - | ^^^^^^^^^^^^^^^^^^^^^ PLE1520 + | ^^^^^^^^^^^^^^^^^^^^^ 5 | def convert_position(position): 6 | pass | - = help: Replace with `@singledispatch` +help: Replace with `@singledispatch` ℹ Unsafe fix 1 |-from functools import singledispatchmethod diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap index c57a96cd09..1b6adf6316 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -yield_from_in_async_function.py:7:5: PLE1700 `yield from` statement in async function; use `async for` instead +PLE1700 `yield from` statement in async function; use `async for` instead + --> yield_from_in_async_function.py:7:5 | 5 | async def fail(): 6 | l = (1, 2, 3) 7 | yield from l - | ^^^^^^^^^^^^ PLE1700 + | ^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap index 8d11a86388..18356831d7 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap @@ -1,41 +1,42 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -bidirectional_unicode.py:2:1: PLE2502 Contains control characters that can permit obfuscated code +PLE2502 Contains control characters that can permit obfuscated code + --> bidirectional_unicode.py:2:1 | 1 | # E2502 2 | print("שלום") - | ^^^^^^^^^^^^^ PLE2502 + | ^^^^^^^^^^^^^ 3 | 4 | # E2502 -5 | example = "x‏" * 100 # "‏x" is assigned | -bidirectional_unicode.py:5:1: PLE2502 Contains control characters that can permit obfuscated code +PLE2502 Contains control characters that can permit obfuscated code + --> bidirectional_unicode.py:5:1 | 4 | # E2502 5 | example = "x‏" * 100 # "‏x" is assigned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | # E2502 -8 | if access_level != "none": # Check if admin ' and access_level != 'user | -bidirectional_unicode.py:8:1: PLE2502 Contains control characters that can permit obfuscated code +PLE2502 Contains control characters that can permit obfuscated code + --> bidirectional_unicode.py:8:1 | 7 | # E2502 8 | if access_level != "none": # Check if admin ' and access_level != 'user - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | print("You are an admin.") | -bidirectional_unicode.py:14:1: PLE2502 Contains control characters that can permit obfuscated code +PLE2502 Contains control characters that can permit obfuscated code + --> bidirectional_unicode.py:14:1 | 12 | # E2502 13 | def subtract_funds(account: str, amount: int): 14 | """Subtract funds from bank account then """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE2502 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | return 16 | bank[account] -= amount -17 | return | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap index d9f3c78c2dc1089a5ee387bd11d39453191cad71..f2bd3e976d087c3c8d7fbba733eb2708f640e92c 100644 GIT binary patch delta 383 zcmZ1@|3q$r_2kpMZY;XGb_$c%@rtn+np&AnoK-HyWoV{QqmZOvtB|JtXhMfNmx6*q z4cFvCPL;_w`FJO%GJZnQ2UKol4psA!QDpK3CXGqVvT)_W%qLNlvznS(85vHlVcEpS zWeT*2Yw}+)-3jhCRx=YTL&M1j*wZI*YBNIIf+}xjWoR_{0Y}7S z2TmQZ-Kf$QAnA{skpf(1mO#%bDJf|pc?(%BkGT=dJLZOy|Fh{$mf=>K?8dDDHWewr p#90hL9{J8)HaU{d29;( zol8MMp$0_QDol3ZP?;RS_#dL%%*q_1n@OQ&;w#0;H<@I#5QdloH5pofOp4FX2I^Ih ziAlm@7T;tS<`W?E*iB8Xj0_B;4E zn!JHM1)=9Dhc+9Mn}Oy}KET1s1XX&1BNUtSpq$z zq@<*Y9w-aBq+o{c<3ciAm|FwM?I36D=LS0i80gHv5SqM@Pk8cO?pTC# invalid_characters_syntax_error.py:5:6 | 4 | # Before any syntax error 5 | b = '␈' - | ^ PLE2510 + | ^ 6 | # Unterminated string 7 | b = '␈ | - = help: Replace with escape sequence +help: Replace with escape sequence -invalid_characters_syntax_error.py:7:5: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> invalid_characters_syntax_error.py:7:5 | 5 | b = '␈' 6 | # Unterminated string @@ -21,29 +23,31 @@ invalid_characters_syntax_error.py:7:5: invalid-syntax: missing closing quote in 9 | # Unterminated f-string | -invalid_characters_syntax_error.py:7:7: invalid-syntax: Expected a statement - | - 5 | b = '␈' - 6 | # Unterminated string - 7 | b = '␈ - | ^ - 8 | b = '␈' - 9 | # Unterminated f-string -10 | b = f'␈ - | +invalid-syntax: Expected a statement + --> invalid_characters_syntax_error.py:7:7 + | +5 | b = '␈' +6 | # Unterminated string +7 | b = '␈ + | ^ +8 | b = '␈' +9 | # Unterminated f-string + | -invalid_characters_syntax_error.py:8:6: PLE2510 Invalid unescaped character backspace, use "\b" instead +PLE2510 Invalid unescaped character backspace, use "\b" instead + --> invalid_characters_syntax_error.py:8:6 | 6 | # Unterminated string 7 | b = '␈ 8 | b = '␈' - | ^ PLE2510 + | ^ 9 | # Unterminated f-string 10 | b = f'␈ | - = help: Replace with escape sequence +help: Replace with escape sequence -invalid_characters_syntax_error.py:10:7: invalid-syntax: f-string: unterminated string +invalid-syntax: f-string: unterminated string + --> invalid_characters_syntax_error.py:10:7 | 8 | b = '␈' 9 | # Unterminated f-string @@ -53,7 +57,8 @@ invalid_characters_syntax_error.py:10:7: invalid-syntax: f-string: unterminated 12 | # Implicitly concatenated | -invalid_characters_syntax_error.py:10:8: invalid-syntax: Expected FStringEnd, found newline +invalid-syntax: Expected FStringEnd, found newline + --> invalid_characters_syntax_error.py:10:8 | 8 | b = '␈' 9 | # Unterminated f-string @@ -61,39 +66,42 @@ invalid_characters_syntax_error.py:10:8: invalid-syntax: Expected FStringEnd, fo | ^ 11 | b = f'␈' 12 | # Implicitly concatenated -13 | b = '␈' f'␈' '␈ | -invalid_characters_syntax_error.py:11:7: PLE2510 Invalid unescaped character backspace, use "\b" instead +PLE2510 Invalid unescaped character backspace, use "\b" instead + --> invalid_characters_syntax_error.py:11:7 | 9 | # Unterminated f-string 10 | b = f'␈ 11 | b = f'␈' - | ^ PLE2510 + | ^ 12 | # Implicitly concatenated 13 | b = '␈' f'␈' '␈ | - = help: Replace with escape sequence +help: Replace with escape sequence -invalid_characters_syntax_error.py:13:6: PLE2510 Invalid unescaped character backspace, use "\b" instead +PLE2510 Invalid unescaped character backspace, use "\b" instead + --> invalid_characters_syntax_error.py:13:6 | 11 | b = f'␈' 12 | # Implicitly concatenated 13 | b = '␈' f'␈' '␈ - | ^ PLE2510 + | ^ | - = help: Replace with escape sequence +help: Replace with escape sequence -invalid_characters_syntax_error.py:13:11: PLE2510 Invalid unescaped character backspace, use "\b" instead +PLE2510 Invalid unescaped character backspace, use "\b" instead + --> invalid_characters_syntax_error.py:13:11 | 11 | b = f'␈' 12 | # Implicitly concatenated 13 | b = '␈' f'␈' '␈ - | ^ PLE2510 + | ^ | - = help: Replace with escape sequence +help: Replace with escape sequence -invalid_characters_syntax_error.py:13:14: invalid-syntax: missing closing quote in string literal +invalid-syntax: missing closing quote in string literal + --> invalid_characters_syntax_error.py:13:14 | 11 | b = f'␈' 12 | # Implicitly concatenated @@ -101,7 +109,8 @@ invalid_characters_syntax_error.py:13:14: invalid-syntax: missing closing quote | ^^ | -invalid_characters_syntax_error.py:13:16: invalid-syntax: Expected a statement +invalid-syntax: Expected a statement + --> invalid_characters_syntax_error.py:13:16 | 11 | b = f'␈' 12 | # Implicitly concatenated diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap index 7dd5bc0e6e81992ed23061474470c87c685febae..2d36515f6e1370a20d777af151b84b33de9df575 100644 GIT binary patch delta 428 zcmX@0{6T4g_2dJ*PAs~*b_$a(Fp9I7SQ#2kobD{eWn`*QqflI$q+qL%rVgT|)VUNC z6l%C8Gcuk>)+0Sxhsj=n%g78UXJii16rZ0B)TbU(VVH=}WiZDwU?JozqH^Vysx&UfHY2=H+=GBq@s?8qd^#-*U3V5=~>kk4?k7UR5$ zjpA&kR))q9#glcIY!Iq5m=stMigz+Cn!J!1X6)qs%$xaO=5m>uDb#RH4&?9!8D4|1 zVe@a6C5%8_;%pXHhDK03nAyt_c2u!vBkb5L#$m)bu~BUD0!~(t^Zj`2Ca>U3MX2WG z(t)d10V-rSGlRGtsFF#cX7U40naQ`gED#zVa%&?z4AB8}3COn~vk!BJ%fkI&W~or4 zproXviRuTCCN^_pD@&-JwLIwv<3)J2QQR|mKQGwfz;K^@oEOQPc6`PVg_{fcSV3N7 iw=lFaGJ}K&Gbr#5^2tvA#a}86cMnQP8ckjiGofO=lgId1o*fbnHm~T&SjEk<5EyiuvM7+klk>y4dbSX zjpA&ER)*#f#gl`WkW|lOQeZ_We$TXJVx!pP|IDmVlbIE2xF)Y*O_`j>;*YRmFG~bm zlhI~()`g5fUF>ECR)$6pJHXm5vWZPjWiJzkxeVl}8i>m_KV;8^=rOS}GzRMNz^DQP0P2pCo%y=>+tR+dmpHuE?mEcwQxiDJp*`Mj_&n!J%;cX9`l7(($w!8nBD z4JTLeT?To;!obQ1WHvCufLf{$%6Wy1kd^lfTmmaMv@$k;C_m_8q^~7)o7F}ICg^AWu6Q}4-JgG8Skws;44-?;H6~-2zq#Q^xGp{T$Co?5J zIU}(sF}WnQs93L{(#qJ<%5*X#lZ_mgiGe~5mx-Z5jY3{&PJDj0f~|sjjDb3rf&x$+ zYT(?-32ZiCt0rqQOHZz6&Yb*#SqCf$l#s`5jhUI1q3Pt=EK!sHvJj=-0;GNgYqS8D jnI+IkN=izaNG<_dhR09lW>%JyXR>)te#IsYbel2&NvK%> delta 280 zcmey%yOwW)^~8E9CM$)>3m6?H&e7sf2=H+=GBq@rEXbtH#-*U3V5=~hk5y$dALFEn z_2R6SR;CcOlNp&T5sIytYrFIHaVY}6=b+Bi_PS6<}`$cyUaQW4M2tL zW@c7~AftgQnG|X!uV5BJb^Vr7Ups;GfRaU1tldVO_1|z c5Pkq^Vly|hvV^*)lFbd_p8agnaQ7$!0K&~e8UO$Q diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap index 833b37b2e559329da6db0cae0407d2635c25bf04..ab4bd9aaacb5c1f9efaf86658e2abb76681bd720 100644 GIT binary patch delta 495 zcmdmLd(~!w_2fkMKo(tHJB7&wQevzoCRT>V6PNi+{G~Kmk?|Fpq^Xsm$>cJofXU~W zl!4MllQo$4qbT7vHLx-^<5EyisNtG?fK_I42}=|s*W?Ql#*=&a6B)TS7qVVvMA5-& zYG`F_K6yQR|71JiV?eb)V>i2SPC!>>WMyWs*`Aw`aq>LjG^n!E0@{p|t;BdH%ks@Z zF?8~IK2}V{Xf|`38e5qeLfr~+VeI7j!t*BUNtkbL6k%gRF%qoW2&d|ujFXk6d?)ux z`NG0ddh&It%*h_oIzS((AWMj|m{}Q`O=gjanw%zsDa&aAlm*)}Sx-iGvWu*x0GFAi tLXCowl9DFWel!!sSj~YkV=!4&&P$BT+zhBTuQW%&RzWF-K?$xy833cagZ%&i delta 700 zcmca=v(Je^6052lmL#0(_d%PPSIG@u4VAekb;ydP+a zIGcf$u^GgW$zCj#aBC-DU^krH$(_Q6s%>*O>q17LK4~VX9v1$j$+K8AcopK{)|whk z-Y6nGSwYZyat}uus^d4Sa83Z}7oV)a&4MuFA2&j`F;utg*S-0Wm?0w~v`kGvq2(x~gBe=9o1-N<7$?8v<(bSU<_I&! z2;vCRjJXQ*gA_RQ45WM~&zDL=g!n^gZRF5yloDq%voZul4oK+{>2QQnX&D_v$N&u# zXS0B-WKyV^%r7lF`KOGfEId@rEEQ@Ll$4Y-(LD!BdFH@`WB|41s;s**T$ed80V(8_ P<^a=;QVfF modified_iterating_set.py:4:1 | 3 | nums = {1, 2, 3} 4 | / for num in nums: 5 | | nums.add(num + 1) - | |_____________________^ PLE4703 + | |_____________________^ 6 | 7 | animals = {"dog", "cat", "cow"} | - = help: Iterate over a copy of `nums` +help: Iterate over a copy of `nums` ℹ Unsafe fix 1 1 | # Errors @@ -22,16 +23,17 @@ modified_iterating_set.py:4:1: PLE4703 [*] Iterated set `nums` is modified withi 6 6 | 7 7 | animals = {"dog", "cat", "cow"} -modified_iterating_set.py:8:1: PLE4703 [*] Iterated set `animals` is modified within the `for` loop +PLE4703 [*] Iterated set `animals` is modified within the `for` loop + --> modified_iterating_set.py:8:1 | 7 | animals = {"dog", "cat", "cow"} 8 | / for animal in animals: 9 | | animals.pop("cow") - | |______________________^ PLE4703 + | |______________________^ 10 | 11 | fruits = {"apple", "orange", "grape"} | - = help: Iterate over a copy of `animals` +help: Iterate over a copy of `animals` ℹ Unsafe fix 5 5 | nums.add(num + 1) @@ -43,16 +45,17 @@ modified_iterating_set.py:8:1: PLE4703 [*] Iterated set `animals` is modified wi 10 10 | 11 11 | fruits = {"apple", "orange", "grape"} -modified_iterating_set.py:12:1: PLE4703 [*] Iterated set `fruits` is modified within the `for` loop +PLE4703 [*] Iterated set `fruits` is modified within the `for` loop + --> modified_iterating_set.py:12:1 | 11 | fruits = {"apple", "orange", "grape"} 12 | / for fruit in fruits: 13 | | fruits.clear() - | |__________________^ PLE4703 + | |__________________^ 14 | 15 | planets = {"mercury", "venus", "earth"} | - = help: Iterate over a copy of `fruits` +help: Iterate over a copy of `fruits` ℹ Unsafe fix 9 9 | animals.pop("cow") @@ -64,16 +67,17 @@ modified_iterating_set.py:12:1: PLE4703 [*] Iterated set `fruits` is modified wi 14 14 | 15 15 | planets = {"mercury", "venus", "earth"} -modified_iterating_set.py:16:1: PLE4703 [*] Iterated set `planets` is modified within the `for` loop +PLE4703 [*] Iterated set `planets` is modified within the `for` loop + --> modified_iterating_set.py:16:1 | 15 | planets = {"mercury", "venus", "earth"} 16 | / for planet in planets: 17 | | planets.discard("mercury") - | |______________________________^ PLE4703 + | |______________________________^ 18 | 19 | colors = {"red", "green", "blue"} | - = help: Iterate over a copy of `planets` +help: Iterate over a copy of `planets` ℹ Unsafe fix 13 13 | fruits.clear() @@ -85,16 +89,17 @@ modified_iterating_set.py:16:1: PLE4703 [*] Iterated set `planets` is modified w 18 18 | 19 19 | colors = {"red", "green", "blue"} -modified_iterating_set.py:20:1: PLE4703 [*] Iterated set `colors` is modified within the `for` loop +PLE4703 [*] Iterated set `colors` is modified within the `for` loop + --> modified_iterating_set.py:20:1 | 19 | colors = {"red", "green", "blue"} 20 | / for color in colors: 21 | | colors.remove("red") - | |________________________^ PLE4703 + | |________________________^ 22 | 23 | odds = {1, 3, 5} | - = help: Iterate over a copy of `colors` +help: Iterate over a copy of `colors` ℹ Unsafe fix 17 17 | planets.discard("mercury") @@ -106,17 +111,18 @@ modified_iterating_set.py:20:1: PLE4703 [*] Iterated set `colors` is modified wi 22 22 | 23 23 | odds = {1, 3, 5} -modified_iterating_set.py:24:1: PLE4703 [*] Iterated set `odds` is modified within the `for` loop +PLE4703 [*] Iterated set `odds` is modified within the `for` loop + --> modified_iterating_set.py:24:1 | 23 | odds = {1, 3, 5} 24 | / for num in odds: 25 | | if num > 1: 26 | | odds.add(num + 1) - | |_________________________^ PLE4703 + | |_________________________^ 27 | 28 | # OK | - = help: Iterate over a copy of `odds` +help: Iterate over a copy of `odds` ℹ Unsafe fix 21 21 | colors.remove("red") diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap index 6812c32fb4..4458590eb4 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap @@ -1,121 +1,133 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -comparison_with_itself.py:2:1: PLR0124 Name compared with itself, consider replacing `foo == foo` +PLR0124 Name compared with itself, consider replacing `foo == foo` + --> comparison_with_itself.py:2:1 | 1 | # Errors. 2 | foo == foo - | ^^^ PLR0124 + | ^^^ 3 | 4 | foo != foo | -comparison_with_itself.py:4:1: PLR0124 Name compared with itself, consider replacing `foo != foo` +PLR0124 Name compared with itself, consider replacing `foo != foo` + --> comparison_with_itself.py:4:1 | 2 | foo == foo 3 | 4 | foo != foo - | ^^^ PLR0124 + | ^^^ 5 | 6 | foo > foo | -comparison_with_itself.py:6:1: PLR0124 Name compared with itself, consider replacing `foo > foo` +PLR0124 Name compared with itself, consider replacing `foo > foo` + --> comparison_with_itself.py:6:1 | 4 | foo != foo 5 | 6 | foo > foo - | ^^^ PLR0124 + | ^^^ 7 | 8 | foo >= foo | -comparison_with_itself.py:8:1: PLR0124 Name compared with itself, consider replacing `foo >= foo` +PLR0124 Name compared with itself, consider replacing `foo >= foo` + --> comparison_with_itself.py:8:1 | 6 | foo > foo 7 | 8 | foo >= foo - | ^^^ PLR0124 + | ^^^ 9 | 10 | foo < foo | -comparison_with_itself.py:10:1: PLR0124 Name compared with itself, consider replacing `foo < foo` +PLR0124 Name compared with itself, consider replacing `foo < foo` + --> comparison_with_itself.py:10:1 | 8 | foo >= foo 9 | 10 | foo < foo - | ^^^ PLR0124 + | ^^^ 11 | 12 | foo <= foo | -comparison_with_itself.py:12:1: PLR0124 Name compared with itself, consider replacing `foo <= foo` +PLR0124 Name compared with itself, consider replacing `foo <= foo` + --> comparison_with_itself.py:12:1 | 10 | foo < foo 11 | 12 | foo <= foo - | ^^^ PLR0124 + | ^^^ 13 | 14 | foo is foo | -comparison_with_itself.py:14:1: PLR0124 Name compared with itself, consider replacing `foo is foo` +PLR0124 Name compared with itself, consider replacing `foo is foo` + --> comparison_with_itself.py:14:1 | 12 | foo <= foo 13 | 14 | foo is foo - | ^^^ PLR0124 + | ^^^ 15 | 16 | foo is not foo | -comparison_with_itself.py:16:1: PLR0124 Name compared with itself, consider replacing `foo is not foo` +PLR0124 Name compared with itself, consider replacing `foo is not foo` + --> comparison_with_itself.py:16:1 | 14 | foo is foo 15 | 16 | foo is not foo - | ^^^ PLR0124 + | ^^^ 17 | 18 | foo in foo | -comparison_with_itself.py:18:1: PLR0124 Name compared with itself, consider replacing `foo in foo` +PLR0124 Name compared with itself, consider replacing `foo in foo` + --> comparison_with_itself.py:18:1 | 16 | foo is not foo 17 | 18 | foo in foo - | ^^^ PLR0124 + | ^^^ 19 | 20 | foo not in foo | -comparison_with_itself.py:20:1: PLR0124 Name compared with itself, consider replacing `foo not in foo` +PLR0124 Name compared with itself, consider replacing `foo not in foo` + --> comparison_with_itself.py:20:1 | 18 | foo in foo 19 | 20 | foo not in foo - | ^^^ PLR0124 + | ^^^ 21 | 22 | id(foo) == id(foo) | -comparison_with_itself.py:22:1: PLR0124 Name compared with itself, consider replacing `id(foo) == id(foo)` +PLR0124 Name compared with itself, consider replacing `id(foo) == id(foo)` + --> comparison_with_itself.py:22:1 | 20 | foo not in foo 21 | 22 | id(foo) == id(foo) - | ^^^^^^^ PLR0124 + | ^^^^^^^ 23 | 24 | len(foo) == len(foo) | -comparison_with_itself.py:24:1: PLR0124 Name compared with itself, consider replacing `len(foo) == len(foo)` +PLR0124 Name compared with itself, consider replacing `len(foo) == len(foo)` + --> comparison_with_itself.py:24:1 | 22 | id(foo) == id(foo) 23 | 24 | len(foo) == len(foo) - | ^^^^^^^^ PLR0124 + | ^^^^^^^^ 25 | 26 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap index 30bcc7a4f8..f054d0e065 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap @@ -1,91 +1,101 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -comparison_of_constant.py:3:4: PLR0133 Two constants compared in a comparison, consider replacing `100 == 100` +PLR0133 Two constants compared in a comparison, consider replacing `100 == 100` + --> comparison_of_constant.py:3:4 | 1 | """Check that magic values are not used in comparisons""" 2 | 3 | if 100 == 100: # [comparison-of-constants] - | ^^^ PLR0133 + | ^^^ 4 | pass | -comparison_of_constant.py:6:4: PLR0133 Two constants compared in a comparison, consider replacing `1 == 3` +PLR0133 Two constants compared in a comparison, consider replacing `1 == 3` + --> comparison_of_constant.py:6:4 | 4 | pass 5 | 6 | if 1 == 3: # [comparison-of-constants] - | ^ PLR0133 + | ^ 7 | pass | -comparison_of_constant.py:9:4: PLR0133 Two constants compared in a comparison, consider replacing `1 != 3` +PLR0133 Two constants compared in a comparison, consider replacing `1 != 3` + --> comparison_of_constant.py:9:4 | 7 | pass 8 | 9 | if 1 != 3: # [comparison-of-constants] - | ^ PLR0133 + | ^ 10 | pass | -comparison_of_constant.py:13:4: PLR0133 Two constants compared in a comparison, consider replacing `4 == 3` +PLR0133 Two constants compared in a comparison, consider replacing `4 == 3` + --> comparison_of_constant.py:13:4 | 12 | x = 0 13 | if 4 == 3 == x: # [comparison-of-constants] - | ^ PLR0133 + | ^ 14 | pass | -comparison_of_constant.py:23:4: PLR0133 Two constants compared in a comparison, consider replacing `1 > 0` +PLR0133 Two constants compared in a comparison, consider replacing `1 > 0` + --> comparison_of_constant.py:23:4 | 21 | pass 22 | 23 | if 1 > 0: # [comparison-of-constants] - | ^ PLR0133 + | ^ 24 | pass | -comparison_of_constant.py:29:4: PLR0133 Two constants compared in a comparison, consider replacing `1 >= 0` +PLR0133 Two constants compared in a comparison, consider replacing `1 >= 0` + --> comparison_of_constant.py:29:4 | 27 | pass 28 | 29 | if 1 >= 0: # [comparison-of-constants] - | ^ PLR0133 + | ^ 30 | pass | -comparison_of_constant.py:35:4: PLR0133 Two constants compared in a comparison, consider replacing `1 < 0` +PLR0133 Two constants compared in a comparison, consider replacing `1 < 0` + --> comparison_of_constant.py:35:4 | 33 | pass 34 | 35 | if 1 < 0: # [comparison-of-constants] - | ^ PLR0133 + | ^ 36 | pass | -comparison_of_constant.py:41:4: PLR0133 Two constants compared in a comparison, consider replacing `1 <= 0` +PLR0133 Two constants compared in a comparison, consider replacing `1 <= 0` + --> comparison_of_constant.py:41:4 | 39 | pass 40 | 41 | if 1 <= 0: # [comparison-of-constants] - | ^ PLR0133 + | ^ 42 | pass | -comparison_of_constant.py:51:4: PLR0133 Two constants compared in a comparison, consider replacing `"hello" == ""` +PLR0133 Two constants compared in a comparison, consider replacing `"hello" == ""` + --> comparison_of_constant.py:51:4 | 49 | pass 50 | 51 | if "hello" == "": # [comparison-of-constants] - | ^^^^^^^ PLR0133 + | ^^^^^^^ 52 | pass | -comparison_of_constant.py:58:4: PLR0133 Two constants compared in a comparison, consider replacing `True == False` +PLR0133 Two constants compared in a comparison, consider replacing `True == False` + --> comparison_of_constant.py:58:4 | 56 | pass 57 | 58 | if True == False: # [comparison-of-constants] - | ^^^^ PLR0133 + | ^^^^ 59 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap index b59cccfa4c..785b6a2f91 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0202_no_method_decorator.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -no_method_decorator.py:9:5: PLR0202 [*] Class method defined without decorator +PLR0202 [*] Class method defined without decorator + --> no_method_decorator.py:9:5 | 7 | self.color = color 8 | 9 | def pick_colors(cls, *args): # [no-classmethod-decorator] - | ^ PLR0202 + | ^ 10 | """classmethod to pick fruit colors""" 11 | cls.COLORS = args | - = help: Add @classmethod decorator +help: Add @classmethod decorator ℹ Safe fix 6 6 | def __init__(self, color): @@ -26,14 +27,15 @@ no_method_decorator.py:9:5: PLR0202 [*] Class method defined without decorator 15 15 | def pick_one_color(): # [no-staticmethod-decorator] 16 16 | """staticmethod to pick one fruit color""" -no_method_decorator.py:22:5: PLR0202 [*] Class method defined without decorator +PLR0202 [*] Class method defined without decorator + --> no_method_decorator.py:22:5 | 21 | class Class: 22 | def class_method(cls): - | ^ PLR0202 + | ^ 23 | pass | - = help: Add @classmethod decorator +help: Add @classmethod decorator ℹ Safe fix 19 19 | pick_one_color = staticmethod(pick_one_color) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap index 49579ff4ad..7634dbb586 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0203_no_method_decorator.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -no_method_decorator.py:15:5: PLR0203 [*] Static method defined without decorator +PLR0203 [*] Static method defined without decorator + --> no_method_decorator.py:15:5 | 13 | pick_colors = classmethod(pick_colors) 14 | 15 | def pick_one_color(): # [no-staticmethod-decorator] - | ^ PLR0203 + | ^ 16 | """staticmethod to pick one fruit color""" 17 | return choice(Fruit.COLORS) | - = help: Add @staticmethod decorator +help: Add @staticmethod decorator ℹ Safe fix 12 12 | @@ -26,15 +27,16 @@ no_method_decorator.py:15:5: PLR0203 [*] Static method defined without decorator 21 21 | class Class: 22 22 | def class_method(cls): -no_method_decorator.py:27:5: PLR0203 [*] Static method defined without decorator +PLR0203 [*] Static method defined without decorator + --> no_method_decorator.py:27:5 | 25 | class_method = classmethod(class_method);another_statement 26 | 27 | def static_method(): - | ^ PLR0203 + | ^ 28 | pass | - = help: Add @staticmethod decorator +help: Add @staticmethod decorator ℹ Safe fix 24 24 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0206_property_with_parameters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0206_property_with_parameters.py.snap index 3c8afe856c..67b04aa9a4 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0206_property_with_parameters.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0206_property_with_parameters.py.snap @@ -1,79 +1,87 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -property_with_parameters.py:7:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:7:9 | 5 | class Cls: 6 | @property 7 | def attribute(self, param, param1): # [property-with-parameters] - | ^^^^^^^^^ PLR0206 + | ^^^^^^^^^ 8 | return param + param1 | -property_with_parameters.py:11:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:11:9 | 10 | @property 11 | def attribute_keyword_only(self, *, param, param1): # [property-with-parameters] - | ^^^^^^^^^^^^^^^^^^^^^^ PLR0206 + | ^^^^^^^^^^^^^^^^^^^^^^ 12 | return param + param1 | -property_with_parameters.py:15:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:15:9 | 14 | @property 15 | def attribute_positional_only(self, param, param1, /): # [property-with-parameters] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0206 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | return param + param1 | -property_with_parameters.py:35:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:35:9 | 33 | class VariadicParameters: 34 | @property 35 | def attribute_var_args(self, *args): # [property-with-parameters] - | ^^^^^^^^^^^^^^^^^^ PLR0206 + | ^^^^^^^^^^^^^^^^^^ 36 | return sum(args) | -property_with_parameters.py:39:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:39:9 | 38 | @property 39 | def attribute_var_kwargs(self, **kwargs): #[property-with-parameters] - | ^^^^^^^^^^^^^^^^^^^^ PLR0206 + | ^^^^^^^^^^^^^^^^^^^^ 40 | return {key: value * 2 for key, value in kwargs.items()} | -property_with_parameters.py:48:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:48:9 | 46 | class Cached: 47 | @cached_property 48 | def cached_prop(self, value): # [property-with-parameters] - | ^^^^^^^^^^^ PLR0206 + | ^^^^^^^^^^^ 49 | ... | -property_with_parameters.py:59:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:59:9 | 57 | class Baz: 58 | @abc.abstractproperty 59 | def prop2(self, param) -> None: # [property-with-parameters] - | ^^^^^ PLR0206 + | ^^^^^ 60 | return None | -property_with_parameters.py:63:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:63:9 | 62 | @types.DynamicClassAttribute 63 | def prop3(self, param) -> None: # [property-with-parameters] - | ^^^^^ PLR0206 + | ^^^^^ 64 | return None | -property_with_parameters.py:67:9: PLR0206 Cannot have defined parameters for properties +PLR0206 Cannot have defined parameters for properties + --> property_with_parameters.py:67:9 | 66 | @enum.property 67 | def prop4(self, param) -> None: # [property-with-parameters] - | ^^^^^ PLR0206 + | ^^^^^ 68 | return None | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap index 944d71a06c..d204598a9d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -import_aliasing.py:9:8: PLR0402 [*] Use `from os import path` in lieu of alias +PLR0402 [*] Use `from os import path` in lieu of alias + --> import_aliasing.py:9:8 | 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] 8 | from collections import OrderedDict as o_dict 9 | import os.path as path # [consider-using-from-import] - | ^^^^^^^^^^^^^^^ PLR0402 + | ^^^^^^^^^^^^^^^ 10 | import os.path as p 11 | import foo.bar.foobar as foobar # [consider-using-from-import] | - = help: Replace with `from os import path` +help: Replace with `from os import path` ℹ Safe fix 6 6 | import collections as collections # [useless-import-alias] @@ -23,16 +23,17 @@ import_aliasing.py:9:8: PLR0402 [*] Use `from os import path` in lieu of alias 11 11 | import foo.bar.foobar as foobar # [consider-using-from-import] 12 12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] -import_aliasing.py:11:8: PLR0402 [*] Use `from foo.bar import foobar` in lieu of alias +PLR0402 [*] Use `from foo.bar import foobar` in lieu of alias + --> import_aliasing.py:11:8 | 9 | import os.path as path # [consider-using-from-import] 10 | import os.path as p 11 | import foo.bar.foobar as foobar # [consider-using-from-import] - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR0402 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] 13 | import os | - = help: Replace with `from foo.bar import foobar` +help: Replace with `from foo.bar import foobar` ℹ Safe fix 8 8 | from collections import OrderedDict as o_dict @@ -44,13 +45,14 @@ import_aliasing.py:11:8: PLR0402 [*] Use `from foo.bar import foobar` in lieu of 13 13 | import os 14 14 | import os as OS -import_aliasing.py:12:8: PLR0402 Use `from foo.bar import foobar` in lieu of alias +PLR0402 Use `from foo.bar import foobar` in lieu of alias + --> import_aliasing.py:12:8 | 10 | import os.path as p 11 | import foo.bar.foobar as foobar # [consider-using-from-import] 12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR0402 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 13 | import os 14 | import os as OS | - = help: Replace with `from foo.bar import foobar` +help: Replace with `from foo.bar import foobar` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap index 7db77dee35..f06c6f3344 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_return_statements.py:4:5: PLR0911 Too many return statements (11 > 6) +PLR0911 Too many return statements (11 > 6) + --> too_many_return_statements.py:4:5 | 2 | https://github.com/PyCQA/pylint/blob/69eca9b3f9856c3033957b769358803ee48e8e47/tests/functional/t/too/too_many_return_statements.py 3 | """ 4 | def stupid_function(arg): # [too-many-return-statements] - | ^^^^^^^^^^^^^^^ PLR0911 + | ^^^^^^^^^^^^^^^ 5 | if arg == 1: 6 | return 1 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap index ab698ec5d0..33a9a14515 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap @@ -1,21 +1,23 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -too_many_branches.py:8:5: PLR0912 Too many branches (13 > 12) +PLR0912 Too many branches (13 > 12) + --> too_many_branches.py:8:5 | 7 | # pylint: disable=using-constant-test 8 | def wrong(): # [too-many-branches] - | ^^^^^ PLR0912 + | ^^^^^ 9 | """ Has too many branches. """ 10 | if 1: | -too_many_branches.py:80:5: PLR0912 Too many branches (13 > 12) +PLR0912 Too many branches (13 > 12) + --> too_many_branches.py:80:5 | 78 | pass 79 | 80 | def with_statement_wrong(): - | ^^^^^^^^^^^^^^^^^^^^ PLR0912 + | ^^^^^^^^^^^^^^^^^^^^ 81 | """statements inside the with statement should get counted""" 82 | with suppress(Exception): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0913_too_many_arguments.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0913_too_many_arguments.py.snap index fcdbc52e19..60f069c1ef 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0913_too_many_arguments.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0913_too_many_arguments.py.snap @@ -1,70 +1,78 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_arguments.py:1:5: PLR0913 Too many arguments in function definition (8 > 5) +PLR0913 Too many arguments in function definition (8 > 5) + --> too_many_arguments.py:1:5 | 1 | def f(x, y, z, t, u, v, w, r): # Too many arguments (8/5) - | ^ PLR0913 + | ^ 2 | pass | -too_many_arguments.py:17:5: PLR0913 Too many arguments in function definition (6 > 5) +PLR0913 Too many arguments in function definition (6 > 5) + --> too_many_arguments.py:17:5 | 17 | def f(x, y, z, u=1, v=1, r=1): # Too many arguments (6/5) - | ^ PLR0913 + | ^ 18 | pass | -too_many_arguments.py:25:5: PLR0913 Too many arguments in function definition (6 > 5) +PLR0913 Too many arguments in function definition (6 > 5) + --> too_many_arguments.py:25:5 | 25 | def f(x, y, z, /, u, v, w): # Too many arguments (6/5) - | ^ PLR0913 + | ^ 26 | pass | -too_many_arguments.py:29:5: PLR0913 Too many arguments in function definition (6 > 5) +PLR0913 Too many arguments in function definition (6 > 5) + --> too_many_arguments.py:29:5 | 29 | def f(x, y, z, *, u, v, w): # Too many arguments (6/5) - | ^ PLR0913 + | ^ 30 | pass | -too_many_arguments.py:33:5: PLR0913 Too many arguments in function definition (9 > 5) +PLR0913 Too many arguments in function definition (9 > 5) + --> too_many_arguments.py:33:5 | 33 | def f(x, y, z, a, b, c, *, u, v, w): # Too many arguments (9/5) - | ^ PLR0913 + | ^ 34 | pass | -too_many_arguments.py:51:9: PLR0913 Too many arguments in function definition (8 > 5) +PLR0913 Too many arguments in function definition (8 > 5) + --> too_many_arguments.py:51:9 | 50 | class C: 51 | def f(self, y, z, a, b, c, *, u, v, w): # Too many arguments (8/5) - | ^ PLR0913 + | ^ 52 | pass | -too_many_arguments.py:58:9: PLR0913 Too many arguments in function definition (8 > 5) +PLR0913 Too many arguments in function definition (8 > 5) + --> too_many_arguments.py:58:9 | 57 | @classmethod 58 | def f(cls, y, z, a, b, c, *, u, v, w): # Too many arguments (8/5) - | ^ PLR0913 + | ^ 59 | pass | -too_many_arguments.py:66:9: PLR0913 Too many arguments in function definition (8 > 5) +PLR0913 Too many arguments in function definition (8 > 5) + --> too_many_arguments.py:66:9 | 65 | @staticmethod 66 | def f(y, z, a, b, c, *, u, v, w): # Too many arguments (8/5) - | ^ PLR0913 + | ^ 67 | pass | -too_many_arguments.py:70:9: PLR0913 Too many arguments in function definition (6 > 5) +PLR0913 Too many arguments in function definition (6 > 5) + --> too_many_arguments.py:70:9 | 69 | @staticmethod 70 | def f(y, z, a, b, c, d): # OK - | ^ PLR0913 + | ^ 71 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0915_too_many_statements.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0915_too_many_statements.py.snap index f3d12f984a..17da1e0dab 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0915_too_many_statements.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0915_too_many_statements.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_statements.py:5:11: PLR0915 Too many statements (51 > 50) +PLR0915 Too many statements (51 > 50) + --> too_many_statements.py:5:11 | 5 | async def f(): # Too many statements (52/50) - | ^ PLR0915 + | ^ 6 | print() 7 | print() | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0917_too_many_positional_arguments.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0917_too_many_positional_arguments.py.snap index 43145d416a..c46bd0b617 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0917_too_many_positional_arguments.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0917_too_many_positional_arguments.py.snap @@ -1,40 +1,45 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -too_many_positional_arguments.py:1:5: PLR0917 Too many positional arguments (8/5) +PLR0917 Too many positional arguments (8/5) + --> too_many_positional_arguments.py:1:5 | 1 | def f(x, y, z, t, u, v, w, r): # Too many positional arguments (8/5) - | ^ PLR0917 + | ^ 2 | pass | -too_many_positional_arguments.py:21:5: PLR0917 Too many positional arguments (6/5) +PLR0917 Too many positional arguments (6/5) + --> too_many_positional_arguments.py:21:5 | 21 | def f(x, y, z, /, u, v, w): # Too many positional arguments (6/5) - | ^ PLR0917 + | ^ 22 | pass | -too_many_positional_arguments.py:29:5: PLR0917 Too many positional arguments (6/5) +PLR0917 Too many positional arguments (6/5) + --> too_many_positional_arguments.py:29:5 | 29 | def f(x, y, z, a, b, c, *, u, v, w): # Too many positional arguments (6/5) - | ^ PLR0917 + | ^ 30 | pass | -too_many_positional_arguments.py:43:9: PLR0917 Too many positional arguments (6/5) +PLR0917 Too many positional arguments (6/5) + --> too_many_positional_arguments.py:43:9 | 41 | pass 42 | 43 | def f(self, a, b, c, d, e, g): # Too many positional arguments (6/5) - | ^ PLR0917 + | ^ 44 | pass | -too_many_positional_arguments.py:47:9: PLR0917 Too many positional arguments (6/5) +PLR0917 Too many positional arguments (6/5) + --> too_many_positional_arguments.py:47:9 | 46 | @staticmethod 47 | def f(self, a, b, c, d, e): # Too many positional arguments (6/5) - | ^ PLR0917 + | ^ 48 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1702_too_many_nested_blocks.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1702_too_many_nested_blocks.py.snap index 5897b38a4b..d17c9975e1 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1702_too_many_nested_blocks.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1702_too_many_nested_blocks.py.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -too_many_nested_blocks.py:2:5: PLR1702 Too many nested blocks (6 > 5) +PLR1702 Too many nested blocks (6 > 5) + --> too_many_nested_blocks.py:2:5 | 1 | def correct_fruits(fruits) -> bool: 2 | / if len(fruits) > 1: # PLR1702 @@ -12,6 +13,6 @@ too_many_nested_blocks.py:2:5: PLR1702 Too many nested blocks (6 > 5) 7 | | if "kiwi" in fruits: 8 | | if count == 2: 9 | | return True - | |_______________________________________^ PLR1702 + | |_______________________________________^ 10 | return False | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1704_redefined_argument_from_local.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1704_redefined_argument_from_local.py.snap index 19a226391e..0fba753787 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1704_redefined_argument_from_local.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1704_redefined_argument_from_local.py.snap @@ -1,114 +1,126 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -redefined_argument_from_local.py:41:9: PLR1704 Redefining argument with the local name `a` +PLR1704 Redefining argument with the local name `a` + --> redefined_argument_from_local.py:41:9 | 39 | # Errors 40 | def func(a): 41 | for a in range(1): - | ^ PLR1704 + | ^ 42 | ... | -redefined_argument_from_local.py:46:9: PLR1704 Redefining argument with the local name `i` +PLR1704 Redefining argument with the local name `i` + --> redefined_argument_from_local.py:46:9 | 45 | def func(i): 46 | for i in range(10): - | ^ PLR1704 + | ^ 47 | print(i) | -redefined_argument_from_local.py:53:25: PLR1704 Redefining argument with the local name `e` +PLR1704 Redefining argument with the local name `e` + --> redefined_argument_from_local.py:53:25 | 51 | try: 52 | ... 53 | except Exception as e: - | ^ PLR1704 + | ^ 54 | print(e) | -redefined_argument_from_local.py:58:24: PLR1704 Redefining argument with the local name `f` +PLR1704 Redefining argument with the local name `f` + --> redefined_argument_from_local.py:58:24 | 57 | def func(f): 58 | with open('', ) as f: - | ^ PLR1704 + | ^ 59 | print(f) | -redefined_argument_from_local.py:63:24: PLR1704 Redefining argument with the local name `a` +PLR1704 Redefining argument with the local name `a` + --> redefined_argument_from_local.py:63:24 | 62 | def func(a, b): 63 | with context() as (a, b, c): - | ^ PLR1704 + | ^ 64 | print(a, b, c) | -redefined_argument_from_local.py:63:27: PLR1704 Redefining argument with the local name `b` +PLR1704 Redefining argument with the local name `b` + --> redefined_argument_from_local.py:63:27 | 62 | def func(a, b): 63 | with context() as (a, b, c): - | ^ PLR1704 + | ^ 64 | print(a, b, c) | -redefined_argument_from_local.py:68:24: PLR1704 Redefining argument with the local name `a` +PLR1704 Redefining argument with the local name `a` + --> redefined_argument_from_local.py:68:24 | 67 | def func(a, b): 68 | with context() as [a, b, c]: - | ^ PLR1704 + | ^ 69 | print(a, b, c) | -redefined_argument_from_local.py:68:27: PLR1704 Redefining argument with the local name `b` +PLR1704 Redefining argument with the local name `b` + --> redefined_argument_from_local.py:68:27 | 67 | def func(a, b): 68 | with context() as [a, b, c]: - | ^ PLR1704 + | ^ 69 | print(a, b, c) | -redefined_argument_from_local.py:73:51: PLR1704 Redefining argument with the local name `a` +PLR1704 Redefining argument with the local name `a` + --> redefined_argument_from_local.py:73:51 | 72 | def func(a): 73 | with open('foo.py', ) as f, open('bar.py') as a: - | ^ PLR1704 + | ^ 74 | ... | -redefined_argument_from_local.py:79:13: PLR1704 Redefining argument with the local name `a` +PLR1704 Redefining argument with the local name `a` + --> redefined_argument_from_local.py:79:13 | 77 | def func(a): 78 | def bar(b): 79 | for a in range(1): - | ^ PLR1704 + | ^ 80 | print(a) | -redefined_argument_from_local.py:85:13: PLR1704 Redefining argument with the local name `b` +PLR1704 Redefining argument with the local name `b` + --> redefined_argument_from_local.py:85:13 | 83 | def func(a): 84 | def bar(b): 85 | for b in range(1): - | ^ PLR1704 + | ^ 86 | print(b) | -redefined_argument_from_local.py:91:13: PLR1704 Redefining argument with the local name `a` +PLR1704 Redefining argument with the local name `a` + --> redefined_argument_from_local.py:91:13 | 89 | def func(a=1): 90 | def bar(b=2): 91 | for a in range(1): - | ^ PLR1704 + | ^ 92 | print(a) 93 | for b in range(1): | -redefined_argument_from_local.py:93:13: PLR1704 Redefining argument with the local name `b` +PLR1704 Redefining argument with the local name `b` + --> redefined_argument_from_local.py:93:13 | 91 | for a in range(1): 92 | print(a) 93 | for b in range(1): - | ^ PLR1704 + | ^ 94 | print(b) | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap index 42779605bb..f43de224b9 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -useless_return.py:6:5: PLR1711 [*] Useless `return` statement at end of function +PLR1711 [*] Useless `return` statement at end of function + --> useless_return.py:6:5 | 4 | def print_python_version(): 5 | print(sys.version) 6 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 + | ^^^^^^^^^^^ | - = help: Remove useless `return` statement +help: Remove useless `return` statement ℹ Safe fix 3 3 | @@ -20,14 +20,15 @@ useless_return.py:6:5: PLR1711 [*] Useless `return` statement at end of function 8 7 | 9 8 | def print_python_version(): -useless_return.py:11:5: PLR1711 [*] Useless `return` statement at end of function +PLR1711 [*] Useless `return` statement at end of function + --> useless_return.py:11:5 | 9 | def print_python_version(): 10 | print(sys.version) 11 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 + | ^^^^^^^^^^^ | - = help: Remove useless `return` statement +help: Remove useless `return` statement ℹ Safe fix 8 8 | @@ -38,14 +39,15 @@ useless_return.py:11:5: PLR1711 [*] Useless `return` statement at end of functio 13 12 | 14 13 | def print_python_version(): -useless_return.py:16:5: PLR1711 [*] Useless `return` statement at end of function +PLR1711 [*] Useless `return` statement at end of function + --> useless_return.py:16:5 | 14 | def print_python_version(): 15 | print(sys.version) 16 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 + | ^^^^^^^^^^^ | - = help: Remove useless `return` statement +help: Remove useless `return` statement ℹ Safe fix 13 13 | @@ -56,14 +58,15 @@ useless_return.py:16:5: PLR1711 [*] Useless `return` statement at end of functio 18 17 | 19 18 | class SomeClass: -useless_return.py:22:9: PLR1711 [*] Useless `return` statement at end of function +PLR1711 [*] Useless `return` statement at end of function + --> useless_return.py:22:9 | 20 | def print_python_version(self): 21 | print(sys.version) 22 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 + | ^^^^^^^^^^^ | - = help: Remove useless `return` statement +help: Remove useless `return` statement ℹ Safe fix 19 19 | class SomeClass: @@ -74,14 +77,15 @@ useless_return.py:22:9: PLR1711 [*] Useless `return` statement at end of functio 24 23 | 25 24 | def print_python_version(): -useless_return.py:50:5: PLR1711 [*] Useless `return` statement at end of function +PLR1711 [*] Useless `return` statement at end of function + --> useless_return.py:50:5 | 48 | """This function returns None.""" 49 | print(sys.version) 50 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 + | ^^^^^^^^^^^ | - = help: Remove useless `return` statement +help: Remove useless `return` statement ℹ Safe fix 47 47 | def print_python_version(): @@ -92,14 +96,15 @@ useless_return.py:50:5: PLR1711 [*] Useless `return` statement at end of functio 52 51 | 53 52 | class BaseCache: -useless_return.py:60:9: PLR1711 [*] Useless `return` statement at end of function +PLR1711 [*] Useless `return` statement at end of function + --> useless_return.py:60:9 | 58 | def get(self, key: str) -> None: 59 | print(f"{key} not found") 60 | return None - | ^^^^^^^^^^^ PLR1711 + | ^^^^^^^^^^^ | - = help: Remove useless `return` statement +help: Remove useless `return` statement ℹ Safe fix 57 57 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap index 8c988f02f7..725efe59ed 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b"}`. + --> repeated_equality_comparison.py:2:1 | 1 | # Errors. 2 | foo == "a" or foo == "b" - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | foo != "a" and foo != "b" | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 1 1 | # Errors. @@ -19,16 +20,17 @@ repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple compa 4 4 | foo != "a" and foo != "b" 5 5 | -repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b"}`. + --> repeated_equality_comparison.py:4:1 | 2 | foo == "a" or foo == "b" 3 | 4 | foo != "a" and foo != "b" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | foo == "a" or foo == "b" or foo == "c" | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 1 1 | # Errors. @@ -40,16 +42,17 @@ repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple compa 6 6 | foo == "a" or foo == "b" or foo == "c" 7 7 | -repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. + --> repeated_equality_comparison.py:6:1 | 4 | foo != "a" and foo != "b" 5 | 6 | foo == "a" or foo == "b" or foo == "c" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | foo != "a" and foo != "b" and foo != "c" | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 3 3 | @@ -61,16 +64,17 @@ repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple compa 8 8 | foo != "a" and foo != "b" and foo != "c" 9 9 | -repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. + --> repeated_equality_comparison.py:8:1 | 6 | foo == "a" or foo == "b" or foo == "c" 7 | 8 | foo != "a" and foo != "b" and foo != "c" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 5 5 | @@ -82,16 +86,17 @@ repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple compa 10 10 | foo == a or foo == "b" or foo == 3 # Mixed types. 11 11 | -repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (a, "b", 3)`. Use a `set` if the elements are hashable. +PLR1714 [*] Consider merging multiple comparisons: `foo in (a, "b", 3)`. Use a `set` if the elements are hashable. + --> repeated_equality_comparison.py:10:1 | 8 | foo != "a" and foo != "b" and foo != "c" 9 | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | "a" == foo or "b" == foo or "c" == foo | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 7 7 | @@ -103,16 +108,17 @@ repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comp 12 12 | "a" == foo or "b" == foo or "c" == foo 13 13 | -repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. + --> repeated_equality_comparison.py:12:1 | 10 | foo == a or foo == "b" or foo == 3 # Mixed types. 11 | 12 | "a" == foo or "b" == foo or "c" == foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | "a" != foo and "b" != foo and "c" != foo | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 9 9 | @@ -124,16 +130,17 @@ repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comp 14 14 | "a" != foo and "b" != foo and "c" != foo 15 15 | -repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. + --> repeated_equality_comparison.py:14:1 | 12 | "a" == foo or "b" == foo or "c" == foo 13 | 14 | "a" != foo and "b" != foo and "c" != foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | "a" == foo or foo == "b" or "c" == foo | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 11 11 | @@ -145,16 +152,17 @@ repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comp 16 16 | "a" == foo or foo == "b" or "c" == foo 17 17 | -repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. + --> repeated_equality_comparison.py:16:1 | 14 | "a" != foo and "b" != foo and "c" != foo 15 | 16 | "a" == foo or foo == "b" or "c" == foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | foo == bar or baz == foo or qux == foo | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 13 13 | @@ -166,16 +174,17 @@ repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comp 18 18 | foo == bar or baz == foo or qux == foo 19 19 | -repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comparisons: `foo in (bar, baz, qux)`. Use a `set` if the elements are hashable. +PLR1714 [*] Consider merging multiple comparisons: `foo in (bar, baz, qux)`. Use a `set` if the elements are hashable. + --> repeated_equality_comparison.py:18:1 | 16 | "a" == foo or foo == "b" or "c" == foo 17 | 18 | foo == bar or baz == foo or qux == foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | foo == "a" or "b" == foo or foo == "c" | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 15 15 | @@ -187,16 +196,17 @@ repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comp 20 20 | foo == "a" or "b" == foo or foo == "c" 21 21 | -repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b", "c"}`. + --> repeated_equality_comparison.py:20:1 | 18 | foo == bar or baz == foo or qux == foo 19 | 20 | foo == "a" or "b" == foo or foo == "c" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | 22 | foo != "a" and "b" != foo and foo != "c" | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 17 17 | @@ -208,16 +218,17 @@ repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comp 22 22 | foo != "a" and "b" != foo and foo != "c" 23 23 | -repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo not in {"a", "b", "c"}`. + --> repeated_equality_comparison.py:22:1 | 20 | foo == "a" or "b" == foo or foo == "c" 21 | 22 | foo != "a" and "b" != foo and foo != "c" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 19 19 | @@ -229,16 +240,17 @@ repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comp 24 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets 25 25 | -repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b"}`. + --> repeated_equality_comparison.py:24:1 | 22 | foo != "a" and "b" != foo and foo != "c" 23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 21 21 | @@ -250,16 +262,17 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp 26 26 | foo.bar == "a" or foo.bar == "b" # Attributes. 27 27 | -repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comparisons: `bar in {"c", "d"}`. +PLR1714 [*] Consider merging multiple comparisons: `bar in {"c", "d"}`. + --> repeated_equality_comparison.py:24:1 | 22 | foo != "a" and "b" != foo and foo != "c" 23 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 21 21 | @@ -271,16 +284,17 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp 26 26 | foo.bar == "a" or foo.bar == "b" # Attributes. 27 27 | -repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comparisons: `foo.bar in {"a", "b"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo.bar in {"a", "b"}`. + --> repeated_equality_comparison.py:26:1 | 24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets 25 | 26 | foo.bar == "a" or foo.bar == "b" # Attributes. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | # OK | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 23 23 | @@ -292,16 +306,17 @@ repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comp 28 28 | # OK 29 29 | foo == "a" and foo == "b" and foo == "c" # `and` mixed with `==`. -repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple comparisons: `bar in {"c", "d"}`. +PLR1714 [*] Consider merging multiple comparisons: `bar in {"c", "d"}`. + --> repeated_equality_comparison.py:61:16 | 59 | foo == "a" or "c" == bar or foo == "b" or "d" == bar # Multiple targets 60 | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 58 58 | @@ -313,16 +328,17 @@ repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple com 63 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets 64 64 | -repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b"}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {"a", "b"}`. + --> repeated_equality_comparison.py:63:1 | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets 62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 60 60 | @@ -334,16 +350,17 @@ repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comp 65 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets 66 66 | -repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple comparisons: `bar not in {"c", "d"}`. +PLR1714 [*] Consider merging multiple comparisons: `bar not in {"c", "d"}`. + --> repeated_equality_comparison.py:63:29 | 61 | foo == "a" or ("c" == bar or "d" == bar) or foo == "b" # Multiple targets 62 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 60 60 | @@ -355,16 +372,17 @@ repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple com 65 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets 66 66 | -repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple comparisons: `bar not in {"c", "d"}`. +PLR1714 [*] Consider merging multiple comparisons: `bar not in {"c", "d"}`. + --> repeated_equality_comparison.py:65:16 | 63 | foo == "a" or foo == "b" or "c" != bar and "d" != bar # Multiple targets 64 | 65 | foo == "a" or ("c" != bar and "d" != bar) or foo == "b" # Multiple targets - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 62 62 | @@ -376,16 +394,17 @@ repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple com 67 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets 68 68 | -repeated_equality_comparison.py:69:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {1, True}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {1, True}`. + --> repeated_equality_comparison.py:69:1 | 67 | foo == "a" and "c" != bar or foo == "b" and "d" != bar # Multiple targets 68 | 69 | foo == 1 or foo == True # Different types, same hashed value - | ^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^ 70 | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 66 66 | @@ -397,16 +416,17 @@ repeated_equality_comparison.py:69:1: PLR1714 [*] Consider merging multiple comp 71 71 | foo == 1 or foo == 1.0 # Different types, same hashed value 72 72 | -repeated_equality_comparison.py:71:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {1, 1.0}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {1, 1.0}`. + --> repeated_equality_comparison.py:71:1 | 69 | foo == 1 or foo == True # Different types, same hashed value 70 | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value - | ^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | foo == False or foo == 0 # Different types, same hashed value | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 68 68 | @@ -418,16 +438,17 @@ repeated_equality_comparison.py:71:1: PLR1714 [*] Consider merging multiple comp 73 73 | foo == False or foo == 0 # Different types, same hashed value 74 74 | -repeated_equality_comparison.py:73:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {False, 0}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {False, 0}`. + --> repeated_equality_comparison.py:73:1 | 71 | foo == 1 or foo == 1.0 # Different types, same hashed value 72 | 73 | foo == False or foo == 0 # Different types, same hashed value - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 74 | 75 | foo == 0.0 or foo == 0j # Different types, same hashed value | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 70 70 | @@ -438,14 +459,15 @@ repeated_equality_comparison.py:73:1: PLR1714 [*] Consider merging multiple comp 74 74 | 75 75 | foo == 0.0 or foo == 0j # Different types, same hashed value -repeated_equality_comparison.py:75:1: PLR1714 [*] Consider merging multiple comparisons: `foo in {0.0, 0j}`. +PLR1714 [*] Consider merging multiple comparisons: `foo in {0.0, 0j}`. + --> repeated_equality_comparison.py:75:1 | 73 | foo == False or foo == 0 # Different types, same hashed value 74 | 75 | foo == 0.0 or foo == 0j # Different types, same hashed value - | ^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Merge multiple comparisons +help: Merge multiple comparisons ℹ Unsafe fix 72 72 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1716_boolean_chained_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1716_boolean_chained_comparison.py.snap index 649554548f..faf07307cc 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1716_boolean_chained_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1716_boolean_chained_comparison.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -boolean_chained_comparison.py:8:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:8:4 | 6 | b = int(input()) 7 | c = int(input()) 8 | if a < b and b < c: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^ 9 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 5 5 | a = int(input()) @@ -21,15 +22,16 @@ boolean_chained_comparison.py:8:4: PLR1716 [*] Contains chained boolean comparis 10 10 | 11 11 | a = int(input()) -boolean_chained_comparison.py:14:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:14:4 | 12 | b = int(input()) 13 | c = int(input()) 14 | if a < b and b <= c: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^ 15 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 11 11 | a = int(input()) @@ -41,15 +43,16 @@ boolean_chained_comparison.py:14:4: PLR1716 [*] Contains chained boolean compari 16 16 | 17 17 | a = int(input()) -boolean_chained_comparison.py:20:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:20:4 | 18 | b = int(input()) 19 | c = int(input()) 20 | if a <= b and b < c: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^ 21 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 17 17 | a = int(input()) @@ -61,15 +64,16 @@ boolean_chained_comparison.py:20:4: PLR1716 [*] Contains chained boolean compari 22 22 | 23 23 | a = int(input()) -boolean_chained_comparison.py:26:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:26:4 | 24 | b = int(input()) 25 | c = int(input()) 26 | if a <= b and b <= c: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^^ 27 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 23 23 | a = int(input()) @@ -81,15 +85,16 @@ boolean_chained_comparison.py:26:4: PLR1716 [*] Contains chained boolean compari 28 28 | 29 29 | # --------------------- -boolean_chained_comparison.py:36:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:36:4 | 34 | b = int(input()) 35 | c = int(input()) 36 | if a > b and b > c: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^ 37 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 33 33 | a = int(input()) @@ -101,15 +106,16 @@ boolean_chained_comparison.py:36:4: PLR1716 [*] Contains chained boolean compari 38 38 | 39 39 | a = int(input()) -boolean_chained_comparison.py:42:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:42:4 | 40 | b = int(input()) 41 | c = int(input()) 42 | if a >= b and b > c: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^ 43 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 39 39 | a = int(input()) @@ -121,15 +127,16 @@ boolean_chained_comparison.py:42:4: PLR1716 [*] Contains chained boolean compari 44 44 | 45 45 | a = int(input()) -boolean_chained_comparison.py:48:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:48:4 | 46 | b = int(input()) 47 | c = int(input()) 48 | if a > b and b >= c: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^ 49 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 45 45 | a = int(input()) @@ -141,15 +148,16 @@ boolean_chained_comparison.py:48:4: PLR1716 [*] Contains chained boolean compari 50 50 | 51 51 | a = int(input()) -boolean_chained_comparison.py:54:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:54:4 | 52 | b = int(input()) 53 | c = int(input()) 54 | if a >= b and b >= c: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^^ 55 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 51 51 | a = int(input()) @@ -161,15 +169,16 @@ boolean_chained_comparison.py:54:4: PLR1716 [*] Contains chained boolean compari 56 56 | 57 57 | # ----------------------- -boolean_chained_comparison.py:65:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:65:4 | 63 | c = int(input()) 64 | d = int(input()) 65 | if a < b and b < c and c < d: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^ 66 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 62 62 | b = int(input()) @@ -181,15 +190,16 @@ boolean_chained_comparison.py:65:4: PLR1716 [*] Contains chained boolean compari 67 67 | 68 68 | a = int(input()) -boolean_chained_comparison.py:65:14: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:65:14 | 63 | c = int(input()) 64 | d = int(input()) 65 | if a < b and b < c and c < d: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^ 66 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 62 62 | b = int(input()) @@ -201,15 +211,16 @@ boolean_chained_comparison.py:65:14: PLR1716 [*] Contains chained boolean compar 67 67 | 68 68 | a = int(input()) -boolean_chained_comparison.py:73:4: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:73:4 | 71 | d = int(input()) 72 | e = int(input()) 73 | if a < b and b < c and c < d and d < e: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^ 74 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 70 70 | c = int(input()) @@ -221,15 +232,16 @@ boolean_chained_comparison.py:73:4: PLR1716 [*] Contains chained boolean compari 75 75 | 76 76 | # ------------ -boolean_chained_comparison.py:73:14: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:73:14 | 71 | d = int(input()) 72 | e = int(input()) 73 | if a < b and b < c and c < d and d < e: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^ 74 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 70 70 | c = int(input()) @@ -241,15 +253,16 @@ boolean_chained_comparison.py:73:14: PLR1716 [*] Contains chained boolean compar 75 75 | 76 76 | # ------------ -boolean_chained_comparison.py:73:24: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:73:24 | 71 | d = int(input()) 72 | e = int(input()) 73 | if a < b and b < c and c < d and d < e: # [boolean-chained-comparison] - | ^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^ 74 | pass | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 70 70 | c = int(input()) @@ -261,15 +274,16 @@ boolean_chained_comparison.py:73:24: PLR1716 [*] Contains chained boolean compar 75 75 | 76 76 | # ------------ -boolean_chained_comparison.py:123:2: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:123:2 | 122 | # fixes will balance parentheses 123 | (a < b) and b < c - | ^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^ 124 | a < b and (b < c) 125 | ((a < b) and b < c) | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 120 120 | pass @@ -281,16 +295,17 @@ boolean_chained_comparison.py:123:2: PLR1716 [*] Contains chained boolean compar 125 125 | ((a < b) and b < c) 126 126 | (a < b) and (b < c) -boolean_chained_comparison.py:124:1: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:124:1 | 122 | # fixes will balance parentheses 123 | (a < b) and b < c 124 | a < b and (b < c) - | ^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^ 125 | ((a < b) and b < c) 126 | (a < b) and (b < c) | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 121 121 | @@ -302,16 +317,17 @@ boolean_chained_comparison.py:124:1: PLR1716 [*] Contains chained boolean compar 126 126 | (a < b) and (b < c) 127 127 | (((a < b))) and (b < c) -boolean_chained_comparison.py:125:3: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:125:3 | 123 | (a < b) and b < c 124 | a < b and (b < c) 125 | ((a < b) and b < c) - | ^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^ 126 | (a < b) and (b < c) 127 | (((a < b))) and (b < c) | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 122 122 | # fixes will balance parentheses @@ -323,15 +339,16 @@ boolean_chained_comparison.py:125:3: PLR1716 [*] Contains chained boolean compar 127 127 | (((a < b))) and (b < c) 128 128 | -boolean_chained_comparison.py:126:2: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:126:2 | 124 | a < b and (b < c) 125 | ((a < b) and b < c) 126 | (a < b) and (b < c) - | ^^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^^ 127 | (((a < b))) and (b < c) | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 123 123 | (a < b) and b < c @@ -343,16 +360,17 @@ boolean_chained_comparison.py:126:2: PLR1716 [*] Contains chained boolean compar 128 128 | 129 129 | (a boolean_chained_comparison.py:127:4 | 125 | ((a < b) and b < c) 126 | (a < b) and (b < c) 127 | (((a < b))) and (b < c) - | ^^^^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^^^^ 128 | 129 | (a boolean_chained_comparison.py:129:2 | 127 | (((a < b))) and (b < c) 128 | 129 | (a boolean_chained_comparison.py:129:11 | 127 | (((a < b))) and (b < c) 128 | 129 | (a boolean_chained_comparison.py:132:1 | 131 | # should error and fix 132 | a boolean_chained_comparison.py:135:1 | 134 | # more involved examples (all should error and fix) 135 | / a < ( # sneaky comment 136 | | b 137 | | # more comments 138 | | ) and b < c - | |___________^ PLR1716 + | |___________^ 139 | 140 | ( | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 135 135 | a < ( # sneaky comment @@ -449,7 +471,8 @@ boolean_chained_comparison.py:135:1: PLR1716 [*] Contains chained boolean compar 140 140 | ( 141 141 | a -boolean_chained_comparison.py:141:5: PLR1716 [*] Contains chained boolean comparison that can be simplified +PLR1716 [*] Contains chained boolean comparison that can be simplified + --> boolean_chained_comparison.py:141:5 | 140 | ( 141 | / a @@ -457,10 +480,10 @@ boolean_chained_comparison.py:141:5: PLR1716 [*] Contains chained boolean compar 143 | | # hmmm... 144 | | boolean_chained_comparison.py:148:1 | 146 | ) 147 | 148 | a < (b) and (((b)) < c) - | ^^^^^^^^^^^^^^^^^^^^^^ PLR1716 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use a single compare expression +help: Use a single compare expression ℹ Safe fix 145 145 | and ((c sys_exit_alias_0.py:1:1 | 1 | exit(0) - | ^^^^ PLR1722 + | ^^^^ 2 | quit(0) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |-exit(0) @@ -18,13 +18,14 @@ sys_exit_alias_0.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` 3 4 | 4 5 | -sys_exit_alias_0.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_0.py:2:1 | 1 | exit(0) 2 | quit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys @@ -35,14 +36,15 @@ sys_exit_alias_0.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` 4 5 | 5 6 | def main(): -sys_exit_alias_0.py:6:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_0.py:6:5 | 5 | def main(): 6 | exit(2) - | ^^^^ PLR1722 + | ^^^^ 7 | quit(2) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys @@ -55,14 +57,15 @@ sys_exit_alias_0.py:6:5: PLR1722 [*] Use `sys.exit()` instead of `exit` 7 |+ sys.exit(2) 7 8 | quit(2) -sys_exit_alias_0.py:7:5: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_0.py:7:5 | 5 | def main(): 6 | exit(2) 7 | quit(2) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap index 986e16f9b2..fe9dbde798 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_1.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_1.py:3:1 | 1 | import sys 2 | 3 | exit(0) - | ^^^^ PLR1722 + | ^^^^ 4 | quit(0) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 1 | import sys @@ -20,13 +21,14 @@ sys_exit_alias_1.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` 5 5 | 6 6 | -sys_exit_alias_1.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_1.py:4:1 | 3 | exit(0) 4 | quit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 1 | import sys @@ -38,14 +40,15 @@ sys_exit_alias_1.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` 6 6 | 7 7 | def main(): -sys_exit_alias_1.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_1.py:8:5 | 7 | def main(): 8 | exit(1) - | ^^^^ PLR1722 + | ^^^^ 9 | quit(1) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 5 5 | @@ -57,14 +60,15 @@ sys_exit_alias_1.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` 10 10 | 11 11 | -sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_1.py:9:5 | 7 | def main(): 8 | exit(1) 9 | quit(1) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 6 6 | @@ -76,20 +80,22 @@ sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` 11 11 | 12 12 | def main(): -sys_exit_alias_1.py:15:5: PLR1722 Use `sys.exit()` instead of `exit` +PLR1722 Use `sys.exit()` instead of `exit` + --> sys_exit_alias_1.py:15:5 | 13 | sys = 1 14 | 15 | exit(1) - | ^^^^ PLR1722 + | ^^^^ 16 | quit(1) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` -sys_exit_alias_1.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` +PLR1722 Use `sys.exit()` instead of `quit` + --> sys_exit_alias_1.py:16:5 | 15 | exit(1) 16 | quit(1) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap index d8bfe3033e..c6481fa743 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -sys_exit_alias_10.py:8:5: PLR1722 Use `sys.exit()` instead of `exit` +PLR1722 Use `sys.exit()` instead of `exit` + --> sys_exit_alias_10.py:8:5 | 7 | def main(): 8 | exit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap index 3475c756f2..815d6fcb23 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_11.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_11.py:3:1 | 1 | from sys import * 2 | 3 | exit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 1 | from sys import * diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap index 081f770791..3e0a0aa135 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_12.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_12.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_12.py:3:1 | 1 | import os \ 2 | 3 | exit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |-import os \ diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_13.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_13.py.snap index ecca433ff9..f5ac04576c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_13.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_13.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_13.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_13.py:1:1 | 1 | exit(code=2) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |-exit(code=2) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_14.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_14.py.snap index 208d3ee4f7..e190005449 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_14.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_14.py.snap @@ -1,10 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_14.py:2:1: PLR1722 Use `sys.exit()` instead of `exit` +PLR1722 Use `sys.exit()` instead of `exit` + --> sys_exit_alias_14.py:2:1 | 1 | code = {"code": 2} 2 | exit(**code) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_15.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_15.py.snap index f0c8b0d054..dc80fda262 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_15.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_15.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_15.py:6:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_15.py:6:1 | 4 | else: 5 | code = 1 6 | exit(code) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_16.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_16.py.snap index 1e8b7d377f..c6ba6451e5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_16.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_16.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_16.py:3:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_16.py:3:5 | 1 | def test_case_1(): 2 | # comments preserved with a positional argument 3 | exit( # comment - | ^^^^ PLR1722 + | ^^^^ 4 | 1, # 2 5 | ) # 3 | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys @@ -22,16 +23,17 @@ sys_exit_alias_16.py:3:5: PLR1722 [*] Use `sys.exit()` instead of `exit` 5 6 | ) # 3 6 7 | -sys_exit_alias_16.py:10:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_16.py:10:5 | 8 | def test_case_2(): 9 | # comments preserved with a single keyword argument 10 | exit( # comment - | ^^^^ PLR1722 + | ^^^^ 11 | code=1, # 2 12 | ) # 3 | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys @@ -50,23 +52,25 @@ sys_exit_alias_16.py:10:5: PLR1722 [*] Use `sys.exit()` instead of `exit` 13 14 | 14 15 | -sys_exit_alias_16.py:17:5: PLR1722 Use `sys.exit()` instead of `exit` +PLR1722 Use `sys.exit()` instead of `exit` + --> sys_exit_alias_16.py:17:5 | 15 | def test_case_3(): 16 | # no diagnostic for multiple arguments 17 | exit(2, 3, 4) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` -sys_exit_alias_16.py:23:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_16.py:23:5 | 21 | # this should now be fixable 22 | codes = [1] 23 | exit(*codes) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap index fa77515597..642d47a335 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_2.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_2.py:3:1 | 1 | import sys as sys2 2 | 3 | exit(0) - | ^^^^ PLR1722 + | ^^^^ 4 | quit(0) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 1 | import sys as sys2 @@ -20,13 +21,14 @@ sys_exit_alias_2.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` 5 5 | 6 6 | -sys_exit_alias_2.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_2.py:4:1 | 3 | exit(0) 4 | quit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 1 | import sys as sys2 @@ -38,14 +40,15 @@ sys_exit_alias_2.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` 6 6 | 7 7 | def main(): -sys_exit_alias_2.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_2.py:8:5 | 7 | def main(): 8 | exit(1) - | ^^^^ PLR1722 + | ^^^^ 9 | quit(1) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 5 5 | @@ -55,14 +58,15 @@ sys_exit_alias_2.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` 8 |+ sys2.exit(1) 9 9 | quit(1) -sys_exit_alias_2.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_2.py:9:5 | 7 | def main(): 8 | exit(1) 9 | quit(1) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 6 6 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap index 43e4361fe2..c3e57c562a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -sys_exit_alias_3.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_3.py:4:1 | 3 | exit(0) 4 | quit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 1 | from sys import exit @@ -20,14 +20,15 @@ sys_exit_alias_3.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` 6 6 | 7 7 | def main(): -sys_exit_alias_3.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_3.py:9:5 | 7 | def main(): 8 | exit(1) 9 | quit(1) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 6 6 | @@ -39,10 +40,11 @@ sys_exit_alias_3.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` 11 11 | 12 12 | def main(): -sys_exit_alias_3.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` +PLR1722 Use `sys.exit()` instead of `quit` + --> sys_exit_alias_3.py:16:5 | 15 | exit(1) 16 | quit(1) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap index 5f17881fe8..a488ad084d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_4.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_4.py:3:1 | 1 | from sys import exit as exit2 2 | 3 | exit(0) - | ^^^^ PLR1722 + | ^^^^ 4 | quit(0) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 1 | from sys import exit as exit2 @@ -20,13 +21,14 @@ sys_exit_alias_4.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` 5 5 | 6 6 | -sys_exit_alias_4.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_4.py:4:1 | 3 | exit(0) 4 | quit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 1 | from sys import exit as exit2 @@ -38,14 +40,15 @@ sys_exit_alias_4.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` 6 6 | 7 7 | def main(): -sys_exit_alias_4.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_4.py:8:5 | 7 | def main(): 8 | exit(1) - | ^^^^ PLR1722 + | ^^^^ 9 | quit(1) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 5 5 | @@ -55,14 +58,15 @@ sys_exit_alias_4.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` 8 |+ exit2(1) 9 9 | quit(1) -sys_exit_alias_4.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_4.py:9:5 | 7 | def main(): 8 | exit(1) 9 | quit(1) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 6 6 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap index 99a789f9ef..e1ba1969a6 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -sys_exit_alias_5.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_5.py:3:1 | 1 | from sys import * 2 | 3 | exit(0) - | ^^^^ PLR1722 + | ^^^^ 4 | quit(0) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 1 | from sys import * @@ -21,13 +22,14 @@ sys_exit_alias_5.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` 5 6 | 6 7 | -sys_exit_alias_5.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_5.py:4:1 | 3 | exit(0) 4 | quit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 1 | from sys import * @@ -40,14 +42,15 @@ sys_exit_alias_5.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` 6 7 | 7 8 | def main(): -sys_exit_alias_5.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_5.py:8:5 | 7 | def main(): 8 | exit(1) - | ^^^^ PLR1722 + | ^^^^ 9 | quit(1) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 1 | from sys import * @@ -62,14 +65,15 @@ sys_exit_alias_5.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` 9 |+ sys.exit(1) 9 10 | quit(1) -sys_exit_alias_5.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_5.py:9:5 | 7 | def main(): 8 | exit(1) 9 | quit(1) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 1 | from sys import * diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap index bff2c47eec..50fccc0bb8 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -sys_exit_alias_6.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_6.py:1:1 | 1 | exit(0) - | ^^^^ PLR1722 + | ^^^^ 2 | quit(0) | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |-exit(0) @@ -18,13 +18,14 @@ sys_exit_alias_6.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` 3 4 | 4 5 | -sys_exit_alias_6.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` +PLR1722 [*] Use `sys.exit()` instead of `quit` + --> sys_exit_alias_6.py:2:1 | 1 | exit(0) 2 | quit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `quit` with `sys.exit()` +help: Replace `quit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap index 072845bb2e..43c99f3f74 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -sys_exit_alias_7.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_7.py:2:5 | 1 | def main(): 2 | exit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap index 337821b7d4..2008a11682 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -sys_exit_alias_8.py:5:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_8.py:5:5 | 4 | def main(): 5 | exit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |-from sys import argv diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap index 019462ca26..667a82f2f6 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -sys_exit_alias_9.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` +PLR1722 [*] Use `sys.exit()` instead of `exit` + --> sys_exit_alias_9.py:2:5 | 1 | def main(): 2 | exit(0) - | ^^^^ PLR1722 + | ^^^^ | - = help: Replace `exit` with `sys.exit()` +help: Replace `exit` with `sys.exit()` ℹ Unsafe fix 1 |+import sys diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1730_if_stmt_min_max.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1730_if_stmt_min_max.py.snap index 89aec8775e..6b97573e49 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1730_if_stmt_min_max.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1730_if_stmt_min_max.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -if_stmt_min_max.py:21:1: PLR1730 [*] Replace `if` statement with `a = min(b, a)` +PLR1730 [*] Replace `if` statement with `a = min(b, a)` + --> if_stmt_min_max.py:21:1 | 20 | # case 1: a = min(b, a) 21 | / if a >= b: 22 | | a = b - | |_________^ PLR1730 + | |_________^ 23 | 24 | # case 2: a = max(b, a) | - = help: Replace with `a = min(b, a)` +help: Replace with `a = min(b, a)` ℹ Safe fix 18 18 | a, b = [], [] @@ -23,16 +24,17 @@ if_stmt_min_max.py:21:1: PLR1730 [*] Replace `if` statement with `a = min(b, a)` 24 23 | # case 2: a = max(b, a) 25 24 | if a <= b: -if_stmt_min_max.py:25:1: PLR1730 [*] Replace `if` statement with `a = max(b, a)` +PLR1730 [*] Replace `if` statement with `a = max(b, a)` + --> if_stmt_min_max.py:25:1 | 24 | # case 2: a = max(b, a) 25 | / if a <= b: 26 | | a = b - | |_________^ PLR1730 + | |_________^ 27 | 28 | # case 3: b = min(a, b) | - = help: Replace with `a = max(b, a)` +help: Replace with `a = max(b, a)` ℹ Safe fix 22 22 | a = b @@ -45,16 +47,17 @@ if_stmt_min_max.py:25:1: PLR1730 [*] Replace `if` statement with `a = max(b, a)` 28 27 | # case 3: b = min(a, b) 29 28 | if a <= b: -if_stmt_min_max.py:29:1: PLR1730 [*] Replace `if` statement with `b = min(a, b)` +PLR1730 [*] Replace `if` statement with `b = min(a, b)` + --> if_stmt_min_max.py:29:1 | 28 | # case 3: b = min(a, b) 29 | / if a <= b: 30 | | b = a - | |_________^ PLR1730 + | |_________^ 31 | 32 | # case 4: b = max(a, b) | - = help: Replace with `b = min(a, b)` +help: Replace with `b = min(a, b)` ℹ Safe fix 26 26 | a = b @@ -67,16 +70,17 @@ if_stmt_min_max.py:29:1: PLR1730 [*] Replace `if` statement with `b = min(a, b)` 32 31 | # case 4: b = max(a, b) 33 32 | if a >= b: -if_stmt_min_max.py:33:1: PLR1730 [*] Replace `if` statement with `b = max(a, b)` +PLR1730 [*] Replace `if` statement with `b = max(a, b)` + --> if_stmt_min_max.py:33:1 | 32 | # case 4: b = max(a, b) 33 | / if a >= b: 34 | | b = a - | |_________^ PLR1730 + | |_________^ 35 | 36 | # case 5: a = min(a, b) | - = help: Replace with `b = max(a, b)` +help: Replace with `b = max(a, b)` ℹ Safe fix 30 30 | b = a @@ -89,16 +93,17 @@ if_stmt_min_max.py:33:1: PLR1730 [*] Replace `if` statement with `b = max(a, b)` 36 35 | # case 5: a = min(a, b) 37 36 | if a > b: -if_stmt_min_max.py:37:1: PLR1730 [*] Replace `if` statement with `a = min(a, b)` +PLR1730 [*] Replace `if` statement with `a = min(a, b)` + --> if_stmt_min_max.py:37:1 | 36 | # case 5: a = min(a, b) 37 | / if a > b: 38 | | a = b - | |_________^ PLR1730 + | |_________^ 39 | 40 | # case 6: a = max(a, b) | - = help: Replace with `a = min(a, b)` +help: Replace with `a = min(a, b)` ℹ Safe fix 34 34 | b = a @@ -111,16 +116,17 @@ if_stmt_min_max.py:37:1: PLR1730 [*] Replace `if` statement with `a = min(a, b)` 40 39 | # case 6: a = max(a, b) 41 40 | if a < b: -if_stmt_min_max.py:41:1: PLR1730 [*] Replace `if` statement with `a = max(a, b)` +PLR1730 [*] Replace `if` statement with `a = max(a, b)` + --> if_stmt_min_max.py:41:1 | 40 | # case 6: a = max(a, b) 41 | / if a < b: 42 | | a = b - | |_________^ PLR1730 + | |_________^ 43 | 44 | # case 7: b = min(b, a) | - = help: Replace with `a = max(a, b)` +help: Replace with `a = max(a, b)` ℹ Safe fix 38 38 | a = b @@ -133,16 +139,17 @@ if_stmt_min_max.py:41:1: PLR1730 [*] Replace `if` statement with `a = max(a, b)` 44 43 | # case 7: b = min(b, a) 45 44 | if a < b: -if_stmt_min_max.py:45:1: PLR1730 [*] Replace `if` statement with `b = min(b, a)` +PLR1730 [*] Replace `if` statement with `b = min(b, a)` + --> if_stmt_min_max.py:45:1 | 44 | # case 7: b = min(b, a) 45 | / if a < b: 46 | | b = a - | |_________^ PLR1730 + | |_________^ 47 | 48 | # case 8: b = max(b, a) | - = help: Replace with `b = min(b, a)` +help: Replace with `b = min(b, a)` ℹ Safe fix 42 42 | a = b @@ -155,14 +162,15 @@ if_stmt_min_max.py:45:1: PLR1730 [*] Replace `if` statement with `b = min(b, a)` 48 47 | # case 8: b = max(b, a) 49 48 | if a > b: -if_stmt_min_max.py:49:1: PLR1730 [*] Replace `if` statement with `b = max(b, a)` +PLR1730 [*] Replace `if` statement with `b = max(b, a)` + --> if_stmt_min_max.py:49:1 | 48 | # case 8: b = max(b, a) 49 | / if a > b: 50 | | b = a - | |_________^ PLR1730 + | |_________^ | - = help: Replace with `b = max(b, a)` +help: Replace with `b = max(b, a)` ℹ Safe fix 46 46 | b = a @@ -175,16 +183,17 @@ if_stmt_min_max.py:49:1: PLR1730 [*] Replace `if` statement with `b = max(b, a)` 52 51 | 53 52 | # test cases with assigned variables and primitives -if_stmt_min_max.py:59:1: PLR1730 [*] Replace `if` statement with `value = max(value, 10)` +PLR1730 [*] Replace `if` statement with `value = max(value, 10)` + --> if_stmt_min_max.py:59:1 | 58 | # base case 6: value = max(value, 10) 59 | / if value < 10: 60 | | value = 10 - | |______________^ PLR1730 + | |______________^ 61 | 62 | # base case 2: value = max(10, value) | - = help: Replace with `value = max(value, 10)` +help: Replace with `value = max(value, 10)` ℹ Safe fix 56 56 | value3 = 3 @@ -197,16 +206,17 @@ if_stmt_min_max.py:59:1: PLR1730 [*] Replace `if` statement with `value = max(va 62 61 | # base case 2: value = max(10, value) 63 62 | if value <= 10: -if_stmt_min_max.py:63:1: PLR1730 [*] Replace `if` statement with `value = max(10, value)` +PLR1730 [*] Replace `if` statement with `value = max(10, value)` + --> if_stmt_min_max.py:63:1 | 62 | # base case 2: value = max(10, value) 63 | / if value <= 10: 64 | | value = 10 - | |______________^ PLR1730 + | |______________^ 65 | 66 | # base case 6: value = max(value, value2) | - = help: Replace with `value = max(10, value)` +help: Replace with `value = max(10, value)` ℹ Safe fix 60 60 | value = 10 @@ -219,16 +229,17 @@ if_stmt_min_max.py:63:1: PLR1730 [*] Replace `if` statement with `value = max(10 66 65 | # base case 6: value = max(value, value2) 67 66 | if value < value2: -if_stmt_min_max.py:67:1: PLR1730 [*] Replace `if` statement with `value = max(value, value2)` +PLR1730 [*] Replace `if` statement with `value = max(value, value2)` + --> if_stmt_min_max.py:67:1 | 66 | # base case 6: value = max(value, value2) 67 | / if value < value2: 68 | | value = value2 - | |__________________^ PLR1730 + | |__________________^ 69 | 70 | # base case 5: value = min(value, 10) | - = help: Replace with `value = max(value, value2)` +help: Replace with `value = max(value, value2)` ℹ Safe fix 64 64 | value = 10 @@ -241,16 +252,17 @@ if_stmt_min_max.py:67:1: PLR1730 [*] Replace `if` statement with `value = max(va 70 69 | # base case 5: value = min(value, 10) 71 70 | if value > 10: -if_stmt_min_max.py:71:1: PLR1730 [*] Replace `if` statement with `value = min(value, 10)` +PLR1730 [*] Replace `if` statement with `value = min(value, 10)` + --> if_stmt_min_max.py:71:1 | 70 | # base case 5: value = min(value, 10) 71 | / if value > 10: 72 | | value = 10 - | |______________^ PLR1730 + | |______________^ 73 | 74 | # base case 1: value = min(10, value) | - = help: Replace with `value = min(value, 10)` +help: Replace with `value = min(value, 10)` ℹ Safe fix 68 68 | value = value2 @@ -263,16 +275,17 @@ if_stmt_min_max.py:71:1: PLR1730 [*] Replace `if` statement with `value = min(va 74 73 | # base case 1: value = min(10, value) 75 74 | if value >= 10: -if_stmt_min_max.py:75:1: PLR1730 [*] Replace `if` statement with `value = min(10, value)` +PLR1730 [*] Replace `if` statement with `value = min(10, value)` + --> if_stmt_min_max.py:75:1 | 74 | # base case 1: value = min(10, value) 75 | / if value >= 10: 76 | | value = 10 - | |______________^ PLR1730 + | |______________^ 77 | 78 | # base case 5: value = min(value, value2) | - = help: Replace with `value = min(10, value)` +help: Replace with `value = min(10, value)` ℹ Safe fix 72 72 | value = 10 @@ -285,14 +298,15 @@ if_stmt_min_max.py:75:1: PLR1730 [*] Replace `if` statement with `value = min(10 78 77 | # base case 5: value = min(value, value2) 79 78 | if value > value2: -if_stmt_min_max.py:79:1: PLR1730 [*] Replace `if` statement with `value = min(value, value2)` +PLR1730 [*] Replace `if` statement with `value = min(value, value2)` + --> if_stmt_min_max.py:79:1 | 78 | # base case 5: value = min(value, value2) 79 | / if value > value2: 80 | | value = value2 - | |__________________^ PLR1730 + | |__________________^ | - = help: Replace with `value = min(value, value2)` +help: Replace with `value = min(value, value2)` ℹ Safe fix 76 76 | value = 10 @@ -305,15 +319,16 @@ if_stmt_min_max.py:79:1: PLR1730 [*] Replace `if` statement with `value = min(va 82 81 | 83 82 | # cases with calls -if_stmt_min_max.py:92:1: PLR1730 [*] Replace `if` statement with `A1.value = max(A1.value, 10)` +PLR1730 [*] Replace `if` statement with `A1.value = max(A1.value, 10)` + --> if_stmt_min_max.py:92:1 | 92 | / if A1.value < 10: 93 | | A1.value = 10 - | |_________________^ PLR1730 + | |_________________^ 94 | 95 | if A1.value > 10: | - = help: Replace with `A1.value = max(A1.value, 10)` +help: Replace with `A1.value = max(A1.value, 10)` ℹ Safe fix 89 89 | A1 = A() @@ -326,15 +341,16 @@ if_stmt_min_max.py:92:1: PLR1730 [*] Replace `if` statement with `A1.value = max 95 94 | if A1.value > 10: 96 95 | A1.value = 10 -if_stmt_min_max.py:95:1: PLR1730 [*] Replace `if` statement with `A1.value = min(A1.value, 10)` +PLR1730 [*] Replace `if` statement with `A1.value = min(A1.value, 10)` + --> if_stmt_min_max.py:95:1 | 93 | A1.value = 10 94 | 95 | / if A1.value > 10: 96 | | A1.value = 10 - | |_________________^ PLR1730 + | |_________________^ | - = help: Replace with `A1.value = min(A1.value, 10)` +help: Replace with `A1.value = min(A1.value, 10)` ℹ Safe fix 92 92 | if A1.value < 10: @@ -347,17 +363,18 @@ if_stmt_min_max.py:95:1: PLR1730 [*] Replace `if` statement with `A1.value = min 98 97 | 99 98 | class AA: -if_stmt_min_max.py:119:1: PLR1730 [*] Replace `if` statement with `A2 = max(A2, A1)` +PLR1730 [*] Replace `if` statement with `A2 = max(A2, A1)` + --> if_stmt_min_max.py:119:1 | 117 | A2 = AA(3) 118 | 119 | / if A2 < A1: # [max-instead-of-if] 120 | | A2 = A1 - | |___________^ PLR1730 + | |___________^ 121 | 122 | if A2 <= A1: # [max-instead-of-if] | - = help: Replace with `A2 = max(A2, A1)` +help: Replace with `A2 = max(A2, A1)` ℹ Unsafe fix 116 116 | A1 = AA(0) @@ -370,17 +387,18 @@ if_stmt_min_max.py:119:1: PLR1730 [*] Replace `if` statement with `A2 = max(A2, 122 121 | if A2 <= A1: # [max-instead-of-if] 123 122 | A2 = A1 -if_stmt_min_max.py:122:1: PLR1730 [*] Replace `if` statement with `A2 = max(A1, A2)` +PLR1730 [*] Replace `if` statement with `A2 = max(A1, A2)` + --> if_stmt_min_max.py:122:1 | 120 | A2 = A1 121 | 122 | / if A2 <= A1: # [max-instead-of-if] 123 | | A2 = A1 - | |___________^ PLR1730 + | |___________^ 124 | 125 | if A2 > A1: # [min-instead-of-if] | - = help: Replace with `A2 = max(A1, A2)` +help: Replace with `A2 = max(A1, A2)` ℹ Unsafe fix 119 119 | if A2 < A1: # [max-instead-of-if] @@ -393,17 +411,18 @@ if_stmt_min_max.py:122:1: PLR1730 [*] Replace `if` statement with `A2 = max(A1, 125 124 | if A2 > A1: # [min-instead-of-if] 126 125 | A2 = A1 -if_stmt_min_max.py:125:1: PLR1730 [*] Replace `if` statement with `A2 = min(A2, A1)` +PLR1730 [*] Replace `if` statement with `A2 = min(A2, A1)` + --> if_stmt_min_max.py:125:1 | 123 | A2 = A1 124 | 125 | / if A2 > A1: # [min-instead-of-if] 126 | | A2 = A1 - | |___________^ PLR1730 + | |___________^ 127 | 128 | if A2 >= A1: # [min-instead-of-if] | - = help: Replace with `A2 = min(A2, A1)` +help: Replace with `A2 = min(A2, A1)` ℹ Unsafe fix 122 122 | if A2 <= A1: # [max-instead-of-if] @@ -416,17 +435,18 @@ if_stmt_min_max.py:125:1: PLR1730 [*] Replace `if` statement with `A2 = min(A2, 128 127 | if A2 >= A1: # [min-instead-of-if] 129 128 | A2 = A1 -if_stmt_min_max.py:128:1: PLR1730 [*] Replace `if` statement with `A2 = min(A1, A2)` +PLR1730 [*] Replace `if` statement with `A2 = min(A1, A2)` + --> if_stmt_min_max.py:128:1 | 126 | A2 = A1 127 | 128 | / if A2 >= A1: # [min-instead-of-if] 129 | | A2 = A1 - | |___________^ PLR1730 + | |___________^ 130 | 131 | # Negative | - = help: Replace with `A2 = min(A1, A2)` +help: Replace with `A2 = min(A1, A2)` ℹ Unsafe fix 125 125 | if A2 > A1: # [min-instead-of-if] @@ -439,7 +459,8 @@ if_stmt_min_max.py:128:1: PLR1730 [*] Replace `if` statement with `A2 = min(A1, 131 130 | # Negative 132 131 | if value < 10: -if_stmt_min_max.py:191:1: PLR1730 [*] Replace `if` statement with `min` call +PLR1730 [*] Replace `if` statement with `min` call + --> if_stmt_min_max.py:191:1 | 190 | # Parenthesized expressions 191 | / if value.attr > 3: @@ -447,11 +468,11 @@ if_stmt_min_max.py:191:1: PLR1730 [*] Replace `if` statement with `min` call 193 | | value. 194 | | attr 195 | | ) = 3 - | |_________^ PLR1730 + | |_________^ 196 | 197 | class Foo: | - = help: Replace with `min` call +help: Replace with `min` call ℹ Safe fix 188 188 | value = 2 @@ -468,16 +489,17 @@ if_stmt_min_max.py:191:1: PLR1730 [*] Replace `if` statement with `min` call 197 196 | class Foo: 198 197 | _min = 0 -if_stmt_min_max.py:202:9: PLR1730 [*] Replace `if` statement with `self._min = min(self._min, value)` +PLR1730 [*] Replace `if` statement with `self._min = min(self._min, value)` + --> if_stmt_min_max.py:202:9 | 201 | def foo(self, value) -> None: 202 | / if value < self._min: 203 | | self._min = value - | |_____________________________^ PLR1730 + | |_____________________________^ 204 | if value > self._max: 205 | self._max = value | - = help: Replace with `self._min = min(self._min, value)` +help: Replace with `self._min = min(self._min, value)` ℹ Safe fix 199 199 | _max = 0 @@ -490,17 +512,18 @@ if_stmt_min_max.py:202:9: PLR1730 [*] Replace `if` statement with `self._min = m 205 204 | self._max = value 206 205 | -if_stmt_min_max.py:204:9: PLR1730 [*] Replace `if` statement with `self._max = max(self._max, value)` +PLR1730 [*] Replace `if` statement with `self._max = max(self._max, value)` + --> if_stmt_min_max.py:204:9 | 202 | if value < self._min: 203 | self._min = value 204 | / if value > self._max: 205 | | self._max = value - | |_____________________________^ PLR1730 + | |_____________________________^ 206 | 207 | if self._min < value: | - = help: Replace with `self._max = max(self._max, value)` +help: Replace with `self._max = max(self._max, value)` ℹ Safe fix 201 201 | def foo(self, value) -> None: @@ -513,17 +536,18 @@ if_stmt_min_max.py:204:9: PLR1730 [*] Replace `if` statement with `self._max = m 207 206 | if self._min < value: 208 207 | self._min = value -if_stmt_min_max.py:207:9: PLR1730 [*] Replace `if` statement with `self._min = max(self._min, value)` +PLR1730 [*] Replace `if` statement with `self._min = max(self._min, value)` + --> if_stmt_min_max.py:207:9 | 205 | self._max = value 206 | 207 | / if self._min < value: 208 | | self._min = value - | |_____________________________^ PLR1730 + | |_____________________________^ 209 | if self._max > value: 210 | self._max = value | - = help: Replace with `self._min = max(self._min, value)` +help: Replace with `self._min = max(self._min, value)` ℹ Safe fix 204 204 | if value > self._max: @@ -536,17 +560,18 @@ if_stmt_min_max.py:207:9: PLR1730 [*] Replace `if` statement with `self._min = m 210 209 | self._max = value 211 210 | -if_stmt_min_max.py:209:9: PLR1730 [*] Replace `if` statement with `self._max = min(self._max, value)` +PLR1730 [*] Replace `if` statement with `self._max = min(self._max, value)` + --> if_stmt_min_max.py:209:9 | 207 | if self._min < value: 208 | self._min = value 209 | / if self._max > value: 210 | | self._max = value - | |_____________________________^ PLR1730 + | |_____________________________^ 211 | 212 | if value <= self._min: | - = help: Replace with `self._max = min(self._max, value)` +help: Replace with `self._max = min(self._max, value)` ℹ Safe fix 206 206 | @@ -559,17 +584,18 @@ if_stmt_min_max.py:209:9: PLR1730 [*] Replace `if` statement with `self._max = m 212 211 | if value <= self._min: 213 212 | self._min = value -if_stmt_min_max.py:212:9: PLR1730 [*] Replace `if` statement with `self._min = min(value, self._min)` +PLR1730 [*] Replace `if` statement with `self._min = min(value, self._min)` + --> if_stmt_min_max.py:212:9 | 210 | self._max = value 211 | 212 | / if value <= self._min: 213 | | self._min = value - | |_____________________________^ PLR1730 + | |_____________________________^ 214 | if value >= self._max: 215 | self._max = value | - = help: Replace with `self._min = min(value, self._min)` +help: Replace with `self._min = min(value, self._min)` ℹ Safe fix 209 209 | if self._max > value: @@ -582,17 +608,18 @@ if_stmt_min_max.py:212:9: PLR1730 [*] Replace `if` statement with `self._min = m 215 214 | self._max = value 216 215 | -if_stmt_min_max.py:214:9: PLR1730 [*] Replace `if` statement with `self._max = max(value, self._max)` +PLR1730 [*] Replace `if` statement with `self._max = max(value, self._max)` + --> if_stmt_min_max.py:214:9 | 212 | if value <= self._min: 213 | self._min = value 214 | / if value >= self._max: 215 | | self._max = value - | |_____________________________^ PLR1730 + | |_____________________________^ 216 | 217 | if self._min <= value: | - = help: Replace with `self._max = max(value, self._max)` +help: Replace with `self._max = max(value, self._max)` ℹ Safe fix 211 211 | @@ -605,17 +632,18 @@ if_stmt_min_max.py:214:9: PLR1730 [*] Replace `if` statement with `self._max = m 217 216 | if self._min <= value: 218 217 | self._min = value -if_stmt_min_max.py:217:9: PLR1730 [*] Replace `if` statement with `self._min = max(value, self._min)` +PLR1730 [*] Replace `if` statement with `self._min = max(value, self._min)` + --> if_stmt_min_max.py:217:9 | 215 | self._max = value 216 | 217 | / if self._min <= value: 218 | | self._min = value - | |_____________________________^ PLR1730 + | |_____________________________^ 219 | if self._max >= value: 220 | self._max = value | - = help: Replace with `self._min = max(value, self._min)` +help: Replace with `self._min = max(value, self._min)` ℹ Safe fix 214 214 | if value >= self._max: @@ -628,15 +656,16 @@ if_stmt_min_max.py:217:9: PLR1730 [*] Replace `if` statement with `self._min = m 220 219 | self._max = value 221 220 | -if_stmt_min_max.py:219:9: PLR1730 [*] Replace `if` statement with `self._max = min(value, self._max)` +PLR1730 [*] Replace `if` statement with `self._max = min(value, self._max)` + --> if_stmt_min_max.py:219:9 | 217 | if self._min <= value: 218 | self._min = value 219 | / if self._max >= value: 220 | | self._max = value - | |_____________________________^ PLR1730 + | |_____________________________^ | - = help: Replace with `self._max = min(value, self._max)` +help: Replace with `self._max = min(value, self._max)` ℹ Safe fix 216 216 | @@ -649,16 +678,17 @@ if_stmt_min_max.py:219:9: PLR1730 [*] Replace `if` statement with `self._max = m 222 221 | 223 222 | counter = {"a": 0, "b": 0} -if_stmt_min_max.py:226:1: PLR1730 [*] Replace `if` statement with `counter["a"] = max(counter["b"], counter["a"])` +PLR1730 [*] Replace `if` statement with `counter["a"] = max(counter["b"], counter["a"])` + --> if_stmt_min_max.py:226:1 | 225 | # base case 2: counter["a"] = max(counter["b"], counter["a"]) 226 | / if counter["a"] <= counter["b"]: 227 | | counter["a"] = counter["b"] - | |_______________________________^ PLR1730 + | |_______________________________^ 228 | 229 | # case 3: counter["b"] = min(counter["a"], counter["b"]) | - = help: Replace with `counter["a"] = max(counter["b"], counter["a"])` +help: Replace with `counter["a"] = max(counter["b"], counter["a"])` ℹ Safe fix 223 223 | counter = {"a": 0, "b": 0} @@ -671,16 +701,17 @@ if_stmt_min_max.py:226:1: PLR1730 [*] Replace `if` statement with `counter["a"] 229 228 | # case 3: counter["b"] = min(counter["a"], counter["b"]) 230 229 | if counter["a"] <= counter["b"]: -if_stmt_min_max.py:230:1: PLR1730 [*] Replace `if` statement with `counter["b"] = min(counter["a"], counter["b"])` +PLR1730 [*] Replace `if` statement with `counter["b"] = min(counter["a"], counter["b"])` + --> if_stmt_min_max.py:230:1 | 229 | # case 3: counter["b"] = min(counter["a"], counter["b"]) 230 | / if counter["a"] <= counter["b"]: 231 | | counter["b"] = counter["a"] - | |_______________________________^ PLR1730 + | |_______________________________^ 232 | 233 | # case 5: counter["a"] = min(counter["a"], counter["b"]) | - = help: Replace with `counter["b"] = min(counter["a"], counter["b"])` +help: Replace with `counter["b"] = min(counter["a"], counter["b"])` ℹ Safe fix 227 227 | counter["a"] = counter["b"] @@ -693,16 +724,17 @@ if_stmt_min_max.py:230:1: PLR1730 [*] Replace `if` statement with `counter["b"] 233 232 | # case 5: counter["a"] = min(counter["a"], counter["b"]) 234 233 | if counter["a"] > counter["b"]: -if_stmt_min_max.py:234:1: PLR1730 [*] Replace `if` statement with `counter["b"] = max(counter["b"], counter["a"])` +PLR1730 [*] Replace `if` statement with `counter["b"] = max(counter["b"], counter["a"])` + --> if_stmt_min_max.py:234:1 | 233 | # case 5: counter["a"] = min(counter["a"], counter["b"]) 234 | / if counter["a"] > counter["b"]: 235 | | counter["b"] = counter["a"] - | |_______________________________^ PLR1730 + | |_______________________________^ 236 | 237 | # case 8: counter["a"] = max(counter["b"], counter["a"]) | - = help: Replace with `counter["b"] = max(counter["b"], counter["a"])` +help: Replace with `counter["b"] = max(counter["b"], counter["a"])` ℹ Safe fix 231 231 | counter["b"] = counter["a"] @@ -715,16 +747,17 @@ if_stmt_min_max.py:234:1: PLR1730 [*] Replace `if` statement with `counter["b"] 237 236 | # case 8: counter["a"] = max(counter["b"], counter["a"]) 238 237 | if counter["a"] > counter["b"]: -if_stmt_min_max.py:238:1: PLR1730 [*] Replace `if` statement with `counter["b"] = max(counter["b"], counter["a"])` +PLR1730 [*] Replace `if` statement with `counter["b"] = max(counter["b"], counter["a"])` + --> if_stmt_min_max.py:238:1 | 237 | # case 8: counter["a"] = max(counter["b"], counter["a"]) 238 | / if counter["a"] > counter["b"]: 239 | | counter["b"] = counter["a"] - | |_______________________________^ PLR1730 + | |_______________________________^ 240 | 241 | # https://github.com/astral-sh/ruff/issues/17311 | - = help: Replace with `counter["b"] = max(counter["b"], counter["a"])` +help: Replace with `counter["b"] = max(counter["b"], counter["a"])` ℹ Safe fix 235 235 | counter["b"] = counter["a"] @@ -737,18 +770,19 @@ if_stmt_min_max.py:238:1: PLR1730 [*] Replace `if` statement with `counter["b"] 241 240 | # https://github.com/astral-sh/ruff/issues/17311 242 241 | -if_stmt_min_max.py:245:1: PLR1730 [*] Replace `if` statement with `a = min(b, a)` +PLR1730 [*] Replace `if` statement with `a = min(b, a)` + --> if_stmt_min_max.py:245:1 | 243 | # fix marked unsafe as delete comments 244 | a, b = [], [] 245 | / if a >= b: 246 | | # very important comment 247 | | a = b - | |_________^ PLR1730 + | |_________^ 248 | 249 | # fix marked safe as preserve comments | - = help: Replace with `a = min(b, a)` +help: Replace with `a = min(b, a)` ℹ Unsafe fix 242 242 | @@ -762,14 +796,15 @@ if_stmt_min_max.py:245:1: PLR1730 [*] Replace `if` statement with `a = min(b, a) 249 247 | # fix marked safe as preserve comments 250 248 | if a >= b: -if_stmt_min_max.py:250:1: PLR1730 [*] Replace `if` statement with `a = min(b, a)` +PLR1730 [*] Replace `if` statement with `a = min(b, a)` + --> if_stmt_min_max.py:250:1 | 249 | # fix marked safe as preserve comments 250 | / if a >= b: 251 | | a = b # very important comment - | |_________^ PLR1730 + | |_________^ | - = help: Replace with `a = min(b, a)` +help: Replace with `a = min(b, a)` ℹ Safe fix 247 247 | a = b diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap index 44822f1e92..8445685d8b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1733_unnecessary_dict_index_lookup.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -unnecessary_dict_index_lookup.py:4:6: PLR1733 [*] Unnecessary lookup of dictionary value by key +PLR1733 [*] Unnecessary lookup of dictionary value by key + --> unnecessary_dict_index_lookup.py:4:6 | 3 | def fix_these(): 4 | [FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()] # PLR1733 - | ^^^^^^^^^^^^^^^^^^ PLR1733 + | ^^^^^^^^^^^^^^^^^^ 5 | {FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 6 | {fruit_name: FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 | - = help: Use existing variable +help: Use existing variable ℹ Safe fix 1 1 | FRUITS = {"apple": 1, "orange": 10, "berry": 22} @@ -21,15 +22,16 @@ unnecessary_dict_index_lookup.py:4:6: PLR1733 [*] Unnecessary lookup of dictiona 6 6 | {fruit_name: FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 7 7 | -unnecessary_dict_index_lookup.py:5:6: PLR1733 [*] Unnecessary lookup of dictionary value by key +PLR1733 [*] Unnecessary lookup of dictionary value by key + --> unnecessary_dict_index_lookup.py:5:6 | 3 | def fix_these(): 4 | [FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()] # PLR1733 5 | {FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 - | ^^^^^^^^^^^^^^^^^^ PLR1733 + | ^^^^^^^^^^^^^^^^^^ 6 | {fruit_name: FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 | - = help: Use existing variable +help: Use existing variable ℹ Safe fix 2 2 | @@ -41,16 +43,17 @@ unnecessary_dict_index_lookup.py:5:6: PLR1733 [*] Unnecessary lookup of dictiona 7 7 | 8 8 | for fruit_name, fruit_count in FRUITS.items(): -unnecessary_dict_index_lookup.py:6:18: PLR1733 [*] Unnecessary lookup of dictionary value by key +PLR1733 [*] Unnecessary lookup of dictionary value by key + --> unnecessary_dict_index_lookup.py:6:18 | 4 | [FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()] # PLR1733 5 | {FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 6 | {fruit_name: FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 - | ^^^^^^^^^^^^^^^^^^ PLR1733 + | ^^^^^^^^^^^^^^^^^^ 7 | 8 | for fruit_name, fruit_count in FRUITS.items(): | - = help: Use existing variable +help: Use existing variable ℹ Safe fix 3 3 | def fix_these(): @@ -62,15 +65,16 @@ unnecessary_dict_index_lookup.py:6:18: PLR1733 [*] Unnecessary lookup of diction 8 8 | for fruit_name, fruit_count in FRUITS.items(): 9 9 | print(FRUITS[fruit_name]) # PLR1733 -unnecessary_dict_index_lookup.py:9:15: PLR1733 [*] Unnecessary lookup of dictionary value by key +PLR1733 [*] Unnecessary lookup of dictionary value by key + --> unnecessary_dict_index_lookup.py:9:15 | 8 | for fruit_name, fruit_count in FRUITS.items(): 9 | print(FRUITS[fruit_name]) # PLR1733 - | ^^^^^^^^^^^^^^^^^^ PLR1733 + | ^^^^^^^^^^^^^^^^^^ 10 | blah = FRUITS[fruit_name] # PLR1733 11 | assert FRUITS[fruit_name] == "pear" # PLR1733 | - = help: Use existing variable +help: Use existing variable ℹ Safe fix 6 6 | {fruit_name: FRUITS[fruit_name] for fruit_name, fruit_count in FRUITS.items()} # PLR1733 @@ -82,15 +86,16 @@ unnecessary_dict_index_lookup.py:9:15: PLR1733 [*] Unnecessary lookup of diction 11 11 | assert FRUITS[fruit_name] == "pear" # PLR1733 12 12 | -unnecessary_dict_index_lookup.py:10:16: PLR1733 [*] Unnecessary lookup of dictionary value by key +PLR1733 [*] Unnecessary lookup of dictionary value by key + --> unnecessary_dict_index_lookup.py:10:16 | 8 | for fruit_name, fruit_count in FRUITS.items(): 9 | print(FRUITS[fruit_name]) # PLR1733 10 | blah = FRUITS[fruit_name] # PLR1733 - | ^^^^^^^^^^^^^^^^^^ PLR1733 + | ^^^^^^^^^^^^^^^^^^ 11 | assert FRUITS[fruit_name] == "pear" # PLR1733 | - = help: Use existing variable +help: Use existing variable ℹ Safe fix 7 7 | @@ -102,14 +107,15 @@ unnecessary_dict_index_lookup.py:10:16: PLR1733 [*] Unnecessary lookup of dictio 12 12 | 13 13 | -unnecessary_dict_index_lookup.py:11:16: PLR1733 [*] Unnecessary lookup of dictionary value by key +PLR1733 [*] Unnecessary lookup of dictionary value by key + --> unnecessary_dict_index_lookup.py:11:16 | 9 | print(FRUITS[fruit_name]) # PLR1733 10 | blah = FRUITS[fruit_name] # PLR1733 11 | assert FRUITS[fruit_name] == "pear" # PLR1733 - | ^^^^^^^^^^^^^^^^^^ PLR1733 + | ^^^^^^^^^^^^^^^^^^ | - = help: Use existing variable +help: Use existing variable ℹ Safe fix 8 8 | for fruit_name, fruit_count in FRUITS.items(): @@ -121,16 +127,17 @@ unnecessary_dict_index_lookup.py:11:16: PLR1733 [*] Unnecessary lookup of dictio 13 13 | 14 14 | def dont_fix_these(): -unnecessary_dict_index_lookup.py:50:51: PLR1733 [*] Unnecessary lookup of dictionary value by key +PLR1733 [*] Unnecessary lookup of dictionary value by key + --> unnecessary_dict_index_lookup.py:50:51 | 48 | if mapped_label in mapped_arrays: 49 | for i in range(len(array)): 50 | mapped_arrays[mapped_label][i] += value_arrays[label][i] # PLR1733 - | ^^^^^^^^^^^^^^^^^^^ PLR1733 + | ^^^^^^^^^^^^^^^^^^^ 51 | else: 52 | mapped_arrays[mapped_label] = [value_arrays[label][i] for i in range(len(array))] # PLR1733 | - = help: Use existing variable +help: Use existing variable ℹ Safe fix 47 47 | mapped_label = client_label_map(label) @@ -142,15 +149,16 @@ unnecessary_dict_index_lookup.py:50:51: PLR1733 [*] Unnecessary lookup of dictio 52 52 | mapped_arrays[mapped_label] = [value_arrays[label][i] for i in range(len(array))] # PLR1733 53 53 | return mapped_arrays -unnecessary_dict_index_lookup.py:52:44: PLR1733 [*] Unnecessary lookup of dictionary value by key +PLR1733 [*] Unnecessary lookup of dictionary value by key + --> unnecessary_dict_index_lookup.py:52:44 | 50 | mapped_arrays[mapped_label][i] += value_arrays[label][i] # PLR1733 51 | else: 52 | mapped_arrays[mapped_label] = [value_arrays[label][i] for i in range(len(array))] # PLR1733 - | ^^^^^^^^^^^^^^^^^^^ PLR1733 + | ^^^^^^^^^^^^^^^^^^^ 53 | return mapped_arrays | - = help: Use existing variable +help: Use existing variable ℹ Safe fix 49 49 | for i in range(len(array)): diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap index af6f0edc26..037f20311c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -unnecessary_list_index_lookup.py:7:6: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:7:6 | 6 | def fix_these(): 7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ 8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 4 4 | @@ -21,15 +22,16 @@ unnecessary_list_index_lookup.py:7:6: PLR1736 [*] List index lookup in `enumerat 9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 10 10 | -unnecessary_list_index_lookup.py:8:6: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:8:6 | 6 | def fix_these(): 7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 5 5 | @@ -41,16 +43,17 @@ unnecessary_list_index_lookup.py:8:6: PLR1736 [*] List index lookup in `enumerat 10 10 | 11 11 | for index, letter in enumerate(letters): -unnecessary_list_index_lookup.py:9:14: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:9:14 | 7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ 10 | 11 | for index, letter in enumerate(letters): | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 6 6 | def fix_these(): @@ -62,15 +65,16 @@ unnecessary_list_index_lookup.py:9:14: PLR1736 [*] List index lookup in `enumera 11 11 | for index, letter in enumerate(letters): 12 12 | print(letters[index]) # PLR1736 -unnecessary_list_index_lookup.py:12:15: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:12:15 | 11 | for index, letter in enumerate(letters): 12 | print(letters[index]) # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ 13 | blah = letters[index] # PLR1736 14 | assert letters[index] == "d" # PLR1736 | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 @@ -82,15 +86,16 @@ unnecessary_list_index_lookup.py:12:15: PLR1736 [*] List index lookup in `enumer 14 14 | assert letters[index] == "d" # PLR1736 15 15 | -unnecessary_list_index_lookup.py:13:16: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:13:16 | 11 | for index, letter in enumerate(letters): 12 | print(letters[index]) # PLR1736 13 | blah = letters[index] # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ 14 | assert letters[index] == "d" # PLR1736 | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 10 10 | @@ -102,16 +107,17 @@ unnecessary_list_index_lookup.py:13:16: PLR1736 [*] List index lookup in `enumer 15 15 | 16 16 | for index, letter in builtins.enumerate(letters): -unnecessary_list_index_lookup.py:14:16: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:14:16 | 12 | print(letters[index]) # PLR1736 13 | blah = letters[index] # PLR1736 14 | assert letters[index] == "d" # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ 15 | 16 | for index, letter in builtins.enumerate(letters): | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 11 11 | for index, letter in enumerate(letters): @@ -123,15 +129,16 @@ unnecessary_list_index_lookup.py:14:16: PLR1736 [*] List index lookup in `enumer 16 16 | for index, letter in builtins.enumerate(letters): 17 17 | print(letters[index]) # PLR1736 -unnecessary_list_index_lookup.py:17:15: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:17:15 | 16 | for index, letter in builtins.enumerate(letters): 17 | print(letters[index]) # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ 18 | blah = letters[index] # PLR1736 19 | assert letters[index] == "d" # PLR1736 | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 14 14 | assert letters[index] == "d" # PLR1736 @@ -143,15 +150,16 @@ unnecessary_list_index_lookup.py:17:15: PLR1736 [*] List index lookup in `enumer 19 19 | assert letters[index] == "d" # PLR1736 20 20 | -unnecessary_list_index_lookup.py:18:16: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:18:16 | 16 | for index, letter in builtins.enumerate(letters): 17 | print(letters[index]) # PLR1736 18 | blah = letters[index] # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ 19 | assert letters[index] == "d" # PLR1736 | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 15 15 | @@ -163,14 +171,15 @@ unnecessary_list_index_lookup.py:18:16: PLR1736 [*] List index lookup in `enumer 20 20 | 21 21 | -unnecessary_list_index_lookup.py:19:16: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:19:16 | 17 | print(letters[index]) # PLR1736 18 | blah = letters[index] # PLR1736 19 | assert letters[index] == "d" # PLR1736 - | ^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^ | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 16 16 | for index, letter in builtins.enumerate(letters): @@ -182,16 +191,17 @@ unnecessary_list_index_lookup.py:19:16: PLR1736 [*] List index lookup in `enumer 21 21 | 22 22 | def dont_fix_these(): -unnecessary_list_index_lookup.py:74:15: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:74:15 | 72 | # PLR1736 73 | for index, list_item in enumerate(some_list, start=0): 74 | print(some_list[index]) - | ^^^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^^^ 75 | 76 | # PLR1736 | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 71 71 | @@ -203,14 +213,15 @@ unnecessary_list_index_lookup.py:74:15: PLR1736 [*] List index lookup in `enumer 76 76 | # PLR1736 77 77 | for index, list_item in enumerate(some_list): -unnecessary_list_index_lookup.py:78:15: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:78:15 | 76 | # PLR1736 77 | for index, list_item in enumerate(some_list): 78 | print(some_list[index]) - | ^^^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^^^ | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 75 75 | @@ -222,14 +233,15 @@ unnecessary_list_index_lookup.py:78:15: PLR1736 [*] List index lookup in `enumer 80 80 | 81 81 | def nested_index_lookup(): -unnecessary_list_index_lookup.py:85:18: PLR1736 [*] List index lookup in `enumerate()` loop +PLR1736 [*] List index lookup in `enumerate()` loop + --> unnecessary_list_index_lookup.py:85:18 | 83 | column_names = ["a", "b"] 84 | for index, column_name in enumerate(column_names): 85 | _ = data[column_names[index]] # PLR1736 - | ^^^^^^^^^^^^^^^^^^^ PLR1736 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Use the loop variable directly +help: Use the loop variable directly ℹ Safe fix 82 82 | data = {"a": 1, "b": 2} diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap index d5b501687f..ca866de719 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap @@ -1,74 +1,82 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -magic_value_comparison.py:5:4: PLR2004 Magic value used in comparison, consider replacing `10` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `10` with a constant variable + --> magic_value_comparison.py:5:4 | 3 | user_input = 10 4 | 5 | if 10 > user_input: # [magic-value-comparison] - | ^^ PLR2004 + | ^^ 6 | pass | -magic_value_comparison.py:47:12: PLR2004 Magic value used in comparison, consider replacing `2` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `2` with a constant variable + --> magic_value_comparison.py:47:12 | 45 | pass 46 | 47 | if argc != 2: # [magic-value-comparison] - | ^ PLR2004 + | ^ 48 | pass | -magic_value_comparison.py:50:12: PLR2004 Magic value used in comparison, consider replacing `-2` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `-2` with a constant variable + --> magic_value_comparison.py:50:12 | 48 | pass 49 | 50 | if argc != -2: # [magic-value-comparison] - | ^^ PLR2004 + | ^^ 51 | pass | -magic_value_comparison.py:53:12: PLR2004 Magic value used in comparison, consider replacing `+2` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `+2` with a constant variable + --> magic_value_comparison.py:53:12 | 51 | pass 52 | 53 | if argc != +2: # [magic-value-comparison] - | ^^ PLR2004 + | ^^ 54 | pass | -magic_value_comparison.py:56:12: PLR2004 Magic value used in comparison, consider replacing `-2.0` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `-2.0` with a constant variable + --> magic_value_comparison.py:56:12 | 54 | pass 55 | 56 | if argc != -2.0: # [magic-value-comparison] - | ^^^^ PLR2004 + | ^^^^ 57 | pass | -magic_value_comparison.py:59:12: PLR2004 Magic value used in comparison, consider replacing `+2.0` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `+2.0` with a constant variable + --> magic_value_comparison.py:59:12 | 57 | pass 58 | 59 | if argc != +2.0: # [magic-value-comparison] - | ^^^^ PLR2004 + | ^^^^ 60 | pass | -magic_value_comparison.py:80:21: PLR2004 Magic value used in comparison, consider replacing `3.141592653589793238` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `3.141592653589793238` with a constant variable + --> magic_value_comparison.py:80:21 | 78 | pi_estimation = 3.14 79 | 80 | if pi_estimation == 3.141592653589793238: # [magic-value-comparison] - | ^^^^^^^^^^^^^^^^^^^^ PLR2004 + | ^^^^^^^^^^^^^^^^^^^^ 81 | pass | -magic_value_comparison.py:86:21: PLR2004 Magic value used in comparison, consider replacing `0x3` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `0x3` with a constant variable + --> magic_value_comparison.py:86:21 | 84 | pass 85 | 86 | if pi_estimation == 0x3: # [magic-value-comparison] - | ^^^ PLR2004 + | ^^^ 87 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap index 5b1a959bda..34f07f7c76 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -empty_comment.py:3:1: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment.py:3:1 | 1 | # this line has a non-empty comment and is OK 2 | # this line is also OK, but the three following lines are not 3 | # - | ^ PLR2044 + | ^ 4 | # 5 | # | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 1 1 | # this line has a non-empty comment and is OK @@ -20,15 +21,16 @@ empty_comment.py:3:1: PLR2044 [*] Line with empty comment 5 4 | # 6 5 | -empty_comment.py:4:5: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment.py:4:5 | 2 | # this line is also OK, but the three following lines are not 3 | # 4 | # - | ^ PLR2044 + | ^ 5 | # | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 1 1 | # this line has a non-empty comment and is OK @@ -39,16 +41,17 @@ empty_comment.py:4:5: PLR2044 [*] Line with empty comment 6 5 | 7 6 | # this non-empty comment has trailing whitespace and is OK -empty_comment.py:5:9: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment.py:5:9 | 3 | # 4 | # 5 | # - | ^ PLR2044 + | ^ 6 | 7 | # this non-empty comment has trailing whitespace and is OK | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 2 2 | # this line is also OK, but the three following lines are not @@ -59,13 +62,14 @@ empty_comment.py:5:9: PLR2044 [*] Line with empty comment 7 6 | # this non-empty comment has trailing whitespace and is OK 8 7 | -empty_comment.py:18:11: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment.py:18:11 | 17 | def foo(): # this comment is OK, the one below is not 18 | pass # - | ^ PLR2044 + | ^ | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 15 15 | @@ -77,15 +81,16 @@ empty_comment.py:18:11: PLR2044 [*] Line with empty comment 20 20 | 21 21 | # the lines below have no comments and are OK -empty_comment.py:44:1: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment.py:44:1 | 42 | # These should be removed, despite being an empty "block comment". 43 | 44 | # - | ^ PLR2044 + | ^ 45 | # | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 42 42 | # These should be removed, despite being an empty "block comment". @@ -96,15 +101,16 @@ empty_comment.py:44:1: PLR2044 [*] Line with empty comment 47 46 | # These should also be removed. 48 47 | -empty_comment.py:45:1: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment.py:45:1 | 44 | # 45 | # - | ^ PLR2044 + | ^ 46 | 47 | # These should also be removed. | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 42 42 | # These should be removed, despite being an empty "block comment". @@ -115,13 +121,14 @@ empty_comment.py:45:1: PLR2044 [*] Line with empty comment 47 46 | # These should also be removed. 48 47 | -empty_comment.py:58:2: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment.py:58:2 | 57 | α = 1 58 | α# - | ^ PLR2044 + | ^ | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 55 55 | # This should be removed. diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment_line_continuation.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment_line_continuation.py.snap index 2a11daba77..bd171d35a0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment_line_continuation.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2044_empty_comment_line_continuation.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -empty_comment_line_continuation.py:1:1: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment_line_continuation.py:1:1 | 1 | # - | ^ PLR2044 + | ^ 2 | x = 0 \ 3 | # | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 1 |-# @@ -16,16 +17,17 @@ empty_comment_line_continuation.py:1:1: PLR2044 [*] Line with empty comment 3 2 | # 4 3 | +1 -empty_comment_line_continuation.py:3:1: PLR2044 [*] Line with empty comment +PLR2044 [*] Line with empty comment + --> empty_comment_line_continuation.py:3:1 | 1 | # 2 | x = 0 \ 3 | # - | ^ PLR2044 + | ^ 4 | +1 5 | print(x) | - = help: Delete the empty comment +help: Delete the empty comment ℹ Safe fix 1 1 | # diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap index 44b4747fc2..e85ad02790 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -collapsible_else_if.py:37:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:37:5 | 35 | if 1: 36 | pass 37 | / else: 38 | | if 2: - | |________^ PLR5501 + | |________^ 39 | pass | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 34 34 | def not_ok0(): @@ -25,17 +26,18 @@ collapsible_else_if.py:37:5: PLR5501 [*] Use `elif` instead of `else` then `if`, 41 40 | 42 41 | def not_ok1(): -collapsible_else_if.py:45:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:45:5 | 43 | if 1: 44 | pass 45 | / else: 46 | | if 2: - | |________^ PLR5501 + | |________^ 47 | pass 48 | else: | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 42 42 | def not_ok1(): @@ -53,18 +55,19 @@ collapsible_else_if.py:45:5: PLR5501 [*] Use `elif` instead of `else` then `if`, 51 50 | 52 51 | def not_ok1_with_comments(): -collapsible_else_if.py:55:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:55:5 | 53 | if 1: 54 | pass 55 | / else: 56 | | # inner comment 57 | | if 2: - | |________^ PLR5501 + | |________^ 58 | pass 59 | else: | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 52 52 | def not_ok1_with_comments(): @@ -84,17 +87,18 @@ collapsible_else_if.py:55:5: PLR5501 [*] Use `elif` instead of `else` then `if`, 62 61 | 63 62 | # Regression test for https://github.com/apache/airflow/blob/f1e1cdcc3b2826e68ba133f350300b5065bbca33/airflow/models/dag.py#L1737 -collapsible_else_if.py:69:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:69:5 | 67 | elif True: 68 | print(2) 69 | / else: 70 | | if True: - | |________^ PLR5501 + | |________^ 71 | print(3) 72 | else: | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 66 66 | print(1) @@ -112,16 +116,17 @@ collapsible_else_if.py:69:5: PLR5501 [*] Use `elif` instead of `else` then `if`, 75 74 | 76 75 | def not_ok3(): -collapsible_else_if.py:79:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:79:5 | 77 | if 1: 78 | pass 79 | / else: 80 | | if 2: pass - | |________^ PLR5501 + | |________^ 81 | else: pass | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 76 76 | def not_ok3(): @@ -136,17 +141,18 @@ collapsible_else_if.py:79:5: PLR5501 [*] Use `elif` instead of `else` then `if`, 83 82 | 84 83 | def not_ok4(): -collapsible_else_if.py:87:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:87:5 | 85 | if 1: 86 | pass 87 | / else: 88 | | if 2: pass - | |________^ PLR5501 + | |________^ 89 | else: 90 | pass | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 84 84 | def not_ok4(): @@ -162,17 +168,18 @@ collapsible_else_if.py:87:5: PLR5501 [*] Use `elif` instead of `else` then `if`, 92 91 | 93 92 | def not_ok5(): -collapsible_else_if.py:96:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:96:5 | 94 | if 1: 95 | pass 96 | / else: 97 | | if 2: - | |________^ PLR5501 + | |________^ 98 | pass 99 | else: pass | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 93 93 | def not_ok5(): @@ -189,7 +196,8 @@ collapsible_else_if.py:96:5: PLR5501 [*] Use `elif` instead of `else` then `if`, 101 100 | 102 101 | def not_ok1_with_multiline_comments(): -collapsible_else_if.py:105:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:105:5 | 103 | if 1: 104 | pass @@ -197,11 +205,11 @@ collapsible_else_if.py:105:5: PLR5501 [*] Use `elif` instead of `else` then `if` 106 | | # inner comment which happens 107 | | # to be longer than one line 108 | | if 2: - | |________^ PLR5501 + | |________^ 109 | pass 110 | else: | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 102 102 | def not_ok1_with_multiline_comments(): @@ -223,18 +231,19 @@ collapsible_else_if.py:105:5: PLR5501 [*] Use `elif` instead of `else` then `if` 113 112 | 114 113 | def not_ok1_with_deep_indented_comments(): -collapsible_else_if.py:117:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:117:5 | 115 | if 1: 116 | pass 117 | / else: 118 | | # inner comment which happens to be overly indented 119 | | if 2: - | |________^ PLR5501 + | |________^ 120 | pass 121 | else: | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 114 114 | def not_ok1_with_deep_indented_comments(): @@ -254,18 +263,19 @@ collapsible_else_if.py:117:5: PLR5501 [*] Use `elif` instead of `else` then `if` 124 123 | 125 124 | def not_ok1_with_shallow_indented_comments(): -collapsible_else_if.py:128:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:128:5 | 126 | if 1: 127 | pass 128 | / else: 129 | | # inner comment which happens to be under indented 130 | | if 2: - | |________^ PLR5501 + | |________^ 131 | pass 132 | else: | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 125 125 | def not_ok1_with_shallow_indented_comments(): @@ -285,7 +295,8 @@ collapsible_else_if.py:128:5: PLR5501 [*] Use `elif` instead of `else` then `if` 135 134 | 136 135 | def not_ok1_with_mixed_indented_comments(): -collapsible_else_if.py:139:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation +PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation + --> collapsible_else_if.py:139:5 | 137 | if 1: 138 | pass @@ -294,11 +305,11 @@ collapsible_else_if.py:139:5: PLR5501 [*] Use `elif` instead of `else` then `if` 141 | | # indentation levels 142 | | # which is pretty weird 143 | | if 2: - | |________^ PLR5501 + | |________^ 144 | pass 145 | else: | - = help: Convert to `elif` +help: Convert to `elif` ℹ Safe fix 136 136 | def not_ok1_with_mixed_indented_comments(): diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap index 9de292825b..c8f98fb600 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6104_non_augmented_assignment.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -non_augmented_assignment.py:16:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:16:1 | 14 | mat1, mat2 = None, None 15 | 16 | some_string = some_string + "a very long end of string" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | index = index - 1 18 | a_list = a_list + ["to concat"] | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 13 13 | some_set = {"elem"} @@ -22,15 +23,16 @@ non_augmented_assignment.py:16:1: PLR6104 [*] Use `+=` to perform an augmented a 18 18 | a_list = a_list + ["to concat"] 19 19 | some_set = some_set | {"to concat"} -non_augmented_assignment.py:17:1: PLR6104 [*] Use `-=` to perform an augmented assignment directly +PLR6104 [*] Use `-=` to perform an augmented assignment directly + --> non_augmented_assignment.py:17:1 | 16 | some_string = some_string + "a very long end of string" 17 | index = index - 1 - | ^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^ 18 | a_list = a_list + ["to concat"] 19 | some_set = some_set | {"to concat"} | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 14 14 | mat1, mat2 = None, None @@ -42,16 +44,17 @@ non_augmented_assignment.py:17:1: PLR6104 [*] Use `-=` to perform an augmented a 19 19 | some_set = some_set | {"to concat"} 20 20 | to_multiply = to_multiply * 5 -non_augmented_assignment.py:18:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:18:1 | 16 | some_string = some_string + "a very long end of string" 17 | index = index - 1 18 | a_list = a_list + ["to concat"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | some_set = some_set | {"to concat"} 20 | to_multiply = to_multiply * 5 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 15 15 | @@ -63,16 +66,17 @@ non_augmented_assignment.py:18:1: PLR6104 [*] Use `+=` to perform an augmented a 20 20 | to_multiply = to_multiply * 5 21 21 | to_multiply = 5 * to_multiply -non_augmented_assignment.py:19:1: PLR6104 [*] Use `|=` to perform an augmented assignment directly +PLR6104 [*] Use `|=` to perform an augmented assignment directly + --> non_augmented_assignment.py:19:1 | 17 | index = index - 1 18 | a_list = a_list + ["to concat"] 19 | some_set = some_set | {"to concat"} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | to_multiply = to_multiply * 5 21 | to_multiply = 5 * to_multiply | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 16 16 | some_string = some_string + "a very long end of string" @@ -84,16 +88,17 @@ non_augmented_assignment.py:19:1: PLR6104 [*] Use `|=` to perform an augmented a 21 21 | to_multiply = 5 * to_multiply 22 22 | to_multiply = to_multiply * to_multiply -non_augmented_assignment.py:20:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly +PLR6104 [*] Use `*=` to perform an augmented assignment directly + --> non_augmented_assignment.py:20:1 | 18 | a_list = a_list + ["to concat"] 19 | some_set = some_set | {"to concat"} 20 | to_multiply = to_multiply * 5 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | to_multiply = 5 * to_multiply 22 | to_multiply = to_multiply * to_multiply | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 17 17 | index = index - 1 @@ -105,16 +110,17 @@ non_augmented_assignment.py:20:1: PLR6104 [*] Use `*=` to perform an augmented a 22 22 | to_multiply = to_multiply * to_multiply 23 23 | to_divide = to_divide / 5 -non_augmented_assignment.py:21:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly +PLR6104 [*] Use `*=` to perform an augmented assignment directly + --> non_augmented_assignment.py:21:1 | 19 | some_set = some_set | {"to concat"} 20 | to_multiply = to_multiply * 5 21 | to_multiply = 5 * to_multiply - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | to_multiply = to_multiply * to_multiply 23 | to_divide = to_divide / 5 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 18 18 | a_list = a_list + ["to concat"] @@ -126,16 +132,17 @@ non_augmented_assignment.py:21:1: PLR6104 [*] Use `*=` to perform an augmented a 23 23 | to_divide = to_divide / 5 24 24 | to_divide = to_divide // 5 -non_augmented_assignment.py:22:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly +PLR6104 [*] Use `*=` to perform an augmented assignment directly + --> non_augmented_assignment.py:22:1 | 20 | to_multiply = to_multiply * 5 21 | to_multiply = 5 * to_multiply 22 | to_multiply = to_multiply * to_multiply - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | to_divide = to_divide / 5 24 | to_divide = to_divide // 5 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 19 19 | some_set = some_set | {"to concat"} @@ -147,16 +154,17 @@ non_augmented_assignment.py:22:1: PLR6104 [*] Use `*=` to perform an augmented a 24 24 | to_divide = to_divide // 5 25 25 | to_cube = to_cube**3 -non_augmented_assignment.py:23:1: PLR6104 [*] Use `/=` to perform an augmented assignment directly +PLR6104 [*] Use `/=` to perform an augmented assignment directly + --> non_augmented_assignment.py:23:1 | 21 | to_multiply = 5 * to_multiply 22 | to_multiply = to_multiply * to_multiply 23 | to_divide = to_divide / 5 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | to_divide = to_divide // 5 25 | to_cube = to_cube**3 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 20 20 | to_multiply = to_multiply * 5 @@ -168,16 +176,17 @@ non_augmented_assignment.py:23:1: PLR6104 [*] Use `/=` to perform an augmented a 25 25 | to_cube = to_cube**3 26 26 | to_cube = 3**to_cube -non_augmented_assignment.py:24:1: PLR6104 [*] Use `//=` to perform an augmented assignment directly +PLR6104 [*] Use `//=` to perform an augmented assignment directly + --> non_augmented_assignment.py:24:1 | 22 | to_multiply = to_multiply * to_multiply 23 | to_divide = to_divide / 5 24 | to_divide = to_divide // 5 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | to_cube = to_cube**3 26 | to_cube = 3**to_cube | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 21 21 | to_multiply = 5 * to_multiply @@ -189,16 +198,17 @@ non_augmented_assignment.py:24:1: PLR6104 [*] Use `//=` to perform an augmented 26 26 | to_cube = 3**to_cube 27 27 | to_cube = to_cube**to_cube -non_augmented_assignment.py:25:1: PLR6104 [*] Use `**=` to perform an augmented assignment directly +PLR6104 [*] Use `**=` to perform an augmented assignment directly + --> non_augmented_assignment.py:25:1 | 23 | to_divide = to_divide / 5 24 | to_divide = to_divide // 5 25 | to_cube = to_cube**3 - | ^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^ 26 | to_cube = 3**to_cube 27 | to_cube = to_cube**to_cube | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 22 22 | to_multiply = to_multiply * to_multiply @@ -210,16 +220,17 @@ non_augmented_assignment.py:25:1: PLR6104 [*] Use `**=` to perform an augmented 27 27 | to_cube = to_cube**to_cube 28 28 | timeDiffSeconds = timeDiffSeconds % 60 -non_augmented_assignment.py:27:1: PLR6104 [*] Use `**=` to perform an augmented assignment directly +PLR6104 [*] Use `**=` to perform an augmented assignment directly + --> non_augmented_assignment.py:27:1 | 25 | to_cube = to_cube**3 26 | to_cube = 3**to_cube 27 | to_cube = to_cube**to_cube - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | timeDiffSeconds = timeDiffSeconds % 60 29 | flags = flags & 0x1 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 24 24 | to_divide = to_divide // 5 @@ -231,16 +242,17 @@ non_augmented_assignment.py:27:1: PLR6104 [*] Use `**=` to perform an augmented 29 29 | flags = flags & 0x1 30 30 | flags = flags | 0x1 -non_augmented_assignment.py:28:1: PLR6104 [*] Use `%=` to perform an augmented assignment directly +PLR6104 [*] Use `%=` to perform an augmented assignment directly + --> non_augmented_assignment.py:28:1 | 26 | to_cube = 3**to_cube 27 | to_cube = to_cube**to_cube 28 | timeDiffSeconds = timeDiffSeconds % 60 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | flags = flags & 0x1 30 | flags = flags | 0x1 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 25 25 | to_cube = to_cube**3 @@ -252,16 +264,17 @@ non_augmented_assignment.py:28:1: PLR6104 [*] Use `%=` to perform an augmented a 30 30 | flags = flags | 0x1 31 31 | flags = flags ^ 0x1 -non_augmented_assignment.py:29:1: PLR6104 [*] Use `&=` to perform an augmented assignment directly +PLR6104 [*] Use `&=` to perform an augmented assignment directly + --> non_augmented_assignment.py:29:1 | 27 | to_cube = to_cube**to_cube 28 | timeDiffSeconds = timeDiffSeconds % 60 29 | flags = flags & 0x1 - | ^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^ 30 | flags = flags | 0x1 31 | flags = flags ^ 0x1 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 26 26 | to_cube = 3**to_cube @@ -273,16 +286,17 @@ non_augmented_assignment.py:29:1: PLR6104 [*] Use `&=` to perform an augmented a 31 31 | flags = flags ^ 0x1 32 32 | flags = flags << 1 -non_augmented_assignment.py:30:1: PLR6104 [*] Use `|=` to perform an augmented assignment directly +PLR6104 [*] Use `|=` to perform an augmented assignment directly + --> non_augmented_assignment.py:30:1 | 28 | timeDiffSeconds = timeDiffSeconds % 60 29 | flags = flags & 0x1 30 | flags = flags | 0x1 - | ^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^ 31 | flags = flags ^ 0x1 32 | flags = flags << 1 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 27 27 | to_cube = to_cube**to_cube @@ -294,16 +308,17 @@ non_augmented_assignment.py:30:1: PLR6104 [*] Use `|=` to perform an augmented a 32 32 | flags = flags << 1 33 33 | flags = flags >> 1 -non_augmented_assignment.py:31:1: PLR6104 [*] Use `^=` to perform an augmented assignment directly +PLR6104 [*] Use `^=` to perform an augmented assignment directly + --> non_augmented_assignment.py:31:1 | 29 | flags = flags & 0x1 30 | flags = flags | 0x1 31 | flags = flags ^ 0x1 - | ^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^ 32 | flags = flags << 1 33 | flags = flags >> 1 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 28 28 | timeDiffSeconds = timeDiffSeconds % 60 @@ -315,16 +330,17 @@ non_augmented_assignment.py:31:1: PLR6104 [*] Use `^=` to perform an augmented a 33 33 | flags = flags >> 1 34 34 | mat1 = mat1 @ mat2 -non_augmented_assignment.py:32:1: PLR6104 [*] Use `<<=` to perform an augmented assignment directly +PLR6104 [*] Use `<<=` to perform an augmented assignment directly + --> non_augmented_assignment.py:32:1 | 30 | flags = flags | 0x1 31 | flags = flags ^ 0x1 32 | flags = flags << 1 - | ^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^ 33 | flags = flags >> 1 34 | mat1 = mat1 @ mat2 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 29 29 | flags = flags & 0x1 @@ -336,16 +352,17 @@ non_augmented_assignment.py:32:1: PLR6104 [*] Use `<<=` to perform an augmented 34 34 | mat1 = mat1 @ mat2 35 35 | a_list[1] = a_list[1] + 1 -non_augmented_assignment.py:33:1: PLR6104 [*] Use `>>=` to perform an augmented assignment directly +PLR6104 [*] Use `>>=` to perform an augmented assignment directly + --> non_augmented_assignment.py:33:1 | 31 | flags = flags ^ 0x1 32 | flags = flags << 1 33 | flags = flags >> 1 - | ^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^ 34 | mat1 = mat1 @ mat2 35 | a_list[1] = a_list[1] + 1 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 30 30 | flags = flags | 0x1 @@ -357,15 +374,16 @@ non_augmented_assignment.py:33:1: PLR6104 [*] Use `>>=` to perform an augmented 35 35 | a_list[1] = a_list[1] + 1 36 36 | -non_augmented_assignment.py:34:1: PLR6104 [*] Use `@=` to perform an augmented assignment directly +PLR6104 [*] Use `@=` to perform an augmented assignment directly + --> non_augmented_assignment.py:34:1 | 32 | flags = flags << 1 33 | flags = flags >> 1 34 | mat1 = mat1 @ mat2 - | ^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^ 35 | a_list[1] = a_list[1] + 1 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 31 31 | flags = flags ^ 0x1 @@ -377,16 +395,17 @@ non_augmented_assignment.py:34:1: PLR6104 [*] Use `@=` to perform an augmented a 36 36 | 37 37 | a_list[0:2] = a_list[0:2] * 3 -non_augmented_assignment.py:35:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:35:1 | 33 | flags = flags >> 1 34 | mat1 = mat1 @ mat2 35 | a_list[1] = a_list[1] + 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | 37 | a_list[0:2] = a_list[0:2] * 3 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 32 32 | flags = flags << 1 @@ -398,16 +417,17 @@ non_augmented_assignment.py:35:1: PLR6104 [*] Use `+=` to perform an augmented a 37 37 | a_list[0:2] = a_list[0:2] * 3 38 38 | a_list[:2] = a_list[:2] * 3 -non_augmented_assignment.py:37:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly +PLR6104 [*] Use `*=` to perform an augmented assignment directly + --> non_augmented_assignment.py:37:1 | 35 | a_list[1] = a_list[1] + 1 36 | 37 | a_list[0:2] = a_list[0:2] * 3 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | a_list[:2] = a_list[:2] * 3 39 | a_list[1:] = a_list[1:] * 3 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 34 34 | mat1 = mat1 @ mat2 @@ -419,15 +439,16 @@ non_augmented_assignment.py:37:1: PLR6104 [*] Use `*=` to perform an augmented a 39 39 | a_list[1:] = a_list[1:] * 3 40 40 | a_list[:] = a_list[:] * 3 -non_augmented_assignment.py:38:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly +PLR6104 [*] Use `*=` to perform an augmented assignment directly + --> non_augmented_assignment.py:38:1 | 37 | a_list[0:2] = a_list[0:2] * 3 38 | a_list[:2] = a_list[:2] * 3 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | a_list[1:] = a_list[1:] * 3 40 | a_list[:] = a_list[:] * 3 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 35 35 | a_list[1] = a_list[1] + 1 @@ -439,15 +460,16 @@ non_augmented_assignment.py:38:1: PLR6104 [*] Use `*=` to perform an augmented a 40 40 | a_list[:] = a_list[:] * 3 41 41 | -non_augmented_assignment.py:39:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly +PLR6104 [*] Use `*=` to perform an augmented assignment directly + --> non_augmented_assignment.py:39:1 | 37 | a_list[0:2] = a_list[0:2] * 3 38 | a_list[:2] = a_list[:2] * 3 39 | a_list[1:] = a_list[1:] * 3 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | a_list[:] = a_list[:] * 3 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 36 36 | @@ -459,16 +481,17 @@ non_augmented_assignment.py:39:1: PLR6104 [*] Use `*=` to perform an augmented a 41 41 | 42 42 | index = index * (index + 10) -non_augmented_assignment.py:40:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly +PLR6104 [*] Use `*=` to perform an augmented assignment directly + --> non_augmented_assignment.py:40:1 | 38 | a_list[:2] = a_list[:2] * 3 39 | a_list[1:] = a_list[1:] * 3 40 | a_list[:] = a_list[:] * 3 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | 42 | index = index * (index + 10) | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 37 37 | a_list[0:2] = a_list[0:2] * 3 @@ -480,14 +503,15 @@ non_augmented_assignment.py:40:1: PLR6104 [*] Use `*=` to perform an augmented a 42 42 | index = index * (index + 10) 43 43 | -non_augmented_assignment.py:42:1: PLR6104 [*] Use `*=` to perform an augmented assignment directly +PLR6104 [*] Use `*=` to perform an augmented assignment directly + --> non_augmented_assignment.py:42:1 | 40 | a_list[:] = a_list[:] * 3 41 | 42 | index = index * (index + 10) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 39 39 | a_list[1:] = a_list[1:] * 3 @@ -499,14 +523,15 @@ non_augmented_assignment.py:42:1: PLR6104 [*] Use `*=` to perform an augmented a 44 44 | 45 45 | class T: -non_augmented_assignment.py:47:9: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:47:9 | 45 | class T: 46 | def t(self): 47 | self.a = self.a + 1 - | ^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 44 44 | @@ -518,13 +543,14 @@ non_augmented_assignment.py:47:9: PLR6104 [*] Use `+=` to perform an augmented a 49 49 | 50 50 | obj = T() -non_augmented_assignment.py:51:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:51:1 | 50 | obj = T() 51 | obj.a = obj.a + 1 - | ^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^ | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 48 48 | @@ -536,14 +562,15 @@ non_augmented_assignment.py:51:1: PLR6104 [*] Use `+=` to perform an augmented a 53 53 | 54 54 | a = a+-1 -non_augmented_assignment.py:54:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:54:1 | 54 | a = a+-1 - | ^^^^^^^^ PLR6104 + | ^^^^^^^^ 55 | 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/11672 | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 51 51 | obj.a = obj.a + 1 @@ -555,16 +582,17 @@ non_augmented_assignment.py:54:1: PLR6104 [*] Use `+=` to perform an augmented a 56 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/11672 57 57 | test = 0x5 -non_augmented_assignment.py:58:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:58:1 | 56 | # Regression tests for https://github.com/astral-sh/ruff/issues/11672 57 | test = 0x5 58 | test = test + 0xBA - | ^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^ 59 | 60 | test2 = b"" | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 55 55 | @@ -576,15 +604,16 @@ non_augmented_assignment.py:58:1: PLR6104 [*] Use `+=` to perform an augmented a 60 60 | test2 = b"" 61 61 | test2 = test2 + b"\000" -non_augmented_assignment.py:61:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:61:1 | 60 | test2 = b"" 61 | test2 = test2 + b"\000" - | ^^^^^^^^^^^^^^^^^^^^^^^ PLR6104 + | ^^^^^^^^^^^^^^^^^^^^^^^ 62 | 63 | test3 = "" | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 58 58 | test = test + 0xBA @@ -596,16 +625,17 @@ non_augmented_assignment.py:61:1: PLR6104 [*] Use `+=` to perform an augmented a 63 63 | test3 = "" 64 64 | test3 = test3 + ( a := R"" -non_augmented_assignment.py:64:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:64:1 | 63 | test3 = "" 64 | / test3 = test3 + ( a := R"" 65 | | f"oo" ) - | |__________________________________^ PLR6104 + | |__________________________________^ 66 | 67 | test4 = [] | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 61 61 | test2 = test2 + b"\000" @@ -617,18 +647,19 @@ non_augmented_assignment.py:64:1: PLR6104 [*] Use `+=` to perform an augmented a 66 66 | 67 67 | test4 = [] -non_augmented_assignment.py:68:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:68:1 | 67 | test4 = [] 68 | / test4 = test4 + ( e 69 | | for e in 70 | | range(10) 71 | | ) - | |___________________^ PLR6104 + | |___________________^ 72 | 73 | test5 = test5 + ( | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 65 65 | f"oo" ) @@ -640,7 +671,8 @@ non_augmented_assignment.py:68:1: PLR6104 [*] Use `+=` to perform an augmented a 70 70 | range(10) 71 71 | ) -non_augmented_assignment.py:73:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:73:1 | 71 | ) 72 | @@ -649,11 +681,11 @@ non_augmented_assignment.py:73:1: PLR6104 [*] Use `+=` to perform an augmented a 75 | | * 76 | | 10 77 | | ) - | |_^ PLR6104 + | |_^ 78 | 79 | test6 = test6 + \ | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 70 70 | range(10) @@ -665,7 +697,8 @@ non_augmented_assignment.py:73:1: PLR6104 [*] Use `+=` to perform an augmented a 75 75 | * 76 76 | 10 -non_augmented_assignment.py:79:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:79:1 | 77 | ) 78 | @@ -675,11 +708,11 @@ non_augmented_assignment.py:79:1: PLR6104 [*] Use `+=` to perform an augmented a 82 | | * 83 | | 10 84 | | ) - | |_________^ PLR6104 + | |_________^ 85 | 86 | test7 = \ | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 76 76 | 10 @@ -692,18 +725,19 @@ non_augmented_assignment.py:79:1: PLR6104 [*] Use `+=` to perform an augmented a 82 81 | * 83 82 | 10 -non_augmented_assignment.py:86:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:86:1 | 84 | ) 85 | 86 | / test7 = \ 87 | | 100 \ 88 | | + test7 - | |___________^ PLR6104 + | |___________^ 89 | 90 | test8 = \ | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 83 83 | 10 @@ -717,7 +751,8 @@ non_augmented_assignment.py:86:1: PLR6104 [*] Use `+=` to perform an augmented a 90 88 | test8 = \ 91 89 | 886 \ -non_augmented_assignment.py:90:1: PLR6104 [*] Use `+=` to perform an augmented assignment directly +PLR6104 [*] Use `+=` to perform an augmented assignment directly + --> non_augmented_assignment.py:90:1 | 88 | + test7 89 | @@ -726,9 +761,9 @@ non_augmented_assignment.py:90:1: PLR6104 [*] Use `+=` to perform an augmented a 92 | | + \ 93 | | \ 94 | | test8 - | |_________^ PLR6104 + | |_________^ | - = help: Replace with augmented assignment +help: Replace with augmented assignment ℹ Unsafe fix 87 87 | 100 \ diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap index 273ce58e09..caf82f42de 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6201_literal_membership.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -literal_membership.py:2:6: PLR6201 [*] Use a set literal when testing for membership +PLR6201 [*] Use a set literal when testing for membership + --> literal_membership.py:2:6 | 1 | # Errors 2 | 1 in [1, 2, 3] - | ^^^^^^^^^ PLR6201 + | ^^^^^^^^^ 3 | 1 in (1, 2, 3) 4 | 1 in ( | - = help: Convert to `set` +help: Convert to `set` ℹ Unsafe fix 1 1 | # Errors @@ -19,16 +20,17 @@ literal_membership.py:2:6: PLR6201 [*] Use a set literal when testing for member 4 4 | 1 in ( 5 5 | 1, 2, 3 -literal_membership.py:3:6: PLR6201 [*] Use a set literal when testing for membership +PLR6201 [*] Use a set literal when testing for membership + --> literal_membership.py:3:6 | 1 | # Errors 2 | 1 in [1, 2, 3] 3 | 1 in (1, 2, 3) - | ^^^^^^^^^ PLR6201 + | ^^^^^^^^^ 4 | 1 in ( 5 | 1, 2, 3 | - = help: Convert to `set` +help: Convert to `set` ℹ Unsafe fix 1 1 | # Errors @@ -39,7 +41,8 @@ literal_membership.py:3:6: PLR6201 [*] Use a set literal when testing for member 5 5 | 1, 2, 3 6 6 | ) -literal_membership.py:4:6: PLR6201 [*] Use a set literal when testing for membership +PLR6201 [*] Use a set literal when testing for membership + --> literal_membership.py:4:6 | 2 | 1 in [1, 2, 3] 3 | 1 in (1, 2, 3) @@ -47,11 +50,11 @@ literal_membership.py:4:6: PLR6201 [*] Use a set literal when testing for member | ______^ 5 | | 1, 2, 3 6 | | ) - | |_^ PLR6201 + | |_^ 7 | fruits = ["cherry", "grapes"] 8 | "cherry" in fruits | - = help: Convert to `set` +help: Convert to `set` ℹ Unsafe fix 1 1 | # Errors @@ -66,16 +69,17 @@ literal_membership.py:4:6: PLR6201 [*] Use a set literal when testing for member 8 8 | "cherry" in fruits 9 9 | _ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")} -literal_membership.py:9:70: PLR6201 [*] Use a set literal when testing for membership +PLR6201 [*] Use a set literal when testing for membership + --> literal_membership.py:9:70 | 7 | fruits = ["cherry", "grapes"] 8 | "cherry" in fruits 9 | _ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")} - | ^^^^^^^^^^ PLR6201 + | ^^^^^^^^^^ 10 | 11 | # OK | - = help: Convert to `set` +help: Convert to `set` ℹ Unsafe fix 6 6 | ) diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap index 4971a0c1fb..5e82421071 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap @@ -1,95 +1,105 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -no_self_use.py:7:9: PLR6301 Method `developer_greeting` could be a function, class method, or static method +PLR6301 Method `developer_greeting` could be a function, class method, or static method + --> no_self_use.py:7:9 | 6 | class Person: 7 | def developer_greeting(self, name): # [no-self-use] - | ^^^^^^^^^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^^^^^^^^^ 8 | print(f"Greetings {name}!") | -no_self_use.py:10:9: PLR6301 Method `greeting_1` could be a function, class method, or static method +PLR6301 Method `greeting_1` could be a function, class method, or static method + --> no_self_use.py:10:9 | 8 | print(f"Greetings {name}!") 9 | 10 | def greeting_1(self): # [no-self-use] - | ^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^ 11 | print("Hello!") | -no_self_use.py:13:9: PLR6301 Method `greeting_2` could be a function, class method, or static method +PLR6301 Method `greeting_2` could be a function, class method, or static method + --> no_self_use.py:13:9 | 11 | print("Hello!") 12 | 13 | def greeting_2(self): # [no-self-use] - | ^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^ 14 | print("Hi!") | -no_self_use.py:103:9: PLR6301 Method `validate_y` could be a function, class method, or static method +PLR6301 Method `validate_y` could be a function, class method, or static method + --> no_self_use.py:103:9 | 102 | @y.validator 103 | def validate_y(self, attribute, value): - | ^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^ 104 | if value <= 0: 105 | raise ValueError("y must be a positive integer") | -no_self_use.py:128:9: PLR6301 Method `non_simple_assignment` could be a function, class method, or static method +PLR6301 Method `non_simple_assignment` could be a function, class method, or static method + --> no_self_use.py:128:9 | 126 | # Errors 127 | 128 | def non_simple_assignment(self): - | ^^^^^^^^^^^^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^^^^^^^^^^^^ 129 | msg = foo = "" 130 | raise NotImplementedError(msg) | -no_self_use.py:132:9: PLR6301 Method `non_simple_assignment_2` could be a function, class method, or static method +PLR6301 Method `non_simple_assignment_2` could be a function, class method, or static method + --> no_self_use.py:132:9 | 130 | raise NotImplementedError(msg) 131 | 132 | def non_simple_assignment_2(self): - | ^^^^^^^^^^^^^^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^^^^^^^^^^^^^^ 133 | msg[0] = "" 134 | raise NotImplementedError(msg) | -no_self_use.py:136:9: PLR6301 Method `unused_message` could be a function, class method, or static method +PLR6301 Method `unused_message` could be a function, class method, or static method + --> no_self_use.py:136:9 | 134 | raise NotImplementedError(msg) 135 | 136 | def unused_message(self): - | ^^^^^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^^^^^ 137 | msg = "" 138 | raise NotImplementedError("") | -no_self_use.py:140:9: PLR6301 Method `unused_message_2` could be a function, class method, or static method +PLR6301 Method `unused_message_2` could be a function, class method, or static method + --> no_self_use.py:140:9 | 138 | raise NotImplementedError("") 139 | 140 | def unused_message_2(self, x): - | ^^^^^^^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^^^^^^^ 141 | msg = "" 142 | raise NotImplementedError(x) | -no_self_use.py:145:9: PLR6301 Method `developer_greeting` could be a function, class method, or static method +PLR6301 Method `developer_greeting` could be a function, class method, or static method + --> no_self_use.py:145:9 | 144 | class TPerson: 145 | def developer_greeting(self, name): # [no-self-use] - | ^^^^^^^^^^^^^^^^^^ PLR6301 + | ^^^^^^^^^^^^^^^^^^ 146 | print(t"Greetings {name}!") | -no_self_use.py:151:9: PLR6301 Method `tstring` could be a function, class method, or static method +PLR6301 Method `tstring` could be a function, class method, or static method + --> no_self_use.py:151:9 | 149 | print(t"Hello from {self.name} !") 150 | 151 | def tstring(self, x): - | ^^^^^^^ PLR6301 + | ^^^^^^^ 152 | msg = t"{x}" 153 | raise NotImplementedError(msg) | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0101_unreachable.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0101_unreachable.py.snap index 832f1db331..87c0c9c471 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0101_unreachable.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0101_unreachable.py.snap @@ -1,34 +1,37 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -unreachable.py:18:5: PLW0101 Unreachable code in `after_return` +PLW0101 Unreachable code in `after_return` + --> unreachable.py:18:5 | 16 | def after_return(): 17 | return 1 18 | / print("unreachable") 19 | | print("and this") - | |_____________________^ PLW0101 + | |_____________________^ 20 | 21 | def after_raise(): | -unreachable.py:23:5: PLW0101 Unreachable code in `after_raise` +PLW0101 Unreachable code in `after_raise` + --> unreachable.py:23:5 | 21 | def after_raise(): 22 | raise ValueError 23 | / print("unreachable") 24 | | print("and this") - | |_____________________^ PLW0101 + | |_____________________^ 25 | 26 | def multiple_returns(): | -unreachable.py:28:5: PLW0101 Unreachable code in `multiple_returns` +PLW0101 Unreachable code in `multiple_returns` + --> unreachable.py:28:5 | 26 | def multiple_returns(): 27 | return 1 28 | / print("unreachable") 29 | | return 2 30 | | print("unreachable range should include above return") - | |__________________________________________________________^ PLW0101 + | |__________________________________________________________^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap index 73dd687d2f..5d267e44ef 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0108_unnecessary_lambda.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -unnecessary_lambda.py:1:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:1:5 | 1 | _ = lambda: print() # [unnecessary-lambda] - | ^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^ 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 1 |-_ = lambda: print() # [unnecessary-lambda] @@ -16,15 +17,16 @@ unnecessary_lambda.py:1:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 3 3 | 4 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] -unnecessary_lambda.py:2:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:2:5 | 1 | _ = lambda: print() # [unnecessary-lambda] 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] - | ^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 1 1 | _ = lambda: print() # [unnecessary-lambda] @@ -34,16 +36,17 @@ unnecessary_lambda.py:2:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 4 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] 5 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] -unnecessary_lambda.py:4:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:4:5 | 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] 3 | 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] - | ^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^ 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 1 1 | _ = lambda: print() # [unnecessary-lambda] @@ -55,15 +58,16 @@ unnecessary_lambda.py:4:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 6 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] 7 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] -unnecessary_lambda.py:5:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:5:5 | 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 2 2 | _ = lambda x, y: min(x, y) # [unnecessary-lambda] @@ -75,15 +79,16 @@ unnecessary_lambda.py:5:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 7 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] 8 8 | -unnecessary_lambda.py:6:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:6:5 | 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 3 3 | @@ -95,16 +100,17 @@ unnecessary_lambda.py:6:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 8 8 | 9 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] -unnecessary_lambda.py:7:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:7:5 | 5 | _ = lambda **kwargs: f(**kwargs) # [unnecessary-lambda] 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 4 4 | _ = lambda *args: f(*args) # [unnecessary-lambda] @@ -116,15 +122,16 @@ unnecessary_lambda.py:7:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 9 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] 10 10 | _ = lambda x, y: f(lambda x, y: x + y)(x, y) # [unnecessary-lambda] -unnecessary_lambda.py:9:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:9:5 | 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] 8 | 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | _ = lambda x, y: f(lambda x, y: x + y)(x, y) # [unnecessary-lambda] | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 6 6 | _ = lambda *args, **kwargs: f(*args, **kwargs) # [unnecessary-lambda] @@ -136,15 +143,16 @@ unnecessary_lambda.py:9:5: PLW0108 [*] Lambda may be unnecessary; consider inlin 11 11 | 12 12 | # default value in lambda parameters -unnecessary_lambda.py:10:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:10:5 | 9 | _ = lambda x: f(lambda x: x)(x) # [unnecessary-lambda] 10 | _ = lambda x, y: f(lambda x, y: x + y)(x, y) # [unnecessary-lambda] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | # default value in lambda parameters | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 7 7 | _ = lambda x, y, z, *args, **kwargs: f(x, y, z, *args, **kwargs) # [unnecessary-lambda] @@ -156,14 +164,15 @@ unnecessary_lambda.py:10:5: PLW0108 [*] Lambda may be unnecessary; consider inli 12 12 | # default value in lambda parameters 13 13 | _ = lambda x=42: print(x) -unnecessary_lambda.py:62:5: PLW0108 [*] Lambda may be unnecessary; consider inlining inner function +PLW0108 [*] Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:62:5 | 61 | # https://github.com/astral-sh/ruff/issues/18675 62 | _ = lambda x: (string := str)(x) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | _ = lambda x: ((x := 1) and str)(x) | - = help: Inline function call +help: Inline function call ℹ Unsafe fix 59 59 | _ = lambda *args: f(*args, y=x) @@ -173,11 +182,12 @@ unnecessary_lambda.py:62:5: PLW0108 [*] Lambda may be unnecessary; consider inli 62 |+_ = (string := str) 63 63 | _ = lambda x: ((x := 1) and str)(x) -unnecessary_lambda.py:63:5: PLW0108 Lambda may be unnecessary; consider inlining inner function +PLW0108 Lambda may be unnecessary; consider inlining inner function + --> unnecessary_lambda.py:63:5 | 61 | # https://github.com/astral-sh/ruff/issues/18675 62 | _ = lambda x: (string := str)(x) 63 | _ = lambda x: ((x := 1) and str)(x) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0108 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Inline function call +help: Inline function call diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap index 0a03d7a4c4..39be92ea3a 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -useless_else_on_loop.py:9:5: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents +PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents + --> useless_else_on_loop.py:9:5 | 7 | if i % 2: 8 | return i 9 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 + | ^^^^ 10 | print("math is broken") 11 | return None | - = help: Remove `else` +help: Remove `else` ℹ Safe fix 6 6 | for i in range(10): @@ -23,16 +24,17 @@ useless_else_on_loop.py:9:5: PLW0120 [*] `else` clause on loop without a `break` 12 11 | 13 12 | -useless_else_on_loop.py:18:5: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents +PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents + --> useless_else_on_loop.py:18:5 | 16 | while True: 17 | return 1 18 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 + | ^^^^ 19 | print("math is broken") 20 | return None | - = help: Remove `else` +help: Remove `else` ℹ Safe fix 15 15 | """else + return is not acceptable.""" @@ -45,15 +47,16 @@ useless_else_on_loop.py:18:5: PLW0120 [*] `else` clause on loop without a `break 21 20 | 22 21 | -useless_else_on_loop.py:30:1: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents +PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents + --> useless_else_on_loop.py:30:1 | 28 | break 29 | 30 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 + | ^^^^ 31 | print("or else!") | - = help: Remove `else` +help: Remove `else` ℹ Safe fix 27 27 | for _ in range(10): @@ -66,15 +69,16 @@ useless_else_on_loop.py:30:1: PLW0120 [*] `else` clause on loop without a `break 33 32 | 34 33 | while True: -useless_else_on_loop.py:37:1: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents +PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents + --> useless_else_on_loop.py:37:1 | 35 | while False: 36 | break 37 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 + | ^^^^ 38 | print("or else!") | - = help: Remove `else` +help: Remove `else` ℹ Safe fix 34 34 | while True: @@ -87,16 +91,17 @@ useless_else_on_loop.py:37:1: PLW0120 [*] `else` clause on loop without a `break 40 39 | for j in range(10): 41 40 | pass -useless_else_on_loop.py:42:1: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents +PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents + --> useless_else_on_loop.py:42:1 | 40 | for j in range(10): 41 | pass 42 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 + | ^^^^ 43 | print("fat chance") 44 | for j in range(10): | - = help: Remove `else` +help: Remove `else` ℹ Safe fix 39 39 | @@ -113,16 +118,17 @@ useless_else_on_loop.py:42:1: PLW0120 [*] `else` clause on loop without a `break 47 46 | 48 47 | def test_return_for2(): -useless_else_on_loop.py:88:5: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents +PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents + --> useless_else_on_loop.py:88:5 | 86 | else: 87 | print("all right") 88 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 + | ^^^^ 89 | return True 90 | return False | - = help: Remove `else` +help: Remove `else` ℹ Safe fix 85 85 | break @@ -135,16 +141,17 @@ useless_else_on_loop.py:88:5: PLW0120 [*] `else` clause on loop without a `break 91 90 | 92 91 | -useless_else_on_loop.py:98:9: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents +PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents + --> useless_else_on_loop.py:98:9 | 96 | for _ in range(3): 97 | pass 98 | else: - | ^^^^ PLW0120 + | ^^^^ 99 | if 1 < 2: # pylint: disable=comparison-of-constants 100 | break | - = help: Remove `else` +help: Remove `else` ℹ Safe fix 95 95 | for _ in range(10): @@ -159,16 +166,17 @@ useless_else_on_loop.py:98:9: PLW0120 [*] `else` clause on loop without a `break 102 101 | return True 103 102 | return False -useless_else_on_loop.py:144:5: PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents +PLW0120 [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents + --> useless_else_on_loop.py:144:5 | 142 | for j in range(10): 143 | pass 144 | else: - | ^^^^ PLW0120 + | ^^^^ 145 | # [useless-else-on-loop] 146 | print("fat chance") | - = help: Remove `else` +help: Remove `else` ℹ Safe fix 141 141 | """Retain the comment within the `else` block""" diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap index e1489cb2ab..7c48b0eda1 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap @@ -1,409 +1,450 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -self_assigning_variable.py:6:1: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:6:1 | 5 | # Errors. 6 | foo = foo - | ^^^ PLW0127 + | ^^^ 7 | bar = bar 8 | foo, bar = foo, bar | -self_assigning_variable.py:7:1: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:7:1 | 5 | # Errors. 6 | foo = foo 7 | bar = bar - | ^^^ PLW0127 + | ^^^ 8 | foo, bar = foo, bar 9 | bar, foo = bar, foo | -self_assigning_variable.py:8:1: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:8:1 | 6 | foo = foo 7 | bar = bar 8 | foo, bar = foo, bar - | ^^^ PLW0127 + | ^^^ 9 | bar, foo = bar, foo 10 | (foo, bar) = (foo, bar) | -self_assigning_variable.py:8:6: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:8:6 | 6 | foo = foo 7 | bar = bar 8 | foo, bar = foo, bar - | ^^^ PLW0127 + | ^^^ 9 | bar, foo = bar, foo 10 | (foo, bar) = (foo, bar) | -self_assigning_variable.py:9:1: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:9:1 | 7 | bar = bar 8 | foo, bar = foo, bar 9 | bar, foo = bar, foo - | ^^^ PLW0127 + | ^^^ 10 | (foo, bar) = (foo, bar) 11 | (bar, foo) = (bar, foo) | -self_assigning_variable.py:9:6: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:9:6 | 7 | bar = bar 8 | foo, bar = foo, bar 9 | bar, foo = bar, foo - | ^^^ PLW0127 + | ^^^ 10 | (foo, bar) = (foo, bar) 11 | (bar, foo) = (bar, foo) | -self_assigning_variable.py:10:2: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:10:2 | 8 | foo, bar = foo, bar 9 | bar, foo = bar, foo 10 | (foo, bar) = (foo, bar) - | ^^^ PLW0127 + | ^^^ 11 | (bar, foo) = (bar, foo) 12 | foo, (bar, baz) = foo, (bar, baz) | -self_assigning_variable.py:10:7: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:10:7 | 8 | foo, bar = foo, bar 9 | bar, foo = bar, foo 10 | (foo, bar) = (foo, bar) - | ^^^ PLW0127 + | ^^^ 11 | (bar, foo) = (bar, foo) 12 | foo, (bar, baz) = foo, (bar, baz) | -self_assigning_variable.py:11:2: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:11:2 | 9 | bar, foo = bar, foo 10 | (foo, bar) = (foo, bar) 11 | (bar, foo) = (bar, foo) - | ^^^ PLW0127 + | ^^^ 12 | foo, (bar, baz) = foo, (bar, baz) 13 | bar, (foo, baz) = bar, (foo, baz) | -self_assigning_variable.py:11:7: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:11:7 | 9 | bar, foo = bar, foo 10 | (foo, bar) = (foo, bar) 11 | (bar, foo) = (bar, foo) - | ^^^ PLW0127 + | ^^^ 12 | foo, (bar, baz) = foo, (bar, baz) 13 | bar, (foo, baz) = bar, (foo, baz) | -self_assigning_variable.py:12:1: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:12:1 | 10 | (foo, bar) = (foo, bar) 11 | (bar, foo) = (bar, foo) 12 | foo, (bar, baz) = foo, (bar, baz) - | ^^^ PLW0127 + | ^^^ 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz | -self_assigning_variable.py:12:7: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:12:7 | 10 | (foo, bar) = (foo, bar) 11 | (bar, foo) = (bar, foo) 12 | foo, (bar, baz) = foo, (bar, baz) - | ^^^ PLW0127 + | ^^^ 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz | -self_assigning_variable.py:12:12: PLW0127 Self-assignment of variable `baz` +PLW0127 Self-assignment of variable `baz` + --> self_assigning_variable.py:12:12 | 10 | (foo, bar) = (foo, bar) 11 | (bar, foo) = (bar, foo) 12 | foo, (bar, baz) = foo, (bar, baz) - | ^^^ PLW0127 + | ^^^ 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz | -self_assigning_variable.py:13:1: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:13:1 | 11 | (bar, foo) = (bar, foo) 12 | foo, (bar, baz) = foo, (bar, baz) 13 | bar, (foo, baz) = bar, (foo, baz) - | ^^^ PLW0127 + | ^^^ 14 | (foo, bar), baz = (foo, bar), baz 15 | (foo, (bar, baz)) = (foo, (bar, baz)) | -self_assigning_variable.py:13:7: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:13:7 | 11 | (bar, foo) = (bar, foo) 12 | foo, (bar, baz) = foo, (bar, baz) 13 | bar, (foo, baz) = bar, (foo, baz) - | ^^^ PLW0127 + | ^^^ 14 | (foo, bar), baz = (foo, bar), baz 15 | (foo, (bar, baz)) = (foo, (bar, baz)) | -self_assigning_variable.py:13:12: PLW0127 Self-assignment of variable `baz` +PLW0127 Self-assignment of variable `baz` + --> self_assigning_variable.py:13:12 | 11 | (bar, foo) = (bar, foo) 12 | foo, (bar, baz) = foo, (bar, baz) 13 | bar, (foo, baz) = bar, (foo, baz) - | ^^^ PLW0127 + | ^^^ 14 | (foo, bar), baz = (foo, bar), baz 15 | (foo, (bar, baz)) = (foo, (bar, baz)) | -self_assigning_variable.py:14:2: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:14:2 | 12 | foo, (bar, baz) = foo, (bar, baz) 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz - | ^^^ PLW0127 + | ^^^ 15 | (foo, (bar, baz)) = (foo, (bar, baz)) 16 | foo, bar = foo, 1 | -self_assigning_variable.py:14:7: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:14:7 | 12 | foo, (bar, baz) = foo, (bar, baz) 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz - | ^^^ PLW0127 + | ^^^ 15 | (foo, (bar, baz)) = (foo, (bar, baz)) 16 | foo, bar = foo, 1 | -self_assigning_variable.py:14:13: PLW0127 Self-assignment of variable `baz` +PLW0127 Self-assignment of variable `baz` + --> self_assigning_variable.py:14:13 | 12 | foo, (bar, baz) = foo, (bar, baz) 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz - | ^^^ PLW0127 + | ^^^ 15 | (foo, (bar, baz)) = (foo, (bar, baz)) 16 | foo, bar = foo, 1 | -self_assigning_variable.py:15:2: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:15:2 | 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz 15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | ^^^ PLW0127 + | ^^^ 16 | foo, bar = foo, 1 17 | bar, foo = bar, 1 | -self_assigning_variable.py:15:8: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:15:8 | 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz 15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | ^^^ PLW0127 + | ^^^ 16 | foo, bar = foo, 1 17 | bar, foo = bar, 1 | -self_assigning_variable.py:15:13: PLW0127 Self-assignment of variable `baz` +PLW0127 Self-assignment of variable `baz` + --> self_assigning_variable.py:15:13 | 13 | bar, (foo, baz) = bar, (foo, baz) 14 | (foo, bar), baz = (foo, bar), baz 15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | ^^^ PLW0127 + | ^^^ 16 | foo, bar = foo, 1 17 | bar, foo = bar, 1 | -self_assigning_variable.py:16:1: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:16:1 | 14 | (foo, bar), baz = (foo, bar), baz 15 | (foo, (bar, baz)) = (foo, (bar, baz)) 16 | foo, bar = foo, 1 - | ^^^ PLW0127 + | ^^^ 17 | bar, foo = bar, 1 18 | (foo, bar) = (foo, 1) | -self_assigning_variable.py:17:1: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:17:1 | 15 | (foo, (bar, baz)) = (foo, (bar, baz)) 16 | foo, bar = foo, 1 17 | bar, foo = bar, 1 - | ^^^ PLW0127 + | ^^^ 18 | (foo, bar) = (foo, 1) 19 | (bar, foo) = (bar, 1) | -self_assigning_variable.py:18:2: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:18:2 | 16 | foo, bar = foo, 1 17 | bar, foo = bar, 1 18 | (foo, bar) = (foo, 1) - | ^^^ PLW0127 + | ^^^ 19 | (bar, foo) = (bar, 1) 20 | foo, (bar, baz) = foo, (bar, 1) | -self_assigning_variable.py:19:2: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:19:2 | 17 | bar, foo = bar, 1 18 | (foo, bar) = (foo, 1) 19 | (bar, foo) = (bar, 1) - | ^^^ PLW0127 + | ^^^ 20 | foo, (bar, baz) = foo, (bar, 1) 21 | bar, (foo, baz) = bar, (foo, 1) | -self_assigning_variable.py:20:1: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:20:1 | 18 | (foo, bar) = (foo, 1) 19 | (bar, foo) = (bar, 1) 20 | foo, (bar, baz) = foo, (bar, 1) - | ^^^ PLW0127 + | ^^^ 21 | bar, (foo, baz) = bar, (foo, 1) 22 | (foo, bar), baz = (foo, bar), 1 | -self_assigning_variable.py:20:7: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:20:7 | 18 | (foo, bar) = (foo, 1) 19 | (bar, foo) = (bar, 1) 20 | foo, (bar, baz) = foo, (bar, 1) - | ^^^ PLW0127 + | ^^^ 21 | bar, (foo, baz) = bar, (foo, 1) 22 | (foo, bar), baz = (foo, bar), 1 | -self_assigning_variable.py:21:1: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:21:1 | 19 | (bar, foo) = (bar, 1) 20 | foo, (bar, baz) = foo, (bar, 1) 21 | bar, (foo, baz) = bar, (foo, 1) - | ^^^ PLW0127 + | ^^^ 22 | (foo, bar), baz = (foo, bar), 1 23 | (foo, (bar, baz)) = (foo, (bar, 1)) | -self_assigning_variable.py:21:7: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:21:7 | 19 | (bar, foo) = (bar, 1) 20 | foo, (bar, baz) = foo, (bar, 1) 21 | bar, (foo, baz) = bar, (foo, 1) - | ^^^ PLW0127 + | ^^^ 22 | (foo, bar), baz = (foo, bar), 1 23 | (foo, (bar, baz)) = (foo, (bar, 1)) | -self_assigning_variable.py:22:2: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:22:2 | 20 | foo, (bar, baz) = foo, (bar, 1) 21 | bar, (foo, baz) = bar, (foo, 1) 22 | (foo, bar), baz = (foo, bar), 1 - | ^^^ PLW0127 + | ^^^ 23 | (foo, (bar, baz)) = (foo, (bar, 1)) 24 | foo: int = foo | -self_assigning_variable.py:22:7: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:22:7 | 20 | foo, (bar, baz) = foo, (bar, 1) 21 | bar, (foo, baz) = bar, (foo, 1) 22 | (foo, bar), baz = (foo, bar), 1 - | ^^^ PLW0127 + | ^^^ 23 | (foo, (bar, baz)) = (foo, (bar, 1)) 24 | foo: int = foo | -self_assigning_variable.py:23:2: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:23:2 | 21 | bar, (foo, baz) = bar, (foo, 1) 22 | (foo, bar), baz = (foo, bar), 1 23 | (foo, (bar, baz)) = (foo, (bar, 1)) - | ^^^ PLW0127 + | ^^^ 24 | foo: int = foo 25 | bar: int = bar | -self_assigning_variable.py:23:8: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:23:8 | 21 | bar, (foo, baz) = bar, (foo, 1) 22 | (foo, bar), baz = (foo, bar), 1 23 | (foo, (bar, baz)) = (foo, (bar, 1)) - | ^^^ PLW0127 + | ^^^ 24 | foo: int = foo 25 | bar: int = bar | -self_assigning_variable.py:24:1: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:24:1 | 22 | (foo, bar), baz = (foo, bar), 1 23 | (foo, (bar, baz)) = (foo, (bar, 1)) 24 | foo: int = foo - | ^^^ PLW0127 + | ^^^ 25 | bar: int = bar 26 | foo = foo = bar | -self_assigning_variable.py:25:1: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:25:1 | 23 | (foo, (bar, baz)) = (foo, (bar, 1)) 24 | foo: int = foo 25 | bar: int = bar - | ^^^ PLW0127 + | ^^^ 26 | foo = foo = bar 27 | (foo, bar) = (foo, bar) = baz | -self_assigning_variable.py:26:1: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:26:1 | 24 | foo: int = foo 25 | bar: int = bar 26 | foo = foo = bar - | ^^^ PLW0127 + | ^^^ 27 | (foo, bar) = (foo, bar) = baz 28 | (foo, bar) = baz = (foo, bar) = 1 | -self_assigning_variable.py:27:2: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:27:2 | 25 | bar: int = bar 26 | foo = foo = bar 27 | (foo, bar) = (foo, bar) = baz - | ^^^ PLW0127 + | ^^^ 28 | (foo, bar) = baz = (foo, bar) = 1 | -self_assigning_variable.py:27:7: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:27:7 | 25 | bar: int = bar 26 | foo = foo = bar 27 | (foo, bar) = (foo, bar) = baz - | ^^^ PLW0127 + | ^^^ 28 | (foo, bar) = baz = (foo, bar) = 1 | -self_assigning_variable.py:28:2: PLW0127 Self-assignment of variable `foo` +PLW0127 Self-assignment of variable `foo` + --> self_assigning_variable.py:28:2 | 26 | foo = foo = bar 27 | (foo, bar) = (foo, bar) = baz 28 | (foo, bar) = baz = (foo, bar) = 1 - | ^^^ PLW0127 + | ^^^ 29 | 30 | # Non-errors. | -self_assigning_variable.py:28:7: PLW0127 Self-assignment of variable `bar` +PLW0127 Self-assignment of variable `bar` + --> self_assigning_variable.py:28:7 | 26 | foo = foo = bar 27 | (foo, bar) = (foo, bar) = baz 28 | (foo, bar) = baz = (foo, bar) = 1 - | ^^^ PLW0127 + | ^^^ 29 | 30 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0128_redeclared_assigned_name.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0128_redeclared_assigned_name.py.snap index 13c70ddf96..6db345ec8e 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0128_redeclared_assigned_name.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0128_redeclared_assigned_name.py.snap @@ -1,97 +1,107 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -redeclared_assigned_name.py:1:8: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:1:8 | 1 | FIRST, FIRST = (1, 2) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 2 | FIRST, (FIRST, SECOND) = (1, (1, 2)) # PLW0128 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 | -redeclared_assigned_name.py:2:9: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:2:9 | 1 | FIRST, FIRST = (1, 2) # PLW0128 2 | FIRST, (FIRST, SECOND) = (1, (1, 2)) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 | -redeclared_assigned_name.py:3:9: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:3:9 | 1 | FIRST, FIRST = (1, 2) # PLW0128 2 | FIRST, (FIRST, SECOND) = (1, (1, 2)) # PLW0128 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 5 | FIRST, [FIRST, SECOND] = (1, (1, 2)) # PLW0128 | -redeclared_assigned_name.py:3:32: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:3:32 | 1 | FIRST, FIRST = (1, 2) # PLW0128 2 | FIRST, (FIRST, SECOND) = (1, (1, 2)) # PLW0128 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 5 | FIRST, [FIRST, SECOND] = (1, (1, 2)) # PLW0128 | -redeclared_assigned_name.py:4:23: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:4:23 | 2 | FIRST, (FIRST, SECOND) = (1, (1, 2)) # PLW0128 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 5 | FIRST, [FIRST, SECOND] = (1, (1, 2)) # PLW0128 6 | FIRST, [FIRST, SECOND, [THIRD, FIRST]] = (1, (1, 2)) # PLW0128 | -redeclared_assigned_name.py:4:30: PLW0128 Redeclared variable `SECOND` in assignment +PLW0128 Redeclared variable `SECOND` in assignment + --> redeclared_assigned_name.py:4:30 | 2 | FIRST, (FIRST, SECOND) = (1, (1, 2)) # PLW0128 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 - | ^^^^^^ PLW0128 + | ^^^^^^ 5 | FIRST, [FIRST, SECOND] = (1, (1, 2)) # PLW0128 6 | FIRST, [FIRST, SECOND, [THIRD, FIRST]] = (1, (1, 2)) # PLW0128 | -redeclared_assigned_name.py:5:9: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:5:9 | 3 | FIRST, (FIRST, SECOND, (THIRD, FIRST)) = (1, (1, 2)) # PLW0128 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 5 | FIRST, [FIRST, SECOND] = (1, (1, 2)) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 6 | FIRST, [FIRST, SECOND, [THIRD, FIRST]] = (1, (1, 2)) # PLW0128 7 | FIRST, *FIRST = (1, 2) # PLW0128 | -redeclared_assigned_name.py:6:9: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:6:9 | 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 5 | FIRST, [FIRST, SECOND] = (1, (1, 2)) # PLW0128 6 | FIRST, [FIRST, SECOND, [THIRD, FIRST]] = (1, (1, 2)) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 7 | FIRST, *FIRST = (1, 2) # PLW0128 | -redeclared_assigned_name.py:6:32: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:6:32 | 4 | FIRST, SECOND, THIRD, FIRST, SECOND = (1, 2, 3, 4) # PLW0128 5 | FIRST, [FIRST, SECOND] = (1, (1, 2)) # PLW0128 6 | FIRST, [FIRST, SECOND, [THIRD, FIRST]] = (1, (1, 2)) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 7 | FIRST, *FIRST = (1, 2) # PLW0128 | -redeclared_assigned_name.py:7:9: PLW0128 Redeclared variable `FIRST` in assignment +PLW0128 Redeclared variable `FIRST` in assignment + --> redeclared_assigned_name.py:7:9 | 5 | FIRST, [FIRST, SECOND] = (1, (1, 2)) # PLW0128 6 | FIRST, [FIRST, SECOND, [THIRD, FIRST]] = (1, (1, 2)) # PLW0128 7 | FIRST, *FIRST = (1, 2) # PLW0128 - | ^^^^^ PLW0128 + | ^^^^^ 8 | 9 | FIRST, SECOND, _, _, _ignored = (1, 2, 3, 4, 5) # OK | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap index 120302d3df..f840a788e5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap @@ -1,97 +1,107 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -assert_on_string_literal.py:3:12: PLW0129 Asserting on a non-empty string literal will always pass +PLW0129 Asserting on a non-empty string literal will always pass + --> assert_on_string_literal.py:3:12 | 1 | def test_division(): 2 | a = 9 / 3 3 | assert "No ZeroDivisionError were raised" # [assert-on-string-literal] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0129 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -assert_on_string_literal.py:12:12: PLW0129 Asserting on a non-empty string literal will always pass +PLW0129 Asserting on a non-empty string literal will always pass + --> assert_on_string_literal.py:12:12 | 11 | try: 12 | assert "bad" # [assert-on-string-literal] - | ^^^^^ PLW0129 + | ^^^^^ 13 | except: 14 | assert "bad again" # [assert-on-string-literal] | -assert_on_string_literal.py:14:12: PLW0129 Asserting on a non-empty string literal will always pass +PLW0129 Asserting on a non-empty string literal will always pass + --> assert_on_string_literal.py:14:12 | 12 | assert "bad" # [assert-on-string-literal] 13 | except: 14 | assert "bad again" # [assert-on-string-literal] - | ^^^^^^^^^^^ PLW0129 + | ^^^^^^^^^^^ 15 | 16 | a = 12 | -assert_on_string_literal.py:17:8: PLW0129 Asserting on a non-empty string literal will always pass +PLW0129 Asserting on a non-empty string literal will always pass + --> assert_on_string_literal.py:17:8 | 16 | a = 12 17 | assert f"hello {a}" # [assert-on-string-literal] - | ^^^^^^^^^^^^ PLW0129 + | ^^^^^^^^^^^^ 18 | assert f"{a}" # [assert-on-string-literal] 19 | assert f"" # [assert-on-string-literal] | -assert_on_string_literal.py:18:8: PLW0129 Asserting on a string literal may have unintended results +PLW0129 Asserting on a string literal may have unintended results + --> assert_on_string_literal.py:18:8 | 16 | a = 12 17 | assert f"hello {a}" # [assert-on-string-literal] 18 | assert f"{a}" # [assert-on-string-literal] - | ^^^^^^ PLW0129 + | ^^^^^^ 19 | assert f"" # [assert-on-string-literal] 20 | assert "" # [assert-on-string-literal] | -assert_on_string_literal.py:19:8: PLW0129 Asserting on an empty string literal will never pass +PLW0129 Asserting on an empty string literal will never pass + --> assert_on_string_literal.py:19:8 | 17 | assert f"hello {a}" # [assert-on-string-literal] 18 | assert f"{a}" # [assert-on-string-literal] 19 | assert f"" # [assert-on-string-literal] - | ^^^ PLW0129 + | ^^^ 20 | assert "" # [assert-on-string-literal] 21 | assert b"hello" # [assert-on-string-literal] | -assert_on_string_literal.py:20:8: PLW0129 Asserting on an empty string literal will never pass +PLW0129 Asserting on an empty string literal will never pass + --> assert_on_string_literal.py:20:8 | 18 | assert f"{a}" # [assert-on-string-literal] 19 | assert f"" # [assert-on-string-literal] 20 | assert "" # [assert-on-string-literal] - | ^^ PLW0129 + | ^^ 21 | assert b"hello" # [assert-on-string-literal] 22 | assert "", b"hi" # [assert-on-string-literal] | -assert_on_string_literal.py:21:8: PLW0129 Asserting on a non-empty string literal will always pass +PLW0129 Asserting on a non-empty string literal will always pass + --> assert_on_string_literal.py:21:8 | 19 | assert f"" # [assert-on-string-literal] 20 | assert "" # [assert-on-string-literal] 21 | assert b"hello" # [assert-on-string-literal] - | ^^^^^^^^ PLW0129 + | ^^^^^^^^ 22 | assert "", b"hi" # [assert-on-string-literal] 23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] | -assert_on_string_literal.py:22:8: PLW0129 Asserting on an empty string literal will never pass +PLW0129 Asserting on an empty string literal will never pass + --> assert_on_string_literal.py:22:8 | 20 | assert "" # [assert-on-string-literal] 21 | assert b"hello" # [assert-on-string-literal] 22 | assert "", b"hi" # [assert-on-string-literal] - | ^^ PLW0129 + | ^^ 23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] 24 | assert 12, "ok here" | -assert_on_string_literal.py:23:8: PLW0129 Asserting on a non-empty string literal will always pass +PLW0129 Asserting on a non-empty string literal will always pass + --> assert_on_string_literal.py:23:8 | 21 | assert b"hello" # [assert-on-string-literal] 22 | assert "", b"hi" # [assert-on-string-literal] 23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] - | ^^^^^^^^^^^^^ PLW0129 + | ^^^^^^^^^^^^^ 24 | assert 12, "ok here" | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap index ae0e8efbf1..4306ba4fc7 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap @@ -1,27 +1,29 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -named_expr_without_context.py:2:2: PLW0131 Named expression used without context +PLW0131 Named expression used without context + --> named_expr_without_context.py:2:2 | 1 | # Errors 2 | (a := 42) - | ^^^^^^^ PLW0131 + | ^^^^^^^ 3 | if True: 4 | (b := 1) | -named_expr_without_context.py:4:6: PLW0131 Named expression used without context +PLW0131 Named expression used without context + --> named_expr_without_context.py:4:6 | 2 | (a := 42) 3 | if True: 4 | (b := 1) - | ^^^^^^ PLW0131 + | ^^^^^^ | -named_expr_without_context.py:8:6: PLW0131 Named expression used without context +PLW0131 Named expression used without context + --> named_expr_without_context.py:8:6 | 7 | class Foo: 8 | (c := 1) - | ^^^^^^ PLW0131 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap index 9df03f0994..3bb64a4e40 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0133_useless_exception_statement.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -useless_exception_statement.py:7:5: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:7:5 | 5 | # Test case 1: Useless exception statement 6 | def func(): 7 | AssertionError("This is an assertion error") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 4 4 | @@ -20,16 +21,17 @@ useless_exception_statement.py:7:5: PLW0133 [*] Missing `raise` statement on exc 9 9 | 10 10 | # Test case 2: Useless exception statement in try-except block -useless_exception_statement.py:13:9: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:13:9 | 11 | def func(): 12 | try: 13 | Exception("This is an exception") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | except Exception as err: 15 | pass | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 10 10 | # Test case 2: Useless exception statement in try-except block @@ -41,14 +43,15 @@ useless_exception_statement.py:13:9: PLW0133 [*] Missing `raise` statement on ex 15 15 | pass 16 16 | -useless_exception_statement.py:21:9: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:21:9 | 19 | def func(): 20 | if True: 21 | RuntimeError("This is an exception") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 18 18 | # Test case 3: Useless exception statement in if statement @@ -60,14 +63,15 @@ useless_exception_statement.py:21:9: PLW0133 [*] Missing `raise` statement on ex 23 23 | 24 24 | # Test case 4: Useless exception statement in class -useless_exception_statement.py:28:13: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:28:13 | 26 | class Class: 27 | def __init__(self): 28 | TypeError("This is an exception") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 25 25 | def func(): @@ -79,16 +83,17 @@ useless_exception_statement.py:28:13: PLW0133 [*] Missing `raise` statement on e 30 30 | 31 31 | # Test case 5: Useless exception statement in function -useless_exception_statement.py:34:9: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:34:9 | 32 | def func(): 33 | def inner(): 34 | IndexError("This is an exception") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | inner() | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 31 31 | # Test case 5: Useless exception statement in function @@ -100,14 +105,15 @@ useless_exception_statement.py:34:9: PLW0133 [*] Missing `raise` statement on ex 36 36 | inner() 37 37 | -useless_exception_statement.py:42:9: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:42:9 | 40 | def func(): 41 | while True: 42 | KeyError("This is an exception") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 39 39 | # Test case 6: Useless exception statement in while loop @@ -119,14 +125,15 @@ useless_exception_statement.py:42:9: PLW0133 [*] Missing `raise` statement on ex 44 44 | 45 45 | # Test case 7: Useless exception statement in abstract class -useless_exception_statement.py:50:13: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:50:13 | 48 | @abstractmethod 49 | def method(self): 50 | NotImplementedError("This is an exception") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 47 47 | class Class(ABC): @@ -138,14 +145,15 @@ useless_exception_statement.py:50:13: PLW0133 [*] Missing `raise` statement on e 52 52 | 53 53 | # Test case 8: Useless exception statement inside context manager -useless_exception_statement.py:56:9: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:56:9 | 54 | def func(): 55 | with suppress(AttributeError): 56 | AttributeError("This is an exception") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 53 53 | # Test case 8: Useless exception statement inside context manager @@ -157,14 +165,15 @@ useless_exception_statement.py:56:9: PLW0133 [*] Missing `raise` statement on ex 58 58 | 59 59 | # Test case 9: Useless exception statement in parentheses -useless_exception_statement.py:61:5: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:61:5 | 59 | # Test case 9: Useless exception statement in parentheses 60 | def func(): 61 | (RuntimeError("This is an exception")) # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 58 58 | @@ -176,14 +185,15 @@ useless_exception_statement.py:61:5: PLW0133 [*] Missing `raise` statement on ex 63 63 | 64 64 | # Test case 10: Useless exception statement in continuation -useless_exception_statement.py:66:12: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:66:12 | 64 | # Test case 10: Useless exception statement in continuation 65 | def func(): 66 | x = 1; (RuntimeError("This is an exception")); y = 2 # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 63 63 | @@ -195,14 +205,15 @@ useless_exception_statement.py:66:12: PLW0133 [*] Missing `raise` statement on e 68 68 | 69 69 | # Test case 11: Useless warning statement -useless_exception_statement.py:71:5: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:71:5 | 69 | # Test case 11: Useless warning statement 70 | def func(): 71 | UserWarning("This is an assertion error") # PLW0133 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 68 68 | @@ -214,16 +225,17 @@ useless_exception_statement.py:71:5: PLW0133 [*] Missing `raise` statement on ex 73 73 | 74 74 | # Non-violation test cases: PLW0133 -useless_exception_statement.py:126:1: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:126:1 | 124 | import builtins 125 | 126 | builtins.TypeError("still an exception even though it's an Attribute") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 127 | 128 | PythonFinalizationError("Added in Python 3.13") | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 123 123 | @@ -234,14 +246,15 @@ useless_exception_statement.py:126:1: PLW0133 [*] Missing `raise` statement on e 127 127 | 128 128 | PythonFinalizationError("Added in Python 3.13") -useless_exception_statement.py:128:1: PLW0133 [*] Missing `raise` statement on exception +PLW0133 [*] Missing `raise` statement on exception + --> useless_exception_statement.py:128:1 | 126 | builtins.TypeError("still an exception even though it's an Attribute") 127 | 128 | PythonFinalizationError("Added in Python 3.13") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0133 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `raise` keyword +help: Add `raise` keyword ℹ Unsafe fix 125 125 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0177_nan_comparison.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0177_nan_comparison.py.snap index 3cc8d69737..538f8dbb9c 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0177_nan_comparison.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0177_nan_comparison.py.snap @@ -1,126 +1,141 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -nan_comparison.py:11:9: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:11:9 | 10 | # PLW0117 11 | if x == float("nan"): - | ^^^^^^^^^^^^ PLW0177 + | ^^^^^^^^^^^^ 12 | pass | -nan_comparison.py:15:9: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:15:9 | 14 | # PLW0117 15 | if x == float("NaN"): - | ^^^^^^^^^^^^ PLW0177 + | ^^^^^^^^^^^^ 16 | pass | -nan_comparison.py:19:9: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:19:9 | 18 | # PLW0117 19 | if x == float("NAN"): - | ^^^^^^^^^^^^ PLW0177 + | ^^^^^^^^^^^^ 20 | pass | -nan_comparison.py:23:9: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:23:9 | 22 | # PLW0117 23 | if x == float("Nan"): - | ^^^^^^^^^^^^ PLW0177 + | ^^^^^^^^^^^^ 24 | pass | -nan_comparison.py:27:9: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:27:9 | 26 | # PLW0117 27 | if x == math.nan: - | ^^^^^^^^ PLW0177 + | ^^^^^^^^ 28 | pass | -nan_comparison.py:31:9: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:31:9 | 30 | # PLW0117 31 | if x == bad_val: - | ^^^^^^^ PLW0177 + | ^^^^^^^ 32 | pass | -nan_comparison.py:35:9: PLW0177 Comparing against a NaN value; use `np.isnan` instead +PLW0177 Comparing against a NaN value; use `np.isnan` instead + --> nan_comparison.py:35:9 | 34 | # PLW0117 35 | if y == np.NaN: - | ^^^^^^ PLW0177 + | ^^^^^^ 36 | pass | -nan_comparison.py:39:9: PLW0177 Comparing against a NaN value; use `np.isnan` instead +PLW0177 Comparing against a NaN value; use `np.isnan` instead + --> nan_comparison.py:39:9 | 38 | # PLW0117 39 | if y == np.NAN: - | ^^^^^^ PLW0177 + | ^^^^^^ 40 | pass | -nan_comparison.py:43:9: PLW0177 Comparing against a NaN value; use `np.isnan` instead +PLW0177 Comparing against a NaN value; use `np.isnan` instead + --> nan_comparison.py:43:9 | 42 | # PLW0117 43 | if y == np.nan: - | ^^^^^^ PLW0177 + | ^^^^^^ 44 | pass | -nan_comparison.py:47:9: PLW0177 Comparing against a NaN value; use `np.isnan` instead +PLW0177 Comparing against a NaN value; use `np.isnan` instead + --> nan_comparison.py:47:9 | 46 | # PLW0117 47 | if y == npy_nan: - | ^^^^^^^ PLW0177 + | ^^^^^^^ 48 | pass | -nan_comparison.py:53:9: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:53:9 | 52 | # PLW0117 53 | if x == builtins.float("nan"): - | ^^^^^^^^^^^^^^^^^^^^^ PLW0177 + | ^^^^^^^^^^^^^^^^^^^^^ 54 | pass | -nan_comparison.py:59:10: PLW0177 Comparing against a NaN value; use `np.isnan` instead +PLW0177 Comparing against a NaN value; use `np.isnan` instead + --> nan_comparison.py:59:10 | 57 | match number: 58 | # Errors 59 | case np.nan: ... - | ^^^^^^ PLW0177 + | ^^^^^^ 60 | case math.nan: ... | -nan_comparison.py:60:10: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:60:10 | 58 | # Errors 59 | case np.nan: ... 60 | case math.nan: ... - | ^^^^^^^^ PLW0177 + | ^^^^^^^^ 61 | 62 | # No errors | -nan_comparison.py:98:13: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:98:13 | 96 | # PLW0117 97 | # https://github.com/astral-sh/ruff/issues/18596 98 | assert x == float("-NaN ") - | ^^^^^^^^^^^^^^ PLW0177 + | ^^^^^^^^^^^^^^ 99 | assert x == float(" \n+nan \t") | -nan_comparison.py:99:13: PLW0177 Comparing against a NaN value; use `math.isnan` instead +PLW0177 Comparing against a NaN value; use `math.isnan` instead + --> nan_comparison.py:99:13 | 97 | # https://github.com/astral-sh/ruff/issues/18596 98 | assert x == float("-NaN ") 99 | assert x == float(" \n+nan \t") - | ^^^^^^^^^^^^^^^^^^^^^ PLW0177 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0211_bad_staticmethod_argument.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0211_bad_staticmethod_argument.py.snap index 9a18d7a33d..979494fab0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0211_bad_staticmethod_argument.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0211_bad_staticmethod_argument.py.snap @@ -1,37 +1,41 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -bad_staticmethod_argument.py:3:13: PLW0211 First argument of a static method should not be named `self` +PLW0211 First argument of a static method should not be named `self` + --> bad_staticmethod_argument.py:3:13 | 1 | class Wolf: 2 | @staticmethod 3 | def eat(self): # [bad-staticmethod-argument] - | ^^^^ PLW0211 + | ^^^^ 4 | pass | -bad_staticmethod_argument.py:15:13: PLW0211 First argument of a static method should not be named `cls` +PLW0211 First argument of a static method should not be named `cls` + --> bad_staticmethod_argument.py:15:13 | 13 | class Sheep: 14 | @staticmethod 15 | def eat(cls, x, y, z): # [bad-staticmethod-argument] - | ^^^ PLW0211 + | ^^^ 16 | pass | -bad_staticmethod_argument.py:19:15: PLW0211 First argument of a static method should not be named `self` +PLW0211 First argument of a static method should not be named `self` + --> bad_staticmethod_argument.py:19:15 | 18 | @staticmethod 19 | def sleep(self, x, y, z): # [bad-staticmethod-argument] - | ^^^^ PLW0211 + | ^^^^ 20 | pass | -bad_staticmethod_argument.py:55:17: PLW0211 First argument of a static method should not be named `self` +PLW0211 First argument of a static method should not be named `self` + --> bad_staticmethod_argument.py:55:17 | 53 | # `self` but not with `cls` as first argument - see above). 54 | class Foo: 55 | def __new__(self, x, y, z): # [bad-staticmethod-argument] - | ^^^^ PLW0211 + | ^^^^ 56 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0244_redefined_slots_in_subclass.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0244_redefined_slots_in_subclass.py.snap index 8077c6868d..aca4d1ddf4 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0244_redefined_slots_in_subclass.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0244_redefined_slots_in_subclass.py.snap @@ -1,34 +1,38 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -redefined_slots_in_subclass.py:6:18: PLW0244 Slot `a` redefined from base class `Base` +PLW0244 Slot `a` redefined from base class `Base` + --> redefined_slots_in_subclass.py:6:18 | 5 | class Subclass(Base): 6 | __slots__ = ("a", "d") # [redefined-slots-in-subclass] - | ^^^ PLW0244 + | ^^^ 7 | 8 | class Grandparent: | -redefined_slots_in_subclass.py:17:23: PLW0244 Slot `a` redefined from base class `Grandparent` +PLW0244 Slot `a` redefined from base class `Grandparent` + --> redefined_slots_in_subclass.py:17:23 | 16 | class Child(Parent): 17 | __slots__ = ("c", "a") - | ^^^ PLW0244 + | ^^^ 18 | 19 | class AnotherBase: | -redefined_slots_in_subclass.py:23:18: PLW0244 Slot `a` redefined from base class `AnotherBase` +PLW0244 Slot `a` redefined from base class `AnotherBase` + --> redefined_slots_in_subclass.py:23:18 | 22 | class AnotherChild(AnotherBase): 23 | __slots__ = ["a","b","e","f"] - | ^^^ PLW0244 + | ^^^ | -redefined_slots_in_subclass.py:23:22: PLW0244 Slot `b` redefined from base class `AnotherBase` +PLW0244 Slot `b` redefined from base class `AnotherBase` + --> redefined_slots_in_subclass.py:23:22 | 22 | class AnotherChild(AnotherBase): 23 | __slots__ = ["a","b","e","f"] - | ^^^ PLW0244 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap index b52fb9601f..f940cf92ca 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0245_super_without_brackets.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -super_without_brackets.py:10:26: PLW0245 [*] `super` call is missing parentheses +PLW0245 [*] `super` call is missing parentheses + --> super_without_brackets.py:10:26 | 8 | @staticmethod 9 | def speak(): 10 | original_speak = super.speak() # PLW0245 - | ^^^^^ PLW0245 + | ^^^^^ 11 | return f"{original_speak} But as a dog, it barks!" | - = help: Add parentheses to `super` call +help: Add parentheses to `super` call ℹ Safe fix 7 7 | class BadDog(Animal): diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0406_import_self__module.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0406_import_self__module.py.snap index 7ac51eba2d..741e604b57 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0406_import_self__module.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0406_import_self__module.py.snap @@ -1,27 +1,29 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -module.py:1:8: PLW0406 Module `import_self.module` imports itself +PLW0406 Module `import_self.module` imports itself + --> module.py:1:8 | 1 | import import_self.module - | ^^^^^^^^^^^^^^^^^^ PLW0406 + | ^^^^^^^^^^^^^^^^^^ 2 | from import_self import module 3 | from . import module | -module.py:2:25: PLW0406 Module `import_self.module` imports itself +PLW0406 Module `import_self.module` imports itself + --> module.py:2:25 | 1 | import import_self.module 2 | from import_self import module - | ^^^^^^ PLW0406 + | ^^^^^^ 3 | from . import module | -module.py:3:15: PLW0406 Module `import_self.module` imports itself +PLW0406 Module `import_self.module` imports itself + --> module.py:3:15 | 1 | import import_self.module 2 | from import_self import module 3 | from . import module - | ^^^^^^ PLW0406 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap index 3ba04a3cec..8b06cc77f5 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap @@ -1,19 +1,21 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -global_variable_not_assigned.py:5:12: PLW0602 Using global for `X` but no assignment is done +PLW0602 Using global for `X` but no assignment is done + --> global_variable_not_assigned.py:5:12 | 3 | ### 4 | def f(): 5 | global X - | ^ PLW0602 + | ^ | -global_variable_not_assigned.py:9:12: PLW0602 Using global for `X` but no assignment is done +PLW0602 Using global for `X` but no assignment is done + --> global_variable_not_assigned.py:9:12 | 8 | def f(): 9 | global X - | ^ PLW0602 + | ^ 10 | 11 | print(X) | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap index 30959b0b11..3277d2c319 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap @@ -1,100 +1,110 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -global_statement.py:17:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged +PLW0603 Using the global statement to update `CONSTANT` is discouraged + --> global_statement.py:17:12 | 15 | def fix_constant(value): 16 | """All this is ok, but try not to use `global` ;)""" 17 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 + | ^^^^^^^^ 18 | print(CONSTANT) 19 | CONSTANT = value | -global_statement.py:24:12: PLW0603 Using the global statement to update `sys` is discouraged +PLW0603 Using the global statement to update `sys` is discouraged + --> global_statement.py:24:12 | 22 | def global_with_import(): 23 | """Should only warn for global-statement when using `Import` node""" 24 | global sys # [global-statement] - | ^^^ PLW0603 + | ^^^ 25 | import sys | -global_statement.py:30:12: PLW0603 Using the global statement to update `namedtuple` is discouraged +PLW0603 Using the global statement to update `namedtuple` is discouraged + --> global_statement.py:30:12 | 28 | def global_with_import_from(): 29 | """Should only warn for global-statement when using `ImportFrom` node""" 30 | global namedtuple # [global-statement] - | ^^^^^^^^^^ PLW0603 + | ^^^^^^^^^^ 31 | from collections import namedtuple | -global_statement.py:36:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged +PLW0603 Using the global statement to update `CONSTANT` is discouraged + --> global_statement.py:36:12 | 34 | def global_del(): 35 | """Deleting the global name prevents `global-variable-not-assigned`""" 36 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 + | ^^^^^^^^ 37 | print(CONSTANT) 38 | del CONSTANT | -global_statement.py:43:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged +PLW0603 Using the global statement to update `CONSTANT` is discouraged + --> global_statement.py:43:12 | 41 | def global_operator_assign(): 42 | """Operator assigns should only throw a global statement error""" 43 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 + | ^^^^^^^^ 44 | print(CONSTANT) 45 | CONSTANT += 1 | -global_statement.py:50:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged +PLW0603 Using the global statement to update `CONSTANT` is discouraged + --> global_statement.py:50:12 | 48 | def global_function_assign(): 49 | """Function assigns should only throw a global statement error""" 50 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 + | ^^^^^^^^ 51 | 52 | def CONSTANT(): | -global_statement.py:60:12: PLW0603 Using the global statement to update `FUNC` is discouraged +PLW0603 Using the global statement to update `FUNC` is discouraged + --> global_statement.py:60:12 | 58 | def override_func(): 59 | """Overriding a function should only throw a global statement error""" 60 | global FUNC # [global-statement] - | ^^^^ PLW0603 + | ^^^^ 61 | 62 | def FUNC(): | -global_statement.py:70:12: PLW0603 Using the global statement to update `CLASS` is discouraged +PLW0603 Using the global statement to update `CLASS` is discouraged + --> global_statement.py:70:12 | 68 | def override_class(): 69 | """Overriding a class should only throw a global statement error""" 70 | global CLASS # [global-statement] - | ^^^^^ PLW0603 + | ^^^^^ 71 | 72 | class CLASS: | -global_statement.py:80:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged +PLW0603 Using the global statement to update `CONSTANT` is discouraged + --> global_statement.py:80:12 | 78 | def multiple_assignment(): 79 | """Should warn on every assignment.""" 80 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 + | ^^^^^^^^ 81 | CONSTANT = 1 82 | CONSTANT = 2 | -global_statement.py:80:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged +PLW0603 Using the global statement to update `CONSTANT` is discouraged + --> global_statement.py:80:12 | 78 | def multiple_assignment(): 79 | """Should warn on every assignment.""" 80 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 + | ^^^^^^^^ 81 | CONSTANT = 1 82 | CONSTANT = 2 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0604_global_at_module_level.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0604_global_at_module_level.py.snap index 7ca2dd0b69..fd650c4d16 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0604_global_at_module_level.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0604_global_at_module_level.py.snap @@ -1,19 +1,21 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -global_at_module_level.py:1:1: PLW0604 `global` at module level is redundant +PLW0604 `global` at module level is redundant + --> global_at_module_level.py:1:1 | 1 | global price # W0604 - | ^^^^^^^^^^^^ PLW0604 + | ^^^^^^^^^^^^ 2 | 3 | price = 25 | -global_at_module_level.py:6:5: PLW0604 `global` at module level is redundant +PLW0604 `global` at module level is redundant + --> global_at_module_level.py:6:5 | 5 | if True: 6 | global X # W0604 - | ^^^^^^^^ PLW0604 + | ^^^^^^^^ 7 | 8 | def no_error(): | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap index e7521e3977..360984514f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0642_self_or_cls_assignment.py.snap @@ -1,161 +1,176 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -self_or_cls_assignment.py:4:9: PLW0642 Reassigned `cls` variable in class method +PLW0642 Reassigned `cls` variable in class method + --> self_or_cls_assignment.py:4:9 | 2 | @classmethod 3 | def list_fruits(cls) -> None: 4 | cls = "apple" # PLW0642 - | ^^^ PLW0642 + | ^^^ 5 | cls: Fruit = "apple" # PLW0642 6 | cls += "orange" # OK, augmented assignments are ignored | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:5:9: PLW0642 Reassigned `cls` variable in class method +PLW0642 Reassigned `cls` variable in class method + --> self_or_cls_assignment.py:5:9 | 3 | def list_fruits(cls) -> None: 4 | cls = "apple" # PLW0642 5 | cls: Fruit = "apple" # PLW0642 - | ^^^ PLW0642 + | ^^^ 6 | cls += "orange" # OK, augmented assignments are ignored 7 | *cls = "banana" # PLW0642 | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:7:10: PLW0642 Reassigned `cls` variable in class method +PLW0642 Reassigned `cls` variable in class method + --> self_or_cls_assignment.py:7:10 | 5 | cls: Fruit = "apple" # PLW0642 6 | cls += "orange" # OK, augmented assignments are ignored 7 | *cls = "banana" # PLW0642 - | ^^^ PLW0642 + | ^^^ 8 | cls, blah = "apple", "orange" # PLW0642 9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642 | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:8:9: PLW0642 Reassigned `cls` variable in class method +PLW0642 Reassigned `cls` variable in class method + --> self_or_cls_assignment.py:8:9 | 6 | cls += "orange" # OK, augmented assignments are ignored 7 | *cls = "banana" # PLW0642 8 | cls, blah = "apple", "orange" # PLW0642 - | ^^^ PLW0642 + | ^^^ 9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642 10 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642 | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:9:16: PLW0642 Reassigned `cls` variable in class method +PLW0642 Reassigned `cls` variable in class method + --> self_or_cls_assignment.py:9:16 | 7 | *cls = "banana" # PLW0642 8 | cls, blah = "apple", "orange" # PLW0642 9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642 - | ^^^ PLW0642 + | ^^^ 10 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642 | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:10:16: PLW0642 Reassigned `cls` variable in class method +PLW0642 Reassigned `cls` variable in class method + --> self_or_cls_assignment.py:10:16 | 8 | cls, blah = "apple", "orange" # PLW0642 9 | blah, (cls, blah2) = "apple", ("orange", "banana") # PLW0642 10 | blah, [cls, blah2] = "apple", ("orange", "banana") # PLW0642 - | ^^^ PLW0642 + | ^^^ 11 | 12 | @classmethod | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:14:9: PLW0642 Reassigned `cls` variable in class method +PLW0642 Reassigned `cls` variable in class method + --> self_or_cls_assignment.py:14:9 | 12 | @classmethod 13 | def add_fruits(cls, fruits, /) -> None: 14 | cls = fruits # PLW0642 - | ^^^ PLW0642 + | ^^^ 15 | 16 | def print_color(self) -> None: | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:17:9: PLW0642 Reassigned `self` variable in instance method +PLW0642 Reassigned `self` variable in instance method + --> self_or_cls_assignment.py:17:9 | 16 | def print_color(self) -> None: 17 | self = "red" # PLW0642 - | ^^^^ PLW0642 + | ^^^^ 18 | self: Self = "red" # PLW0642 19 | self += "blue" # OK, augmented assignments are ignored | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:18:9: PLW0642 Reassigned `self` variable in instance method +PLW0642 Reassigned `self` variable in instance method + --> self_or_cls_assignment.py:18:9 | 16 | def print_color(self) -> None: 17 | self = "red" # PLW0642 18 | self: Self = "red" # PLW0642 - | ^^^^ PLW0642 + | ^^^^ 19 | self += "blue" # OK, augmented assignments are ignored 20 | *self = "blue" # PLW0642 | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:20:10: PLW0642 Reassigned `self` variable in instance method +PLW0642 Reassigned `self` variable in instance method + --> self_or_cls_assignment.py:20:10 | 18 | self: Self = "red" # PLW0642 19 | self += "blue" # OK, augmented assignments are ignored 20 | *self = "blue" # PLW0642 - | ^^^^ PLW0642 + | ^^^^ 21 | self, blah = "red", "blue" # PLW0642 22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642 | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:21:9: PLW0642 Reassigned `self` variable in instance method +PLW0642 Reassigned `self` variable in instance method + --> self_or_cls_assignment.py:21:9 | 19 | self += "blue" # OK, augmented assignments are ignored 20 | *self = "blue" # PLW0642 21 | self, blah = "red", "blue" # PLW0642 - | ^^^^ PLW0642 + | ^^^^ 22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642 23 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642 | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:22:16: PLW0642 Reassigned `self` variable in instance method +PLW0642 Reassigned `self` variable in instance method + --> self_or_cls_assignment.py:22:16 | 20 | *self = "blue" # PLW0642 21 | self, blah = "red", "blue" # PLW0642 22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642 - | ^^^^ PLW0642 + | ^^^^ 23 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642 | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:23:16: PLW0642 Reassigned `self` variable in instance method +PLW0642 Reassigned `self` variable in instance method + --> self_or_cls_assignment.py:23:16 | 21 | self, blah = "red", "blue" # PLW0642 22 | blah, (self, blah2) = "apple", ("orange", "banana") # PLW0642 23 | blah, [self, blah2] = "apple", ("orange", "banana") # PLW0642 - | ^^^^ PLW0642 + | ^^^^ 24 | 25 | def print_color(self, color, /) -> None: | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:26:9: PLW0642 Reassigned `self` variable in instance method +PLW0642 Reassigned `self` variable in instance method + --> self_or_cls_assignment.py:26:9 | 25 | def print_color(self, color, /) -> None: 26 | self = color - | ^^^^ PLW0642 + | ^^^^ 27 | 28 | def ok(self) -> None: | - = help: Consider using a different variable name +help: Consider using a different variable name -self_or_cls_assignment.py:50:9: PLW0642 Reassigned `cls` variable in `__new__` method +PLW0642 Reassigned `cls` variable in `__new__` method + --> self_or_cls_assignment.py:50:9 | 48 | class Foo: 49 | def __new__(cls): 50 | cls = "apple" # PLW0642 - | ^^^ PLW0642 + | ^^^ | - = help: Consider using a different variable name +help: Consider using a different variable name diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0711_binary_op_exception.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0711_binary_op_exception.py.snap index d0f7bf9c11..ae462b688f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0711_binary_op_exception.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0711_binary_op_exception.py.snap @@ -1,21 +1,22 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -binary_op_exception.py:3:8: PLW0711 Exception to catch is the result of a binary `or` operation +PLW0711 Exception to catch is the result of a binary `or` operation + --> binary_op_exception.py:3:8 | 1 | try: 2 | 1 / 0 3 | except ZeroDivisionError or ValueError as e: # [binary-op-exception] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0711 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | pass | -binary_op_exception.py:8:8: PLW0711 Exception to catch is the result of a binary `and` operation +PLW0711 Exception to catch is the result of a binary `and` operation + --> binary_op_exception.py:8:8 | 6 | try: 7 | raise ValueError 8 | except ZeroDivisionError and ValueError as e: # [binary-op-exception] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0711 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | print(e) | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1501_bad_open_mode.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1501_bad_open_mode.py.snap index 6c19b91ebe..0566155cc3 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1501_bad_open_mode.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1501_bad_open_mode.py.snap @@ -1,118 +1,130 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -bad_open_mode.py:11:12: PLW1501 `rwx` is not a valid mode for `open` +PLW1501 `rwx` is not a valid mode for `open` + --> bad_open_mode.py:11:12 | 9 | open(NAME, "+r", encoding="utf-8") 10 | open(NAME, "xb") 11 | open(NAME, "rwx") # [bad-open-mode] - | ^^^^^ PLW1501 + | ^^^^^ 12 | open(NAME, mode="rwx") # [bad-open-mode] 13 | open(NAME, "rwx", encoding="utf-8") # [bad-open-mode] | -bad_open_mode.py:12:17: PLW1501 `rwx` is not a valid mode for `open` +PLW1501 `rwx` is not a valid mode for `open` + --> bad_open_mode.py:12:17 | 10 | open(NAME, "xb") 11 | open(NAME, "rwx") # [bad-open-mode] 12 | open(NAME, mode="rwx") # [bad-open-mode] - | ^^^^^ PLW1501 + | ^^^^^ 13 | open(NAME, "rwx", encoding="utf-8") # [bad-open-mode] 14 | open(NAME, "rr", encoding="utf-8") # [bad-open-mode] | -bad_open_mode.py:13:12: PLW1501 `rwx` is not a valid mode for `open` +PLW1501 `rwx` is not a valid mode for `open` + --> bad_open_mode.py:13:12 | 11 | open(NAME, "rwx") # [bad-open-mode] 12 | open(NAME, mode="rwx") # [bad-open-mode] 13 | open(NAME, "rwx", encoding="utf-8") # [bad-open-mode] - | ^^^^^ PLW1501 + | ^^^^^ 14 | open(NAME, "rr", encoding="utf-8") # [bad-open-mode] 15 | open(NAME, "+", encoding="utf-8") # [bad-open-mode] | -bad_open_mode.py:14:12: PLW1501 `rr` is not a valid mode for `open` +PLW1501 `rr` is not a valid mode for `open` + --> bad_open_mode.py:14:12 | 12 | open(NAME, mode="rwx") # [bad-open-mode] 13 | open(NAME, "rwx", encoding="utf-8") # [bad-open-mode] 14 | open(NAME, "rr", encoding="utf-8") # [bad-open-mode] - | ^^^^ PLW1501 + | ^^^^ 15 | open(NAME, "+", encoding="utf-8") # [bad-open-mode] 16 | open(NAME, "xw", encoding="utf-8") # [bad-open-mode] | -bad_open_mode.py:15:12: PLW1501 `+` is not a valid mode for `open` +PLW1501 `+` is not a valid mode for `open` + --> bad_open_mode.py:15:12 | 13 | open(NAME, "rwx", encoding="utf-8") # [bad-open-mode] 14 | open(NAME, "rr", encoding="utf-8") # [bad-open-mode] 15 | open(NAME, "+", encoding="utf-8") # [bad-open-mode] - | ^^^ PLW1501 + | ^^^ 16 | open(NAME, "xw", encoding="utf-8") # [bad-open-mode] 17 | open(NAME, "ab+") | -bad_open_mode.py:16:12: PLW1501 `xw` is not a valid mode for `open` +PLW1501 `xw` is not a valid mode for `open` + --> bad_open_mode.py:16:12 | 14 | open(NAME, "rr", encoding="utf-8") # [bad-open-mode] 15 | open(NAME, "+", encoding="utf-8") # [bad-open-mode] 16 | open(NAME, "xw", encoding="utf-8") # [bad-open-mode] - | ^^^^ PLW1501 + | ^^^^ 17 | open(NAME, "ab+") 18 | open(NAME, "a+b") | -bad_open_mode.py:22:12: PLW1501 `Ua` is not a valid mode for `open` +PLW1501 `Ua` is not a valid mode for `open` + --> bad_open_mode.py:22:12 | 20 | open(NAME, "+rUb") 21 | open(NAME, "x+b") 22 | open(NAME, "Ua", encoding="utf-8") # [bad-open-mode] - | ^^^^ PLW1501 + | ^^^^ 23 | open(NAME, "Ur++", encoding="utf-8") # [bad-open-mode] 24 | open(NAME, "Ut", encoding="utf-8") | -bad_open_mode.py:23:12: PLW1501 `Ur++` is not a valid mode for `open` +PLW1501 `Ur++` is not a valid mode for `open` + --> bad_open_mode.py:23:12 | 21 | open(NAME, "x+b") 22 | open(NAME, "Ua", encoding="utf-8") # [bad-open-mode] 23 | open(NAME, "Ur++", encoding="utf-8") # [bad-open-mode] - | ^^^^^^ PLW1501 + | ^^^^^^ 24 | open(NAME, "Ut", encoding="utf-8") 25 | open(NAME, "Ubr") | -bad_open_mode.py:32:25: PLW1501 `rwx` is not a valid mode for `open` +PLW1501 `rwx` is not a valid mode for `open` + --> bad_open_mode.py:32:25 | 30 | pathlib.Path(NAME).open("wb") 31 | pathlib.Path(NAME).open(mode) 32 | pathlib.Path(NAME).open("rwx") # [bad-open-mode] - | ^^^^^ PLW1501 + | ^^^^^ 33 | pathlib.Path(NAME).open(mode="rwx") # [bad-open-mode] 34 | pathlib.Path(NAME).open("rwx", encoding="utf-8") # [bad-open-mode] | -bad_open_mode.py:33:30: PLW1501 `rwx` is not a valid mode for `open` +PLW1501 `rwx` is not a valid mode for `open` + --> bad_open_mode.py:33:30 | 31 | pathlib.Path(NAME).open(mode) 32 | pathlib.Path(NAME).open("rwx") # [bad-open-mode] 33 | pathlib.Path(NAME).open(mode="rwx") # [bad-open-mode] - | ^^^^^ PLW1501 + | ^^^^^ 34 | pathlib.Path(NAME).open("rwx", encoding="utf-8") # [bad-open-mode] | -bad_open_mode.py:34:25: PLW1501 `rwx` is not a valid mode for `open` +PLW1501 `rwx` is not a valid mode for `open` + --> bad_open_mode.py:34:25 | 32 | pathlib.Path(NAME).open("rwx") # [bad-open-mode] 33 | pathlib.Path(NAME).open(mode="rwx") # [bad-open-mode] 34 | pathlib.Path(NAME).open("rwx", encoding="utf-8") # [bad-open-mode] - | ^^^^^ PLW1501 + | ^^^^^ 35 | 36 | import builtins | -bad_open_mode.py:37:21: PLW1501 `Ua` is not a valid mode for `open` +PLW1501 `Ua` is not a valid mode for `open` + --> bad_open_mode.py:37:21 | 36 | import builtins 37 | builtins.open(NAME, "Ua", encoding="utf-8") - | ^^^^ PLW1501 + | ^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1507_shallow_copy_environ.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1507_shallow_copy_environ.py.snap index 45472379ba..02b7108617 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1507_shallow_copy_environ.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1507_shallow_copy_environ.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -shallow_copy_environ.py:4:14: PLW1507 [*] Shallow copy of `os.environ` via `copy.copy(os.environ)` +PLW1507 [*] Shallow copy of `os.environ` via `copy.copy(os.environ)` + --> shallow_copy_environ.py:4:14 | 2 | import os 3 | 4 | copied_env = copy.copy(os.environ) # [shallow-copy-environ] - | ^^^^^^^^^^^^^^^^^^^^^ PLW1507 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `os.environ.copy()` +help: Replace with `os.environ.copy()` ℹ Unsafe fix 1 1 | import copy @@ -20,14 +21,15 @@ shallow_copy_environ.py:4:14: PLW1507 [*] Shallow copy of `os.environ` via `copy 6 6 | 7 7 | # Test case where the proposed fix is wrong, i.e., unsafe fix -shallow_copy_environ.py:11:7: PLW1507 [*] Shallow copy of `os.environ` via `copy.copy(os.environ)` +PLW1507 [*] Shallow copy of `os.environ` via `copy.copy(os.environ)` + --> shallow_copy_environ.py:11:7 | 10 | os.environ["X"] = "0" 11 | env = copy.copy(os.environ) - | ^^^^^^^^^^^^^^^^^^^^^ PLW1507 + | ^^^^^^^^^^^^^^^^^^^^^ 12 | os.environ["X"] = "1" | - = help: Replace with `os.environ.copy()` +help: Replace with `os.environ.copy()` ℹ Unsafe fix 8 8 | # Ref: https://github.com/astral-sh/ruff/issues/16274#event-16423475135 diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap index 0ad2917d0c..b716eaf3f0 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap @@ -1,62 +1,68 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -invalid_envvar_default.py:3:29: PLW1508 Invalid type for environment variable default; expected `str` or `None` +PLW1508 Invalid type for environment variable default; expected `str` or `None` + --> invalid_envvar_default.py:3:29 | 1 | import os 2 | 3 | tempVar = os.getenv("TEST", 12) # [invalid-envvar-default] - | ^^ PLW1508 + | ^^ 4 | goodVar = os.getenv("TESTING", None) 5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] | -invalid_envvar_default.py:5:31: PLW1508 Invalid type for environment variable default; expected `str` or `None` +PLW1508 Invalid type for environment variable default; expected `str` or `None` + --> invalid_envvar_default.py:5:31 | 3 | tempVar = os.getenv("TEST", 12) # [invalid-envvar-default] 4 | goodVar = os.getenv("TESTING", None) 5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] - | ^^^^^^^^ PLW1508 + | ^^^^^^^^ 6 | print(os.getenv("TEST", False)) # [invalid-envvar-default] 7 | os.getenv("AA", "GOOD") | -invalid_envvar_default.py:6:25: PLW1508 Invalid type for environment variable default; expected `str` or `None` +PLW1508 Invalid type for environment variable default; expected `str` or `None` + --> invalid_envvar_default.py:6:25 | 4 | goodVar = os.getenv("TESTING", None) 5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] 6 | print(os.getenv("TEST", False)) # [invalid-envvar-default] - | ^^^^^ PLW1508 + | ^^^^^ 7 | os.getenv("AA", "GOOD") 8 | os.getenv("AA", f"GOOD") | -invalid_envvar_default.py:10:17: PLW1508 Invalid type for environment variable default; expected `str` or `None` +PLW1508 Invalid type for environment variable default; expected `str` or `None` + --> invalid_envvar_default.py:10:17 | 8 | os.getenv("AA", f"GOOD") 9 | os.getenv("AA", "GOOD" + "BAR") 10 | os.getenv("AA", "GOOD" + 1) - | ^^^^^^^^^^ PLW1508 + | ^^^^^^^^^^ 11 | os.getenv("AA", "GOOD %s" % "BAR") 12 | os.getenv("B", Z) | -invalid_envvar_default.py:14:17: PLW1508 Invalid type for environment variable default; expected `str` or `None` +PLW1508 Invalid type for environment variable default; expected `str` or `None` + --> invalid_envvar_default.py:14:17 | 12 | os.getenv("B", Z) 13 | os.getenv("AA", "GOOD" if Z else "BAR") 14 | os.getenv("AA", 1 if Z else "BAR") # [invalid-envvar-default] - | ^^^^^^^^^^^^^^^^^ PLW1508 + | ^^^^^^^^^^^^^^^^^ 15 | os.environ.get("TEST", 12) # [invalid-envvar-default] 16 | os.environ.get("TEST", "AA" * 12) | -invalid_envvar_default.py:15:24: PLW1508 Invalid type for environment variable default; expected `str` or `None` +PLW1508 Invalid type for environment variable default; expected `str` or `None` + --> invalid_envvar_default.py:15:24 | 13 | os.getenv("AA", "GOOD" if Z else "BAR") 14 | os.getenv("AA", 1 if Z else "BAR") # [invalid-envvar-default] 15 | os.environ.get("TEST", 12) # [invalid-envvar-default] - | ^^ PLW1508 + | ^^ 16 | os.environ.get("TEST", "AA" * 12) 17 | os.environ.get("TEST", 13 * "AA") | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap index 9918c300e9..676fdb021e 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -subprocess_popen_preexec_fn.py:9:18: PLW1509 `preexec_fn` argument is unsafe when using threads +PLW1509 `preexec_fn` argument is unsafe when using threads + --> subprocess_popen_preexec_fn.py:9:18 | 8 | # Errors. 9 | subprocess.Popen(preexec_fn=foo) - | ^^^^^^^^^^^^^^ PLW1509 + | ^^^^^^^^^^^^^^ 10 | subprocess.Popen(["ls"], preexec_fn=foo) 11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) | -subprocess_popen_preexec_fn.py:10:26: PLW1509 `preexec_fn` argument is unsafe when using threads +PLW1509 `preexec_fn` argument is unsafe when using threads + --> subprocess_popen_preexec_fn.py:10:26 | 8 | # Errors. 9 | subprocess.Popen(preexec_fn=foo) 10 | subprocess.Popen(["ls"], preexec_fn=foo) - | ^^^^^^^^^^^^^^ PLW1509 + | ^^^^^^^^^^^^^^ 11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) 12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) | -subprocess_popen_preexec_fn.py:11:18: PLW1509 `preexec_fn` argument is unsafe when using threads +PLW1509 `preexec_fn` argument is unsafe when using threads + --> subprocess_popen_preexec_fn.py:11:18 | 9 | subprocess.Popen(preexec_fn=foo) 10 | subprocess.Popen(["ls"], preexec_fn=foo) 11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1509 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) | -subprocess_popen_preexec_fn.py:12:26: PLW1509 `preexec_fn` argument is unsafe when using threads +PLW1509 `preexec_fn` argument is unsafe when using threads + --> subprocess_popen_preexec_fn.py:12:26 | 10 | subprocess.Popen(["ls"], preexec_fn=foo) 11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) 12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1509 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | # Non-errors. | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap index b0d1645a5d..4d980923ac 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -subprocess_run_without_check.py:4:1: PLW1510 [*] `subprocess.run` without explicit `check` argument +PLW1510 [*] `subprocess.run` without explicit `check` argument + --> subprocess_run_without_check.py:4:1 | 3 | # Errors. 4 | subprocess.run("ls") - | ^^^^^^^^^^^^^^ PLW1510 + | ^^^^^^^^^^^^^^ 5 | subprocess.run("ls", shell=True) 6 | subprocess.run( | - = help: Add explicit `check=False` +help: Add explicit `check=False` ℹ Safe fix 1 1 | import subprocess @@ -21,16 +22,17 @@ subprocess_run_without_check.py:4:1: PLW1510 [*] `subprocess.run` without explic 6 6 | subprocess.run( 7 7 | ["ls"], -subprocess_run_without_check.py:5:1: PLW1510 [*] `subprocess.run` without explicit `check` argument +PLW1510 [*] `subprocess.run` without explicit `check` argument + --> subprocess_run_without_check.py:5:1 | 3 | # Errors. 4 | subprocess.run("ls") 5 | subprocess.run("ls", shell=True) - | ^^^^^^^^^^^^^^ PLW1510 + | ^^^^^^^^^^^^^^ 6 | subprocess.run( 7 | ["ls"], | - = help: Add explicit `check=False` +help: Add explicit `check=False` ℹ Safe fix 2 2 | @@ -42,16 +44,17 @@ subprocess_run_without_check.py:5:1: PLW1510 [*] `subprocess.run` without explic 7 7 | ["ls"], 8 8 | shell=False, -subprocess_run_without_check.py:6:1: PLW1510 [*] `subprocess.run` without explicit `check` argument +PLW1510 [*] `subprocess.run` without explicit `check` argument + --> subprocess_run_without_check.py:6:1 | 4 | subprocess.run("ls") 5 | subprocess.run("ls", shell=True) 6 | subprocess.run( - | ^^^^^^^^^^^^^^ PLW1510 + | ^^^^^^^^^^^^^^ 7 | ["ls"], 8 | shell=False, | - = help: Add explicit `check=False` +help: Add explicit `check=False` ℹ Safe fix 5 5 | subprocess.run("ls", shell=True) @@ -63,16 +66,17 @@ subprocess_run_without_check.py:6:1: PLW1510 [*] `subprocess.run` without explic 10 10 | subprocess.run(["ls"], **kwargs) 11 11 | -subprocess_run_without_check.py:10:1: PLW1510 [*] `subprocess.run` without explicit `check` argument +PLW1510 [*] `subprocess.run` without explicit `check` argument + --> subprocess_run_without_check.py:10:1 | 8 | shell=False, 9 | ) 10 | subprocess.run(["ls"], **kwargs) - | ^^^^^^^^^^^^^^ PLW1510 + | ^^^^^^^^^^^^^^ 11 | 12 | # Non-errors. | - = help: Add explicit `check=False` +help: Add explicit `check=False` ℹ Unsafe fix 7 7 | ["ls"], diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap index c67477849c..d8fd1c6d90 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1514_unspecified_encoding.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -unspecified_encoding.py:8:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:8:1 | 7 | # Errors. 8 | open("test.txt") - | ^^^^ PLW1514 + | ^^^^ 9 | io.TextIOWrapper(io.FileIO("test.txt")) 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 5 5 | import codecs @@ -21,16 +22,17 @@ unspecified_encoding.py:8:1: PLW1514 [*] `open` in text mode without explicit `e 10 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) 11 11 | tempfile.NamedTemporaryFile("w") -unspecified_encoding.py:9:1: PLW1514 [*] `io.TextIOWrapper` without explicit `encoding` argument +PLW1514 [*] `io.TextIOWrapper` without explicit `encoding` argument + --> unspecified_encoding.py:9:1 | 7 | # Errors. 8 | open("test.txt") 9 | io.TextIOWrapper(io.FileIO("test.txt")) - | ^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^ 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) 11 | tempfile.NamedTemporaryFile("w") | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 6 6 | @@ -42,16 +44,17 @@ unspecified_encoding.py:9:1: PLW1514 [*] `io.TextIOWrapper` without explicit `en 11 11 | tempfile.NamedTemporaryFile("w") 12 12 | tempfile.TemporaryFile("w") -unspecified_encoding.py:10:1: PLW1514 [*] `io.TextIOWrapper` without explicit `encoding` argument +PLW1514 [*] `io.TextIOWrapper` without explicit `encoding` argument + --> unspecified_encoding.py:10:1 | 8 | open("test.txt") 9 | io.TextIOWrapper(io.FileIO("test.txt")) 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) - | ^^^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^^^ 11 | tempfile.NamedTemporaryFile("w") 12 | tempfile.TemporaryFile("w") | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 7 7 | # Errors. @@ -63,16 +66,17 @@ unspecified_encoding.py:10:1: PLW1514 [*] `io.TextIOWrapper` without explicit `e 12 12 | tempfile.TemporaryFile("w") 13 13 | codecs.open("test.txt") -unspecified_encoding.py:11:1: PLW1514 [*] `tempfile.NamedTemporaryFile` in text mode without explicit `encoding` argument +PLW1514 [*] `tempfile.NamedTemporaryFile` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:11:1 | 9 | io.TextIOWrapper(io.FileIO("test.txt")) 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) 11 | tempfile.NamedTemporaryFile("w") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | tempfile.TemporaryFile("w") 13 | codecs.open("test.txt") | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 8 8 | open("test.txt") @@ -84,16 +88,17 @@ unspecified_encoding.py:11:1: PLW1514 [*] `tempfile.NamedTemporaryFile` in text 13 13 | codecs.open("test.txt") 14 14 | tempfile.SpooledTemporaryFile(0, "w") -unspecified_encoding.py:12:1: PLW1514 [*] `tempfile.TemporaryFile` in text mode without explicit `encoding` argument +PLW1514 [*] `tempfile.TemporaryFile` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:12:1 | 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) 11 | tempfile.NamedTemporaryFile("w") 12 | tempfile.TemporaryFile("w") - | ^^^^^^^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^^^^^^^ 13 | codecs.open("test.txt") 14 | tempfile.SpooledTemporaryFile(0, "w") | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 9 9 | io.TextIOWrapper(io.FileIO("test.txt")) @@ -105,15 +110,16 @@ unspecified_encoding.py:12:1: PLW1514 [*] `tempfile.TemporaryFile` in text mode 14 14 | tempfile.SpooledTemporaryFile(0, "w") 15 15 | -unspecified_encoding.py:13:1: PLW1514 [*] `codecs.open` in text mode without explicit `encoding` argument +PLW1514 [*] `codecs.open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:13:1 | 11 | tempfile.NamedTemporaryFile("w") 12 | tempfile.TemporaryFile("w") 13 | codecs.open("test.txt") - | ^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^ 14 | tempfile.SpooledTemporaryFile(0, "w") | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 10 10 | hugo.TextIOWrapper(hugo.FileIO("test.txt")) @@ -125,16 +131,17 @@ unspecified_encoding.py:13:1: PLW1514 [*] `codecs.open` in text mode without exp 15 15 | 16 16 | # Non-errors. -unspecified_encoding.py:14:1: PLW1514 [*] `tempfile.SpooledTemporaryFile` in text mode without explicit `encoding` argument +PLW1514 [*] `tempfile.SpooledTemporaryFile` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:14:1 | 12 | tempfile.TemporaryFile("w") 13 | codecs.open("test.txt") 14 | tempfile.SpooledTemporaryFile(0, "w") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | # Non-errors. | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 11 11 | tempfile.NamedTemporaryFile("w") @@ -146,16 +153,17 @@ unspecified_encoding.py:14:1: PLW1514 [*] `tempfile.SpooledTemporaryFile` in tex 16 16 | # Non-errors. 17 17 | open("test.txt", encoding="utf-8") -unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:46:1 | 44 | tempfile.SpooledTemporaryFile(0, ) 45 | 46 | open("test.txt",) - | ^^^^ PLW1514 + | ^^^^ 47 | open() 48 | open( | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 43 43 | tempfile.SpooledTemporaryFile(0, "wb") @@ -167,15 +175,16 @@ unspecified_encoding.py:46:1: PLW1514 [*] `open` in text mode without explicit ` 48 48 | open( 49 49 | "test.txt", # comment -unspecified_encoding.py:47:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:47:1 | 46 | open("test.txt",) 47 | open() - | ^^^^ PLW1514 + | ^^^^ 48 | open( 49 | "test.txt", # comment | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 44 44 | tempfile.SpooledTemporaryFile(0, ) @@ -187,16 +196,17 @@ unspecified_encoding.py:47:1: PLW1514 [*] `open` in text mode without explicit ` 49 49 | "test.txt", # comment 50 50 | ) -unspecified_encoding.py:48:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:48:1 | 46 | open("test.txt",) 47 | open() 48 | open( - | ^^^^ PLW1514 + | ^^^^ 49 | "test.txt", # comment 50 | ) | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 46 46 | open("test.txt",) @@ -208,16 +218,17 @@ unspecified_encoding.py:48:1: PLW1514 [*] `open` in text mode without explicit ` 51 51 | open( 52 52 | "test.txt", -unspecified_encoding.py:51:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:51:1 | 49 | "test.txt", # comment 50 | ) 51 | open( - | ^^^^ PLW1514 + | ^^^^ 52 | "test.txt", 53 | # comment | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 49 49 | "test.txt", # comment @@ -229,16 +240,17 @@ unspecified_encoding.py:51:1: PLW1514 [*] `open` in text mode without explicit ` 54 54 | ) 55 55 | open(("test.txt"),) -unspecified_encoding.py:55:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:55:1 | 53 | # comment 54 | ) 55 | open(("test.txt"),) - | ^^^^ PLW1514 + | ^^^^ 56 | open( 57 | ("test.txt"), # comment | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 52 52 | "test.txt", @@ -250,16 +262,17 @@ unspecified_encoding.py:55:1: PLW1514 [*] `open` in text mode without explicit ` 57 57 | ("test.txt"), # comment 58 58 | ) -unspecified_encoding.py:56:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:56:1 | 54 | ) 55 | open(("test.txt"),) 56 | open( - | ^^^^ PLW1514 + | ^^^^ 57 | ("test.txt"), # comment 58 | ) | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 54 54 | ) @@ -271,16 +284,17 @@ unspecified_encoding.py:56:1: PLW1514 [*] `open` in text mode without explicit ` 59 59 | open( 60 60 | ("test.txt"), -unspecified_encoding.py:59:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:59:1 | 57 | ("test.txt"), # comment 58 | ) 59 | open( - | ^^^^ PLW1514 + | ^^^^ 60 | ("test.txt"), 61 | # comment | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 57 57 | ("test.txt"), # comment @@ -292,16 +306,17 @@ unspecified_encoding.py:59:1: PLW1514 [*] `open` in text mode without explicit ` 62 62 | ) 63 63 | -unspecified_encoding.py:64:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:64:1 | 62 | ) 63 | 64 | open((("test.txt")),) - | ^^^^ PLW1514 + | ^^^^ 65 | open( 66 | (("test.txt")), # comment | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 61 61 | # comment @@ -313,15 +328,16 @@ unspecified_encoding.py:64:1: PLW1514 [*] `open` in text mode without explicit ` 66 66 | (("test.txt")), # comment 67 67 | ) -unspecified_encoding.py:65:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:65:1 | 64 | open((("test.txt")),) 65 | open( - | ^^^^ PLW1514 + | ^^^^ 66 | (("test.txt")), # comment 67 | ) | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 63 63 | @@ -333,16 +349,17 @@ unspecified_encoding.py:65:1: PLW1514 [*] `open` in text mode without explicit ` 68 68 | open( 69 69 | (("test.txt")), -unspecified_encoding.py:68:1: PLW1514 [*] `open` in text mode without explicit `encoding` argument +PLW1514 [*] `open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:68:1 | 66 | (("test.txt")), # comment 67 | ) 68 | open( - | ^^^^ PLW1514 + | ^^^^ 69 | (("test.txt")), 70 | # comment | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 66 66 | (("test.txt")), # comment @@ -354,15 +371,16 @@ unspecified_encoding.py:68:1: PLW1514 [*] `open` in text mode without explicit ` 71 71 | ) 72 72 | -unspecified_encoding.py:77:1: PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument +PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:77:1 | 76 | # Errors. 77 | Path("foo.txt").open() - | ^^^^^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^^^^^ 78 | Path("foo.txt").open("w") 79 | text = Path("foo.txt").read_text() | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 74 74 | from pathlib import Path @@ -374,16 +392,17 @@ unspecified_encoding.py:77:1: PLW1514 [*] `pathlib.Path(...).open` in text mode 79 79 | text = Path("foo.txt").read_text() 80 80 | Path("foo.txt").write_text(text) -unspecified_encoding.py:78:1: PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument +PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:78:1 | 76 | # Errors. 77 | Path("foo.txt").open() 78 | Path("foo.txt").open("w") - | ^^^^^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^^^^^ 79 | text = Path("foo.txt").read_text() 80 | Path("foo.txt").write_text(text) | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 75 75 | @@ -395,15 +414,16 @@ unspecified_encoding.py:78:1: PLW1514 [*] `pathlib.Path(...).open` in text mode 80 80 | Path("foo.txt").write_text(text) 81 81 | -unspecified_encoding.py:79:8: PLW1514 [*] `pathlib.Path(...).read_text` without explicit `encoding` argument +PLW1514 [*] `pathlib.Path(...).read_text` without explicit `encoding` argument + --> unspecified_encoding.py:79:8 | 77 | Path("foo.txt").open() 78 | Path("foo.txt").open("w") 79 | text = Path("foo.txt").read_text() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 80 | Path("foo.txt").write_text(text) | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 76 76 | # Errors. @@ -415,16 +435,17 @@ unspecified_encoding.py:79:8: PLW1514 [*] `pathlib.Path(...).read_text` without 81 81 | 82 82 | # Non-errors. -unspecified_encoding.py:80:1: PLW1514 [*] `pathlib.Path(...).write_text` without explicit `encoding` argument +PLW1514 [*] `pathlib.Path(...).write_text` without explicit `encoding` argument + --> unspecified_encoding.py:80:1 | 78 | Path("foo.txt").open("w") 79 | text = Path("foo.txt").read_text() 80 | Path("foo.txt").write_text(text) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1514 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 81 | 82 | # Non-errors. | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 77 77 | Path("foo.txt").open() @@ -436,16 +457,17 @@ unspecified_encoding.py:80:1: PLW1514 [*] `pathlib.Path(...).write_text` without 82 82 | # Non-errors. 83 83 | Path("foo.txt").open(encoding="utf-8") -unspecified_encoding.py:96:1: PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument +PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:96:1 | 94 | # https://github.com/astral-sh/ruff/issues/19294 95 | x = Path("foo.txt") 96 | x.open() - | ^^^^^^ PLW1514 + | ^^^^^^ 97 | 98 | # https://github.com/astral-sh/ruff/issues/18107 | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 93 93 | @@ -457,14 +479,15 @@ unspecified_encoding.py:96:1: PLW1514 [*] `pathlib.Path(...).open` in text mode 98 98 | # https://github.com/astral-sh/ruff/issues/18107 99 99 | codecs.open("plw1514.py", "r", "utf-8").close() # this is fine -unspecified_encoding.py:105:10: PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument +PLW1514 [*] `pathlib.Path(...).open` in text mode without explicit `encoding` argument + --> unspecified_encoding.py:105:10 | 104 | def format_file(file: Path): 105 | with file.open() as f: - | ^^^^^^^^^ PLW1514 + | ^^^^^^^^^ 106 | contents = f.read() | - = help: Add explicit `encoding` argument +help: Add explicit `encoding` argument ℹ Unsafe fix 102 102 | from pathlib import Path diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap index 572aabdcba..6197da46d6 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap @@ -1,132 +1,148 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -eq_without_hash.py:3:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:3:7 | 1 | ### Errors 2 | 3 | class Person: - | ^^^^^^ PLW1641 + | ^^^^^^ 4 | def __init__(self): 5 | self.name = "monty" | -eq_without_hash.py:11:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:11:7 | 11 | class MaybeEqIf: - | ^^^^^^^^^ PLW1641 + | ^^^^^^^^^ 12 | if ...: 13 | def __eq__(self, other): ... | -eq_without_hash.py:16:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:16:7 | 16 | class MaybeEqElif: - | ^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^ 17 | if ...: 18 | ... | -eq_without_hash.py:23:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:23:7 | 23 | class MaybeEqElse: - | ^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^ 24 | if ...: 25 | ... | -eq_without_hash.py:30:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:30:7 | 30 | class MaybeEqWith: - | ^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^ 31 | with ...: 32 | def __eq__(self, other): ... | -eq_without_hash.py:35:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:35:7 | 35 | class MaybeEqFor: - | ^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^ 36 | for _ in ...: 37 | def __eq__(self, other): ... | -eq_without_hash.py:40:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:40:7 | 40 | class MaybeEqForElse: - | ^^^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^^^ 41 | for _ in ...: 42 | ... | -eq_without_hash.py:47:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:47:7 | 47 | class MaybeEqWhile: - | ^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^ 48 | while ...: 49 | def __eq__(self, other): ... | -eq_without_hash.py:52:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:52:7 | 52 | class MaybeEqWhileElse: - | ^^^^^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^^^^^ 53 | while ...: 54 | ... | -eq_without_hash.py:59:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:59:7 | 59 | class MaybeEqTry: - | ^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^ 60 | try: 61 | def __eq__(self, other): ... | -eq_without_hash.py:66:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:66:7 | 66 | class MaybeEqTryExcept: - | ^^^^^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^^^^^ 67 | try: 68 | ... | -eq_without_hash.py:73:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:73:7 | 73 | class MaybeEqTryExceptElse: - | ^^^^^^^^^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^^^^^^^^^ 74 | try: 75 | ... | -eq_without_hash.py:82:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:82:7 | 82 | class MaybeEqTryFinally: - | ^^^^^^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^^^^^^ 83 | try: 84 | ... | -eq_without_hash.py:89:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:89:7 | 89 | class MaybeEqMatchCase: - | ^^^^^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^^^^^ 90 | match ...: 91 | case int(): | -eq_without_hash.py:95:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:95:7 | 95 | class MaybeEqMatchCaseWildcard: - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 96 | match ...: 97 | case int(): ... | -eq_without_hash.py:102:7: PLW1641 Object does not implement `__hash__` method +PLW1641 Object does not implement `__hash__` method + --> eq_without_hash.py:102:7 | 102 | class MaybeEqDeeplyNested: - | ^^^^^^^^^^^^^^^^^^^ PLW1641 + | ^^^^^^^^^^^^^^^^^^^ 103 | if ...: 104 | ... | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2101_useless_with_lock.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2101_useless_with_lock.py.snap index 8f42ef34e9..df3f9cc915 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2101_useless_with_lock.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2101_useless_with_lock.py.snap @@ -1,99 +1,110 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -useless_with_lock.py:5:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:5:6 | 5 | with threading.Lock(): # [useless-with-lock] - | ^^^^^^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^^^^^^ 6 | ... | -useless_with_lock.py:8:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:8:6 | 6 | ... 7 | 8 | with Lock(): # [useless-with-lock] - | ^^^^^^ PLW2101 + | ^^^^^^ 9 | ... | -useless_with_lock.py:11:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:11:6 | 9 | ... 10 | 11 | with threading.Lock() as this_shouldnt_matter: # [useless-with-lock] - | ^^^^^^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^^^^^^ 12 | ... | -useless_with_lock.py:14:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:14:6 | 12 | ... 13 | 14 | with threading.RLock(): # [useless-with-lock] - | ^^^^^^^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^^^^^^^ 15 | ... | -useless_with_lock.py:17:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:17:6 | 15 | ... 16 | 17 | with RLock(): # [useless-with-lock] - | ^^^^^^^ PLW2101 + | ^^^^^^^ 18 | ... | -useless_with_lock.py:20:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:20:6 | 18 | ... 19 | 20 | with threading.Condition(): # [useless-with-lock] - | ^^^^^^^^^^^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^^^^^^^^^^^ 21 | ... | -useless_with_lock.py:23:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:23:6 | 21 | ... 22 | 23 | with Condition(): # [useless-with-lock] - | ^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^ 24 | ... | -useless_with_lock.py:26:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:26:6 | 24 | ... 25 | 26 | with threading.Semaphore(): # [useless-with-lock] - | ^^^^^^^^^^^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^^^^^^^^^^^ 27 | ... | -useless_with_lock.py:29:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:29:6 | 27 | ... 28 | 29 | with Semaphore(): # [useless-with-lock] - | ^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^ 30 | ... | -useless_with_lock.py:32:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:32:6 | 30 | ... 31 | 32 | with threading.BoundedSemaphore(): # [useless-with-lock] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | ... | -useless_with_lock.py:35:6: PLW2101 Threading lock directly created in `with` statement has no effect +PLW2101 Threading lock directly created in `with` statement has no effect + --> useless_with_lock.py:35:6 | 33 | ... 34 | 35 | with BoundedSemaphore(): # [useless-with-lock] - | ^^^^^^^^^^^^^^^^^^ PLW2101 + | ^^^^^^^^^^^^^^^^^^ 36 | ... | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap index 8bb2aff29e..4a37f5facd 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap @@ -1,250 +1,277 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -redefined_loop_name.py:6:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:6:9 | 4 | # For -> for, variable reused 5 | for i in []: 6 | for i in []: # error - | ^ PLW2901 + | ^ 7 | pass | -redefined_loop_name.py:11:9: PLW2901 `with` statement variable `i` overwritten by `for` loop target +PLW2901 `with` statement variable `i` overwritten by `for` loop target + --> redefined_loop_name.py:11:9 | 9 | # With -> for, variable reused 10 | with None as i: 11 | for i in []: # error - | ^ PLW2901 + | ^ 12 | pass | -redefined_loop_name.py:16:18: PLW2901 `for` loop variable `i` overwritten by `with` statement target +PLW2901 `for` loop variable `i` overwritten by `with` statement target + --> redefined_loop_name.py:16:18 | 14 | # For -> with, variable reused 15 | for i in []: 16 | with None as i: # error - | ^ PLW2901 + | ^ 17 | pass | -redefined_loop_name.py:21:18: PLW2901 Outer `with` statement variable `i` overwritten by inner `with` statement target +PLW2901 Outer `with` statement variable `i` overwritten by inner `with` statement target + --> redefined_loop_name.py:21:18 | 19 | # With -> with, variable reused 20 | with None as i: 21 | with None as i: # error - | ^ PLW2901 + | ^ 22 | pass | -redefined_loop_name.py:36:18: PLW2901 Outer `with` statement variable `i` overwritten by inner `with` statement target +PLW2901 Outer `with` statement variable `i` overwritten by inner `with` statement target + --> redefined_loop_name.py:36:18 | 34 | # Async with -> with, variable reused 35 | async with None as i: 36 | with None as i: # error - | ^ PLW2901 + | ^ 37 | pass | -redefined_loop_name.py:46:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:46:9 | 44 | # Async for -> for, variable reused 45 | async for i in []: 46 | for i in []: # error - | ^ PLW2901 + | ^ 47 | pass | -redefined_loop_name.py:52:13: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:52:13 | 50 | for i in []: 51 | for j in []: 52 | for i in []: # error - | ^ PLW2901 + | ^ 53 | pass | -redefined_loop_name.py:58:13: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:58:13 | 56 | for i in []: 57 | for j in []: 58 | for i in []: # error - | ^ PLW2901 + | ^ 59 | for j in []: # error 60 | pass | -redefined_loop_name.py:59:17: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target + --> redefined_loop_name.py:59:17 | 57 | for j in []: 58 | for i in []: # error 59 | for j in []: # error - | ^ PLW2901 + | ^ 60 | pass | -redefined_loop_name.py:67:5: PLW2901 `for` loop variable `i` overwritten by assignment target +PLW2901 `for` loop variable `i` overwritten by assignment target + --> redefined_loop_name.py:67:5 | 65 | i = cast(int, i) 66 | i = typing.cast(int, i) 67 | i = 5 # error - | ^ PLW2901 + | ^ 68 | 69 | # For -> augmented assignment | -redefined_loop_name.py:71:5: PLW2901 `for` loop variable `i` overwritten by assignment target +PLW2901 `for` loop variable `i` overwritten by assignment target + --> redefined_loop_name.py:71:5 | 69 | # For -> augmented assignment 70 | for i in []: 71 | i += 5 # error - | ^ PLW2901 + | ^ 72 | 73 | # For -> annotated assignment | -redefined_loop_name.py:75:5: PLW2901 `for` loop variable `i` overwritten by assignment target +PLW2901 `for` loop variable `i` overwritten by assignment target + --> redefined_loop_name.py:75:5 | 73 | # For -> annotated assignment 74 | for i in []: 75 | i: int = 5 # error - | ^ PLW2901 + | ^ 76 | 77 | # For -> annotated assignment without value | -redefined_loop_name.py:83:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:83:9 | 81 | # Async for -> for, variable reused 82 | async for i in []: 83 | for i in []: # error - | ^ PLW2901 + | ^ 84 | pass | -redefined_loop_name.py:88:15: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:88:15 | 86 | # For -> async for, variable reused 87 | for i in []: 88 | async for i in []: # error - | ^ PLW2901 + | ^ 89 | pass | -redefined_loop_name.py:93:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:93:9 | 91 | # For -> for, outer loop unpacks tuple 92 | for i, j in enumerate([]): 93 | for i in []: # error - | ^ PLW2901 + | ^ 94 | pass | -redefined_loop_name.py:98:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:98:9 | 96 | # For -> for, inner loop unpacks tuple 97 | for i in []: 98 | for i, j in enumerate([]): # error - | ^ PLW2901 + | ^ 99 | pass | -redefined_loop_name.py:103:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:103:9 | 101 | # For -> for, both loops unpack tuple 102 | for (i, (j, k)) in []: 103 | for i, j in enumerate([]): # two errors - | ^ PLW2901 + | ^ 104 | pass | -redefined_loop_name.py:103:12: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target + --> redefined_loop_name.py:103:12 | 101 | # For -> for, both loops unpack tuple 102 | for (i, (j, k)) in []: 103 | for i, j in enumerate([]): # two errors - | ^ PLW2901 + | ^ 104 | pass | -redefined_loop_name.py:120:9: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target + --> redefined_loop_name.py:120:9 | 118 | # For -> for, outer loop unpacks with asterisk 119 | for i, *j in []: 120 | for j in []: # error - | ^ PLW2901 + | ^ 121 | pass | -redefined_loop_name.py:137:13: PLW2901 `for` loop variable `i` overwritten by assignment target +PLW2901 `for` loop variable `i` overwritten by assignment target + --> redefined_loop_name.py:137:13 | 135 | def f(): 136 | for i in []: # no error 137 | i = 2 # error - | ^ PLW2901 + | ^ 138 | 139 | # For -> class definition -> for -> for | -redefined_loop_name.py:143:17: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target +PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + --> redefined_loop_name.py:143:17 | 141 | class A: 142 | for i in []: # no error 143 | for i in []: # error - | ^ PLW2901 + | ^ 144 | pass | -redefined_loop_name.py:158:5: PLW2901 `for` loop variable `a[0]` overwritten by assignment target +PLW2901 `for` loop variable `a[0]` overwritten by assignment target + --> redefined_loop_name.py:158:5 | 156 | # For target with subscript -> assignment 157 | for a[0] in []: 158 | a[0] = 2 # error - | ^^^^ PLW2901 + | ^^^^ 159 | a[1] = 2 # no error | -redefined_loop_name.py:163:5: PLW2901 `for` loop variable `a['i']` overwritten by assignment target +PLW2901 `for` loop variable `a['i']` overwritten by assignment target + --> redefined_loop_name.py:163:5 | 161 | # For target with subscript -> assignment 162 | for a['i'] in []: 163 | a['i'] = 2 # error - | ^^^^^^ PLW2901 + | ^^^^^^ 164 | a['j'] = 2 # no error | -redefined_loop_name.py:168:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target +PLW2901 `for` loop variable `a.i` overwritten by assignment target + --> redefined_loop_name.py:168:5 | 166 | # For target with attribute -> assignment 167 | for a.i in []: 168 | a.i = 2 # error - | ^^^ PLW2901 + | ^^^ 169 | a.j = 2 # no error | -redefined_loop_name.py:173:5: PLW2901 `for` loop variable `a.i.j` overwritten by assignment target +PLW2901 `for` loop variable `a.i.j` overwritten by assignment target + --> redefined_loop_name.py:173:5 | 171 | # For target with double nested attribute -> assignment 172 | for a.i.j in []: 173 | a.i.j = 2 # error - | ^^^^^ PLW2901 + | ^^^^^ 174 | a.j.i = 2 # no error | -redefined_loop_name.py:178:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target +PLW2901 `for` loop variable `a.i` overwritten by assignment target + --> redefined_loop_name.py:178:5 | 176 | # For target with attribute -> assignment with different spacing 177 | for a.i in []: 178 | a. i = 2 # error - | ^^^^ PLW2901 + | ^^^^ 179 | for a. i in []: 180 | a.i = 2 # error | -redefined_loop_name.py:180:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target +PLW2901 `for` loop variable `a.i` overwritten by assignment target + --> redefined_loop_name.py:180:5 | 178 | a. i = 2 # error 179 | for a. i in []: 180 | a.i = 2 # error - | ^^^ PLW2901 + | ^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap index 407fa4b92d..8be1c559ec 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap @@ -1,67 +1,74 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -bad_dunder_method_name.py:5:9: PLW3201 Dunder method `_init_` has no special meaning in Python 3 +PLW3201 Dunder method `_init_` has no special meaning in Python 3 + --> bad_dunder_method_name.py:5:9 | 4 | class Apples: 5 | def _init_(self): # [bad-dunder-name] - | ^^^^^^ PLW3201 + | ^^^^^^ 6 | pass | -bad_dunder_method_name.py:8:9: PLW3201 Dunder method `__hello__` has no special meaning in Python 3 +PLW3201 Dunder method `__hello__` has no special meaning in Python 3 + --> bad_dunder_method_name.py:8:9 | 6 | pass 7 | 8 | def __hello__(self): # [bad-dunder-name] - | ^^^^^^^^^ PLW3201 + | ^^^^^^^^^ 9 | print("hello") | -bad_dunder_method_name.py:11:9: PLW3201 Dunder method `__init_` has no special meaning in Python 3 +PLW3201 Dunder method `__init_` has no special meaning in Python 3 + --> bad_dunder_method_name.py:11:9 | 9 | print("hello") 10 | 11 | def __init_(self): # [bad-dunder-name] - | ^^^^^^^ PLW3201 + | ^^^^^^^ 12 | # author likely unintentionally misspelled the correct init dunder. 13 | pass | -bad_dunder_method_name.py:15:9: PLW3201 Dunder method `_init_` has no special meaning in Python 3 +PLW3201 Dunder method `_init_` has no special meaning in Python 3 + --> bad_dunder_method_name.py:15:9 | 13 | pass 14 | 15 | def _init_(self): # [bad-dunder-name] - | ^^^^^^ PLW3201 + | ^^^^^^ 16 | # author likely unintentionally misspelled the correct init dunder. 17 | pass | -bad_dunder_method_name.py:19:9: PLW3201 Dunder method `___neg__` has no special meaning in Python 3 +PLW3201 Dunder method `___neg__` has no special meaning in Python 3 + --> bad_dunder_method_name.py:19:9 | 17 | pass 18 | 19 | def ___neg__(self): # [bad-dunder-name] - | ^^^^^^^^ PLW3201 + | ^^^^^^^^ 20 | # author likely accidentally added an additional `_` 21 | pass | -bad_dunder_method_name.py:23:9: PLW3201 Dunder method `__inv__` has no special meaning in Python 3 +PLW3201 Dunder method `__inv__` has no special meaning in Python 3 + --> bad_dunder_method_name.py:23:9 | 21 | pass 22 | 23 | def __inv__(self): # [bad-dunder-name] - | ^^^^^^^ PLW3201 + | ^^^^^^^ 24 | # author likely meant to call the invert dunder method 25 | pass | -bad_dunder_method_name.py:98:9: PLW3201 Dunder method `__unicode__` has no special meaning in Python 3 +PLW3201 Dunder method `__unicode__` has no special meaning in Python 3 + --> bad_dunder_method_name.py:98:9 | 97 | # Removed with Python 3 98 | def __unicode__(self): - | ^^^^^^^^^^^ PLW3201 + | ^^^^^^^^^^^ 99 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap index 0afee2e286..9c0c63af9d 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -nested_min_max.py:2:1: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:2:1 | 1 | min(1, 2, 3) 2 | min(1, min(2, 3)) - | ^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^ 3 | min(1, min(2, min(3, 4))) 4 | min(1, foo("a", "b"), min(3, 4)) | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 1 1 | min(1, 2, 3) @@ -19,16 +20,17 @@ nested_min_max.py:2:1: PLW3301 [*] Nested `min` calls can be flattened 4 4 | min(1, foo("a", "b"), min(3, 4)) 5 5 | min(1, max(2, 3)) -nested_min_max.py:3:1: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:3:1 | 1 | min(1, 2, 3) 2 | min(1, min(2, 3)) 3 | min(1, min(2, min(3, 4))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | min(1, foo("a", "b"), min(3, 4)) 5 | min(1, max(2, 3)) | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 1 1 | min(1, 2, 3) @@ -39,16 +41,17 @@ nested_min_max.py:3:1: PLW3301 [*] Nested `min` calls can be flattened 5 5 | min(1, max(2, 3)) 6 6 | max(1, 2, 3) -nested_min_max.py:3:8: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:3:8 | 1 | min(1, 2, 3) 2 | min(1, min(2, 3)) 3 | min(1, min(2, min(3, 4))) - | ^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^ 4 | min(1, foo("a", "b"), min(3, 4)) 5 | min(1, max(2, 3)) | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 1 1 | min(1, 2, 3) @@ -59,16 +62,17 @@ nested_min_max.py:3:8: PLW3301 [*] Nested `min` calls can be flattened 5 5 | min(1, max(2, 3)) 6 6 | max(1, 2, 3) -nested_min_max.py:4:1: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:4:1 | 2 | min(1, min(2, 3)) 3 | min(1, min(2, min(3, 4))) 4 | min(1, foo("a", "b"), min(3, 4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | min(1, max(2, 3)) 6 | max(1, 2, 3) | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 1 1 | min(1, 2, 3) @@ -80,16 +84,17 @@ nested_min_max.py:4:1: PLW3301 [*] Nested `min` calls can be flattened 6 6 | max(1, 2, 3) 7 7 | max(1, max(2, 3)) -nested_min_max.py:7:1: PLW3301 [*] Nested `max` calls can be flattened +PLW3301 [*] Nested `max` calls can be flattened + --> nested_min_max.py:7:1 | 5 | min(1, max(2, 3)) 6 | max(1, 2, 3) 7 | max(1, max(2, 3)) - | ^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^ 8 | max(1, max(2, max(3, 4))) 9 | max(1, foo("a", "b"), max(3, 4)) | - = help: Flatten nested `max` calls +help: Flatten nested `max` calls ℹ Unsafe fix 4 4 | min(1, foo("a", "b"), min(3, 4)) @@ -101,15 +106,16 @@ nested_min_max.py:7:1: PLW3301 [*] Nested `max` calls can be flattened 9 9 | max(1, foo("a", "b"), max(3, 4)) 10 10 | -nested_min_max.py:8:1: PLW3301 [*] Nested `max` calls can be flattened +PLW3301 [*] Nested `max` calls can be flattened + --> nested_min_max.py:8:1 | 6 | max(1, 2, 3) 7 | max(1, max(2, 3)) 8 | max(1, max(2, max(3, 4))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | max(1, foo("a", "b"), max(3, 4)) | - = help: Flatten nested `max` calls +help: Flatten nested `max` calls ℹ Unsafe fix 5 5 | min(1, max(2, 3)) @@ -121,15 +127,16 @@ nested_min_max.py:8:1: PLW3301 [*] Nested `max` calls can be flattened 10 10 | 11 11 | # These should not trigger; we do not flag cases with keyword args. -nested_min_max.py:8:8: PLW3301 [*] Nested `max` calls can be flattened +PLW3301 [*] Nested `max` calls can be flattened + --> nested_min_max.py:8:8 | 6 | max(1, 2, 3) 7 | max(1, max(2, 3)) 8 | max(1, max(2, max(3, 4))) - | ^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^ 9 | max(1, foo("a", "b"), max(3, 4)) | - = help: Flatten nested `max` calls +help: Flatten nested `max` calls ℹ Unsafe fix 5 5 | min(1, max(2, 3)) @@ -141,16 +148,17 @@ nested_min_max.py:8:8: PLW3301 [*] Nested `max` calls can be flattened 10 10 | 11 11 | # These should not trigger; we do not flag cases with keyword args. -nested_min_max.py:9:1: PLW3301 [*] Nested `max` calls can be flattened +PLW3301 [*] Nested `max` calls can be flattened + --> nested_min_max.py:9:1 | 7 | max(1, max(2, 3)) 8 | max(1, max(2, max(3, 4))) 9 | max(1, foo("a", "b"), max(3, 4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # These should not trigger; we do not flag cases with keyword args. | - = help: Flatten nested `max` calls +help: Flatten nested `max` calls ℹ Unsafe fix 6 6 | max(1, 2, 3) @@ -162,16 +170,17 @@ nested_min_max.py:9:1: PLW3301 [*] Nested `max` calls can be flattened 11 11 | # These should not trigger; we do not flag cases with keyword args. 12 12 | min(1, min(2, 3), key=test) -nested_min_max.py:15:1: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:15:1 | 13 | min(1, min(2, 3, key=test)) 14 | # This will still trigger, to merge the calls without keyword args. 15 | min(1, min(2, 3, key=test), min(4, 5)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | # The fix is already unsafe, so deleting comments is okay. | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 12 12 | min(1, min(2, 3), key=test) @@ -183,18 +192,19 @@ nested_min_max.py:15:1: PLW3301 [*] Nested `min` calls can be flattened 17 17 | # The fix is already unsafe, so deleting comments is okay. 18 18 | min( -nested_min_max.py:18:1: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:18:1 | 17 | # The fix is already unsafe, so deleting comments is okay. 18 | / min( 19 | | 1, # This is a comment. 20 | | min(2, 3), 21 | | ) - | |_^ PLW3301 + | |_^ 22 | 23 | # Handle iterable expressions. | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 15 15 | min(1, min(2, 3, key=test), min(4, 5)) @@ -209,15 +219,16 @@ nested_min_max.py:18:1: PLW3301 [*] Nested `min` calls can be flattened 23 20 | # Handle iterable expressions. 24 21 | min(1, min(a)) -nested_min_max.py:24:1: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:24:1 | 23 | # Handle iterable expressions. 24 | min(1, min(a)) - | ^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^ 25 | min(1, min(i for i in range(10))) 26 | max(1, max(a)) | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 21 21 | ) @@ -229,16 +240,17 @@ nested_min_max.py:24:1: PLW3301 [*] Nested `min` calls can be flattened 26 26 | max(1, max(a)) 27 27 | max(1, max(i for i in range(10))) -nested_min_max.py:25:1: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:25:1 | 23 | # Handle iterable expressions. 24 | min(1, min(a)) 25 | min(1, min(i for i in range(10))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | max(1, max(a)) 27 | max(1, max(i for i in range(10))) | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 22 22 | @@ -250,15 +262,16 @@ nested_min_max.py:25:1: PLW3301 [*] Nested `min` calls can be flattened 27 27 | max(1, max(i for i in range(10))) 28 28 | -nested_min_max.py:26:1: PLW3301 [*] Nested `max` calls can be flattened +PLW3301 [*] Nested `max` calls can be flattened + --> nested_min_max.py:26:1 | 24 | min(1, min(a)) 25 | min(1, min(i for i in range(10))) 26 | max(1, max(a)) - | ^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^ 27 | max(1, max(i for i in range(10))) | - = help: Flatten nested `max` calls +help: Flatten nested `max` calls ℹ Unsafe fix 23 23 | # Handle iterable expressions. @@ -270,16 +283,17 @@ nested_min_max.py:26:1: PLW3301 [*] Nested `max` calls can be flattened 28 28 | 29 29 | tuples_list = [ -nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened +PLW3301 [*] Nested `max` calls can be flattened + --> nested_min_max.py:27:1 | 25 | min(1, min(i for i in range(10))) 26 | max(1, max(a)) 27 | max(1, max(i for i in range(10))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | tuples_list = [ | - = help: Flatten nested `max` calls +help: Flatten nested `max` calls ℹ Unsafe fix 24 24 | min(1, min(a)) @@ -291,15 +305,16 @@ nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened 29 29 | tuples_list = [ 30 30 | (1, 2), -nested_min_max.py:41:1: PLW3301 [*] Nested `max` calls can be flattened +PLW3301 [*] Nested `max` calls can be flattened + --> nested_min_max.py:41:1 | 40 | # Starred argument should be copied as it is. 41 | max(1, max(*a)) - | ^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^ 42 | 43 | import builtins | - = help: Flatten nested `max` calls +help: Flatten nested `max` calls ℹ Unsafe fix 38 38 | max(max(tuples_list)) @@ -311,13 +326,14 @@ nested_min_max.py:41:1: PLW3301 [*] Nested `max` calls can be flattened 43 43 | import builtins 44 44 | builtins.min(1, min(2, 3)) -nested_min_max.py:44:1: PLW3301 [*] Nested `min` calls can be flattened +PLW3301 [*] Nested `min` calls can be flattened + --> nested_min_max.py:44:1 | 43 | import builtins 44 | builtins.min(1, min(2, 3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Flatten nested `min` calls +help: Flatten nested `min` calls ℹ Unsafe fix 41 41 | max(1, max(*a)) @@ -329,7 +345,8 @@ nested_min_max.py:44:1: PLW3301 [*] Nested `min` calls can be flattened 46 46 | 47 47 | # PLW3301 -nested_min_max.py:48:16: PLW3301 [*] Nested `max` calls can be flattened +PLW3301 [*] Nested `max` calls can be flattened + --> nested_min_max.py:48:16 | 47 | # PLW3301 48 | max_word_len = max( @@ -337,11 +354,11 @@ nested_min_max.py:48:16: PLW3301 [*] Nested `max` calls can be flattened 49 | | max(len(word) for word in "blah blah blah".split(" ")), 50 | | len("Done!"), 51 | | ) - | |_^ PLW3301 + | |_^ 52 | 53 | # OK | - = help: Flatten nested `max` calls +help: Flatten nested `max` calls ℹ Unsafe fix 45 45 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap index 6d6a223c11..998350927f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap @@ -1,47 +1,52 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -magic_value_comparison.py:56:12: PLR2004 Magic value used in comparison, consider replacing `-2.0` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `-2.0` with a constant variable + --> magic_value_comparison.py:56:12 | 54 | pass 55 | 56 | if argc != -2.0: # [magic-value-comparison] - | ^^^^ PLR2004 + | ^^^^ 57 | pass | -magic_value_comparison.py:59:12: PLR2004 Magic value used in comparison, consider replacing `+2.0` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `+2.0` with a constant variable + --> magic_value_comparison.py:59:12 | 57 | pass 58 | 59 | if argc != +2.0: # [magic-value-comparison] - | ^^^^ PLR2004 + | ^^^^ 60 | pass | -magic_value_comparison.py:74:22: PLR2004 Magic value used in comparison, consider replacing `"Hunter2"` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `"Hunter2"` with a constant variable + --> magic_value_comparison.py:74:22 | 72 | pass 73 | 74 | if input_password == "Hunter2": # correct - | ^^^^^^^^^ PLR2004 + | ^^^^^^^^^ 75 | pass | -magic_value_comparison.py:80:21: PLR2004 Magic value used in comparison, consider replacing `3.141592653589793238` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `3.141592653589793238` with a constant variable + --> magic_value_comparison.py:80:21 | 78 | pi_estimation = 3.14 79 | 80 | if pi_estimation == 3.141592653589793238: # [magic-value-comparison] - | ^^^^^^^^^^^^^^^^^^^^ PLR2004 + | ^^^^^^^^^^^^^^^^^^^^ 81 | pass | -magic_value_comparison.py:92:18: PLR2004 Magic value used in comparison, consider replacing `b"something"` with a constant variable +PLR2004 Magic value used in comparison, consider replacing `b"something"` with a constant variable + --> magic_value_comparison.py:92:18 | 90 | user_input = b"Hello, There!" 91 | 92 | if user_input == b"something": # correct - | ^^^^^^^^^^^^ PLR2004 + | ^^^^^^^^^^^^ 93 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap index 2391a6f9d4..d76dcc4236 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap @@ -1,126 +1,139 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -continue_in_finally.py:5:9: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:5:9 | 3 | pass 4 | finally: 5 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 6 | 7 | while True: | -continue_in_finally.py:16:13: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:16:13 | 14 | pass 15 | finally: 16 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 17 | pass | -continue_in_finally.py:26:17: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:26:17 | 24 | match test: 25 | case "aa": 26 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 27 | 28 | while True: | -continue_in_finally.py:33:13: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:33:13 | 31 | finally: 32 | with "aa" as f: 33 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 34 | 35 | while True: | -continue_in_finally.py:40:13: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:40:13 | 38 | finally: 39 | if True: 40 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 41 | continue # [continue-in-finally] | -continue_in_finally.py:41:9: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:41:9 | 39 | if True: 40 | continue # [continue-in-finally] 41 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 42 | 43 | def test(): | -continue_in_finally.py:49:17: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:49:17 | 47 | pass 48 | finally: 49 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ | -continue_in_finally.py:56:9: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:56:9 | 54 | pass 55 | finally: 56 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 57 | 58 | def test(): | -continue_in_finally.py:69:9: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:69:9 | 67 | for i in range(12): 68 | continue 69 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 70 | 71 | while True: | -continue_in_finally.py:74:13: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:74:13 | 72 | pass 73 | else: 74 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 75 | 76 | def test(): | -continue_in_finally.py:89:13: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:89:13 | 87 | pass 88 | elif False: 89 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 90 | else: 91 | continue # [continue-in-finally] | -continue_in_finally.py:91:13: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:91:13 | 89 | continue # [continue-in-finally] 90 | else: 91 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ 92 | for i in range(10): 93 | pass | -continue_in_finally.py:95:17: PLE0116 `continue` not supported inside `finally` clause +PLE0116 `continue` not supported inside `finally` clause + --> continue_in_finally.py:95:17 | 93 | pass 94 | else: 95 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__import_outside_top_level_with_banned.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__import_outside_top_level_with_banned.snap index ede65043dd..f433c3ce4b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__import_outside_top_level_with_banned.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__import_outside_top_level_with_banned.snap @@ -1,94 +1,104 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -import_outside_top_level_with_banned.py:9:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:9:5 | 8 | def import_in_function(): 9 | import symtable # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^ 10 | import os, sys # [import-outside-toplevel] 11 | import time as thyme # [import-outside-toplevel] | -import_outside_top_level_with_banned.py:10:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:10:5 | 8 | def import_in_function(): 9 | import symtable # [import-outside-toplevel] 10 | import os, sys # [import-outside-toplevel] - | ^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^ 11 | import time as thyme # [import-outside-toplevel] 12 | import random as rand, socket as sock # [import-outside-toplevel] | -import_outside_top_level_with_banned.py:11:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:11:5 | 9 | import symtable # [import-outside-toplevel] 10 | import os, sys # [import-outside-toplevel] 11 | import time as thyme # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^ 12 | import random as rand, socket as sock # [import-outside-toplevel] 13 | from collections import defaultdict # [import-outside-toplevel] | -import_outside_top_level_with_banned.py:12:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:12:5 | 10 | import os, sys # [import-outside-toplevel] 11 | import time as thyme # [import-outside-toplevel] 12 | import random as rand, socket as sock # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | from collections import defaultdict # [import-outside-toplevel] 14 | from math import sin as sign, cos as cosplay # [import-outside-toplevel] | -import_outside_top_level_with_banned.py:13:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:13:5 | 11 | import time as thyme # [import-outside-toplevel] 12 | import random as rand, socket as sock # [import-outside-toplevel] 13 | from collections import defaultdict # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | from math import sin as sign, cos as cosplay # [import-outside-toplevel] | -import_outside_top_level_with_banned.py:14:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:14:5 | 12 | import random as rand, socket as sock # [import-outside-toplevel] 13 | from collections import defaultdict # [import-outside-toplevel] 14 | from math import sin as sign, cos as cosplay # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | # these should be allowed due to TID253 top-level ban | -import_outside_top_level_with_banned.py:24:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:24:5 | 23 | # this should still trigger an error due to multiple imports 24 | from pkg import foo_allowed, bar_banned # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | class ClassWithImports: | -import_outside_top_level_with_banned.py:27:5: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:27:5 | 26 | class ClassWithImports: 27 | import tokenize # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^ 28 | 29 | def __init__(self): | -import_outside_top_level_with_banned.py:30:9: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:30:9 | 29 | def __init__(self): 30 | import trace # [import-outside-toplevel] - | ^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^ 31 | 32 | # these should be allowed due to TID253 top-level ban | -import_outside_top_level_with_banned.py:40:9: PLC0415 `import` should be at the top-level of a file +PLC0415 `import` should be at the top-level of a file + --> import_outside_top_level_with_banned.py:40:9 | 39 | # this should still trigger an error due to multiple imports 40 | from pkg import foo_allowed, bar_banned # [import-outside-toplevel] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0415 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args.snap index bdc4b307ea..f731c14b11 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args.snap @@ -1,21 +1,22 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_arguments_params.py:3:5: PLR0913 Too many arguments in function definition (6 > 4) +PLR0913 Too many arguments in function definition (6 > 4) + --> too_many_arguments_params.py:3:5 | 1 | # Too many args (6/4) for max_args=4 2 | # OK for dummy_variable_rgx ~ "skip_.*" 3 | def f(x, y, z, skip_t, skip_u, skip_v): - | ^ PLR0913 + | ^ 4 | pass | -too_many_arguments_params.py:9:5: PLR0913 Too many arguments in function definition (6 > 4) +PLR0913 Too many arguments in function definition (6 > 4) + --> too_many_arguments_params.py:9:5 | 7 | # Too many args (6/4) for max_args=4 8 | # Too many args (6/5) for dummy_variable_rgx ~ "skip_.*" 9 | def f(x, y, z, t, u, v): - | ^ PLR0913 + | ^ 10 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args_with_dummy_variables.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args_with_dummy_variables.snap index 6f978e8024..4130629608 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args_with_dummy_variables.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args_with_dummy_variables.snap @@ -1,12 +1,12 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_arguments_params.py:9:5: PLR0913 Too many arguments in function definition (6 > 5) +PLR0913 Too many arguments in function definition (6 > 5) + --> too_many_arguments_params.py:9:5 | 7 | # Too many args (6/4) for max_args=4 8 | # Too many args (6/5) for dummy_variable_rgx ~ "skip_.*" 9 | def f(x, y, z, t, u, v): - | ^ PLR0913 + | ^ 10 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_boolean_expressions.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_boolean_expressions.snap index 3bab1afdea..e3d2099ff6 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_boolean_expressions.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_boolean_expressions.snap @@ -1,212 +1,233 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -too_many_boolean_expressions.py:11:6: PLR0916 Too many Boolean expressions (6 > 5) +PLR0916 Too many Boolean expressions (6 > 5) + --> too_many_boolean_expressions.py:11:6 | 9 | elif (a and b) and c and d and e: 10 | ... 11 | elif (a and b) and c and d and e and f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | ... 13 | elif (a and b) and c and d and e and f and g: | -too_many_boolean_expressions.py:13:6: PLR0916 Too many Boolean expressions (7 > 5) +PLR0916 Too many Boolean expressions (7 > 5) + --> too_many_boolean_expressions.py:13:6 | 11 | elif (a and b) and c and d and e and f: 12 | ... 13 | elif (a and b) and c and d and e and f and g: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | ... 15 | elif (a and b) and c and d and e and f and g and h: | -too_many_boolean_expressions.py:15:6: PLR0916 Too many Boolean expressions (8 > 5) +PLR0916 Too many Boolean expressions (8 > 5) + --> too_many_boolean_expressions.py:15:6 | 13 | elif (a and b) and c and d and e and f and g: 14 | ... 15 | elif (a and b) and c and d and e and f and g and h: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | ... 17 | elif (a and b) and c and d and e and f and g and h and i: | -too_many_boolean_expressions.py:17:6: PLR0916 Too many Boolean expressions (9 > 5) +PLR0916 Too many Boolean expressions (9 > 5) + --> too_many_boolean_expressions.py:17:6 | 15 | elif (a and b) and c and d and e and f and g and h: 16 | ... 17 | elif (a and b) and c and d and e and f and g and h and i: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | ... 19 | elif (a and b) and c and d and e and f and g and h and i and j: | -too_many_boolean_expressions.py:19:6: PLR0916 Too many Boolean expressions (10 > 5) +PLR0916 Too many Boolean expressions (10 > 5) + --> too_many_boolean_expressions.py:19:6 | 17 | elif (a and b) and c and d and e and f and g and h and i: 18 | ... 19 | elif (a and b) and c and d and e and f and g and h and i and j: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | ... 21 | elif (a and b) and c and d and e and f and g and h and i and j and k: | -too_many_boolean_expressions.py:21:6: PLR0916 Too many Boolean expressions (11 > 5) +PLR0916 Too many Boolean expressions (11 > 5) + --> too_many_boolean_expressions.py:21:6 | 19 | elif (a and b) and c and d and e and f and g and h and i and j: 20 | ... 21 | elif (a and b) and c and d and e and f and g and h and i and j and k: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | ... 23 | elif (a and b) and c and d and e and f and g and h and i and j and k and l: | -too_many_boolean_expressions.py:23:6: PLR0916 Too many Boolean expressions (12 > 5) +PLR0916 Too many Boolean expressions (12 > 5) + --> too_many_boolean_expressions.py:23:6 | 21 | elif (a and b) and c and d and e and f and g and h and i and j and k: 22 | ... 23 | elif (a and b) and c and d and e and f and g and h and i and j and k and l: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | ... 25 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m: | -too_many_boolean_expressions.py:25:6: PLR0916 Too many Boolean expressions (13 > 5) +PLR0916 Too many Boolean expressions (13 > 5) + --> too_many_boolean_expressions.py:25:6 | 23 | elif (a and b) and c and d and e and f and g and h and i and j and k and l: 24 | ... 25 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | ... 27 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n: | -too_many_boolean_expressions.py:27:6: PLR0916 Too many Boolean expressions (14 > 5) +PLR0916 Too many Boolean expressions (14 > 5) + --> too_many_boolean_expressions.py:27:6 | 25 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m: 26 | ... 27 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | ... 29 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o: | -too_many_boolean_expressions.py:29:6: PLR0916 Too many Boolean expressions (15 > 5) +PLR0916 Too many Boolean expressions (15 > 5) + --> too_many_boolean_expressions.py:29:6 | 27 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n: 28 | ... 29 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | ... 31 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p: | -too_many_boolean_expressions.py:31:6: PLR0916 Too many Boolean expressions (16 > 5) +PLR0916 Too many Boolean expressions (16 > 5) + --> too_many_boolean_expressions.py:31:6 | 29 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o: 30 | ... 31 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | ... 33 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q: | -too_many_boolean_expressions.py:33:6: PLR0916 Too many Boolean expressions (17 > 5) +PLR0916 Too many Boolean expressions (17 > 5) + --> too_many_boolean_expressions.py:33:6 | 31 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p: 32 | ... 33 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | ... 35 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r: | -too_many_boolean_expressions.py:35:6: PLR0916 Too many Boolean expressions (18 > 5) +PLR0916 Too many Boolean expressions (18 > 5) + --> too_many_boolean_expressions.py:35:6 | 33 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q: 34 | ... 35 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | ... 37 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s: | -too_many_boolean_expressions.py:37:6: PLR0916 Too many Boolean expressions (19 > 5) +PLR0916 Too many Boolean expressions (19 > 5) + --> too_many_boolean_expressions.py:37:6 | 35 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r: 36 | ... 37 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | ... 39 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t: | -too_many_boolean_expressions.py:39:6: PLR0916 Too many Boolean expressions (20 > 5) +PLR0916 Too many Boolean expressions (20 > 5) + --> too_many_boolean_expressions.py:39:6 | 37 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s: 38 | ... 39 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | ... 41 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u: | -too_many_boolean_expressions.py:41:6: PLR0916 Too many Boolean expressions (21 > 5) +PLR0916 Too many Boolean expressions (21 > 5) + --> too_many_boolean_expressions.py:41:6 | 39 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t: 40 | ... 41 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | ... 43 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v: | -too_many_boolean_expressions.py:43:6: PLR0916 Too many Boolean expressions (22 > 5) +PLR0916 Too many Boolean expressions (22 > 5) + --> too_many_boolean_expressions.py:43:6 | 41 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u: 42 | ... 43 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | ... 45 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and … | -too_many_boolean_expressions.py:45:6: PLR0916 Too many Boolean expressions (23 > 5) +PLR0916 Too many Boolean expressions (23 > 5) + --> too_many_boolean_expressions.py:45:6 | 43 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v: 44 | ... 45 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | ... 47 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and … | -too_many_boolean_expressions.py:47:6: PLR0916 Too many Boolean expressions (24 > 5) +PLR0916 Too many Boolean expressions (24 > 5) + --> too_many_boolean_expressions.py:47:6 | 45 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w: 46 | ... 47 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | ... 49 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and … | -too_many_boolean_expressions.py:49:6: PLR0916 Too many Boolean expressions (25 > 5) +PLR0916 Too many Boolean expressions (25 > 5) + --> too_many_boolean_expressions.py:49:6 | 47 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x: 48 | ... 49 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and y: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | ... 51 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and y and … | -too_many_boolean_expressions.py:51:6: PLR0916 Too many Boolean expressions (26 > 5) +PLR0916 Too many Boolean expressions (26 > 5) + --> too_many_boolean_expressions.py:51:6 | 49 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and y: 50 | ... 51 | elif (a and b) and c and d and e and f and g and h and i and j and k and l and m and n and o and p and q and r and s and t and u and v and w and x and y and z: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0916 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | ... 53 | else: | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap index bcfd72f36a..d5a58658b8 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -too_many_branches_params.py:6:5: PLR0912 Too many branches (2 > 1) +PLR0912 Too many branches (2 > 1) + --> too_many_branches_params.py:6:5 | 6 | def g(x): - | ^ PLR0912 + | ^ 7 | if x: 8 | pass | -too_many_branches_params.py:15:9: PLR0912 Too many branches (2 > 1) +PLR0912 Too many branches (2 > 1) + --> too_many_branches_params.py:15:9 | 13 | return 14 | 15 | def i(x): - | ^ PLR0912 + | ^ 16 | if x: 17 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_positional_args.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_positional_args.snap index fd65b9bb84..de72029a0f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_positional_args.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_positional_args.snap @@ -1,21 +1,22 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_positional_params.py:3:5: PLR0917 Too many positional arguments (7/4) +PLR0917 Too many positional arguments (7/4) + --> too_many_positional_params.py:3:5 | 1 | # Too many positional arguments (7/4) for max_positional=4 2 | # OK for dummy_variable_rgx ~ "skip_.*" 3 | def f(w, x, y, z, skip_t, skip_u, skip_v): - | ^ PLR0917 + | ^ 4 | pass | -too_many_positional_params.py:9:5: PLR0917 Too many positional arguments (7/4) +PLR0917 Too many positional arguments (7/4) + --> too_many_positional_params.py:9:5 | 7 | # Too many positional arguments (7/4) for max_args=4 8 | # Too many positional arguments (7/3) for dummy_variable_rgx ~ "skip_.*" 9 | def f(w, x, y, z, t, u, v): - | ^ PLR0917 + | ^ 10 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_return_statements.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_return_statements.snap index 36c4a29056..3845fda3c2 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_return_statements.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_return_statements.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_return_statements_params.py:1:5: PLR0911 Too many return statements (2 > 1) +PLR0911 Too many return statements (2 > 1) + --> too_many_return_statements_params.py:1:5 | 1 | def f(x): # Too many return statements (2/1) - | ^ PLR0911 + | ^ 2 | if x == 1: 3 | return | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_statements.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_statements.snap index 9b524750b6..03fdae9a0b 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_statements.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_statements.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_statements_params.py:6:5: PLR0915 Too many statements (2 > 1) +PLR0915 Too many statements (2 > 1) + --> too_many_statements_params.py:6:5 | 6 | def f(x): - | ^ PLR0915 + | ^ 7 | def g(x): 8 | pass | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_locals.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_locals.snap index 65eacdcd81..6b30ac6e44 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_locals.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_locals.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs -snapshot_kind: text --- -too_many_locals.py:20:5: PLR0914 Too many local variables (16/15) +PLR0914 Too many local variables (16/15) + --> too_many_locals.py:20:5 | 20 | def func() -> None: # PLR0914 - | ^^^^ PLR0914 + | ^^^^ 21 | first = 1 22 | second = 2 | diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap index 6eff6362b5..8fdb140f3f 100644 --- a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/rules/pylint/mod.rs --- -too_many_public_methods.py:4:1: PLR0904 Too many public methods (10 > 7) +PLR0904 Too many public methods (10 > 7) + --> too_many_public_methods.py:4:1 | 4 | / class Everything: 5 | | foo = 1 @@ -38,5 +39,5 @@ too_many_public_methods.py:4:1: PLR0904 Too many public methods (10 > 7) 36 | | 37 | | def method9(self): 38 | | pass - | |____________^ PLR0904 + | |____________^ | diff --git a/crates/ruff_linter/src/rules/pyupgrade/mod.rs b/crates/ruff_linter/src/rules/pyupgrade/mod.rs index 65e0313f2d..afc3f2c049 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/mod.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/mod.rs @@ -332,24 +332,31 @@ mod tests { }, ); assert_diagnostics!(diagnostics, @r" - :1:1: UP035 [*] Import from `shlex` instead: `quote` + UP035 [*] Import from `shlex` instead: `quote` + --> :1:1 | 1 | from pipes import quote, Template - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Import from `shlex` + help: Import from `shlex` ℹ Safe fix 1 |-from pipes import quote, Template 1 |+from pipes import Template 2 |+from shlex import quote - :1:1: I002 [*] Missing required import: `from __future__ import generator_stop` + I002 [*] Missing required import: `from __future__ import generator_stop` + --> :1:1 + help: Insert required import: `from __future__ import generator_stop` + ℹ Safe fix 1 |+from __future__ import generator_stop 1 2 | from pipes import quote, Template - :1:1: I002 [*] Missing required import: `from collections import Sequence` + I002 [*] Missing required import: `from collections import Sequence` + --> :1:1 + help: Insert required import: `from collections import Sequence` + ℹ Safe fix 1 |+from collections import Sequence 1 2 | from pipes import quote, Template diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap index e0964e0a04..7f1c7a75a1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP001.py:2:5: UP001 [*] `__metaclass__ = type` is implied +UP001 [*] `__metaclass__ = type` is implied + --> UP001.py:2:5 | 1 | class A: 2 | __metaclass__ = type - | ^^^^^^^^^^^^^^^^^^^^ UP001 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Remove `__metaclass__ = type` +help: Remove `__metaclass__ = type` ℹ Safe fix 1 1 | class A: @@ -17,15 +18,16 @@ UP001.py:2:5: UP001 [*] `__metaclass__ = type` is implied 4 4 | 5 5 | class B: -UP001.py:6:5: UP001 [*] `__metaclass__ = type` is implied +UP001 [*] `__metaclass__ = type` is implied + --> UP001.py:6:5 | 5 | class B: 6 | __metaclass__ = type - | ^^^^^^^^^^^^^^^^^^^^ UP001 + | ^^^^^^^^^^^^^^^^^^^^ 7 | 8 | def __init__(self) -> None: | - = help: Remove `__metaclass__ = type` +help: Remove `__metaclass__ = type` ℹ Safe fix 3 3 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap index d11e176201..08d84dd2bb 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP003.py:1:1: UP003 [*] Use `str` instead of `type(...)` +UP003 [*] Use `str` instead of `type(...)` + --> UP003.py:1:1 | 1 | type("") - | ^^^^^^^^ UP003 + | ^^^^^^^^ 2 | type(b"") 3 | type(0) | - = help: Replace `type(...)` with `str` +help: Replace `type(...)` with `str` ℹ Safe fix 1 |-type("") @@ -17,15 +18,16 @@ UP003.py:1:1: UP003 [*] Use `str` instead of `type(...)` 3 3 | type(0) 4 4 | type(0.0) -UP003.py:2:1: UP003 [*] Use `bytes` instead of `type(...)` +UP003 [*] Use `bytes` instead of `type(...)` + --> UP003.py:2:1 | 1 | type("") 2 | type(b"") - | ^^^^^^^^^ UP003 + | ^^^^^^^^^ 3 | type(0) 4 | type(0.0) | - = help: Replace `type(...)` with `bytes` +help: Replace `type(...)` with `bytes` ℹ Safe fix 1 1 | type("") @@ -35,16 +37,17 @@ UP003.py:2:1: UP003 [*] Use `bytes` instead of `type(...)` 4 4 | type(0.0) 5 5 | type(0j) -UP003.py:3:1: UP003 [*] Use `int` instead of `type(...)` +UP003 [*] Use `int` instead of `type(...)` + --> UP003.py:3:1 | 1 | type("") 2 | type(b"") 3 | type(0) - | ^^^^^^^ UP003 + | ^^^^^^^ 4 | type(0.0) 5 | type(0j) | - = help: Replace `type(...)` with `int` +help: Replace `type(...)` with `int` ℹ Safe fix 1 1 | type("") @@ -55,15 +58,16 @@ UP003.py:3:1: UP003 [*] Use `int` instead of `type(...)` 5 5 | type(0j) 6 6 | -UP003.py:4:1: UP003 [*] Use `float` instead of `type(...)` +UP003 [*] Use `float` instead of `type(...)` + --> UP003.py:4:1 | 2 | type(b"") 3 | type(0) 4 | type(0.0) - | ^^^^^^^^^ UP003 + | ^^^^^^^^^ 5 | type(0j) | - = help: Replace `type(...)` with `float` +help: Replace `type(...)` with `float` ℹ Safe fix 1 1 | type("") @@ -75,16 +79,17 @@ UP003.py:4:1: UP003 [*] Use `float` instead of `type(...)` 6 6 | 7 7 | # OK -UP003.py:5:1: UP003 [*] Use `complex` instead of `type(...)` +UP003 [*] Use `complex` instead of `type(...)` + --> UP003.py:5:1 | 3 | type(0) 4 | type(0.0) 5 | type(0j) - | ^^^^^^^^ UP003 + | ^^^^^^^^ 6 | 7 | # OK | - = help: Replace `type(...)` with `complex` +help: Replace `type(...)` with `complex` ℹ Safe fix 2 2 | type(b"") @@ -96,13 +101,14 @@ UP003.py:5:1: UP003 [*] Use `complex` instead of `type(...)` 7 7 | # OK 8 8 | type(arg)(" ") -UP003.py:14:29: UP003 [*] Use `str` instead of `type(...)` +UP003 [*] Use `str` instead of `type(...)` + --> UP003.py:14:29 | 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459841 14 | assert isinstance(fullname, type("")is not True) - | ^^^^^^^^ UP003 + | ^^^^^^^^ | - = help: Replace `type(...)` with `str` +help: Replace `type(...)` with `str` ℹ Safe fix 11 11 | y = x.dtype.type(0.0) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap index 07d46783e2..06bc6b37d4 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP004.py:5:9: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:5:9 | 5 | class A(object): - | ^^^^^^ UP004 + | ^^^^^^ 6 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 2 2 | ... @@ -19,15 +20,16 @@ UP004.py:5:9: UP004 [*] Class `A` inherits from `object` 7 7 | 8 8 | -UP004.py:10:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:10:5 | 9 | class A( 10 | object, - | ^^^^^^ UP004 + | ^^^^^^ 11 | ): 12 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 6 6 | ... @@ -41,15 +43,16 @@ UP004.py:10:5: UP004 [*] Class `A` inherits from `object` 13 11 | 14 12 | -UP004.py:16:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:16:5 | 15 | class A( 16 | object, - | ^^^^^^ UP004 + | ^^^^^^ 17 | # 18 | ): | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 12 12 | ... @@ -64,16 +67,17 @@ UP004.py:16:5: UP004 [*] Class `A` inherits from `object` 20 17 | 21 18 | -UP004.py:24:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:24:5 | 22 | class A( 23 | # 24 | object, - | ^^^^^^ UP004 + | ^^^^^^ 25 | ): 26 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 19 19 | ... @@ -88,16 +92,17 @@ UP004.py:24:5: UP004 [*] Class `A` inherits from `object` 27 24 | 28 25 | -UP004.py:31:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:31:5 | 29 | class A( 30 | # 31 | object - | ^^^^^^ UP004 + | ^^^^^^ 32 | ): 33 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 26 26 | ... @@ -112,15 +117,16 @@ UP004.py:31:5: UP004 [*] Class `A` inherits from `object` 34 31 | 35 32 | -UP004.py:37:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:37:5 | 36 | class A( 37 | object - | ^^^^^^ UP004 + | ^^^^^^ 38 | # 39 | ): | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 33 33 | ... @@ -135,16 +141,17 @@ UP004.py:37:5: UP004 [*] Class `A` inherits from `object` 41 38 | 42 39 | -UP004.py:45:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:45:5 | 43 | class A( 44 | # 45 | object, - | ^^^^^^ UP004 + | ^^^^^^ 46 | # 47 | ): | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 40 40 | ... @@ -160,16 +167,17 @@ UP004.py:45:5: UP004 [*] Class `A` inherits from `object` 49 45 | 50 46 | -UP004.py:53:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:53:5 | 51 | class A( 52 | # 53 | object, - | ^^^^^^ UP004 + | ^^^^^^ 54 | # 55 | ): | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 48 48 | ... @@ -185,16 +193,17 @@ UP004.py:53:5: UP004 [*] Class `A` inherits from `object` 57 53 | 58 54 | -UP004.py:61:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:61:5 | 59 | class A( 60 | # 61 | object - | ^^^^^^ UP004 + | ^^^^^^ 62 | # 63 | ): | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 56 56 | ... @@ -210,16 +219,17 @@ UP004.py:61:5: UP004 [*] Class `A` inherits from `object` 65 61 | 66 62 | -UP004.py:69:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:69:5 | 67 | class A( 68 | # 69 | object - | ^^^^^^ UP004 + | ^^^^^^ 70 | # 71 | ): | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 64 64 | ... @@ -235,13 +245,14 @@ UP004.py:69:5: UP004 [*] Class `A` inherits from `object` 73 69 | 74 70 | -UP004.py:75:12: UP004 [*] Class `B` inherits from `object` +UP004 [*] Class `B` inherits from `object` + --> UP004.py:75:12 | 75 | class B(A, object): - | ^^^^^^ UP004 + | ^^^^^^ 76 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 72 72 | ... @@ -253,13 +264,14 @@ UP004.py:75:12: UP004 [*] Class `B` inherits from `object` 77 77 | 78 78 | -UP004.py:79:9: UP004 [*] Class `B` inherits from `object` +UP004 [*] Class `B` inherits from `object` + --> UP004.py:79:9 | 79 | class B(object, A): - | ^^^^^^ UP004 + | ^^^^^^ 80 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 76 76 | ... @@ -271,15 +283,16 @@ UP004.py:79:9: UP004 [*] Class `B` inherits from `object` 81 81 | 82 82 | -UP004.py:84:5: UP004 [*] Class `B` inherits from `object` +UP004 [*] Class `B` inherits from `object` + --> UP004.py:84:5 | 83 | class B( 84 | object, - | ^^^^^^ UP004 + | ^^^^^^ 85 | A, 86 | ): | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 81 81 | @@ -290,16 +303,17 @@ UP004.py:84:5: UP004 [*] Class `B` inherits from `object` 86 85 | ): 87 86 | ... -UP004.py:92:5: UP004 [*] Class `B` inherits from `object` +UP004 [*] Class `B` inherits from `object` + --> UP004.py:92:5 | 90 | class B( 91 | A, 92 | object, - | ^^^^^^ UP004 + | ^^^^^^ 93 | ): 94 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 89 89 | @@ -310,15 +324,16 @@ UP004.py:92:5: UP004 [*] Class `B` inherits from `object` 94 93 | ... 95 94 | -UP004.py:98:5: UP004 [*] Class `B` inherits from `object` +UP004 [*] Class `B` inherits from `object` + --> UP004.py:98:5 | 97 | class B( 98 | object, - | ^^^^^^ UP004 + | ^^^^^^ 99 | # Comment on A. 100 | A, | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 95 95 | @@ -329,16 +344,17 @@ UP004.py:98:5: UP004 [*] Class `B` inherits from `object` 100 99 | A, 101 100 | ): -UP004.py:108:5: UP004 [*] Class `B` inherits from `object` +UP004 [*] Class `B` inherits from `object` + --> UP004.py:108:5 | 106 | # Comment on A. 107 | A, 108 | object, - | ^^^^^^ UP004 + | ^^^^^^ 109 | ): 110 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 105 105 | class B( @@ -349,15 +365,16 @@ UP004.py:108:5: UP004 [*] Class `B` inherits from `object` 110 109 | ... 111 110 | -UP004.py:119:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:119:5 | 118 | class A( 119 | object, - | ^^^^^^ UP004 + | ^^^^^^ 120 | ): 121 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 115 115 | ... @@ -371,15 +388,16 @@ UP004.py:119:5: UP004 [*] Class `A` inherits from `object` 122 120 | 123 121 | -UP004.py:125:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:125:5 | 124 | class A( 125 | object, # ) - | ^^^^^^ UP004 + | ^^^^^^ 126 | ): 127 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 121 121 | ... @@ -393,15 +411,16 @@ UP004.py:125:5: UP004 [*] Class `A` inherits from `object` 128 126 | 129 127 | -UP004.py:131:5: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:131:5 | 130 | class A( 131 | object # ) - | ^^^^^^ UP004 + | ^^^^^^ 132 | , 133 | ): | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Unsafe fix 127 127 | ... @@ -416,13 +435,14 @@ UP004.py:131:5: UP004 [*] Class `A` inherits from `object` 135 132 | 136 133 | -UP004.py:137:9: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:137:9 | 137 | class A(object, object): - | ^^^^^^ UP004 + | ^^^^^^ 138 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 134 134 | ... @@ -434,13 +454,14 @@ UP004.py:137:9: UP004 [*] Class `A` inherits from `object` 139 139 | 140 140 | -UP004.py:137:17: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:137:17 | 137 | class A(object, object): - | ^^^^^^ UP004 + | ^^^^^^ 138 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 134 134 | ... @@ -452,14 +473,15 @@ UP004.py:137:17: UP004 [*] Class `A` inherits from `object` 139 139 | 140 140 | -UP004.py:142:9: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:142:9 | 141 | @decorator() 142 | class A(object): - | ^^^^^^ UP004 + | ^^^^^^ 143 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 139 139 | @@ -471,14 +493,15 @@ UP004.py:142:9: UP004 [*] Class `A` inherits from `object` 144 144 | 145 145 | @decorator() # class A(object): -UP004.py:146:9: UP004 [*] Class `A` inherits from `object` +UP004 [*] Class `A` inherits from `object` + --> UP004.py:146:9 | 145 | @decorator() # class A(object): 146 | class A(object): - | ^^^^^^ UP004 + | ^^^^^^ 147 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 143 143 | ... @@ -490,15 +513,16 @@ UP004.py:146:9: UP004 [*] Class `A` inherits from `object` 148 148 | 149 149 | -UP004.py:159:15: UP004 [*] Class `Unusual` inherits from `object` +UP004 [*] Class `Unusual` inherits from `object` + --> UP004.py:159:15 | 157 | import builtins 158 | 159 | class Unusual(builtins.object): - | ^^^^^^^^^^^^^^^ UP004 + | ^^^^^^^^^^^^^^^ 160 | ... | - = help: Remove `object` inheritance +help: Remove `object` inheritance ℹ Safe fix 156 156 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap index 9f6ddec478..062d02bd62 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP005.py:6:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` +UP005 [*] `assertEquals` is deprecated, use `assertEqual` + --> UP005.py:6:9 | 4 | class Suite(unittest.TestCase): 5 | def test(self) -> None: 6 | self.assertEquals (1, 2) - | ^^^^^^^^^^^^^^^^^ UP005 + | ^^^^^^^^^^^^^^^^^ 7 | self.assertEquals(1, 2) 8 | self.assertEqual(3, 4) | - = help: Replace `assertEqual` with `assertEquals` +help: Replace `assertEqual` with `assertEquals` ℹ Safe fix 3 3 | @@ -23,16 +23,17 @@ UP005.py:6:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` 8 8 | self.assertEqual(3, 4) 9 9 | self.failUnlessAlmostEqual(1, 1.1) -UP005.py:7:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` +UP005 [*] `assertEquals` is deprecated, use `assertEqual` + --> UP005.py:7:9 | 5 | def test(self) -> None: 6 | self.assertEquals (1, 2) 7 | self.assertEquals(1, 2) - | ^^^^^^^^^^^^^^^^^ UP005 + | ^^^^^^^^^^^^^^^^^ 8 | self.assertEqual(3, 4) 9 | self.failUnlessAlmostEqual(1, 1.1) | - = help: Replace `assertEqual` with `assertEquals` +help: Replace `assertEqual` with `assertEquals` ℹ Safe fix 4 4 | class Suite(unittest.TestCase): @@ -44,15 +45,16 @@ UP005.py:7:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` 9 9 | self.failUnlessAlmostEqual(1, 1.1) 10 10 | self.assertNotRegexpMatches("a", "b") -UP005.py:9:9: UP005 [*] `failUnlessAlmostEqual` is deprecated, use `assertAlmostEqual` +UP005 [*] `failUnlessAlmostEqual` is deprecated, use `assertAlmostEqual` + --> UP005.py:9:9 | 7 | self.assertEquals(1, 2) 8 | self.assertEqual(3, 4) 9 | self.failUnlessAlmostEqual(1, 1.1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | self.assertNotRegexpMatches("a", "b") | - = help: Replace `assertAlmostEqual` with `failUnlessAlmostEqual` +help: Replace `assertAlmostEqual` with `failUnlessAlmostEqual` ℹ Safe fix 6 6 | self.assertEquals (1, 2) @@ -62,14 +64,15 @@ UP005.py:9:9: UP005 [*] `failUnlessAlmostEqual` is deprecated, use `assertAlmost 9 |+ self.assertAlmostEqual(1, 1.1) 10 10 | self.assertNotRegexpMatches("a", "b") -UP005.py:10:9: UP005 [*] `assertNotRegexpMatches` is deprecated, use `assertNotRegex` +UP005 [*] `assertNotRegexpMatches` is deprecated, use `assertNotRegex` + --> UP005.py:10:9 | 8 | self.assertEqual(3, 4) 9 | self.failUnlessAlmostEqual(1, 1.1) 10 | self.assertNotRegexpMatches("a", "b") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace `assertNotRegex` with `assertNotRegexpMatches` +help: Replace `assertNotRegex` with `assertNotRegexpMatches` ℹ Safe fix 7 7 | self.assertEquals(1, 2) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap index 58bd2d2497..c5370c7563 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP006_0.py:4:10: UP006 [*] Use `list` instead of `typing.List` for type annotation +UP006 [*] Use `list` instead of `typing.List` for type annotation + --> UP006_0.py:4:10 | 4 | def f(x: typing.List[str]) -> None: - | ^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^ 5 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 1 1 | import typing @@ -20,13 +20,14 @@ UP006_0.py:4:10: UP006 [*] Use `list` instead of `typing.List` for type annotati 6 6 | 7 7 | -UP006_0.py:11:10: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> UP006_0.py:11:10 | 11 | def f(x: List[str]) -> None: - | ^^^^ UP006 + | ^^^^ 12 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 8 8 | from typing import List @@ -38,13 +39,14 @@ UP006_0.py:11:10: UP006 [*] Use `list` instead of `List` for type annotation 13 13 | 14 14 | -UP006_0.py:18:10: UP006 [*] Use `list` instead of `t.List` for type annotation +UP006 [*] Use `list` instead of `t.List` for type annotation + --> UP006_0.py:18:10 | 18 | def f(x: t.List[str]) -> None: - | ^^^^^^ UP006 + | ^^^^^^ 19 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 15 15 | import typing as t @@ -56,13 +58,14 @@ UP006_0.py:18:10: UP006 [*] Use `list` instead of `t.List` for type annotation 20 20 | 21 21 | -UP006_0.py:25:10: UP006 [*] Use `list` instead of `IList` for type annotation +UP006 [*] Use `list` instead of `IList` for type annotation + --> UP006_0.py:25:10 | 25 | def f(x: IList[str]) -> None: - | ^^^^^ UP006 + | ^^^^^ 26 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 22 22 | from typing import List as IList @@ -74,13 +77,14 @@ UP006_0.py:25:10: UP006 [*] Use `list` instead of `IList` for type annotation 27 27 | 28 28 | -UP006_0.py:29:11: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> UP006_0.py:29:11 | 29 | def f(x: "List[str]") -> None: - | ^^^^ UP006 + | ^^^^ 30 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 26 26 | ... @@ -92,13 +96,14 @@ UP006_0.py:29:11: UP006 [*] Use `list` instead of `List` for type annotation 31 31 | 32 32 | -UP006_0.py:33:12: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> UP006_0.py:33:12 | 33 | def f(x: r"List[str]") -> None: - | ^^^^ UP006 + | ^^^^ 34 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 30 30 | ... @@ -110,13 +115,14 @@ UP006_0.py:33:12: UP006 [*] Use `list` instead of `List` for type annotation 35 35 | 36 36 | -UP006_0.py:37:11: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> UP006_0.py:37:11 | 37 | def f(x: "List[str]") -> None: - | ^^^^ UP006 + | ^^^^ 38 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 34 34 | ... @@ -128,13 +134,14 @@ UP006_0.py:37:11: UP006 [*] Use `list` instead of `List` for type annotation 39 39 | 40 40 | -UP006_0.py:41:13: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> UP006_0.py:41:13 | 41 | def f(x: """List[str]""") -> None: - | ^^^^ UP006 + | ^^^^ 42 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 38 38 | ... @@ -146,21 +153,23 @@ UP006_0.py:41:13: UP006 [*] Use `list` instead of `List` for type annotation 43 43 | 44 44 | -UP006_0.py:45:10: UP006 Use `list` instead of `List` for type annotation +UP006 Use `list` instead of `List` for type annotation + --> UP006_0.py:45:10 | 45 | def f(x: "Li" "st[str]") -> None: - | ^^^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^^^ 46 | ... | - = help: Replace with `list` +help: Replace with `list` -UP006_0.py:49:11: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> UP006_0.py:49:11 | 49 | def f(x: "List['List[str]']") -> None: - | ^^^^ UP006 + | ^^^^ 50 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 46 46 | ... @@ -172,13 +181,14 @@ UP006_0.py:49:11: UP006 [*] Use `list` instead of `List` for type annotation 51 51 | 52 52 | -UP006_0.py:49:17: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> UP006_0.py:49:17 | 49 | def f(x: "List['List[str]']") -> None: - | ^^^^ UP006 + | ^^^^ 50 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 46 46 | ... @@ -190,13 +200,14 @@ UP006_0.py:49:17: UP006 [*] Use `list` instead of `List` for type annotation 51 51 | 52 52 | -UP006_0.py:53:11: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> UP006_0.py:53:11 | 53 | def f(x: "List['Li' 'st[str]']") -> None: - | ^^^^ UP006 + | ^^^^ 54 | ... | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 50 50 | ... @@ -208,37 +219,41 @@ UP006_0.py:53:11: UP006 [*] Use `list` instead of `List` for type annotation 55 55 | 56 56 | -UP006_0.py:53:16: UP006 Use `list` instead of `List` for type annotation +UP006 Use `list` instead of `List` for type annotation + --> UP006_0.py:53:16 | 53 | def f(x: "List['Li' 'st[str]']") -> None: - | ^^^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^^^ 54 | ... | - = help: Replace with `list` +help: Replace with `list` -UP006_0.py:57:10: UP006 Use `list` instead of `List` for type annotation +UP006 Use `list` instead of `List` for type annotation + --> UP006_0.py:57:10 | 57 | def f(x: "Li" "st['List[str]']") -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^^^^^^^^^^^ 58 | ... | - = help: Replace with `list` +help: Replace with `list` -UP006_0.py:57:10: UP006 Use `list` instead of `List` for type annotation +UP006 Use `list` instead of `List` for type annotation + --> UP006_0.py:57:10 | 57 | def f(x: "Li" "st['List[str]']") -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^^^^^^^^^^^ 58 | ... | - = help: Replace with `list` +help: Replace with `list` -UP006_0.py:61:10: UP006 [*] Use `collections.deque` instead of `typing.Deque` for type annotation +UP006 [*] Use `collections.deque` instead of `typing.Deque` for type annotation + --> UP006_0.py:61:10 | 61 | def f(x: typing.Deque[str]) -> None: - | ^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^ 62 | ... | - = help: Replace with `collections.deque` +help: Replace with `collections.deque` ℹ Safe fix 20 20 | @@ -258,13 +273,14 @@ UP006_0.py:61:10: UP006 [*] Use `collections.deque` instead of `typing.Deque` fo 63 64 | 64 65 | -UP006_0.py:65:10: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation +UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation + --> UP006_0.py:65:10 | 65 | def f(x: typing.DefaultDict[str, str]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^^^^^^^ 66 | ... | - = help: Replace with `collections.defaultdict` +help: Replace with `collections.defaultdict` ℹ Safe fix 20 20 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap index f262fe0498..680fe6a594 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP006_1.py:9:10: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation +UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation + --> UP006_1.py:9:10 | 9 | def f(x: typing.DefaultDict[str, str]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^^^^^^^ 10 | ... | - = help: Replace with `collections.defaultdict` +help: Replace with `collections.defaultdict` ℹ Safe fix 6 6 | from collections import defaultdict diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_2.py.snap index adc1afe1ef..e03ab73fc8 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_2.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP006_2.py:7:10: UP006 Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation +UP006 Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation + --> UP006_2.py:7:10 | 7 | def f(x: typing.DefaultDict[str, str]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^^^^^^^ 8 | ... | - = help: Replace with `collections.defaultdict` +help: Replace with `collections.defaultdict` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap index b9d64a074b..956d599409 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP006_3.py:7:11: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation +UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation + --> UP006_3.py:7:11 | 7 | def f(x: "typing.DefaultDict[str, str]") -> None: - | ^^^^^^^^^^^^^^^^^^ UP006 + | ^^^^^^^^^^^^^^^^^^ 8 | ... | - = help: Replace with `collections.defaultdict` +help: Replace with `collections.defaultdict` ℹ Safe fix 4 4 | from collections import defaultdict diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap index d61828d4c4..8d7774bbe1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP007.py:5:10: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:5:10 | 5 | def f(x: Union[str, int, Union[float, bytes]]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 2 2 | from typing import Union @@ -19,13 +20,14 @@ UP007.py:5:10: UP007 [*] Use `X | Y` for type annotations 7 7 | 8 8 | -UP007.py:5:26: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:5:26 | 5 | def f(x: Union[str, int, Union[float, bytes]]) -> None: - | ^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^ 6 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 2 2 | from typing import Union @@ -37,13 +39,14 @@ UP007.py:5:26: UP007 [*] Use `X | Y` for type annotations 7 7 | 8 8 | -UP007.py:9:10: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:9:10 | 9 | def f(x: typing.Union[str, int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^ 10 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 6 6 | ... @@ -55,13 +58,14 @@ UP007.py:9:10: UP007 [*] Use `X | Y` for type annotations 11 11 | 12 12 | -UP007.py:13:10: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:13:10 | 13 | def f(x: typing.Union[(str, int)]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 14 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 10 10 | ... @@ -73,13 +77,14 @@ UP007.py:13:10: UP007 [*] Use `X | Y` for type annotations 15 15 | 16 16 | -UP007.py:17:10: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:17:10 | 17 | def f(x: typing.Union[(str, int), float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 14 14 | ... @@ -91,13 +96,14 @@ UP007.py:17:10: UP007 [*] Use `X | Y` for type annotations 19 19 | 20 20 | -UP007.py:21:10: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:21:10 | 21 | def f(x: typing.Union[(int,)]) -> None: - | ^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^ 22 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 18 18 | ... @@ -109,13 +115,14 @@ UP007.py:21:10: UP007 [*] Use `X | Y` for type annotations 23 23 | 24 24 | -UP007.py:25:10: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:25:10 | 25 | def f(x: typing.Union[()]) -> None: - | ^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^ 26 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 22 22 | ... @@ -127,13 +134,14 @@ UP007.py:25:10: UP007 [*] Use `X | Y` for type annotations 27 27 | 28 28 | -UP007.py:29:11: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:29:11 | 29 | def f(x: "Union[str, int, Union[float, bytes]]") -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 26 26 | ... @@ -145,13 +153,14 @@ UP007.py:29:11: UP007 [*] Use `X | Y` for type annotations 31 31 | 32 32 | -UP007.py:29:27: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:29:27 | 29 | def f(x: "Union[str, int, Union[float, bytes]]") -> None: - | ^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^ 30 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 26 26 | ... @@ -163,13 +172,14 @@ UP007.py:29:27: UP007 [*] Use `X | Y` for type annotations 31 31 | 32 32 | -UP007.py:33:11: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:33:11 | 33 | def f(x: "typing.Union[str, int]") -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^ 34 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 30 30 | ... @@ -181,25 +191,27 @@ UP007.py:33:11: UP007 [*] Use `X | Y` for type annotations 35 35 | 36 36 | -UP007.py:46:9: UP007 Use `X | Y` for type annotations +UP007 Use `X | Y` for type annotations + --> UP007.py:46:9 | 45 | def f() -> None: 46 | x = Union[str, int] - | ^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^ 47 | x = Union["str", "int"] 48 | x: Union[str, int] | - = help: Convert to `X | Y` +help: Convert to `X | Y` -UP007.py:48:8: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:48:8 | 46 | x = Union[str, int] 47 | x = Union["str", "int"] 48 | x: Union[str, int] - | ^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^ 49 | x: Union["str", "int"] | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 45 45 | def f() -> None: @@ -211,14 +223,15 @@ UP007.py:48:8: UP007 [*] Use `X | Y` for type annotations 50 50 | 51 51 | -UP007.py:49:8: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:49:8 | 47 | x = Union["str", "int"] 48 | x: Union[str, int] 49 | x: Union["str", "int"] - | ^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 46 46 | x = Union[str, int] @@ -230,62 +243,69 @@ UP007.py:49:8: UP007 [*] Use `X | Y` for type annotations 51 51 | 52 52 | def f(x: Union[int : float]) -> None: -UP007.py:52:10: UP007 Use `X | Y` for type annotations +UP007 Use `X | Y` for type annotations + --> UP007.py:52:10 | 52 | def f(x: Union[int : float]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^ 53 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` -UP007.py:56:10: UP007 Use `X | Y` for type annotations +UP007 Use `X | Y` for type annotations + --> UP007.py:56:10 | 56 | def f(x: Union[str, int : float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^^ 57 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` -UP007.py:60:10: UP007 Use `X | Y` for type annotations +UP007 Use `X | Y` for type annotations + --> UP007.py:60:10 | 60 | def f(x: Union[x := int]) -> None: - | ^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^ 61 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` -UP007.py:64:10: UP007 Use `X | Y` for type annotations +UP007 Use `X | Y` for type annotations + --> UP007.py:64:10 | 64 | def f(x: Union[str, x := int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^ 65 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` -UP007.py:68:10: UP007 Use `X | Y` for type annotations +UP007 Use `X | Y` for type annotations + --> UP007.py:68:10 | 68 | def f(x: Union[lambda: int]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^ 69 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` -UP007.py:72:10: UP007 Use `X | Y` for type annotations +UP007 Use `X | Y` for type annotations + --> UP007.py:72:10 | 72 | def f(x: Union[str, lambda: int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^^ 73 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` -UP007.py:83:10: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:83:10 | 82 | # Regression test for: https://github.com/astral-sh/ruff/issues/8609 83 | def f(x: Union[int, str, bytes]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^ 84 | ... | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 80 80 | @@ -297,15 +317,16 @@ UP007.py:83:10: UP007 [*] Use `X | Y` for type annotations 85 85 | 86 86 | -UP007.py:91:26: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> UP007.py:91:26 | 89 | ... 90 | 91 | def myfunc(param: "tuple[Union[int, 'AClass', None], str]"): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 92 | print(param) | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 88 88 | class AClass: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap index f6070b8ded..b0d8a7da1c 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP008.py:17:23: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:17:23 | 16 | def wrong(self): 17 | parent = super(Child, self) # wrong - | ^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^ 18 | super(Child, self).method # wrong 19 | super( | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 14 14 | Parent.super(1, 2) # ok @@ -21,16 +22,17 @@ UP008.py:17:23: UP008 [*] Use `super()` instead of `super(__class__, self)` 19 19 | super( 20 20 | Child, -UP008.py:18:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:18:14 | 16 | def wrong(self): 17 | parent = super(Child, self) # wrong 18 | super(Child, self).method # wrong - | ^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^ 19 | super( 20 | Child, | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 15 15 | @@ -42,7 +44,8 @@ UP008.py:18:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 20 20 | Child, 21 21 | self, -UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:19:14 | 17 | parent = super(Child, self) # wrong 18 | super(Child, self).method # wrong @@ -51,9 +54,9 @@ UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 20 | | Child, 21 | | self, 22 | | ).method() # wrong - | |_________^ UP008 + | |_________^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 16 16 | def wrong(self): @@ -68,15 +71,16 @@ UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 24 21 | 25 22 | class BaseClass: -UP008.py:36:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:36:14 | 34 | class MyClass(BaseClass): 35 | def normal(self): 36 | super(MyClass, self).f() # can use super() - | ^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^ 37 | super().f() | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 33 33 | @@ -88,14 +92,15 @@ UP008.py:36:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 38 38 | 39 39 | def different_argument(self, other): -UP008.py:50:18: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:50:18 | 49 | def inner_argument(self): 50 | super(MyClass, self).f() # can use super() - | ^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^ 51 | super().f() | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 47 47 | super(MyClass, self).f() # CANNOT use super() @@ -107,15 +112,16 @@ UP008.py:50:18: UP008 [*] Use `super()` instead of `super(__class__, self)` 52 52 | 53 53 | outer_argument() -UP008.py:74:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:74:14 | 72 | class DataClass: 73 | def normal(self): 74 | super(DataClass, self).f() # Error - | ^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^ 75 | super().f() # OK | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 71 71 | @dataclass @@ -127,14 +133,15 @@ UP008.py:74:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 76 76 | 77 77 | -UP008.py:92:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:92:14 | 90 | class B(A): 91 | def bar(self): 92 | super(__class__, self).foo() - | ^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 89 89 | @@ -146,14 +153,15 @@ UP008.py:92:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 94 94 | 95 95 | # see: https://github.com/astral-sh/ruff/issues/18684 -UP008.py:107:23: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:107:23 | 105 | class C: 106 | def f(self): 107 | builtins.super(C, self) - | ^^^^^^^^^ UP008 + | ^^^^^^^^^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 104 104 | @@ -165,7 +173,8 @@ UP008.py:107:23: UP008 [*] Use `super()` instead of `super(__class__, self)` 109 109 | 110 110 | # see: https://github.com/astral-sh/ruff/issues/18533 -UP008.py:113:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:113:14 | 111 | class ClassForCommentEnthusiasts(BaseClass): 112 | def with_comments(self): @@ -175,11 +184,11 @@ UP008.py:113:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 115 | | ClassForCommentEnthusiasts, 116 | | self 117 | | ).f() - | |_________^ UP008 + | |_________^ 118 | super( 119 | ClassForCommentEnthusiasts, | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 110 110 | # see: https://github.com/astral-sh/ruff/issues/18533 @@ -195,7 +204,8 @@ UP008.py:113:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 119 115 | ClassForCommentEnthusiasts, 120 116 | # even more helpful comment -UP008.py:118:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:118:14 | 116 | self 117 | ).f() @@ -205,11 +215,11 @@ UP008.py:118:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 120 | | # even more helpful comment 121 | | self 122 | | ).f() - | |_________^ UP008 + | |_________^ 123 | super( 124 | ClassForCommentEnthusiasts, | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 115 115 | ClassForCommentEnthusiasts, @@ -225,7 +235,8 @@ UP008.py:118:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 124 120 | ClassForCommentEnthusiasts, 125 121 | self -UP008.py:123:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:123:14 | 121 | self 122 | ).f() @@ -235,9 +246,9 @@ UP008.py:123:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 125 | | self 126 | | # also a comment 127 | | ).f() - | |_________^ UP008 + | |_________^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 120 120 | # even more helpful comment @@ -253,45 +264,49 @@ UP008.py:123:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 129 125 | 130 126 | # Issue #19096: super calls with keyword arguments should emit diagnostic but not be fixed -UP008.py:133:21: UP008 Use `super()` instead of `super(__class__, self)` +UP008 Use `super()` instead of `super(__class__, self)` + --> UP008.py:133:21 | 131 | class Ord(int): 132 | def __len__(self): 133 | return super(Ord, self, uhoh=True, **{"error": True}).bit_length() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 134 | 135 | class ExampleWithKeywords: | - = help: Remove `super()` parameters +help: Remove `super()` parameters -UP008.py:137:14: UP008 Use `super()` instead of `super(__class__, self)` +UP008 Use `super()` instead of `super(__class__, self)` + --> UP008.py:137:14 | 135 | class ExampleWithKeywords: 136 | def method1(self): 137 | super(ExampleWithKeywords, self, invalid=True).some_method() # Should emit diagnostic but NOT be fixed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 138 | 139 | def method2(self): | - = help: Remove `super()` parameters +help: Remove `super()` parameters -UP008.py:140:14: UP008 Use `super()` instead of `super(__class__, self)` +UP008 Use `super()` instead of `super(__class__, self)` + --> UP008.py:140:14 | 139 | def method2(self): 140 | super(ExampleWithKeywords, self, **{"kwarg": "value"}).some_method() # Should emit diagnostic but NOT be fixed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 141 | 142 | def method3(self): | - = help: Remove `super()` parameters +help: Remove `super()` parameters -UP008.py:143:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:143:14 | 142 | def method3(self): 143 | super(ExampleWithKeywords, self).some_method() # Should be fixed - no keywords - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 140 140 | super(ExampleWithKeywords, self, **{"kwarg": "value"}).some_method() # Should emit diagnostic but NOT be fixed diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py__preview.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py__preview.snap index c6c4bf37f1..ab4386423d 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py__preview.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py__preview.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP008.py:17:23: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:17:23 | 16 | def wrong(self): 17 | parent = super(Child, self) # wrong - | ^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^ 18 | super(Child, self).method # wrong 19 | super( | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 14 14 | Parent.super(1, 2) # ok @@ -21,16 +22,17 @@ UP008.py:17:23: UP008 [*] Use `super()` instead of `super(__class__, self)` 19 19 | super( 20 20 | Child, -UP008.py:18:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:18:14 | 16 | def wrong(self): 17 | parent = super(Child, self) # wrong 18 | super(Child, self).method # wrong - | ^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^ 19 | super( 20 | Child, | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 15 15 | @@ -42,7 +44,8 @@ UP008.py:18:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 20 20 | Child, 21 21 | self, -UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:19:14 | 17 | parent = super(Child, self) # wrong 18 | super(Child, self).method # wrong @@ -51,9 +54,9 @@ UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 20 | | Child, 21 | | self, 22 | | ).method() # wrong - | |_________^ UP008 + | |_________^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 16 16 | def wrong(self): @@ -68,15 +71,16 @@ UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 24 21 | 25 22 | class BaseClass: -UP008.py:36:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:36:14 | 34 | class MyClass(BaseClass): 35 | def normal(self): 36 | super(MyClass, self).f() # can use super() - | ^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^ 37 | super().f() | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 33 33 | @@ -88,14 +92,15 @@ UP008.py:36:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 38 38 | 39 39 | def different_argument(self, other): -UP008.py:50:18: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:50:18 | 49 | def inner_argument(self): 50 | super(MyClass, self).f() # can use super() - | ^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^ 51 | super().f() | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 47 47 | super(MyClass, self).f() # CANNOT use super() @@ -107,15 +112,16 @@ UP008.py:50:18: UP008 [*] Use `super()` instead of `super(__class__, self)` 52 52 | 53 53 | outer_argument() -UP008.py:74:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:74:14 | 72 | class DataClass: 73 | def normal(self): 74 | super(DataClass, self).f() # Error - | ^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^ 75 | super().f() # OK | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 71 71 | @dataclass @@ -127,14 +133,15 @@ UP008.py:74:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 76 76 | 77 77 | -UP008.py:92:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:92:14 | 90 | class B(A): 91 | def bar(self): 92 | super(__class__, self).foo() - | ^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 89 89 | @@ -146,14 +153,15 @@ UP008.py:92:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 94 94 | 95 95 | # see: https://github.com/astral-sh/ruff/issues/18684 -UP008.py:107:23: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:107:23 | 105 | class C: 106 | def f(self): 107 | builtins.super(C, self) - | ^^^^^^^^^ UP008 + | ^^^^^^^^^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 104 104 | @@ -165,7 +173,8 @@ UP008.py:107:23: UP008 [*] Use `super()` instead of `super(__class__, self)` 109 109 | 110 110 | # see: https://github.com/astral-sh/ruff/issues/18533 -UP008.py:113:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:113:14 | 111 | class ClassForCommentEnthusiasts(BaseClass): 112 | def with_comments(self): @@ -175,11 +184,11 @@ UP008.py:113:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 115 | | ClassForCommentEnthusiasts, 116 | | self 117 | | ).f() - | |_________^ UP008 + | |_________^ 118 | super( 119 | ClassForCommentEnthusiasts, | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 110 110 | # see: https://github.com/astral-sh/ruff/issues/18533 @@ -195,7 +204,8 @@ UP008.py:113:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 119 115 | ClassForCommentEnthusiasts, 120 116 | # even more helpful comment -UP008.py:118:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:118:14 | 116 | self 117 | ).f() @@ -205,11 +215,11 @@ UP008.py:118:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 120 | | # even more helpful comment 121 | | self 122 | | ).f() - | |_________^ UP008 + | |_________^ 123 | super( 124 | ClassForCommentEnthusiasts, | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 115 115 | ClassForCommentEnthusiasts, @@ -225,7 +235,8 @@ UP008.py:118:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 124 120 | ClassForCommentEnthusiasts, 125 121 | self -UP008.py:123:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:123:14 | 121 | self 122 | ).f() @@ -235,9 +246,9 @@ UP008.py:123:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 125 | | self 126 | | # also a comment 127 | | ).f() - | |_________^ UP008 + | |_________^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Unsafe fix 120 120 | # even more helpful comment @@ -253,45 +264,49 @@ UP008.py:123:14: UP008 [*] Use `super()` instead of `super(__class__, self)` 129 125 | 130 126 | # Issue #19096: super calls with keyword arguments should emit diagnostic but not be fixed -UP008.py:133:21: UP008 Use `super()` instead of `super(__class__, self)` +UP008 Use `super()` instead of `super(__class__, self)` + --> UP008.py:133:21 | 131 | class Ord(int): 132 | def __len__(self): 133 | return super(Ord, self, uhoh=True, **{"error": True}).bit_length() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 134 | 135 | class ExampleWithKeywords: | - = help: Remove `super()` parameters +help: Remove `super()` parameters -UP008.py:137:14: UP008 Use `super()` instead of `super(__class__, self)` +UP008 Use `super()` instead of `super(__class__, self)` + --> UP008.py:137:14 | 135 | class ExampleWithKeywords: 136 | def method1(self): 137 | super(ExampleWithKeywords, self, invalid=True).some_method() # Should emit diagnostic but NOT be fixed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 138 | 139 | def method2(self): | - = help: Remove `super()` parameters +help: Remove `super()` parameters -UP008.py:140:14: UP008 Use `super()` instead of `super(__class__, self)` +UP008 Use `super()` instead of `super(__class__, self)` + --> UP008.py:140:14 | 139 | def method2(self): 140 | super(ExampleWithKeywords, self, **{"kwarg": "value"}).some_method() # Should emit diagnostic but NOT be fixed - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 141 | 142 | def method3(self): | - = help: Remove `super()` parameters +help: Remove `super()` parameters -UP008.py:143:14: UP008 [*] Use `super()` instead of `super(__class__, self)` +UP008 [*] Use `super()` instead of `super(__class__, self)` + --> UP008.py:143:14 | 142 | def method3(self): 143 | super(ExampleWithKeywords, self).some_method() # Should be fixed - no keywords - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP008 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove `super()` parameters +help: Remove `super()` parameters ℹ Safe fix 140 140 | super(ExampleWithKeywords, self, **{"kwarg": "value"}).some_method() # Should emit diagnostic but NOT be fixed diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap index 496c05b804..d13be47734 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP009_0.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary +UP009 [*] UTF-8 encoding declaration is unnecessary + --> UP009_0.py:1:1 | 1 | # coding=utf8 - | ^^^^^^^^^^^^^ UP009 + | ^^^^^^^^^^^^^ 2 | 3 | print("Hello world") | - = help: Remove unnecessary coding comment +help: Remove unnecessary coding comment ℹ Safe fix 1 |-# coding=utf8 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap index 5b64115e35..518d66064e 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP009_1.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary +UP009 [*] UTF-8 encoding declaration is unnecessary + --> UP009_1.py:2:1 | 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- - | ^^^^^^^^^^^^^^^^^^^^^^^ UP009 + | ^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | print('Hello world') | - = help: Remove unnecessary coding comment +help: Remove unnecessary coding comment ℹ Safe fix 1 1 | #!/usr/bin/python diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap index b588ce12d9..51aa5c1f21 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP009_6.py:1:2: UP009 [*] UTF-8 encoding declaration is unnecessary +UP009 [*] UTF-8 encoding declaration is unnecessary + --> UP009_6.py:1:2 | 1 | # coding=utf8 - | ^^^^^^^^^^^^^ UP009 + | ^^^^^^^^^^^^^ 2 | print("Hello world") | - = help: Remove unnecessary coding comment +help: Remove unnecessary coding comment ℹ Safe fix 1 |- # coding=utf8 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap index ee89c5f61a..172cef836e 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP009_7.py:1:2: UP009 [*] UTF-8 encoding declaration is unnecessary +UP009 [*] UTF-8 encoding declaration is unnecessary + --> UP009_7.py:1:2 | 1 | # coding=utf8 - | ^^^^^^^^^^^^^ UP009 + | ^^^^^^^^^^^^^ 2 | print("Hello world") | - = help: Remove unnecessary coding comment +help: Remove unnecessary coding comment ℹ Safe fix 1 |- # coding=utf8 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_code_other.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_code_other.py.snap index ac9c9e5a45..62c3c09c76 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_code_other.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_code_other.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP009_utf8_code_other.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary +UP009 [*] UTF-8 encoding declaration is unnecessary + --> UP009_utf8_code_other.py:1:1 | 1 | # -*- coding: utf8 -*- - | ^^^^^^^^^^^^^^^^^^^^^^ UP009 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | print("the following is not a coding comment") 3 | # -*- coding: ascii -*- | - = help: Remove unnecessary coding comment +help: Remove unnecessary coding comment ℹ Safe fix 1 |-# -*- coding: utf8 -*- diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_utf8.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_utf8.py.snap index 71358de177..cdf3e2b5b1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_utf8.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_utf8.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP009_utf8_utf8.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary +UP009 [*] UTF-8 encoding declaration is unnecessary + --> UP009_utf8_utf8.py:1:1 | 1 | # -*- coding: utf-8 -*- - | ^^^^^^^^^^^^^^^^^^^^^^^ UP009 + | ^^^^^^^^^^^^^^^^^^^^^^^ 2 | # -*- coding: utf-8 -*- | - = help: Remove unnecessary coding comment +help: Remove unnecessary coding comment ℹ Safe fix 1 1 | # -*- coding: utf-8 -*- diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_utf8_other.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_utf8_other.py.snap index 42a521a4b0..6cefa818a7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_utf8_other.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_utf8_utf8_other.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP009_utf8_utf8_other.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary +UP009 [*] UTF-8 encoding declaration is unnecessary + --> UP009_utf8_utf8_other.py:1:1 | 1 | # -*- coding: utf-8 -*- - | ^^^^^^^^^^^^^^^^^^^^^^^ UP009 + | ^^^^^^^^^^^^^^^^^^^^^^^ 2 | # -*- coding: utf-8 -*- 3 | # -*- coding: ascii -*- | - = help: Remove unnecessary coding comment +help: Remove unnecessary coding comment ℹ Safe fix 1 1 | # -*- coding: utf-8 -*- diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap index 4696822fe9..58c064522c 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP010.py:1:1: UP010 [*] Unnecessary `__future__` imports `generators`, `nested_scopes` for target Python version +UP010 [*] Unnecessary `__future__` imports `generators`, `nested_scopes` for target Python version + --> UP010.py:1:1 | 1 | from __future__ import nested_scopes, generators - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | from __future__ import with_statement, unicode_literals 3 | from __future__ import absolute_import, division | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 1 |-from __future__ import nested_scopes, generators @@ -16,15 +17,16 @@ UP010.py:1:1: UP010 [*] Unnecessary `__future__` imports `generators`, `nested_s 3 2 | from __future__ import absolute_import, division 4 3 | from __future__ import generator_stop -UP010.py:2:1: UP010 [*] Unnecessary `__future__` imports `unicode_literals`, `with_statement` for target Python version +UP010 [*] Unnecessary `__future__` imports `unicode_literals`, `with_statement` for target Python version + --> UP010.py:2:1 | 1 | from __future__ import nested_scopes, generators 2 | from __future__ import with_statement, unicode_literals - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | from __future__ import absolute_import, division 4 | from __future__ import generator_stop | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 1 1 | from __future__ import nested_scopes, generators @@ -33,16 +35,17 @@ UP010.py:2:1: UP010 [*] Unnecessary `__future__` imports `unicode_literals`, `wi 4 3 | from __future__ import generator_stop 5 4 | from __future__ import print_function, generator_stop -UP010.py:3:1: UP010 [*] Unnecessary `__future__` imports `absolute_import`, `division` for target Python version +UP010 [*] Unnecessary `__future__` imports `absolute_import`, `division` for target Python version + --> UP010.py:3:1 | 1 | from __future__ import nested_scopes, generators 2 | from __future__ import with_statement, unicode_literals 3 | from __future__ import absolute_import, division - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | from __future__ import generator_stop 5 | from __future__ import print_function, generator_stop | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 1 1 | from __future__ import nested_scopes, generators @@ -52,16 +55,17 @@ UP010.py:3:1: UP010 [*] Unnecessary `__future__` imports `absolute_import`, `div 5 4 | from __future__ import print_function, generator_stop 6 5 | from __future__ import invalid_module, generators -UP010.py:4:1: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version +UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version + --> UP010.py:4:1 | 2 | from __future__ import with_statement, unicode_literals 3 | from __future__ import absolute_import, division 4 | from __future__ import generator_stop - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | from __future__ import print_function, generator_stop 6 | from __future__ import invalid_module, generators | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 1 1 | from __future__ import nested_scopes, generators @@ -72,15 +76,16 @@ UP010.py:4:1: UP010 [*] Unnecessary `__future__` import `generator_stop` for tar 6 5 | from __future__ import invalid_module, generators 7 6 | -UP010.py:5:1: UP010 [*] Unnecessary `__future__` imports `generator_stop`, `print_function` for target Python version +UP010 [*] Unnecessary `__future__` imports `generator_stop`, `print_function` for target Python version + --> UP010.py:5:1 | 3 | from __future__ import absolute_import, division 4 | from __future__ import generator_stop 5 | from __future__ import print_function, generator_stop - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | from __future__ import invalid_module, generators | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 2 2 | from __future__ import with_statement, unicode_literals @@ -91,16 +96,17 @@ UP010.py:5:1: UP010 [*] Unnecessary `__future__` imports `generator_stop`, `prin 7 6 | 8 7 | if True: -UP010.py:6:1: UP010 [*] Unnecessary `__future__` import `generators` for target Python version +UP010 [*] Unnecessary `__future__` import `generators` for target Python version + --> UP010.py:6:1 | 4 | from __future__ import generator_stop 5 | from __future__ import print_function, generator_stop 6 | from __future__ import invalid_module, generators - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | if True: | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 3 3 | from __future__ import absolute_import, division @@ -112,14 +118,15 @@ UP010.py:6:1: UP010 [*] Unnecessary `__future__` import `generators` for target 8 8 | if True: 9 9 | from __future__ import generator_stop -UP010.py:9:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version +UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version + --> UP010.py:9:5 | 8 | if True: 9 | from __future__ import generator_stop - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | from __future__ import generators | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 6 6 | from __future__ import invalid_module, generators @@ -130,16 +137,17 @@ UP010.py:9:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for tar 11 10 | 12 11 | if True: -UP010.py:10:5: UP010 [*] Unnecessary `__future__` import `generators` for target Python version +UP010 [*] Unnecessary `__future__` import `generators` for target Python version + --> UP010.py:10:5 | 8 | if True: 9 | from __future__ import generator_stop 10 | from __future__ import generators - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | if True: | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 7 7 | @@ -150,15 +158,16 @@ UP010.py:10:5: UP010 [*] Unnecessary `__future__` import `generators` for target 12 11 | if True: 13 12 | from __future__ import generator_stop -UP010.py:13:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version +UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version + --> UP010.py:13:5 | 12 | if True: 13 | from __future__ import generator_stop - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | from __future__ import invalid_module, generators 15 | from __future__ import generators # comment | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 10 10 | from __future__ import generators @@ -168,15 +177,16 @@ UP010.py:13:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for ta 14 13 | from __future__ import invalid_module, generators 15 14 | from __future__ import generators # comment -UP010.py:14:5: UP010 [*] Unnecessary `__future__` import `generators` for target Python version +UP010 [*] Unnecessary `__future__` import `generators` for target Python version + --> UP010.py:14:5 | 12 | if True: 13 | from __future__ import generator_stop 14 | from __future__ import invalid_module, generators - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | from __future__ import generators # comment | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Safe fix 11 11 | @@ -186,14 +196,15 @@ UP010.py:14:5: UP010 [*] Unnecessary `__future__` import `generators` for target 14 |+ from __future__ import invalid_module 15 15 | from __future__ import generators # comment -UP010.py:15:5: UP010 [*] Unnecessary `__future__` import `generators` for target Python version +UP010 [*] Unnecessary `__future__` import `generators` for target Python version + --> UP010.py:15:5 | 13 | from __future__ import generator_stop 14 | from __future__ import invalid_module, generators 15 | from __future__ import generators # comment - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove unnecessary `__future__` import +help: Remove unnecessary `__future__` import ℹ Unsafe fix 12 12 | if True: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap index 7fb2e270ca..fe85949af8 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP011.py:5:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` +UP011 [*] Unnecessary parentheses to `functools.lru_cache` + --> UP011.py:5:21 | 5 | @functools.lru_cache() - | ^^ UP011 + | ^^ 6 | def fixme(): 7 | pass | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 2 2 | from functools import lru_cache @@ -21,14 +21,15 @@ UP011.py:5:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` 7 7 | pass 8 8 | -UP011.py:10:11: UP011 [*] Unnecessary parentheses to `functools.lru_cache` +UP011 [*] Unnecessary parentheses to `functools.lru_cache` + --> UP011.py:10:11 | 10 | @lru_cache() - | ^^ UP011 + | ^^ 11 | def fixme(): 12 | pass | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 7 7 | pass @@ -40,15 +41,16 @@ UP011.py:10:11: UP011 [*] Unnecessary parentheses to `functools.lru_cache` 12 12 | pass 13 13 | -UP011.py:16:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` +UP011 [*] Unnecessary parentheses to `functools.lru_cache` + --> UP011.py:16:21 | 15 | @other_decorator 16 | @functools.lru_cache() - | ^^ UP011 + | ^^ 17 | def fixme(): 18 | pass | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 13 13 | @@ -60,14 +62,15 @@ UP011.py:16:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` 18 18 | pass 19 19 | -UP011.py:21:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` +UP011 [*] Unnecessary parentheses to `functools.lru_cache` + --> UP011.py:21:21 | 21 | @functools.lru_cache() - | ^^ UP011 + | ^^ 22 | @other_decorator 23 | def fixme(): | - = help: Remove unnecessary parentheses +help: Remove unnecessary parentheses ℹ Safe fix 18 18 | pass diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap index a3e42b982f..cc02002e15 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP012.py:2:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:2:1 | 1 | # ASCII literals should be replaced by a bytes literal 2 | "foo".encode("utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^ 3 | "foo".encode("u8") # b"foo" 4 | "foo".encode() # b"foo" | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 1 1 | # ASCII literals should be replaced by a bytes literal @@ -19,16 +20,17 @@ UP012.py:2:1: UP012 [*] Unnecessary call to `encode` as UTF-8 4 4 | "foo".encode() # b"foo" 5 5 | "foo".encode("UTF8") # b"foo" -UP012.py:3:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:3:1 | 1 | # ASCII literals should be replaced by a bytes literal 2 | "foo".encode("utf-8") # b"foo" 3 | "foo".encode("u8") # b"foo" - | ^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^ 4 | "foo".encode() # b"foo" 5 | "foo".encode("UTF8") # b"foo" | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 1 1 | # ASCII literals should be replaced by a bytes literal @@ -39,16 +41,17 @@ UP012.py:3:1: UP012 [*] Unnecessary call to `encode` as UTF-8 5 5 | "foo".encode("UTF8") # b"foo" 6 6 | U"foo".encode("utf-8") # b"foo" -UP012.py:4:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:4:1 | 2 | "foo".encode("utf-8") # b"foo" 3 | "foo".encode("u8") # b"foo" 4 | "foo".encode() # b"foo" - | ^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^ 5 | "foo".encode("UTF8") # b"foo" 6 | U"foo".encode("utf-8") # b"foo" | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 1 1 | # ASCII literals should be replaced by a bytes literal @@ -60,16 +63,17 @@ UP012.py:4:1: UP012 [*] Unnecessary call to `encode` as UTF-8 6 6 | U"foo".encode("utf-8") # b"foo" 7 7 | "foo".encode(encoding="utf-8") # b"foo" -UP012.py:5:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:5:1 | 3 | "foo".encode("u8") # b"foo" 4 | "foo".encode() # b"foo" 5 | "foo".encode("UTF8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^ 6 | U"foo".encode("utf-8") # b"foo" 7 | "foo".encode(encoding="utf-8") # b"foo" | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 2 2 | "foo".encode("utf-8") # b"foo" @@ -81,16 +85,17 @@ UP012.py:5:1: UP012 [*] Unnecessary call to `encode` as UTF-8 7 7 | "foo".encode(encoding="utf-8") # b"foo" 8 8 | """ -UP012.py:6:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:6:1 | 4 | "foo".encode() # b"foo" 5 | "foo".encode("UTF8") # b"foo" 6 | U"foo".encode("utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^ 7 | "foo".encode(encoding="utf-8") # b"foo" 8 | """ | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 3 3 | "foo".encode("u8") # b"foo" @@ -102,16 +107,17 @@ UP012.py:6:1: UP012 [*] Unnecessary call to `encode` as UTF-8 8 8 | """ 9 9 | Lorem -UP012.py:7:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:7:1 | 5 | "foo".encode("UTF8") # b"foo" 6 | U"foo".encode("utf-8") # b"foo" 7 | "foo".encode(encoding="utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | """ 9 | Lorem | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 4 4 | "foo".encode() # b"foo" @@ -123,7 +129,8 @@ UP012.py:7:1: UP012 [*] Unnecessary call to `encode` as UTF-8 9 9 | Lorem 10 10 | -UP012.py:8:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:8:1 | 6 | U"foo".encode("utf-8") # b"foo" 7 | "foo".encode(encoding="utf-8") # b"foo" @@ -134,11 +141,11 @@ UP012.py:8:1: UP012 [*] Unnecessary call to `encode` as UTF-8 12 | | """.encode( 13 | | "utf-8" 14 | | ) - | |_^ UP012 + | |_^ 15 | ( 16 | "Lorem " | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 5 5 | "foo".encode("UTF8") # b"foo" @@ -157,17 +164,18 @@ UP012.py:8:1: UP012 [*] Unnecessary call to `encode` as UTF-8 16 14 | "Lorem " 17 15 | "Ipsum".encode() -UP012.py:16:5: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:16:5 | 14 | ) 15 | ( 16 | / "Lorem " 17 | | "Ipsum".encode() - | |____________________^ UP012 + | |____________________^ 18 | ) 19 | ( | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 13 13 | "utf-8" @@ -181,17 +189,18 @@ UP012.py:16:5: UP012 [*] Unnecessary call to `encode` as UTF-8 19 19 | ( 20 20 | "Lorem " # Comment -UP012.py:20:5: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:20:5 | 18 | ) 19 | ( 20 | / "Lorem " # Comment 21 | | "Ipsum".encode() # Comment - | |____________________^ UP012 + | |____________________^ 22 | ) 23 | ( | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 17 17 | "Ipsum".encode() @@ -205,15 +214,16 @@ UP012.py:20:5: UP012 [*] Unnecessary call to `encode` as UTF-8 23 23 | ( 24 24 | "Lorem " "Ipsum".encode() -UP012.py:24:5: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:24:5 | 22 | ) 23 | ( 24 | "Lorem " "Ipsum".encode() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | ) | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 21 21 | "Ipsum".encode() # Comment @@ -225,15 +235,16 @@ UP012.py:24:5: UP012 [*] Unnecessary call to `encode` as UTF-8 26 26 | 27 27 | # `encode` on variables should not be processed. -UP012.py:32:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` +UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + --> UP012.py:32:1 | 31 | bar = "bar" 32 | f"foo{bar}".encode("utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | encoding = "latin" 34 | "foo".encode(encoding) | - = help: Remove unnecessary `encoding` argument +help: Remove unnecessary `encoding` argument ℹ Safe fix 29 29 | string.encode("utf-8") @@ -245,18 +256,19 @@ UP012.py:32:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 34 34 | "foo".encode(encoding) 35 35 | f"foo{bar}".encode(encoding) -UP012.py:36:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` +UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + --> UP012.py:36:1 | 34 | "foo".encode(encoding) 35 | f"foo{bar}".encode(encoding) 36 | / f"{a=} {b=}".encode( 37 | | "utf-8", 38 | | ) - | |_^ UP012 + | |_^ 39 | 40 | # `encode` with custom args and kwargs should not be processed. | - = help: Remove unnecessary `encoding` argument +help: Remove unnecessary `encoding` argument ℹ Safe fix 33 33 | encoding = "latin" @@ -270,15 +282,16 @@ UP012.py:36:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 40 38 | # `encode` with custom args and kwargs should not be processed. 41 39 | "foo".encode("utf-8", errors="replace") -UP012.py:53:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` +UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + --> UP012.py:53:1 | 52 | # Unicode literals should only be stripped of default encoding. 53 | "unicode text©".encode("utf-8") # "unicode text©".encode() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | "unicode text©".encode() 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() | - = help: Remove unnecessary `encoding` argument +help: Remove unnecessary `encoding` argument ℹ Safe fix 50 50 | "unicode text©".encode(encoding="utf-8", errors="replace") @@ -290,16 +303,17 @@ UP012.py:53:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() 56 56 | -UP012.py:55:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` +UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + --> UP012.py:55:1 | 53 | "unicode text©".encode("utf-8") # "unicode text©".encode() 54 | "unicode text©".encode() 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | 57 | r"foo\o".encode("utf-8") # br"foo\o" | - = help: Remove unnecessary `encoding` argument +help: Remove unnecessary `encoding` argument ℹ Safe fix 52 52 | # Unicode literals should only be stripped of default encoding. @@ -311,16 +325,17 @@ UP012.py:55:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 57 57 | r"foo\o".encode("utf-8") # br"foo\o" 58 58 | u"foo".encode("utf-8") # b"foo" -UP012.py:57:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:57:1 | 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() 56 | 57 | r"foo\o".encode("utf-8") # br"foo\o" - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 58 | u"foo".encode("utf-8") # b"foo" 59 | R"foo\o".encode("utf-8") # br"foo\o" | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 54 54 | "unicode text©".encode() @@ -332,15 +347,16 @@ UP012.py:57:1: UP012 [*] Unnecessary call to `encode` as UTF-8 59 59 | R"foo\o".encode("utf-8") # br"foo\o" 60 60 | U"foo".encode("utf-8") # b"foo" -UP012.py:58:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:58:1 | 57 | r"foo\o".encode("utf-8") # br"foo\o" 58 | u"foo".encode("utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^ 59 | R"foo\o".encode("utf-8") # br"foo\o" 60 | U"foo".encode("utf-8") # b"foo" | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() @@ -352,16 +368,17 @@ UP012.py:58:1: UP012 [*] Unnecessary call to `encode` as UTF-8 60 60 | U"foo".encode("utf-8") # b"foo" 61 61 | print("foo".encode()) # print(b"foo") -UP012.py:59:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:59:1 | 57 | r"foo\o".encode("utf-8") # br"foo\o" 58 | u"foo".encode("utf-8") # b"foo" 59 | R"foo\o".encode("utf-8") # br"foo\o" - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 60 | U"foo".encode("utf-8") # b"foo" 61 | print("foo".encode()) # print(b"foo") | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 56 56 | @@ -373,15 +390,16 @@ UP012.py:59:1: UP012 [*] Unnecessary call to `encode` as UTF-8 61 61 | print("foo".encode()) # print(b"foo") 62 62 | -UP012.py:60:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:60:1 | 58 | u"foo".encode("utf-8") # b"foo" 59 | R"foo\o".encode("utf-8") # br"foo\o" 60 | U"foo".encode("utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^ 61 | print("foo".encode()) # print(b"foo") | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 57 57 | r"foo\o".encode("utf-8") # br"foo\o" @@ -393,16 +411,17 @@ UP012.py:60:1: UP012 [*] Unnecessary call to `encode` as UTF-8 62 62 | 63 63 | # `encode` on parenthesized strings. -UP012.py:61:7: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:61:7 | 59 | R"foo\o".encode("utf-8") # br"foo\o" 60 | U"foo".encode("utf-8") # b"foo" 61 | print("foo".encode()) # print(b"foo") - | ^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^ 62 | 63 | # `encode` on parenthesized strings. | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 58 58 | u"foo".encode("utf-8") # b"foo" @@ -414,18 +433,19 @@ UP012.py:61:7: UP012 [*] Unnecessary call to `encode` as UTF-8 63 63 | # `encode` on parenthesized strings. 64 64 | ( -UP012.py:64:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:64:1 | 63 | # `encode` on parenthesized strings. 64 | / ( 65 | | "abc" 66 | | "def" 67 | | ).encode() - | |__________^ UP012 + | |__________^ 68 | 69 | (( | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 62 62 | @@ -441,7 +461,8 @@ UP012.py:64:1: UP012 [*] Unnecessary call to `encode` as UTF-8 69 69 | (( 70 70 | "abc" -UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:69:1 | 67 | ).encode() 68 | @@ -449,11 +470,11 @@ UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8 70 | | "abc" 71 | | "def" 72 | | )).encode() - | |___________^ UP012 + | |___________^ 73 | 74 | (f"foo{bar}").encode("utf-8") | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 67 67 | ).encode() @@ -469,16 +490,17 @@ UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8 74 74 | (f"foo{bar}").encode("utf-8") 75 75 | (f"foo{bar}").encode(encoding="utf-8") -UP012.py:74:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` +UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + --> UP012.py:74:1 | 72 | )).encode() 73 | 74 | (f"foo{bar}").encode("utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | (f"foo{bar}").encode(encoding="utf-8") 76 | ("unicode text©").encode("utf-8") | - = help: Remove unnecessary `encoding` argument +help: Remove unnecessary `encoding` argument ℹ Safe fix 71 71 | "def" @@ -490,15 +512,16 @@ UP012.py:74:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 76 76 | ("unicode text©").encode("utf-8") 77 77 | ("unicode text©").encode(encoding="utf-8") -UP012.py:75:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` +UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + --> UP012.py:75:1 | 74 | (f"foo{bar}").encode("utf-8") 75 | (f"foo{bar}").encode(encoding="utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 76 | ("unicode text©").encode("utf-8") 77 | ("unicode text©").encode(encoding="utf-8") | - = help: Remove unnecessary `encoding` argument +help: Remove unnecessary `encoding` argument ℹ Safe fix 72 72 | )).encode() @@ -510,15 +533,16 @@ UP012.py:75:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 77 77 | ("unicode text©").encode(encoding="utf-8") 78 78 | -UP012.py:76:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` +UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + --> UP012.py:76:1 | 74 | (f"foo{bar}").encode("utf-8") 75 | (f"foo{bar}").encode(encoding="utf-8") 76 | ("unicode text©").encode("utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 77 | ("unicode text©").encode(encoding="utf-8") | - = help: Remove unnecessary `encoding` argument +help: Remove unnecessary `encoding` argument ℹ Safe fix 73 73 | @@ -530,14 +554,15 @@ UP012.py:76:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 78 78 | 79 79 | -UP012.py:77:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` +UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + --> UP012.py:77:1 | 75 | (f"foo{bar}").encode(encoding="utf-8") 76 | ("unicode text©").encode("utf-8") 77 | ("unicode text©").encode(encoding="utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove unnecessary `encoding` argument +help: Remove unnecessary `encoding` argument ℹ Safe fix 74 74 | (f"foo{bar}").encode("utf-8") @@ -549,16 +574,17 @@ UP012.py:77:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` 79 79 | 80 80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 -UP012.py:82:17: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:82:17 | 80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 81 | def _match_ignore(line): 82 | input=stdin and'\n'.encode()or None - | ^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^ 83 | 84 | # Not a valid type annotation but this test shouldn't result in a panic. | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 79 79 | @@ -570,16 +596,17 @@ UP012.py:82:17: UP012 [*] Unnecessary call to `encode` as UTF-8 84 84 | # Not a valid type annotation but this test shouldn't result in a panic. 85 85 | # Refer: https://github.com/astral-sh/ruff/issues/11736 -UP012.py:86:5: UP012 [*] Unnecessary call to `encode` as UTF-8 +UP012 [*] Unnecessary call to `encode` as UTF-8 + --> UP012.py:86:5 | 84 | # Not a valid type annotation but this test shouldn't result in a panic. 85 | # Refer: https://github.com/astral-sh/ruff/issues/11736 86 | x: '"foo".encode("utf-8")' - | ^^^^^^^^^^^^^^^^^^^^^ UP012 + | ^^^^^^^^^^^^^^^^^^^^^ 87 | 88 | # AttributeError for t-strings so skip lint | - = help: Rewrite as bytes literal +help: Rewrite as bytes literal ℹ Safe fix 83 83 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap index f428a3a4d7..ec78ba6e59 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP013.py:5:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:5:1 | 4 | # dict literal 5 | MyType = TypedDict("MyType", {"a": int, "b": str}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | # dict call | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 2 2 | import typing @@ -23,15 +24,16 @@ UP013.py:5:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class sy 7 9 | # dict call 8 10 | MyType = TypedDict("MyType", dict(a=int, b=str)) -UP013.py:8:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:8:1 | 7 | # dict call 8 | MyType = TypedDict("MyType", dict(a=int, b=str)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | # kwargs | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 5 5 | MyType = TypedDict("MyType", {"a": int, "b": str}) @@ -45,15 +47,16 @@ UP013.py:8:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class sy 10 12 | # kwargs 11 13 | MyType = TypedDict("MyType", a=int, b=str) -UP013.py:11:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:11:1 | 10 | # kwargs 11 | MyType = TypedDict("MyType", a=int, b=str) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | # Empty TypedDict | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 8 8 | MyType = TypedDict("MyType", dict(a=int, b=str)) @@ -67,15 +70,16 @@ UP013.py:11:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 13 15 | # Empty TypedDict 14 16 | MyType = TypedDict("MyType") -UP013.py:14:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:14:1 | 13 | # Empty TypedDict 14 | MyType = TypedDict("MyType") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | # Literal values | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 11 11 | MyType = TypedDict("MyType", a=int, b=str) @@ -88,14 +92,15 @@ UP013.py:14:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 16 17 | # Literal values 17 18 | MyType = TypedDict("MyType", {"a": "hello"}) -UP013.py:17:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:17:1 | 16 | # Literal values 17 | MyType = TypedDict("MyType", {"a": "hello"}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | MyType = TypedDict("MyType", a="hello") | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 14 14 | MyType = TypedDict("MyType") @@ -108,16 +113,17 @@ UP013.py:17:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 19 20 | 20 21 | # NotRequired -UP013.py:18:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:18:1 | 16 | # Literal values 17 | MyType = TypedDict("MyType", {"a": "hello"}) 18 | MyType = TypedDict("MyType", a="hello") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # NotRequired | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 15 15 | @@ -130,15 +136,16 @@ UP013.py:18:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 20 21 | # NotRequired 21 22 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) -UP013.py:21:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:21:1 | 20 | # NotRequired 21 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | # total | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 18 18 | MyType = TypedDict("MyType", a="hello") @@ -151,15 +158,16 @@ UP013.py:21:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 23 24 | # total 24 25 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) -UP013.py:24:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:24:1 | 23 | # total 24 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | # using Literal type | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 21 21 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) @@ -173,15 +181,16 @@ UP013.py:24:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 26 28 | # using Literal type 27 29 | MyType = TypedDict("MyType", {"key": Literal["value"]}) -UP013.py:27:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:27:1 | 26 | # using Literal type 27 | MyType = TypedDict("MyType", {"key": Literal["value"]}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | # using namespace TypedDict | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 24 24 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) @@ -194,15 +203,16 @@ UP013.py:27:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 29 30 | # using namespace TypedDict 30 31 | MyType = typing.TypedDict("MyType", {"key": int}) -UP013.py:30:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:30:1 | 29 | # using namespace TypedDict 30 | MyType = typing.TypedDict("MyType", {"key": int}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | 32 | # invalid identifiers (OK) | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 27 27 | MyType = TypedDict("MyType", {"key": Literal["value"]}) @@ -215,15 +225,16 @@ UP013.py:30:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 32 33 | # invalid identifiers (OK) 33 34 | MyType = TypedDict("MyType", {"in": int, "x-y": int}) -UP013.py:40:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:40:1 | 39 | # Empty dict literal 40 | MyType = TypedDict("MyType", {}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | 42 | # Empty dict call | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 37 37 | MyType = TypedDict("MyType", {"a": int, "b": str, **c}) @@ -236,15 +247,16 @@ UP013.py:40:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 42 43 | # Empty dict call 43 44 | MyType = TypedDict("MyType", dict()) -UP013.py:43:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax +UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + --> UP013.py:43:1 | 42 | # Empty dict call 43 | MyType = TypedDict("MyType", dict()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | # Unsafe fix if comments are present | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 40 40 | MyType = TypedDict("MyType", {}) @@ -257,17 +269,18 @@ UP013.py:43:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class s 45 46 | # Unsafe fix if comments are present 46 47 | X = TypedDict("X", { -UP013.py:46:1: UP013 [*] Convert `X` from `TypedDict` functional to class syntax +UP013 [*] Convert `X` from `TypedDict` functional to class syntax + --> UP013.py:46:1 | 45 | # Unsafe fix if comments are present 46 | / X = TypedDict("X", { 47 | | "some_config": int, # important 48 | | }) - | |__^ UP013 + | |__^ 49 | 50 | # Private names should not be reported (OK) | - = help: Convert `X` to class syntax +help: Convert `X` to class syntax ℹ Unsafe fix 43 43 | MyType = TypedDict("MyType", dict()) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap index 24aec45ab8..f55d203b2f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP014.py:5:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax +UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + --> UP014.py:5:1 | 4 | # with complex annotations 5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | # with namespace | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 2 2 | import typing @@ -23,15 +24,16 @@ UP014.py:5:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class s 7 9 | # with namespace 8 10 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) -UP014.py:8:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax +UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + --> UP014.py:8:1 | 7 | # with namespace 8 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | # invalid identifiers (OK) | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 5 5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) @@ -45,15 +47,16 @@ UP014.py:8:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class s 10 12 | # invalid identifiers (OK) 11 13 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])]) -UP014.py:14:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax +UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + --> UP014.py:14:1 | 13 | # no fields 14 | MyType = typing.NamedTuple("MyType") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | # empty fields | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 11 11 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])]) @@ -66,15 +69,16 @@ UP014.py:14:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class 16 17 | # empty fields 17 18 | MyType = typing.NamedTuple("MyType", []) -UP014.py:17:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax +UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + --> UP014.py:17:1 | 16 | # empty fields 17 | MyType = typing.NamedTuple("MyType", []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | # keywords | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 14 14 | MyType = typing.NamedTuple("MyType") @@ -87,15 +91,16 @@ UP014.py:17:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class 19 20 | # keywords 20 21 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) -UP014.py:20:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax +UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + --> UP014.py:20:1 | 19 | # keywords 20 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | 22 | # unfixable | - = help: Convert `MyType` to class syntax +help: Convert `MyType` to class syntax ℹ Safe fix 17 17 | MyType = typing.NamedTuple("MyType", []) @@ -109,15 +114,16 @@ UP014.py:20:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class 22 24 | # unfixable 23 25 | MyType = typing.NamedTuple("MyType", [("a", int)], [("b", str)]) -UP014.py:36:1: UP014 [*] Convert `X` from `NamedTuple` functional to class syntax +UP014 [*] Convert `X` from `NamedTuple` functional to class syntax + --> UP014.py:36:1 | 35 | # Unsafe fix if comments are present 36 | / X = NamedTuple("X", [ 37 | | ("some_config", int), # important 38 | | ]) - | |__^ UP014 + | |__^ | - = help: Convert `X` to class syntax +help: Convert `X` to class syntax ℹ Unsafe fix 33 33 | ) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap index b265b7e803..022846fbca 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP015.py:1:13: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:1:13 | 1 | open("foo", "U") - | ^^^ UP015 + | ^^^ 2 | open("foo", "Ur") 3 | open("foo", "Ub") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 1 |-open("foo", "U") @@ -17,15 +18,16 @@ UP015.py:1:13: UP015 [*] Unnecessary mode argument 3 3 | open("foo", "Ub") 4 4 | open("foo", "rUb") -UP015.py:2:13: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:2:13 | 1 | open("foo", "U") 2 | open("foo", "Ur") - | ^^^^ UP015 + | ^^^^ 3 | open("foo", "Ub") 4 | open("foo", "rUb") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 1 1 | open("foo", "U") @@ -35,16 +37,17 @@ UP015.py:2:13: UP015 [*] Unnecessary mode argument 4 4 | open("foo", "rUb") 5 5 | open("foo", "r") -UP015.py:3:13: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:3:13 | 1 | open("foo", "U") 2 | open("foo", "Ur") 3 | open("foo", "Ub") - | ^^^^ UP015 + | ^^^^ 4 | open("foo", "rUb") 5 | open("foo", "r") | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 1 1 | open("foo", "U") @@ -55,16 +58,17 @@ UP015.py:3:13: UP015 [*] Unnecessary modes, use `rb` 5 5 | open("foo", "r") 6 6 | open("foo", "rt") -UP015.py:4:13: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:4:13 | 2 | open("foo", "Ur") 3 | open("foo", "Ub") 4 | open("foo", "rUb") - | ^^^^^ UP015 + | ^^^^^ 5 | open("foo", "r") 6 | open("foo", "rt") | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 1 1 | open("foo", "U") @@ -76,16 +80,17 @@ UP015.py:4:13: UP015 [*] Unnecessary modes, use `rb` 6 6 | open("foo", "rt") 7 7 | open("f", "r", encoding="UTF-8") -UP015.py:5:13: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:5:13 | 3 | open("foo", "Ub") 4 | open("foo", "rUb") 5 | open("foo", "r") - | ^^^ UP015 + | ^^^ 6 | open("foo", "rt") 7 | open("f", "r", encoding="UTF-8") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 2 2 | open("foo", "Ur") @@ -97,16 +102,17 @@ UP015.py:5:13: UP015 [*] Unnecessary mode argument 7 7 | open("f", "r", encoding="UTF-8") 8 8 | open("f", "wt") -UP015.py:6:13: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:6:13 | 4 | open("foo", "rUb") 5 | open("foo", "r") 6 | open("foo", "rt") - | ^^^^ UP015 + | ^^^^ 7 | open("f", "r", encoding="UTF-8") 8 | open("f", "wt") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 3 3 | open("foo", "Ub") @@ -118,16 +124,17 @@ UP015.py:6:13: UP015 [*] Unnecessary mode argument 8 8 | open("f", "wt") 9 9 | open("f", "tw") -UP015.py:7:11: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:7:11 | 5 | open("foo", "r") 6 | open("foo", "rt") 7 | open("f", "r", encoding="UTF-8") - | ^^^ UP015 + | ^^^ 8 | open("f", "wt") 9 | open("f", "tw") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 4 4 | open("foo", "rUb") @@ -139,15 +146,16 @@ UP015.py:7:11: UP015 [*] Unnecessary mode argument 9 9 | open("f", "tw") 10 10 | -UP015.py:8:11: UP015 [*] Unnecessary modes, use `w` +UP015 [*] Unnecessary modes, use `w` + --> UP015.py:8:11 | 6 | open("foo", "rt") 7 | open("f", "r", encoding="UTF-8") 8 | open("f", "wt") - | ^^^^ UP015 + | ^^^^ 9 | open("f", "tw") | - = help: Replace with `w` +help: Replace with `w` ℹ Safe fix 5 5 | open("foo", "r") @@ -159,16 +167,17 @@ UP015.py:8:11: UP015 [*] Unnecessary modes, use `w` 10 10 | 11 11 | with open("foo", "U") as f: -UP015.py:9:11: UP015 [*] Unnecessary modes, use `w` +UP015 [*] Unnecessary modes, use `w` + --> UP015.py:9:11 | 7 | open("f", "r", encoding="UTF-8") 8 | open("f", "wt") 9 | open("f", "tw") - | ^^^^ UP015 + | ^^^^ 10 | 11 | with open("foo", "U") as f: | - = help: Replace with `w` +help: Replace with `w` ℹ Safe fix 6 6 | open("foo", "rt") @@ -180,16 +189,17 @@ UP015.py:9:11: UP015 [*] Unnecessary modes, use `w` 11 11 | with open("foo", "U") as f: 12 12 | pass -UP015.py:11:18: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:11:18 | 9 | open("f", "tw") 10 | 11 | with open("foo", "U") as f: - | ^^^ UP015 + | ^^^ 12 | pass 13 | with open("foo", "Ur") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 8 8 | open("f", "wt") @@ -201,16 +211,17 @@ UP015.py:11:18: UP015 [*] Unnecessary mode argument 13 13 | with open("foo", "Ur") as f: 14 14 | pass -UP015.py:13:18: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:13:18 | 11 | with open("foo", "U") as f: 12 | pass 13 | with open("foo", "Ur") as f: - | ^^^^ UP015 + | ^^^^ 14 | pass 15 | with open("foo", "Ub") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 10 10 | @@ -222,16 +233,17 @@ UP015.py:13:18: UP015 [*] Unnecessary mode argument 15 15 | with open("foo", "Ub") as f: 16 16 | pass -UP015.py:15:18: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:15:18 | 13 | with open("foo", "Ur") as f: 14 | pass 15 | with open("foo", "Ub") as f: - | ^^^^ UP015 + | ^^^^ 16 | pass 17 | with open("foo", "rUb") as f: | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 12 12 | pass @@ -243,16 +255,17 @@ UP015.py:15:18: UP015 [*] Unnecessary modes, use `rb` 17 17 | with open("foo", "rUb") as f: 18 18 | pass -UP015.py:17:18: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:17:18 | 15 | with open("foo", "Ub") as f: 16 | pass 17 | with open("foo", "rUb") as f: - | ^^^^^ UP015 + | ^^^^^ 18 | pass 19 | with open("foo", "r") as f: | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 14 14 | pass @@ -264,16 +277,17 @@ UP015.py:17:18: UP015 [*] Unnecessary modes, use `rb` 19 19 | with open("foo", "r") as f: 20 20 | pass -UP015.py:19:18: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:19:18 | 17 | with open("foo", "rUb") as f: 18 | pass 19 | with open("foo", "r") as f: - | ^^^ UP015 + | ^^^ 20 | pass 21 | with open("foo", "rt") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 16 16 | pass @@ -285,16 +299,17 @@ UP015.py:19:18: UP015 [*] Unnecessary mode argument 21 21 | with open("foo", "rt") as f: 22 22 | pass -UP015.py:21:18: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:21:18 | 19 | with open("foo", "r") as f: 20 | pass 21 | with open("foo", "rt") as f: - | ^^^^ UP015 + | ^^^^ 22 | pass 23 | with open("foo", "r", encoding="UTF-8") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 18 18 | pass @@ -306,16 +321,17 @@ UP015.py:21:18: UP015 [*] Unnecessary mode argument 23 23 | with open("foo", "r", encoding="UTF-8") as f: 24 24 | pass -UP015.py:23:18: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:23:18 | 21 | with open("foo", "rt") as f: 22 | pass 23 | with open("foo", "r", encoding="UTF-8") as f: - | ^^^ UP015 + | ^^^ 24 | pass 25 | with open("foo", "wt") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 20 20 | pass @@ -327,15 +343,16 @@ UP015.py:23:18: UP015 [*] Unnecessary mode argument 25 25 | with open("foo", "wt") as f: 26 26 | pass -UP015.py:25:18: UP015 [*] Unnecessary modes, use `w` +UP015 [*] Unnecessary modes, use `w` + --> UP015.py:25:18 | 23 | with open("foo", "r", encoding="UTF-8") as f: 24 | pass 25 | with open("foo", "wt") as f: - | ^^^^ UP015 + | ^^^^ 26 | pass | - = help: Replace with `w` +help: Replace with `w` ℹ Safe fix 22 22 | pass @@ -347,15 +364,16 @@ UP015.py:25:18: UP015 [*] Unnecessary modes, use `w` 27 27 | 28 28 | open(f("a", "b", "c"), "U") -UP015.py:28:24: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:28:24 | 26 | pass 27 | 28 | open(f("a", "b", "c"), "U") - | ^^^ UP015 + | ^^^ 29 | open(f("a", "b", "c"), "Ub") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 25 25 | with open("foo", "wt") as f: @@ -367,15 +385,16 @@ UP015.py:28:24: UP015 [*] Unnecessary mode argument 30 30 | 31 31 | with open(f("a", "b", "c"), "U") as f: -UP015.py:29:24: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:29:24 | 28 | open(f("a", "b", "c"), "U") 29 | open(f("a", "b", "c"), "Ub") - | ^^^^ UP015 + | ^^^^ 30 | 31 | with open(f("a", "b", "c"), "U") as f: | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 26 26 | pass @@ -387,16 +406,17 @@ UP015.py:29:24: UP015 [*] Unnecessary modes, use `rb` 31 31 | with open(f("a", "b", "c"), "U") as f: 32 32 | pass -UP015.py:31:29: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:31:29 | 29 | open(f("a", "b", "c"), "Ub") 30 | 31 | with open(f("a", "b", "c"), "U") as f: - | ^^^ UP015 + | ^^^ 32 | pass 33 | with open(f("a", "b", "c"), "Ub") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 28 28 | open(f("a", "b", "c"), "U") @@ -408,15 +428,16 @@ UP015.py:31:29: UP015 [*] Unnecessary mode argument 33 33 | with open(f("a", "b", "c"), "Ub") as f: 34 34 | pass -UP015.py:33:29: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:33:29 | 31 | with open(f("a", "b", "c"), "U") as f: 32 | pass 33 | with open(f("a", "b", "c"), "Ub") as f: - | ^^^^ UP015 + | ^^^^ 34 | pass | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 30 30 | @@ -428,16 +449,17 @@ UP015.py:33:29: UP015 [*] Unnecessary modes, use `rb` 35 35 | 36 36 | with open("foo", "U") as fa, open("bar", "U") as fb: -UP015.py:36:18: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:36:18 | 34 | pass 35 | 36 | with open("foo", "U") as fa, open("bar", "U") as fb: - | ^^^ UP015 + | ^^^ 37 | pass 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 33 33 | with open(f("a", "b", "c"), "Ub") as f: @@ -449,16 +471,17 @@ UP015.py:36:18: UP015 [*] Unnecessary mode argument 38 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: 39 39 | pass -UP015.py:36:42: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:36:42 | 34 | pass 35 | 36 | with open("foo", "U") as fa, open("bar", "U") as fb: - | ^^^ UP015 + | ^^^ 37 | pass 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 33 33 | with open(f("a", "b", "c"), "Ub") as f: @@ -470,15 +493,16 @@ UP015.py:36:42: UP015 [*] Unnecessary mode argument 38 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: 39 39 | pass -UP015.py:38:18: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:38:18 | 36 | with open("foo", "U") as fa, open("bar", "U") as fb: 37 | pass 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: - | ^^^^ UP015 + | ^^^^ 39 | pass | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 35 35 | @@ -490,15 +514,16 @@ UP015.py:38:18: UP015 [*] Unnecessary modes, use `rb` 40 40 | 41 41 | open("foo", mode="U") -UP015.py:38:43: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:38:43 | 36 | with open("foo", "U") as fa, open("bar", "U") as fb: 37 | pass 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: - | ^^^^ UP015 + | ^^^^ 39 | pass | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 35 35 | @@ -510,16 +535,17 @@ UP015.py:38:43: UP015 [*] Unnecessary modes, use `rb` 40 40 | 41 41 | open("foo", mode="U") -UP015.py:41:18: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:41:18 | 39 | pass 40 | 41 | open("foo", mode="U") - | ^^^ UP015 + | ^^^ 42 | open(name="foo", mode="U") 43 | open(mode="U", name="foo") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 38 38 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: @@ -531,14 +557,15 @@ UP015.py:41:18: UP015 [*] Unnecessary mode argument 43 43 | open(mode="U", name="foo") 44 44 | -UP015.py:42:23: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:42:23 | 41 | open("foo", mode="U") 42 | open(name="foo", mode="U") - | ^^^ UP015 + | ^^^ 43 | open(mode="U", name="foo") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 39 39 | pass @@ -550,16 +577,17 @@ UP015.py:42:23: UP015 [*] Unnecessary mode argument 44 44 | 45 45 | with open("foo", mode="U") as f: -UP015.py:43:11: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:43:11 | 41 | open("foo", mode="U") 42 | open(name="foo", mode="U") 43 | open(mode="U", name="foo") - | ^^^ UP015 + | ^^^ 44 | 45 | with open("foo", mode="U") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 40 40 | @@ -571,16 +599,17 @@ UP015.py:43:11: UP015 [*] Unnecessary mode argument 45 45 | with open("foo", mode="U") as f: 46 46 | pass -UP015.py:45:23: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:45:23 | 43 | open(mode="U", name="foo") 44 | 45 | with open("foo", mode="U") as f: - | ^^^ UP015 + | ^^^ 46 | pass 47 | with open(name="foo", mode="U") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 42 42 | open(name="foo", mode="U") @@ -592,16 +621,17 @@ UP015.py:45:23: UP015 [*] Unnecessary mode argument 47 47 | with open(name="foo", mode="U") as f: 48 48 | pass -UP015.py:47:28: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:47:28 | 45 | with open("foo", mode="U") as f: 46 | pass 47 | with open(name="foo", mode="U") as f: - | ^^^ UP015 + | ^^^ 48 | pass 49 | with open(mode="U", name="foo") as f: | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 44 44 | @@ -613,15 +643,16 @@ UP015.py:47:28: UP015 [*] Unnecessary mode argument 49 49 | with open(mode="U", name="foo") as f: 50 50 | pass -UP015.py:49:16: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:49:16 | 47 | with open(name="foo", mode="U") as f: 48 | pass 49 | with open(mode="U", name="foo") as f: - | ^^^ UP015 + | ^^^ 50 | pass | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 46 46 | pass @@ -633,16 +664,17 @@ UP015.py:49:16: UP015 [*] Unnecessary mode argument 51 51 | 52 52 | open("foo", mode="Ub") -UP015.py:52:18: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:52:18 | 50 | pass 51 | 52 | open("foo", mode="Ub") - | ^^^^ UP015 + | ^^^^ 53 | open(name="foo", mode="Ub") 54 | open(mode="Ub", name="foo") | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 49 49 | with open(mode="U", name="foo") as f: @@ -654,14 +686,15 @@ UP015.py:52:18: UP015 [*] Unnecessary modes, use `rb` 54 54 | open(mode="Ub", name="foo") 55 55 | -UP015.py:53:23: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:53:23 | 52 | open("foo", mode="Ub") 53 | open(name="foo", mode="Ub") - | ^^^^ UP015 + | ^^^^ 54 | open(mode="Ub", name="foo") | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 50 50 | pass @@ -673,16 +706,17 @@ UP015.py:53:23: UP015 [*] Unnecessary modes, use `rb` 55 55 | 56 56 | with open("foo", mode="Ub") as f: -UP015.py:54:11: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:54:11 | 52 | open("foo", mode="Ub") 53 | open(name="foo", mode="Ub") 54 | open(mode="Ub", name="foo") - | ^^^^ UP015 + | ^^^^ 55 | 56 | with open("foo", mode="Ub") as f: | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 51 51 | @@ -694,16 +728,17 @@ UP015.py:54:11: UP015 [*] Unnecessary modes, use `rb` 56 56 | with open("foo", mode="Ub") as f: 57 57 | pass -UP015.py:56:23: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:56:23 | 54 | open(mode="Ub", name="foo") 55 | 56 | with open("foo", mode="Ub") as f: - | ^^^^ UP015 + | ^^^^ 57 | pass 58 | with open(name="foo", mode="Ub") as f: | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 53 53 | open(name="foo", mode="Ub") @@ -715,16 +750,17 @@ UP015.py:56:23: UP015 [*] Unnecessary modes, use `rb` 58 58 | with open(name="foo", mode="Ub") as f: 59 59 | pass -UP015.py:58:28: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:58:28 | 56 | with open("foo", mode="Ub") as f: 57 | pass 58 | with open(name="foo", mode="Ub") as f: - | ^^^^ UP015 + | ^^^^ 59 | pass 60 | with open(mode="Ub", name="foo") as f: | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 55 55 | @@ -736,15 +772,16 @@ UP015.py:58:28: UP015 [*] Unnecessary modes, use `rb` 60 60 | with open(mode="Ub", name="foo") as f: 61 61 | pass -UP015.py:60:16: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:60:16 | 58 | with open(name="foo", mode="Ub") as f: 59 | pass 60 | with open(mode="Ub", name="foo") as f: - | ^^^^ UP015 + | ^^^^ 61 | pass | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 57 57 | pass @@ -756,16 +793,17 @@ UP015.py:60:16: UP015 [*] Unnecessary modes, use `rb` 62 62 | 63 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -UP015.py:63:23: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:63:23 | 61 | pass 62 | 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^ UP015 + | ^^^ 64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 60 60 | with open(mode="Ub", name="foo") as f: @@ -777,15 +815,16 @@ UP015.py:63:23: UP015 [*] Unnecessary mode argument 65 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) 66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -UP015.py:64:106: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:64:106 | 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') - | ^^^ UP015 + | ^^^ 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 61 61 | pass @@ -797,15 +836,16 @@ UP015.py:64:106: UP015 [*] Unnecessary mode argument 66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 67 67 | -UP015.py:65:65: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:65:65 | 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) - | ^^^ UP015 + | ^^^ 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 62 62 | @@ -817,16 +857,17 @@ UP015.py:65:65: UP015 [*] Unnecessary mode argument 67 67 | 68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -UP015.py:66:11: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:66:11 | 64 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^ UP015 + | ^^^ 67 | 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 63 63 | open(file="foo", mode='U', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) @@ -838,16 +879,17 @@ UP015.py:66:11: UP015 [*] Unnecessary mode argument 68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 69 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') -UP015.py:68:23: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:68:23 | 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 67 | 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^^ UP015 + | ^^^^ 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 65 65 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) @@ -859,15 +901,16 @@ UP015.py:68:23: UP015 [*] Unnecessary modes, use `rb` 70 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) 71 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -UP015.py:69:106: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:69:106 | 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') - | ^^^^ UP015 + | ^^^^ 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 66 66 | open(mode='U', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) @@ -879,15 +922,16 @@ UP015.py:69:106: UP015 [*] Unnecessary modes, use `rb` 71 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 72 72 | -UP015.py:70:65: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:70:65 | 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) - | ^^^^ UP015 + | ^^^^ 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 67 67 | @@ -899,16 +943,17 @@ UP015.py:70:65: UP015 [*] Unnecessary modes, use `rb` 72 72 | 73 73 | import aiofiles -UP015.py:71:11: UP015 [*] Unnecessary modes, use `rb` +UP015 [*] Unnecessary modes, use `rb` + --> UP015.py:71:11 | 69 | open(file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') 70 | open(file="foo", buffering=-1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) 71 | open(mode='Ub', file="foo", buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^^ UP015 + | ^^^^ 72 | 73 | import aiofiles | - = help: Replace with `rb` +help: Replace with `rb` ℹ Safe fix 68 68 | open(file="foo", mode='Ub', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) @@ -920,16 +965,17 @@ UP015.py:71:11: UP015 [*] Unnecessary modes, use `rb` 73 73 | import aiofiles 74 74 | -UP015.py:75:22: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:75:22 | 73 | import aiofiles 74 | 75 | aiofiles.open("foo", "U") - | ^^^ UP015 + | ^^^ 76 | aiofiles.open("foo", "r") 77 | aiofiles.open("foo", mode="r") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 72 72 | @@ -941,14 +987,15 @@ UP015.py:75:22: UP015 [*] Unnecessary mode argument 77 77 | aiofiles.open("foo", mode="r") 78 78 | -UP015.py:76:22: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:76:22 | 75 | aiofiles.open("foo", "U") 76 | aiofiles.open("foo", "r") - | ^^^ UP015 + | ^^^ 77 | aiofiles.open("foo", mode="r") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 73 73 | import aiofiles @@ -960,16 +1007,17 @@ UP015.py:76:22: UP015 [*] Unnecessary mode argument 78 78 | 79 79 | open("foo", "r+") -UP015.py:77:27: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015.py:77:27 | 75 | aiofiles.open("foo", "U") 76 | aiofiles.open("foo", "r") 77 | aiofiles.open("foo", mode="r") - | ^^^ UP015 + | ^^^ 78 | 79 | open("foo", "r+") | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 74 74 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015_1.py.snap index a3f9d68f6c..27b02bad15 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015_1.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP015_1.py:3:17: UP015 [*] Unnecessary mode argument +UP015 [*] Unnecessary mode argument + --> UP015_1.py:3:17 | 1 | # Not a valid type annotation but this test shouldn't result in a panic. 2 | # Refer: https://github.com/astral-sh/ruff/issues/11736 3 | x: 'open("foo", "r")' - | ^^^ UP015 + | ^^^ | - = help: Remove mode argument +help: Remove mode argument ℹ Safe fix 1 1 | # Not a valid type annotation but this test shouldn't result in a panic. diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap index 0f6820140c..e30ca3fdbf 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP018.py:37:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) +UP018 [*] Unnecessary `str` call (rewrite as a literal) + --> UP018.py:37:1 | 36 | # These become literals 37 | str() - | ^^^^^ UP018 + | ^^^^^ 38 | str("foo") 39 | str(""" | - = help: Replace with string literal +help: Replace with string literal ℹ Safe fix 34 34 | int().denominator @@ -21,16 +22,17 @@ UP018.py:37:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) 39 39 | str(""" 40 40 | foo""") -UP018.py:38:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) +UP018 [*] Unnecessary `str` call (rewrite as a literal) + --> UP018.py:38:1 | 36 | # These become literals 37 | str() 38 | str("foo") - | ^^^^^^^^^^ UP018 + | ^^^^^^^^^^ 39 | str(""" 40 | foo""") | - = help: Replace with string literal +help: Replace with string literal ℹ Safe fix 35 35 | @@ -42,17 +44,18 @@ UP018.py:38:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) 40 40 | foo""") 41 41 | bytes() -UP018.py:39:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) +UP018 [*] Unnecessary `str` call (rewrite as a literal) + --> UP018.py:39:1 | 37 | str() 38 | str("foo") 39 | / str(""" 40 | | foo""") - | |_______^ UP018 + | |_______^ 41 | bytes() 42 | bytes(b"foo") | - = help: Replace with string literal +help: Replace with string literal ℹ Safe fix 36 36 | # These become literals @@ -66,16 +69,17 @@ UP018.py:39:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) 42 42 | bytes(b"foo") 43 43 | bytes(b""" -UP018.py:41:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) +UP018 [*] Unnecessary `bytes` call (rewrite as a literal) + --> UP018.py:41:1 | 39 | str(""" 40 | foo""") 41 | bytes() - | ^^^^^^^ UP018 + | ^^^^^^^ 42 | bytes(b"foo") 43 | bytes(b""" | - = help: Replace with bytes literal +help: Replace with bytes literal ℹ Safe fix 38 38 | str("foo") @@ -87,16 +91,17 @@ UP018.py:41:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) 43 43 | bytes(b""" 44 44 | foo""") -UP018.py:42:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) +UP018 [*] Unnecessary `bytes` call (rewrite as a literal) + --> UP018.py:42:1 | 40 | foo""") 41 | bytes() 42 | bytes(b"foo") - | ^^^^^^^^^^^^^ UP018 + | ^^^^^^^^^^^^^ 43 | bytes(b""" 44 | foo""") | - = help: Replace with bytes literal +help: Replace with bytes literal ℹ Safe fix 39 39 | str(""" @@ -108,17 +113,18 @@ UP018.py:42:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) 44 44 | foo""") 45 45 | f"{str()}" -UP018.py:43:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) +UP018 [*] Unnecessary `bytes` call (rewrite as a literal) + --> UP018.py:43:1 | 41 | bytes() 42 | bytes(b"foo") 43 | / bytes(b""" 44 | | foo""") - | |_______^ UP018 + | |_______^ 45 | f"{str()}" 46 | int() | - = help: Replace with bytes literal +help: Replace with bytes literal ℹ Safe fix 40 40 | foo""") @@ -132,16 +138,17 @@ UP018.py:43:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) 46 46 | int() 47 47 | int(1) -UP018.py:45:4: UP018 [*] Unnecessary `str` call (rewrite as a literal) +UP018 [*] Unnecessary `str` call (rewrite as a literal) + --> UP018.py:45:4 | 43 | bytes(b""" 44 | foo""") 45 | f"{str()}" - | ^^^^^ UP018 + | ^^^^^ 46 | int() 47 | int(1) | - = help: Replace with string literal +help: Replace with string literal ℹ Safe fix 42 42 | bytes(b"foo") @@ -153,16 +160,17 @@ UP018.py:45:4: UP018 [*] Unnecessary `str` call (rewrite as a literal) 47 47 | int(1) 48 48 | float() -UP018.py:46:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:46:1 | 44 | foo""") 45 | f"{str()}" 46 | int() - | ^^^^^ UP018 + | ^^^^^ 47 | int(1) 48 | float() | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 43 43 | bytes(b""" @@ -174,16 +182,17 @@ UP018.py:46:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 48 48 | float() 49 49 | float(1.0) -UP018.py:47:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:47:1 | 45 | f"{str()}" 46 | int() 47 | int(1) - | ^^^^^^ UP018 + | ^^^^^^ 48 | float() 49 | float(1.0) | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 44 44 | foo""") @@ -195,16 +204,17 @@ UP018.py:47:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 49 49 | float(1.0) 50 50 | bool() -UP018.py:48:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) +UP018 [*] Unnecessary `float` call (rewrite as a literal) + --> UP018.py:48:1 | 46 | int() 47 | int(1) 48 | float() - | ^^^^^^^ UP018 + | ^^^^^^^ 49 | float(1.0) 50 | bool() | - = help: Replace with float literal +help: Replace with float literal ℹ Safe fix 45 45 | f"{str()}" @@ -216,16 +226,17 @@ UP018.py:48:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) 50 50 | bool() 51 51 | bool(True) -UP018.py:49:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) +UP018 [*] Unnecessary `float` call (rewrite as a literal) + --> UP018.py:49:1 | 47 | int(1) 48 | float() 49 | float(1.0) - | ^^^^^^^^^^ UP018 + | ^^^^^^^^^^ 50 | bool() 51 | bool(True) | - = help: Replace with float literal +help: Replace with float literal ℹ Safe fix 46 46 | int() @@ -237,16 +248,17 @@ UP018.py:49:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) 51 51 | bool(True) 52 52 | bool(False) -UP018.py:50:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) +UP018 [*] Unnecessary `bool` call (rewrite as a literal) + --> UP018.py:50:1 | 48 | float() 49 | float(1.0) 50 | bool() - | ^^^^^^ UP018 + | ^^^^^^ 51 | bool(True) 52 | bool(False) | - = help: Replace with boolean literal +help: Replace with boolean literal ℹ Safe fix 47 47 | int(1) @@ -258,15 +270,16 @@ UP018.py:50:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) 52 52 | bool(False) 53 53 | -UP018.py:51:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) +UP018 [*] Unnecessary `bool` call (rewrite as a literal) + --> UP018.py:51:1 | 49 | float(1.0) 50 | bool() 51 | bool(True) - | ^^^^^^^^^^ UP018 + | ^^^^^^^^^^ 52 | bool(False) | - = help: Replace with boolean literal +help: Replace with boolean literal ℹ Safe fix 48 48 | float() @@ -278,16 +291,17 @@ UP018.py:51:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) 53 53 | 54 54 | # These become a literal but retain parentheses -UP018.py:52:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) +UP018 [*] Unnecessary `bool` call (rewrite as a literal) + --> UP018.py:52:1 | 50 | bool() 51 | bool(True) 52 | bool(False) - | ^^^^^^^^^^^ UP018 + | ^^^^^^^^^^^ 53 | 54 | # These become a literal but retain parentheses | - = help: Replace with boolean literal +help: Replace with boolean literal ℹ Safe fix 49 49 | float(1.0) @@ -299,15 +313,16 @@ UP018.py:52:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) 54 54 | # These become a literal but retain parentheses 55 55 | int(1).denominator -UP018.py:55:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:55:1 | 54 | # These become a literal but retain parentheses 55 | int(1).denominator - | ^^^^^^ UP018 + | ^^^^^^ 56 | 57 | # These too are literals in spirit | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 52 52 | bool(False) @@ -319,15 +334,16 @@ UP018.py:55:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 57 57 | # These too are literals in spirit 58 58 | int(+1) -UP018.py:58:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:58:1 | 57 | # These too are literals in spirit 58 | int(+1) - | ^^^^^^^ UP018 + | ^^^^^^^ 59 | int(-1) 60 | float(+1.0) | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 55 55 | int(1).denominator @@ -339,16 +355,17 @@ UP018.py:58:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 60 60 | float(+1.0) 61 61 | float(-1.0) -UP018.py:59:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:59:1 | 57 | # These too are literals in spirit 58 | int(+1) 59 | int(-1) - | ^^^^^^^ UP018 + | ^^^^^^^ 60 | float(+1.0) 61 | float(-1.0) | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 56 56 | @@ -360,15 +377,16 @@ UP018.py:59:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 61 61 | float(-1.0) 62 62 | -UP018.py:60:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) +UP018 [*] Unnecessary `float` call (rewrite as a literal) + --> UP018.py:60:1 | 58 | int(+1) 59 | int(-1) 60 | float(+1.0) - | ^^^^^^^^^^^ UP018 + | ^^^^^^^^^^^ 61 | float(-1.0) | - = help: Replace with float literal +help: Replace with float literal ℹ Safe fix 57 57 | # These too are literals in spirit @@ -380,14 +398,15 @@ UP018.py:60:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) 62 62 | 63 63 | -UP018.py:61:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) +UP018 [*] Unnecessary `float` call (rewrite as a literal) + --> UP018.py:61:1 | 59 | int(-1) 60 | float(+1.0) 61 | float(-1.0) - | ^^^^^^^^^^^ UP018 + | ^^^^^^^^^^^ | - = help: Replace with float literal +help: Replace with float literal ℹ Safe fix 58 58 | int(+1) @@ -399,14 +418,15 @@ UP018.py:61:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) 63 63 | 64 64 | # https://github.com/astral-sh/ruff/issues/15859 -UP018.py:65:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:65:1 | 64 | # https://github.com/astral-sh/ruff/issues/15859 65 | int(-1) ** 0 # (-1) ** 0 - | ^^^^^^^ UP018 + | ^^^^^^^ 66 | 2 ** int(-1) # 2 ** -1 | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 62 62 | @@ -418,16 +438,17 @@ UP018.py:65:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 67 67 | 68 68 | int(-1)[0] # (-1)[0] -UP018.py:66:6: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:66:6 | 64 | # https://github.com/astral-sh/ruff/issues/15859 65 | int(-1) ** 0 # (-1) ** 0 66 | 2 ** int(-1) # 2 ** -1 - | ^^^^^^^ UP018 + | ^^^^^^^ 67 | 68 | int(-1)[0] # (-1)[0] | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 63 63 | @@ -439,15 +460,16 @@ UP018.py:66:6: UP018 [*] Unnecessary `int` call (rewrite as a literal) 68 68 | int(-1)[0] # (-1)[0] 69 69 | 2[int(-1)] # 2[-1] -UP018.py:68:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:68:1 | 66 | 2 ** int(-1) # 2 ** -1 67 | 68 | int(-1)[0] # (-1)[0] - | ^^^^^^^ UP018 + | ^^^^^^^ 69 | 2[int(-1)] # 2[-1] | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 65 65 | int(-1) ** 0 # (-1) ** 0 @@ -459,15 +481,16 @@ UP018.py:68:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 70 70 | 71 71 | int(-1)(0) # (-1)(0) -UP018.py:69:3: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:69:3 | 68 | int(-1)[0] # (-1)[0] 69 | 2[int(-1)] # 2[-1] - | ^^^^^^^ UP018 + | ^^^^^^^ 70 | 71 | int(-1)(0) # (-1)(0) | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 66 66 | 2 ** int(-1) # 2 ** -1 @@ -479,15 +502,16 @@ UP018.py:69:3: UP018 [*] Unnecessary `int` call (rewrite as a literal) 71 71 | int(-1)(0) # (-1)(0) 72 72 | 2(int(-1)) # 2(-1) -UP018.py:71:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:71:1 | 69 | 2[int(-1)] # 2[-1] 70 | 71 | int(-1)(0) # (-1)(0) - | ^^^^^^^ UP018 + | ^^^^^^^ 72 | 2(int(-1)) # 2(-1) | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 68 68 | int(-1)[0] # (-1)[0] @@ -499,15 +523,16 @@ UP018.py:71:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 73 73 | 74 74 | float(-1.0).foo # (-1.0).foo -UP018.py:72:3: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:72:3 | 71 | int(-1)(0) # (-1)(0) 72 | 2(int(-1)) # 2(-1) - | ^^^^^^^ UP018 + | ^^^^^^^ 73 | 74 | float(-1.0).foo # (-1.0).foo | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 69 69 | 2[int(-1)] # 2[-1] @@ -519,16 +544,17 @@ UP018.py:72:3: UP018 [*] Unnecessary `int` call (rewrite as a literal) 74 74 | float(-1.0).foo # (-1.0).foo 75 75 | -UP018.py:74:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) +UP018 [*] Unnecessary `float` call (rewrite as a literal) + --> UP018.py:74:1 | 72 | 2(int(-1)) # 2(-1) 73 | 74 | float(-1.0).foo # (-1.0).foo - | ^^^^^^^^^^^ UP018 + | ^^^^^^^^^^^ 75 | 76 | await int(-1) # await (-1) | - = help: Replace with float literal +help: Replace with float literal ℹ Safe fix 71 71 | int(-1)(0) # (-1)(0) @@ -540,14 +566,15 @@ UP018.py:74:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) 76 76 | await int(-1) # await (-1) 77 77 | -UP018.py:76:7: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:76:7 | 74 | float(-1.0).foo # (-1.0).foo 75 | 76 | await int(-1) # await (-1) - | ^^^^^^^ UP018 + | ^^^^^^^ | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 73 73 | @@ -559,13 +586,14 @@ UP018.py:76:7: UP018 [*] Unnecessary `int` call (rewrite as a literal) 78 78 | 79 79 | int(+1) ** 0 -UP018.py:79:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:79:1 | 79 | int(+1) ** 0 - | ^^^^^^^ UP018 + | ^^^^^^^ 80 | float(+1.0)() | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 76 76 | await int(-1) # await (-1) @@ -577,13 +605,14 @@ UP018.py:79:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 81 81 | 82 82 | -UP018.py:80:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) +UP018 [*] Unnecessary `float` call (rewrite as a literal) + --> UP018.py:80:1 | 79 | int(+1) ** 0 80 | float(+1.0)() - | ^^^^^^^^^^^ UP018 + | ^^^^^^^^^^^ | - = help: Replace with float literal +help: Replace with float literal ℹ Safe fix 77 77 | @@ -595,17 +624,18 @@ UP018.py:80:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) 82 82 | 83 83 | str( -UP018.py:83:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) +UP018 [*] Unnecessary `str` call (rewrite as a literal) + --> UP018.py:83:1 | 83 | / str( 84 | | '''Lorem 85 | | ipsum''' # Comment 86 | | ).foo - | |_^ UP018 + | |_^ 87 | 88 | # https://github.com/astral-sh/ruff/issues/17606 | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 80 80 | float(+1.0)() @@ -621,15 +651,16 @@ UP018.py:83:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) 88 86 | # https://github.com/astral-sh/ruff/issues/17606 89 87 | bool(True)and None -UP018.py:89:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) +UP018 [*] Unnecessary `bool` call (rewrite as a literal) + --> UP018.py:89:1 | 88 | # https://github.com/astral-sh/ruff/issues/17606 89 | bool(True)and None - | ^^^^^^^^^^ UP018 + | ^^^^^^^^^^ 90 | int(1)and None 91 | float(1.)and None | - = help: Replace with boolean literal +help: Replace with boolean literal ℹ Safe fix 86 86 | ).foo @@ -641,16 +672,17 @@ UP018.py:89:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) 91 91 | float(1.)and None 92 92 | bool(True)and() -UP018.py:90:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018.py:90:1 | 88 | # https://github.com/astral-sh/ruff/issues/17606 89 | bool(True)and None 90 | int(1)and None - | ^^^^^^ UP018 + | ^^^^^^ 91 | float(1.)and None 92 | bool(True)and() | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 87 87 | @@ -662,15 +694,16 @@ UP018.py:90:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 92 92 | bool(True)and() 93 93 | -UP018.py:91:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) +UP018 [*] Unnecessary `float` call (rewrite as a literal) + --> UP018.py:91:1 | 89 | bool(True)and None 90 | int(1)and None 91 | float(1.)and None - | ^^^^^^^^^ UP018 + | ^^^^^^^^^ 92 | bool(True)and() | - = help: Replace with float literal +help: Replace with float literal ℹ Safe fix 88 88 | # https://github.com/astral-sh/ruff/issues/17606 @@ -682,14 +715,15 @@ UP018.py:91:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) 93 93 | 94 94 | -UP018.py:92:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) +UP018 [*] Unnecessary `bool` call (rewrite as a literal) + --> UP018.py:92:1 | 90 | int(1)and None 91 | float(1.)and None 92 | bool(True)and() - | ^^^^^^^^^^ UP018 + | ^^^^^^^^^^ | - = help: Replace with boolean literal +help: Replace with boolean literal ℹ Safe fix 89 89 | bool(True)and None diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018_CR.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018_CR.py.snap index 6dae74bfe5..b5e11a0c87 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018_CR.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018_CR.py.snap @@ -1,22 +1,31 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP018_CR.py:2:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018_CR.py:2:1 | -1 | # Keep parenthesis around preserved CR int(- 1) int(+ 1) - | ^^^^^^^^^^^ UP018 +1 | # Keep parenthesis around preserved CR +2 | / int(- +3 | | 1) + | |______^ +4 | int(+ +5 | 1) | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 1 1 | # Keep parenthesis around preserved CR 2 |-int(- 2 |+(- 3 3 | 1) 4 4 | int(+ 5 5 | 1) -UP018_CR.py:4:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018_CR.py:4:1 | -2 | int(- 1) int(+ 1) - | ^^^^^^^^^^^ UP018 +2 | int(- +3 | 1) +4 | / int(+ +5 | | 1) + | |______^ | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 1 1 | # Keep parenthesis around preserved CR 2 2 | int(- 3 3 | 1) 4 |-int(+ 4 |+(+ 5 5 | 1) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018_LF.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018_LF.py.snap index d3a530d273..243b5efaa7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018_LF.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018_LF.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP018_LF.py:3:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018_LF.py:3:1 | 1 | # Keep parentheses around preserved \n 2 | 3 | / int(- 4 | | 1) - | |______^ UP018 + | |______^ 5 | 6 | int(+ | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 1 1 | # Keep parentheses around preserved \n @@ -22,15 +23,16 @@ UP018_LF.py:3:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) 5 5 | 6 6 | int(+ -UP018_LF.py:6:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) +UP018 [*] Unnecessary `int` call (rewrite as a literal) + --> UP018_LF.py:6:1 | 4 | 1) 5 | 6 | / int(+ 7 | | 1) - | |______^ UP018 + | |______^ | - = help: Replace with integer literal +help: Replace with integer literal ℹ Safe fix 3 3 | int(- diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap index 7d61f428e1..39152672a8 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP019.py:7:22: UP019 [*] `typing.Text` is deprecated, use `str` +UP019 [*] `typing.Text` is deprecated, use `str` + --> UP019.py:7:22 | 7 | def print_word(word: Text) -> None: - | ^^^^ UP019 + | ^^^^ 8 | print(word) | - = help: Replace with `str` +help: Replace with `str` ℹ Safe fix 4 4 | from typing import Text as Goodbye @@ -20,13 +20,14 @@ UP019.py:7:22: UP019 [*] `typing.Text` is deprecated, use `str` 9 9 | 10 10 | -UP019.py:11:29: UP019 [*] `typing.Text` is deprecated, use `str` +UP019 [*] `typing.Text` is deprecated, use `str` + --> UP019.py:11:29 | 11 | def print_second_word(word: typing.Text) -> None: - | ^^^^^^^^^^^ UP019 + | ^^^^^^^^^^^ 12 | print(word) | - = help: Replace with `str` +help: Replace with `str` ℹ Safe fix 8 8 | print(word) @@ -38,13 +39,14 @@ UP019.py:11:29: UP019 [*] `typing.Text` is deprecated, use `str` 13 13 | 14 14 | -UP019.py:15:28: UP019 [*] `typing.Text` is deprecated, use `str` +UP019 [*] `typing.Text` is deprecated, use `str` + --> UP019.py:15:28 | 15 | def print_third_word(word: Hello.Text) -> None: - | ^^^^^^^^^^ UP019 + | ^^^^^^^^^^ 16 | print(word) | - = help: Replace with `str` +help: Replace with `str` ℹ Safe fix 12 12 | print(word) @@ -56,13 +58,14 @@ UP019.py:15:28: UP019 [*] `typing.Text` is deprecated, use `str` 17 17 | 18 18 | -UP019.py:19:29: UP019 [*] `typing.Text` is deprecated, use `str` +UP019 [*] `typing.Text` is deprecated, use `str` + --> UP019.py:19:29 | 19 | def print_fourth_word(word: Goodbye) -> None: - | ^^^^^^^ UP019 + | ^^^^^^^ 20 | print(word) | - = help: Replace with `str` +help: Replace with `str` ℹ Safe fix 16 16 | print(word) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap index 314d5aa499..6fe9612829 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP020.py:3:6: UP020 [*] Use builtin `open` +UP020 [*] Use builtin `open` + --> UP020.py:3:6 | 1 | import io 2 | 3 | with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP020 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | print(f.read()) | - = help: Replace with builtin `open` +help: Replace with builtin `open` ℹ Safe fix 1 1 | import io @@ -20,15 +21,16 @@ UP020.py:3:6: UP020 [*] Use builtin `open` 5 5 | 6 6 | from io import open -UP020.py:8:6: UP020 [*] Use builtin `open` +UP020 [*] Use builtin `open` + --> UP020.py:8:6 | 6 | from io import open 7 | 8 | with open("f.txt") as f: - | ^^^^^^^^^^^^^ UP020 + | ^^^^^^^^^^^^^ 9 | print(f.read()) | - = help: Replace with builtin `open` +help: Replace with builtin `open` ℹ Safe fix 4 4 | print(f.read()) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap index 9d7e2095ad..967b409372 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP021.py:5:25: UP021 [*] `universal_newlines` is deprecated, use `text` +UP021 [*] `universal_newlines` is deprecated, use `text` + --> UP021.py:5:25 | 4 | # Errors 5 | subprocess.run(["foo"], universal_newlines=True, check=True) - | ^^^^^^^^^^^^^^^^^^ UP021 + | ^^^^^^^^^^^^^^^^^^ 6 | subprocess.run(["foo"], universal_newlines=True, text=True) 7 | run(["foo"], universal_newlines=True, check=False) | - = help: Replace with `text` keyword argument +help: Replace with `text` keyword argument ℹ Safe fix 2 2 | from subprocess import run @@ -21,15 +22,16 @@ UP021.py:5:25: UP021 [*] `universal_newlines` is deprecated, use `text` 7 7 | run(["foo"], universal_newlines=True, check=False) 8 8 | -UP021.py:6:25: UP021 [*] `universal_newlines` is deprecated, use `text` +UP021 [*] `universal_newlines` is deprecated, use `text` + --> UP021.py:6:25 | 4 | # Errors 5 | subprocess.run(["foo"], universal_newlines=True, check=True) 6 | subprocess.run(["foo"], universal_newlines=True, text=True) - | ^^^^^^^^^^^^^^^^^^ UP021 + | ^^^^^^^^^^^^^^^^^^ 7 | run(["foo"], universal_newlines=True, check=False) | - = help: Replace with `text` keyword argument +help: Replace with `text` keyword argument ℹ Safe fix 3 3 | @@ -41,16 +43,17 @@ UP021.py:6:25: UP021 [*] `universal_newlines` is deprecated, use `text` 8 8 | 9 9 | # OK -UP021.py:7:14: UP021 [*] `universal_newlines` is deprecated, use `text` +UP021 [*] `universal_newlines` is deprecated, use `text` + --> UP021.py:7:14 | 5 | subprocess.run(["foo"], universal_newlines=True, check=True) 6 | subprocess.run(["foo"], universal_newlines=True, text=True) 7 | run(["foo"], universal_newlines=True, check=False) - | ^^^^^^^^^^^^^^^^^^ UP021 + | ^^^^^^^^^^^^^^^^^^ 8 | 9 | # OK | - = help: Replace with `text` keyword argument +help: Replace with `text` keyword argument ℹ Safe fix 4 4 | # Errors diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap index 990936ee28..79582dbaee 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP022.py:4:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:4:10 | 2 | import subprocess 3 | 4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument ℹ Unsafe fix 1 1 | from subprocess import run @@ -22,16 +23,17 @@ UP022.py:4:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde 6 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 7 7 | -UP022.py:6:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:6:10 | 4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 5 | 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument ℹ Unsafe fix 3 3 | @@ -43,16 +45,17 @@ UP022.py:6:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde 8 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) 9 9 | -UP022.py:8:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:8:10 | 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 7 | 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | output = subprocess.run( | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument ℹ Unsafe fix 5 5 | @@ -64,7 +67,8 @@ UP022.py:8:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stde 10 10 | output = subprocess.run( 11 11 | ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE -UP022.py:10:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:10:10 | 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) 9 | @@ -72,11 +76,11 @@ UP022.py:10:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std | __________^ 11 | | ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE 12 | | ) - | |_^ UP022 + | |_^ 13 | 14 | output = subprocess.run( | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument ℹ Unsafe fix 8 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) @@ -88,7 +92,8 @@ UP022.py:10:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std 13 13 | 14 14 | output = subprocess.run( -UP022.py:14:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:14:10 | 12 | ) 13 | @@ -96,11 +101,11 @@ UP022.py:14:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std | __________^ 15 | | ["foo"], stderr=subprocess.PIPE, check=True, stdout=subprocess.PIPE 16 | | ) - | |_^ UP022 + | |_^ 17 | 18 | output = subprocess.run( | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument ℹ Unsafe fix 12 12 | ) @@ -112,7 +117,8 @@ UP022.py:14:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std 17 17 | 18 18 | output = subprocess.run( -UP022.py:18:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:18:10 | 16 | ) 17 | @@ -126,11 +132,11 @@ UP022.py:18:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std 24 | | encoding="utf-8", 25 | | close_fds=True, 26 | | ) - | |_^ UP022 + | |_^ 27 | 28 | if output: | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument ℹ Unsafe fix 17 17 | @@ -144,7 +150,8 @@ UP022.py:18:10: UP022 [*] Prefer `capture_output` over sending `stdout` and `std 24 23 | encoding="utf-8", 25 24 | close_fds=True, -UP022.py:29:14: UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 [*] Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:29:14 | 28 | if output: 29 | output = subprocess.run( @@ -156,11 +163,11 @@ UP022.py:29:14: UP022 [*] Prefer `capture_output` over sending `stdout` and `std 34 | | text=True, 35 | | encoding="utf-8", 36 | | ) - | |_____^ UP022 + | |_____^ 37 | 38 | output = subprocess.run( | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument ℹ Unsafe fix 28 28 | if output: @@ -174,7 +181,8 @@ UP022.py:29:14: UP022 [*] Prefer `capture_output` over sending `stdout` and `std 35 34 | encoding="utf-8", 36 35 | ) -UP022.py:38:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:38:10 | 36 | ) 37 | @@ -182,13 +190,14 @@ UP022.py:38:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` | __________^ 39 | | ["foo"], stdout=subprocess.PIPE, capture_output=True, stderr=subprocess.PIPE 40 | | ) - | |_^ UP022 + | |_^ 41 | 42 | output = subprocess.run( | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument -UP022.py:42:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:42:10 | 40 | ) 41 | @@ -196,13 +205,14 @@ UP022.py:42:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` | __________^ 43 | | ["foo"], stdout=subprocess.PIPE, capture_output=False, stderr=subprocess.PIPE 44 | | ) - | |_^ UP022 + | |_^ 45 | 46 | output = subprocess.run( | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument -UP022.py:46:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` +UP022 Prefer `capture_output` over sending `stdout` and `stderr` to `PIPE` + --> UP022.py:46:10 | 44 | ) 45 | @@ -210,8 +220,8 @@ UP022.py:46:10: UP022 Prefer `capture_output` over sending `stdout` and `stderr` | __________^ 47 | | ["foo"], capture_output=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE 48 | | ) - | |_^ UP022 + | |_^ 49 | 50 | # OK | - = help: Replace with `capture_output` keyword argument +help: Replace with `capture_output` keyword argument diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap index 33e1699fe3..5052273855 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP023.py:2:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:2:1 | 1 | # These two imports have something after cElementTree, so they should be fixed. 2 | from xml.etree.cElementTree import XML, Element, SubElement - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | import xml.etree.cElementTree as ET | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 1 1 | # These two imports have something after cElementTree, so they should be fixed. @@ -18,16 +19,17 @@ UP023.py:2:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 4 4 | 5 5 | # Weird spacing should not cause issues. -UP023.py:3:8: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:3:8 | 1 | # These two imports have something after cElementTree, so they should be fixed. 2 | from xml.etree.cElementTree import XML, Element, SubElement 3 | import xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | # Weird spacing should not cause issues. | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 1 1 | # These two imports have something after cElementTree, so they should be fixed. @@ -38,14 +40,15 @@ UP023.py:3:8: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 5 5 | # Weird spacing should not cause issues. 6 6 | from xml.etree.cElementTree import XML -UP023.py:6:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:6:1 | 5 | # Weird spacing should not cause issues. 6 | from xml.etree.cElementTree import XML - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | import xml.etree.cElementTree as ET | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 3 3 | import xml.etree.cElementTree as ET @@ -57,16 +60,17 @@ UP023.py:6:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 8 8 | 9 9 | # Multi line imports should also work fine. -UP023.py:7:11: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:7:11 | 5 | # Weird spacing should not cause issues. 6 | from xml.etree.cElementTree import XML 7 | import xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # Multi line imports should also work fine. | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 4 4 | @@ -78,7 +82,8 @@ UP023.py:7:11: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 9 9 | # Multi line imports should also work fine. 10 10 | from xml.etree.cElementTree import ( -UP023.py:10:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:10:1 | 9 | # Multi line imports should also work fine. 10 | / from xml.etree.cElementTree import ( @@ -86,11 +91,11 @@ UP023.py:10:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 12 | | Element, 13 | | SubElement, 14 | | ) - | |_^ UP023 + | |_^ 15 | if True: 16 | import xml.etree.cElementTree as ET | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 7 7 | import xml.etree.cElementTree as ET @@ -102,15 +107,16 @@ UP023.py:10:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 12 12 | Element, 13 13 | SubElement, -UP023.py:16:12: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:16:12 | 14 | ) 15 | if True: 16 | import xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | from xml.etree import cElementTree as CET | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 13 13 | SubElement, @@ -122,16 +128,17 @@ UP023.py:16:12: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 18 18 | 19 19 | from xml.etree import cElementTree as ET -UP023.py:17:27: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:17:27 | 15 | if True: 16 | import xml.etree.cElementTree as ET 17 | from xml.etree import cElementTree as CET - | ^^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^^ 18 | 19 | from xml.etree import cElementTree as ET | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 14 14 | ) @@ -143,16 +150,17 @@ UP023.py:17:27: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 19 19 | from xml.etree import cElementTree as ET 20 20 | -UP023.py:19:23: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:19:23 | 17 | from xml.etree import cElementTree as CET 18 | 19 | from xml.etree import cElementTree as ET - | ^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^ 20 | 21 | import contextlib, xml.etree.cElementTree as ET | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 16 16 | import xml.etree.cElementTree as ET @@ -164,16 +172,17 @@ UP023.py:19:23: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 21 21 | import contextlib, xml.etree.cElementTree as ET 22 22 | -UP023.py:21:20: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:21:20 | 19 | from xml.etree import cElementTree as ET 20 | 21 | import contextlib, xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | # This should fix the second, but not the first invocation. | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 18 18 | @@ -185,15 +194,16 @@ UP023.py:21:20: UP023 [*] `cElementTree` is deprecated, use `ElementTree` 23 23 | # This should fix the second, but not the first invocation. 24 24 | import xml.etree.cElementTree, xml.etree.cElementTree as ET -UP023.py:24:32: UP023 [*] `cElementTree` is deprecated, use `ElementTree` +UP023 [*] `cElementTree` is deprecated, use `ElementTree` + --> UP023.py:24:32 | 23 | # This should fix the second, but not the first invocation. 24 | import xml.etree.cElementTree, xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | # The below items should NOT be changed. | - = help: Replace with `ElementTree` +help: Replace with `ElementTree` ℹ Safe fix 21 21 | import contextlib, xml.etree.cElementTree as ET diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap index 70898be69c..552413b64e 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP024_0.py:6:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:6:8 | 4 | try: 5 | pass 6 | except EnvironmentError: - | ^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^ 7 | pass | - = help: Replace `EnvironmentError` with builtin `OSError` +help: Replace `EnvironmentError` with builtin `OSError` ℹ Safe fix 3 3 | # These should be fixed @@ -22,15 +22,16 @@ UP024_0.py:6:8: UP024 [*] Replace aliased errors with `OSError` 8 8 | 9 9 | try: -UP024_0.py:11:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:11:8 | 9 | try: 10 | pass 11 | except IOError: - | ^^^^^^^ UP024 + | ^^^^^^^ 12 | pass | - = help: Replace `IOError` with builtin `OSError` +help: Replace `IOError` with builtin `OSError` ℹ Safe fix 8 8 | @@ -42,15 +43,16 @@ UP024_0.py:11:8: UP024 [*] Replace aliased errors with `OSError` 13 13 | 14 14 | try: -UP024_0.py:16:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:16:8 | 14 | try: 15 | pass 16 | except WindowsError: - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 17 | pass | - = help: Replace `WindowsError` with builtin `OSError` +help: Replace `WindowsError` with builtin `OSError` ℹ Safe fix 13 13 | @@ -62,15 +64,16 @@ UP024_0.py:16:8: UP024 [*] Replace aliased errors with `OSError` 18 18 | 19 19 | try: -UP024_0.py:21:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:21:8 | 19 | try: 20 | pass 21 | except mmap.error: - | ^^^^^^^^^^ UP024 + | ^^^^^^^^^^ 22 | pass | - = help: Replace `mmap.error` with builtin `OSError` +help: Replace `mmap.error` with builtin `OSError` ℹ Safe fix 18 18 | @@ -82,15 +85,16 @@ UP024_0.py:21:8: UP024 [*] Replace aliased errors with `OSError` 23 23 | 24 24 | try: -UP024_0.py:26:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:26:8 | 24 | try: 25 | pass 26 | except select.error: - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 27 | pass | - = help: Replace `select.error` with builtin `OSError` +help: Replace `select.error` with builtin `OSError` ℹ Safe fix 23 23 | @@ -102,15 +106,16 @@ UP024_0.py:26:8: UP024 [*] Replace aliased errors with `OSError` 28 28 | 29 29 | try: -UP024_0.py:31:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:31:8 | 29 | try: 30 | pass 31 | except socket.error: - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 32 | pass | - = help: Replace `socket.error` with builtin `OSError` +help: Replace `socket.error` with builtin `OSError` ℹ Safe fix 28 28 | @@ -122,15 +127,16 @@ UP024_0.py:31:8: UP024 [*] Replace aliased errors with `OSError` 33 33 | 34 34 | try: -UP024_0.py:36:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:36:8 | 34 | try: 35 | pass 36 | except error: - | ^^^^^ UP024 + | ^^^^^ 37 | pass | - = help: Replace `error` with builtin `OSError` +help: Replace `error` with builtin `OSError` ℹ Safe fix 33 33 | @@ -142,16 +148,17 @@ UP024_0.py:36:8: UP024 [*] Replace aliased errors with `OSError` 38 38 | 39 39 | # Should NOT be in parentheses when replaced -UP024_0.py:43:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:43:8 | 41 | try: 42 | pass 43 | except (IOError,): - | ^^^^^^^^^^ UP024 + | ^^^^^^^^^^ 44 | pass 45 | try: | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 40 40 | @@ -163,16 +170,17 @@ UP024_0.py:43:8: UP024 [*] Replace aliased errors with `OSError` 45 45 | try: 46 46 | pass -UP024_0.py:47:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:47:8 | 45 | try: 46 | pass 47 | except (mmap.error,): - | ^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^ 48 | pass 49 | try: | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 44 44 | pass @@ -184,15 +192,16 @@ UP024_0.py:47:8: UP024 [*] Replace aliased errors with `OSError` 49 49 | try: 50 50 | pass -UP024_0.py:51:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:51:8 | 49 | try: 50 | pass 51 | except (EnvironmentError, IOError, OSError, select.error): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | pass | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 48 48 | pass @@ -204,15 +213,16 @@ UP024_0.py:51:8: UP024 [*] Replace aliased errors with `OSError` 53 53 | 54 54 | # Should be kept in parentheses (because multiple) -UP024_0.py:58:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:58:8 | 56 | try: 57 | pass 58 | except (IOError, KeyError, OSError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 59 | pass | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 55 55 | @@ -224,16 +234,17 @@ UP024_0.py:58:8: UP024 [*] Replace aliased errors with `OSError` 60 60 | 61 61 | # First should change, second should not -UP024_0.py:65:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:65:8 | 63 | try: 64 | pass 65 | except (IOError, error): - | ^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^ 66 | pass 67 | # These should not change | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 62 62 | from .mmap import error @@ -245,15 +256,16 @@ UP024_0.py:65:8: UP024 [*] Replace aliased errors with `OSError` 67 67 | # These should not change 68 68 | -UP024_0.py:87:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:87:8 | 85 | try: 86 | pass 87 | except (mmap).error: - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 88 | pass | - = help: Replace `mmap.error` with builtin `OSError` +help: Replace `mmap.error` with builtin `OSError` ℹ Safe fix 84 84 | pass @@ -265,15 +277,16 @@ UP024_0.py:87:8: UP024 [*] Replace aliased errors with `OSError` 89 89 | 90 90 | try: -UP024_0.py:105:11: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:105:11 | 103 | try: 104 | mac_address = get_primary_mac_address() 105 | except(IOError, OSError) as ex: - | ^^^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^^^ 106 | msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex) | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 102 102 | def get_owner_id_from_mac_address(): @@ -285,15 +298,16 @@ UP024_0.py:105:11: UP024 [*] Replace aliased errors with `OSError` 107 107 | 108 108 | -UP024_0.py:114:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_0.py:114:8 | 112 | try: 113 | pass 114 | except os.error: - | ^^^^^^^^ UP024 + | ^^^^^^^^ 115 | pass | - = help: Replace `os.error` with builtin `OSError` +help: Replace `os.error` with builtin `OSError` ℹ Safe fix 111 111 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap index 202e701dc7..0f79af245f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP024_1.py:5:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_1.py:5:8 | 3 | try: 4 | pass 5 | except (OSError, mmap.error, IOError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | pass 7 | except (OSError, socket.error, KeyError): | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 2 2 | @@ -23,15 +23,16 @@ UP024_1.py:5:8: UP024 [*] Replace aliased errors with `OSError` 7 7 | except (OSError, socket.error, KeyError): 8 8 | pass -UP024_1.py:7:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_1.py:7:8 | 5 | except (OSError, mmap.error, IOError): 6 | pass 7 | except (OSError, socket.error, KeyError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | pass | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 4 4 | pass @@ -43,7 +44,8 @@ UP024_1.py:7:8: UP024 [*] Replace aliased errors with `OSError` 9 9 | 10 10 | try: -UP024_1.py:12:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_1.py:12:8 | 10 | try: 11 | pass @@ -53,10 +55,10 @@ UP024_1.py:12:8: UP024 [*] Replace aliased errors with `OSError` 14 | | select.error, 15 | | IOError, 16 | | ): - | |_^ UP024 + | |_^ 17 | pass | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 9 9 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap index 7a05ae711b..6f60ec07fd 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP024_2.py:10:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:10:7 | 8 | # Testing the modules 9 | import socket, mmap, select, resource 10 | raise socket.error - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 11 | raise mmap.error 12 | raise select.error | - = help: Replace `socket.error` with builtin `OSError` +help: Replace `socket.error` with builtin `OSError` ℹ Safe fix 7 7 | @@ -22,16 +23,17 @@ UP024_2.py:10:7: UP024 [*] Replace aliased errors with `OSError` 12 12 | raise select.error 13 13 | raise resource.error -UP024_2.py:11:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:11:7 | 9 | import socket, mmap, select, resource 10 | raise socket.error 11 | raise mmap.error - | ^^^^^^^^^^ UP024 + | ^^^^^^^^^^ 12 | raise select.error 13 | raise resource.error | - = help: Replace `mmap.error` with builtin `OSError` +help: Replace `mmap.error` with builtin `OSError` ℹ Safe fix 8 8 | # Testing the modules @@ -43,15 +45,16 @@ UP024_2.py:11:7: UP024 [*] Replace aliased errors with `OSError` 13 13 | raise resource.error 14 14 | -UP024_2.py:12:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:12:7 | 10 | raise socket.error 11 | raise mmap.error 12 | raise select.error - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 13 | raise resource.error | - = help: Replace `select.error` with builtin `OSError` +help: Replace `select.error` with builtin `OSError` ℹ Safe fix 9 9 | import socket, mmap, select, resource @@ -63,16 +66,17 @@ UP024_2.py:12:7: UP024 [*] Replace aliased errors with `OSError` 14 14 | 15 15 | raise socket.error() -UP024_2.py:13:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:13:7 | 11 | raise mmap.error 12 | raise select.error 13 | raise resource.error - | ^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^ 14 | 15 | raise socket.error() | - = help: Replace `resource.error` with builtin `OSError` +help: Replace `resource.error` with builtin `OSError` ℹ Safe fix 10 10 | raise socket.error @@ -84,16 +88,17 @@ UP024_2.py:13:7: UP024 [*] Replace aliased errors with `OSError` 15 15 | raise socket.error() 16 16 | raise mmap.error(1) -UP024_2.py:15:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:15:7 | 13 | raise resource.error 14 | 15 | raise socket.error() - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 16 | raise mmap.error(1) 17 | raise select.error(1, 2) | - = help: Replace `socket.error` with builtin `OSError` +help: Replace `socket.error` with builtin `OSError` ℹ Safe fix 12 12 | raise select.error @@ -105,15 +110,16 @@ UP024_2.py:15:7: UP024 [*] Replace aliased errors with `OSError` 17 17 | raise select.error(1, 2) 18 18 | raise resource.error(1, "strerror", "filename") -UP024_2.py:16:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:16:7 | 15 | raise socket.error() 16 | raise mmap.error(1) - | ^^^^^^^^^^ UP024 + | ^^^^^^^^^^ 17 | raise select.error(1, 2) 18 | raise resource.error(1, "strerror", "filename") | - = help: Replace `mmap.error` with builtin `OSError` +help: Replace `mmap.error` with builtin `OSError` ℹ Safe fix 13 13 | raise resource.error @@ -125,15 +131,16 @@ UP024_2.py:16:7: UP024 [*] Replace aliased errors with `OSError` 18 18 | raise resource.error(1, "strerror", "filename") 19 19 | -UP024_2.py:17:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:17:7 | 15 | raise socket.error() 16 | raise mmap.error(1) 17 | raise select.error(1, 2) - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 18 | raise resource.error(1, "strerror", "filename") | - = help: Replace `select.error` with builtin `OSError` +help: Replace `select.error` with builtin `OSError` ℹ Safe fix 14 14 | @@ -145,16 +152,17 @@ UP024_2.py:17:7: UP024 [*] Replace aliased errors with `OSError` 19 19 | 20 20 | raise socket.error( -UP024_2.py:18:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:18:7 | 16 | raise mmap.error(1) 17 | raise select.error(1, 2) 18 | raise resource.error(1, "strerror", "filename") - | ^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^ 19 | 20 | raise socket.error( | - = help: Replace `resource.error` with builtin `OSError` +help: Replace `resource.error` with builtin `OSError` ℹ Safe fix 15 15 | raise socket.error() @@ -166,16 +174,17 @@ UP024_2.py:18:7: UP024 [*] Replace aliased errors with `OSError` 20 20 | raise socket.error( 21 21 | 1, -UP024_2.py:20:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:20:7 | 18 | raise resource.error(1, "strerror", "filename") 19 | 20 | raise socket.error( - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 21 | 1, 22 | 2, | - = help: Replace `socket.error` with builtin `OSError` +help: Replace `socket.error` with builtin `OSError` ℹ Safe fix 17 17 | raise select.error(1, 2) @@ -187,15 +196,16 @@ UP024_2.py:20:7: UP024 [*] Replace aliased errors with `OSError` 22 22 | 2, 23 23 | 3, -UP024_2.py:27:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:27:7 | 26 | from mmap import error 27 | raise error - | ^^^^^ UP024 + | ^^^^^ 28 | 29 | from socket import error | - = help: Replace `error` with builtin `OSError` +help: Replace `error` with builtin `OSError` ℹ Safe fix 24 24 | ) @@ -207,15 +217,16 @@ UP024_2.py:27:7: UP024 [*] Replace aliased errors with `OSError` 29 29 | from socket import error 30 30 | raise error(1) -UP024_2.py:30:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:30:7 | 29 | from socket import error 30 | raise error(1) - | ^^^^^ UP024 + | ^^^^^ 31 | 32 | from select import error | - = help: Replace `error` with builtin `OSError` +help: Replace `error` with builtin `OSError` ℹ Safe fix 27 27 | raise error @@ -227,15 +238,16 @@ UP024_2.py:30:7: UP024 [*] Replace aliased errors with `OSError` 32 32 | from select import error 33 33 | raise error(1, 2) -UP024_2.py:33:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:33:7 | 32 | from select import error 33 | raise error(1, 2) - | ^^^^^ UP024 + | ^^^^^ 34 | 35 | from resource import error | - = help: Replace `error` with builtin `OSError` +help: Replace `error` with builtin `OSError` ℹ Safe fix 30 30 | raise error(1) @@ -247,15 +259,16 @@ UP024_2.py:33:7: UP024 [*] Replace aliased errors with `OSError` 35 35 | from resource import error 36 36 | raise error(1, "strerror", "filename") -UP024_2.py:36:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:36:7 | 35 | from resource import error 36 | raise error(1, "strerror", "filename") - | ^^^^^ UP024 + | ^^^^^ 37 | 38 | # Testing the names | - = help: Replace `error` with builtin `OSError` +help: Replace `error` with builtin `OSError` ℹ Safe fix 33 33 | raise error(1, 2) @@ -267,15 +280,16 @@ UP024_2.py:36:7: UP024 [*] Replace aliased errors with `OSError` 38 38 | # Testing the names 39 39 | raise EnvironmentError -UP024_2.py:39:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:39:7 | 38 | # Testing the names 39 | raise EnvironmentError - | ^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^ 40 | raise IOError 41 | raise WindowsError | - = help: Replace `EnvironmentError` with builtin `OSError` +help: Replace `EnvironmentError` with builtin `OSError` ℹ Safe fix 36 36 | raise error(1, "strerror", "filename") @@ -287,15 +301,16 @@ UP024_2.py:39:7: UP024 [*] Replace aliased errors with `OSError` 41 41 | raise WindowsError 42 42 | -UP024_2.py:40:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:40:7 | 38 | # Testing the names 39 | raise EnvironmentError 40 | raise IOError - | ^^^^^^^ UP024 + | ^^^^^^^ 41 | raise WindowsError | - = help: Replace `IOError` with builtin `OSError` +help: Replace `IOError` with builtin `OSError` ℹ Safe fix 37 37 | @@ -307,16 +322,17 @@ UP024_2.py:40:7: UP024 [*] Replace aliased errors with `OSError` 42 42 | 43 43 | raise EnvironmentError() -UP024_2.py:41:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:41:7 | 39 | raise EnvironmentError 40 | raise IOError 41 | raise WindowsError - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 42 | 43 | raise EnvironmentError() | - = help: Replace `WindowsError` with builtin `OSError` +help: Replace `WindowsError` with builtin `OSError` ℹ Safe fix 38 38 | # Testing the names @@ -328,16 +344,17 @@ UP024_2.py:41:7: UP024 [*] Replace aliased errors with `OSError` 43 43 | raise EnvironmentError() 44 44 | raise IOError(1) -UP024_2.py:43:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:43:7 | 41 | raise WindowsError 42 | 43 | raise EnvironmentError() - | ^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^ 44 | raise IOError(1) 45 | raise WindowsError(1, 2) | - = help: Replace `EnvironmentError` with builtin `OSError` +help: Replace `EnvironmentError` with builtin `OSError` ℹ Safe fix 40 40 | raise IOError @@ -349,14 +366,15 @@ UP024_2.py:43:7: UP024 [*] Replace aliased errors with `OSError` 45 45 | raise WindowsError(1, 2) 46 46 | -UP024_2.py:44:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:44:7 | 43 | raise EnvironmentError() 44 | raise IOError(1) - | ^^^^^^^ UP024 + | ^^^^^^^ 45 | raise WindowsError(1, 2) | - = help: Replace `IOError` with builtin `OSError` +help: Replace `IOError` with builtin `OSError` ℹ Safe fix 41 41 | raise WindowsError @@ -368,16 +386,17 @@ UP024_2.py:44:7: UP024 [*] Replace aliased errors with `OSError` 46 46 | 47 47 | raise EnvironmentError( -UP024_2.py:45:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:45:7 | 43 | raise EnvironmentError() 44 | raise IOError(1) 45 | raise WindowsError(1, 2) - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 46 | 47 | raise EnvironmentError( | - = help: Replace `WindowsError` with builtin `OSError` +help: Replace `WindowsError` with builtin `OSError` ℹ Safe fix 42 42 | @@ -389,16 +408,17 @@ UP024_2.py:45:7: UP024 [*] Replace aliased errors with `OSError` 47 47 | raise EnvironmentError( 48 48 | 1, -UP024_2.py:47:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:47:7 | 45 | raise WindowsError(1, 2) 46 | 47 | raise EnvironmentError( - | ^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^ 48 | 1, 49 | 2, | - = help: Replace `EnvironmentError` with builtin `OSError` +help: Replace `EnvironmentError` with builtin `OSError` ℹ Safe fix 44 44 | raise IOError(1) @@ -410,16 +430,17 @@ UP024_2.py:47:7: UP024 [*] Replace aliased errors with `OSError` 49 49 | 2, 50 50 | 3, -UP024_2.py:53:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:53:7 | 51 | ) 52 | 53 | raise WindowsError - | ^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^ 54 | raise EnvironmentError(1) 55 | raise IOError(1, 2) | - = help: Replace `WindowsError` with builtin `OSError` +help: Replace `WindowsError` with builtin `OSError` ℹ Safe fix 50 50 | 3, @@ -430,14 +451,15 @@ UP024_2.py:53:7: UP024 [*] Replace aliased errors with `OSError` 54 54 | raise EnvironmentError(1) 55 55 | raise IOError(1, 2) -UP024_2.py:54:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:54:7 | 53 | raise WindowsError 54 | raise EnvironmentError(1) - | ^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^ 55 | raise IOError(1, 2) | - = help: Replace `EnvironmentError` with builtin `OSError` +help: Replace `EnvironmentError` with builtin `OSError` ℹ Safe fix 51 51 | ) @@ -447,14 +469,15 @@ UP024_2.py:54:7: UP024 [*] Replace aliased errors with `OSError` 54 |+raise OSError(1) 55 55 | raise IOError(1, 2) -UP024_2.py:55:7: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_2.py:55:7 | 53 | raise WindowsError 54 | raise EnvironmentError(1) 55 | raise IOError(1, 2) - | ^^^^^^^ UP024 + | ^^^^^^^ | - = help: Replace `IOError` with builtin `OSError` +help: Replace `IOError` with builtin `OSError` ℹ Safe fix 52 52 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap index c3ea530f1d..010982c8f1 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP024_4.py:9:8: UP024 [*] Replace aliased errors with `OSError` +UP024 [*] Replace aliased errors with `OSError` + --> UP024_4.py:9:8 | 7 | conn.ensure_connection(max_retries=2) 8 | conn._close() 9 | except (socket.error, exceptions.OperationalError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | return HttpResponseServerError("cache: cannot connect to broker.") | - = help: Replace with builtin `OSError` +help: Replace with builtin `OSError` ℹ Safe fix 6 6 | conn = Connection(settings.CELERY_BROKER_URL) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap index b9b6bc4da1..5fc2ff59e5 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP025.py:1:1: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:1:1 | 1 | u"Hello" - | ^^^^^^^^ UP025 + | ^^^^^^^^ 2 | 3 | x = u"Hello" # UP025 | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 1 |-u"Hello" @@ -17,16 +18,17 @@ UP025.py:1:1: UP025 [*] Remove unicode literals from strings 3 3 | x = u"Hello" # UP025 4 4 | -UP025.py:3:5: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:3:5 | 1 | u"Hello" 2 | 3 | x = u"Hello" # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 4 | 5 | u'world' # UP025 | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 1 1 | u"Hello" @@ -37,16 +39,17 @@ UP025.py:3:5: UP025 [*] Remove unicode literals from strings 5 5 | u'world' # UP025 6 6 | -UP025.py:5:1: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:5:1 | 3 | x = u"Hello" # UP025 4 | 5 | u'world' # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 6 | 7 | print(u"Hello") # UP025 | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 2 2 | @@ -58,16 +61,17 @@ UP025.py:5:1: UP025 [*] Remove unicode literals from strings 7 7 | print(u"Hello") # UP025 8 8 | -UP025.py:7:7: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:7:7 | 5 | u'world' # UP025 6 | 7 | print(u"Hello") # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 8 | 9 | print(u'world') # UP025 | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 4 4 | @@ -79,16 +83,17 @@ UP025.py:7:7: UP025 [*] Remove unicode literals from strings 9 9 | print(u'world') # UP025 10 10 | -UP025.py:9:7: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:9:7 | 7 | print(u"Hello") # UP025 8 | 9 | print(u'world') # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 10 | 11 | import foo | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 6 6 | @@ -100,16 +105,17 @@ UP025.py:9:7: UP025 [*] Remove unicode literals from strings 11 11 | import foo 12 12 | -UP025.py:13:5: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:13:5 | 11 | import foo 12 | 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 14 | 15 | # Retain quotes when fixing. | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 10 10 | @@ -121,16 +127,17 @@ UP025.py:13:5: UP025 [*] Remove unicode literals from strings 15 15 | # Retain quotes when fixing. 16 16 | x = u'hello' # UP025 -UP025.py:13:15: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:13:15 | 11 | import foo 12 | 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 14 | 15 | # Retain quotes when fixing. | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 10 10 | @@ -142,16 +149,17 @@ UP025.py:13:15: UP025 [*] Remove unicode literals from strings 15 15 | # Retain quotes when fixing. 16 16 | x = u'hello' # UP025 -UP025.py:13:27: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:13:27 | 11 | import foo 12 | 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 14 | 15 | # Retain quotes when fixing. | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 10 10 | @@ -163,16 +171,17 @@ UP025.py:13:27: UP025 [*] Remove unicode literals from strings 15 15 | # Retain quotes when fixing. 16 16 | x = u'hello' # UP025 -UP025.py:13:39: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:13:39 | 11 | import foo 12 | 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 14 | 15 | # Retain quotes when fixing. | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 10 10 | @@ -184,15 +193,16 @@ UP025.py:13:39: UP025 [*] Remove unicode literals from strings 15 15 | # Retain quotes when fixing. 16 16 | x = u'hello' # UP025 -UP025.py:16:5: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:16:5 | 15 | # Retain quotes when fixing. 16 | x = u'hello' # UP025 - | ^^^^^^^^ UP025 + | ^^^^^^^^ 17 | x = u"""hello""" # UP025 18 | x = u'''hello''' # UP025 | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 13 13 | foo(u"Hello", U"world", a=u"Hello", b=u"world") # UP025 @@ -204,16 +214,17 @@ UP025.py:16:5: UP025 [*] Remove unicode literals from strings 18 18 | x = u'''hello''' # UP025 19 19 | x = u'Hello "World"' # UP025 -UP025.py:17:5: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:17:5 | 15 | # Retain quotes when fixing. 16 | x = u'hello' # UP025 17 | x = u"""hello""" # UP025 - | ^^^^^^^^^^^^ UP025 + | ^^^^^^^^^^^^ 18 | x = u'''hello''' # UP025 19 | x = u'Hello "World"' # UP025 | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 14 14 | @@ -225,15 +236,16 @@ UP025.py:17:5: UP025 [*] Remove unicode literals from strings 19 19 | x = u'Hello "World"' # UP025 20 20 | -UP025.py:18:5: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:18:5 | 16 | x = u'hello' # UP025 17 | x = u"""hello""" # UP025 18 | x = u'''hello''' # UP025 - | ^^^^^^^^^^^^ UP025 + | ^^^^^^^^^^^^ 19 | x = u'Hello "World"' # UP025 | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 15 15 | # Retain quotes when fixing. @@ -245,16 +257,17 @@ UP025.py:18:5: UP025 [*] Remove unicode literals from strings 20 20 | 21 21 | u = "Hello" # OK -UP025.py:19:5: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:19:5 | 17 | x = u"""hello""" # UP025 18 | x = u'''hello''' # UP025 19 | x = u'Hello "World"' # UP025 - | ^^^^^^^^^^^^^^^^ UP025 + | ^^^^^^^^^^^^^^^^ 20 | 21 | u = "Hello" # OK | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 16 16 | x = u'hello' # UP025 @@ -266,15 +279,16 @@ UP025.py:19:5: UP025 [*] Remove unicode literals from strings 21 21 | u = "Hello" # OK 22 22 | u = u # OK -UP025.py:27:7: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:27:7 | 25 | return"Hello" # OK 26 | 27 | f"foo"u"bar" # OK - | ^^^^^^ UP025 + | ^^^^^^ 28 | f"foo" u"bar" # OK | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 24 24 | def hello(): @@ -286,15 +300,16 @@ UP025.py:27:7: UP025 [*] Remove unicode literals from strings 29 29 | 30 30 | # https://github.com/astral-sh/ruff/issues/18895 -UP025.py:28:8: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:28:8 | 27 | f"foo"u"bar" # OK 28 | f"foo" u"bar" # OK - | ^^^^^^ UP025 + | ^^^^^^ 29 | 30 | # https://github.com/astral-sh/ruff/issues/18895 | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 25 25 | return"Hello" # OK @@ -306,15 +321,16 @@ UP025.py:28:8: UP025 [*] Remove unicode literals from strings 30 30 | # https://github.com/astral-sh/ruff/issues/18895 31 31 | ""u"" -UP025.py:31:3: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:31:3 | 30 | # https://github.com/astral-sh/ruff/issues/18895 31 | ""u"" - | ^^^ UP025 + | ^^^ 32 | ""u"hi" 33 | """"""""""""""""""""u"hi" | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 28 28 | f"foo" u"bar" # OK @@ -326,16 +342,17 @@ UP025.py:31:3: UP025 [*] Remove unicode literals from strings 33 33 | """"""""""""""""""""u"hi" 34 34 | ""U"helloooo" -UP025.py:32:3: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:32:3 | 30 | # https://github.com/astral-sh/ruff/issues/18895 31 | ""u"" 32 | ""u"hi" - | ^^^^^ UP025 + | ^^^^^ 33 | """"""""""""""""""""u"hi" 34 | ""U"helloooo" | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 29 29 | @@ -346,15 +363,16 @@ UP025.py:32:3: UP025 [*] Remove unicode literals from strings 33 33 | """"""""""""""""""""u"hi" 34 34 | ""U"helloooo" -UP025.py:33:21: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:33:21 | 31 | ""u"" 32 | ""u"hi" 33 | """"""""""""""""""""u"hi" - | ^^^^^ UP025 + | ^^^^^ 34 | ""U"helloooo" | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 30 30 | # https://github.com/astral-sh/ruff/issues/18895 @@ -364,14 +382,15 @@ UP025.py:33:21: UP025 [*] Remove unicode literals from strings 33 |+"""""""""""""""""""" "hi" 34 34 | ""U"helloooo" -UP025.py:34:3: UP025 [*] Remove unicode literals from strings +UP025 [*] Remove unicode literals from strings + --> UP025.py:34:3 | 32 | ""u"hi" 33 | """"""""""""""""""""u"hi" 34 | ""U"helloooo" - | ^^^^^^^^^^^ UP025 + | ^^^^^^^^^^^ | - = help: Remove unicode prefix +help: Remove unicode prefix ℹ Safe fix 31 31 | ""u"" diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap index 83ef343e8e..33ff29dad7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP026.py:3:12: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:3:12 | 1 | # Error (`from unittest import mock`) 2 | if True: 3 | import mock - | ^^^^ UP026 + | ^^^^ 4 | 5 | # Error (`from unittest import mock`) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 1 1 | # Error (`from unittest import mock`) @@ -21,16 +22,17 @@ UP026.py:3:12: UP026 [*] `mock` is deprecated, use `unittest.mock` 5 5 | # Error (`from unittest import mock`) 6 6 | if True: -UP026.py:7:12: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:7:12 | 5 | # Error (`from unittest import mock`) 6 | if True: 7 | import mock, sys - | ^^^^ UP026 + | ^^^^ 8 | 9 | # Error (`from unittest.mock import *`) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 4 4 | @@ -43,16 +45,17 @@ UP026.py:7:12: UP026 [*] `mock` is deprecated, use `unittest.mock` 9 10 | # Error (`from unittest.mock import *`) 10 11 | if True: -UP026.py:11:5: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:11:5 | 9 | # Error (`from unittest.mock import *`) 10 | if True: 11 | from mock import * - | ^^^^^^^^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^^^^^^^^ 12 | 13 | # Error (`from unittest import mock`) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 8 8 | @@ -64,15 +67,16 @@ UP026.py:11:5: UP026 [*] `mock` is deprecated, use `unittest.mock` 13 13 | # Error (`from unittest import mock`) 14 14 | import mock.mock -UP026.py:14:8: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:14:8 | 13 | # Error (`from unittest import mock`) 14 | import mock.mock - | ^^^^^^^^^ UP026 + | ^^^^^^^^^ 15 | 16 | # Error (`from unittest import mock`) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 11 11 | from mock import * @@ -84,15 +88,16 @@ UP026.py:14:8: UP026 [*] `mock` is deprecated, use `unittest.mock` 16 16 | # Error (`from unittest import mock`) 17 17 | import contextlib, mock, sys -UP026.py:17:20: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:17:20 | 16 | # Error (`from unittest import mock`) 17 | import contextlib, mock, sys - | ^^^^ UP026 + | ^^^^ 18 | 19 | # Error (`from unittest import mock`) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 14 14 | import mock.mock @@ -105,14 +110,15 @@ UP026.py:17:20: UP026 [*] `mock` is deprecated, use `unittest.mock` 19 20 | # Error (`from unittest import mock`) 20 21 | import mock, sys -UP026.py:20:8: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:20:8 | 19 | # Error (`from unittest import mock`) 20 | import mock, sys - | ^^^^ UP026 + | ^^^^ 21 | x = "This code should be preserved one line below the mock" | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 17 17 | import contextlib, mock, sys @@ -125,15 +131,16 @@ UP026.py:20:8: UP026 [*] `mock` is deprecated, use `unittest.mock` 22 23 | 23 24 | # Error (`from unittest import mock`) -UP026.py:24:1: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:24:1 | 23 | # Error (`from unittest import mock`) 24 | from mock import mock - | ^^^^^^^^^^^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^^^^^^^^^^^ 25 | 26 | # Error (keep trailing comma) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 21 21 | x = "This code should be preserved one line below the mock" @@ -145,7 +152,8 @@ UP026.py:24:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 26 26 | # Error (keep trailing comma) 27 27 | from mock import ( -UP026.py:27:1: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:27:1 | 26 | # Error (keep trailing comma) 27 | / from mock import ( @@ -154,11 +162,11 @@ UP026.py:27:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 30 | | b, 31 | | c, 32 | | ) - | |_^ UP026 + | |_^ 33 | from mock import ( 34 | a, | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 24 24 | from mock import mock @@ -176,7 +184,8 @@ UP026.py:27:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 34 34 | a, 35 35 | b, -UP026.py:33:1: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:33:1 | 31 | c, 32 | ) @@ -186,11 +195,11 @@ UP026.py:33:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 36 | | c, 37 | | mock, 38 | | ) - | |_^ UP026 + | |_^ 39 | 40 | # Error (avoid trailing comma) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 30 30 | b, @@ -208,7 +217,8 @@ UP026.py:33:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 40 40 | # Error (avoid trailing comma) 41 41 | from mock import ( -UP026.py:41:1: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:41:1 | 40 | # Error (avoid trailing comma) 41 | / from mock import ( @@ -217,11 +227,11 @@ UP026.py:41:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 44 | | b, 45 | | c 46 | | ) - | |_^ UP026 + | |_^ 47 | from mock import ( 48 | a, | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 38 38 | ) @@ -239,7 +249,8 @@ UP026.py:41:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 48 48 | a, 49 49 | b, -UP026.py:47:1: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:47:1 | 45 | c 46 | ) @@ -249,11 +260,11 @@ UP026.py:47:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 50 | | c, 51 | | mock 52 | | ) - | |_^ UP026 + | |_^ 53 | from mock import mock, a, b, c 54 | from mock import a, b, c, mock | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 44 44 | b, @@ -272,15 +283,16 @@ UP026.py:47:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 54 54 | from mock import a, b, c, mock 55 55 | -UP026.py:53:1: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:53:1 | 51 | mock 52 | ) 53 | from mock import mock, a, b, c - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | from mock import a, b, c, mock | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 50 50 | c, @@ -293,16 +305,17 @@ UP026.py:53:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 55 56 | 56 57 | if True: -UP026.py:54:1: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:54:1 | 52 | ) 53 | from mock import mock, a, b, c 54 | from mock import a, b, c, mock - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | 56 | if True: | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 51 51 | mock @@ -315,7 +328,8 @@ UP026.py:54:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 56 57 | if True: 57 58 | if False: -UP026.py:58:9: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:58:9 | 56 | if True: 57 | if False: @@ -325,11 +339,11 @@ UP026.py:58:9: UP026 [*] `mock` is deprecated, use `unittest.mock` 61 | | b, 62 | | c 63 | | ) - | |_________^ UP026 + | |_________^ 64 | 65 | # OK | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 55 55 | @@ -347,15 +361,16 @@ UP026.py:58:9: UP026 [*] `mock` is deprecated, use `unittest.mock` 65 65 | # OK 66 66 | import os, io -UP026.py:69:8: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:69:8 | 68 | # Error (`from unittest import mock`) 69 | import mock, mock - | ^^^^ UP026 + | ^^^^ 70 | 71 | # Error (`from unittest import mock as foo`) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 66 66 | import os, io @@ -368,15 +383,16 @@ UP026.py:69:8: UP026 [*] `mock` is deprecated, use `unittest.mock` 71 72 | # Error (`from unittest import mock as foo`) 72 73 | import mock as foo -UP026.py:69:14: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:69:14 | 68 | # Error (`from unittest import mock`) 69 | import mock, mock - | ^^^^ UP026 + | ^^^^ 70 | 71 | # Error (`from unittest import mock as foo`) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 66 66 | import os, io @@ -389,15 +405,16 @@ UP026.py:69:14: UP026 [*] `mock` is deprecated, use `unittest.mock` 71 72 | # Error (`from unittest import mock as foo`) 72 73 | import mock as foo -UP026.py:72:8: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:72:8 | 71 | # Error (`from unittest import mock as foo`) 72 | import mock as foo - | ^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^ 73 | 74 | # Error (`from unittest import mock as foo`) | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 69 69 | import mock, mock @@ -409,15 +426,16 @@ UP026.py:72:8: UP026 [*] `mock` is deprecated, use `unittest.mock` 74 74 | # Error (`from unittest import mock as foo`) 75 75 | from mock import mock as foo -UP026.py:75:1: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:75:1 | 74 | # Error (`from unittest import mock as foo`) 75 | from mock import mock as foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 76 | 77 | if True: | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 72 72 | import mock as foo @@ -429,16 +447,17 @@ UP026.py:75:1: UP026 [*] `mock` is deprecated, use `unittest.mock` 77 77 | if True: 78 78 | # This should yield multiple, aliased imports. -UP026.py:79:12: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:79:12 | 77 | if True: 78 | # This should yield multiple, aliased imports. 79 | import mock as foo, mock as bar, mock - | ^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^ 80 | 81 | # This should yield multiple, aliased imports, and preserve `os`. | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 76 76 | @@ -452,16 +471,17 @@ UP026.py:79:12: UP026 [*] `mock` is deprecated, use `unittest.mock` 81 83 | # This should yield multiple, aliased imports, and preserve `os`. 82 84 | import mock as foo, mock as bar, mock, os -UP026.py:79:25: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:79:25 | 77 | if True: 78 | # This should yield multiple, aliased imports. 79 | import mock as foo, mock as bar, mock - | ^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^ 80 | 81 | # This should yield multiple, aliased imports, and preserve `os`. | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 76 76 | @@ -475,16 +495,17 @@ UP026.py:79:25: UP026 [*] `mock` is deprecated, use `unittest.mock` 81 83 | # This should yield multiple, aliased imports, and preserve `os`. 82 84 | import mock as foo, mock as bar, mock, os -UP026.py:79:38: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:79:38 | 77 | if True: 78 | # This should yield multiple, aliased imports. 79 | import mock as foo, mock as bar, mock - | ^^^^ UP026 + | ^^^^ 80 | 81 | # This should yield multiple, aliased imports, and preserve `os`. | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 76 76 | @@ -498,15 +519,16 @@ UP026.py:79:38: UP026 [*] `mock` is deprecated, use `unittest.mock` 81 83 | # This should yield multiple, aliased imports, and preserve `os`. 82 84 | import mock as foo, mock as bar, mock, os -UP026.py:82:12: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:82:12 | 81 | # This should yield multiple, aliased imports, and preserve `os`. 82 | import mock as foo, mock as bar, mock, os - | ^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^ 83 | 84 | if True: | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 79 79 | import mock as foo, mock as bar, mock @@ -521,15 +543,16 @@ UP026.py:82:12: UP026 [*] `mock` is deprecated, use `unittest.mock` 84 87 | if True: 85 88 | # This should yield multiple, aliased imports. -UP026.py:82:25: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:82:25 | 81 | # This should yield multiple, aliased imports, and preserve `os`. 82 | import mock as foo, mock as bar, mock, os - | ^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^ 83 | 84 | if True: | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 79 79 | import mock as foo, mock as bar, mock @@ -544,15 +567,16 @@ UP026.py:82:25: UP026 [*] `mock` is deprecated, use `unittest.mock` 84 87 | if True: 85 88 | # This should yield multiple, aliased imports. -UP026.py:82:38: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:82:38 | 81 | # This should yield multiple, aliased imports, and preserve `os`. 82 | import mock as foo, mock as bar, mock, os - | ^^^^ UP026 + | ^^^^ 83 | 84 | if True: | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 79 79 | import mock as foo, mock as bar, mock @@ -567,14 +591,15 @@ UP026.py:82:38: UP026 [*] `mock` is deprecated, use `unittest.mock` 84 87 | if True: 85 88 | # This should yield multiple, aliased imports. -UP026.py:86:5: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:86:5 | 84 | if True: 85 | # This should yield multiple, aliased imports. 86 | from mock import mock as foo, mock as bar, mock - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Import from `unittest.mock` instead +help: Import from `unittest.mock` instead ℹ Safe fix 83 83 | @@ -588,13 +613,14 @@ UP026.py:86:5: UP026 [*] `mock` is deprecated, use `unittest.mock` 88 90 | 89 91 | # OK. -UP026.py:93:5: UP026 [*] `mock` is deprecated, use `unittest.mock` +UP026 [*] `mock` is deprecated, use `unittest.mock` + --> UP026.py:93:5 | 92 | # Error (`mock.Mock()`). 93 | x = mock.mock.Mock() - | ^^^^^^^^^ UP026 + | ^^^^^^^^^ | - = help: Replace `mock.mock` with `mock` +help: Replace `mock.mock` with `mock` ℹ Safe fix 90 90 | x = mock.Mock() diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap index 2f00cdcfda..9ff4a063a7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP028_0.py:2:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:2:5 | 1 | def f(): 2 | / for x in y: 3 | | yield x - | |_______________^ UP028 + | |_______________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 1 1 | def f(): @@ -19,14 +20,15 @@ UP028_0.py:2:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 5 4 | 6 5 | def g(): -UP028_0.py:7:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:7:5 | 6 | def g(): 7 | / for x, y in z: 8 | | yield (x, y) - | |____________________^ UP028 + | |____________________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 4 4 | @@ -39,14 +41,15 @@ UP028_0.py:7:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 10 9 | 11 10 | def h(): -UP028_0.py:12:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:12:5 | 11 | def h(): 12 | / for x in [1, 2, 3]: 13 | | yield x - | |_______________^ UP028 + | |_______________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 9 9 | @@ -59,14 +62,15 @@ UP028_0.py:12:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 15 14 | 16 15 | def i(): -UP028_0.py:17:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:17:5 | 16 | def i(): 17 | / for x in {x for x in y}: 18 | | yield x - | |_______________^ UP028 + | |_______________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 14 14 | @@ -79,14 +83,15 @@ UP028_0.py:17:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 20 19 | 21 20 | def j(): -UP028_0.py:22:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:22:5 | 21 | def j(): 22 | / for x in (1, 2, 3): 23 | | yield x - | |_______________^ UP028 + | |_______________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 19 19 | @@ -99,14 +104,15 @@ UP028_0.py:22:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 25 24 | 26 25 | def k(): -UP028_0.py:27:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:27:5 | 26 | def k(): 27 | / for x, y in {3: "x", 6: "y"}: 28 | | yield x, y - | |__________________^ UP028 + | |__________________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 24 24 | @@ -119,7 +125,8 @@ UP028_0.py:27:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 30 29 | 31 30 | def f(): # Comment one\n' -UP028_0.py:33:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:33:5 | 31 | def f(): # Comment one\n' 32 | # Comment two\n' @@ -130,10 +137,10 @@ UP028_0.py:33:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 37 | | }: # Comment seven\n' 38 | | # Comment eight\n' 39 | | yield x, y # Comment nine\n' - | |__________________^ UP028 + | |__________________^ 40 | # Comment ten', | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 30 30 | @@ -152,14 +159,15 @@ UP028_0.py:33:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 41 39 | 42 40 | -UP028_0.py:44:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:44:5 | 43 | def f(): 44 | / for x, y in [{3: (3, [44, "long ss"]), 6: "y"}]: 45 | | yield x, y - | |__________________^ UP028 + | |__________________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 41 41 | @@ -172,16 +180,17 @@ UP028_0.py:44:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 47 46 | 48 47 | def f(): -UP028_0.py:49:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:49:5 | 48 | def f(): 49 | / for x, y in z(): 50 | | yield x, y - | |__________________^ UP028 + | |__________________^ 51 | 52 | def f(): | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 46 46 | @@ -194,18 +203,19 @@ UP028_0.py:49:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 52 51 | def f(): 53 52 | def func(): -UP028_0.py:55:9: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:55:9 | 53 | def func(): 54 | # This comment is preserved\n' 55 | / for x, y in z(): # Comment one\n' 56 | | # Comment two\n' 57 | | yield x, y # Comment three\n' - | |______________________^ UP028 + | |______________________^ 58 | # Comment four\n' 59 | # Comment\n' | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 52 52 | def f(): @@ -219,15 +229,16 @@ UP028_0.py:55:9: UP028 [*] Replace `yield` over `for` loop with `yield from` 59 57 | # Comment\n' 60 58 | def g(): -UP028_0.py:67:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:67:5 | 65 | for x in y: 66 | yield x 67 | / for z in x: 68 | | yield z - | |_______________^ UP028 + | |_______________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 64 64 | def f(): @@ -240,15 +251,16 @@ UP028_0.py:67:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 70 69 | 71 70 | def f(): -UP028_0.py:72:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:72:5 | 71 | def f(): 72 | / for x, y in z(): 73 | | yield x, y - | |__________________^ UP028 + | |__________________^ 74 | x = 1 | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 69 69 | @@ -261,7 +273,8 @@ UP028_0.py:72:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 75 74 | 76 75 | -UP028_0.py:79:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:79:5 | 77 | # Regression test for: https://github.com/astral-sh/ruff/issues/7103 78 | def _serve_method(fn): @@ -270,9 +283,9 @@ UP028_0.py:79:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 81 | | .markup(highlight=args.region) 82 | | ): 83 | | yield h - | |_______________^ UP028 + | |_______________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 76 76 | @@ -289,17 +302,18 @@ UP028_0.py:79:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 85 84 | 86 85 | # UP028: The later loop variable is not a reference to the earlier loop variable -UP028_0.py:97:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:97:5 | 95 | # UP028: The exception binding is not a reference to the loop variable 96 | def f(): 97 | / for x in (1, 2, 3): 98 | | yield x - | |_______________^ UP028 + | |_______________^ 99 | # Shadowing with an `except` 100 | try: | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 94 94 | @@ -312,17 +326,18 @@ UP028_0.py:97:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 100 99 | try: 101 100 | pass -UP028_0.py:108:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:108:5 | 106 | # UP028: The context binding is not a reference to the loop variable 107 | def f(): 108 | / for x in (1, 2, 3): 109 | | yield x - | |_______________^ UP028 + | |_______________^ 110 | # Shadowing with `with` 111 | with contextlib.nullcontext() as x: | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 105 105 | @@ -335,17 +350,18 @@ UP028_0.py:108:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 111 110 | with contextlib.nullcontext() as x: 112 111 | pass -UP028_0.py:118:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:118:5 | 116 | # UP028: The type annotation binding is not a reference to the loop variable 117 | def f(): 118 | / for x in (1, 2, 3): 119 | | yield x - | |_______________^ UP028 + | |_______________^ 120 | # Shadowing with a type annotation 121 | x: int | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 115 115 | @@ -358,17 +374,18 @@ UP028_0.py:118:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 121 120 | x: int 122 121 | -UP028_0.py:134:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:134:5 | 132 | # UP028: The exception bindings are not a reference to the loop variable 133 | def f(): 134 | / for x in (1, 2, 3): 135 | | yield x - | |_______________^ UP028 + | |_______________^ 136 | # Shadowing with multiple `except` blocks 137 | try: | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 131 131 | @@ -381,15 +398,16 @@ UP028_0.py:134:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 137 136 | try: 138 137 | pass -UP028_0.py:170:5: UP028 [*] Replace `yield` over `for` loop with `yield from` +UP028 [*] Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:170:5 | 168 | # https://github.com/astral-sh/ruff/issues/15540 169 | def f(): 170 | / for a in 1,: 171 | | yield a - | |_______________^ UP028 + | |_______________^ | - = help: Replace with `yield from` +help: Replace with `yield from` ℹ Unsafe fix 167 167 | @@ -402,24 +420,26 @@ UP028_0.py:170:5: UP028 [*] Replace `yield` over `for` loop with `yield from` 173 172 | 174 173 | SOME_GLOBAL = None -UP028_0.py:179:5: UP028 Replace `yield` over `for` loop with `yield from` +UP028 Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:179:5 | 177 | global SOME_GLOBAL 178 | 179 | / for SOME_GLOBAL in iterable: 180 | | yield SOME_GLOBAL - | |_________________________^ UP028 + | |_________________________^ 181 | 182 | some_non_local = None | - = help: Replace with `yield from` +help: Replace with `yield from` -UP028_0.py:187:9: UP028 Replace `yield` over `for` loop with `yield from` +UP028 Replace `yield` over `for` loop with `yield from` + --> UP028_0.py:187:9 | 185 | nonlocal some_non_local 186 | 187 | / for some_non_local in iterable: 188 | | yield some_non_local - | |________________________________^ UP028 + | |________________________________^ | - = help: Replace with `yield from` +help: Replace with `yield from` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap index 67f4c5ab7f..09c5ad548c 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP029.py:1:1: UP029 [*] Unnecessary builtin import: `*` +UP029 [*] Unnecessary builtin import: `*` + --> UP029.py:1:1 | 1 | from builtins import * - | ^^^^^^^^^^^^^^^^^^^^^^ UP029 + | ^^^^^^^^^^^^^^^^^^^^^^ 2 | from builtins import ascii, bytes, compile 3 | from builtins import str as _str | - = help: Remove unnecessary builtin import +help: Remove unnecessary builtin import ℹ Unsafe fix 1 |-from builtins import * @@ -17,15 +17,16 @@ UP029.py:1:1: UP029 [*] Unnecessary builtin import: `*` 3 2 | from builtins import str as _str 4 3 | from six.moves import filter, zip, zip_longest -UP029.py:2:1: UP029 [*] Unnecessary builtin imports: `ascii`, `bytes` +UP029 [*] Unnecessary builtin imports: `ascii`, `bytes` + --> UP029.py:2:1 | 1 | from builtins import * 2 | from builtins import ascii, bytes, compile - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP029 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | from builtins import str as _str 4 | from six.moves import filter, zip, zip_longest | - = help: Remove unnecessary builtin import +help: Remove unnecessary builtin import ℹ Unsafe fix 1 1 | from builtins import * @@ -35,16 +36,17 @@ UP029.py:2:1: UP029 [*] Unnecessary builtin imports: `ascii`, `bytes` 4 4 | from six.moves import filter, zip, zip_longest 5 5 | from io import open -UP029.py:4:1: UP029 [*] Unnecessary builtin imports: `filter`, `zip` +UP029 [*] Unnecessary builtin imports: `filter`, `zip` + --> UP029.py:4:1 | 2 | from builtins import ascii, bytes, compile 3 | from builtins import str as _str 4 | from six.moves import filter, zip, zip_longest - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP029 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | from io import open 6 | import io | - = help: Remove unnecessary builtin import +help: Remove unnecessary builtin import ℹ Unsafe fix 1 1 | from builtins import * @@ -56,16 +58,17 @@ UP029.py:4:1: UP029 [*] Unnecessary builtin imports: `filter`, `zip` 6 6 | import io 7 7 | import six -UP029.py:5:1: UP029 [*] Unnecessary builtin import: `open` +UP029 [*] Unnecessary builtin import: `open` + --> UP029.py:5:1 | 3 | from builtins import str as _str 4 | from six.moves import filter, zip, zip_longest 5 | from io import open - | ^^^^^^^^^^^^^^^^^^^ UP029 + | ^^^^^^^^^^^^^^^^^^^ 6 | import io 7 | import six | - = help: Remove unnecessary builtin import +help: Remove unnecessary builtin import ℹ Unsafe fix 2 2 | from builtins import ascii, bytes, compile diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap index 0a13ddbd11..f24c483f25 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP030_0.py:3:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:3:1 | 1 | # Invalid calls; errors expected. 2 | 3 | "{0}" "{1}" "{2}".format(1, 2, 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | "a {3} complicated {1} string with {0} {2}".format( | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 1 1 | # Invalid calls; errors expected. @@ -21,18 +22,19 @@ UP030_0.py:3:1: UP030 [*] Use implicit references for positional format fields 5 5 | "a {3} complicated {1} string with {0} {2}".format( 6 6 | "first", "second", "third", "fourth" -UP030_0.py:5:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:5:1 | 3 | "{0}" "{1}" "{2}".format(1, 2, 3) 4 | 5 | / "a {3} complicated {1} string with {0} {2}".format( 6 | | "first", "second", "third", "fourth" 7 | | ) - | |_^ UP030 + | |_^ 8 | 9 | '{0}'.format(1) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 2 2 | @@ -46,16 +48,17 @@ UP030_0.py:5:1: UP030 [*] Use implicit references for positional format fields 8 8 | 9 9 | '{0}'.format(1) -UP030_0.py:9:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:9:1 | 7 | ) 8 | 9 | '{0}'.format(1) - | ^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^ 10 | 11 | '{0:x}'.format(30) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 6 6 | "first", "second", "third", "fourth" @@ -67,16 +70,17 @@ UP030_0.py:9:1: UP030 [*] Use implicit references for positional format fields 11 11 | '{0:x}'.format(30) 12 12 | -UP030_0.py:11:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:11:1 | 9 | '{0}'.format(1) 10 | 11 | '{0:x}'.format(30) - | ^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^ 12 | 13 | x = '{0}'.format(1) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 8 8 | @@ -88,16 +92,17 @@ UP030_0.py:11:1: UP030 [*] Use implicit references for positional format fields 13 13 | x = '{0}'.format(1) 14 14 | -UP030_0.py:13:5: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:13:5 | 11 | '{0:x}'.format(30) 12 | 13 | x = '{0}'.format(1) - | ^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^ 14 | 15 | '''{0}\n{1}\n'''.format(1, 2) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 10 10 | @@ -109,16 +114,17 @@ UP030_0.py:13:5: UP030 [*] Use implicit references for positional format fields 15 15 | '''{0}\n{1}\n'''.format(1, 2) 16 16 | -UP030_0.py:15:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:15:1 | 13 | x = '{0}'.format(1) 14 | 15 | '''{0}\n{1}\n'''.format(1, 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | x = "foo {0}" \ | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 12 12 | @@ -130,18 +136,19 @@ UP030_0.py:15:1: UP030 [*] Use implicit references for positional format fields 17 17 | x = "foo {0}" \ 18 18 | "bar {1}".format(1, 2) -UP030_0.py:17:5: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:17:5 | 15 | '''{0}\n{1}\n'''.format(1, 2) 16 | 17 | x = "foo {0}" \ | _____^ 18 | | "bar {1}".format(1, 2) - | |__________________________^ UP030 + | |__________________________^ 19 | 20 | ("{0}").format(1) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 14 14 | @@ -155,16 +162,17 @@ UP030_0.py:17:5: UP030 [*] Use implicit references for positional format fields 20 20 | ("{0}").format(1) 21 21 | -UP030_0.py:20:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:20:1 | 18 | "bar {1}".format(1, 2) 19 | 20 | ("{0}").format(1) - | ^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^ 21 | 22 | "\N{snowman} {0}".format(1) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 17 17 | x = "foo {0}" \ @@ -176,16 +184,17 @@ UP030_0.py:20:1: UP030 [*] Use implicit references for positional format fields 22 22 | "\N{snowman} {0}".format(1) 23 23 | -UP030_0.py:22:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:22:1 | 20 | ("{0}").format(1) 21 | 22 | "\N{snowman} {0}".format(1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | print( | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 19 19 | @@ -197,15 +206,16 @@ UP030_0.py:22:1: UP030 [*] Use implicit references for positional format fields 24 24 | print( 25 25 | 'foo{0}' -UP030_0.py:25:5: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:25:5 | 24 | print( 25 | / 'foo{0}' 26 | | 'bar{1}'.format(1, 2) - | |_________________________^ UP030 + | |_________________________^ 27 | ) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 22 22 | "\N{snowman} {0}".format(1) @@ -219,15 +229,16 @@ UP030_0.py:25:5: UP030 [*] Use implicit references for positional format fields 28 28 | 29 29 | print( -UP030_0.py:30:5: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:30:5 | 29 | print( 30 | / 'foo{0}' # ohai\n" 31 | | 'bar{1}'.format(1, 2) - | |_________________________^ UP030 + | |_________________________^ 32 | ) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 27 27 | ) @@ -241,27 +252,29 @@ UP030_0.py:30:5: UP030 [*] Use implicit references for positional format fields 33 33 | 34 34 | '{' '0}'.format(1) -UP030_0.py:34:1: UP030 Use implicit references for positional format fields +UP030 Use implicit references for positional format fields + --> UP030_0.py:34:1 | 32 | ) 33 | 34 | '{' '0}'.format(1) - | ^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^ 35 | 36 | args = list(range(10)) | - = help: Remove explicit positional indices +help: Remove explicit positional indices -UP030_0.py:39:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:39:1 | 37 | kwargs = {x: x for x in range(10)} 38 | 39 | "{0}".format(*args) - | ^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^ 40 | 41 | "{0}".format(**kwargs) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 36 36 | args = list(range(10)) @@ -273,16 +286,17 @@ UP030_0.py:39:1: UP030 [*] Use implicit references for positional format fields 41 41 | "{0}".format(**kwargs) 42 42 | -UP030_0.py:41:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:41:1 | 39 | "{0}".format(*args) 40 | 41 | "{0}".format(**kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^ 42 | 43 | "{0}_{1}".format(*args) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 38 38 | @@ -294,16 +308,17 @@ UP030_0.py:41:1: UP030 [*] Use implicit references for positional format fields 43 43 | "{0}_{1}".format(*args) 44 44 | -UP030_0.py:43:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:43:1 | 41 | "{0}".format(**kwargs) 42 | 43 | "{0}_{1}".format(*args) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^ 44 | 45 | "{0}_{1}".format(1, *args) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 40 40 | @@ -315,16 +330,17 @@ UP030_0.py:43:1: UP030 [*] Use implicit references for positional format fields 45 45 | "{0}_{1}".format(1, *args) 46 46 | -UP030_0.py:45:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:45:1 | 43 | "{0}_{1}".format(*args) 44 | 45 | "{0}_{1}".format(1, *args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | 47 | "{0}_{1}".format(1, 2, *args) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 42 42 | @@ -336,16 +352,17 @@ UP030_0.py:45:1: UP030 [*] Use implicit references for positional format fields 47 47 | "{0}_{1}".format(1, 2, *args) 48 48 | -UP030_0.py:47:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:47:1 | 45 | "{0}_{1}".format(1, *args) 46 | 47 | "{0}_{1}".format(1, 2, *args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | 49 | "{0}_{1}".format(*args, 1, 2) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 44 44 | @@ -357,16 +374,17 @@ UP030_0.py:47:1: UP030 [*] Use implicit references for positional format fields 49 49 | "{0}_{1}".format(*args, 1, 2) 50 50 | -UP030_0.py:49:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:49:1 | 47 | "{0}_{1}".format(1, 2, *args) 48 | 49 | "{0}_{1}".format(*args, 1, 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | "{0}_{1}_{2}".format(1, **kwargs) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 46 46 | @@ -378,16 +396,17 @@ UP030_0.py:49:1: UP030 [*] Use implicit references for positional format fields 51 51 | "{0}_{1}_{2}".format(1, **kwargs) 52 52 | -UP030_0.py:51:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:51:1 | 49 | "{0}_{1}".format(*args, 1, 2) 50 | 51 | "{0}_{1}_{2}".format(1, **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 48 48 | @@ -399,16 +418,17 @@ UP030_0.py:51:1: UP030 [*] Use implicit references for positional format fields 53 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) 54 54 | -UP030_0.py:53:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:53:1 | 51 | "{0}_{1}_{2}".format(1, **kwargs) 52 | 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 50 50 | @@ -420,16 +440,17 @@ UP030_0.py:53:1: UP030 [*] Use implicit references for positional format fields 55 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) 56 56 | -UP030_0.py:55:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:55:1 | 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) 54 | 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 52 52 | @@ -441,16 +462,17 @@ UP030_0.py:55:1: UP030 [*] Use implicit references for positional format fields 57 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) 58 58 | -UP030_0.py:57:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:57:1 | 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) 56 | 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 58 | 59 | "{1}_{0}".format(1, 2, *args) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 54 54 | @@ -462,16 +484,17 @@ UP030_0.py:57:1: UP030 [*] Use implicit references for positional format fields 59 59 | "{1}_{0}".format(1, 2, *args) 60 60 | -UP030_0.py:59:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:59:1 | 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) 58 | 59 | "{1}_{0}".format(1, 2, *args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | 61 | "{1}_{0}".format(1, 2) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 56 56 | @@ -483,16 +506,17 @@ UP030_0.py:59:1: UP030 [*] Use implicit references for positional format fields 61 61 | "{1}_{0}".format(1, 2) 62 62 | -UP030_0.py:61:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:61:1 | 59 | "{1}_{0}".format(1, 2, *args) 60 | 61 | "{1}_{0}".format(1, 2) - | ^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^ 62 | 63 | r"\d{{1,2}} {0}".format(42) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 58 58 | @@ -504,16 +528,17 @@ UP030_0.py:61:1: UP030 [*] Use implicit references for positional format fields 63 63 | r"\d{{1,2}} {0}".format(42) 64 64 | -UP030_0.py:63:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:63:1 | 61 | "{1}_{0}".format(1, 2) 62 | 63 | r"\d{{1,2}} {0}".format(42) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | 65 | "{{{0}}}".format(123) | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 60 60 | @@ -524,14 +549,15 @@ UP030_0.py:63:1: UP030 [*] Use implicit references for positional format fields 64 64 | 65 65 | "{{{0}}}".format(123) -UP030_0.py:65:1: UP030 [*] Use implicit references for positional format fields +UP030 [*] Use implicit references for positional format fields + --> UP030_0.py:65:1 | 63 | r"\d{{1,2}} {0}".format(42) 64 | 65 | "{{{0}}}".format(123) - | ^^^^^^^^^^^^^^^^^^^^^ UP030 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove explicit positional indices +help: Remove explicit positional indices ℹ Unsafe fix 62 62 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap index 129a49cc93..f298074e37 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP031_0.py:4:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:4:7 | 3 | # UP031 4 | print('%s %s' % (a, b)) - | ^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^ 5 | 6 | print('%s%s' % (a, b)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 1 1 | a, b, x, y = 1, 2, 3, 4 @@ -21,16 +22,17 @@ UP031_0.py:4:7: UP031 [*] Use format specifiers instead of percent format 6 6 | print('%s%s' % (a, b)) 7 7 | -UP031_0.py:6:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:6:7 | 4 | print('%s %s' % (a, b)) 5 | 6 | print('%s%s' % (a, b)) - | ^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^ 7 | 8 | print("trivial" % ()) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 3 3 | # UP031 @@ -42,16 +44,17 @@ UP031_0.py:6:7: UP031 [*] Use format specifiers instead of percent format 8 8 | print("trivial" % ()) 9 9 | -UP031_0.py:8:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:8:7 | 6 | print('%s%s' % (a, b)) 7 | 8 | print("trivial" % ()) - | ^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^ 9 | 10 | print("%s" % ("simple",)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 5 5 | @@ -63,16 +66,17 @@ UP031_0.py:8:7: UP031 [*] Use format specifiers instead of percent format 10 10 | print("%s" % ("simple",)) 11 11 | -UP031_0.py:10:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:10:7 | 8 | print("trivial" % ()) 9 | 10 | print("%s" % ("simple",)) - | ^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^ 11 | 12 | print("%s" % ("%s" % ("nested",),)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 7 7 | @@ -84,16 +88,17 @@ UP031_0.py:10:7: UP031 [*] Use format specifiers instead of percent format 12 12 | print("%s" % ("%s" % ("nested",),)) 13 13 | -UP031_0.py:12:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:12:7 | 10 | print("%s" % ("simple",)) 11 | 12 | print("%s" % ("%s" % ("nested",),)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | print("%s%% percent" % (15,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 9 9 | @@ -105,16 +110,17 @@ UP031_0.py:12:7: UP031 [*] Use format specifiers instead of percent format 14 14 | print("%s%% percent" % (15,)) 15 15 | -UP031_0.py:12:15: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:12:15 | 10 | print("%s" % ("simple",)) 11 | 12 | print("%s" % ("%s" % ("nested",),)) - | ^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^ 13 | 14 | print("%s%% percent" % (15,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 9 9 | @@ -126,16 +132,17 @@ UP031_0.py:12:15: UP031 [*] Use format specifiers instead of percent format 14 14 | print("%s%% percent" % (15,)) 15 15 | -UP031_0.py:14:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:14:7 | 12 | print("%s" % ("%s" % ("nested",),)) 13 | 14 | print("%s%% percent" % (15,)) - | ^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | print("%f" % (15,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 11 11 | @@ -147,16 +154,17 @@ UP031_0.py:14:7: UP031 [*] Use format specifiers instead of percent format 16 16 | print("%f" % (15,)) 17 17 | -UP031_0.py:16:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:16:7 | 14 | print("%s%% percent" % (15,)) 15 | 16 | print("%f" % (15,)) - | ^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^ 17 | 18 | print("%.f" % (15,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 13 13 | @@ -168,16 +176,17 @@ UP031_0.py:16:7: UP031 [*] Use format specifiers instead of percent format 18 18 | print("%.f" % (15,)) 19 19 | -UP031_0.py:18:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:18:7 | 16 | print("%f" % (15,)) 17 | 18 | print("%.f" % (15,)) - | ^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^ 19 | 20 | print("%.3f" % (15,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 15 15 | @@ -189,16 +198,17 @@ UP031_0.py:18:7: UP031 [*] Use format specifiers instead of percent format 20 20 | print("%.3f" % (15,)) 21 21 | -UP031_0.py:20:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:20:7 | 18 | print("%.f" % (15,)) 19 | 20 | print("%.3f" % (15,)) - | ^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^ 21 | 22 | print("%3f" % (15,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 17 17 | @@ -210,16 +220,17 @@ UP031_0.py:20:7: UP031 [*] Use format specifiers instead of percent format 22 22 | print("%3f" % (15,)) 23 23 | -UP031_0.py:22:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:22:7 | 20 | print("%.3f" % (15,)) 21 | 22 | print("%3f" % (15,)) - | ^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^ 23 | 24 | print("%-5f" % (5,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 19 19 | @@ -231,16 +242,17 @@ UP031_0.py:22:7: UP031 [*] Use format specifiers instead of percent format 24 24 | print("%-5f" % (5,)) 25 25 | -UP031_0.py:24:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:24:7 | 22 | print("%3f" % (15,)) 23 | 24 | print("%-5f" % (5,)) - | ^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^ 25 | 26 | print("%9f" % (5,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 21 21 | @@ -252,16 +264,17 @@ UP031_0.py:24:7: UP031 [*] Use format specifiers instead of percent format 26 26 | print("%9f" % (5,)) 27 27 | -UP031_0.py:26:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:26:7 | 24 | print("%-5f" % (5,)) 25 | 26 | print("%9f" % (5,)) - | ^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^ 27 | 28 | print("%#o" % (123,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 23 23 | @@ -273,16 +286,17 @@ UP031_0.py:26:7: UP031 [*] Use format specifiers instead of percent format 28 28 | print("%#o" % (123,)) 29 29 | -UP031_0.py:28:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:28:7 | 26 | print("%9f" % (5,)) 27 | 28 | print("%#o" % (123,)) - | ^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^ 29 | 30 | print("brace {} %s" % (1,)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 25 25 | @@ -294,16 +308,17 @@ UP031_0.py:28:7: UP031 [*] Use format specifiers instead of percent format 30 30 | print("brace {} %s" % (1,)) 31 31 | -UP031_0.py:30:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:30:7 | 28 | print("%#o" % (123,)) 29 | 30 | print("brace {} %s" % (1,)) - | ^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^ 31 | 32 | print(( | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 27 27 | @@ -315,15 +330,16 @@ UP031_0.py:30:7: UP031 [*] Use format specifiers instead of percent format 32 32 | print(( 33 33 | "foo %s " -UP031_0.py:33:5: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:33:5 | 32 | print(( 33 | / "foo %s " 34 | | "bar %s" % (x, y) - | |_____________________^ UP031 + | |_____________________^ 35 | )) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 30 30 | print("brace {} %s" % (1,)) @@ -337,16 +353,17 @@ UP031_0.py:33:5: UP031 [*] Use format specifiers instead of percent format 36 36 | 37 37 | print( -UP031_0.py:38:3: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:38:3 | 37 | print( 38 | / "%s" % ( 39 | | "trailing comma", 40 | | ) - | |_________^ UP031 + | |_________^ 41 | ) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 35 35 | )) @@ -358,16 +375,17 @@ UP031_0.py:38:3: UP031 [*] Use format specifiers instead of percent format 40 40 | ) 41 41 | ) -UP031_0.py:43:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:43:7 | 41 | ) 42 | 43 | print("foo %s " % (x,)) - | ^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^ 44 | 45 | print("%(k)s" % {"k": "v"}) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 40 40 | ) @@ -379,16 +397,17 @@ UP031_0.py:43:7: UP031 [*] Use format specifiers instead of percent format 45 45 | print("%(k)s" % {"k": "v"}) 46 46 | -UP031_0.py:45:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:45:7 | 43 | print("foo %s " % (x,)) 44 | 45 | print("%(k)s" % {"k": "v"}) - | ^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^ 46 | 47 | print("%(k)s" % { | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 42 42 | @@ -400,7 +419,8 @@ UP031_0.py:45:7: UP031 [*] Use format specifiers instead of percent format 47 47 | print("%(k)s" % { 48 48 | "k": "v", -UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:47:7 | 45 | print("%(k)s" % {"k": "v"}) 46 | @@ -409,11 +429,11 @@ UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format 48 | | "k": "v", 49 | | "i": "j" 50 | | }) - | |_^ UP031 + | |_^ 51 | 52 | print("%(to_list)s" % {"to_list": []}) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 44 44 | @@ -431,16 +451,17 @@ UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format 52 52 | print("%(to_list)s" % {"to_list": []}) 53 53 | -UP031_0.py:52:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:52:7 | 50 | }) 51 | 52 | print("%(to_list)s" % {"to_list": []}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 53 | 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 49 49 | "i": "j" @@ -452,16 +473,17 @@ UP031_0.py:52:7: UP031 [*] Use format specifiers instead of percent format 54 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) 55 55 | -UP031_0.py:54:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:54:7 | 52 | print("%(to_list)s" % {"to_list": []}) 53 | 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | 56 | print("%(ab)s" % {"a" "b": 1}) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 51 51 | @@ -473,16 +495,17 @@ UP031_0.py:54:7: UP031 [*] Use format specifiers instead of percent format 56 56 | print("%(ab)s" % {"a" "b": 1}) 57 57 | -UP031_0.py:56:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:56:7 | 54 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) 55 | 56 | print("%(ab)s" % {"a" "b": 1}) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^ 57 | 58 | print("%(a)s" % {"a" : 1}) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 53 53 | @@ -494,14 +517,15 @@ UP031_0.py:56:7: UP031 [*] Use format specifiers instead of percent format 58 58 | print("%(a)s" % {"a" : 1}) 59 59 | -UP031_0.py:58:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:58:7 | 56 | print("%(ab)s" % {"a" "b": 1}) 57 | 58 | print("%(a)s" % {"a" : 1}) - | ^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 55 55 | @@ -513,15 +537,16 @@ UP031_0.py:58:7: UP031 [*] Use format specifiers instead of percent format 60 60 | 61 61 | print( -UP031_0.py:62:5: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:62:5 | 61 | print( 62 | / "foo %(foo)s " 63 | | "bar %(bar)s" % {"foo": x, "bar": y} - | |________________________________________^ UP031 + | |________________________________________^ 64 | ) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 59 59 | @@ -535,16 +560,17 @@ UP031_0.py:62:5: UP031 [*] Use format specifiers instead of percent format 65 65 | 66 66 | bar = {"bar": y} -UP031_0.py:68:5: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:68:5 | 66 | bar = {"bar": y} 67 | print( 68 | / "foo %(foo)s " 69 | | "bar %(bar)s" % {"foo": x, **bar} - | |_____________________________________^ UP031 + | |_____________________________________^ 70 | ) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 65 65 | @@ -558,16 +584,17 @@ UP031_0.py:68:5: UP031 [*] Use format specifiers instead of percent format 71 71 | 72 72 | print("%s \N{snowman}" % (a,)) -UP031_0.py:72:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:72:7 | 70 | ) 71 | 72 | print("%s \N{snowman}" % (a,)) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^ 73 | 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 69 69 | "bar %(bar)s" % {"foo": x, **bar} @@ -579,16 +606,17 @@ UP031_0.py:72:7: UP031 [*] Use format specifiers instead of percent format 74 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) 75 75 | -UP031_0.py:74:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:74:7 | 72 | print("%s \N{snowman}" % (a,)) 73 | 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | 76 | print(("foo %s " "bar %s") % (x, y)) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 71 71 | @@ -600,16 +628,17 @@ UP031_0.py:74:7: UP031 [*] Use format specifiers instead of percent format 76 76 | print(("foo %s " "bar %s") % (x, y)) 77 77 | -UP031_0.py:76:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:76:7 | 74 | print("%(foo)s \N{snowman}" % {"foo": 1}) 75 | 76 | print(("foo %s " "bar %s") % (x, y)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 77 | 78 | # Single-value expressions | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 73 73 | @@ -621,15 +650,16 @@ UP031_0.py:76:7: UP031 [*] Use format specifiers instead of percent format 78 78 | # Single-value expressions 79 79 | print('Hello %s' % "World") -UP031_0.py:79:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:79:7 | 78 | # Single-value expressions 79 | print('Hello %s' % "World") - | ^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^ 80 | print('Hello %s' % f"World") 81 | print('Hello %s (%s)' % bar) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 76 76 | print(("foo %s " "bar %s") % (x, y)) @@ -641,16 +671,17 @@ UP031_0.py:79:7: UP031 [*] Use format specifiers instead of percent format 81 81 | print('Hello %s (%s)' % bar) 82 82 | print('Hello %s (%s)' % bar.baz) -UP031_0.py:80:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:80:7 | 78 | # Single-value expressions 79 | print('Hello %s' % "World") 80 | print('Hello %s' % f"World") - | ^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^ 81 | print('Hello %s (%s)' % bar) 82 | print('Hello %s (%s)' % bar.baz) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 77 77 | @@ -662,16 +693,17 @@ UP031_0.py:80:7: UP031 [*] Use format specifiers instead of percent format 82 82 | print('Hello %s (%s)' % bar.baz) 83 83 | print('Hello %s (%s)' % bar['bop']) -UP031_0.py:81:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:81:7 | 79 | print('Hello %s' % "World") 80 | print('Hello %s' % f"World") 81 | print('Hello %s (%s)' % bar) - | ^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^ 82 | print('Hello %s (%s)' % bar.baz) 83 | print('Hello %s (%s)' % bar['bop']) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 78 78 | # Single-value expressions @@ -683,16 +715,17 @@ UP031_0.py:81:7: UP031 [*] Use format specifiers instead of percent format 83 83 | print('Hello %s (%s)' % bar['bop']) 84 84 | print('Hello %(arg)s' % bar) -UP031_0.py:82:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:82:7 | 80 | print('Hello %s' % f"World") 81 | print('Hello %s (%s)' % bar) 82 | print('Hello %s (%s)' % bar.baz) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 83 | print('Hello %s (%s)' % bar['bop']) 84 | print('Hello %(arg)s' % bar) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 79 79 | print('Hello %s' % "World") @@ -704,16 +737,17 @@ UP031_0.py:82:7: UP031 [*] Use format specifiers instead of percent format 84 84 | print('Hello %(arg)s' % bar) 85 85 | print('Hello %(arg)s' % bar.baz) -UP031_0.py:83:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:83:7 | 81 | print('Hello %s (%s)' % bar) 82 | print('Hello %s (%s)' % bar.baz) 83 | print('Hello %s (%s)' % bar['bop']) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | print('Hello %(arg)s' % bar) 85 | print('Hello %(arg)s' % bar.baz) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 80 80 | print('Hello %s' % f"World") @@ -725,16 +759,17 @@ UP031_0.py:83:7: UP031 [*] Use format specifiers instead of percent format 85 85 | print('Hello %(arg)s' % bar.baz) 86 86 | print('Hello %(arg)s' % bar['bop']) -UP031_0.py:84:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:84:7 | 82 | print('Hello %s (%s)' % bar.baz) 83 | print('Hello %s (%s)' % bar['bop']) 84 | print('Hello %(arg)s' % bar) - | ^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^ 85 | print('Hello %(arg)s' % bar.baz) 86 | print('Hello %(arg)s' % bar['bop']) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 81 81 | print('Hello %s (%s)' % bar) @@ -746,15 +781,16 @@ UP031_0.py:84:7: UP031 [*] Use format specifiers instead of percent format 86 86 | print('Hello %(arg)s' % bar['bop']) 87 87 | -UP031_0.py:85:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:85:7 | 83 | print('Hello %s (%s)' % bar['bop']) 84 | print('Hello %(arg)s' % bar) 85 | print('Hello %(arg)s' % bar.baz) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 86 | print('Hello %(arg)s' % bar['bop']) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 82 82 | print('Hello %s (%s)' % bar.baz) @@ -766,16 +802,17 @@ UP031_0.py:85:7: UP031 [*] Use format specifiers instead of percent format 87 87 | 88 88 | # Hanging modulos -UP031_0.py:86:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:86:7 | 84 | print('Hello %(arg)s' % bar) 85 | print('Hello %(arg)s' % bar.baz) 86 | print('Hello %(arg)s' % bar['bop']) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 | 88 | # Hanging modulos | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 83 83 | print('Hello %s (%s)' % bar['bop']) @@ -787,18 +824,19 @@ UP031_0.py:86:7: UP031 [*] Use format specifiers instead of percent format 88 88 | # Hanging modulos 89 89 | ( -UP031_0.py:89:1: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:89:1 | 88 | # Hanging modulos 89 | / ( 90 | | "foo %s " 91 | | "bar %s" 92 | | ) % (x, y) - | |__________^ UP031 + | |__________^ 93 | 94 | ( | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 87 87 | @@ -814,7 +852,8 @@ UP031_0.py:89:1: UP031 [*] Use format specifiers instead of percent format 94 94 | ( 95 95 | "foo %(foo)s " -UP031_0.py:94:1: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:94:1 | 92 | ) % (x, y) 93 | @@ -822,11 +861,11 @@ UP031_0.py:94:1: UP031 [*] Use format specifiers instead of percent format 95 | | "foo %(foo)s " 96 | | "bar %(bar)s" 97 | | ) % {"foo": x, "bar": y} - | |________________________^ UP031 + | |________________________^ 98 | 99 | ( | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 92 92 | ) % (x, y) @@ -842,15 +881,16 @@ UP031_0.py:94:1: UP031 [*] Use format specifiers instead of percent format 99 99 | ( 100 100 | """foo %s""" -UP031_0.py:100:5: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:100:5 | 99 | ( 100 | / """foo %s""" 101 | | % (x,) - | |__________^ UP031 + | |__________^ 102 | ) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 97 97 | ) % {"foo": x, "bar": y} @@ -863,17 +903,18 @@ UP031_0.py:100:5: UP031 [*] Use format specifiers instead of percent format 103 102 | 104 103 | ( -UP031_0.py:105:5: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:105:5 | 104 | ( 105 | / """ 106 | | foo %s 107 | | """ 108 | | % (x,) - | |__________^ UP031 + | |__________^ 109 | ) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 103 103 | @@ -888,16 +929,17 @@ UP031_0.py:105:5: UP031 [*] Use format specifiers instead of percent format 110 109 | 111 110 | "%s" % ( -UP031_0.py:111:1: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:111:1 | 109 | ) 110 | 111 | / "%s" % ( 112 | | x, # comment 113 | | ) - | |_^ UP031 + | |_^ | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 108 108 | % (x,) @@ -909,7 +951,8 @@ UP031_0.py:111:1: UP031 [*] Use format specifiers instead of percent format 113 113 | ) 114 114 | -UP031_0.py:116:8: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:116:8 | 116 | path = "%s-%s-%s.pem" % ( | ________^ @@ -917,11 +960,11 @@ UP031_0.py:116:8: UP031 [*] Use format specifiers instead of percent format 118 | | cert.not_valid_after.date().isoformat().replace("-", ""), # expiration date 119 | | hexlify(cert.fingerprint(hashes.SHA256())).decode("ascii")[0:8], # fingerprint prefix 120 | | ) - | |_^ UP031 + | |_^ 121 | 122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 113 113 | ) @@ -933,15 +976,16 @@ UP031_0.py:116:8: UP031 [*] Use format specifiers instead of percent format 118 118 | cert.not_valid_after.date().isoformat().replace("-", ""), # expiration date 119 119 | hexlify(cert.fingerprint(hashes.SHA256())).decode("ascii")[0:8], # fingerprint prefix -UP031_0.py:123:1: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:123:1 | 122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes) 123 | 'Hello %s' % bar - | ^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^ 124 | 125 | 'Hello %s' % bar.baz | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 120 120 | ) @@ -953,16 +997,17 @@ UP031_0.py:123:1: UP031 [*] Use format specifiers instead of percent format 125 125 | 'Hello %s' % bar.baz 126 126 | -UP031_0.py:125:1: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:125:1 | 123 | 'Hello %s' % bar 124 | 125 | 'Hello %s' % bar.baz - | ^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^ 126 | 127 | 'Hello %s' % bar['bop'] | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 122 122 | # UP031 (no longer false negatives; now offer potentially unsafe fixes) @@ -974,16 +1019,17 @@ UP031_0.py:125:1: UP031 [*] Use format specifiers instead of percent format 127 127 | 'Hello %s' % bar['bop'] 128 128 | -UP031_0.py:127:1: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:127:1 | 125 | 'Hello %s' % bar.baz 126 | 127 | 'Hello %s' % bar['bop'] - | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^^^^^^ 128 | 129 | # Not a valid type annotation but this test shouldn't result in a panic. | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 124 124 | @@ -995,16 +1041,17 @@ UP031_0.py:127:1: UP031 [*] Use format specifiers instead of percent format 129 129 | # Not a valid type annotation but this test shouldn't result in a panic. 130 130 | # Refer: https://github.com/astral-sh/ruff/issues/11736 -UP031_0.py:131:5: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:131:5 | 129 | # Not a valid type annotation but this test shouldn't result in a panic. 130 | # Refer: https://github.com/astral-sh/ruff/issues/11736 131 | x: "'%s + %s' % (1, 2)" - | ^^^^^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^^^^^ 132 | 133 | # See: https://github.com/astral-sh/ruff/issues/12421 | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 128 128 | @@ -1016,15 +1063,16 @@ UP031_0.py:131:5: UP031 [*] Use format specifiers instead of percent format 133 133 | # See: https://github.com/astral-sh/ruff/issues/12421 134 134 | print("%.2X" % 1) -UP031_0.py:134:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:134:7 | 133 | # See: https://github.com/astral-sh/ruff/issues/12421 134 | print("%.2X" % 1) - | ^^^^^^^^^^ UP031 + | ^^^^^^^^^^ 135 | print("%.02X" % 1) 136 | print("%02X" % 1) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 131 131 | x: "'%s + %s' % (1, 2)" @@ -1036,16 +1084,17 @@ UP031_0.py:134:7: UP031 [*] Use format specifiers instead of percent format 136 136 | print("%02X" % 1) 137 137 | print("%.00002X" % 1) -UP031_0.py:135:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:135:7 | 133 | # See: https://github.com/astral-sh/ruff/issues/12421 134 | print("%.2X" % 1) 135 | print("%.02X" % 1) - | ^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^ 136 | print("%02X" % 1) 137 | print("%.00002X" % 1) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 132 132 | @@ -1057,16 +1106,17 @@ UP031_0.py:135:7: UP031 [*] Use format specifiers instead of percent format 137 137 | print("%.00002X" % 1) 138 138 | print("%.20X" % 1) -UP031_0.py:136:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:136:7 | 134 | print("%.2X" % 1) 135 | print("%.02X" % 1) 136 | print("%02X" % 1) - | ^^^^^^^^^^ UP031 + | ^^^^^^^^^^ 137 | print("%.00002X" % 1) 138 | print("%.20X" % 1) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 133 133 | # See: https://github.com/astral-sh/ruff/issues/12421 @@ -1078,15 +1128,16 @@ UP031_0.py:136:7: UP031 [*] Use format specifiers instead of percent format 138 138 | print("%.20X" % 1) 139 139 | -UP031_0.py:137:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:137:7 | 135 | print("%.02X" % 1) 136 | print("%02X" % 1) 137 | print("%.00002X" % 1) - | ^^^^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^^^^ 138 | print("%.20X" % 1) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 134 134 | print("%.2X" % 1) @@ -1098,16 +1149,17 @@ UP031_0.py:137:7: UP031 [*] Use format specifiers instead of percent format 139 139 | 140 140 | print("%2X" % 1) -UP031_0.py:138:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:138:7 | 136 | print("%02X" % 1) 137 | print("%.00002X" % 1) 138 | print("%.20X" % 1) - | ^^^^^^^^^^^ UP031 + | ^^^^^^^^^^^ 139 | 140 | print("%2X" % 1) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 135 135 | print("%.02X" % 1) @@ -1119,15 +1171,16 @@ UP031_0.py:138:7: UP031 [*] Use format specifiers instead of percent format 140 140 | print("%2X" % 1) 141 141 | print("%02X" % 1) -UP031_0.py:140:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:140:7 | 138 | print("%.20X" % 1) 139 | 140 | print("%2X" % 1) - | ^^^^^^^^^ UP031 + | ^^^^^^^^^ 141 | print("%02X" % 1) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 137 137 | print("%.00002X" % 1) @@ -1139,15 +1192,16 @@ UP031_0.py:140:7: UP031 [*] Use format specifiers instead of percent format 142 142 | 143 143 | # UP031 (no longer false negatives, but offer no fix because of more complex syntax) -UP031_0.py:141:7: UP031 [*] Use format specifiers instead of percent format +UP031 [*] Use format specifiers instead of percent format + --> UP031_0.py:141:7 | 140 | print("%2X" % 1) 141 | print("%02X" % 1) - | ^^^^^^^^^^ UP031 + | ^^^^^^^^^^ 142 | 143 | # UP031 (no longer false negatives, but offer no fix because of more complex syntax) | - = help: Replace with format specifiers +help: Replace with format specifiers ℹ Unsafe fix 138 138 | print("%.20X" % 1) @@ -1159,154 +1213,168 @@ UP031_0.py:141:7: UP031 [*] Use format specifiers instead of percent format 143 143 | # UP031 (no longer false negatives, but offer no fix because of more complex syntax) 144 144 | -UP031_0.py:145:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:145:1 | 143 | # UP031 (no longer false negatives, but offer no fix because of more complex syntax) 144 | 145 | "%d.%d" % (a, b) - | ^^^^^^^ UP031 + | ^^^^^^^ 146 | 147 | "%*s" % (5, "hi") | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:147:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:147:1 | 145 | "%d.%d" % (a, b) 146 | 147 | "%*s" % (5, "hi") - | ^^^^^ UP031 + | ^^^^^ 148 | 149 | "%d" % (flt,) | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:149:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:149:1 | 147 | "%*s" % (5, "hi") 148 | 149 | "%d" % (flt,) - | ^^^^ UP031 + | ^^^^ 150 | 151 | "%c" % (some_string,) | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:151:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:151:1 | 149 | "%d" % (flt,) 150 | 151 | "%c" % (some_string,) - | ^^^^ UP031 + | ^^^^ 152 | 153 | "%.2r" % (1.25) | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:153:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:153:1 | 151 | "%c" % (some_string,) 152 | 153 | "%.2r" % (1.25) - | ^^^^^^ UP031 + | ^^^^^^ 154 | 155 | "%.*s" % (5, "hi") | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:155:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:155:1 | 153 | "%.2r" % (1.25) 154 | 155 | "%.*s" % (5, "hi") - | ^^^^^^ UP031 + | ^^^^^^ 156 | 157 | "%i" % (flt,) | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:157:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:157:1 | 155 | "%.*s" % (5, "hi") 156 | 157 | "%i" % (flt,) - | ^^^^ UP031 + | ^^^^ 158 | 159 | "%()s" % {"": "empty"} | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:159:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:159:1 | 157 | "%i" % (flt,) 158 | 159 | "%()s" % {"": "empty"} - | ^^^^^^ UP031 + | ^^^^^^ 160 | 161 | "%s" % {"k": "v"} | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:161:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:161:1 | 159 | "%()s" % {"": "empty"} 160 | 161 | "%s" % {"k": "v"} - | ^^^^ UP031 + | ^^^^ 162 | 163 | "%()s" % {"": "bar"} | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:163:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:163:1 | 161 | "%s" % {"k": "v"} 162 | 163 | "%()s" % {"": "bar"} - | ^^^^^^ UP031 + | ^^^^^^ 164 | 165 | "%(1)s" % {"1": "bar"} | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:165:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:165:1 | 163 | "%()s" % {"": "bar"} 164 | 165 | "%(1)s" % {"1": "bar"} - | ^^^^^^^ UP031 + | ^^^^^^^ 166 | 167 | "%(a)s" % {"a": 1, "a": 2} | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:167:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:167:1 | 165 | "%(1)s" % {"1": "bar"} 166 | 167 | "%(a)s" % {"a": 1, "a": 2} - | ^^^^^^^ UP031 + | ^^^^^^^ 168 | 169 | "%(1)s" % {1: 2, "1": 2} | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:169:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:169:1 | 167 | "%(a)s" % {"a": 1, "a": 2} 168 | 169 | "%(1)s" % {1: 2, "1": 2} - | ^^^^^^^ UP031 + | ^^^^^^^ 170 | 171 | "%(and)s" % {"and": 2} | - = help: Replace with format specifiers +help: Replace with format specifiers -UP031_0.py:171:1: UP031 Use format specifiers instead of percent format +UP031 Use format specifiers instead of percent format + --> UP031_0.py:171:1 | 169 | "%(1)s" % {1: 2, "1": 2} 170 | 171 | "%(and)s" % {"and": 2} - | ^^^^^^^^^ UP031 + | ^^^^^^^^^ | - = help: Replace with format specifiers +help: Replace with format specifiers diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap index 51bd88cd7f..19c78a643d 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP032_0.py:5:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:5:1 | 3 | ### 4 | 5 | "{} {}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^ 6 | 7 | "{1} {0}".format(a, b) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 2 2 | # Errors @@ -22,16 +23,17 @@ UP032_0.py:5:1: UP032 [*] Use f-string instead of `format` call 7 7 | "{1} {0}".format(a, b) 8 8 | -UP032_0.py:7:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:7:1 | 5 | "{} {}".format(a, b) 6 | 7 | "{1} {0}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | "{0} {1} {0}".format(a, b) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 4 4 | @@ -43,16 +45,17 @@ UP032_0.py:7:1: UP032 [*] Use f-string instead of `format` call 9 9 | "{0} {1} {0}".format(a, b) 10 10 | -UP032_0.py:9:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:9:1 | 7 | "{1} {0}".format(a, b) 8 | 9 | "{0} {1} {0}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | "{x.y}".format(x=z) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 6 6 | @@ -64,16 +67,17 @@ UP032_0.py:9:1: UP032 [*] Use f-string instead of `format` call 11 11 | "{x.y}".format(x=z) 12 12 | -UP032_0.py:11:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:11:1 | 9 | "{0} {1} {0}".format(a, b) 10 | 11 | "{x.y}".format(x=z) - | ^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^ 12 | 13 | "{x} {y} {x}".format(x=a, y=b) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 8 8 | @@ -85,16 +89,17 @@ UP032_0.py:11:1: UP032 [*] Use f-string instead of `format` call 13 13 | "{x} {y} {x}".format(x=a, y=b) 14 14 | -UP032_0.py:13:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:13:1 | 11 | "{x.y}".format(x=z) 12 | 13 | "{x} {y} {x}".format(x=a, y=b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | "{.x} {.y}".format(a, b) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 10 10 | @@ -106,16 +111,17 @@ UP032_0.py:13:1: UP032 [*] Use f-string instead of `format` call 15 15 | "{.x} {.y}".format(a, b) 16 16 | -UP032_0.py:15:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:15:1 | 13 | "{x} {y} {x}".format(x=a, y=b) 14 | 15 | "{.x} {.y}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | "{} {}".format(a.b, c.d) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 12 12 | @@ -127,16 +133,17 @@ UP032_0.py:15:1: UP032 [*] Use f-string instead of `format` call 17 17 | "{} {}".format(a.b, c.d) 18 18 | -UP032_0.py:17:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:17:1 | 15 | "{.x} {.y}".format(a, b) 16 | 17 | "{} {}".format(a.b, c.d) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | "{}".format(a()) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 14 14 | @@ -148,16 +155,17 @@ UP032_0.py:17:1: UP032 [*] Use f-string instead of `format` call 19 19 | "{}".format(a()) 20 20 | -UP032_0.py:19:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:19:1 | 17 | "{} {}".format(a.b, c.d) 18 | 19 | "{}".format(a()) - | ^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^ 20 | 21 | "{}".format(a.b()) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 16 16 | @@ -169,16 +177,17 @@ UP032_0.py:19:1: UP032 [*] Use f-string instead of `format` call 21 21 | "{}".format(a.b()) 22 22 | -UP032_0.py:21:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:21:1 | 19 | "{}".format(a()) 20 | 21 | "{}".format(a.b()) - | ^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^ 22 | 23 | "{}".format(a.b().c()) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 18 18 | @@ -190,16 +199,17 @@ UP032_0.py:21:1: UP032 [*] Use f-string instead of `format` call 23 23 | "{}".format(a.b().c()) 24 24 | -UP032_0.py:23:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:23:1 | 21 | "{}".format(a.b()) 22 | 23 | "{}".format(a.b().c()) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^ 24 | 25 | "hello {}!".format(name) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 20 20 | @@ -211,16 +221,17 @@ UP032_0.py:23:1: UP032 [*] Use f-string instead of `format` call 25 25 | "hello {}!".format(name) 26 26 | -UP032_0.py:25:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:25:1 | 23 | "{}".format(a.b().c()) 24 | 25 | "hello {}!".format(name) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | "{}{b}{}".format(a, c, b=b) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 22 22 | @@ -232,16 +243,17 @@ UP032_0.py:25:1: UP032 [*] Use f-string instead of `format` call 27 27 | "{}{b}{}".format(a, c, b=b) 28 28 | -UP032_0.py:27:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:27:1 | 25 | "hello {}!".format(name) 26 | 27 | "{}{b}{}".format(a, c, b=b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | "{}".format(0x0) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 24 24 | @@ -253,16 +265,17 @@ UP032_0.py:27:1: UP032 [*] Use f-string instead of `format` call 29 29 | "{}".format(0x0) 30 30 | -UP032_0.py:29:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:29:1 | 27 | "{}{b}{}".format(a, c, b=b) 28 | 29 | "{}".format(0x0) - | ^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^ 30 | 31 | "{} {}".format(a, b) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 26 26 | @@ -274,16 +287,17 @@ UP032_0.py:29:1: UP032 [*] Use f-string instead of `format` call 31 31 | "{} {}".format(a, b) 32 32 | -UP032_0.py:31:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:31:1 | 29 | "{}".format(0x0) 30 | 31 | "{} {}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^ 32 | 33 | """{} {}""".format(a, b) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 28 28 | @@ -295,16 +309,17 @@ UP032_0.py:31:1: UP032 [*] Use f-string instead of `format` call 33 33 | """{} {}""".format(a, b) 34 34 | -UP032_0.py:33:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:33:1 | 31 | "{} {}".format(a, b) 32 | 33 | """{} {}""".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 34 | 35 | "foo{}".format(1) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 30 30 | @@ -316,16 +331,17 @@ UP032_0.py:33:1: UP032 [*] Use f-string instead of `format` call 35 35 | "foo{}".format(1) 36 36 | -UP032_0.py:35:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:35:1 | 33 | """{} {}""".format(a, b) 34 | 35 | "foo{}".format(1) - | ^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^ 36 | 37 | r"foo{}".format(1) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 32 32 | @@ -337,16 +353,17 @@ UP032_0.py:35:1: UP032 [*] Use f-string instead of `format` call 37 37 | r"foo{}".format(1) 38 38 | -UP032_0.py:37:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:37:1 | 35 | "foo{}".format(1) 36 | 37 | r"foo{}".format(1) - | ^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^ 38 | 39 | x = "{a}".format(a=1) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 34 34 | @@ -358,16 +375,17 @@ UP032_0.py:37:1: UP032 [*] Use f-string instead of `format` call 39 39 | x = "{a}".format(a=1) 40 40 | -UP032_0.py:39:5: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:39:5 | 37 | r"foo{}".format(1) 38 | 39 | x = "{a}".format(a=1) - | ^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^ 40 | 41 | print("foo {} ".format(x)) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 36 36 | @@ -379,16 +397,17 @@ UP032_0.py:39:5: UP032 [*] Use f-string instead of `format` call 41 41 | print("foo {} ".format(x)) 42 42 | -UP032_0.py:41:7: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:41:7 | 39 | x = "{a}".format(a=1) 40 | 41 | print("foo {} ".format(x)) - | ^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^ 42 | 43 | "{a[b]}".format(a=a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 38 38 | @@ -400,16 +419,17 @@ UP032_0.py:41:7: UP032 [*] Use f-string instead of `format` call 43 43 | "{a[b]}".format(a=a) 44 44 | -UP032_0.py:43:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:43:1 | 41 | print("foo {} ".format(x)) 42 | 43 | "{a[b]}".format(a=a) - | ^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^ 44 | 45 | "{a.a[b]}".format(a=a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 40 40 | @@ -421,16 +441,17 @@ UP032_0.py:43:1: UP032 [*] Use f-string instead of `format` call 45 45 | "{a.a[b]}".format(a=a) 46 46 | -UP032_0.py:45:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:45:1 | 43 | "{a[b]}".format(a=a) 44 | 45 | "{a.a[b]}".format(a=a) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^ 46 | 47 | "{}{{}}{}".format(escaped, y) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 42 42 | @@ -442,16 +463,17 @@ UP032_0.py:45:1: UP032 [*] Use f-string instead of `format` call 47 47 | "{}{{}}{}".format(escaped, y) 48 48 | -UP032_0.py:47:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:47:1 | 45 | "{a.a[b]}".format(a=a) 46 | 47 | "{}{{}}{}".format(escaped, y) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | 49 | "{}".format(a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 44 44 | @@ -463,16 +485,17 @@ UP032_0.py:47:1: UP032 [*] Use f-string instead of `format` call 49 49 | "{}".format(a) 50 50 | -UP032_0.py:49:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:49:1 | 47 | "{}{{}}{}".format(escaped, y) 48 | 49 | "{}".format(a) - | ^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^ 50 | 51 | '({}={{0!e}})'.format(a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 46 46 | @@ -484,16 +507,17 @@ UP032_0.py:49:1: UP032 [*] Use f-string instead of `format` call 51 51 | '({}={{0!e}})'.format(a) 52 52 | -UP032_0.py:51:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:51:1 | 49 | "{}".format(a) 50 | 51 | '({}={{0!e}})'.format(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 52 | 53 | "{[b]}".format(a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 48 48 | @@ -505,16 +529,17 @@ UP032_0.py:51:1: UP032 [*] Use f-string instead of `format` call 53 53 | "{[b]}".format(a) 54 54 | -UP032_0.py:53:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:53:1 | 51 | '({}={{0!e}})'.format(a) 52 | 53 | "{[b]}".format(a) - | ^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^ 54 | 55 | '{[b]}'.format(a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 50 50 | @@ -526,16 +551,17 @@ UP032_0.py:53:1: UP032 [*] Use f-string instead of `format` call 55 55 | '{[b]}'.format(a) 56 56 | -UP032_0.py:55:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:55:1 | 53 | "{[b]}".format(a) 54 | 55 | '{[b]}'.format(a) - | ^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^ 56 | 57 | """{[b]}""".format(a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 52 52 | @@ -547,16 +573,17 @@ UP032_0.py:55:1: UP032 [*] Use f-string instead of `format` call 57 57 | """{[b]}""".format(a) 58 58 | -UP032_0.py:57:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:57:1 | 55 | '{[b]}'.format(a) 56 | 57 | """{[b]}""".format(a) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^ 58 | 59 | '''{[b]}'''.format(a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 54 54 | @@ -568,16 +595,17 @@ UP032_0.py:57:1: UP032 [*] Use f-string instead of `format` call 59 59 | '''{[b]}'''.format(a) 60 60 | -UP032_0.py:59:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:59:1 | 57 | """{[b]}""".format(a) 58 | 59 | '''{[b]}'''.format(a) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^ 60 | 61 | "{}".format( | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 56 56 | @@ -589,18 +617,19 @@ UP032_0.py:59:1: UP032 [*] Use f-string instead of `format` call 61 61 | "{}".format( 62 62 | 1 -UP032_0.py:61:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:61:1 | 59 | '''{[b]}'''.format(a) 60 | 61 | / "{}".format( 62 | | 1 63 | | ) - | |_^ UP032 + | |_^ 64 | 65 | "123456789 {}".format( | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 58 58 | @@ -614,18 +643,19 @@ UP032_0.py:61:1: UP032 [*] Use f-string instead of `format` call 65 63 | "123456789 {}".format( 66 64 | 1111111111111111111111111111111111111111111111111111111111111111111111111, -UP032_0.py:65:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:65:1 | 63 | ) 64 | 65 | / "123456789 {}".format( 66 | | 1111111111111111111111111111111111111111111111111111111111111111111111111, 67 | | ) - | |_^ UP032 + | |_^ 68 | 69 | """ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 62 62 | 1 @@ -639,18 +669,19 @@ UP032_0.py:65:1: UP032 [*] Use f-string instead of `format` call 69 67 | """ 70 68 | {} -UP032_0.py:69:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:69:1 | 67 | ) 68 | 69 | / """ 70 | | {} 71 | | """.format(1) - | |_____________^ UP032 + | |_____________^ 72 | 73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 66 66 | 1111111111111111111111111111111111111111111111111111111111111111111111111, @@ -665,7 +696,8 @@ UP032_0.py:69:1: UP032 [*] Use f-string instead of `format` call 73 73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ 74 74 | {} -UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:73:85 | 71 | """.format(1) 72 | @@ -675,11 +707,11 @@ UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call 75 | | """.format( 76 | | 111111 77 | | ) - | |_^ UP032 + | |_^ 78 | 79 | "{a}" "{b}".format(a=1, b=1) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 70 70 | {} @@ -697,16 +729,17 @@ UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call 79 77 | "{a}" "{b}".format(a=1, b=1) 80 78 | -UP032_0.py:79:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:79:1 | 77 | ) 78 | 79 | "{a}" "{b}".format(a=1, b=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 80 | 81 | ( | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 76 76 | 111111 @@ -718,7 +751,8 @@ UP032_0.py:79:1: UP032 [*] Use f-string instead of `format` call 81 81 | ( 82 82 | "{a}" -UP032_0.py:81:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:81:1 | 79 | "{a}" "{b}".format(a=1, b=1) 80 | @@ -726,11 +760,11 @@ UP032_0.py:81:1: UP032 [*] Use f-string instead of `format` call 82 | | "{a}" 83 | | "{b}" 84 | | ).format(a=1, b=1) - | |__________________^ UP032 + | |__________________^ 85 | 86 | ( | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 79 79 | "{a}" "{b}".format(a=1, b=1) @@ -746,7 +780,8 @@ UP032_0.py:81:1: UP032 [*] Use f-string instead of `format` call 86 86 | ( 87 87 | "{a}" -UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:86:1 | 84 | ).format(a=1, b=1) 85 | @@ -756,11 +791,11 @@ UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call 89 | | "{b}" 90 | | "" 91 | | ).format(a=1, b=1) - | |__________________^ UP032 + | |__________________^ 92 | 93 | ( | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 84 84 | ).format(a=1, b=1) @@ -778,7 +813,8 @@ UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call 93 91 | ( 94 92 | ( -UP032_0.py:94:5: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:94:5 | 93 | ( 94 | / ( @@ -789,10 +825,10 @@ UP032_0.py:94:5: UP032 [*] Use f-string instead of `format` call 99 | | ) 100 | | # comment 101 | | .format(a=1, b=1) - | |_____________________^ UP032 + | |_____________________^ 102 | ) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 93 93 | ( @@ -811,7 +847,8 @@ UP032_0.py:94:5: UP032 [*] Use f-string instead of `format` call 103 103 | 104 104 | ( -UP032_0.py:104:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:104:1 | 102 | ) 103 | @@ -819,9 +856,9 @@ UP032_0.py:104:1: UP032 [*] Use f-string instead of `format` call 105 | | "{a}" 106 | | "b" 107 | | ).format(a=1) - | |_____________^ UP032 + | |_____________^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 102 102 | ) @@ -836,13 +873,14 @@ UP032_0.py:104:1: UP032 [*] Use f-string instead of `format` call 109 109 | 110 110 | def d(osname, version, release): -UP032_0.py:111:11: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:111:11 | 110 | def d(osname, version, release): 111 | return"{}-{}.{}".format(osname, version, release) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 108 108 | @@ -854,13 +892,14 @@ UP032_0.py:111:11: UP032 [*] Use f-string instead of `format` call 113 113 | 114 114 | def e(): -UP032_0.py:115:10: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:115:10 | 114 | def e(): 115 | yield"{}".format(1) - | ^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 112 112 | @@ -872,12 +911,13 @@ UP032_0.py:115:10: UP032 [*] Use f-string instead of `format` call 117 117 | 118 118 | assert"{}".format(1) -UP032_0.py:118:7: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:118:7 | 118 | assert"{}".format(1) - | ^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 115 115 | yield"{}".format(1) @@ -889,13 +929,14 @@ UP032_0.py:118:7: UP032 [*] Use f-string instead of `format` call 120 120 | 121 121 | async def c(): -UP032_0.py:122:12: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:122:12 | 121 | async def c(): 122 | return "{}".format(await 3) - | ^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 119 119 | @@ -907,13 +948,14 @@ UP032_0.py:122:12: UP032 [*] Use f-string instead of `format` call 124 124 | 125 125 | async def c(): -UP032_0.py:126:12: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:126:12 | 125 | async def c(): 126 | return "{}".format(1 + await 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 123 123 | @@ -925,14 +967,15 @@ UP032_0.py:126:12: UP032 [*] Use f-string instead of `format` call 128 128 | 129 129 | "{}".format(1 * 2) -UP032_0.py:129:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:129:1 | 129 | "{}".format(1 * 2) - | ^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^ 130 | 131 | ### | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 126 126 | return "{}".format(1 + await 3) @@ -944,18 +987,19 @@ UP032_0.py:129:1: UP032 [*] Use f-string instead of `format` call 131 131 | ### 132 132 | # Non-errors -UP032_0.py:160:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:160:1 | 158 | r'"\N{snowman} {}".format(a)' 159 | 160 | / "123456789 {}".format( 161 | | 11111111111111111111111111111111111111111111111111111111111111111111111111, 162 | | ) - | |_^ UP032 + | |_^ 163 | 164 | """ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 157 157 | @@ -969,7 +1013,8 @@ UP032_0.py:160:1: UP032 [*] Use f-string instead of `format` call 164 162 | """ 165 163 | {} -UP032_0.py:164:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:164:1 | 162 | ) 163 | @@ -982,11 +1027,11 @@ UP032_0.py:164:1: UP032 [*] Use f-string instead of `format` call 170 | | 2, 171 | | 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111, 172 | | ) - | |_^ UP032 + | |_^ 173 | 174 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """{} | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 161 161 | 11111111111111111111111111111111111111111111111111111111111111111111111111, @@ -1009,7 +1054,8 @@ UP032_0.py:164:1: UP032 [*] Use f-string instead of `format` call 174 170 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """{} 175 171 | """.format( -UP032_0.py:174:84: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:174:84 | 172 | ) 173 | @@ -1018,11 +1064,11 @@ UP032_0.py:174:84: UP032 [*] Use f-string instead of `format` call 175 | | """.format( 176 | | 111111 177 | | ) - | |_^ UP032 + | |_^ 178 | 179 | "{}".format( | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 171 171 | 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111, @@ -1038,27 +1084,29 @@ UP032_0.py:174:84: UP032 [*] Use f-string instead of `format` call 179 177 | "{}".format( 180 178 | [ -UP032_0.py:202:1: UP032 Use f-string instead of `format` call +UP032 Use f-string instead of `format` call + --> UP032_0.py:202:1 | 200 | "{}".format(**c) 201 | 202 | / "{}".format( 203 | | 1 # comment 204 | | ) - | |_^ UP032 + | |_^ | - = help: Convert to f-string +help: Convert to f-string -UP032_0.py:209:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:209:1 | 207 | # The fixed string will exceed the line length, but it's still smaller than the 208 | # existing line length, so it's fine. 209 | "".format(self.internal_ids, self.external_ids, self.properties, self.tags, self.others) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 210 | 211 | # When fixing, trim the trailing empty string. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 206 206 | @@ -1070,17 +1118,18 @@ UP032_0.py:209:1: UP032 [*] Use f-string instead of `format` call 211 211 | # When fixing, trim the trailing empty string. 212 212 | raise ValueError("Conflicting configuration dicts: {!r} {!r}" -UP032_0.py:212:18: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:212:18 | 211 | # When fixing, trim the trailing empty string. 212 | raise ValueError("Conflicting configuration dicts: {!r} {!r}" | __________________^ 213 | | "".format(new_dict, d)) - | |_______________________________________^ UP032 + | |_______________________________________^ 214 | 215 | # When fixing, trim the trailing empty string. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 209 209 | "".format(self.internal_ids, self.external_ids, self.properties, self.tags, self.others) @@ -1093,17 +1142,18 @@ UP032_0.py:212:18: UP032 [*] Use f-string instead of `format` call 215 214 | # When fixing, trim the trailing empty string. 216 215 | raise ValueError("Conflicting configuration dicts: {!r} {!r}" -UP032_0.py:216:18: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:216:18 | 215 | # When fixing, trim the trailing empty string. 216 | raise ValueError("Conflicting configuration dicts: {!r} {!r}" | __________________^ 217 | | .format(new_dict, d)) - | |_____________________________________^ UP032 + | |_____________________________________^ 218 | 219 | raise ValueError( | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 213 213 | "".format(new_dict, d)) @@ -1117,15 +1167,16 @@ UP032_0.py:216:18: UP032 [*] Use f-string instead of `format` call 219 219 | raise ValueError( 220 220 | "Conflicting configuration dicts: {!r} {!r}" -UP032_0.py:220:5: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:220:5 | 219 | raise ValueError( 220 | / "Conflicting configuration dicts: {!r} {!r}" 221 | | "".format(new_dict, d) - | |__________________________^ UP032 + | |__________________________^ 222 | ) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 217 217 | .format(new_dict, d)) @@ -1138,16 +1189,17 @@ UP032_0.py:220:5: UP032 [*] Use f-string instead of `format` call 223 222 | 224 223 | raise ValueError( -UP032_0.py:225:5: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:225:5 | 224 | raise ValueError( 225 | / "Conflicting configuration dicts: {!r} {!r}" 226 | | "".format(new_dict, d) - | |__________________________^ UP032 + | |__________________________^ 227 | 228 | ) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 222 222 | ) @@ -1160,18 +1212,19 @@ UP032_0.py:225:5: UP032 [*] Use f-string instead of `format` call 228 227 | ) 229 228 | -UP032_0.py:231:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:231:1 | 230 | # The first string will be converted to an f-string and the curly braces in the second should be converted to be unescaped 231 | / ( 232 | | "{}" 233 | | "{{}}" 234 | | ).format(a) - | |___________^ UP032 + | |___________^ 235 | 236 | ("{}" "{{}}").format(a) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 229 229 | @@ -1186,14 +1239,15 @@ UP032_0.py:231:1: UP032 [*] Use f-string instead of `format` call 236 236 | ("{}" "{{}}").format(a) 237 237 | -UP032_0.py:236:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:236:1 | 234 | ).format(a) 235 | 236 | ("{}" "{{}}").format(a) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 233 233 | "{{}}" @@ -1205,18 +1259,19 @@ UP032_0.py:236:1: UP032 [*] Use f-string instead of `format` call 238 238 | 239 239 | # Both strings will be converted to an f-string and the curly braces in the second should left escaped -UP032_0.py:240:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:240:1 | 239 | # Both strings will be converted to an f-string and the curly braces in the second should left escaped 240 | / ( 241 | | "{}" 242 | | "{{{}}}" 243 | | ).format(a, b) - | |______________^ UP032 + | |______________^ 244 | 245 | ("{}" "{{{}}}").format(a, b) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 238 238 | @@ -1232,16 +1287,17 @@ UP032_0.py:240:1: UP032 [*] Use f-string instead of `format` call 245 245 | ("{}" "{{{}}}").format(a, b) 246 246 | -UP032_0.py:245:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:245:1 | 243 | ).format(a, b) 244 | 245 | ("{}" "{{{}}}").format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 246 | 247 | # The dictionary should be parenthesized. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 242 242 | "{{{}}}" @@ -1253,15 +1309,16 @@ UP032_0.py:245:1: UP032 [*] Use f-string instead of `format` call 247 247 | # The dictionary should be parenthesized. 248 248 | "{}".format({0: 1}[0]) -UP032_0.py:248:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:248:1 | 247 | # The dictionary should be parenthesized. 248 | "{}".format({0: 1}[0]) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^ 249 | 250 | # The dictionary should be parenthesized. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 245 245 | ("{}" "{{{}}}").format(a, b) @@ -1273,15 +1330,16 @@ UP032_0.py:248:1: UP032 [*] Use f-string instead of `format` call 250 250 | # The dictionary should be parenthesized. 251 251 | "{}".format({0: 1}.bar) -UP032_0.py:251:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:251:1 | 250 | # The dictionary should be parenthesized. 251 | "{}".format({0: 1}.bar) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^ 252 | 253 | # The dictionary should be parenthesized. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 248 248 | "{}".format({0: 1}[0]) @@ -1293,15 +1351,16 @@ UP032_0.py:251:1: UP032 [*] Use f-string instead of `format` call 253 253 | # The dictionary should be parenthesized. 254 254 | "{}".format({0: 1}()) -UP032_0.py:254:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:254:1 | 253 | # The dictionary should be parenthesized. 254 | "{}".format({0: 1}()) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^ 255 | 256 | # The string shouldn't be converted, since it would require repeating the function call. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 251 251 | "{}".format({0: 1}.bar) @@ -1313,15 +1372,16 @@ UP032_0.py:254:1: UP032 [*] Use f-string instead of `format` call 256 256 | # The string shouldn't be converted, since it would require repeating the function call. 257 257 | "{x} {x}".format(x=foo()) -UP032_0.py:261:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:261:1 | 260 | # The string _should_ be converted, since the function call is repeated in the arguments. 261 | "{0} {1}".format(foo(), foo()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 262 | 263 | # The call should be removed, but the string itself should remain. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 258 258 | "{0} {0}".format(foo()) @@ -1333,15 +1393,16 @@ UP032_0.py:261:1: UP032 [*] Use f-string instead of `format` call 263 263 | # The call should be removed, but the string itself should remain. 264 264 | ''.format(self.project) -UP032_0.py:264:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:264:1 | 263 | # The call should be removed, but the string itself should remain. 264 | ''.format(self.project) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^ 265 | 266 | # The call should be removed, but the string itself should remain. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 261 261 | "{0} {1}".format(foo(), foo()) @@ -1353,15 +1414,16 @@ UP032_0.py:264:1: UP032 [*] Use f-string instead of `format` call 266 266 | # The call should be removed, but the string itself should remain. 267 267 | "".format(self.project) -UP032_0.py:267:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:267:1 | 266 | # The call should be removed, but the string itself should remain. 267 | "".format(self.project) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^ 268 | 269 | # Not a valid type annotation but this test shouldn't result in a panic. | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 264 264 | ''.format(self.project) @@ -1373,14 +1435,15 @@ UP032_0.py:267:1: UP032 [*] Use f-string instead of `format` call 269 269 | # Not a valid type annotation but this test shouldn't result in a panic. 270 270 | # Refer: https://github.com/astral-sh/ruff/issues/11736 -UP032_0.py:271:5: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_0.py:271:5 | 269 | # Not a valid type annotation but this test shouldn't result in a panic. 270 | # Refer: https://github.com/astral-sh/ruff/issues/11736 271 | x: "'{} + {}'.format(x, y)" - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 268 268 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap index dbb0955b48..705d8d2492 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP032_1.py:1:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_1.py:1:1 | 1 | "{} {}".format(a, b) # Intentionally at start-of-file, to ensure graceful handling. - | ^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 1 |-"{} {}".format(a, b) # Intentionally at start-of-file, to ensure graceful handling. diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap index 2789248a3c..b104d2bb3f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP032_2.py:2:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:2:1 | 1 | # Errors 2 | "{.real}".format(1) - | ^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^ 3 | "{0.real}".format(1) 4 | "{a.real}".format(a=1) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 1 1 | # Errors @@ -19,15 +20,16 @@ UP032_2.py:2:1: UP032 [*] Use f-string instead of `format` call 4 4 | "{a.real}".format(a=1) 5 5 | -UP032_2.py:3:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:3:1 | 1 | # Errors 2 | "{.real}".format(1) 3 | "{0.real}".format(1) - | ^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^ 4 | "{a.real}".format(a=1) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 1 1 | # Errors @@ -38,16 +40,17 @@ UP032_2.py:3:1: UP032 [*] Use f-string instead of `format` call 5 5 | 6 6 | "{.real}".format(1.0) -UP032_2.py:4:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:4:1 | 2 | "{.real}".format(1) 3 | "{0.real}".format(1) 4 | "{a.real}".format(a=1) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | "{.real}".format(1.0) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 1 1 | # Errors @@ -59,16 +62,17 @@ UP032_2.py:4:1: UP032 [*] Use f-string instead of `format` call 6 6 | "{.real}".format(1.0) 7 7 | "{0.real}".format(1.0) -UP032_2.py:6:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:6:1 | 4 | "{a.real}".format(a=1) 5 | 6 | "{.real}".format(1.0) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^ 7 | "{0.real}".format(1.0) 8 | "{a.real}".format(a=1.0) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 3 3 | "{0.real}".format(1) @@ -80,14 +84,15 @@ UP032_2.py:6:1: UP032 [*] Use f-string instead of `format` call 8 8 | "{a.real}".format(a=1.0) 9 9 | -UP032_2.py:7:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:7:1 | 6 | "{.real}".format(1.0) 7 | "{0.real}".format(1.0) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^ 8 | "{a.real}".format(a=1.0) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 4 4 | "{a.real}".format(a=1) @@ -99,16 +104,17 @@ UP032_2.py:7:1: UP032 [*] Use f-string instead of `format` call 9 9 | 10 10 | "{.real}".format(1j) -UP032_2.py:8:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:8:1 | 6 | "{.real}".format(1.0) 7 | "{0.real}".format(1.0) 8 | "{a.real}".format(a=1.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | "{.real}".format(1j) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 5 5 | @@ -120,16 +126,17 @@ UP032_2.py:8:1: UP032 [*] Use f-string instead of `format` call 10 10 | "{.real}".format(1j) 11 11 | "{0.real}".format(1j) -UP032_2.py:10:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:10:1 | 8 | "{a.real}".format(a=1.0) 9 | 10 | "{.real}".format(1j) - | ^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^ 11 | "{0.real}".format(1j) 12 | "{a.real}".format(a=1j) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 7 7 | "{0.real}".format(1.0) @@ -141,14 +148,15 @@ UP032_2.py:10:1: UP032 [*] Use f-string instead of `format` call 12 12 | "{a.real}".format(a=1j) 13 13 | -UP032_2.py:11:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:11:1 | 10 | "{.real}".format(1j) 11 | "{0.real}".format(1j) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^ 12 | "{a.real}".format(a=1j) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 8 8 | "{a.real}".format(a=1.0) @@ -160,16 +168,17 @@ UP032_2.py:11:1: UP032 [*] Use f-string instead of `format` call 13 13 | 14 14 | "{.real}".format(0b01) -UP032_2.py:12:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:12:1 | 10 | "{.real}".format(1j) 11 | "{0.real}".format(1j) 12 | "{a.real}".format(a=1j) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | "{.real}".format(0b01) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 9 9 | @@ -181,16 +190,17 @@ UP032_2.py:12:1: UP032 [*] Use f-string instead of `format` call 14 14 | "{.real}".format(0b01) 15 15 | "{0.real}".format(0b01) -UP032_2.py:14:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:14:1 | 12 | "{a.real}".format(a=1j) 13 | 14 | "{.real}".format(0b01) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^ 15 | "{0.real}".format(0b01) 16 | "{a.real}".format(a=0b01) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 11 11 | "{0.real}".format(1j) @@ -202,14 +212,15 @@ UP032_2.py:14:1: UP032 [*] Use f-string instead of `format` call 16 16 | "{a.real}".format(a=0b01) 17 17 | -UP032_2.py:15:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:15:1 | 14 | "{.real}".format(0b01) 15 | "{0.real}".format(0b01) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^ 16 | "{a.real}".format(a=0b01) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 12 12 | "{a.real}".format(a=1j) @@ -221,16 +232,17 @@ UP032_2.py:15:1: UP032 [*] Use f-string instead of `format` call 17 17 | 18 18 | "{}".format(1 + 2) -UP032_2.py:16:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:16:1 | 14 | "{.real}".format(0b01) 15 | "{0.real}".format(0b01) 16 | "{a.real}".format(a=0b01) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | "{}".format(1 + 2) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 13 13 | @@ -242,16 +254,17 @@ UP032_2.py:16:1: UP032 [*] Use f-string instead of `format` call 18 18 | "{}".format(1 + 2) 19 19 | "{}".format([1, 2]) -UP032_2.py:18:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:18:1 | 16 | "{a.real}".format(a=0b01) 17 | 18 | "{}".format(1 + 2) - | ^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^ 19 | "{}".format([1, 2]) 20 | "{}".format({1, 2}) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 15 15 | "{0.real}".format(0b01) @@ -263,15 +276,16 @@ UP032_2.py:18:1: UP032 [*] Use f-string instead of `format` call 20 20 | "{}".format({1, 2}) 21 21 | "{}".format({1: 2, 3: 4}) -UP032_2.py:19:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:19:1 | 18 | "{}".format(1 + 2) 19 | "{}".format([1, 2]) - | ^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^ 20 | "{}".format({1, 2}) 21 | "{}".format({1: 2, 3: 4}) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 16 16 | "{a.real}".format(a=0b01) @@ -283,16 +297,17 @@ UP032_2.py:19:1: UP032 [*] Use f-string instead of `format` call 21 21 | "{}".format({1: 2, 3: 4}) 22 22 | "{}".format((i for i in range(2))) -UP032_2.py:20:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:20:1 | 18 | "{}".format(1 + 2) 19 | "{}".format([1, 2]) 20 | "{}".format({1, 2}) - | ^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^ 21 | "{}".format({1: 2, 3: 4}) 22 | "{}".format((i for i in range(2))) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 17 17 | @@ -304,15 +319,16 @@ UP032_2.py:20:1: UP032 [*] Use f-string instead of `format` call 22 22 | "{}".format((i for i in range(2))) 23 23 | -UP032_2.py:21:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:21:1 | 19 | "{}".format([1, 2]) 20 | "{}".format({1, 2}) 21 | "{}".format({1: 2, 3: 4}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | "{}".format((i for i in range(2))) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 18 18 | "{}".format(1 + 2) @@ -324,16 +340,17 @@ UP032_2.py:21:1: UP032 [*] Use f-string instead of `format` call 23 23 | 24 24 | "{.real}".format(1 + 2) -UP032_2.py:22:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:22:1 | 20 | "{}".format({1, 2}) 21 | "{}".format({1: 2, 3: 4}) 22 | "{}".format((i for i in range(2))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | "{.real}".format(1 + 2) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 19 19 | "{}".format([1, 2]) @@ -345,16 +362,17 @@ UP032_2.py:22:1: UP032 [*] Use f-string instead of `format` call 24 24 | "{.real}".format(1 + 2) 25 25 | "{.real}".format([1, 2]) -UP032_2.py:24:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:24:1 | 22 | "{}".format((i for i in range(2))) 23 | 24 | "{.real}".format(1 + 2) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^ 25 | "{.real}".format([1, 2]) 26 | "{.real}".format({1, 2}) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 21 21 | "{}".format({1: 2, 3: 4}) @@ -366,15 +384,16 @@ UP032_2.py:24:1: UP032 [*] Use f-string instead of `format` call 26 26 | "{.real}".format({1, 2}) 27 27 | "{.real}".format({1: 2, 3: 4}) -UP032_2.py:25:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:25:1 | 24 | "{.real}".format(1 + 2) 25 | "{.real}".format([1, 2]) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 26 | "{.real}".format({1, 2}) 27 | "{.real}".format({1: 2, 3: 4}) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 22 22 | "{}".format((i for i in range(2))) @@ -386,16 +405,17 @@ UP032_2.py:25:1: UP032 [*] Use f-string instead of `format` call 27 27 | "{.real}".format({1: 2, 3: 4}) 28 28 | "{}".format((i for i in range(2))) -UP032_2.py:26:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:26:1 | 24 | "{.real}".format(1 + 2) 25 | "{.real}".format([1, 2]) 26 | "{.real}".format({1, 2}) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 27 | "{.real}".format({1: 2, 3: 4}) 28 | "{}".format((i for i in range(2))) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 23 23 | @@ -406,15 +426,16 @@ UP032_2.py:26:1: UP032 [*] Use f-string instead of `format` call 27 27 | "{.real}".format({1: 2, 3: 4}) 28 28 | "{}".format((i for i in range(2))) -UP032_2.py:27:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:27:1 | 25 | "{.real}".format([1, 2]) 26 | "{.real}".format({1, 2}) 27 | "{.real}".format({1: 2, 3: 4}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | "{}".format((i for i in range(2))) | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 24 24 | "{.real}".format(1 + 2) @@ -424,14 +445,15 @@ UP032_2.py:27:1: UP032 [*] Use f-string instead of `format` call 27 |+f"{({1: 2, 3: 4}).real}" 28 28 | "{}".format((i for i in range(2))) -UP032_2.py:28:1: UP032 [*] Use f-string instead of `format` call +UP032 [*] Use f-string instead of `format` call + --> UP032_2.py:28:1 | 26 | "{.real}".format({1, 2}) 27 | "{.real}".format({1: 2, 3: 4}) 28 | "{}".format((i for i in range(2))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to f-string +help: Convert to f-string ℹ Safe fix 25 25 | "{.real}".format([1, 2]) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap index bef261b87e..360f79668a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP033_0.py:4:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` +UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + --> UP033_0.py:4:21 | 4 | @functools.lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 + | ^^^^^^^^^^^^^^ 5 | def fixme(): 6 | pass | - = help: Rewrite with `@functools.cache +help: Rewrite with `@functools.cache ℹ Safe fix 1 1 | import functools @@ -21,15 +21,16 @@ UP033_0.py:4:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cac 6 6 | pass 7 7 | -UP033_0.py:10:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` +UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + --> UP033_0.py:10:21 | 9 | @other_decorator 10 | @functools.lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 + | ^^^^^^^^^^^^^^ 11 | def fixme(): 12 | pass | - = help: Rewrite with `@functools.cache +help: Rewrite with `@functools.cache ℹ Safe fix 7 7 | @@ -41,14 +42,15 @@ UP033_0.py:10:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_ca 12 12 | pass 13 13 | -UP033_0.py:15:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` +UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + --> UP033_0.py:15:21 | 15 | @functools.lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 + | ^^^^^^^^^^^^^^ 16 | @other_decorator 17 | def fixme(): | - = help: Rewrite with `@functools.cache +help: Rewrite with `@functools.cache ℹ Safe fix 12 12 | pass diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap index 5cf350c7e0..cb370b0f83 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP033_1.py:4:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` +UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + --> UP033_1.py:4:11 | 4 | @lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 + | ^^^^^^^^^^^^^^ 5 | def fixme(): 6 | pass | - = help: Rewrite with `@functools.cache +help: Rewrite with `@functools.cache ℹ Safe fix 1 |-from functools import lru_cache @@ -22,15 +22,16 @@ UP033_1.py:4:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cac 6 6 | pass 7 7 | -UP033_1.py:10:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` +UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + --> UP033_1.py:10:11 | 9 | @other_decorator 10 | @lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 + | ^^^^^^^^^^^^^^ 11 | def fixme(): 12 | pass | - = help: Rewrite with `@functools.cache +help: Rewrite with `@functools.cache ℹ Safe fix 1 |-from functools import lru_cache @@ -48,14 +49,15 @@ UP033_1.py:10:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_ca 12 12 | pass 13 13 | -UP033_1.py:15:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` +UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + --> UP033_1.py:15:11 | 15 | @lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 + | ^^^^^^^^^^^^^^ 16 | @other_decorator 17 | def fixme(): | - = help: Rewrite with `@functools.cache +help: Rewrite with `@functools.cache ℹ Safe fix 1 |-from functools import lru_cache diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap index 4c93c84778..99c070b031 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP034.py:2:7: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:2:7 | 1 | # UP034 2 | print(("foo")) - | ^^^^^^^ UP034 + | ^^^^^^^ 3 | 4 | # UP034 | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 1 1 | # UP034 @@ -19,15 +20,16 @@ UP034.py:2:7: UP034 [*] Avoid extraneous parentheses 4 4 | # UP034 5 5 | print(("hell((goodybe))o")) -UP034.py:5:7: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:5:7 | 4 | # UP034 5 | print(("hell((goodybe))o")) - | ^^^^^^^^^^^^^^^^^^^^ UP034 + | ^^^^^^^^^^^^^^^^^^^^ 6 | 7 | # UP034 | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 2 2 | print(("foo")) @@ -39,15 +41,16 @@ UP034.py:5:7: UP034 [*] Avoid extraneous parentheses 7 7 | # UP034 8 8 | print((("foo"))) -UP034.py:8:7: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:8:7 | 7 | # UP034 8 | print((("foo"))) - | ^^^^^^^^^ UP034 + | ^^^^^^^^^ 9 | 10 | # UP034 | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 5 5 | print(("hell((goodybe))o")) @@ -59,15 +62,16 @@ UP034.py:8:7: UP034 [*] Avoid extraneous parentheses 10 10 | # UP034 11 11 | print((((1)))) -UP034.py:11:7: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:11:7 | 10 | # UP034 11 | print((((1)))) - | ^^^^^^^ UP034 + | ^^^^^^^ 12 | 13 | # UP034 | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 8 8 | print((("foo"))) @@ -79,15 +83,16 @@ UP034.py:11:7: UP034 [*] Avoid extraneous parentheses 13 13 | # UP034 14 14 | print(("foo{}".format(1))) -UP034.py:14:7: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:14:7 | 13 | # UP034 14 | print(("foo{}".format(1))) - | ^^^^^^^^^^^^^^^^^^^ UP034 + | ^^^^^^^^^^^^^^^^^^^ 15 | 16 | # UP034 | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 11 11 | print((((1)))) @@ -99,15 +104,16 @@ UP034.py:14:7: UP034 [*] Avoid extraneous parentheses 16 16 | # UP034 17 17 | print( -UP034.py:18:5: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:18:5 | 16 | # UP034 17 | print( 18 | ("foo{}".format(1)) - | ^^^^^^^^^^^^^^^^^^^ UP034 + | ^^^^^^^^^^^^^^^^^^^ 19 | ) | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 15 15 | @@ -119,17 +125,18 @@ UP034.py:18:5: UP034 [*] Avoid extraneous parentheses 20 20 | 21 21 | # UP034 -UP034.py:23:5: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:23:5 | 21 | # UP034 22 | print( 23 | / ( 24 | | "foo" 25 | | ) - | |_____^ UP034 + | |_____^ 26 | ) | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 20 20 | @@ -144,16 +151,17 @@ UP034.py:23:5: UP034 [*] Avoid extraneous parentheses 27 27 | 28 28 | # UP034 -UP034.py:30:13: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:30:13 | 28 | # UP034 29 | def f(): 30 | x = int(((yield 1))) - | ^^^^^^^^^^^ UP034 + | ^^^^^^^^^^^ 31 | 32 | # UP034 | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 27 27 | @@ -165,15 +173,16 @@ UP034.py:30:13: UP034 [*] Avoid extraneous parentheses 32 32 | # UP034 33 33 | if True: -UP034.py:35:9: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:35:9 | 33 | if True: 34 | print( 35 | ("foo{}".format(1)) - | ^^^^^^^^^^^^^^^^^^^ UP034 + | ^^^^^^^^^^^^^^^^^^^ 36 | ) | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 32 32 | # UP034 @@ -185,15 +194,16 @@ UP034.py:35:9: UP034 [*] Avoid extraneous parentheses 37 37 | 38 38 | # UP034 -UP034.py:39:7: UP034 [*] Avoid extraneous parentheses +UP034 [*] Avoid extraneous parentheses + --> UP034.py:39:7 | 38 | # UP034 39 | print((x for x in range(3))) - | ^^^^^^^^^^^^^^^^^^^^^ UP034 + | ^^^^^^^^^^^^^^^^^^^^^ 40 | 41 | # OK | - = help: Remove extraneous parentheses +help: Remove extraneous parentheses ℹ Safe fix 36 36 | ) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap index 95c0bee046..8b0669e054 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP035.py:2:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:2:1 | 1 | # UP035 2 | from collections import Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | from collections import Mapping as MAP | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 1 1 | # UP035 @@ -19,16 +20,17 @@ UP035.py:2:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 4 4 | from collections import Mapping as MAP 5 5 | -UP035.py:4:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:4:1 | 2 | from collections import Mapping 3 | 4 | from collections import Mapping as MAP - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 6 | from collections import Mapping, Sequence | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 1 1 | # UP035 @@ -40,16 +42,17 @@ UP035.py:4:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 6 6 | from collections import Mapping, Sequence 7 7 | -UP035.py:6:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` +UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` + --> UP035.py:6:1 | 4 | from collections import Mapping as MAP 5 | 6 | from collections import Mapping, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | from collections import Counter, Mapping | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 3 3 | @@ -61,16 +64,17 @@ UP035.py:6:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Seque 8 8 | from collections import Counter, Mapping 9 9 | -UP035.py:8:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:8:1 | 6 | from collections import Mapping, Sequence 7 | 8 | from collections import Counter, Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | from collections import (Counter, Mapping) | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 5 5 | @@ -83,16 +87,17 @@ UP035.py:8:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 10 11 | from collections import (Counter, Mapping) 11 12 | -UP035.py:10:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:10:1 | 8 | from collections import Counter, Mapping 9 | 10 | from collections import (Counter, Mapping) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | from collections import (Counter, | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 7 7 | @@ -105,17 +110,18 @@ UP035.py:10:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 12 13 | from collections import (Counter, 13 14 | Mapping) -UP035.py:12:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:12:1 | 10 | from collections import (Counter, Mapping) 11 | 12 | / from collections import (Counter, 13 | | Mapping) - | |_________________________________^ UP035 + | |_________________________________^ 14 | 15 | from collections import Counter, \ | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 9 9 | @@ -129,17 +135,18 @@ UP035.py:12:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 15 15 | from collections import Counter, \ 16 16 | Mapping -UP035.py:15:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:15:1 | 13 | Mapping) 14 | 15 | / from collections import Counter, \ 16 | | Mapping - | |________________________________^ UP035 + | |________________________________^ 17 | 18 | from collections import Counter, Mapping, Sequence | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 12 12 | from collections import (Counter, @@ -153,16 +160,17 @@ UP035.py:15:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 18 18 | from collections import Counter, Mapping, Sequence 19 19 | -UP035.py:18:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` +UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` + --> UP035.py:18:1 | 16 | Mapping 17 | 18 | from collections import Counter, Mapping, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | from collections import Mapping as mapping, Counter | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 15 15 | from collections import Counter, \ @@ -175,16 +183,17 @@ UP035.py:18:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequ 20 21 | from collections import Mapping as mapping, Counter 21 22 | -UP035.py:20:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:20:1 | 18 | from collections import Counter, Mapping, Sequence 19 | 20 | from collections import Mapping as mapping, Counter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | 22 | if True: | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 17 17 | @@ -197,15 +206,16 @@ UP035.py:20:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 22 23 | if True: 23 24 | from collections import Mapping, Counter -UP035.py:23:5: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:23:5 | 22 | if True: 23 | from collections import Mapping, Counter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | 25 | if True: | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 20 20 | from collections import Mapping as mapping, Counter @@ -218,16 +228,17 @@ UP035.py:23:5: UP035 [*] Import from `collections.abc` instead: `Mapping` 25 26 | if True: 26 27 | if True: -UP035.py:28:5: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:28:5 | 26 | if True: 27 | pass 28 | from collections import Mapping, Counter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | 30 | if True: from collections import Mapping | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 25 25 | if True: @@ -240,16 +251,17 @@ UP035.py:28:5: UP035 [*] Import from `collections.abc` instead: `Mapping` 30 31 | if True: from collections import Mapping 31 32 | -UP035.py:30:10: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:30:10 | 28 | from collections import Mapping, Counter 29 | 30 | if True: from collections import Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | 32 | import os | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 27 27 | pass @@ -261,14 +273,15 @@ UP035.py:30:10: UP035 [*] Import from `collections.abc` instead: `Mapping` 32 32 | import os 33 33 | from collections import Counter, Mapping -UP035.py:33:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:33:1 | 32 | import os 33 | from collections import Counter, Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 34 | import sys | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 30 30 | if True: from collections import Mapping @@ -281,7 +294,8 @@ UP035.py:33:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 35 36 | 36 37 | if True: -UP035.py:37:5: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Callable` +UP035 [*] Import from `collections.abc` instead: `Mapping`, `Callable` + --> UP035.py:37:5 | 36 | if True: 37 | / from collections import ( @@ -290,11 +304,11 @@ UP035.py:37:5: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Call 40 | | Bad, 41 | | Good, 42 | | ) - | |_____^ UP035 + | |_____^ 43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 35 35 | @@ -310,16 +324,17 @@ UP035.py:37:5: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Call 44 43 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager 45 44 | -UP035.py:44:1: UP035 [*] Import from `collections.abc` instead: `Callable` +UP035 [*] Import from `collections.abc` instead: `Callable` + --> UP035.py:44:1 | 42 | ) 43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | if True: from collections import ( | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 41 41 | Good, @@ -332,16 +347,17 @@ UP035.py:44:1: UP035 [*] Import from `collections.abc` instead: `Callable` 46 47 | if True: from collections import ( 47 48 | Mapping, Counter) -UP035.py:44:1: UP035 [*] Import from `collections` instead: `OrderedDict` +UP035 [*] Import from `collections` instead: `OrderedDict` + --> UP035.py:44:1 | 42 | ) 43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | if True: from collections import ( | - = help: Import from `collections` +help: Import from `collections` ℹ Safe fix 41 41 | Good, @@ -354,16 +370,17 @@ UP035.py:44:1: UP035 [*] Import from `collections` instead: `OrderedDict` 46 47 | if True: from collections import ( 47 48 | Mapping, Counter) -UP035.py:44:1: UP035 [*] Import from `re` instead: `Match`, `Pattern` +UP035 [*] Import from `re` instead: `Match`, `Pattern` + --> UP035.py:44:1 | 42 | ) 43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | if True: from collections import ( | - = help: Import from `re` +help: Import from `re` ℹ Safe fix 41 41 | Good, @@ -376,68 +393,74 @@ UP035.py:44:1: UP035 [*] Import from `re` instead: `Match`, `Pattern` 46 47 | if True: from collections import ( 47 48 | Mapping, Counter) -UP035.py:44:1: UP035 `typing.List` is deprecated, use `list` instead +UP035 `typing.List` is deprecated, use `list` instead + --> UP035.py:44:1 | 42 | ) 43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | if True: from collections import ( | -UP035.py:44:1: UP035 `typing.AbstractSet` is deprecated, use `collections.abc.Set` instead +UP035 `typing.AbstractSet` is deprecated, use `collections.abc.Set` instead + --> UP035.py:44:1 | 42 | ) 43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | if True: from collections import ( | -UP035.py:44:1: UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead +UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead + --> UP035.py:44:1 | 42 | ) 43 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | if True: from collections import ( | -UP035.py:46:10: UP035 Import from `collections.abc` instead: `Mapping` +UP035 Import from `collections.abc` instead: `Mapping` + --> UP035.py:46:10 | 44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager 45 | 46 | if True: from collections import ( | __________^ 47 | | Mapping, Counter) - | |_____________________^ UP035 + | |_____________________^ 48 | 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) | - = help: Import from `collections.abc` +help: Import from `collections.abc` -UP035.py:50:1: UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead +UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead + --> UP035.py:50:1 | 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) 50 | from typing import ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 51 | from typing import OrderedDict 52 | from typing_extensions import OrderedDict | -UP035.py:51:1: UP035 [*] Import from `collections` instead: `OrderedDict` +UP035 [*] Import from `collections` instead: `OrderedDict` + --> UP035.py:51:1 | 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) 50 | from typing import ContextManager 51 | from typing import OrderedDict - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | from typing_extensions import OrderedDict 53 | from typing import Callable | - = help: Import from `collections` +help: Import from `collections` ℹ Safe fix 48 48 | @@ -449,16 +472,17 @@ UP035.py:51:1: UP035 [*] Import from `collections` instead: `OrderedDict` 53 53 | from typing import Callable 54 54 | from typing import ByteString -UP035.py:52:1: UP035 [*] Import from `typing` instead: `OrderedDict` +UP035 [*] Import from `typing` instead: `OrderedDict` + --> UP035.py:52:1 | 50 | from typing import ContextManager 51 | from typing import OrderedDict 52 | from typing_extensions import OrderedDict - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 53 | from typing import Callable 54 | from typing import ByteString | - = help: Import from `typing` +help: Import from `typing` ℹ Safe fix 49 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) @@ -470,16 +494,17 @@ UP035.py:52:1: UP035 [*] Import from `typing` instead: `OrderedDict` 54 54 | from typing import ByteString 55 55 | from typing import Container -UP035.py:53:1: UP035 [*] Import from `collections.abc` instead: `Callable` +UP035 [*] Import from `collections.abc` instead: `Callable` + --> UP035.py:53:1 | 51 | from typing import OrderedDict 52 | from typing_extensions import OrderedDict 53 | from typing import Callable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | from typing import ByteString 55 | from typing import Container | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 50 50 | from typing import ContextManager @@ -491,16 +516,17 @@ UP035.py:53:1: UP035 [*] Import from `collections.abc` instead: `Callable` 55 55 | from typing import Container 56 56 | from typing import Hashable -UP035.py:54:1: UP035 [*] Import from `collections.abc` instead: `ByteString` +UP035 [*] Import from `collections.abc` instead: `ByteString` + --> UP035.py:54:1 | 52 | from typing_extensions import OrderedDict 53 | from typing import Callable 54 | from typing import ByteString - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | from typing import Container 56 | from typing import Hashable | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 51 51 | from typing import OrderedDict @@ -512,16 +538,17 @@ UP035.py:54:1: UP035 [*] Import from `collections.abc` instead: `ByteString` 56 56 | from typing import Hashable 57 57 | from typing import ItemsView -UP035.py:55:1: UP035 [*] Import from `collections.abc` instead: `Container` +UP035 [*] Import from `collections.abc` instead: `Container` + --> UP035.py:55:1 | 53 | from typing import Callable 54 | from typing import ByteString 55 | from typing import Container - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 56 | from typing import Hashable 57 | from typing import ItemsView | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 52 52 | from typing_extensions import OrderedDict @@ -533,16 +560,17 @@ UP035.py:55:1: UP035 [*] Import from `collections.abc` instead: `Container` 57 57 | from typing import ItemsView 58 58 | from typing import Iterable -UP035.py:56:1: UP035 [*] Import from `collections.abc` instead: `Hashable` +UP035 [*] Import from `collections.abc` instead: `Hashable` + --> UP035.py:56:1 | 54 | from typing import ByteString 55 | from typing import Container 56 | from typing import Hashable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 57 | from typing import ItemsView 58 | from typing import Iterable | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 53 53 | from typing import Callable @@ -554,16 +582,17 @@ UP035.py:56:1: UP035 [*] Import from `collections.abc` instead: `Hashable` 58 58 | from typing import Iterable 59 59 | from typing import Iterator -UP035.py:57:1: UP035 [*] Import from `collections.abc` instead: `ItemsView` +UP035 [*] Import from `collections.abc` instead: `ItemsView` + --> UP035.py:57:1 | 55 | from typing import Container 56 | from typing import Hashable 57 | from typing import ItemsView - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 58 | from typing import Iterable 59 | from typing import Iterator | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 54 54 | from typing import ByteString @@ -575,16 +604,17 @@ UP035.py:57:1: UP035 [*] Import from `collections.abc` instead: `ItemsView` 59 59 | from typing import Iterator 60 60 | from typing import KeysView -UP035.py:58:1: UP035 [*] Import from `collections.abc` instead: `Iterable` +UP035 [*] Import from `collections.abc` instead: `Iterable` + --> UP035.py:58:1 | 56 | from typing import Hashable 57 | from typing import ItemsView 58 | from typing import Iterable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 59 | from typing import Iterator 60 | from typing import KeysView | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 55 55 | from typing import Container @@ -596,16 +626,17 @@ UP035.py:58:1: UP035 [*] Import from `collections.abc` instead: `Iterable` 60 60 | from typing import KeysView 61 61 | from typing import Mapping -UP035.py:59:1: UP035 [*] Import from `collections.abc` instead: `Iterator` +UP035 [*] Import from `collections.abc` instead: `Iterator` + --> UP035.py:59:1 | 57 | from typing import ItemsView 58 | from typing import Iterable 59 | from typing import Iterator - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | from typing import KeysView 61 | from typing import Mapping | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 56 56 | from typing import Hashable @@ -617,16 +648,17 @@ UP035.py:59:1: UP035 [*] Import from `collections.abc` instead: `Iterator` 61 61 | from typing import Mapping 62 62 | from typing import MappingView -UP035.py:60:1: UP035 [*] Import from `collections.abc` instead: `KeysView` +UP035 [*] Import from `collections.abc` instead: `KeysView` + --> UP035.py:60:1 | 58 | from typing import Iterable 59 | from typing import Iterator 60 | from typing import KeysView - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61 | from typing import Mapping 62 | from typing import MappingView | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 57 57 | from typing import ItemsView @@ -638,16 +670,17 @@ UP035.py:60:1: UP035 [*] Import from `collections.abc` instead: `KeysView` 62 62 | from typing import MappingView 63 63 | from typing import MutableMapping -UP035.py:61:1: UP035 [*] Import from `collections.abc` instead: `Mapping` +UP035 [*] Import from `collections.abc` instead: `Mapping` + --> UP035.py:61:1 | 59 | from typing import Iterator 60 | from typing import KeysView 61 | from typing import Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 62 | from typing import MappingView 63 | from typing import MutableMapping | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 58 58 | from typing import Iterable @@ -659,16 +692,17 @@ UP035.py:61:1: UP035 [*] Import from `collections.abc` instead: `Mapping` 63 63 | from typing import MutableMapping 64 64 | from typing import MutableSequence -UP035.py:62:1: UP035 [*] Import from `collections.abc` instead: `MappingView` +UP035 [*] Import from `collections.abc` instead: `MappingView` + --> UP035.py:62:1 | 60 | from typing import KeysView 61 | from typing import Mapping 62 | from typing import MappingView - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | from typing import MutableMapping 64 | from typing import MutableSequence | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 59 59 | from typing import Iterator @@ -680,16 +714,17 @@ UP035.py:62:1: UP035 [*] Import from `collections.abc` instead: `MappingView` 64 64 | from typing import MutableSequence 65 65 | from typing import MutableSet -UP035.py:63:1: UP035 [*] Import from `collections.abc` instead: `MutableMapping` +UP035 [*] Import from `collections.abc` instead: `MutableMapping` + --> UP035.py:63:1 | 61 | from typing import Mapping 62 | from typing import MappingView 63 | from typing import MutableMapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | from typing import MutableSequence 65 | from typing import MutableSet | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 60 60 | from typing import KeysView @@ -701,16 +736,17 @@ UP035.py:63:1: UP035 [*] Import from `collections.abc` instead: `MutableMapping` 65 65 | from typing import MutableSet 66 66 | from typing import Sequence -UP035.py:64:1: UP035 [*] Import from `collections.abc` instead: `MutableSequence` +UP035 [*] Import from `collections.abc` instead: `MutableSequence` + --> UP035.py:64:1 | 62 | from typing import MappingView 63 | from typing import MutableMapping 64 | from typing import MutableSequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 | from typing import MutableSet 66 | from typing import Sequence | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 61 61 | from typing import Mapping @@ -722,16 +758,17 @@ UP035.py:64:1: UP035 [*] Import from `collections.abc` instead: `MutableSequence 66 66 | from typing import Sequence 67 67 | from typing import Sized -UP035.py:65:1: UP035 [*] Import from `collections.abc` instead: `MutableSet` +UP035 [*] Import from `collections.abc` instead: `MutableSet` + --> UP035.py:65:1 | 63 | from typing import MutableMapping 64 | from typing import MutableSequence 65 | from typing import MutableSet - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | from typing import Sequence 67 | from typing import Sized | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 62 62 | from typing import MappingView @@ -743,16 +780,17 @@ UP035.py:65:1: UP035 [*] Import from `collections.abc` instead: `MutableSet` 67 67 | from typing import Sized 68 68 | from typing import ValuesView -UP035.py:66:1: UP035 [*] Import from `collections.abc` instead: `Sequence` +UP035 [*] Import from `collections.abc` instead: `Sequence` + --> UP035.py:66:1 | 64 | from typing import MutableSequence 65 | from typing import MutableSet 66 | from typing import Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 | from typing import Sized 68 | from typing import ValuesView | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 63 63 | from typing import MutableMapping @@ -764,16 +802,17 @@ UP035.py:66:1: UP035 [*] Import from `collections.abc` instead: `Sequence` 68 68 | from typing import ValuesView 69 69 | from typing import Awaitable -UP035.py:67:1: UP035 [*] Import from `collections.abc` instead: `Sized` +UP035 [*] Import from `collections.abc` instead: `Sized` + --> UP035.py:67:1 | 65 | from typing import MutableSet 66 | from typing import Sequence 67 | from typing import Sized - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 68 | from typing import ValuesView 69 | from typing import Awaitable | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 64 64 | from typing import MutableSequence @@ -785,16 +824,17 @@ UP035.py:67:1: UP035 [*] Import from `collections.abc` instead: `Sized` 69 69 | from typing import Awaitable 70 70 | from typing import AsyncIterator -UP035.py:68:1: UP035 [*] Import from `collections.abc` instead: `ValuesView` +UP035 [*] Import from `collections.abc` instead: `ValuesView` + --> UP035.py:68:1 | 66 | from typing import Sequence 67 | from typing import Sized 68 | from typing import ValuesView - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 69 | from typing import Awaitable 70 | from typing import AsyncIterator | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 65 65 | from typing import MutableSet @@ -806,16 +846,17 @@ UP035.py:68:1: UP035 [*] Import from `collections.abc` instead: `ValuesView` 70 70 | from typing import AsyncIterator 71 71 | from typing import AsyncIterable -UP035.py:69:1: UP035 [*] Import from `collections.abc` instead: `Awaitable` +UP035 [*] Import from `collections.abc` instead: `Awaitable` + --> UP035.py:69:1 | 67 | from typing import Sized 68 | from typing import ValuesView 69 | from typing import Awaitable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | from typing import AsyncIterator 71 | from typing import AsyncIterable | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 66 66 | from typing import Sequence @@ -827,16 +868,17 @@ UP035.py:69:1: UP035 [*] Import from `collections.abc` instead: `Awaitable` 71 71 | from typing import AsyncIterable 72 72 | from typing import Coroutine -UP035.py:70:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterator` +UP035 [*] Import from `collections.abc` instead: `AsyncIterator` + --> UP035.py:70:1 | 68 | from typing import ValuesView 69 | from typing import Awaitable 70 | from typing import AsyncIterator - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 71 | from typing import AsyncIterable 72 | from typing import Coroutine | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 67 67 | from typing import Sized @@ -848,16 +890,17 @@ UP035.py:70:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterator` 72 72 | from typing import Coroutine 73 73 | from typing import Collection -UP035.py:71:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterable` +UP035 [*] Import from `collections.abc` instead: `AsyncIterable` + --> UP035.py:71:1 | 69 | from typing import Awaitable 70 | from typing import AsyncIterator 71 | from typing import AsyncIterable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | from typing import Coroutine 73 | from typing import Collection | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 68 68 | from typing import ValuesView @@ -869,16 +912,17 @@ UP035.py:71:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterable` 73 73 | from typing import Collection 74 74 | from typing import AsyncGenerator -UP035.py:72:1: UP035 [*] Import from `collections.abc` instead: `Coroutine` +UP035 [*] Import from `collections.abc` instead: `Coroutine` + --> UP035.py:72:1 | 70 | from typing import AsyncIterator 71 | from typing import AsyncIterable 72 | from typing import Coroutine - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 73 | from typing import Collection 74 | from typing import AsyncGenerator | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 69 69 | from typing import Awaitable @@ -890,16 +934,17 @@ UP035.py:72:1: UP035 [*] Import from `collections.abc` instead: `Coroutine` 74 74 | from typing import AsyncGenerator 75 75 | from typing import Reversible -UP035.py:73:1: UP035 [*] Import from `collections.abc` instead: `Collection` +UP035 [*] Import from `collections.abc` instead: `Collection` + --> UP035.py:73:1 | 71 | from typing import AsyncIterable 72 | from typing import Coroutine 73 | from typing import Collection - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 74 | from typing import AsyncGenerator 75 | from typing import Reversible | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 70 70 | from typing import AsyncIterator @@ -911,16 +956,17 @@ UP035.py:73:1: UP035 [*] Import from `collections.abc` instead: `Collection` 75 75 | from typing import Reversible 76 76 | from typing import Generator -UP035.py:74:1: UP035 [*] Import from `collections.abc` instead: `AsyncGenerator` +UP035 [*] Import from `collections.abc` instead: `AsyncGenerator` + --> UP035.py:74:1 | 72 | from typing import Coroutine 73 | from typing import Collection 74 | from typing import AsyncGenerator - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | from typing import Reversible 76 | from typing import Generator | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 71 71 | from typing import AsyncIterable @@ -932,16 +978,17 @@ UP035.py:74:1: UP035 [*] Import from `collections.abc` instead: `AsyncGenerator` 76 76 | from typing import Generator 77 77 | from typing import Callable -UP035.py:75:1: UP035 [*] Import from `collections.abc` instead: `Reversible` +UP035 [*] Import from `collections.abc` instead: `Reversible` + --> UP035.py:75:1 | 73 | from typing import Collection 74 | from typing import AsyncGenerator 75 | from typing import Reversible - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 76 | from typing import Generator 77 | from typing import Callable | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 72 72 | from typing import Coroutine @@ -953,16 +1000,17 @@ UP035.py:75:1: UP035 [*] Import from `collections.abc` instead: `Reversible` 77 77 | from typing import Callable 78 78 | from typing import cast -UP035.py:76:1: UP035 [*] Import from `collections.abc` instead: `Generator` +UP035 [*] Import from `collections.abc` instead: `Generator` + --> UP035.py:76:1 | 74 | from typing import AsyncGenerator 75 | from typing import Reversible 76 | from typing import Generator - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 77 | from typing import Callable 78 | from typing import cast | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 73 73 | from typing import Collection @@ -974,15 +1022,16 @@ UP035.py:76:1: UP035 [*] Import from `collections.abc` instead: `Generator` 78 78 | from typing import cast 79 79 | -UP035.py:77:1: UP035 [*] Import from `collections.abc` instead: `Callable` +UP035 [*] Import from `collections.abc` instead: `Callable` + --> UP035.py:77:1 | 75 | from typing import Reversible 76 | from typing import Generator 77 | from typing import Callable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 78 | from typing import cast | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 74 74 | from typing import AsyncGenerator @@ -994,15 +1043,16 @@ UP035.py:77:1: UP035 [*] Import from `collections.abc` instead: `Callable` 79 79 | 80 80 | # OK -UP035.py:84:1: UP035 [*] Import from `typing` instead: `SupportsIndex` +UP035 [*] Import from `typing` instead: `SupportsIndex` + --> UP035.py:84:1 | 83 | # UP035 on py312+ only 84 | from typing_extensions import SupportsIndex - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 85 | 86 | # UP035 on py312+ only | - = help: Import from `typing` +help: Import from `typing` ℹ Safe fix 81 81 | from a import b @@ -1014,15 +1064,16 @@ UP035.py:84:1: UP035 [*] Import from `typing` instead: `SupportsIndex` 86 86 | # UP035 on py312+ only 87 87 | from typing_extensions import NamedTuple -UP035.py:87:1: UP035 [*] Import from `typing` instead: `NamedTuple` +UP035 [*] Import from `typing` instead: `NamedTuple` + --> UP035.py:87:1 | 86 | # UP035 on py312+ only 87 | from typing_extensions import NamedTuple - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 88 | 89 | # UP035 on py312+ only: `typing_extensions` supports `frozen_default` (backported from 3.12). | - = help: Import from `typing` +help: Import from `typing` ℹ Safe fix 84 84 | from typing_extensions import SupportsIndex @@ -1034,15 +1085,16 @@ UP035.py:87:1: UP035 [*] Import from `typing` instead: `NamedTuple` 89 89 | # UP035 on py312+ only: `typing_extensions` supports `frozen_default` (backported from 3.12). 90 90 | from typing_extensions import dataclass_transform -UP035.py:90:1: UP035 [*] Import from `typing` instead: `dataclass_transform` +UP035 [*] Import from `typing` instead: `dataclass_transform` + --> UP035.py:90:1 | 89 | # UP035 on py312+ only: `typing_extensions` supports `frozen_default` (backported from 3.12). 90 | from typing_extensions import dataclass_transform - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 91 | 92 | # UP035 | - = help: Import from `typing` +help: Import from `typing` ℹ Safe fix 87 87 | from typing_extensions import NamedTuple @@ -1054,15 +1106,16 @@ UP035.py:90:1: UP035 [*] Import from `typing` instead: `dataclass_transform` 92 92 | # UP035 93 93 | from backports.strenum import StrEnum -UP035.py:93:1: UP035 [*] Import from `enum` instead: `StrEnum` +UP035 [*] Import from `enum` instead: `StrEnum` + --> UP035.py:93:1 | 92 | # UP035 93 | from backports.strenum import StrEnum - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 94 | 95 | # UP035 | - = help: Import from `enum` +help: Import from `enum` ℹ Safe fix 90 90 | from typing_extensions import dataclass_transform @@ -1074,15 +1127,16 @@ UP035.py:93:1: UP035 [*] Import from `enum` instead: `StrEnum` 95 95 | # UP035 96 96 | from typing_extensions import override -UP035.py:96:1: UP035 [*] Import from `typing` instead: `override` +UP035 [*] Import from `typing` instead: `override` + --> UP035.py:96:1 | 95 | # UP035 96 | from typing_extensions import override - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 97 | 98 | # UP035 | - = help: Import from `typing` +help: Import from `typing` ℹ Safe fix 93 93 | from backports.strenum import StrEnum @@ -1094,15 +1148,16 @@ UP035.py:96:1: UP035 [*] Import from `typing` instead: `override` 98 98 | # UP035 99 99 | from typing_extensions import Buffer -UP035.py:99:1: UP035 [*] Import from `collections.abc` instead: `Buffer` +UP035 [*] Import from `collections.abc` instead: `Buffer` + --> UP035.py:99:1 | 98 | # UP035 99 | from typing_extensions import Buffer - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 100 | 101 | # UP035 | - = help: Import from `collections.abc` +help: Import from `collections.abc` ℹ Safe fix 96 96 | from typing_extensions import override @@ -1114,15 +1169,16 @@ UP035.py:99:1: UP035 [*] Import from `collections.abc` instead: `Buffer` 101 101 | # UP035 102 102 | from typing_extensions import get_original_bases -UP035.py:102:1: UP035 [*] Import from `types` instead: `get_original_bases` +UP035 [*] Import from `types` instead: `get_original_bases` + --> UP035.py:102:1 | 101 | # UP035 102 | from typing_extensions import get_original_bases - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 103 | 104 | # UP035 on py313+ only | - = help: Import from `types` +help: Import from `types` ℹ Safe fix 99 99 | from typing_extensions import Buffer @@ -1134,15 +1190,16 @@ UP035.py:102:1: UP035 [*] Import from `types` instead: `get_original_bases` 104 104 | # UP035 on py313+ only 105 105 | from typing_extensions import TypeVar -UP035.py:105:1: UP035 [*] Import from `typing` instead: `TypeVar` +UP035 [*] Import from `typing` instead: `TypeVar` + --> UP035.py:105:1 | 104 | # UP035 on py313+ only 105 | from typing_extensions import TypeVar - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 106 | 107 | # UP035 on py313+ only | - = help: Import from `typing` +help: Import from `typing` ℹ Safe fix 102 102 | from typing_extensions import get_original_bases @@ -1154,15 +1211,16 @@ UP035.py:105:1: UP035 [*] Import from `typing` instead: `TypeVar` 107 107 | # UP035 on py313+ only 108 108 | from typing_extensions import CapsuleType -UP035.py:108:1: UP035 [*] Import from `types` instead: `CapsuleType` +UP035 [*] Import from `types` instead: `CapsuleType` + --> UP035.py:108:1 | 107 | # UP035 on py313+ only 108 | from typing_extensions import CapsuleType - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 109 | 110 | # UP035 on py313+ only | - = help: Import from `types` +help: Import from `types` ℹ Safe fix 105 105 | from typing_extensions import TypeVar @@ -1174,15 +1232,16 @@ UP035.py:108:1: UP035 [*] Import from `types` instead: `CapsuleType` 110 110 | # UP035 on py313+ only 111 111 | from typing_extensions import deprecated -UP035.py:111:1: UP035 [*] Import from `warnings` instead: `deprecated` +UP035 [*] Import from `warnings` instead: `deprecated` + --> UP035.py:111:1 | 110 | # UP035 on py313+ only 111 | from typing_extensions import deprecated - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 112 | 113 | # UP035 on py313+ only | - = help: Import from `warnings` +help: Import from `warnings` ℹ Safe fix 108 108 | from typing_extensions import CapsuleType @@ -1194,15 +1253,16 @@ UP035.py:111:1: UP035 [*] Import from `warnings` instead: `deprecated` 113 113 | # UP035 on py313+ only 114 114 | from typing_extensions import get_type_hints -UP035.py:114:1: UP035 [*] Import from `typing` instead: `get_type_hints` +UP035 [*] Import from `typing` instead: `get_type_hints` + --> UP035.py:114:1 | 113 | # UP035 on py313+ only 114 | from typing_extensions import get_type_hints - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 115 | 116 | # https://github.com/astral-sh/ruff/issues/15780 | - = help: Import from `typing` +help: Import from `typing` ℹ Safe fix 111 111 | from typing_extensions import deprecated diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap index 497f7bec51..b3df965476 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP036_0.py:3:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:3:4 | 1 | import sys 2 | 3 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 4 | print("py2") 5 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 1 1 | import sys @@ -24,16 +25,17 @@ UP036_0.py:3:4: UP036 [*] Version block is outdated for minimum Python version 8 5 | if sys.version_info < (3,0): 9 6 | if True: -UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:8:4 | 6 | print("py3") 7 | 8 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 9 | if True: 10 | print("py2!") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 5 5 | else: @@ -51,15 +53,16 @@ UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version 16 10 | if sys.version_info < (3,0): print("PY2!") 17 11 | else: print("PY3!") -UP036_0.py:16:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:16:4 | 14 | print("py3") 15 | 16 | if sys.version_info < (3,0): print("PY2!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 17 | else: print("PY3!") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 13 13 | else: @@ -72,15 +75,16 @@ UP036_0.py:16:4: UP036 [*] Version block is outdated for minimum Python version 19 18 | if True: 20 19 | if sys.version_info < (3,0): -UP036_0.py:20:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:20:8 | 19 | if True: 20 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 21 | print("PY2") 22 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 17 17 | else: print("PY3!") @@ -95,16 +99,17 @@ UP036_0.py:20:8: UP036 [*] Version block is outdated for minimum Python version 25 22 | if sys.version_info < (3,0): print(1 if True else 3) 26 23 | else: -UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:25:4 | 23 | print("PY3") 24 | 25 | if sys.version_info < (3,0): print(1 if True else 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 26 | else: 27 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 22 22 | else: @@ -118,16 +123,17 @@ UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version 29 27 | if sys.version_info < (3,0): 30 28 | def f(): -UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:29:4 | 27 | print("py3") 28 | 29 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 30 | def f(): 31 | print("py2") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 26 26 | else: @@ -147,16 +153,17 @@ UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version 37 33 | if sys.version_info > (3,0): 38 34 | print("py3") -UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:37:4 | 35 | print("This the next") 36 | 37 | if sys.version_info > (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 38 | print("py3") 39 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 34 34 | print("py3") @@ -171,16 +178,17 @@ UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version 42 39 | 43 40 | x = 1 -UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:45:4 | 43 | x = 1 44 | 45 | if sys.version_info > (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 46 | print("py3") 47 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 42 42 | @@ -195,15 +203,16 @@ UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version 50 47 | 51 48 | x = 1 -UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:53:4 | 51 | x = 1 52 | 53 | if sys.version_info > (3,0): print("py3") - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 54 | else: print("py2") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 50 50 | @@ -216,16 +225,17 @@ UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version 56 55 | if sys.version_info > (3,): 57 56 | print("py3") -UP036_0.py:56:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:56:4 | 54 | else: print("py2") 55 | 56 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 57 | print("py3") 58 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 53 53 | if sys.version_info > (3,0): print("py3") @@ -240,15 +250,16 @@ UP036_0.py:56:4: UP036 [*] Version block is outdated for minimum Python version 61 58 | if True: 62 59 | if sys.version_info > (3,): -UP036_0.py:62:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:62:8 | 61 | if True: 62 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 63 | print("py3") 64 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 59 59 | print("py2") @@ -263,16 +274,17 @@ UP036_0.py:62:8: UP036 [*] Version block is outdated for minimum Python version 67 64 | if sys.version_info < (3,): 68 65 | print("py2") -UP036_0.py:67:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:67:4 | 65 | print("py2") 66 | 67 | if sys.version_info < (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 68 | print("py2") 69 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 64 64 | else: @@ -287,15 +299,16 @@ UP036_0.py:67:4: UP036 [*] Version block is outdated for minimum Python version 72 69 | def f(): 73 70 | if sys.version_info < (3,0): -UP036_0.py:73:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:73:8 | 72 | def f(): 73 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 74 | try: 75 | yield | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 70 70 | print("py3") @@ -313,16 +326,17 @@ UP036_0.py:73:8: UP036 [*] Version block is outdated for minimum Python version 81 75 | 82 76 | class C: -UP036_0.py:86:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:86:8 | 84 | pass 85 | 86 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 87 | def f(py2): 88 | pass | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 83 83 | def g(): @@ -340,15 +354,16 @@ UP036_0.py:86:8: UP036 [*] Version block is outdated for minimum Python version 93 89 | def h(): 94 90 | pass -UP036_0.py:97:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:97:8 | 96 | if True: 97 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 98 | 2 99 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 94 94 | pass @@ -363,16 +378,17 @@ UP036_0.py:97:8: UP036 [*] Version block is outdated for minimum Python version 102 99 | # comment 103 100 | -UP036_0.py:104:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:104:4 | 102 | # comment 103 | 104 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 105 | def f(): 106 | print("py2") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 101 101 | @@ -396,15 +412,16 @@ UP036_0.py:104:4: UP036 [*] Version block is outdated for minimum Python version 115 109 | if True: 116 110 | if sys.version_info > (3,): -UP036_0.py:116:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:116:8 | 115 | if True: 116 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 117 | print(3) 118 | # comment | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 113 113 | print("py3") @@ -417,15 +434,16 @@ UP036_0.py:116:8: UP036 [*] Version block is outdated for minimum Python version 119 118 | print(2+3) 120 119 | -UP036_0.py:122:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:122:8 | 121 | if True: 122 | if sys.version_info > (3,): print(3) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 123 | 124 | if True: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 119 119 | print(2+3) @@ -437,14 +455,15 @@ UP036_0.py:122:8: UP036 [*] Version block is outdated for minimum Python version 124 124 | if True: 125 125 | if sys.version_info > (3,): -UP036_0.py:125:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:125:8 | 124 | if True: 125 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 126 | print(3) | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 122 122 | if sys.version_info > (3,): print(3) @@ -457,15 +476,16 @@ UP036_0.py:125:8: UP036 [*] Version block is outdated for minimum Python version 128 127 | 129 128 | if True: -UP036_0.py:130:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:130:8 | 129 | if True: 130 | if sys.version_info <= (3, 0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 131 | expected_error = [] 132 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 127 127 | @@ -485,14 +505,15 @@ UP036_0.py:130:8: UP036 [*] Version block is outdated for minimum Python version 139 136 | 140 137 | if sys.version_info <= (3, 0): -UP036_0.py:140:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:140:4 | 140 | if sys.version_info <= (3, 0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 141 | expected_error = [] 142 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 137 137 | ] @@ -512,14 +533,15 @@ UP036_0.py:140:4: UP036 [*] Version block is outdated for minimum Python version 149 146 | 150 147 | if sys.version_info > (3,0): -UP036_0.py:150:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:150:4 | 150 | if sys.version_info > (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 151 | """this 152 | is valid""" | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 147 147 | ] @@ -546,15 +568,16 @@ UP036_0.py:150:4: UP036 [*] Version block is outdated for minimum Python version 163 162 | if sys.version_info > (3, 0): expected_error = \ 164 163 | [] -UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:163:4 | 161 | "this for some reason") 162 | 163 | if sys.version_info > (3, 0): expected_error = \ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 164 | [] | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 160 160 | ("so is" @@ -566,16 +589,17 @@ UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version 165 165 | 166 166 | if sys.version_info > (3, 0): expected_error = [] -UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:166:4 | 164 | [] 165 | 166 | if sys.version_info > (3, 0): expected_error = [] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 167 | 168 | if sys.version_info > (3, 0): \ | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 163 163 | if sys.version_info > (3, 0): expected_error = \ @@ -587,15 +611,16 @@ UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version 168 168 | if sys.version_info > (3, 0): \ 169 169 | expected_error = [] -UP036_0.py:168:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:168:4 | 166 | if sys.version_info > (3, 0): expected_error = [] 167 | 168 | if sys.version_info > (3, 0): \ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 169 | expected_error = [] | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 165 165 | @@ -608,14 +633,15 @@ UP036_0.py:168:4: UP036 [*] Version block is outdated for minimum Python version 171 170 | if True: 172 171 | if sys.version_info > (3, 0): expected_error = \ -UP036_0.py:172:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:172:8 | 171 | if True: 172 | if sys.version_info > (3, 0): expected_error = \ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 173 | [] | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 169 169 | expected_error = [] @@ -627,15 +653,16 @@ UP036_0.py:172:8: UP036 [*] Version block is outdated for minimum Python version 174 174 | 175 175 | if True: -UP036_0.py:176:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:176:8 | 175 | if True: 176 | if sys.version_info > (3, 0): expected_error = [] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 177 | 178 | if True: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 173 173 | [] @@ -647,14 +674,15 @@ UP036_0.py:176:8: UP036 [*] Version block is outdated for minimum Python version 178 178 | if True: 179 179 | if sys.version_info > (3, 0): \ -UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:179:8 | 178 | if True: 179 | if sys.version_info > (3, 0): \ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 180 | expected_error = [] | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 176 176 | if sys.version_info > (3, 0): expected_error = [] @@ -665,15 +693,16 @@ UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version 181 180 | 182 181 | if sys.version_info < (3,13): -UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:182:4 | 180 | expected_error = [] 181 | 182 | if sys.version_info < (3,13): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 183 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 179 179 | if sys.version_info > (3, 0): \ @@ -685,42 +714,46 @@ UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version 185 183 | if sys.version_info <= (3,13): 186 184 | print("py3") -UP036_0.py:191:24: UP036 Version specifier is invalid +UP036 Version specifier is invalid + --> UP036_0.py:191:24 | 189 | print("py3") 190 | 191 | if sys.version_info == 10000000: - | ^^^^^^^^ UP036 + | ^^^^^^^^ 192 | print("py3") | -UP036_0.py:194:23: UP036 Version specifier is invalid +UP036 Version specifier is invalid + --> UP036_0.py:194:23 | 192 | print("py3") 193 | 194 | if sys.version_info < (3,10000000): - | ^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^ 195 | print("py3") | -UP036_0.py:197:24: UP036 Version specifier is invalid +UP036 Version specifier is invalid + --> UP036_0.py:197:24 | 195 | print("py3") 196 | 197 | if sys.version_info <= (3,10000000): - | ^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^ 198 | print("py3") | -UP036_0.py:203:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:203:4 | 201 | print("py3") 202 | 203 | if sys.version_info >= (3,13): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 204 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 200 200 | if sys.version_info > (3,13): @@ -733,14 +766,15 @@ UP036_0.py:203:4: UP036 [*] Version block is outdated for minimum Python version 206 205 | # Slices on `sys.version_info` should be treated equivalently. 207 206 | if sys.version_info[:2] >= (3,0): -UP036_0.py:207:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:207:4 | 206 | # Slices on `sys.version_info` should be treated equivalently. 207 | if sys.version_info[:2] >= (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 208 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 204 204 | print("py3") @@ -753,15 +787,16 @@ UP036_0.py:207:4: UP036 [*] Version block is outdated for minimum Python version 210 209 | if sys.version_info[:3] >= (3,0): 211 210 | print("py3") -UP036_0.py:210:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:210:4 | 208 | print("py3") 209 | 210 | if sys.version_info[:3] >= (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 211 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 207 207 | if sys.version_info[:2] >= (3,0): @@ -774,16 +809,17 @@ UP036_0.py:210:4: UP036 [*] Version block is outdated for minimum Python version 213 212 | if sys.version_info[:2] > (3,14): 214 213 | print("py3") -UP036_0.py:219:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:219:4 | 217 | print("py3") 218 | 219 | if sys.version_info > (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 220 | f"this is\ 221 | allowed too" | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 216 216 | if sys.version_info[:3] > (3,14): @@ -804,15 +840,16 @@ UP036_0.py:219:4: UP036 [*] Version block is outdated for minimum Python version 228 227 | 229 228 | if sys.version_info[0] == 3: -UP036_0.py:229:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:229:4 | 227 | allowed too" 228 | 229 | if sys.version_info[0] == 3: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 230 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 226 226 | "this is\ @@ -825,15 +862,16 @@ UP036_0.py:229:4: UP036 [*] Version block is outdated for minimum Python version 232 231 | if sys.version_info[0] <= 3: 233 232 | print("py3") -UP036_0.py:232:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:232:4 | 230 | print("py3") 231 | 232 | if sys.version_info[0] <= 3: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 233 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 229 229 | if sys.version_info[0] == 3: @@ -846,15 +884,16 @@ UP036_0.py:232:4: UP036 [*] Version block is outdated for minimum Python version 235 234 | if sys.version_info[0] < 3: 236 235 | print("py3") -UP036_0.py:235:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:235:4 | 233 | print("py3") 234 | 235 | if sys.version_info[0] < 3: - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 236 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 232 232 | if sys.version_info[0] <= 3: @@ -866,15 +905,16 @@ UP036_0.py:235:4: UP036 [*] Version block is outdated for minimum Python version 238 236 | if sys.version_info[0] >= 3: 239 237 | print("py3") -UP036_0.py:238:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:238:4 | 236 | print("py3") 237 | 238 | if sys.version_info[0] >= 3: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 239 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 235 235 | if sys.version_info[0] < 3: @@ -887,15 +927,16 @@ UP036_0.py:238:4: UP036 [*] Version block is outdated for minimum Python version 241 240 | if sys.version_info[0] > 3: 242 241 | print("py3") -UP036_0.py:241:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:241:4 | 239 | print("py3") 240 | 241 | if sys.version_info[0] > 3: - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 242 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 238 238 | if sys.version_info[0] >= 3: @@ -907,15 +948,16 @@ UP036_0.py:241:4: UP036 [*] Version block is outdated for minimum Python version 244 242 | if sys.version_info[0] == 2: 245 243 | print("py3") -UP036_0.py:244:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:244:4 | 242 | print("py3") 243 | 244 | if sys.version_info[0] == 2: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 245 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 241 241 | if sys.version_info[0] > 3: @@ -927,15 +969,16 @@ UP036_0.py:244:4: UP036 [*] Version block is outdated for minimum Python version 247 245 | if sys.version_info[0] <= 2: 248 246 | print("py3") -UP036_0.py:247:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:247:4 | 245 | print("py3") 246 | 247 | if sys.version_info[0] <= 2: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 248 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 244 244 | if sys.version_info[0] == 2: @@ -947,15 +990,16 @@ UP036_0.py:247:4: UP036 [*] Version block is outdated for minimum Python version 250 248 | if sys.version_info[0] < 2: 251 249 | print("py3") -UP036_0.py:250:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:250:4 | 248 | print("py3") 249 | 250 | if sys.version_info[0] < 2: - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 251 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 247 247 | if sys.version_info[0] <= 2: @@ -967,15 +1011,16 @@ UP036_0.py:250:4: UP036 [*] Version block is outdated for minimum Python version 253 251 | if sys.version_info[0] >= 2: 254 252 | print("py3") -UP036_0.py:253:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:253:4 | 251 | print("py3") 252 | 253 | if sys.version_info[0] >= 2: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 254 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 250 250 | if sys.version_info[0] < 2: @@ -988,15 +1033,16 @@ UP036_0.py:253:4: UP036 [*] Version block is outdated for minimum Python version 256 255 | if sys.version_info[0] > 2: 257 256 | print("py3") -UP036_0.py:256:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_0.py:256:4 | 254 | print("py3") 255 | 256 | if sys.version_info[0] > 2: - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 257 | print("py3") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 253 253 | if sys.version_info[0] >= 2: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap index a7619f0825..312669b328 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP036_1.py:3:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:3:4 | 1 | import sys 2 | 3 | if sys.version_info == 2: - | ^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^ 4 | 2 5 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 1 1 | import sys @@ -24,16 +25,17 @@ UP036_1.py:3:4: UP036 [*] Version block is outdated for minimum Python version 8 5 | if sys.version_info < (3,): 9 6 | 2 -UP036_1.py:8:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:8:4 | 6 | 3 7 | 8 | if sys.version_info < (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 9 | 2 10 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 5 5 | else: @@ -48,16 +50,17 @@ UP036_1.py:8:4: UP036 [*] Version block is outdated for minimum Python version 13 10 | if sys.version_info < (3,0): 14 11 | 2 -UP036_1.py:13:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:13:4 | 11 | 3 12 | 13 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 2 15 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 10 10 | else: @@ -72,16 +75,17 @@ UP036_1.py:13:4: UP036 [*] Version block is outdated for minimum Python version 18 15 | if sys.version_info == 3: 19 16 | 3 -UP036_1.py:18:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:18:4 | 16 | 3 17 | 18 | if sys.version_info == 3: - | ^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^ 19 | 3 20 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 15 15 | else: @@ -96,16 +100,17 @@ UP036_1.py:18:4: UP036 [*] Version block is outdated for minimum Python version 23 20 | if sys.version_info > (3,): 24 21 | 3 -UP036_1.py:23:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:23:4 | 21 | 2 22 | 23 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 24 | 3 25 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 20 20 | else: @@ -120,16 +125,17 @@ UP036_1.py:23:4: UP036 [*] Version block is outdated for minimum Python version 28 25 | if sys.version_info >= (3,): 29 26 | 3 -UP036_1.py:28:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:28:4 | 26 | 2 27 | 28 | if sys.version_info >= (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 29 | 3 30 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 25 25 | else: @@ -144,16 +150,17 @@ UP036_1.py:28:4: UP036 [*] Version block is outdated for minimum Python version 33 30 | from sys import version_info 34 31 | -UP036_1.py:35:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:35:4 | 33 | from sys import version_info 34 | 35 | if version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^ 36 | 3 37 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 32 32 | @@ -168,16 +175,17 @@ UP036_1.py:35:4: UP036 [*] Version block is outdated for minimum Python version 40 37 | if True: 41 38 | print(1) -UP036_1.py:42:6: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:42:6 | 40 | if True: 41 | print(1) 42 | elif sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 43 | print(2) 44 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 39 39 | @@ -189,16 +197,17 @@ UP036_1.py:42:6: UP036 [*] Version block is outdated for minimum Python version 45 43 | print(3) 46 44 | -UP036_1.py:49:6: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:49:6 | 47 | if True: 48 | print(1) 49 | elif sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 50 | print(3) 51 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 46 46 | @@ -213,15 +222,16 @@ UP036_1.py:49:6: UP036 [*] Version block is outdated for minimum Python version 54 52 | if True: 55 53 | print(1) -UP036_1.py:56:6: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:56:6 | 54 | if True: 55 | print(1) 56 | elif sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 57 | print(3) | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 53 53 | @@ -233,15 +243,16 @@ UP036_1.py:56:6: UP036 [*] Version block is outdated for minimum Python version 58 58 | 59 59 | def f(): -UP036_1.py:62:10: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:62:10 | 60 | if True: 61 | print(1) 62 | elif sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 63 | print(3) | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 59 59 | def f(): @@ -253,16 +264,17 @@ UP036_1.py:62:10: UP036 [*] Version block is outdated for minimum Python version 64 64 | 65 65 | if True: -UP036_1.py:67:6: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:67:6 | 65 | if True: 66 | print(1) 67 | elif sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 68 | print(2) 69 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 64 64 | @@ -274,15 +286,16 @@ UP036_1.py:67:6: UP036 [*] Version block is outdated for minimum Python version 70 68 | print(3) 71 69 | -UP036_1.py:75:10: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_1.py:75:10 | 73 | if True: 74 | print(1) 75 | elif sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 76 | print(3) | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 72 72 | def f(): diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap index b5d6a7e33a..32373c23a6 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP036_2.py:4:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:4:4 | 2 | from sys import version_info 3 | 4 | if sys.version_info > (3, 5): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | 3+6 6 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 1 1 | import sys @@ -25,16 +26,17 @@ UP036_2.py:4:4: UP036 [*] Version block is outdated for minimum Python version 9 6 | if version_info > (3, 5): 10 7 | 3+6 -UP036_2.py:9:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:9:4 | 7 | 3-5 8 | 9 | if version_info > (3, 5): - | ^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | 3+6 11 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 6 6 | else: @@ -49,16 +51,17 @@ UP036_2.py:9:4: UP036 [*] Version block is outdated for minimum Python version 14 11 | if sys.version_info >= (3,6): 15 12 | 3+6 -UP036_2.py:14:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:14:4 | 12 | 3-5 13 | 14 | if sys.version_info >= (3,6): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 3+6 16 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 11 11 | else: @@ -73,16 +76,17 @@ UP036_2.py:14:4: UP036 [*] Version block is outdated for minimum Python version 19 16 | if version_info >= (3,6): 20 17 | 3+6 -UP036_2.py:19:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:19:4 | 17 | 3-5 18 | 19 | if version_info >= (3,6): - | ^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^ 20 | 3+6 21 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 16 16 | else: @@ -97,16 +101,17 @@ UP036_2.py:19:4: UP036 [*] Version block is outdated for minimum Python version 24 21 | if sys.version_info < (3,6): 25 22 | 3-5 -UP036_2.py:24:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:24:4 | 22 | 3-5 23 | 24 | if sys.version_info < (3,6): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 25 | 3-5 26 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 21 21 | else: @@ -121,16 +126,17 @@ UP036_2.py:24:4: UP036 [*] Version block is outdated for minimum Python version 29 26 | if sys.version_info <= (3,5): 30 27 | 3-5 -UP036_2.py:29:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:29:4 | 27 | 3+6 28 | 29 | if sys.version_info <= (3,5): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | 3-5 31 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 26 26 | else: @@ -145,16 +151,17 @@ UP036_2.py:29:4: UP036 [*] Version block is outdated for minimum Python version 34 31 | if sys.version_info <= (3, 5): 35 32 | 3-5 -UP036_2.py:34:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:34:4 | 32 | 3+6 33 | 34 | if sys.version_info <= (3, 5): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 3-5 36 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 31 31 | else: @@ -169,15 +176,16 @@ UP036_2.py:34:4: UP036 [*] Version block is outdated for minimum Python version 39 36 | if sys.version_info >= (3, 5): 40 37 | pass -UP036_2.py:39:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:39:4 | 37 | 3+6 38 | 39 | if sys.version_info >= (3, 5): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | pass | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 36 36 | else: @@ -190,15 +198,16 @@ UP036_2.py:39:4: UP036 [*] Version block is outdated for minimum Python version 42 41 | if sys.version_info < (3,0): 43 42 | pass -UP036_2.py:42:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:42:4 | 40 | pass 41 | 42 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 43 | pass | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 39 39 | if sys.version_info >= (3, 5): @@ -210,14 +219,15 @@ UP036_2.py:42:4: UP036 [*] Version block is outdated for minimum Python version 45 43 | if True: 46 44 | if sys.version_info < (3,0): -UP036_2.py:46:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:46:8 | 45 | if True: 46 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 47 | pass | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 43 43 | pass @@ -230,16 +240,17 @@ UP036_2.py:46:8: UP036 [*] Version block is outdated for minimum Python version 49 48 | if sys.version_info < (3,0): 50 49 | pass -UP036_2.py:49:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:49:4 | 47 | pass 48 | 49 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 50 | pass 51 | elif False: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 46 46 | if sys.version_info < (3,0): @@ -253,16 +264,17 @@ UP036_2.py:49:4: UP036 [*] Version block is outdated for minimum Python version 53 51 | 54 52 | if sys.version_info > (3,): -UP036_2.py:54:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_2.py:54:4 | 52 | pass 53 | 54 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^ 55 | pass 56 | elif False: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 51 51 | elif False: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap index 8b68445648..82ac0fd9ce 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP036_3.py:3:15: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_3.py:3:15 | 1 | import sys 2 | 3 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 4 | print("py2") 5 | for item in range(10): | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 1 1 | import sys @@ -30,15 +31,16 @@ UP036_3.py:3:15: UP036 [*] Version block is outdated for minimum Python version 12 7 | if False: 13 8 | if sys.version_info < (3,0): -UP036_3.py:13:19: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_3.py:13:19 | 12 | if False: 13 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 14 | print("py2") 15 | for item in range(10): | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 10 10 | print(f"PY3-{item}") @@ -59,13 +61,14 @@ UP036_3.py:13:19: UP036 [*] Version block is outdated for minimum Python version 22 17 | 23 18 | if sys.version_info < (3,0): print("PY2!") -UP036_3.py:23:15: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_3.py:23:15 | 23 | if sys.version_info < (3,0): print("PY2!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 24 | else : print("PY3!") | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 20 20 | print(f"PY3-{item}") diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap index fb13811cfe..37041671bc 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP036_4.py:4:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_4.py:4:8 | 3 | if True: 4 | if sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | cmd = [sys.executable, "-m", "test.regrtest"] | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 1 1 | import sys @@ -21,15 +22,16 @@ UP036_4.py:4:8: UP036 [*] Version block is outdated for minimum Python version 7 6 | 8 7 | if True: -UP036_4.py:11:10: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_4.py:11:10 | 9 | if foo: 10 | print() 11 | elif sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | cmd = [sys.executable, "-m", "test.regrtest"] | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 8 8 | if True: @@ -42,16 +44,17 @@ UP036_4.py:11:10: UP036 [*] Version block is outdated for minimum Python version 14 13 | if True: 15 14 | if foo: -UP036_4.py:17:10: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_4.py:17:10 | 15 | if foo: 16 | print() 17 | elif sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | cmd = [sys.executable, "-m", "test.regrtest"] 19 | elif foo: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 14 14 | if True: @@ -63,15 +66,16 @@ UP036_4.py:17:10: UP036 [*] Version block is outdated for minimum Python version 20 18 | cmd = [sys.executable, "-m", "test", "-j0"] 21 19 | -UP036_4.py:24:10: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_4.py:24:10 | 22 | if foo: 23 | print() 24 | elif sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | cmd = [sys.executable, "-m", "test.regrtest"] | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 21 21 | @@ -84,15 +88,16 @@ UP036_4.py:24:10: UP036 [*] Version block is outdated for minimum Python version 27 26 | if sys.version_info < (3, 3): 28 27 | cmd = [sys.executable, "-m", "test.regrtest"] -UP036_4.py:27:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_4.py:27:8 | 25 | cmd = [sys.executable, "-m", "test.regrtest"] 26 | 27 | if sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | cmd = [sys.executable, "-m", "test.regrtest"] | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 24 24 | elif sys.version_info < (3, 3): @@ -104,16 +109,17 @@ UP036_4.py:27:8: UP036 [*] Version block is outdated for minimum Python version 30 28 | if foo: 31 29 | print() -UP036_4.py:32:10: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_4.py:32:10 | 30 | if foo: 31 | print() 32 | elif sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | cmd = [sys.executable, "-m", "test.regrtest"] 34 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 29 29 | @@ -125,16 +131,17 @@ UP036_4.py:32:10: UP036 [*] Version block is outdated for minimum Python version 35 33 | cmd = [sys.executable, "-m", "test", "-j0"] 36 34 | -UP036_4.py:37:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_4.py:37:8 | 35 | cmd = [sys.executable, "-m", "test", "-j0"] 36 | 37 | if sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | cmd = [sys.executable, "-m", "test.regrtest"] 39 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 34 34 | else: @@ -149,16 +156,17 @@ UP036_4.py:37:8: UP036 [*] Version block is outdated for minimum Python version 42 39 | if sys.version_info < (3, 3): 43 40 | cmd = [sys.executable, "-m", "test.regrtest"] -UP036_4.py:42:8: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_4.py:42:8 | 40 | cmd = [sys.executable, "-m", "test", "-j0"] 41 | 42 | if sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | cmd = [sys.executable, "-m", "test.regrtest"] 44 | elif foo: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 39 39 | else: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap index b1c24a6ba9..5e9addf542 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP036_5.py:3:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:3:4 | 1 | import sys 2 | 3 | if sys.version_info < (3, 8): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | def a(): | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 1 1 | import sys @@ -31,15 +32,16 @@ UP036_5.py:3:4: UP036 [*] Version block is outdated for minimum Python version 15 5 | 16 6 | import sys -UP036_5.py:18:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:18:4 | 16 | import sys 17 | 18 | if sys.version_info < (3, 8): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | pass | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 15 15 | @@ -70,14 +72,15 @@ UP036_5.py:18:4: UP036 [*] Version block is outdated for minimum Python version 32 27 | 33 28 | # https://github.com/astral-sh/ruff/issues/16082 -UP036_5.py:36:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:36:4 | 35 | ## Errors 36 | if sys.version_info < (3, 12, 0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | print() | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 33 33 | # https://github.com/astral-sh/ruff/issues/16082 @@ -89,15 +92,16 @@ UP036_5.py:36:4: UP036 [*] Version block is outdated for minimum Python version 39 37 | if sys.version_info <= (3, 12, 0): 40 38 | print() -UP036_5.py:39:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:39:4 | 37 | print() 38 | 39 | if sys.version_info <= (3, 12, 0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | print() | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 36 36 | if sys.version_info < (3, 12, 0): @@ -109,15 +113,16 @@ UP036_5.py:39:4: UP036 [*] Version block is outdated for minimum Python version 42 40 | if sys.version_info < (3, 12, 11): 43 41 | print() -UP036_5.py:42:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:42:4 | 40 | print() 41 | 42 | if sys.version_info < (3, 12, 11): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | print() | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 39 39 | if sys.version_info <= (3, 12, 0): @@ -129,15 +134,16 @@ UP036_5.py:42:4: UP036 [*] Version block is outdated for minimum Python version 45 43 | if sys.version_info < (3, 13, 0): 46 44 | print() -UP036_5.py:45:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:45:4 | 43 | print() 44 | 45 | if sys.version_info < (3, 13, 0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | print() | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 42 42 | if sys.version_info < (3, 12, 11): @@ -149,25 +155,27 @@ UP036_5.py:45:4: UP036 [*] Version block is outdated for minimum Python version 48 46 | if sys.version_info <= (3, 13, 100000): 49 47 | print() -UP036_5.py:48:24: UP036 Version specifier is invalid +UP036 Version specifier is invalid + --> UP036_5.py:48:24 | 46 | print() 47 | 48 | if sys.version_info <= (3, 13, 100000): - | ^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^ 49 | print() | -UP036_5.py:77:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:77:4 | 75 | # https://github.com/astral-sh/ruff/issues/18165 76 | 77 | if sys.version_info.major >= 3: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 78 | print("3") 79 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 74 74 | @@ -182,16 +190,17 @@ UP036_5.py:77:4: UP036 [*] Version block is outdated for minimum Python version 82 79 | if sys.version_info.major > 3: 83 80 | print("3") -UP036_5.py:82:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:82:4 | 80 | print("2") 81 | 82 | if sys.version_info.major > 3: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 83 | print("3") 84 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 79 79 | else: @@ -206,16 +215,17 @@ UP036_5.py:82:4: UP036 [*] Version block is outdated for minimum Python version 87 84 | if sys.version_info.major <= 3: 88 85 | print("3") -UP036_5.py:87:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:87:4 | 85 | print("2") 86 | 87 | if sys.version_info.major <= 3: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 88 | print("3") 89 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 84 84 | else: @@ -230,16 +240,17 @@ UP036_5.py:87:4: UP036 [*] Version block is outdated for minimum Python version 92 89 | if sys.version_info.major < 3: 93 90 | print("3") -UP036_5.py:92:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:92:4 | 90 | print("2") 91 | 92 | if sys.version_info.major < 3: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 93 | print("3") 94 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 89 89 | else: @@ -254,16 +265,17 @@ UP036_5.py:92:4: UP036 [*] Version block is outdated for minimum Python version 97 94 | if sys.version_info.major == 3: 98 95 | print("3") -UP036_5.py:97:4: UP036 [*] Version block is outdated for minimum Python version +UP036 [*] Version block is outdated for minimum Python version + --> UP036_5.py:97:4 | 95 | print("2") 96 | 97 | if sys.version_info.major == 3: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 98 | print("3") 99 | else: | - = help: Remove outdated version block +help: Remove outdated version block ℹ Unsafe fix 94 94 | else: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap index 2549736148..2c67e9da5a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_0.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP037_0.py:18:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:18:14 | 18 | def foo(var: "MyClass") -> "MyClass": - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ 19 | x: "MyClass" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg @@ -19,13 +20,14 @@ UP037_0.py:18:14: UP037 [*] Remove quotes from type annotation 20 20 | 21 21 | -UP037_0.py:18:28: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:18:28 | 18 | def foo(var: "MyClass") -> "MyClass": - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ 19 | x: "MyClass" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg @@ -37,13 +39,14 @@ UP037_0.py:18:28: UP037 [*] Remove quotes from type annotation 20 20 | 21 21 | -UP037_0.py:19:8: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:19:8 | 18 | def foo(var: "MyClass") -> "MyClass": 19 | x: "MyClass" - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 16 16 | @@ -55,13 +58,14 @@ UP037_0.py:19:8: UP037 [*] Remove quotes from type annotation 21 21 | 22 22 | def foo(*, inplace: "bool"): -UP037_0.py:22:21: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:22:21 | 22 | def foo(*, inplace: "bool"): - | ^^^^^^ UP037 + | ^^^^^^ 23 | pass | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 19 19 | x: "MyClass" @@ -73,13 +77,14 @@ UP037_0.py:22:21: UP037 [*] Remove quotes from type annotation 24 24 | 25 25 | -UP037_0.py:26:16: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:26:16 | 26 | def foo(*args: "str", **kwargs: "int"): - | ^^^^^ UP037 + | ^^^^^ 27 | pass | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 23 23 | pass @@ -91,13 +96,14 @@ UP037_0.py:26:16: UP037 [*] Remove quotes from type annotation 28 28 | 29 29 | -UP037_0.py:26:33: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:26:33 | 26 | def foo(*args: "str", **kwargs: "int"): - | ^^^^^ UP037 + | ^^^^^ 27 | pass | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 23 23 | pass @@ -109,14 +115,15 @@ UP037_0.py:26:33: UP037 [*] Remove quotes from type annotation 28 28 | 29 29 | -UP037_0.py:30:10: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:30:10 | 30 | x: Tuple["MyClass"] - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ 31 | 32 | x: Callable[["MyClass"], None] | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 27 27 | pass @@ -128,14 +135,15 @@ UP037_0.py:30:10: UP037 [*] Remove quotes from type annotation 32 32 | x: Callable[["MyClass"], None] 33 33 | -UP037_0.py:32:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:32:14 | 30 | x: Tuple["MyClass"] 31 | 32 | x: Callable[["MyClass"], None] - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 29 29 | @@ -147,13 +155,14 @@ UP037_0.py:32:14: UP037 [*] Remove quotes from type annotation 34 34 | 35 35 | class Foo(NamedTuple): -UP037_0.py:36:8: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:36:8 | 35 | class Foo(NamedTuple): 36 | x: "MyClass" - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 33 33 | @@ -165,13 +174,14 @@ UP037_0.py:36:8: UP037 [*] Remove quotes from type annotation 38 38 | 39 39 | class D(TypedDict): -UP037_0.py:40:27: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:40:27 | 39 | class D(TypedDict): 40 | E: TypedDict("E", foo="int", total=False) - | ^^^^^ UP037 + | ^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 37 37 | @@ -183,13 +193,14 @@ UP037_0.py:40:27: UP037 [*] Remove quotes from type annotation 42 42 | 43 43 | class D(TypedDict): -UP037_0.py:44:31: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:44:31 | 43 | class D(TypedDict): 44 | E: TypedDict("E", {"foo": "int"}) - | ^^^^^ UP037 + | ^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 41 41 | @@ -201,14 +212,15 @@ UP037_0.py:44:31: UP037 [*] Remove quotes from type annotation 46 46 | 47 47 | x: Annotated["str", "metadata"] -UP037_0.py:47:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:47:14 | 47 | x: Annotated["str", "metadata"] - | ^^^^^ UP037 + | ^^^^^ 48 | 49 | x: Arg("str", "name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 44 44 | E: TypedDict("E", {"foo": "int"}) @@ -220,16 +232,17 @@ UP037_0.py:47:14: UP037 [*] Remove quotes from type annotation 49 49 | x: Arg("str", "name") 50 50 | -UP037_0.py:49:8: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:49:8 | 47 | x: Annotated["str", "metadata"] 48 | 49 | x: Arg("str", "name") - | ^^^^^ UP037 + | ^^^^^ 50 | 51 | x: DefaultArg("str", "name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 46 46 | @@ -241,16 +254,17 @@ UP037_0.py:49:8: UP037 [*] Remove quotes from type annotation 51 51 | x: DefaultArg("str", "name") 52 52 | -UP037_0.py:51:15: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:51:15 | 49 | x: Arg("str", "name") 50 | 51 | x: DefaultArg("str", "name") - | ^^^^^ UP037 + | ^^^^^ 52 | 53 | x: NamedArg("str", "name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 48 48 | @@ -262,16 +276,17 @@ UP037_0.py:51:15: UP037 [*] Remove quotes from type annotation 53 53 | x: NamedArg("str", "name") 54 54 | -UP037_0.py:53:13: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:53:13 | 51 | x: DefaultArg("str", "name") 52 | 53 | x: NamedArg("str", "name") - | ^^^^^ UP037 + | ^^^^^ 54 | 55 | x: DefaultNamedArg("str", "name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 50 50 | @@ -283,16 +298,17 @@ UP037_0.py:53:13: UP037 [*] Remove quotes from type annotation 55 55 | x: DefaultNamedArg("str", "name") 56 56 | -UP037_0.py:55:20: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:55:20 | 53 | x: NamedArg("str", "name") 54 | 55 | x: DefaultNamedArg("str", "name") - | ^^^^^ UP037 + | ^^^^^ 56 | 57 | x: DefaultNamedArg("str", name="name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 52 52 | @@ -304,16 +320,17 @@ UP037_0.py:55:20: UP037 [*] Remove quotes from type annotation 57 57 | x: DefaultNamedArg("str", name="name") 58 58 | -UP037_0.py:57:20: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:57:20 | 55 | x: DefaultNamedArg("str", "name") 56 | 57 | x: DefaultNamedArg("str", name="name") - | ^^^^^ UP037 + | ^^^^^ 58 | 59 | x: VarArg("str") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 54 54 | @@ -325,16 +342,17 @@ UP037_0.py:57:20: UP037 [*] Remove quotes from type annotation 59 59 | x: VarArg("str") 60 60 | -UP037_0.py:59:11: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:59:11 | 57 | x: DefaultNamedArg("str", name="name") 58 | 59 | x: VarArg("str") - | ^^^^^ UP037 + | ^^^^^ 60 | 61 | x: List[List[List["MyClass"]]] | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 56 56 | @@ -346,16 +364,17 @@ UP037_0.py:59:11: UP037 [*] Remove quotes from type annotation 61 61 | x: List[List[List["MyClass"]]] 62 62 | -UP037_0.py:61:19: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:61:19 | 59 | x: VarArg("str") 60 | 61 | x: List[List[List["MyClass"]]] - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ 62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 58 58 | @@ -367,16 +386,17 @@ UP037_0.py:61:19: UP037 [*] Remove quotes from type annotation 63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 64 | -UP037_0.py:63:29: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:63:29 | 61 | x: List[List[List["MyClass"]]] 62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 60 60 | @@ -388,16 +408,17 @@ UP037_0.py:63:29: UP037 [*] Remove quotes from type annotation 65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 66 | -UP037_0.py:63:45: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:63:45 | 61 | x: List[List[List["MyClass"]]] 62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 60 60 | @@ -409,16 +430,17 @@ UP037_0.py:63:45: UP037 [*] Remove quotes from type annotation 65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 66 | -UP037_0.py:65:29: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:65:29 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 62 62 | @@ -430,16 +452,17 @@ UP037_0.py:65:29: UP037 [*] Remove quotes from type annotation 67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) 68 68 | -UP037_0.py:65:36: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:65:36 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 62 62 | @@ -451,16 +474,17 @@ UP037_0.py:65:36: UP037 [*] Remove quotes from type annotation 67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) 68 68 | -UP037_0.py:65:45: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:65:45 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 62 62 | @@ -472,16 +496,17 @@ UP037_0.py:65:45: UP037 [*] Remove quotes from type annotation 67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) 68 68 | -UP037_0.py:65:52: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:65:52 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 62 62 | @@ -493,16 +518,17 @@ UP037_0.py:65:52: UP037 [*] Remove quotes from type annotation 67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) 68 68 | -UP037_0.py:67:24: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:67:24 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^ UP037 + | ^^^ 68 | 69 | X: MyCallable("X") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 64 64 | @@ -514,16 +540,17 @@ UP037_0.py:67:24: UP037 [*] Remove quotes from type annotation 69 69 | X: MyCallable("X") 70 70 | -UP037_0.py:67:38: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:67:38 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^^^ UP037 + | ^^^^^ 68 | 69 | X: MyCallable("X") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 64 64 | @@ -535,16 +562,17 @@ UP037_0.py:67:38: UP037 [*] Remove quotes from type annotation 69 69 | X: MyCallable("X") 70 70 | -UP037_0.py:67:45: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:67:45 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^^^ UP037 + | ^^^^^ 68 | 69 | X: MyCallable("X") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 64 64 | @@ -556,15 +584,16 @@ UP037_0.py:67:45: UP037 [*] Remove quotes from type annotation 69 69 | X: MyCallable("X") 70 70 | -UP037_0.py:112:12: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:112:12 | 110 | # Handle end of line comment in string annotation 111 | # See https://github.com/astral-sh/ruff/issues/15816 112 | def f() -> "Literal[0]#": - | ^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^ 113 | return 0 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 109 109 | @@ -577,15 +606,16 @@ UP037_0.py:112:12: UP037 [*] Remove quotes from type annotation 114 115 | 115 116 | def g(x: "Literal['abc']#") -> None: -UP037_0.py:115:10: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:115:10 | 113 | return 0 114 | 115 | def g(x: "Literal['abc']#") -> None: - | ^^^^^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^^^^^ 116 | return | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 112 112 | def f() -> "Literal[0]#": @@ -598,7 +628,8 @@ UP037_0.py:115:10: UP037 [*] Remove quotes from type annotation 117 118 | 118 119 | def f() -> """Literal[0] -UP037_0.py:118:12: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:118:12 | 116 | return 117 | @@ -607,10 +638,10 @@ UP037_0.py:118:12: UP037 [*] Remove quotes from type annotation 119 | | # 120 | | 121 | | """: - | |_______^ UP037 + | |_______^ 122 | return 0 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 115 115 | def g(x: "Literal['abc']#") -> None: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_1.py.snap index 63db5a46b1..ce3ac81a13 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_1.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP037_1.py:9:8: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_1.py:9:8 | 7 | def foo(): 8 | # UP037 9 | x: "Tuple[int, int]" = (0, 0) - | ^^^^^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^^^^^ 10 | print(x) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 6 6 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_2.pyi.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_2.pyi.snap index dd66f98b51..e10f3761d3 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_2.pyi.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037_2.pyi.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP037_2.pyi:3:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:3:14 | 1 | # https://github.com/astral-sh/ruff/issues/7102 2 | 3 | def f(a: Foo['SingleLine # Comment']): ... - | ^^^^^^^^^^^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 1 1 | # https://github.com/astral-sh/ruff/issues/7102 @@ -20,15 +21,16 @@ UP037_2.pyi:3:14: UP037 [*] Remove quotes from type annotation 5 6 | 6 7 | def f(a: Foo['''Bar[ -UP037_2.pyi:6:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:6:14 | 6 | def f(a: Foo['''Bar[ | ______________^ 7 | | Multi | 8 | | Line]''']): ... - | |____________^ UP037 + | |____________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 3 3 | def f(a: Foo['SingleLine # Comment']): ... @@ -43,16 +45,17 @@ UP037_2.pyi:6:14: UP037 [*] Remove quotes from type annotation 10 10 | 11 11 | def f(a: Foo['''Bar[ -UP037_2.pyi:11:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:11:14 | 11 | def f(a: Foo['''Bar[ | ______________^ 12 | | Multi | 13 | | Line # Comment 14 | | ]''']): ... - | |____^ UP037 + | |____^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 8 8 | Line]''']): ... @@ -68,15 +71,16 @@ UP037_2.pyi:11:14: UP037 [*] Remove quotes from type annotation 16 16 | 17 17 | def f(a: Foo['''Bar[ -UP037_2.pyi:17:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:17:14 | 17 | def f(a: Foo['''Bar[ | ______________^ 18 | | Multi | 19 | | Line] # Comment''']): ... - | |_______________________^ UP037 + | |_______________________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 14 14 | ]''']): ... @@ -92,16 +96,17 @@ UP037_2.pyi:17:14: UP037 [*] Remove quotes from type annotation 21 22 | 22 23 | def f(a: Foo[''' -UP037_2.pyi:22:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:22:14 | 22 | def f(a: Foo[''' | ______________^ 23 | | Bar[ 24 | | Multi | 25 | | Line] # Comment''']): ... - | |_______________________^ UP037 + | |_______________________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 19 19 | Line] # Comment''']): ... @@ -118,14 +123,15 @@ UP037_2.pyi:22:14: UP037 [*] Remove quotes from type annotation 27 28 | 28 29 | def f(a: '''list[int] -UP037_2.pyi:28:10: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:28:10 | 28 | def f(a: '''list[int] | __________^ 29 | | ''' = []): ... - | |_______^ UP037 + | |_______^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 25 25 | Line] # Comment''']): ... @@ -139,14 +145,15 @@ UP037_2.pyi:28:10: UP037 [*] Remove quotes from type annotation 31 31 | 32 32 | a: '''\\ -UP037_2.pyi:32:4: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:32:4 | 32 | a: '''\\ | ____^ 33 | | list[int]''' = [42] - | |____________^ UP037 + | |____________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 29 29 | ''' = []): ... @@ -160,15 +167,16 @@ UP037_2.pyi:32:4: UP037 [*] Remove quotes from type annotation 35 35 | 36 36 | def f(a: ''' -UP037_2.pyi:36:10: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:36:10 | 36 | def f(a: ''' | __________^ 37 | | list[int] 38 | | ''' = []): ... - | |_______^ UP037 + | |_______^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 33 33 | list[int]''' = [42] @@ -183,7 +191,8 @@ UP037_2.pyi:36:10: UP037 [*] Remove quotes from type annotation 40 40 | 41 41 | def f(a: Foo[''' -UP037_2.pyi:41:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:41:14 | 41 | def f(a: Foo[''' | ______________^ @@ -192,9 +201,9 @@ UP037_2.pyi:41:14: UP037 [*] Remove quotes from type annotation 44 | | Multi | 45 | | Line 46 | | ] # Comment''']): ... - | |___________________^ UP037 + | |___________________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 38 38 | ''' = []): ... @@ -213,14 +222,15 @@ UP037_2.pyi:41:14: UP037 [*] Remove quotes from type annotation 48 49 | 49 50 | a: '''list -UP037_2.pyi:49:4: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:49:4 | 49 | a: '''list | ____^ 50 | | [int]''' = [42] - | |________^ UP037 + | |________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 46 46 | ] # Comment''']): ... diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap index 83bd5dbd1f..35ad47f599 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP038.py:1:1: UP038 [*] Use `X | Y` in `isinstance` call instead of `(X, Y)` +UP038 [*] Use `X | Y` in `isinstance` call instead of `(X, Y)` + --> UP038.py:1:1 | 1 | isinstance(1, (int, float)) # UP038 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | issubclass("yes", (int, float, str)) # UP038 | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Unsafe fix 1 |-isinstance(1, (int, float)) # UP038 @@ -16,15 +17,16 @@ UP038.py:1:1: UP038 [*] Use `X | Y` in `isinstance` call instead of `(X, Y)` 3 3 | 4 4 | isinstance(1, int) # OK -UP038.py:2:1: UP038 [*] Use `X | Y` in `issubclass` call instead of `(X, Y)` +UP038 [*] Use `X | Y` in `issubclass` call instead of `(X, Y)` + --> UP038.py:2:1 | 1 | isinstance(1, (int, float)) # UP038 2 | issubclass("yes", (int, float, str)) # UP038 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 | 4 | isinstance(1, int) # OK | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Unsafe fix 1 1 | isinstance(1, (int, float)) # UP038 diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap index 66a8284139..0d83d4c92b 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP039.py:2:8: UP039 [*] Unnecessary parentheses after class definition +UP039 [*] Unnecessary parentheses after class definition + --> UP039.py:2:8 | 1 | # Errors 2 | class A(): - | ^^ UP039 + | ^^ 3 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 1 1 | # Errors @@ -19,14 +19,15 @@ UP039.py:2:8: UP039 [*] Unnecessary parentheses after class definition 4 4 | 5 5 | -UP039.py:6:8: UP039 [*] Unnecessary parentheses after class definition +UP039 [*] Unnecessary parentheses after class definition + --> UP039.py:6:8 | 6 | class A() \ - | ^^ UP039 + | ^^ 7 | : 8 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 3 3 | pass @@ -38,14 +39,15 @@ UP039.py:6:8: UP039 [*] Unnecessary parentheses after class definition 8 8 | pass 9 9 | -UP039.py:12:9: UP039 [*] Unnecessary parentheses after class definition +UP039 [*] Unnecessary parentheses after class definition + --> UP039.py:12:9 | 11 | class A \ 12 | (): - | ^^ UP039 + | ^^ 13 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 9 9 | @@ -57,14 +59,15 @@ UP039.py:12:9: UP039 [*] Unnecessary parentheses after class definition 14 14 | 15 15 | -UP039.py:17:8: UP039 [*] Unnecessary parentheses after class definition +UP039 [*] Unnecessary parentheses after class definition + --> UP039.py:17:8 | 16 | @decorator() 17 | class A(): - | ^^ UP039 + | ^^ 18 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 14 14 | @@ -76,14 +79,15 @@ UP039.py:17:8: UP039 [*] Unnecessary parentheses after class definition 19 19 | 20 20 | @decorator -UP039.py:21:8: UP039 [*] Unnecessary parentheses after class definition +UP039 [*] Unnecessary parentheses after class definition + --> UP039.py:21:8 | 20 | @decorator 21 | class A(): - | ^^ UP039 + | ^^ 22 | pass | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 18 18 | pass diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap index 1c5818c218..55601e0651 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP040.py:5:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:5:1 | 4 | # UP040 5 | x: typing.TypeAlias = int - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | x: TypeAlias = int | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 2 2 | from typing import Any, TypeAlias @@ -20,16 +21,17 @@ UP040.py:5:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of th 7 7 | 8 8 | # UP040 simple generic -UP040.py:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:6:1 | 4 | # UP040 5 | x: typing.TypeAlias = int 6 | x: TypeAlias = int - | ^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^ 7 | 8 | # UP040 simple generic | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 3 3 | @@ -41,16 +43,17 @@ UP040.py:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of th 8 8 | # UP040 simple generic 9 9 | T = typing.TypeVar["T"] -UP040.py:10:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:10:1 | 8 | # UP040 simple generic 9 | T = typing.TypeVar["T"] 10 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | # UP040 call style generic | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 7 7 | @@ -62,16 +65,17 @@ UP040.py:10:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 12 12 | # UP040 call style generic 13 13 | T = typing.TypeVar("T") -UP040.py:14:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:14:1 | 12 | # UP040 call style generic 13 | T = typing.TypeVar("T") 14 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | # UP040 bounded generic | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 11 11 | @@ -83,16 +87,17 @@ UP040.py:14:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 16 16 | # UP040 bounded generic 17 17 | T = typing.TypeVar("T", bound=int) -UP040.py:18:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:18:1 | 16 | # UP040 bounded generic 17 | T = typing.TypeVar("T", bound=int) 18 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # UP040 constrained generic | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 15 15 | @@ -104,16 +109,17 @@ UP040.py:18:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 20 20 | # UP040 constrained generic 21 21 | T = typing.TypeVar("T", int, str) -UP040.py:22:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:22:1 | 20 | # UP040 constrained generic 21 | T = typing.TypeVar("T", int, str) 22 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | # UP040 contravariant generic | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 19 19 | @@ -125,16 +131,17 @@ UP040.py:22:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 24 24 | # UP040 contravariant generic 25 25 | T = typing.TypeVar("T", contravariant=True) -UP040.py:26:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:26:1 | 24 | # UP040 contravariant generic 25 | T = typing.TypeVar("T", contravariant=True) 26 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | # UP040 covariant generic | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 23 23 | @@ -146,16 +153,17 @@ UP040.py:26:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 28 28 | # UP040 covariant generic 29 29 | T = typing.TypeVar("T", covariant=True) -UP040.py:30:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:30:1 | 28 | # UP040 covariant generic 29 | T = typing.TypeVar("T", covariant=True) 30 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | 32 | # UP040 in class scope | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 27 27 | @@ -167,16 +175,17 @@ UP040.py:30:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 32 32 | # UP040 in class scope 33 33 | T = typing.TypeVar["T"] -UP040.py:36:5: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:36:5 | 34 | class Foo: 35 | # reference to global variable 36 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | 38 | # reference to class variable | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 33 33 | T = typing.TypeVar["T"] @@ -188,16 +197,17 @@ UP040.py:36:5: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 38 38 | # reference to class variable 39 39 | TCLS = typing.TypeVar["TCLS"] -UP040.py:40:5: UP040 [*] Type alias `y` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `y` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:40:5 | 38 | # reference to class variable 39 | TCLS = typing.TypeVar["TCLS"] 40 | y: typing.TypeAlias = list[TCLS] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | 42 | # UP040 won't add generics in fix | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 37 37 | @@ -209,16 +219,17 @@ UP040.py:40:5: UP040 [*] Type alias `y` uses `TypeAlias` annotation instead of t 42 42 | # UP040 won't add generics in fix 43 43 | T = typing.TypeVar(*args) -UP040.py:44:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:44:1 | 42 | # UP040 won't add generics in fix 43 | T = typing.TypeVar(*args) 44 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | 46 | # `default` should be skipped for now, added in Python 3.13 | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 41 41 | @@ -230,14 +241,15 @@ UP040.py:44:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 46 46 | # `default` should be skipped for now, added in Python 3.13 47 47 | T = typing.TypeVar("T", default=Any) -UP040.py:57:1: UP040 [*] Type alias `Decorator` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `Decorator` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:57:1 | 55 | # type alias. 56 | T = typing.TypeVar["T"] 57 | Decorator: TypeAlias = typing.Callable[[T], T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 54 54 | # Ensure that "T" appears only once in the type parameters for the modernized @@ -249,18 +261,19 @@ UP040.py:57:1: UP040 [*] Type alias `Decorator` uses `TypeAlias` annotation inst 59 59 | 60 60 | from typing import TypeVar, Annotated, TypeAliasType -UP040.py:67:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword +UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword + --> UP040.py:67:1 | 65 | # https://github.com/astral-sh/ruff/issues/11422 66 | T = TypeVar("T") 67 | / PositiveList = TypeAliasType( 68 | | "PositiveList", list[Annotated[T, Gt(0)]], type_params=(T,) 69 | | ) - | |_^ UP040 + | |_^ 70 | 71 | # Bound | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 64 64 | @@ -274,18 +287,19 @@ UP040.py:67:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignme 71 69 | # Bound 72 70 | T = TypeVar("T", bound=SupportGt) -UP040.py:73:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword +UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword + --> UP040.py:73:1 | 71 | # Bound 72 | T = TypeVar("T", bound=SupportGt) 73 | / PositiveList = TypeAliasType( 74 | | "PositiveList", list[Annotated[T, Gt(0)]], type_params=(T,) 75 | | ) - | |_^ UP040 + | |_^ 76 | 77 | # Multiple bounds | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 70 70 | @@ -299,16 +313,17 @@ UP040.py:73:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignme 77 75 | # Multiple bounds 78 76 | T1 = TypeVar("T1", bound=SupportGt) -UP040.py:81:1: UP040 [*] Type alias `Tuple3` uses `TypeAliasType` assignment instead of the `type` keyword +UP040 [*] Type alias `Tuple3` uses `TypeAliasType` assignment instead of the `type` keyword + --> UP040.py:81:1 | 79 | T2 = TypeVar("T2") 80 | T3 = TypeVar("T3") 81 | Tuple3 = TypeAliasType("Tuple3", tuple[T1, T2, T3], type_params=(T1, T2, T3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 82 | 83 | # No type_params | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 78 78 | T1 = TypeVar("T1", bound=SupportGt) @@ -320,14 +335,15 @@ UP040.py:81:1: UP040 [*] Type alias `Tuple3` uses `TypeAliasType` assignment ins 83 83 | # No type_params 84 84 | PositiveInt = TypeAliasType("PositiveInt", Annotated[int, Gt(0)]) -UP040.py:84:1: UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignment instead of the `type` keyword +UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignment instead of the `type` keyword + --> UP040.py:84:1 | 83 | # No type_params 84 | PositiveInt = TypeAliasType("PositiveInt", Annotated[int, Gt(0)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 85 | PositiveInt = TypeAliasType("PositiveInt", Annotated[int, Gt(0)], type_params=()) | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 81 81 | Tuple3 = TypeAliasType("Tuple3", tuple[T1, T2, T3], type_params=(T1, T2, T3)) @@ -339,16 +355,17 @@ UP040.py:84:1: UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignmen 86 86 | 87 87 | # OK: Other name -UP040.py:85:1: UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignment instead of the `type` keyword +UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignment instead of the `type` keyword + --> UP040.py:85:1 | 83 | # No type_params 84 | PositiveInt = TypeAliasType("PositiveInt", Annotated[int, Gt(0)]) 85 | PositiveInt = TypeAliasType("PositiveInt", Annotated[int, Gt(0)], type_params=()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 86 | 87 | # OK: Other name | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 82 82 | @@ -360,18 +377,19 @@ UP040.py:85:1: UP040 [*] Type alias `PositiveInt` uses `TypeAliasType` assignmen 87 87 | # OK: Other name 88 88 | T = TypeVar("T", bound=SupportGt) -UP040.py:99:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword +UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword + --> UP040.py:99:1 | 97 | # unsafe fix if comments within the fix 98 | T = TypeVar("T") 99 | / PositiveList = TypeAliasType( # eaten comment 100 | | "PositiveList", list[Annotated[T, Gt(0)]], type_params=(T,) 101 | | ) - | |_^ UP040 + | |_^ 102 | 103 | T = TypeVar("T") | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 96 96 | @@ -385,15 +403,16 @@ UP040.py:99:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignme 103 101 | T = TypeVar("T") 104 102 | PositiveList = TypeAliasType( -UP040.py:104:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword +UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword + --> UP040.py:104:1 | 103 | T = TypeVar("T") 104 | / PositiveList = TypeAliasType( 105 | | "PositiveList", list[Annotated[T, Gt(0)]], type_params=(T,) 106 | | ) # this comment should be okay - | |_^ UP040 + | |_^ | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 101 101 | ) @@ -407,7 +426,8 @@ UP040.py:104:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignm 108 106 | 109 107 | # this comment will actually be preserved because it's inside the "value" part -UP040.py:111:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword +UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignment instead of the `type` keyword + --> UP040.py:111:1 | 109 | # this comment will actually be preserved because it's inside the "value" part 110 | T = TypeVar("T") @@ -416,11 +436,11 @@ UP040.py:111:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignm 113 | | Annotated[T, Gt(0)], # preserved comment 114 | | ], type_params=(T,) 115 | | ) - | |_^ UP040 + | |_^ 116 | 117 | T: TypeAlias = ( | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 108 108 | @@ -437,7 +457,8 @@ UP040.py:111:1: UP040 [*] Type alias `PositiveList` uses `TypeAliasType` assignm 117 115 | T: TypeAlias = ( 118 116 | int -UP040.py:117:1: UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:117:1 | 115 | ) 116 | @@ -445,11 +466,11 @@ UP040.py:117:1: UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of 118 | | int 119 | | | str 120 | | ) - | |_^ UP040 + | |_^ 121 | 122 | T: TypeAlias = ( # comment0 | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 114 114 | ], type_params=(T,) @@ -461,7 +482,8 @@ UP040.py:117:1: UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of 119 119 | | str 120 120 | ) -UP040.py:122:1: UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.py:122:1 | 120 | ) 121 | @@ -474,9 +496,9 @@ UP040.py:122:1: UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of 128 | | str # comment6 129 | | # comment7 130 | | ) # comment8 - | |_^ UP040 + | |_^ | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Unsafe fix 119 119 | | str diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.pyi.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.pyi.snap index 7132708896..0ee653e917 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.pyi.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.pyi.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP040.pyi:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.pyi:6:1 | 4 | # UP040 5 | # Fixes in type stub files should be safe to apply unlike in regular code where runtime behavior could change 6 | x: typing.TypeAlias = int - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | x: TypeAlias = int | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 3 3 | @@ -21,14 +22,15 @@ UP040.pyi:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 8 8 | 9 9 | -UP040.pyi:7:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.pyi:7:1 | 5 | # Fixes in type stub files should be safe to apply unlike in regular code where runtime behavior could change 6 | x: typing.TypeAlias = int 7 | x: TypeAlias = int - | ^^^^^^^^^^^^^^^^^^ UP040 + | ^^^^^^^^^^^^^^^^^^ | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 4 4 | # UP040 @@ -40,18 +42,19 @@ UP040.pyi:7:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of t 9 9 | 10 10 | # comments in the value are preserved -UP040.pyi:11:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.pyi:11:1 | 10 | # comments in the value are preserved 11 | / x: TypeAlias = tuple[ 12 | | int, # preserved 13 | | float, 14 | | ] - | |_^ UP040 + | |_^ 15 | 16 | T: TypeAlias = ( # comment0 | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 8 8 | @@ -63,7 +66,8 @@ UP040.pyi:11:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of 13 13 | float, 14 14 | ] -UP040.pyi:16:1: UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of the `type` keyword +UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of the `type` keyword + --> UP040.pyi:16:1 | 14 | ] 15 | @@ -76,9 +80,9 @@ UP040.pyi:16:1: UP040 [*] Type alias `T` uses `TypeAlias` annotation instead of 22 | | str # comment6 23 | | # comment7 24 | | ) # comment8 - | |_^ UP040 + | |_^ | - = help: Use the `type` keyword +help: Use the `type` keyword ℹ Safe fix 13 13 | float, diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP041.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP041.py.snap index 563ec5fd39..a2bbdb30d4 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP041.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP041.py.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP041.py:5:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:5:8 | 3 | try: 4 | pass 5 | except asyncio.TimeoutError: - | ^^^^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^^^^ 6 | pass | - = help: Replace `asyncio.TimeoutError` with builtin `TimeoutError` +help: Replace `asyncio.TimeoutError` with builtin `TimeoutError` ℹ Safe fix 2 2 | # These should be fixed @@ -22,15 +22,16 @@ UP041.py:5:8: UP041 [*] Replace aliased errors with `TimeoutError` 7 7 | 8 8 | try: -UP041.py:10:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:10:8 | 8 | try: 9 | pass 10 | except socket.timeout: - | ^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^ 11 | pass | - = help: Replace `socket.timeout` with builtin `TimeoutError` +help: Replace `socket.timeout` with builtin `TimeoutError` ℹ Safe fix 7 7 | @@ -42,15 +43,16 @@ UP041.py:10:8: UP041 [*] Replace aliased errors with `TimeoutError` 12 12 | 13 13 | # Should NOT be in parentheses when replaced -UP041.py:17:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:17:8 | 15 | try: 16 | pass 17 | except (asyncio.TimeoutError,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | pass | - = help: Replace with builtin `TimeoutError` +help: Replace with builtin `TimeoutError` ℹ Safe fix 14 14 | @@ -62,15 +64,16 @@ UP041.py:17:8: UP041 [*] Replace aliased errors with `TimeoutError` 19 19 | 20 20 | try: -UP041.py:22:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:22:8 | 20 | try: 21 | pass 22 | except (socket.timeout,): - | ^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Replace with builtin `TimeoutError` +help: Replace with builtin `TimeoutError` ℹ Safe fix 19 19 | @@ -82,15 +85,16 @@ UP041.py:22:8: UP041 [*] Replace aliased errors with `TimeoutError` 24 24 | 25 25 | try: -UP041.py:27:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:27:8 | 25 | try: 26 | pass 27 | except (asyncio.TimeoutError, socket.timeout,): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | pass | - = help: Replace with builtin `TimeoutError` +help: Replace with builtin `TimeoutError` ℹ Safe fix 24 24 | @@ -102,15 +106,16 @@ UP041.py:27:8: UP041 [*] Replace aliased errors with `TimeoutError` 29 29 | 30 30 | # Should be kept in parentheses (because multiple) -UP041.py:34:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:34:8 | 32 | try: 33 | pass 34 | except (asyncio.TimeoutError, socket.timeout, KeyError, TimeoutError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | pass | - = help: Replace with builtin `TimeoutError` +help: Replace with builtin `TimeoutError` ℹ Safe fix 31 31 | @@ -122,15 +127,16 @@ UP041.py:34:8: UP041 [*] Replace aliased errors with `TimeoutError` 36 36 | 37 37 | # First should change, second should not -UP041.py:42:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:42:8 | 40 | try: 41 | pass 42 | except (asyncio.TimeoutError, error): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 43 | pass | - = help: Replace with builtin `TimeoutError` +help: Replace with builtin `TimeoutError` ℹ Safe fix 39 39 | from .mmap import error diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP042.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP042.py.snap index 59de11c176..60d8df42da 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP042.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP042.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP042.py:4:7: UP042 [*] Class A inherits from both `str` and `enum.Enum` +UP042 [*] Class A inherits from both `str` and `enum.Enum` + --> UP042.py:4:7 | 4 | class A(str, Enum): ... - | ^ UP042 + | ^ | - = help: Inherit from `enum.StrEnum` +help: Inherit from `enum.StrEnum` ℹ Unsafe fix 1 |-from enum import Enum @@ -20,12 +20,13 @@ UP042.py:4:7: UP042 [*] Class A inherits from both `str` and `enum.Enum` 6 6 | 7 7 | class B(Enum, str): ... -UP042.py:7:7: UP042 [*] Class B inherits from both `str` and `enum.Enum` +UP042 [*] Class B inherits from both `str` and `enum.Enum` + --> UP042.py:7:7 | 7 | class B(Enum, str): ... - | ^ UP042 + | ^ | - = help: Inherit from `enum.StrEnum` +help: Inherit from `enum.StrEnum` ℹ Unsafe fix 1 |-from enum import Enum @@ -41,16 +42,18 @@ UP042.py:7:7: UP042 [*] Class B inherits from both `str` and `enum.Enum` 9 9 | 10 10 | class D(int, str, Enum): ... -UP042.py:10:7: UP042 Class D inherits from both `str` and `enum.Enum` +UP042 Class D inherits from both `str` and `enum.Enum` + --> UP042.py:10:7 | 10 | class D(int, str, Enum): ... - | ^ UP042 + | ^ | - = help: Inherit from `enum.StrEnum` +help: Inherit from `enum.StrEnum` -UP042.py:13:7: UP042 Class E inherits from both `str` and `enum.Enum` +UP042 Class E inherits from both `str` and `enum.Enum` + --> UP042.py:13:7 | 13 | class E(str, int, Enum): ... - | ^ UP042 + | ^ | - = help: Inherit from `enum.StrEnum` +help: Inherit from `enum.StrEnum` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.py.snap index dda6bd47ee..18fb1a0b72 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP043.py:4:15: UP043 [*] Unnecessary default type arguments +UP043 [*] Unnecessary default type arguments + --> UP043.py:4:15 | 4 | def func() -> Generator[int, None, None]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP043 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | yield 42 | - = help: Remove default type arguments +help: Remove default type arguments ℹ Safe fix 1 1 | from collections.abc import Generator, AsyncGenerator @@ -20,13 +20,14 @@ UP043.py:4:15: UP043 [*] Unnecessary default type arguments 6 6 | 7 7 | -UP043.py:8:15: UP043 [*] Unnecessary default type arguments +UP043 [*] Unnecessary default type arguments + --> UP043.py:8:15 | 8 | def func() -> Generator[int, None]: - | ^^^^^^^^^^^^^^^^^^^^ UP043 + | ^^^^^^^^^^^^^^^^^^^^ 9 | yield 42 | - = help: Remove default type arguments +help: Remove default type arguments ℹ Safe fix 5 5 | yield 42 @@ -38,14 +39,15 @@ UP043.py:8:15: UP043 [*] Unnecessary default type arguments 10 10 | 11 11 | -UP043.py:21:15: UP043 [*] Unnecessary default type arguments +UP043 [*] Unnecessary default type arguments + --> UP043.py:21:15 | 21 | def func() -> Generator[int, int, None]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP043 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | _ = yield 42 23 | return None | - = help: Remove default type arguments +help: Remove default type arguments ℹ Safe fix 18 18 | return foo @@ -57,13 +59,14 @@ UP043.py:21:15: UP043 [*] Unnecessary default type arguments 23 23 | return None 24 24 | -UP043.py:31:21: UP043 [*] Unnecessary default type arguments +UP043 [*] Unnecessary default type arguments + --> UP043.py:31:21 | 31 | async def func() -> AsyncGenerator[int, None]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP043 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | yield 42 | - = help: Remove default type arguments +help: Remove default type arguments ℹ Safe fix 28 28 | return 42 @@ -75,13 +78,14 @@ UP043.py:31:21: UP043 [*] Unnecessary default type arguments 33 33 | 34 34 | -UP043.py:47:15: UP043 [*] Unnecessary default type arguments +UP043 [*] Unnecessary default type arguments + --> UP043.py:47:15 | 47 | def func() -> Generator[str, None, None]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP043 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | yield "hello" | - = help: Remove default type arguments +help: Remove default type arguments ℹ Safe fix 44 44 | from typing import Generator, AsyncGenerator @@ -93,13 +97,14 @@ UP043.py:47:15: UP043 [*] Unnecessary default type arguments 49 49 | 50 50 | -UP043.py:51:21: UP043 [*] Unnecessary default type arguments +UP043 [*] Unnecessary default type arguments + --> UP043.py:51:21 | 51 | async def func() -> AsyncGenerator[str, None]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP043 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | yield "hello" | - = help: Remove default type arguments +help: Remove default type arguments ℹ Safe fix 48 48 | yield "hello" @@ -111,17 +116,18 @@ UP043.py:51:21: UP043 [*] Unnecessary default type arguments 53 53 | 54 54 | -UP043.py:55:21: UP043 [*] Unnecessary default type arguments +UP043 [*] Unnecessary default type arguments + --> UP043.py:55:21 | 55 | async def func() -> AsyncGenerator[ # type: ignore | _____________________^ 56 | | str, 57 | | None 58 | | ]: - | |_^ UP043 + | |_^ 59 | yield "hello" | - = help: Remove default type arguments +help: Remove default type arguments ℹ Unsafe fix 52 52 | yield "hello" diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP045.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP045.py.snap index bc50bc8688..5d03d490cd 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP045.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP045.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP045.py:5:10: UP045 [*] Use `X | None` for type annotations +UP045 [*] Use `X | None` for type annotations + --> UP045.py:5:10 | 5 | def f(x: Optional[str]) -> None: - | ^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^ 6 | ... | - = help: Convert to `X | None` +help: Convert to `X | None` ℹ Safe fix 2 2 | from typing import Optional @@ -19,13 +20,14 @@ UP045.py:5:10: UP045 [*] Use `X | None` for type annotations 7 7 | 8 8 | -UP045.py:9:10: UP045 [*] Use `X | None` for type annotations +UP045 [*] Use `X | None` for type annotations + --> UP045.py:9:10 | 9 | def f(x: typing.Optional[str]) -> None: - | ^^^^^^^^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^^^^^^^^ 10 | ... | - = help: Convert to `X | None` +help: Convert to `X | None` ℹ Safe fix 6 6 | ... @@ -37,14 +39,15 @@ UP045.py:9:10: UP045 [*] Use `X | None` for type annotations 11 11 | 12 12 | -UP045.py:14:8: UP045 [*] Use `X | None` for type annotations +UP045 [*] Use `X | None` for type annotations + --> UP045.py:14:8 | 13 | def f() -> None: 14 | x: Optional[str] - | ^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^ 15 | x = Optional[str] | - = help: Convert to `X | None` +help: Convert to `X | None` ℹ Safe fix 11 11 | @@ -56,22 +59,24 @@ UP045.py:14:8: UP045 [*] Use `X | None` for type annotations 16 16 | 17 17 | -UP045.py:15:9: UP045 Use `X | None` for type annotations +UP045 Use `X | None` for type annotations + --> UP045.py:15:9 | 13 | def f() -> None: 14 | x: Optional[str] 15 | x = Optional[str] - | ^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^ | - = help: Convert to `X | None` +help: Convert to `X | None` -UP045.py:18:15: UP045 [*] Use `X | None` for type annotations +UP045 [*] Use `X | None` for type annotations + --> UP045.py:18:15 | 18 | def f(x: list[Optional[int]]) -> None: - | ^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^ 19 | ... | - = help: Convert to `X | None` +help: Convert to `X | None` ℹ Safe fix 15 15 | x = Optional[str] @@ -83,31 +88,35 @@ UP045.py:18:15: UP045 [*] Use `X | None` for type annotations 20 20 | 21 21 | -UP045.py:22:10: UP045 Use `X | None` for type annotations +UP045 Use `X | None` for type annotations + --> UP045.py:22:10 | 22 | def f(x: Optional[int : float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^^^^^^^^^ 23 | ... | - = help: Convert to `X | None` +help: Convert to `X | None` -UP045.py:26:10: UP045 Use `X | None` for type annotations +UP045 Use `X | None` for type annotations + --> UP045.py:26:10 | 26 | def f(x: Optional[str, int : float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | ... | - = help: Convert to `X | None` +help: Convert to `X | None` -UP045.py:30:10: UP045 Use `X | None` for type annotations +UP045 Use `X | None` for type annotations + --> UP045.py:30:10 | 30 | def f(x: Optional[int, float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^^^^^^^^ 31 | ... | - = help: Convert to `X | None` +help: Convert to `X | None` -UP045.py:36:28: UP045 [*] Use `X | None` for type annotations +UP045 [*] Use `X | None` for type annotations + --> UP045.py:36:28 | 34 | # Regression test for: https://github.com/astral-sh/ruff/issues/7131 35 | class ServiceRefOrValue: @@ -116,9 +125,9 @@ UP045.py:36:28: UP045 [*] Use `X | None` for type annotations 37 | | list[ServiceSpecificationRef] 38 | | | list[ServiceSpecification] 39 | | ] = None - | |_____^ UP045 + | |_____^ | - = help: Convert to `X | None` +help: Convert to `X | None` ℹ Safe fix 33 33 | @@ -133,14 +142,15 @@ UP045.py:36:28: UP045 [*] Use `X | None` for type annotations 41 38 | 42 39 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 -UP045.py:44:28: UP045 [*] Use `X | None` for type annotations +UP045 [*] Use `X | None` for type annotations + --> UP045.py:44:28 | 42 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 43 | class ServiceRefOrValue: 44 | service_specification: Optional[str]is not True = None - | ^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^ | - = help: Convert to `X | None` +help: Convert to `X | None` ℹ Safe fix 41 41 | @@ -152,11 +162,12 @@ UP045.py:44:28: UP045 [*] Use `X | None` for type annotations 46 46 | 47 47 | # Test for: https://github.com/astral-sh/ruff/issues/18508 -UP045.py:49:6: UP045 Use `X | None` for type annotations +UP045 Use `X | None` for type annotations + --> UP045.py:49:6 | 47 | # Test for: https://github.com/astral-sh/ruff/issues/18508 48 | # Optional[None] should not be offered a fix 49 | foo: Optional[None] = None - | ^^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^^ | - = help: Convert to `X | None` +help: Convert to `X | None` diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP046_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP046_0.py.snap index c15a773704..9707a08e07 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP046_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP046_0.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP046_0.py:11:9: UP046 [*] Generic class `A` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `A` uses `Generic` subclass instead of type parameters + --> UP046_0.py:11:9 | 11 | class A(Generic[T]): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 12 | # Comments in a class body are preserved 13 | var: T | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 8 8 | P = ParamSpec("P") @@ -21,13 +21,14 @@ UP046_0.py:11:9: UP046 [*] Generic class `A` uses `Generic` subclass instead of 13 13 | var: T 14 14 | -UP046_0.py:16:9: UP046 [*] Generic class `B` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `B` uses `Generic` subclass instead of type parameters + --> UP046_0.py:16:9 | 16 | class B(Generic[*Ts]): - | ^^^^^^^^^^^^ UP046 + | ^^^^^^^^^^^^ 17 | var: tuple[*Ts] | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 13 13 | var: T @@ -39,13 +40,14 @@ UP046_0.py:16:9: UP046 [*] Generic class `B` uses `Generic` subclass instead of 18 18 | 19 19 | -UP046_0.py:20:9: UP046 [*] Generic class `C` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `C` uses `Generic` subclass instead of type parameters + --> UP046_0.py:20:9 | 20 | class C(Generic[P]): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 21 | var: P | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 17 17 | var: tuple[*Ts] @@ -57,13 +59,14 @@ UP046_0.py:20:9: UP046 [*] Generic class `C` uses `Generic` subclass instead of 22 22 | 23 23 | -UP046_0.py:24:19: UP046 [*] Generic class `Constrained` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `Constrained` uses `Generic` subclass instead of type parameters + --> UP046_0.py:24:19 | 24 | class Constrained(Generic[S]): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 25 | var: S | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 21 21 | var: P @@ -75,26 +78,28 @@ UP046_0.py:24:19: UP046 [*] Generic class `Constrained` uses `Generic` subclass 26 26 | 27 27 | -UP046_0.py:30:20: UP046 Generic class `ExternalType` uses `Generic` subclass instead of type parameters +UP046 Generic class `ExternalType` uses `Generic` subclass instead of type parameters + --> UP046_0.py:30:20 | 28 | # This case gets a diagnostic but not a fix because we can't look up the bounds 29 | # or constraints on the TypeVar imported from another module 30 | class ExternalType(Generic[T, SupportsRichComparisonT]): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP046 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | var: T 32 | compare: SupportsRichComparisonT | - = help: Use type parameters +help: Use type parameters -UP046_0.py:37:13: UP046 [*] Generic class `MyStr` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `MyStr` uses `Generic` subclass instead of type parameters + --> UP046_0.py:37:13 | 35 | # typing.AnyStr is a common external type variable, so treat it specially as a 36 | # known TypeVar 37 | class MyStr(Generic[AnyStr]): - | ^^^^^^^^^^^^^^^ UP046 + | ^^^^^^^^^^^^^^^ 38 | s: AnyStr | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 34 34 | @@ -106,14 +111,15 @@ UP046_0.py:37:13: UP046 [*] Generic class `MyStr` uses `Generic` subclass instea 39 39 | 40 40 | -UP046_0.py:41:24: UP046 [*] Generic class `MultipleGenerics` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `MultipleGenerics` uses `Generic` subclass instead of type parameters + --> UP046_0.py:41:24 | 41 | class MultipleGenerics(Generic[S, T, *Ts, P]): - | ^^^^^^^^^^^^^^^^^^^^^ UP046 + | ^^^^^^^^^^^^^^^^^^^^^ 42 | var: S 43 | typ: T | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 38 38 | s: AnyStr @@ -125,13 +131,14 @@ UP046_0.py:41:24: UP046 [*] Generic class `MultipleGenerics` uses `Generic` subc 43 43 | typ: T 44 44 | tup: tuple[*Ts] -UP046_0.py:48:33: UP046 [*] Generic class `MultipleBaseClasses` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `MultipleBaseClasses` uses `Generic` subclass instead of type parameters + --> UP046_0.py:48:33 | 48 | class MultipleBaseClasses(list, Generic[T]): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 49 | var: T | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 45 45 | pep: P @@ -143,13 +150,14 @@ UP046_0.py:48:33: UP046 [*] Generic class `MultipleBaseClasses` uses `Generic` s 50 50 | 51 51 | -UP046_0.py:62:44: UP046 [*] Generic class `MoreBaseClasses` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `MoreBaseClasses` uses `Generic` subclass instead of type parameters + --> UP046_0.py:62:44 | 62 | class MoreBaseClasses(Base1, Base2, Base3, Generic[T]): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 63 | var: T | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 59 59 | class Base3: ... @@ -161,14 +169,15 @@ UP046_0.py:62:44: UP046 [*] Generic class `MoreBaseClasses` uses `Generic` subcl 64 64 | 65 65 | -UP046_0.py:66:52: UP046 [*] Generic class `MultipleBaseAndGenerics` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `MultipleBaseAndGenerics` uses `Generic` subclass instead of type parameters + --> UP046_0.py:66:52 | 66 | class MultipleBaseAndGenerics(Base1, Base2, Base3, Generic[S, T, *Ts, P]): - | ^^^^^^^^^^^^^^^^^^^^^ UP046 + | ^^^^^^^^^^^^^^^^^^^^^ 67 | var: S 68 | typ: T | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 63 63 | var: T @@ -180,12 +189,13 @@ UP046_0.py:66:52: UP046 [*] Generic class `MultipleBaseAndGenerics` uses `Generi 68 68 | typ: T 69 69 | tup: tuple[*Ts] -UP046_0.py:73:9: UP046 [*] Generic class `A` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `A` uses `Generic` subclass instead of type parameters + --> UP046_0.py:73:9 | 73 | class A(Generic[T]): ... - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 70 70 | pep: P @@ -197,13 +207,14 @@ UP046_0.py:73:9: UP046 [*] Generic class `A` uses `Generic` subclass instead of 75 75 | 76 76 | class B(A[S], Generic[S]): -UP046_0.py:76:15: UP046 [*] Generic class `B` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `B` uses `Generic` subclass instead of type parameters + --> UP046_0.py:76:15 | 76 | class B(A[S], Generic[S]): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 77 | var: S | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 73 73 | class A(Generic[T]): ... @@ -215,13 +226,14 @@ UP046_0.py:76:15: UP046 [*] Generic class `B` uses `Generic` subclass instead of 78 78 | 79 79 | -UP046_0.py:80:15: UP046 [*] Generic class `C` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `C` uses `Generic` subclass instead of type parameters + --> UP046_0.py:80:15 | 80 | class C(A[S], Generic[S, T]): - | ^^^^^^^^^^^^^ UP046 + | ^^^^^^^^^^^^^ 81 | var: tuple[S, T] | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 77 77 | var: S @@ -233,13 +245,14 @@ UP046_0.py:80:15: UP046 [*] Generic class `C` uses `Generic` subclass instead of 82 82 | 83 83 | -UP046_0.py:84:17: UP046 [*] Generic class `D` uses `Generic` subclass instead of type parameters +UP046 [*] Generic class `D` uses `Generic` subclass instead of type parameters + --> UP046_0.py:84:17 | 84 | class D(A[int], Generic[T]): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 85 | var: T | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 81 81 | var: tuple[S, T] @@ -251,29 +264,32 @@ UP046_0.py:84:17: UP046 [*] Generic class `D` uses `Generic` subclass instead of 86 86 | 87 87 | -UP046_0.py:88:15: UP046 Generic class `NotLast` uses `Generic` subclass instead of type parameters +UP046 Generic class `NotLast` uses `Generic` subclass instead of type parameters + --> UP046_0.py:88:15 | 88 | class NotLast(Generic[T], Base1): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 89 | var: T | - = help: Use type parameters +help: Use type parameters -UP046_0.py:92:23: UP046 Generic class `Sandwich` uses `Generic` subclass instead of type parameters +UP046 Generic class `Sandwich` uses `Generic` subclass instead of type parameters + --> UP046_0.py:92:23 | 92 | class Sandwich(Base1, Generic[T], Base2): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 93 | var: T | - = help: Use type parameters +help: Use type parameters -UP046_0.py:98:23: UP046 Generic class `TooManyGenerics` uses `Generic` subclass instead of type parameters +UP046 Generic class `TooManyGenerics` uses `Generic` subclass instead of type parameters + --> UP046_0.py:98:23 | 96 | # runtime `TypeError` to inherit from `Generic` multiple times, but we still 97 | # emit a diagnostic 98 | class TooManyGenerics(Generic[T], Generic[S]): - | ^^^^^^^^^^ UP046 + | ^^^^^^^^^^ 99 | var: T 100 | var: S | - = help: Use type parameters +help: Use type parameters diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP046_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP046_1.py.snap index 95de85d97b..2668c98c7f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP046_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP046_1.py.snap @@ -1,11 +1,11 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP046_1.py:11:14: UP046 Generic class `BadStr` uses `Generic` subclass instead of type parameters +UP046 Generic class `BadStr` uses `Generic` subclass instead of type parameters + --> UP046_1.py:11:14 | 11 | class BadStr(Generic[AnyStr]): - | ^^^^^^^^^^^^^^^ UP046 + | ^^^^^^^^^^^^^^^ 12 | var: AnyStr | - = help: Use type parameters +help: Use type parameters diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP047.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP047.py.snap index fd3dde6026..6fdca3167f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP047.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP047.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP047.py:12:5: UP047 [*] Generic function `f` should use type parameters +UP047 [*] Generic function `f` should use type parameters + --> UP047.py:12:5 | 12 | def f(t: T) -> T: - | ^^^^^^^ UP047 + | ^^^^^^^ 13 | return t | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 9 9 | P = ParamSpec("P") @@ -20,13 +20,14 @@ UP047.py:12:5: UP047 [*] Generic function `f` should use type parameters 14 14 | 15 15 | -UP047.py:16:5: UP047 [*] Generic function `g` should use type parameters +UP047 [*] Generic function `g` should use type parameters + --> UP047.py:16:5 | 16 | def g(ts: tuple[*Ts]) -> tuple[*Ts]: - | ^^^^^^^^^^^^^^^^^ UP047 + | ^^^^^^^^^^^^^^^^^ 17 | return ts | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 13 13 | return t @@ -38,7 +39,8 @@ UP047.py:16:5: UP047 [*] Generic function `g` should use type parameters 18 18 | 19 19 | -UP047.py:20:5: UP047 [*] Generic function `h` should use type parameters +UP047 [*] Generic function `h` should use type parameters + --> UP047.py:20:5 | 20 | def h( | _____^ @@ -47,10 +49,10 @@ UP047.py:20:5: UP047 [*] Generic function `h` should use type parameters 23 | | another_param, 24 | | and_another, 25 | | ) -> Callable[P, T]: - | |_^ UP047 + | |_^ 26 | return p | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 17 17 | return ts @@ -62,13 +64,14 @@ UP047.py:20:5: UP047 [*] Generic function `h` should use type parameters 22 22 | # Comment in the middle of a parameter list should be preserved 23 23 | another_param, -UP047.py:29:5: UP047 [*] Generic function `i` should use type parameters +UP047 [*] Generic function `i` should use type parameters + --> UP047.py:29:5 | 29 | def i(s: S) -> S: - | ^^^^^^^ UP047 + | ^^^^^^^ 30 | return s | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 26 26 | return p @@ -80,15 +83,16 @@ UP047.py:29:5: UP047 [*] Generic function `i` should use type parameters 31 31 | 32 32 | -UP047.py:39:5: UP047 [*] Generic function `broken_fix` should use type parameters +UP047 [*] Generic function `broken_fix` should use type parameters + --> UP047.py:39:5 | 37 | # TypeVars with the new-style generic syntax and will be rejected by type 38 | # checkers 39 | def broken_fix(okay: T, bad: Something) -> tuple[T, Something]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP047 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | return (okay, bad) | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 36 36 | # generic type parameter. This leads to code that mixes old-style standalone @@ -100,13 +104,14 @@ UP047.py:39:5: UP047 [*] Generic function `broken_fix` should use type parameter 41 41 | 42 42 | -UP047.py:43:5: UP047 [*] Generic function `any_str_param` should use type parameters +UP047 [*] Generic function `any_str_param` should use type parameters + --> UP047.py:43:5 | 43 | def any_str_param(s: AnyStr) -> AnyStr: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP047 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 44 | return s | - = help: Use type parameters +help: Use type parameters ℹ Unsafe fix 40 40 | return (okay, bad) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP049_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP049_0.py.snap index 087b5f1566..99eed28edc 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP049_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP049_0.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP049_0.py:2:15: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_0.py:2:15 | 1 | # simple case, replace _T in signature and body 2 | class Generic[_T]: - | ^^ UP049 + | ^^ 3 | buf: list[_T] | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 1 1 | # simple case, replace _T in signature and body @@ -23,15 +24,16 @@ UP049_0.py:2:15: UP049 [*] Generic class uses private type parameters 7 7 | 8 8 | -UP049_0.py:10:12: UP049 [*] Generic function uses private type parameters +UP049 [*] Generic function uses private type parameters + --> UP049_0.py:10:12 | 9 | # simple case, replace _T in signature and body 10 | def second[_T](var: tuple[_T]) -> _T: - | ^^ UP049 + | ^^ 11 | y: _T = var[1] 12 | return y | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 7 7 | @@ -45,16 +47,17 @@ UP049_0.py:10:12: UP049 [*] Generic function uses private type parameters 13 13 | 14 14 | -UP049_0.py:17:5: UP049 [*] Generic function uses private type parameters +UP049 [*] Generic function uses private type parameters + --> UP049_0.py:17:5 | 15 | # one diagnostic for each variable, comments are preserved 16 | def many_generics[ 17 | _T, # first generic - | ^^ UP049 + | ^^ 18 | _U, # second generic 19 | ](args): | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 14 14 | @@ -66,16 +69,17 @@ UP049_0.py:17:5: UP049 [*] Generic function uses private type parameters 19 19 | ](args): 20 20 | return args -UP049_0.py:18:5: UP049 [*] Generic function uses private type parameters +UP049 [*] Generic function uses private type parameters + --> UP049_0.py:18:5 | 16 | def many_generics[ 17 | _T, # first generic 18 | _U, # second generic - | ^^ UP049 + | ^^ 19 | ](args): 20 | return args | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 15 15 | # one diagnostic for each variable, comments are preserved @@ -87,14 +91,15 @@ UP049_0.py:18:5: UP049 [*] Generic function uses private type parameters 20 20 | return args 21 21 | -UP049_0.py:27:7: UP049 [*] Generic function uses private type parameters +UP049 [*] Generic function uses private type parameters + --> UP049_0.py:27:7 | 27 | def f[_T](v): - | ^^ UP049 + | ^^ 28 | cast("_T", v) 29 | cast("Literal['_T']") | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 24 24 | from typing import Literal, cast diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP049_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP049_1.py.snap index 16b8dbd70a..4c94954139 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP049_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP049_1.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP049_1.py:2:11: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:2:11 | 1 | # bound 2 | class Foo[_T: str]: - | ^^ UP049 + | ^^ 3 | var: _T | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 1 1 | # bound @@ -20,14 +21,15 @@ UP049_1.py:2:11: UP049 [*] Generic class uses private type parameters 5 5 | 6 6 | # constraint -UP049_1.py:7:11: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:7:11 | 6 | # constraint 7 | class Foo[_T: (str, bytes)]: - | ^^ UP049 + | ^^ 8 | var: _T | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 4 4 | @@ -41,14 +43,15 @@ UP049_1.py:7:11: UP049 [*] Generic class uses private type parameters 10 10 | 11 11 | # python 3.13+ default -UP049_1.py:12:11: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:12:11 | 11 | # python 3.13+ default 12 | class Foo[_T = int]: - | ^^ UP049 + | ^^ 13 | var: _T | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 9 9 | @@ -62,14 +65,15 @@ UP049_1.py:12:11: UP049 [*] Generic class uses private type parameters 15 15 | 16 16 | # tuple -UP049_1.py:17:12: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:17:12 | 16 | # tuple 17 | class Foo[*_Ts]: - | ^^^ UP049 + | ^^^ 18 | var: tuple[*_Ts] | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 14 14 | @@ -83,14 +87,15 @@ UP049_1.py:17:12: UP049 [*] Generic class uses private type parameters 20 20 | 21 21 | # paramspec -UP049_1.py:22:11: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:22:11 | 21 | # paramspec 22 | class C[**_P]: - | ^^ UP049 + | ^^ 23 | var: _P | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 19 19 | @@ -104,16 +109,17 @@ UP049_1.py:22:11: UP049 [*] Generic class uses private type parameters 25 25 | 26 26 | from typing import Callable -UP049_1.py:31:18: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:31:18 | 29 | # each of these will get a separate diagnostic, but at least they'll all get 30 | # fixed 31 | class Everything[_T, _U: str, _V: (int, float), *_W, **_X]: - | ^^ UP049 + | ^^ 32 | @staticmethod 33 | def transform(t: _T, u: _U, v: _V) -> tuple[*_W] | Callable[_X, _T] | None: | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 28 28 | @@ -128,16 +134,17 @@ UP049_1.py:31:18: UP049 [*] Generic class uses private type parameters 35 35 | 36 36 | -UP049_1.py:31:22: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:31:22 | 29 | # each of these will get a separate diagnostic, but at least they'll all get 30 | # fixed 31 | class Everything[_T, _U: str, _V: (int, float), *_W, **_X]: - | ^^ UP049 + | ^^ 32 | @staticmethod 33 | def transform(t: _T, u: _U, v: _V) -> tuple[*_W] | Callable[_X, _T] | None: | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 28 28 | @@ -152,16 +159,17 @@ UP049_1.py:31:22: UP049 [*] Generic class uses private type parameters 35 35 | 36 36 | -UP049_1.py:31:31: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:31:31 | 29 | # each of these will get a separate diagnostic, but at least they'll all get 30 | # fixed 31 | class Everything[_T, _U: str, _V: (int, float), *_W, **_X]: - | ^^ UP049 + | ^^ 32 | @staticmethod 33 | def transform(t: _T, u: _U, v: _V) -> tuple[*_W] | Callable[_X, _T] | None: | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 28 28 | @@ -176,16 +184,17 @@ UP049_1.py:31:31: UP049 [*] Generic class uses private type parameters 35 35 | 36 36 | -UP049_1.py:31:50: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:31:50 | 29 | # each of these will get a separate diagnostic, but at least they'll all get 30 | # fixed 31 | class Everything[_T, _U: str, _V: (int, float), *_W, **_X]: - | ^^ UP049 + | ^^ 32 | @staticmethod 33 | def transform(t: _T, u: _U, v: _V) -> tuple[*_W] | Callable[_X, _T] | None: | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 28 28 | @@ -200,16 +209,17 @@ UP049_1.py:31:50: UP049 [*] Generic class uses private type parameters 35 35 | 36 36 | -UP049_1.py:31:56: UP049 [*] Generic class uses private type parameters +UP049 [*] Generic class uses private type parameters + --> UP049_1.py:31:56 | 29 | # each of these will get a separate diagnostic, but at least they'll all get 30 | # fixed 31 | class Everything[_T, _U: str, _V: (int, float), *_W, **_X]: - | ^^ UP049 + | ^^ 32 | @staticmethod 33 | def transform(t: _T, u: _U, v: _V) -> tuple[*_W] | Callable[_X, _T] | None: | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Safe fix 28 28 | @@ -224,57 +234,63 @@ UP049_1.py:31:56: UP049 [*] Generic class uses private type parameters 35 35 | 36 36 | -UP049_1.py:39:9: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:39:9 | 37 | # this should not be fixed because the new name is a keyword, but we still 38 | # offer a diagnostic 39 | class F[_async]: ... - | ^^^^^^ UP049 + | ^^^^^^ | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores -UP049_1.py:47:25: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:47:25 | 45 | type X = int 46 | 47 | class ScopeConflict[_X]: - | ^^ UP049 + | ^^ 48 | var: _X 49 | x: X | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores -UP049_1.py:64:9: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:64:9 | 64 | class C[_0]: ... - | ^^ UP049 + | ^^ | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores -UP049_1.py:67:12: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:67:12 | 67 | class C[T, _T]: ... - | ^^ UP049 + | ^^ 68 | class C[_T, T]: ... | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores -UP049_1.py:68:9: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:68:9 | 67 | class C[T, _T]: ... 68 | class C[_T, T]: ... - | ^^ UP049 + | ^^ | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores -UP049_1.py:71:9: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:71:9 | 71 | class C[_T]: - | ^^ UP049 + | ^^ 72 | v1 = cast(_T, ...) 73 | v2 = cast('_T', ...) | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Display-only fix 68 68 | class C[_T, T]: ... @@ -300,13 +316,14 @@ UP049_1.py:71:9: UP049 Generic class uses private type parameters 81 81 | 82 82 | class C[_T]: -UP049_1.py:82:9: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:82:9 | 82 | class C[_T]: - | ^^ UP049 + | ^^ 83 | v = cast('Literal[\'foo\'] | _T', ...) | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores ℹ Display-only fix 79 79 | v3 = cast("\u005fT", ...) @@ -320,32 +337,35 @@ UP049_1.py:82:9: UP049 Generic class uses private type parameters 85 85 | 86 86 | ## Name collision -UP049_1.py:88:11: UP049 Generic function uses private type parameters +UP049 Generic function uses private type parameters + --> UP049_1.py:88:11 | 86 | ## Name collision 87 | class C[T]: 88 | def f[_T](self): # No fix, collides with `T` from outer scope - | ^^ UP049 + | ^^ 89 | v1 = cast(_T, ...) 90 | v2 = cast('_T', ...) | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores -UP049_1.py:94:9: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:94:9 | 93 | # Unfixable as the new name collides with a variable visible from one of the inner scopes 94 | class C[_T]: - | ^^ UP049 + | ^^ 95 | T = 42 | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores -UP049_1.py:102:9: UP049 Generic class uses private type parameters +UP049 Generic class uses private type parameters + --> UP049_1.py:102:9 | 101 | # Unfixable as the new name collides with a variable visible from one of the inner scopes 102 | class C[_T]: - | ^^ UP049 + | ^^ 103 | def f[T](self): 104 | v1 = cast(_T, ...) | - = help: Rename type parameter to remove leading underscores +help: Rename type parameter to remove leading underscores diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP050.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP050.py.snap index 1d4e1af6df..904d235e79 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP050.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP050.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP050.py:5:9: UP050 [*] Class `A` uses `metaclass=type`, which is redundant +UP050 [*] Class `A` uses `metaclass=type`, which is redundant + --> UP050.py:5:9 | 5 | class A(metaclass=type): - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 6 | ... | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Safe fix 2 2 | ... @@ -19,15 +20,16 @@ UP050.py:5:9: UP050 [*] Class `A` uses `metaclass=type`, which is redundant 7 7 | 8 8 | -UP050.py:10:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant +UP050 [*] Class `A` uses `metaclass=type`, which is redundant + --> UP050.py:10:5 | 9 | class A( 10 | metaclass=type - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 11 | ): 12 | ... | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Safe fix 6 6 | ... @@ -41,15 +43,16 @@ UP050.py:10:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant 13 11 | 14 12 | -UP050.py:16:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant +UP050 [*] Class `A` uses `metaclass=type`, which is redundant + --> UP050.py:16:5 | 15 | class A( 16 | metaclass=type - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 17 | # 18 | ): | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Unsafe fix 12 12 | ... @@ -64,16 +67,17 @@ UP050.py:16:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant 20 17 | 21 18 | -UP050.py:24:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant +UP050 [*] Class `A` uses `metaclass=type`, which is redundant + --> UP050.py:24:5 | 22 | class A( 23 | # 24 | metaclass=type - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 25 | ): 26 | ... | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Unsafe fix 19 19 | ... @@ -88,15 +92,16 @@ UP050.py:24:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant 27 24 | 28 25 | -UP050.py:30:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant +UP050 [*] Class `A` uses `metaclass=type`, which is redundant + --> UP050.py:30:5 | 29 | class A( 30 | metaclass=type, - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 31 | # 32 | ): | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Unsafe fix 26 26 | ... @@ -111,16 +116,17 @@ UP050.py:30:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant 34 31 | 35 32 | -UP050.py:38:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant +UP050 [*] Class `A` uses `metaclass=type`, which is redundant + --> UP050.py:38:5 | 36 | class A( 37 | # 38 | metaclass=type, - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 39 | # 40 | ): | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Unsafe fix 33 33 | ... @@ -136,13 +142,14 @@ UP050.py:38:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant 42 38 | 43 39 | -UP050.py:44:12: UP050 [*] Class `B` uses `metaclass=type`, which is redundant +UP050 [*] Class `B` uses `metaclass=type`, which is redundant + --> UP050.py:44:12 | 44 | class B(A, metaclass=type): - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 45 | ... | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Safe fix 41 41 | ... @@ -154,16 +161,17 @@ UP050.py:44:12: UP050 [*] Class `B` uses `metaclass=type`, which is redundant 46 46 | 47 47 | -UP050.py:50:5: UP050 [*] Class `B` uses `metaclass=type`, which is redundant +UP050 [*] Class `B` uses `metaclass=type`, which is redundant + --> UP050.py:50:5 | 48 | class B( 49 | A, 50 | metaclass=type, - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 51 | ): 52 | ... | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Safe fix 47 47 | @@ -174,16 +182,17 @@ UP050.py:50:5: UP050 [*] Class `B` uses `metaclass=type`, which is redundant 52 51 | ... 53 52 | -UP050.py:58:5: UP050 [*] Class `B` uses `metaclass=type`, which is redundant +UP050 [*] Class `B` uses `metaclass=type`, which is redundant + --> UP050.py:58:5 | 56 | A, 57 | # comment 58 | metaclass=type, - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 59 | ): 60 | ... | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Unsafe fix 54 54 | @@ -195,15 +204,16 @@ UP050.py:58:5: UP050 [*] Class `B` uses `metaclass=type`, which is redundant 60 58 | ... 61 59 | -UP050.py:69:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant +UP050 [*] Class `A` uses `metaclass=type`, which is redundant + --> UP050.py:69:5 | 68 | class A( 69 | metaclass=type # comment - | ^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^ 70 | , 71 | ): | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Unsafe fix 65 65 | ... @@ -218,15 +228,16 @@ UP050.py:69:5: UP050 [*] Class `A` uses `metaclass=type`, which is redundant 73 70 | 74 71 | -UP050.py:83:9: UP050 [*] Class `A` uses `metaclass=type`, which is redundant +UP050 [*] Class `A` uses `metaclass=type`, which is redundant + --> UP050.py:83:9 | 81 | import builtins 82 | 83 | class A(metaclass=builtins.type): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP050 + | ^^^^^^^^^^^^^^^^^^^^^^^ 84 | ... | - = help: Remove `metaclass=type` +help: Remove `metaclass=type` ℹ Safe fix 80 80 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_0.py.snap index 2549736148..2c67e9da5a 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_0.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP037_0.py:18:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:18:14 | 18 | def foo(var: "MyClass") -> "MyClass": - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ 19 | x: "MyClass" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg @@ -19,13 +20,14 @@ UP037_0.py:18:14: UP037 [*] Remove quotes from type annotation 20 20 | 21 21 | -UP037_0.py:18:28: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:18:28 | 18 | def foo(var: "MyClass") -> "MyClass": - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ 19 | x: "MyClass" | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg @@ -37,13 +39,14 @@ UP037_0.py:18:28: UP037 [*] Remove quotes from type annotation 20 20 | 21 21 | -UP037_0.py:19:8: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:19:8 | 18 | def foo(var: "MyClass") -> "MyClass": 19 | x: "MyClass" - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 16 16 | @@ -55,13 +58,14 @@ UP037_0.py:19:8: UP037 [*] Remove quotes from type annotation 21 21 | 22 22 | def foo(*, inplace: "bool"): -UP037_0.py:22:21: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:22:21 | 22 | def foo(*, inplace: "bool"): - | ^^^^^^ UP037 + | ^^^^^^ 23 | pass | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 19 19 | x: "MyClass" @@ -73,13 +77,14 @@ UP037_0.py:22:21: UP037 [*] Remove quotes from type annotation 24 24 | 25 25 | -UP037_0.py:26:16: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:26:16 | 26 | def foo(*args: "str", **kwargs: "int"): - | ^^^^^ UP037 + | ^^^^^ 27 | pass | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 23 23 | pass @@ -91,13 +96,14 @@ UP037_0.py:26:16: UP037 [*] Remove quotes from type annotation 28 28 | 29 29 | -UP037_0.py:26:33: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:26:33 | 26 | def foo(*args: "str", **kwargs: "int"): - | ^^^^^ UP037 + | ^^^^^ 27 | pass | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 23 23 | pass @@ -109,14 +115,15 @@ UP037_0.py:26:33: UP037 [*] Remove quotes from type annotation 28 28 | 29 29 | -UP037_0.py:30:10: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:30:10 | 30 | x: Tuple["MyClass"] - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ 31 | 32 | x: Callable[["MyClass"], None] | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 27 27 | pass @@ -128,14 +135,15 @@ UP037_0.py:30:10: UP037 [*] Remove quotes from type annotation 32 32 | x: Callable[["MyClass"], None] 33 33 | -UP037_0.py:32:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:32:14 | 30 | x: Tuple["MyClass"] 31 | 32 | x: Callable[["MyClass"], None] - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 29 29 | @@ -147,13 +155,14 @@ UP037_0.py:32:14: UP037 [*] Remove quotes from type annotation 34 34 | 35 35 | class Foo(NamedTuple): -UP037_0.py:36:8: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:36:8 | 35 | class Foo(NamedTuple): 36 | x: "MyClass" - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 33 33 | @@ -165,13 +174,14 @@ UP037_0.py:36:8: UP037 [*] Remove quotes from type annotation 38 38 | 39 39 | class D(TypedDict): -UP037_0.py:40:27: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:40:27 | 39 | class D(TypedDict): 40 | E: TypedDict("E", foo="int", total=False) - | ^^^^^ UP037 + | ^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 37 37 | @@ -183,13 +193,14 @@ UP037_0.py:40:27: UP037 [*] Remove quotes from type annotation 42 42 | 43 43 | class D(TypedDict): -UP037_0.py:44:31: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:44:31 | 43 | class D(TypedDict): 44 | E: TypedDict("E", {"foo": "int"}) - | ^^^^^ UP037 + | ^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 41 41 | @@ -201,14 +212,15 @@ UP037_0.py:44:31: UP037 [*] Remove quotes from type annotation 46 46 | 47 47 | x: Annotated["str", "metadata"] -UP037_0.py:47:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:47:14 | 47 | x: Annotated["str", "metadata"] - | ^^^^^ UP037 + | ^^^^^ 48 | 49 | x: Arg("str", "name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 44 44 | E: TypedDict("E", {"foo": "int"}) @@ -220,16 +232,17 @@ UP037_0.py:47:14: UP037 [*] Remove quotes from type annotation 49 49 | x: Arg("str", "name") 50 50 | -UP037_0.py:49:8: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:49:8 | 47 | x: Annotated["str", "metadata"] 48 | 49 | x: Arg("str", "name") - | ^^^^^ UP037 + | ^^^^^ 50 | 51 | x: DefaultArg("str", "name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 46 46 | @@ -241,16 +254,17 @@ UP037_0.py:49:8: UP037 [*] Remove quotes from type annotation 51 51 | x: DefaultArg("str", "name") 52 52 | -UP037_0.py:51:15: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:51:15 | 49 | x: Arg("str", "name") 50 | 51 | x: DefaultArg("str", "name") - | ^^^^^ UP037 + | ^^^^^ 52 | 53 | x: NamedArg("str", "name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 48 48 | @@ -262,16 +276,17 @@ UP037_0.py:51:15: UP037 [*] Remove quotes from type annotation 53 53 | x: NamedArg("str", "name") 54 54 | -UP037_0.py:53:13: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:53:13 | 51 | x: DefaultArg("str", "name") 52 | 53 | x: NamedArg("str", "name") - | ^^^^^ UP037 + | ^^^^^ 54 | 55 | x: DefaultNamedArg("str", "name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 50 50 | @@ -283,16 +298,17 @@ UP037_0.py:53:13: UP037 [*] Remove quotes from type annotation 55 55 | x: DefaultNamedArg("str", "name") 56 56 | -UP037_0.py:55:20: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:55:20 | 53 | x: NamedArg("str", "name") 54 | 55 | x: DefaultNamedArg("str", "name") - | ^^^^^ UP037 + | ^^^^^ 56 | 57 | x: DefaultNamedArg("str", name="name") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 52 52 | @@ -304,16 +320,17 @@ UP037_0.py:55:20: UP037 [*] Remove quotes from type annotation 57 57 | x: DefaultNamedArg("str", name="name") 58 58 | -UP037_0.py:57:20: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:57:20 | 55 | x: DefaultNamedArg("str", "name") 56 | 57 | x: DefaultNamedArg("str", name="name") - | ^^^^^ UP037 + | ^^^^^ 58 | 59 | x: VarArg("str") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 54 54 | @@ -325,16 +342,17 @@ UP037_0.py:57:20: UP037 [*] Remove quotes from type annotation 59 59 | x: VarArg("str") 60 60 | -UP037_0.py:59:11: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:59:11 | 57 | x: DefaultNamedArg("str", name="name") 58 | 59 | x: VarArg("str") - | ^^^^^ UP037 + | ^^^^^ 60 | 61 | x: List[List[List["MyClass"]]] | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 56 56 | @@ -346,16 +364,17 @@ UP037_0.py:59:11: UP037 [*] Remove quotes from type annotation 61 61 | x: List[List[List["MyClass"]]] 62 62 | -UP037_0.py:61:19: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:61:19 | 59 | x: VarArg("str") 60 | 61 | x: List[List[List["MyClass"]]] - | ^^^^^^^^^ UP037 + | ^^^^^^^^^ 62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 58 58 | @@ -367,16 +386,17 @@ UP037_0.py:61:19: UP037 [*] Remove quotes from type annotation 63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 64 | -UP037_0.py:63:29: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:63:29 | 61 | x: List[List[List["MyClass"]]] 62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 60 60 | @@ -388,16 +408,17 @@ UP037_0.py:63:29: UP037 [*] Remove quotes from type annotation 65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 66 | -UP037_0.py:63:45: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:63:45 | 61 | x: List[List[List["MyClass"]]] 62 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 60 60 | @@ -409,16 +430,17 @@ UP037_0.py:63:45: UP037 [*] Remove quotes from type annotation 65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 66 | -UP037_0.py:65:29: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:65:29 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 62 62 | @@ -430,16 +452,17 @@ UP037_0.py:65:29: UP037 [*] Remove quotes from type annotation 67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) 68 68 | -UP037_0.py:65:36: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:65:36 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 62 62 | @@ -451,16 +474,17 @@ UP037_0.py:65:36: UP037 [*] Remove quotes from type annotation 67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) 68 68 | -UP037_0.py:65:45: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:65:45 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 62 62 | @@ -472,16 +496,17 @@ UP037_0.py:65:45: UP037 [*] Remove quotes from type annotation 67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) 68 68 | -UP037_0.py:65:52: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:65:52 | 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) 64 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 + | ^^^^^ 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 62 62 | @@ -493,16 +518,17 @@ UP037_0.py:65:52: UP037 [*] Remove quotes from type annotation 67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) 68 68 | -UP037_0.py:67:24: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:67:24 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^ UP037 + | ^^^ 68 | 69 | X: MyCallable("X") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 64 64 | @@ -514,16 +540,17 @@ UP037_0.py:67:24: UP037 [*] Remove quotes from type annotation 69 69 | X: MyCallable("X") 70 70 | -UP037_0.py:67:38: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:67:38 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^^^ UP037 + | ^^^^^ 68 | 69 | X: MyCallable("X") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 64 64 | @@ -535,16 +562,17 @@ UP037_0.py:67:38: UP037 [*] Remove quotes from type annotation 69 69 | X: MyCallable("X") 70 70 | -UP037_0.py:67:45: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:67:45 | 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) 66 | 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^^^ UP037 + | ^^^^^ 68 | 69 | X: MyCallable("X") | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 64 64 | @@ -556,15 +584,16 @@ UP037_0.py:67:45: UP037 [*] Remove quotes from type annotation 69 69 | X: MyCallable("X") 70 70 | -UP037_0.py:112:12: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:112:12 | 110 | # Handle end of line comment in string annotation 111 | # See https://github.com/astral-sh/ruff/issues/15816 112 | def f() -> "Literal[0]#": - | ^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^ 113 | return 0 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 109 109 | @@ -577,15 +606,16 @@ UP037_0.py:112:12: UP037 [*] Remove quotes from type annotation 114 115 | 115 116 | def g(x: "Literal['abc']#") -> None: -UP037_0.py:115:10: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:115:10 | 113 | return 0 114 | 115 | def g(x: "Literal['abc']#") -> None: - | ^^^^^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^^^^^ 116 | return | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 112 112 | def f() -> "Literal[0]#": @@ -598,7 +628,8 @@ UP037_0.py:115:10: UP037 [*] Remove quotes from type annotation 117 118 | 118 119 | def f() -> """Literal[0] -UP037_0.py:118:12: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_0.py:118:12 | 116 | return 117 | @@ -607,10 +638,10 @@ UP037_0.py:118:12: UP037 [*] Remove quotes from type annotation 119 | | # 120 | | 121 | | """: - | |_______^ UP037 + | |_______^ 122 | return 0 | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 115 115 | def g(x: "Literal['abc']#") -> None: diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_1.py.snap index 1f195271c7..c6844b63cf 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_1.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_1.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP037_1.py:9:8: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_1.py:9:8 | 7 | def foo(): 8 | # UP037 9 | x: "Tuple[int, int]" = (0, 0) - | ^^^^^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^^^^^ 10 | print(x) | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 6 6 | @@ -21,13 +22,14 @@ UP037_1.py:9:8: UP037 [*] Remove quotes from type annotation 11 11 | 12 12 | -UP037_1.py:14:4: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_1.py:14:4 | 13 | # OK 14 | X: "Tuple[int, int]" = (0, 0) - | ^^^^^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_2.pyi.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_2.pyi.snap index dd66f98b51..e10f3761d3 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_2.pyi.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__add_future_annotation_UP037_2.pyi.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP037_2.pyi:3:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:3:14 | 1 | # https://github.com/astral-sh/ruff/issues/7102 2 | 3 | def f(a: Foo['SingleLine # Comment']): ... - | ^^^^^^^^^^^^^^^^^^^^^^^ UP037 + | ^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 1 1 | # https://github.com/astral-sh/ruff/issues/7102 @@ -20,15 +21,16 @@ UP037_2.pyi:3:14: UP037 [*] Remove quotes from type annotation 5 6 | 6 7 | def f(a: Foo['''Bar[ -UP037_2.pyi:6:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:6:14 | 6 | def f(a: Foo['''Bar[ | ______________^ 7 | | Multi | 8 | | Line]''']): ... - | |____________^ UP037 + | |____________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 3 3 | def f(a: Foo['SingleLine # Comment']): ... @@ -43,16 +45,17 @@ UP037_2.pyi:6:14: UP037 [*] Remove quotes from type annotation 10 10 | 11 11 | def f(a: Foo['''Bar[ -UP037_2.pyi:11:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:11:14 | 11 | def f(a: Foo['''Bar[ | ______________^ 12 | | Multi | 13 | | Line # Comment 14 | | ]''']): ... - | |____^ UP037 + | |____^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 8 8 | Line]''']): ... @@ -68,15 +71,16 @@ UP037_2.pyi:11:14: UP037 [*] Remove quotes from type annotation 16 16 | 17 17 | def f(a: Foo['''Bar[ -UP037_2.pyi:17:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:17:14 | 17 | def f(a: Foo['''Bar[ | ______________^ 18 | | Multi | 19 | | Line] # Comment''']): ... - | |_______________________^ UP037 + | |_______________________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 14 14 | ]''']): ... @@ -92,16 +96,17 @@ UP037_2.pyi:17:14: UP037 [*] Remove quotes from type annotation 21 22 | 22 23 | def f(a: Foo[''' -UP037_2.pyi:22:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:22:14 | 22 | def f(a: Foo[''' | ______________^ 23 | | Bar[ 24 | | Multi | 25 | | Line] # Comment''']): ... - | |_______________________^ UP037 + | |_______________________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 19 19 | Line] # Comment''']): ... @@ -118,14 +123,15 @@ UP037_2.pyi:22:14: UP037 [*] Remove quotes from type annotation 27 28 | 28 29 | def f(a: '''list[int] -UP037_2.pyi:28:10: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:28:10 | 28 | def f(a: '''list[int] | __________^ 29 | | ''' = []): ... - | |_______^ UP037 + | |_______^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 25 25 | Line] # Comment''']): ... @@ -139,14 +145,15 @@ UP037_2.pyi:28:10: UP037 [*] Remove quotes from type annotation 31 31 | 32 32 | a: '''\\ -UP037_2.pyi:32:4: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:32:4 | 32 | a: '''\\ | ____^ 33 | | list[int]''' = [42] - | |____________^ UP037 + | |____________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 29 29 | ''' = []): ... @@ -160,15 +167,16 @@ UP037_2.pyi:32:4: UP037 [*] Remove quotes from type annotation 35 35 | 36 36 | def f(a: ''' -UP037_2.pyi:36:10: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:36:10 | 36 | def f(a: ''' | __________^ 37 | | list[int] 38 | | ''' = []): ... - | |_______^ UP037 + | |_______^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 33 33 | list[int]''' = [42] @@ -183,7 +191,8 @@ UP037_2.pyi:36:10: UP037 [*] Remove quotes from type annotation 40 40 | 41 41 | def f(a: Foo[''' -UP037_2.pyi:41:14: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:41:14 | 41 | def f(a: Foo[''' | ______________^ @@ -192,9 +201,9 @@ UP037_2.pyi:41:14: UP037 [*] Remove quotes from type annotation 44 | | Multi | 45 | | Line 46 | | ] # Comment''']): ... - | |___________________^ UP037 + | |___________________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 38 38 | ''' = []): ... @@ -213,14 +222,15 @@ UP037_2.pyi:41:14: UP037 [*] Remove quotes from type annotation 48 49 | 49 50 | a: '''list -UP037_2.pyi:49:4: UP037 [*] Remove quotes from type annotation +UP037 [*] Remove quotes from type annotation + --> UP037_2.pyi:49:4 | 49 | a: '''list | ____^ 50 | | [int]''' = [42] - | |________^ UP037 + | |________^ | - = help: Remove quotes +help: Remove quotes ℹ Safe fix 46 46 | ] # Comment''']): ... diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__async_timeout_error_alias_not_applied_py310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__async_timeout_error_alias_not_applied_py310.snap index 3e307f7aa2..be9313bc3f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__async_timeout_error_alias_not_applied_py310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__async_timeout_error_alias_not_applied_py310.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP041.py:10:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:10:8 | 8 | try: 9 | pass 10 | except socket.timeout: - | ^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^ 11 | pass | - = help: Replace `socket.timeout` with builtin `TimeoutError` +help: Replace `socket.timeout` with builtin `TimeoutError` ℹ Safe fix 7 7 | @@ -22,15 +22,16 @@ UP041.py:10:8: UP041 [*] Replace aliased errors with `TimeoutError` 12 12 | 13 13 | # Should NOT be in parentheses when replaced -UP041.py:22:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:22:8 | 20 | try: 21 | pass 22 | except (socket.timeout,): - | ^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Replace with builtin `TimeoutError` +help: Replace with builtin `TimeoutError` ℹ Safe fix 19 19 | @@ -42,15 +43,16 @@ UP041.py:22:8: UP041 [*] Replace aliased errors with `TimeoutError` 24 24 | 25 25 | try: -UP041.py:27:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:27:8 | 25 | try: 26 | pass 27 | except (asyncio.TimeoutError, socket.timeout,): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | pass | - = help: Replace with builtin `TimeoutError` +help: Replace with builtin `TimeoutError` ℹ Safe fix 24 24 | @@ -62,15 +64,16 @@ UP041.py:27:8: UP041 [*] Replace aliased errors with `TimeoutError` 29 29 | 30 30 | # Should be kept in parentheses (because multiple) -UP041.py:34:8: UP041 [*] Replace aliased errors with `TimeoutError` +UP041 [*] Replace aliased errors with `TimeoutError` + --> UP041.py:34:8 | 32 | try: 33 | pass 34 | except (asyncio.TimeoutError, socket.timeout, KeyError, TimeoutError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | pass | - = help: Replace with builtin `TimeoutError` +help: Replace with builtin `TimeoutError` ℹ Safe fix 31 31 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap index b236c324f1..d3293b6ea9 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -UP017.py:10:11: UP017 [*] Use `datetime.UTC` alias +UP017 [*] Use `datetime.UTC` alias + --> UP017.py:10:11 | 8 | from datetime import timezone 9 | 10 | print(timezone.utc) - | ^^^^^^^^^^^^ UP017 + | ^^^^^^^^^^^^ | - = help: Convert to `datetime.UTC` alias +help: Convert to `datetime.UTC` alias ℹ Safe fix 1 |+from datetime import UTC @@ -25,14 +26,15 @@ UP017.py:10:11: UP017 [*] Use `datetime.UTC` alias 12 13 | 13 14 | def func(): -UP017.py:16:11: UP017 [*] Use `datetime.UTC` alias +UP017 [*] Use `datetime.UTC` alias + --> UP017.py:16:11 | 14 | from datetime import timezone as tz 15 | 16 | print(tz.utc) - | ^^^^^^ UP017 + | ^^^^^^ | - = help: Convert to `datetime.UTC` alias +help: Convert to `datetime.UTC` alias ℹ Safe fix 1 |+from datetime import UTC @@ -49,14 +51,15 @@ UP017.py:16:11: UP017 [*] Use `datetime.UTC` alias 18 19 | 19 20 | def func(): -UP017.py:22:11: UP017 [*] Use `datetime.UTC` alias +UP017 [*] Use `datetime.UTC` alias + --> UP017.py:22:11 | 20 | import datetime 21 | 22 | print(datetime.timezone.utc) - | ^^^^^^^^^^^^^^^^^^^^^ UP017 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to `datetime.UTC` alias +help: Convert to `datetime.UTC` alias ℹ Safe fix 19 19 | def func(): @@ -68,14 +71,15 @@ UP017.py:22:11: UP017 [*] Use `datetime.UTC` alias 24 24 | 25 25 | def func(): -UP017.py:28:11: UP017 [*] Use `datetime.UTC` alias +UP017 [*] Use `datetime.UTC` alias + --> UP017.py:28:11 | 26 | import datetime as dt 27 | 28 | print(dt.timezone.utc) - | ^^^^^^^^^^^^^^^ UP017 + | ^^^^^^^^^^^^^^^ | - = help: Convert to `datetime.UTC` alias +help: Convert to `datetime.UTC` alias ℹ Safe fix 25 25 | def func(): diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap index eb69749335..6721f49726 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:34:18 | 34 | def f(x: int) -> List[int]: - | ^^^^ UP006 + | ^^^^ 35 | y = List[int]() 36 | y.append(x) | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 31 31 | return cls(x=0, y=0) @@ -20,15 +21,16 @@ future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type ann 36 36 | y.append(x) 37 37 | return y -future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:35:9 | 34 | def f(x: int) -> List[int]: 35 | y = List[int]() - | ^^^^ UP006 + | ^^^^ 36 | y.append(x) 37 | return y | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 32 32 | @@ -40,14 +42,15 @@ future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type anno 37 37 | return y 38 38 | -future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:42:27 | 40 | x: Optional[int] = None 41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^ UP006 + | ^^^^ | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 39 39 | @@ -56,14 +59,15 @@ future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type ann 42 |-MyList: TypeAlias = Union[List[int], List[str]] 42 |+MyList: TypeAlias = Union[list[int], List[str]] -future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:42:38 | 40 | x: Optional[int] = None 41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^ UP006 + | ^^^^ | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 39 39 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap index afe64ea69a..0958d4f9ed 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:34:18 | 34 | def f(x: int) -> List[int]: - | ^^^^ UP006 + | ^^^^ 35 | y = List[int]() 36 | y.append(x) | - = help: Replace with `list` +help: Replace with `list` ℹ Unsafe fix 31 31 | return cls(x=0, y=0) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap index eb69749335..6721f49726 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:34:18 | 34 | def f(x: int) -> List[int]: - | ^^^^ UP006 + | ^^^^ 35 | y = List[int]() 36 | y.append(x) | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 31 31 | return cls(x=0, y=0) @@ -20,15 +21,16 @@ future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type ann 36 36 | y.append(x) 37 37 | return y -future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:35:9 | 34 | def f(x: int) -> List[int]: 35 | y = List[int]() - | ^^^^ UP006 + | ^^^^ 36 | y.append(x) 37 | return y | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 32 32 | @@ -40,14 +42,15 @@ future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type anno 37 37 | return y 38 38 | -future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:42:27 | 40 | x: Optional[int] = None 41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^ UP006 + | ^^^^ | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 39 39 | @@ -56,14 +59,15 @@ future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type ann 42 |-MyList: TypeAlias = Union[List[int], List[str]] 42 |+MyList: TypeAlias = Union[list[int], List[str]] -future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type annotation +UP006 [*] Use `list` instead of `List` for type annotation + --> future_annotations.py:42:38 | 40 | x: Optional[int] = None 41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^ UP006 + | ^^^^ | - = help: Replace with `list` +help: Replace with `list` ℹ Safe fix 39 39 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap index 29df4b48bb..51b92eec81 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -future_annotations.py:40:4: UP045 [*] Use `X | None` for type annotations +UP045 [*] Use `X | None` for type annotations + --> future_annotations.py:40:4 | 40 | x: Optional[int] = None - | ^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^ 41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | - = help: Convert to `X | None` +help: Convert to `X | None` ℹ Unsafe fix 37 37 | return y diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap index 163b0a8cb5..dffe011bc4 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs --- -future_annotations.py:40:4: UP045 [*] Use `X | None` for type annotations +UP045 [*] Use `X | None` for type annotations + --> future_annotations.py:40:4 | 40 | x: Optional[int] = None - | ^^^^^^^^^^^^^ UP045 + | ^^^^^^^^^^^^^ 41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] | - = help: Convert to `X | None` +help: Convert to `X | None` ℹ Safe fix 37 37 | return y @@ -19,14 +20,15 @@ future_annotations.py:40:4: UP045 [*] Use `X | None` for type annotations 41 41 | 42 42 | MyList: TypeAlias = Union[List[int], List[str]] -future_annotations.py:42:21: UP007 [*] Use `X | Y` for type annotations +UP007 [*] Use `X | Y` for type annotations + --> future_annotations.py:42:21 | 40 | x: Optional[int] = None 41 | 42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Convert to `X | Y` +help: Convert to `X | Y` ℹ Safe fix 39 39 | diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__unpack_pep_646_py311.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__unpack_pep_646_py311.snap index 3407035b9a..d87e952262 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__unpack_pep_646_py311.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__unpack_pep_646_py311.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/pyupgrade/mod.rs -snapshot_kind: text --- -UP044.py:6:17: UP044 [*] Use `*` for unpacking +UP044 [*] Use `*` for unpacking + --> UP044.py:6:17 | 6 | class C(Generic[Unpack[Shape]]): - | ^^^^^^^^^^^^^ UP044 + | ^^^^^^^^^^^^^ 7 | pass | - = help: Convert to `*` for unpacking +help: Convert to `*` for unpacking ℹ Unsafe fix 3 3 | Shape = TypeVarTuple("Shape") @@ -20,13 +20,14 @@ UP044.py:6:17: UP044 [*] Use `*` for unpacking 8 8 | 9 9 | -UP044.py:10:17: UP044 [*] Use `*` for unpacking +UP044 [*] Use `*` for unpacking + --> UP044.py:10:17 | 10 | class D(Generic[Unpack[Shape]]): - | ^^^^^^^^^^^^^ UP044 + | ^^^^^^^^^^^^^ 11 | pass | - = help: Convert to `*` for unpacking +help: Convert to `*` for unpacking ℹ Unsafe fix 7 7 | pass @@ -38,13 +39,14 @@ UP044.py:10:17: UP044 [*] Use `*` for unpacking 12 12 | 13 13 | -UP044.py:14:14: UP044 [*] Use `*` for unpacking +UP044 [*] Use `*` for unpacking + --> UP044.py:14:14 | 14 | def f(*args: Unpack[tuple[int, ...]]): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP044 + | ^^^^^^^^^^^^^^^^^^^^^^^ 15 | pass | - = help: Convert to `*` for unpacking +help: Convert to `*` for unpacking ℹ Unsafe fix 11 11 | pass @@ -56,13 +58,14 @@ UP044.py:14:14: UP044 [*] Use `*` for unpacking 16 16 | 17 17 | -UP044.py:18:14: UP044 [*] Use `*` for unpacking +UP044 [*] Use `*` for unpacking + --> UP044.py:18:14 | 18 | def f(*args: Unpack[other.Type]): - | ^^^^^^^^^^^^^^^^^^ UP044 + | ^^^^^^^^^^^^^^^^^^ 19 | pass | - = help: Convert to `*` for unpacking +help: Convert to `*` for unpacking ℹ Unsafe fix 15 15 | pass @@ -74,13 +77,14 @@ UP044.py:18:14: UP044 [*] Use `*` for unpacking 20 20 | 21 21 | -UP044.py:22:27: UP044 [*] Use `*` for unpacking +UP044 [*] Use `*` for unpacking + --> UP044.py:22:27 | 22 | def f(*args: Generic[int, Unpack[int]]): - | ^^^^^^^^^^^ UP044 + | ^^^^^^^^^^^ 23 | pass | - = help: Convert to `*` for unpacking +help: Convert to `*` for unpacking ℹ Unsafe fix 19 19 | pass diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB101_FURB101.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB101_FURB101.py.snap index 7e1899006c..c5a417db0d 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB101_FURB101.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB101_FURB101.py.snap @@ -1,87 +1,96 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- -FURB101.py:12:6: FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text()` +FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text()` + --> FURB101.py:12:6 | 11 | # FURB101 12 | with open("file.txt") as f: - | ^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^ 13 | x = f.read() | -FURB101.py:16:6: FURB101 `open` and `read` should be replaced by `Path("file.txt").read_bytes()` +FURB101 `open` and `read` should be replaced by `Path("file.txt").read_bytes()` + --> FURB101.py:16:6 | 15 | # FURB101 16 | with open("file.txt", "rb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | x = f.read() | -FURB101.py:20:6: FURB101 `open` and `read` should be replaced by `Path("file.txt").read_bytes()` +FURB101 `open` and `read` should be replaced by `Path("file.txt").read_bytes()` + --> FURB101.py:20:6 | 19 | # FURB101 20 | with open("file.txt", mode="rb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | x = f.read() | -FURB101.py:24:6: FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text(encoding="utf8")` +FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text(encoding="utf8")` + --> FURB101.py:24:6 | 23 | # FURB101 24 | with open("file.txt", encoding="utf8") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | x = f.read() | -FURB101.py:28:6: FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text(errors="ignore")` +FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text(errors="ignore")` + --> FURB101.py:28:6 | 27 | # FURB101 28 | with open("file.txt", errors="ignore") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | x = f.read() | -FURB101.py:32:6: FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text()` +FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text()` + --> FURB101.py:32:6 | 31 | # FURB101 32 | with open("file.txt", mode="r") as f: # noqa: FURB120 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | x = f.read() | -FURB101.py:36:6: FURB101 `open` and `read` should be replaced by `Path(foo()).read_bytes()` +FURB101 `open` and `read` should be replaced by `Path(foo()).read_bytes()` + --> FURB101.py:36:6 | 35 | # FURB101 36 | with open(foo(), "rb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^^ 37 | # The body of `with` is non-trivial, but the recommendation holds. 38 | bar("pre") | -FURB101.py:44:6: FURB101 `open` and `read` should be replaced by `Path("a.txt").read_text()` +FURB101 `open` and `read` should be replaced by `Path("a.txt").read_text()` + --> FURB101.py:44:6 | 43 | # FURB101 44 | with open("a.txt") as a, open("b.txt", "rb") as b: - | ^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^ 45 | x = a.read() 46 | y = b.read() | -FURB101.py:44:26: FURB101 `open` and `read` should be replaced by `Path("b.txt").read_bytes()` +FURB101 `open` and `read` should be replaced by `Path("b.txt").read_bytes()` + --> FURB101.py:44:26 | 43 | # FURB101 44 | with open("a.txt") as a, open("b.txt", "rb") as b: - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 45 | x = a.read() 46 | y = b.read() | -FURB101.py:49:18: FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text()` +FURB101 `open` and `read` should be replaced by `Path("file.txt").read_text()` + --> FURB101.py:49:18 | 48 | # FURB101 49 | with foo() as a, open("file.txt") as b, foo() as c: - | ^^^^^^^^^^^^^^^^^^^^^ FURB101 + | ^^^^^^^^^^^^^^^^^^^^^ 50 | # We have other things in here, multiple with items, but 51 | # the user reads the whole file and that bit they can replace. | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB103_FURB103.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB103_FURB103.py.snap index 81a420fbc8..908ac8f6f7 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB103_FURB103.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB103_FURB103.py.snap @@ -1,111 +1,123 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- -FURB103.py:12:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text("test")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text("test")` + --> FURB103.py:12:6 | 11 | # FURB103 12 | with open("file.txt", "w") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | f.write("test") | -FURB103.py:16:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_bytes(foobar)` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_bytes(foobar)` + --> FURB103.py:16:6 | 15 | # FURB103 16 | with open("file.txt", "wb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | f.write(foobar) | -FURB103.py:20:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_bytes(b"abc")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_bytes(b"abc")` + --> FURB103.py:20:6 | 19 | # FURB103 20 | with open("file.txt", mode="wb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | f.write(b"abc") | -FURB103.py:24:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, encoding="utf8")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, encoding="utf8")` + --> FURB103.py:24:6 | 23 | # FURB103 24 | with open("file.txt", "w", encoding="utf8") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | f.write(foobar) | -FURB103.py:28:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, errors="ignore")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, errors="ignore")` + --> FURB103.py:28:6 | 27 | # FURB103 28 | with open("file.txt", "w", errors="ignore") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | f.write(foobar) | -FURB103.py:32:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar)` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar)` + --> FURB103.py:32:6 | 31 | # FURB103 32 | with open("file.txt", mode="w") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | f.write(foobar) | -FURB103.py:36:6: FURB103 `open` and `write` should be replaced by `Path(foo()).write_bytes(bar())` +FURB103 `open` and `write` should be replaced by `Path(foo()).write_bytes(bar())` + --> FURB103.py:36:6 | 35 | # FURB103 36 | with open(foo(), "wb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^ 37 | # The body of `with` is non-trivial, but the recommendation holds. 38 | bar("pre") | -FURB103.py:44:6: FURB103 `open` and `write` should be replaced by `Path("a.txt").write_text(x)` +FURB103 `open` and `write` should be replaced by `Path("a.txt").write_text(x)` + --> FURB103.py:44:6 | 43 | # FURB103 44 | with open("a.txt", "w") as a, open("b.txt", "wb") as b: - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^ 45 | a.write(x) 46 | b.write(y) | -FURB103.py:44:31: FURB103 `open` and `write` should be replaced by `Path("b.txt").write_bytes(y)` +FURB103 `open` and `write` should be replaced by `Path("b.txt").write_bytes(y)` + --> FURB103.py:44:31 | 43 | # FURB103 44 | with open("a.txt", "w") as a, open("b.txt", "wb") as b: - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 45 | a.write(x) 46 | b.write(y) | -FURB103.py:49:18: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(bar(bar(a + x)))` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(bar(bar(a + x)))` + --> FURB103.py:49:18 | 48 | # FURB103 49 | with foo() as a, open("file.txt", "w") as b, foo() as c: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | # We have other things in here, multiple with items, but the user 51 | # writes a single time to file and that bit they can replace. | -FURB103.py:58:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, newline="\r\n")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, newline="\r\n")` + --> FURB103.py:58:6 | 57 | # FURB103 58 | with open("file.txt", "w", newline="\r\n") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 59 | f.write(foobar) | -FURB103.py:66:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, newline="\r\n")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, newline="\r\n")` + --> FURB103.py:66:6 | 65 | # FURB103 66 | with builtins.open("file.txt", "w", newline="\r\n") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 | f.write(foobar) | -FURB103.py:74:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, newline="\r\n")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, newline="\r\n")` + --> FURB103.py:74:6 | 73 | # FURB103 74 | with o("file.txt", "w", newline="\r\n") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 75 | f.write(foobar) | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap index f4db6c7a56..7896595ffa 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB105_FURB105.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB105.py:3:1: FURB105 [*] Unnecessary empty string passed to `print` +FURB105 [*] Unnecessary empty string passed to `print` + --> FURB105.py:3:1 | 1 | # Errors. 2 | 3 | print("") - | ^^^^^^^^^ FURB105 + | ^^^^^^^^^ 4 | print("", sep=",") 5 | print("", end="bar") | - = help: Remove empty string +help: Remove empty string ℹ Safe fix 1 1 | # Errors. @@ -21,15 +22,16 @@ FURB105.py:3:1: FURB105 [*] Unnecessary empty string passed to `print` 5 5 | print("", end="bar") 6 6 | print("", sep=",", end="bar") -FURB105.py:4:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:4:1 | 3 | print("") 4 | print("", sep=",") - | ^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^ 5 | print("", end="bar") 6 | print("", sep=",", end="bar") | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 1 1 | # Errors. @@ -41,16 +43,17 @@ FURB105.py:4:1: FURB105 [*] Unnecessary empty string and separator passed to `pr 6 6 | print("", sep=",", end="bar") 7 7 | print(sep="") -FURB105.py:5:1: FURB105 [*] Unnecessary empty string passed to `print` +FURB105 [*] Unnecessary empty string passed to `print` + --> FURB105.py:5:1 | 3 | print("") 4 | print("", sep=",") 5 | print("", end="bar") - | ^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^ 6 | print("", sep=",", end="bar") 7 | print(sep="") | - = help: Remove empty string +help: Remove empty string ℹ Safe fix 2 2 | @@ -62,16 +65,17 @@ FURB105.py:5:1: FURB105 [*] Unnecessary empty string passed to `print` 7 7 | print(sep="") 8 8 | print("", sep="") -FURB105.py:6:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:6:1 | 4 | print("", sep=",") 5 | print("", end="bar") 6 | print("", sep=",", end="bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | print(sep="") 8 | print("", sep="") | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 3 3 | print("") @@ -83,16 +87,17 @@ FURB105.py:6:1: FURB105 [*] Unnecessary empty string and separator passed to `pr 8 8 | print("", sep="") 9 9 | print("", "", sep="") -FURB105.py:7:1: FURB105 [*] Unnecessary separator passed to `print` +FURB105 [*] Unnecessary separator passed to `print` + --> FURB105.py:7:1 | 5 | print("", end="bar") 6 | print("", sep=",", end="bar") 7 | print(sep="") - | ^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^ 8 | print("", sep="") 9 | print("", "", sep="") | - = help: Remove separator +help: Remove separator ℹ Safe fix 4 4 | print("", sep=",") @@ -104,16 +109,17 @@ FURB105.py:7:1: FURB105 [*] Unnecessary separator passed to `print` 9 9 | print("", "", sep="") 10 10 | print("", "", sep="", end="") -FURB105.py:8:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:8:1 | 6 | print("", sep=",", end="bar") 7 | print(sep="") 8 | print("", sep="") - | ^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^ 9 | print("", "", sep="") 10 | print("", "", sep="", end="") | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 5 5 | print("", end="bar") @@ -125,16 +131,17 @@ FURB105.py:8:1: FURB105 [*] Unnecessary empty string and separator passed to `pr 10 10 | print("", "", sep="", end="") 11 11 | print("", "", sep="", end="bar") -FURB105.py:9:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:9:1 | 7 | print(sep="") 8 | print("", sep="") 9 | print("", "", sep="") - | ^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^ 10 | print("", "", sep="", end="") 11 | print("", "", sep="", end="bar") | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 6 6 | print("", sep=",", end="bar") @@ -146,16 +153,17 @@ FURB105.py:9:1: FURB105 [*] Unnecessary empty string and separator passed to `pr 11 11 | print("", "", sep="", end="bar") 12 12 | print("", sep="", end="bar") -FURB105.py:10:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:10:1 | 8 | print("", sep="") 9 | print("", "", sep="") 10 | print("", "", sep="", end="") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | print("", "", sep="", end="bar") 12 | print("", sep="", end="bar") | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 7 7 | print(sep="") @@ -167,16 +175,17 @@ FURB105.py:10:1: FURB105 [*] Unnecessary empty string and separator passed to `p 12 12 | print("", sep="", end="bar") 13 13 | print(sep="", end="bar") -FURB105.py:11:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:11:1 | 9 | print("", "", sep="") 10 | print("", "", sep="", end="") 11 | print("", "", sep="", end="bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | print("", sep="", end="bar") 13 | print(sep="", end="bar") | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 8 8 | print("", sep="") @@ -188,16 +197,17 @@ FURB105.py:11:1: FURB105 [*] Unnecessary empty string and separator passed to `p 13 13 | print(sep="", end="bar") 14 14 | print("", "foo", sep="") -FURB105.py:12:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:12:1 | 10 | print("", "", sep="", end="") 11 | print("", "", sep="", end="bar") 12 | print("", sep="", end="bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | print(sep="", end="bar") 14 | print("", "foo", sep="") | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 9 9 | print("", "", sep="") @@ -209,16 +219,17 @@ FURB105.py:12:1: FURB105 [*] Unnecessary empty string and separator passed to `p 14 14 | print("", "foo", sep="") 15 15 | print("foo", "", sep="") -FURB105.py:13:1: FURB105 [*] Unnecessary separator passed to `print` +FURB105 [*] Unnecessary separator passed to `print` + --> FURB105.py:13:1 | 11 | print("", "", sep="", end="bar") 12 | print("", sep="", end="bar") 13 | print(sep="", end="bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 14 | print("", "foo", sep="") 15 | print("foo", "", sep="") | - = help: Remove separator +help: Remove separator ℹ Safe fix 10 10 | print("", "", sep="", end="") @@ -230,16 +241,17 @@ FURB105.py:13:1: FURB105 [*] Unnecessary separator passed to `print` 15 15 | print("foo", "", sep="") 16 16 | print("foo", "", "bar", sep="") -FURB105.py:14:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:14:1 | 12 | print("", sep="", end="bar") 13 | print(sep="", end="bar") 14 | print("", "foo", sep="") - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 15 | print("foo", "", sep="") 16 | print("foo", "", "bar", sep="") | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 11 11 | print("", "", sep="", end="bar") @@ -251,16 +263,17 @@ FURB105.py:14:1: FURB105 [*] Unnecessary empty string and separator passed to `p 16 16 | print("foo", "", "bar", sep="") 17 17 | print("", *args) -FURB105.py:15:1: FURB105 [*] Unnecessary empty string and separator passed to `print` +FURB105 [*] Unnecessary empty string and separator passed to `print` + --> FURB105.py:15:1 | 13 | print(sep="", end="bar") 14 | print("", "foo", sep="") 15 | print("foo", "", sep="") - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 16 | print("foo", "", "bar", sep="") 17 | print("", *args) | - = help: Remove empty string and separator +help: Remove empty string and separator ℹ Safe fix 12 12 | print("", sep="", end="bar") @@ -272,16 +285,17 @@ FURB105.py:15:1: FURB105 [*] Unnecessary empty string and separator passed to `p 17 17 | print("", *args) 18 18 | print("", *args, sep="") -FURB105.py:16:1: FURB105 [*] Unnecessary empty string passed to `print` +FURB105 [*] Unnecessary empty string passed to `print` + --> FURB105.py:16:1 | 14 | print("", "foo", sep="") 15 | print("foo", "", sep="") 16 | print("foo", "", "bar", sep="") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | print("", *args) 18 | print("", *args, sep="") | - = help: Remove empty string +help: Remove empty string ℹ Safe fix 13 13 | print(sep="", end="bar") @@ -293,16 +307,17 @@ FURB105.py:16:1: FURB105 [*] Unnecessary empty string passed to `print` 18 18 | print("", *args, sep="") 19 19 | print("", **kwargs) -FURB105.py:18:1: FURB105 [*] Unnecessary empty string passed to `print` +FURB105 [*] Unnecessary empty string passed to `print` + --> FURB105.py:18:1 | 16 | print("foo", "", "bar", sep="") 17 | print("", *args) 18 | print("", *args, sep="") - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 19 | print("", **kwargs) 20 | print(sep="\t") | - = help: Remove empty string +help: Remove empty string ℹ Safe fix 15 15 | print("foo", "", sep="") @@ -314,16 +329,17 @@ FURB105.py:18:1: FURB105 [*] Unnecessary empty string passed to `print` 20 20 | print(sep="\t") 21 21 | print(sep=print(1)) -FURB105.py:19:1: FURB105 [*] Unnecessary empty string passed to `print` +FURB105 [*] Unnecessary empty string passed to `print` + --> FURB105.py:19:1 | 17 | print("", *args) 18 | print("", *args, sep="") 19 | print("", **kwargs) - | ^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^ 20 | print(sep="\t") 21 | print(sep=print(1)) | - = help: Remove empty string +help: Remove empty string ℹ Safe fix 16 16 | print("foo", "", "bar", sep="") @@ -335,15 +351,16 @@ FURB105.py:19:1: FURB105 [*] Unnecessary empty string passed to `print` 21 21 | print(sep=print(1)) 22 22 | -FURB105.py:20:1: FURB105 [*] Unnecessary separator passed to `print` +FURB105 [*] Unnecessary separator passed to `print` + --> FURB105.py:20:1 | 18 | print("", *args, sep="") 19 | print("", **kwargs) 20 | print(sep="\t") - | ^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^ 21 | print(sep=print(1)) | - = help: Remove separator +help: Remove separator ℹ Safe fix 17 17 | print("", *args) @@ -355,16 +372,17 @@ FURB105.py:20:1: FURB105 [*] Unnecessary separator passed to `print` 22 22 | 23 23 | # OK. -FURB105.py:21:1: FURB105 [*] Unnecessary separator passed to `print` +FURB105 [*] Unnecessary separator passed to `print` + --> FURB105.py:21:1 | 19 | print("", **kwargs) 20 | print(sep="\t") 21 | print(sep=print(1)) - | ^^^^^^^^^^^^^^^^^^^ FURB105 + | ^^^^^^^^^^^^^^^^^^^ 22 | 23 | # OK. | - = help: Remove separator +help: Remove separator ℹ Unsafe fix 18 18 | print("", *args, sep="") diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap index cea81dcdd4..5ef02ebcf2 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB110_FURB110.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB110.py:1:5: FURB110 [*] Replace ternary `if` expression with `or` operator +FURB110 [*] Replace ternary `if` expression with `or` operator + --> FURB110.py:1:5 | 1 | z = x if x else y # FURB110 - | ^^^^^^^^^^^^^ FURB110 + | ^^^^^^^^^^^^^ 2 | 3 | z = x \ | - = help: Replace with `or` operator +help: Replace with `or` operator ℹ Safe fix 1 |-z = x if x else y # FURB110 @@ -17,18 +18,19 @@ FURB110.py:1:5: FURB110 [*] Replace ternary `if` expression with `or` operator 3 3 | z = x \ 4 4 | if x else y # FURB110 -FURB110.py:3:5: FURB110 [*] Replace ternary `if` expression with `or` operator +FURB110 [*] Replace ternary `if` expression with `or` operator + --> FURB110.py:3:5 | 1 | z = x if x else y # FURB110 2 | 3 | z = x \ | _____^ 4 | | if x else y # FURB110 - | |_______________^ FURB110 + | |_______________^ 5 | 6 | z = x if x \ | - = help: Replace with `or` operator +help: Replace with `or` operator ℹ Safe fix 1 1 | z = x if x else y # FURB110 @@ -40,7 +42,8 @@ FURB110.py:3:5: FURB110 [*] Replace ternary `if` expression with `or` operator 6 5 | z = x if x \ 7 6 | else \ -FURB110.py:6:5: FURB110 [*] Replace ternary `if` expression with `or` operator +FURB110 [*] Replace ternary `if` expression with `or` operator + --> FURB110.py:6:5 | 4 | if x else y # FURB110 5 | @@ -48,11 +51,11 @@ FURB110.py:6:5: FURB110 [*] Replace ternary `if` expression with `or` operator | _____^ 7 | | else \ 8 | | y # FURB110 - | |_________^ FURB110 + | |_________^ 9 | 10 | z = x() if x() else y() # FURB110 | - = help: Replace with `or` operator +help: Replace with `or` operator ℹ Safe fix 3 3 | z = x \ @@ -66,16 +69,17 @@ FURB110.py:6:5: FURB110 [*] Replace ternary `if` expression with `or` operator 10 8 | z = x() if x() else y() # FURB110 11 9 | -FURB110.py:10:5: FURB110 [*] Replace ternary `if` expression with `or` operator +FURB110 [*] Replace ternary `if` expression with `or` operator + --> FURB110.py:10:5 | 8 | y # FURB110 9 | 10 | z = x() if x() else y() # FURB110 - | ^^^^^^^^^^^^^^^^^^^ FURB110 + | ^^^^^^^^^^^^^^^^^^^ 11 | 12 | # FURB110 | - = help: Replace with `or` operator +help: Replace with `or` operator ℹ Unsafe fix 7 7 | else \ @@ -87,7 +91,8 @@ FURB110.py:10:5: FURB110 [*] Replace ternary `if` expression with `or` operator 12 12 | # FURB110 13 13 | z = x if ( -FURB110.py:13:5: FURB110 [*] Replace ternary `if` expression with `or` operator +FURB110 [*] Replace ternary `if` expression with `or` operator + --> FURB110.py:13:5 | 12 | # FURB110 13 | z = x if ( @@ -98,11 +103,11 @@ FURB110.py:13:5: FURB110 [*] Replace ternary `if` expression with `or` operator 17 | | # Test for y. 18 | | y 19 | | ) - | |_^ FURB110 + | |_^ 20 | 21 | # FURB110 | - = help: Replace with `or` operator +help: Replace with `or` operator ℹ Safe fix 10 10 | z = x() if x() else y() # FURB110 @@ -118,7 +123,8 @@ FURB110.py:13:5: FURB110 [*] Replace ternary `if` expression with `or` operator 18 18 | y 19 19 | ) -FURB110.py:23:5: FURB110 [*] Replace ternary `if` expression with `or` operator +FURB110 [*] Replace ternary `if` expression with `or` operator + --> FURB110.py:23:5 | 21 | # FURB110 22 | z = ( @@ -129,10 +135,10 @@ FURB110.py:23:5: FURB110 [*] Replace ternary `if` expression with `or` operator 27 | | # Test for y. 28 | | y 29 | | ) - | |_____^ FURB110 + | |_____^ 30 | ) | - = help: Replace with `or` operator +help: Replace with `or` operator ℹ Safe fix 20 20 | @@ -148,7 +154,8 @@ FURB110.py:23:5: FURB110 [*] Replace ternary `if` expression with `or` operator 28 28 | y 29 29 | ) -FURB110.py:34:5: FURB110 [*] Replace ternary `if` expression with `or` operator +FURB110 [*] Replace ternary `if` expression with `or` operator + --> FURB110.py:34:5 | 32 | # FURB110 33 | z = ( @@ -158,10 +165,10 @@ FURB110.py:34:5: FURB110 [*] Replace ternary `if` expression with `or` operator 37 | | # Otherwise, use y. 38 | | else 39 | | y - | |_____^ FURB110 + | |_____^ 40 | ) | - = help: Replace with `or` operator +help: Replace with `or` operator ℹ Safe fix 31 31 | @@ -178,7 +185,8 @@ FURB110.py:34:5: FURB110 [*] Replace ternary `if` expression with `or` operator 41 36 | 42 37 | # FURB110 -FURB110.py:44:5: FURB110 [*] Replace ternary `if` expression with `or` operator +FURB110 [*] Replace ternary `if` expression with `or` operator + --> FURB110.py:44:5 | 42 | # FURB110 43 | z = ( @@ -187,10 +195,10 @@ FURB110.py:44:5: FURB110 [*] Replace ternary `if` expression with `or` operator 46 | | else y 47 | | if y > 0 48 | | else None - | |_____________^ FURB110 + | |_____________^ 49 | ) | - = help: Replace with `or` operator +help: Replace with `or` operator ℹ Safe fix 41 41 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap index 401cf40ff6..dae98919ee 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB113.py:23:1: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` +FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` + --> FURB113.py:23:1 | 22 | # FURB113 23 | / nums.append(1) 24 | | nums.append(2) - | |______________^ FURB113 + | |______________^ 25 | pass | - = help: Replace with `nums.extend((1, 2))` +help: Replace with `nums.extend((1, 2))` ℹ Unsafe fix 20 20 | @@ -22,15 +23,16 @@ FURB113.py:23:1: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly cal 26 25 | 27 26 | -FURB113.py:29:1: FURB113 [*] Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` +FURB113 [*] Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` + --> FURB113.py:29:1 | 28 | # FURB113 29 | / nums3.append(1) 30 | | nums3.append(2) - | |_______________^ FURB113 + | |_______________^ 31 | pass | - = help: Replace with `nums3.extend((1, 2))` +help: Replace with `nums3.extend((1, 2))` ℹ Unsafe fix 26 26 | @@ -43,15 +45,16 @@ FURB113.py:29:1: FURB113 [*] Use `nums3.extend((1, 2))` instead of repeatedly ca 32 31 | 33 32 | -FURB113.py:35:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` +FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` + --> FURB113.py:35:1 | 34 | # FURB113 35 | / nums4.append(1) 36 | | nums4.append(2) - | |_______________^ FURB113 + | |_______________^ 37 | pass | - = help: Replace with `nums4.extend((1, 2))` +help: Replace with `nums4.extend((1, 2))` ℹ Unsafe fix 32 32 | @@ -64,19 +67,21 @@ FURB113.py:35:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly ca 38 37 | 39 38 | -FURB113.py:41:1: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` +FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + --> FURB113.py:41:1 | 40 | # FURB113 41 | / nums.append(1) 42 | | nums2.append(1) 43 | | nums.append(2) 44 | | nums.append(3) - | |______________^ FURB113 + | |______________^ 45 | pass | - = help: Replace with `nums.extend((1, 2, 3))` +help: Replace with `nums.extend((1, 2, 3))` -FURB113.py:49:1: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` +FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + --> FURB113.py:49:1 | 48 | # FURB113 49 | / nums.append(1) @@ -85,13 +90,14 @@ FURB113.py:49:1: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly call 52 | | # FURB113 53 | | nums3.append(1) 54 | | nums.append(3) - | |______________^ FURB113 + | |______________^ 55 | # FURB113 56 | nums4.append(1) | - = help: Replace with `nums.extend((1, 2, 3))` +help: Replace with `nums.extend((1, 2, 3))` -FURB113.py:53:1: FURB113 Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` +FURB113 Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` + --> FURB113.py:53:1 | 51 | nums.append(2) 52 | # FURB113 @@ -101,22 +107,23 @@ FURB113.py:53:1: FURB113 Use `nums3.extend((1, 2))` instead of repeatedly callin 56 | | nums4.append(1) 57 | | nums4.append(2) 58 | | nums3.append(2) - | |_______________^ FURB113 + | |_______________^ 59 | pass | - = help: Replace with `nums3.extend((1, 2))` +help: Replace with `nums3.extend((1, 2))` -FURB113.py:56:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` +FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` + --> FURB113.py:56:1 | 54 | nums.append(3) 55 | # FURB113 56 | / nums4.append(1) 57 | | nums4.append(2) - | |_______________^ FURB113 + | |_______________^ 58 | nums3.append(2) 59 | pass | - = help: Replace with `nums4.extend((1, 2))` +help: Replace with `nums4.extend((1, 2))` ℹ Unsafe fix 53 53 | nums3.append(1) @@ -129,15 +136,16 @@ FURB113.py:56:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly ca 59 58 | pass 60 59 | -FURB113.py:62:1: FURB113 [*] Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` +FURB113 [*] Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + --> FURB113.py:62:1 | 61 | # FURB113 62 | / nums.append(1) 63 | | nums.append(2) 64 | | nums.append(3) - | |______________^ FURB113 + | |______________^ | - = help: Replace with `nums.extend((1, 2, 3))` +help: Replace with `nums.extend((1, 2, 3))` ℹ Unsafe fix 59 59 | pass @@ -151,15 +159,16 @@ FURB113.py:62:1: FURB113 [*] Use `nums.extend((1, 2, 3))` instead of repeatedly 66 64 | 67 65 | if True: -FURB113.py:69:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` +FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` + --> FURB113.py:69:5 | 67 | if True: 68 | # FURB113 69 | / nums.append(1) 70 | | nums.append(2) - | |__________________^ FURB113 + | |__________________^ | - = help: Replace with `nums.extend((1, 2))` +help: Replace with `nums.extend((1, 2))` ℹ Unsafe fix 66 66 | @@ -172,16 +181,17 @@ FURB113.py:69:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly cal 72 71 | 73 72 | if True: -FURB113.py:75:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` +FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` + --> FURB113.py:75:5 | 73 | if True: 74 | # FURB113 75 | / nums.append(1) 76 | | nums.append(2) - | |__________________^ FURB113 + | |__________________^ 77 | pass | - = help: Replace with `nums.extend((1, 2))` +help: Replace with `nums.extend((1, 2))` ℹ Unsafe fix 72 72 | @@ -194,7 +204,8 @@ FURB113.py:75:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly cal 78 77 | 79 78 | -FURB113.py:82:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` +FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + --> FURB113.py:82:5 | 80 | if True: 81 | # FURB113 @@ -202,19 +213,20 @@ FURB113.py:82:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly call 83 | | nums2.append(1) 84 | | nums.append(2) 85 | | nums.append(3) - | |__________________^ FURB113 + | |__________________^ | - = help: Replace with `nums.extend((1, 2, 3))` +help: Replace with `nums.extend((1, 2, 3))` -FURB113.py:90:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` +FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + --> FURB113.py:90:5 | 88 | def yes_one(x: list[int]): 89 | # FURB113 90 | / x.append(1) 91 | | x.append(2) - | |_______________^ FURB113 + | |_______________^ | - = help: Replace with `x.extend((1, 2))` +help: Replace with `x.extend((1, 2))` ℹ Unsafe fix 87 87 | @@ -227,15 +239,16 @@ FURB113.py:90:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly callin 93 92 | 94 93 | def yes_two(x: List[int]): -FURB113.py:96:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` +FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + --> FURB113.py:96:5 | 94 | def yes_two(x: List[int]): 95 | # FURB113 96 | / x.append(1) 97 | | x.append(2) - | |_______________^ FURB113 + | |_______________^ | - = help: Replace with `x.extend((1, 2))` +help: Replace with `x.extend((1, 2))` ℹ Unsafe fix 93 93 | @@ -248,15 +261,16 @@ FURB113.py:96:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly callin 99 98 | 100 99 | def yes_three(*, x: list[int]): -FURB113.py:102:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` +FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + --> FURB113.py:102:5 | 100 | def yes_three(*, x: list[int]): 101 | # FURB113 102 | / x.append(1) 103 | | x.append(2) - | |_______________^ FURB113 + | |_______________^ | - = help: Replace with `x.extend((1, 2))` +help: Replace with `x.extend((1, 2))` ℹ Unsafe fix 99 99 | @@ -269,15 +283,16 @@ FURB113.py:102:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli 105 104 | 106 105 | def yes_four(x: list[int], /): -FURB113.py:108:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` +FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + --> FURB113.py:108:5 | 106 | def yes_four(x: list[int], /): 107 | # FURB113 108 | / x.append(1) 109 | | x.append(2) - | |_______________^ FURB113 + | |_______________^ | - = help: Replace with `x.extend((1, 2))` +help: Replace with `x.extend((1, 2))` ℹ Unsafe fix 105 105 | @@ -290,7 +305,8 @@ FURB113.py:108:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli 111 110 | 112 111 | def yes_five(x: list[int], y: list[int]): -FURB113.py:114:5: FURB113 Use `x.extend((1, 2, 3))` instead of repeatedly calling `x.append()` +FURB113 Use `x.extend((1, 2, 3))` instead of repeatedly calling `x.append()` + --> FURB113.py:114:5 | 112 | def yes_five(x: list[int], y: list[int]): 113 | # FURB113 @@ -298,19 +314,20 @@ FURB113.py:114:5: FURB113 Use `x.extend((1, 2, 3))` instead of repeatedly callin 115 | | x.append(2) 116 | | y.append(1) 117 | | x.append(3) - | |_______________^ FURB113 + | |_______________^ | - = help: Replace with `x.extend((1, 2, 3))` +help: Replace with `x.extend((1, 2, 3))` -FURB113.py:122:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` +FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + --> FURB113.py:122:5 | 120 | def yes_six(x: list): 121 | # FURB113 122 | / x.append(1) 123 | | x.append(2) - | |_______________^ FURB113 + | |_______________^ | - = help: Replace with `x.extend((1, 2))` +help: Replace with `x.extend((1, 2))` ℹ Unsafe fix 119 119 | @@ -323,7 +340,8 @@ FURB113.py:122:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calli 125 124 | 126 125 | if True: -FURB113.py:128:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` +FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + --> FURB113.py:128:5 | 126 | if True: 127 | # FURB113 @@ -332,6 +350,6 @@ FURB113.py:128:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly cal 130 | | nums.append(2) 131 | | # comment 132 | | nums.append(3) - | |__________________^ FURB113 + | |__________________^ | - = help: Replace with `nums.extend((1, 2, 3))` +help: Replace with `nums.extend((1, 2, 3))` diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap index c39547d551..803fd4aec3 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB116_FURB116.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB116.py:9:7: FURB116 Replace `oct` call with `f"{num:o}"` +FURB116 Replace `oct` call with `f"{num:o}"` + --> FURB116.py:9:7 | 7 | return num 8 | 9 | print(oct(num)[2:]) # FURB116 - | ^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^ 10 | print(hex(num)[2:]) # FURB116 11 | print(bin(num)[2:]) # FURB116 | - = help: Replace with `f"{num:o}"` +help: Replace with `f"{num:o}"` ℹ Display-only fix 6 6 | def return_num() -> int: @@ -22,14 +23,15 @@ FURB116.py:9:7: FURB116 Replace `oct` call with `f"{num:o}"` 11 11 | print(bin(num)[2:]) # FURB116 12 12 | -FURB116.py:10:7: FURB116 Replace `hex` call with `f"{num:x}"` +FURB116 Replace `hex` call with `f"{num:x}"` + --> FURB116.py:10:7 | 9 | print(oct(num)[2:]) # FURB116 10 | print(hex(num)[2:]) # FURB116 - | ^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^ 11 | print(bin(num)[2:]) # FURB116 | - = help: Replace with `f"{num:x}"` +help: Replace with `f"{num:x}"` ℹ Display-only fix 7 7 | return num @@ -41,16 +43,17 @@ FURB116.py:10:7: FURB116 Replace `hex` call with `f"{num:x}"` 12 12 | 13 13 | print(oct(1337)[2:]) # FURB116 -FURB116.py:11:7: FURB116 Replace `bin` call with `f"{num:b}"` +FURB116 Replace `bin` call with `f"{num:b}"` + --> FURB116.py:11:7 | 9 | print(oct(num)[2:]) # FURB116 10 | print(hex(num)[2:]) # FURB116 11 | print(bin(num)[2:]) # FURB116 - | ^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^ 12 | 13 | print(oct(1337)[2:]) # FURB116 | - = help: Replace with `f"{num:b}"` +help: Replace with `f"{num:b}"` ℹ Display-only fix 8 8 | @@ -62,16 +65,17 @@ FURB116.py:11:7: FURB116 Replace `bin` call with `f"{num:b}"` 13 13 | print(oct(1337)[2:]) # FURB116 14 14 | print(hex(1337)[2:]) # FURB116 -FURB116.py:13:7: FURB116 [*] Replace `oct` call with `f"{1337:o}"` +FURB116 [*] Replace `oct` call with `f"{1337:o}"` + --> FURB116.py:13:7 | 11 | print(bin(num)[2:]) # FURB116 12 | 13 | print(oct(1337)[2:]) # FURB116 - | ^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^ 14 | print(hex(1337)[2:]) # FURB116 15 | print(bin(1337)[2:]) # FURB116 | - = help: Replace with `f"{1337:o}"` +help: Replace with `f"{1337:o}"` ℹ Safe fix 10 10 | print(hex(num)[2:]) # FURB116 @@ -83,15 +87,16 @@ FURB116.py:13:7: FURB116 [*] Replace `oct` call with `f"{1337:o}"` 15 15 | print(bin(1337)[2:]) # FURB116 16 16 | print(bin(+1337)[2:]) # FURB116 -FURB116.py:14:7: FURB116 [*] Replace `hex` call with `f"{1337:x}"` +FURB116 [*] Replace `hex` call with `f"{1337:x}"` + --> FURB116.py:14:7 | 13 | print(oct(1337)[2:]) # FURB116 14 | print(hex(1337)[2:]) # FURB116 - | ^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^ 15 | print(bin(1337)[2:]) # FURB116 16 | print(bin(+1337)[2:]) # FURB116 | - = help: Replace with `f"{1337:x}"` +help: Replace with `f"{1337:x}"` ℹ Safe fix 11 11 | print(bin(num)[2:]) # FURB116 @@ -103,15 +108,16 @@ FURB116.py:14:7: FURB116 [*] Replace `hex` call with `f"{1337:x}"` 16 16 | print(bin(+1337)[2:]) # FURB116 17 17 | -FURB116.py:15:7: FURB116 [*] Replace `bin` call with `f"{1337:b}"` +FURB116 [*] Replace `bin` call with `f"{1337:b}"` + --> FURB116.py:15:7 | 13 | print(oct(1337)[2:]) # FURB116 14 | print(hex(1337)[2:]) # FURB116 15 | print(bin(1337)[2:]) # FURB116 - | ^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^ 16 | print(bin(+1337)[2:]) # FURB116 | - = help: Replace with `f"{1337:b}"` +help: Replace with `f"{1337:b}"` ℹ Safe fix 12 12 | @@ -123,16 +129,17 @@ FURB116.py:15:7: FURB116 [*] Replace `bin` call with `f"{1337:b}"` 17 17 | 18 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) -FURB116.py:16:7: FURB116 [*] Replace `bin` call with `f"{+1337:b}"` +FURB116 [*] Replace `bin` call with `f"{+1337:b}"` + --> FURB116.py:16:7 | 14 | print(hex(1337)[2:]) # FURB116 15 | print(bin(1337)[2:]) # FURB116 16 | print(bin(+1337)[2:]) # FURB116 - | ^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^ 17 | 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) | - = help: Replace with `f"{+1337:b}"` +help: Replace with `f"{+1337:b}"` ℹ Safe fix 13 13 | print(oct(1337)[2:]) # FURB116 @@ -144,36 +151,39 @@ FURB116.py:16:7: FURB116 [*] Replace `bin` call with `f"{+1337:b}"` 18 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) 19 19 | print(bin(int(f"{num}"))[2:]) # FURB116 (no autofix) -FURB116.py:18:7: FURB116 Replace `bin` call with f-string +FURB116 Replace `bin` call with f-string + --> FURB116.py:18:7 | 16 | print(bin(+1337)[2:]) # FURB116 17 | 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) - | ^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^ 19 | print(bin(int(f"{num}"))[2:]) # FURB116 (no autofix) | - = help: Replace with f-string +help: Replace with f-string -FURB116.py:19:7: FURB116 Replace `bin` call with f-string +FURB116 Replace `bin` call with f-string + --> FURB116.py:19:7 | 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) 19 | print(bin(int(f"{num}"))[2:]) # FURB116 (no autofix) - | ^^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | ## invalid | - = help: Replace with f-string +help: Replace with f-string -FURB116.py:32:7: FURB116 Replace `bin` call with `f"{d:b}"` +FURB116 Replace `bin` call with `f"{d:b}"` + --> FURB116.py:32:7 | 30 | d = datetime.datetime.now(tz=datetime.UTC) 31 | # autofix is display-only 32 | print(bin(d)[2:]) - | ^^^^^^^^^^ FURB116 + | ^^^^^^^^^^ 33 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 34 | print(bin(len("xyz").numerator)[2:]) | - = help: Replace with `f"{d:b}"` +help: Replace with `f"{d:b}"` ℹ Display-only fix 29 29 | @@ -185,16 +195,17 @@ FURB116.py:32:7: FURB116 Replace `bin` call with `f"{d:b}"` 34 34 | print(bin(len("xyz").numerator)[2:]) 35 35 | -FURB116.py:34:7: FURB116 Replace `bin` call with `f"{len("xyz").numerator:b}"` +FURB116 Replace `bin` call with `f"{len("xyz").numerator:b}"` + --> FURB116.py:34:7 | 32 | print(bin(d)[2:]) 33 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 34 | print(bin(len("xyz").numerator)[2:]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | # autofix is display-only | - = help: Replace with `f"{len("xyz").numerator:b}"` +help: Replace with `f"{len("xyz").numerator:b}"` ℹ Display-only fix 31 31 | # autofix is display-only @@ -206,15 +217,16 @@ FURB116.py:34:7: FURB116 Replace `bin` call with `f"{len("xyz").numerator:b}"` 36 36 | # autofix is display-only 37 37 | print(bin({0: 1}[0].numerator)[2:]) -FURB116.py:37:7: FURB116 Replace `bin` call with `f"{ {0: 1}[0].numerator:b}"` +FURB116 Replace `bin` call with `f"{ {0: 1}[0].numerator:b}"` + --> FURB116.py:37:7 | 36 | # autofix is display-only 37 | print(bin({0: 1}[0].numerator)[2:]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 39 | print(bin(ord("\\").numerator)[2:]) | - = help: Replace with `f"{ {0: 1}[0].numerator:b}"` +help: Replace with `f"{ {0: 1}[0].numerator:b}"` ℹ Display-only fix 34 34 | print(bin(len("xyz").numerator)[2:]) @@ -226,16 +238,17 @@ FURB116.py:37:7: FURB116 Replace `bin` call with `f"{ {0: 1}[0].numerator:b}"` 39 39 | print(bin(ord("\\").numerator)[2:]) 40 40 | print(hex(sys -FURB116.py:39:7: FURB116 Replace `bin` call with `f"{ord("\\").numerator:b}"` +FURB116 Replace `bin` call with `f"{ord("\\").numerator:b}"` + --> FURB116.py:39:7 | 37 | print(bin({0: 1}[0].numerator)[2:]) 38 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 39 | print(bin(ord("\\").numerator)[2:]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | print(hex(sys 41 | .maxunicode)[2:]) | - = help: Replace with `f"{ord("\\").numerator:b}"` +help: Replace with `f"{ord("\\").numerator:b}"` ℹ Display-only fix 36 36 | # autofix is display-only @@ -247,18 +260,19 @@ FURB116.py:39:7: FURB116 Replace `bin` call with `f"{ord("\\").numerator:b}"` 41 41 | .maxunicode)[2:]) 42 42 | -FURB116.py:40:7: FURB116 Replace `hex` call with f-string +FURB116 Replace `hex` call with f-string + --> FURB116.py:40:7 | 38 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 39 | print(bin(ord("\\").numerator)[2:]) 40 | print(hex(sys | _______^ 41 | | .maxunicode)[2:]) - | |________________^ FURB116 + | |________________^ 42 | 43 | # for negatives numbers autofix is display-only | - = help: Replace with f-string +help: Replace with f-string ℹ Display-only fix 37 37 | print(bin({0: 1}[0].numerator)[2:]) @@ -272,13 +286,14 @@ FURB116.py:40:7: FURB116 Replace `hex` call with f-string 43 43 | # for negatives numbers autofix is display-only 44 44 | print(bin(-1)[2:]) -FURB116.py:44:7: FURB116 Replace `bin` call with `f"{-1:b}"` +FURB116 Replace `bin` call with `f"{-1:b}"` + --> FURB116.py:44:7 | 43 | # for negatives numbers autofix is display-only 44 | print(bin(-1)[2:]) - | ^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^ | - = help: Replace with `f"{-1:b}"` +help: Replace with `f"{-1:b}"` ℹ Display-only fix 41 41 | .maxunicode)[2:]) diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap index f2efa2fbb2..175879f35c 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB118_FURB118.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB118.py:2:13: FURB118 [*] Use `operator.invert` instead of defining a lambda +FURB118 [*] Use `operator.invert` instead of defining a lambda + --> FURB118.py:2:13 | 1 | # Errors. 2 | op_bitnot = lambda x: ~x - | ^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^ 3 | op_not = lambda x: not x 4 | op_pos = lambda x: +x | - = help: Replace with `operator.invert` +help: Replace with `operator.invert` ℹ Unsafe fix 1 1 | # Errors. @@ -20,16 +21,17 @@ FURB118.py:2:13: FURB118 [*] Use `operator.invert` instead of defining a lambda 4 5 | op_pos = lambda x: +x 5 6 | op_neg = lambda x: -x -FURB118.py:3:10: FURB118 [*] Use `operator.not_` instead of defining a lambda +FURB118 [*] Use `operator.not_` instead of defining a lambda + --> FURB118.py:3:10 | 1 | # Errors. 2 | op_bitnot = lambda x: ~x 3 | op_not = lambda x: not x - | ^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^ 4 | op_pos = lambda x: +x 5 | op_neg = lambda x: -x | - = help: Replace with `operator.not_` +help: Replace with `operator.not_` ℹ Unsafe fix 1 1 | # Errors. @@ -41,15 +43,16 @@ FURB118.py:3:10: FURB118 [*] Use `operator.not_` instead of defining a lambda 5 6 | op_neg = lambda x: -x 6 7 | -FURB118.py:4:10: FURB118 [*] Use `operator.pos` instead of defining a lambda +FURB118 [*] Use `operator.pos` instead of defining a lambda + --> FURB118.py:4:10 | 2 | op_bitnot = lambda x: ~x 3 | op_not = lambda x: not x 4 | op_pos = lambda x: +x - | ^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^ 5 | op_neg = lambda x: -x | - = help: Replace with `operator.pos` +help: Replace with `operator.pos` ℹ Unsafe fix 1 1 | # Errors. @@ -62,16 +65,17 @@ FURB118.py:4:10: FURB118 [*] Use `operator.pos` instead of defining a lambda 6 7 | 7 8 | op_add = lambda x, y: x + y -FURB118.py:5:10: FURB118 [*] Use `operator.neg` instead of defining a lambda +FURB118 [*] Use `operator.neg` instead of defining a lambda + --> FURB118.py:5:10 | 3 | op_not = lambda x: not x 4 | op_pos = lambda x: +x 5 | op_neg = lambda x: -x - | ^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^ 6 | 7 | op_add = lambda x, y: x + y | - = help: Replace with `operator.neg` +help: Replace with `operator.neg` ℹ Unsafe fix 1 1 | # Errors. @@ -85,16 +89,17 @@ FURB118.py:5:10: FURB118 [*] Use `operator.neg` instead of defining a lambda 7 8 | op_add = lambda x, y: x + y 8 9 | op_sub = lambda x, y: x - y -FURB118.py:7:10: FURB118 [*] Use `operator.add` instead of defining a lambda +FURB118 [*] Use `operator.add` instead of defining a lambda + --> FURB118.py:7:10 | 5 | op_neg = lambda x: -x 6 | 7 | op_add = lambda x, y: x + y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 8 | op_sub = lambda x, y: x - y 9 | op_mult = lambda x, y: x * y | - = help: Replace with `operator.add` +help: Replace with `operator.add` ℹ Unsafe fix 1 1 | # Errors. @@ -110,15 +115,16 @@ FURB118.py:7:10: FURB118 [*] Use `operator.add` instead of defining a lambda 9 10 | op_mult = lambda x, y: x * y 10 11 | op_matmutl = lambda x, y: x @ y -FURB118.py:8:10: FURB118 [*] Use `operator.sub` instead of defining a lambda +FURB118 [*] Use `operator.sub` instead of defining a lambda + --> FURB118.py:8:10 | 7 | op_add = lambda x, y: x + y 8 | op_sub = lambda x, y: x - y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 9 | op_mult = lambda x, y: x * y 10 | op_matmutl = lambda x, y: x @ y | - = help: Replace with `operator.sub` +help: Replace with `operator.sub` ℹ Unsafe fix 1 1 | # Errors. @@ -135,16 +141,17 @@ FURB118.py:8:10: FURB118 [*] Use `operator.sub` instead of defining a lambda 10 11 | op_matmutl = lambda x, y: x @ y 11 12 | op_truediv = lambda x, y: x / y -FURB118.py:9:11: FURB118 [*] Use `operator.mul` instead of defining a lambda +FURB118 [*] Use `operator.mul` instead of defining a lambda + --> FURB118.py:9:11 | 7 | op_add = lambda x, y: x + y 8 | op_sub = lambda x, y: x - y 9 | op_mult = lambda x, y: x * y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 10 | op_matmutl = lambda x, y: x @ y 11 | op_truediv = lambda x, y: x / y | - = help: Replace with `operator.mul` +help: Replace with `operator.mul` ℹ Unsafe fix 1 1 | # Errors. @@ -162,16 +169,17 @@ FURB118.py:9:11: FURB118 [*] Use `operator.mul` instead of defining a lambda 11 12 | op_truediv = lambda x, y: x / y 12 13 | op_mod = lambda x, y: x % y -FURB118.py:10:14: FURB118 [*] Use `operator.matmul` instead of defining a lambda +FURB118 [*] Use `operator.matmul` instead of defining a lambda + --> FURB118.py:10:14 | 8 | op_sub = lambda x, y: x - y 9 | op_mult = lambda x, y: x * y 10 | op_matmutl = lambda x, y: x @ y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 11 | op_truediv = lambda x, y: x / y 12 | op_mod = lambda x, y: x % y | - = help: Replace with `operator.matmul` +help: Replace with `operator.matmul` ℹ Unsafe fix 1 1 | # Errors. @@ -189,16 +197,17 @@ FURB118.py:10:14: FURB118 [*] Use `operator.matmul` instead of defining a lambda 12 13 | op_mod = lambda x, y: x % y 13 14 | op_pow = lambda x, y: x ** y -FURB118.py:11:14: FURB118 [*] Use `operator.truediv` instead of defining a lambda +FURB118 [*] Use `operator.truediv` instead of defining a lambda + --> FURB118.py:11:14 | 9 | op_mult = lambda x, y: x * y 10 | op_matmutl = lambda x, y: x @ y 11 | op_truediv = lambda x, y: x / y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 12 | op_mod = lambda x, y: x % y 13 | op_pow = lambda x, y: x ** y | - = help: Replace with `operator.truediv` +help: Replace with `operator.truediv` ℹ Unsafe fix 1 1 | # Errors. @@ -216,16 +225,17 @@ FURB118.py:11:14: FURB118 [*] Use `operator.truediv` instead of defining a lambd 13 14 | op_pow = lambda x, y: x ** y 14 15 | op_lshift = lambda x, y: x << y -FURB118.py:12:10: FURB118 [*] Use `operator.mod` instead of defining a lambda +FURB118 [*] Use `operator.mod` instead of defining a lambda + --> FURB118.py:12:10 | 10 | op_matmutl = lambda x, y: x @ y 11 | op_truediv = lambda x, y: x / y 12 | op_mod = lambda x, y: x % y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 13 | op_pow = lambda x, y: x ** y 14 | op_lshift = lambda x, y: x << y | - = help: Replace with `operator.mod` +help: Replace with `operator.mod` ℹ Unsafe fix 1 1 | # Errors. @@ -243,16 +253,17 @@ FURB118.py:12:10: FURB118 [*] Use `operator.mod` instead of defining a lambda 14 15 | op_lshift = lambda x, y: x << y 15 16 | op_rshift = lambda x, y: x >> y -FURB118.py:13:10: FURB118 [*] Use `operator.pow` instead of defining a lambda +FURB118 [*] Use `operator.pow` instead of defining a lambda + --> FURB118.py:13:10 | 11 | op_truediv = lambda x, y: x / y 12 | op_mod = lambda x, y: x % y 13 | op_pow = lambda x, y: x ** y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 14 | op_lshift = lambda x, y: x << y 15 | op_rshift = lambda x, y: x >> y | - = help: Replace with `operator.pow` +help: Replace with `operator.pow` ℹ Unsafe fix 1 1 | # Errors. @@ -270,16 +281,17 @@ FURB118.py:13:10: FURB118 [*] Use `operator.pow` instead of defining a lambda 15 16 | op_rshift = lambda x, y: x >> y 16 17 | op_bitor = lambda x, y: x | y -FURB118.py:14:13: FURB118 [*] Use `operator.lshift` instead of defining a lambda +FURB118 [*] Use `operator.lshift` instead of defining a lambda + --> FURB118.py:14:13 | 12 | op_mod = lambda x, y: x % y 13 | op_pow = lambda x, y: x ** y 14 | op_lshift = lambda x, y: x << y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 15 | op_rshift = lambda x, y: x >> y 16 | op_bitor = lambda x, y: x | y | - = help: Replace with `operator.lshift` +help: Replace with `operator.lshift` ℹ Unsafe fix 1 1 | # Errors. @@ -297,16 +309,17 @@ FURB118.py:14:13: FURB118 [*] Use `operator.lshift` instead of defining a lambda 16 17 | op_bitor = lambda x, y: x | y 17 18 | op_xor = lambda x, y: x ^ y -FURB118.py:15:13: FURB118 [*] Use `operator.rshift` instead of defining a lambda +FURB118 [*] Use `operator.rshift` instead of defining a lambda + --> FURB118.py:15:13 | 13 | op_pow = lambda x, y: x ** y 14 | op_lshift = lambda x, y: x << y 15 | op_rshift = lambda x, y: x >> y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 16 | op_bitor = lambda x, y: x | y 17 | op_xor = lambda x, y: x ^ y | - = help: Replace with `operator.rshift` +help: Replace with `operator.rshift` ℹ Unsafe fix 1 1 | # Errors. @@ -324,16 +337,17 @@ FURB118.py:15:13: FURB118 [*] Use `operator.rshift` instead of defining a lambda 17 18 | op_xor = lambda x, y: x ^ y 18 19 | op_bitand = lambda x, y: x & y -FURB118.py:16:12: FURB118 [*] Use `operator.or_` instead of defining a lambda +FURB118 [*] Use `operator.or_` instead of defining a lambda + --> FURB118.py:16:12 | 14 | op_lshift = lambda x, y: x << y 15 | op_rshift = lambda x, y: x >> y 16 | op_bitor = lambda x, y: x | y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 17 | op_xor = lambda x, y: x ^ y 18 | op_bitand = lambda x, y: x & y | - = help: Replace with `operator.or_` +help: Replace with `operator.or_` ℹ Unsafe fix 1 1 | # Errors. @@ -351,16 +365,17 @@ FURB118.py:16:12: FURB118 [*] Use `operator.or_` instead of defining a lambda 18 19 | op_bitand = lambda x, y: x & y 19 20 | op_floordiv = lambda x, y: x // y -FURB118.py:17:10: FURB118 [*] Use `operator.xor` instead of defining a lambda +FURB118 [*] Use `operator.xor` instead of defining a lambda + --> FURB118.py:17:10 | 15 | op_rshift = lambda x, y: x >> y 16 | op_bitor = lambda x, y: x | y 17 | op_xor = lambda x, y: x ^ y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 18 | op_bitand = lambda x, y: x & y 19 | op_floordiv = lambda x, y: x // y | - = help: Replace with `operator.xor` +help: Replace with `operator.xor` ℹ Unsafe fix 1 1 | # Errors. @@ -378,15 +393,16 @@ FURB118.py:17:10: FURB118 [*] Use `operator.xor` instead of defining a lambda 19 20 | op_floordiv = lambda x, y: x // y 20 21 | -FURB118.py:18:13: FURB118 [*] Use `operator.and_` instead of defining a lambda +FURB118 [*] Use `operator.and_` instead of defining a lambda + --> FURB118.py:18:13 | 16 | op_bitor = lambda x, y: x | y 17 | op_xor = lambda x, y: x ^ y 18 | op_bitand = lambda x, y: x & y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 19 | op_floordiv = lambda x, y: x // y | - = help: Replace with `operator.and_` +help: Replace with `operator.and_` ℹ Unsafe fix 1 1 | # Errors. @@ -404,16 +420,17 @@ FURB118.py:18:13: FURB118 [*] Use `operator.and_` instead of defining a lambda 20 21 | 21 22 | op_eq = lambda x, y: x == y -FURB118.py:19:15: FURB118 [*] Use `operator.floordiv` instead of defining a lambda +FURB118 [*] Use `operator.floordiv` instead of defining a lambda + --> FURB118.py:19:15 | 17 | op_xor = lambda x, y: x ^ y 18 | op_bitand = lambda x, y: x & y 19 | op_floordiv = lambda x, y: x // y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 20 | 21 | op_eq = lambda x, y: x == y | - = help: Replace with `operator.floordiv` +help: Replace with `operator.floordiv` ℹ Unsafe fix 1 1 | # Errors. @@ -431,16 +448,17 @@ FURB118.py:19:15: FURB118 [*] Use `operator.floordiv` instead of defining a lamb 21 22 | op_eq = lambda x, y: x == y 22 23 | op_ne = lambda x, y: x != y -FURB118.py:21:9: FURB118 [*] Use `operator.eq` instead of defining a lambda +FURB118 [*] Use `operator.eq` instead of defining a lambda + --> FURB118.py:21:9 | 19 | op_floordiv = lambda x, y: x // y 20 | 21 | op_eq = lambda x, y: x == y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 22 | op_ne = lambda x, y: x != y 23 | op_lt = lambda x, y: x < y | - = help: Replace with `operator.eq` +help: Replace with `operator.eq` ℹ Unsafe fix 1 1 | # Errors. @@ -458,15 +476,16 @@ FURB118.py:21:9: FURB118 [*] Use `operator.eq` instead of defining a lambda 23 24 | op_lt = lambda x, y: x < y 24 25 | op_lte = lambda x, y: x <= y -FURB118.py:22:9: FURB118 [*] Use `operator.ne` instead of defining a lambda +FURB118 [*] Use `operator.ne` instead of defining a lambda + --> FURB118.py:22:9 | 21 | op_eq = lambda x, y: x == y 22 | op_ne = lambda x, y: x != y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 23 | op_lt = lambda x, y: x < y 24 | op_lte = lambda x, y: x <= y | - = help: Replace with `operator.ne` +help: Replace with `operator.ne` ℹ Unsafe fix 1 1 | # Errors. @@ -484,16 +503,17 @@ FURB118.py:22:9: FURB118 [*] Use `operator.ne` instead of defining a lambda 24 25 | op_lte = lambda x, y: x <= y 25 26 | op_gt = lambda x, y: x > y -FURB118.py:23:9: FURB118 [*] Use `operator.lt` instead of defining a lambda +FURB118 [*] Use `operator.lt` instead of defining a lambda + --> FURB118.py:23:9 | 21 | op_eq = lambda x, y: x == y 22 | op_ne = lambda x, y: x != y 23 | op_lt = lambda x, y: x < y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 24 | op_lte = lambda x, y: x <= y 25 | op_gt = lambda x, y: x > y | - = help: Replace with `operator.lt` +help: Replace with `operator.lt` ℹ Unsafe fix 1 1 | # Errors. @@ -511,16 +531,17 @@ FURB118.py:23:9: FURB118 [*] Use `operator.lt` instead of defining a lambda 25 26 | op_gt = lambda x, y: x > y 26 27 | op_gte = lambda x, y: x >= y -FURB118.py:24:10: FURB118 [*] Use `operator.le` instead of defining a lambda +FURB118 [*] Use `operator.le` instead of defining a lambda + --> FURB118.py:24:10 | 22 | op_ne = lambda x, y: x != y 23 | op_lt = lambda x, y: x < y 24 | op_lte = lambda x, y: x <= y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 25 | op_gt = lambda x, y: x > y 26 | op_gte = lambda x, y: x >= y | - = help: Replace with `operator.le` +help: Replace with `operator.le` ℹ Unsafe fix 1 1 | # Errors. @@ -538,16 +559,17 @@ FURB118.py:24:10: FURB118 [*] Use `operator.le` instead of defining a lambda 26 27 | op_gte = lambda x, y: x >= y 27 28 | op_is = lambda x, y: x is y -FURB118.py:25:9: FURB118 [*] Use `operator.gt` instead of defining a lambda +FURB118 [*] Use `operator.gt` instead of defining a lambda + --> FURB118.py:25:9 | 23 | op_lt = lambda x, y: x < y 24 | op_lte = lambda x, y: x <= y 25 | op_gt = lambda x, y: x > y - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 26 | op_gte = lambda x, y: x >= y 27 | op_is = lambda x, y: x is y | - = help: Replace with `operator.gt` +help: Replace with `operator.gt` ℹ Unsafe fix 1 1 | # Errors. @@ -565,16 +587,17 @@ FURB118.py:25:9: FURB118 [*] Use `operator.gt` instead of defining a lambda 27 28 | op_is = lambda x, y: x is y 28 29 | op_isnot = lambda x, y: x is not y -FURB118.py:26:10: FURB118 [*] Use `operator.ge` instead of defining a lambda +FURB118 [*] Use `operator.ge` instead of defining a lambda + --> FURB118.py:26:10 | 24 | op_lte = lambda x, y: x <= y 25 | op_gt = lambda x, y: x > y 26 | op_gte = lambda x, y: x >= y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 27 | op_is = lambda x, y: x is y 28 | op_isnot = lambda x, y: x is not y | - = help: Replace with `operator.ge` +help: Replace with `operator.ge` ℹ Unsafe fix 1 1 | # Errors. @@ -592,16 +615,17 @@ FURB118.py:26:10: FURB118 [*] Use `operator.ge` instead of defining a lambda 28 29 | op_isnot = lambda x, y: x is not y 29 30 | op_in = lambda x, y: y in x -FURB118.py:27:9: FURB118 [*] Use `operator.is_` instead of defining a lambda +FURB118 [*] Use `operator.is_` instead of defining a lambda + --> FURB118.py:27:9 | 25 | op_gt = lambda x, y: x > y 26 | op_gte = lambda x, y: x >= y 27 | op_is = lambda x, y: x is y - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 28 | op_isnot = lambda x, y: x is not y 29 | op_in = lambda x, y: y in x | - = help: Replace with `operator.is_` +help: Replace with `operator.is_` ℹ Unsafe fix 1 1 | # Errors. @@ -619,16 +643,17 @@ FURB118.py:27:9: FURB118 [*] Use `operator.is_` instead of defining a lambda 29 30 | op_in = lambda x, y: y in x 30 31 | op_itemgetter = lambda x: x[0] -FURB118.py:28:12: FURB118 [*] Use `operator.is_not` instead of defining a lambda +FURB118 [*] Use `operator.is_not` instead of defining a lambda + --> FURB118.py:28:12 | 26 | op_gte = lambda x, y: x >= y 27 | op_is = lambda x, y: x is y 28 | op_isnot = lambda x, y: x is not y - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^^^^^ 29 | op_in = lambda x, y: y in x 30 | op_itemgetter = lambda x: x[0] | - = help: Replace with `operator.is_not` +help: Replace with `operator.is_not` ℹ Unsafe fix 1 1 | # Errors. @@ -646,16 +671,17 @@ FURB118.py:28:12: FURB118 [*] Use `operator.is_not` instead of defining a lambda 30 31 | op_itemgetter = lambda x: x[0] 31 32 | op_itemgetter = lambda x: (x[0], x[1], x[2]) -FURB118.py:29:9: FURB118 [*] Use `operator.contains` instead of defining a lambda +FURB118 [*] Use `operator.contains` instead of defining a lambda + --> FURB118.py:29:9 | 27 | op_is = lambda x, y: x is y 28 | op_isnot = lambda x, y: x is not y 29 | op_in = lambda x, y: y in x - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ 30 | op_itemgetter = lambda x: x[0] 31 | op_itemgetter = lambda x: (x[0], x[1], x[2]) | - = help: Replace with `operator.contains` +help: Replace with `operator.contains` ℹ Unsafe fix 1 1 | # Errors. @@ -673,16 +699,17 @@ FURB118.py:29:9: FURB118 [*] Use `operator.contains` instead of defining a lambd 31 32 | op_itemgetter = lambda x: (x[0], x[1], x[2]) 32 33 | op_itemgetter = lambda x: (x[1:], x[2]) -FURB118.py:30:17: FURB118 [*] Use `operator.itemgetter(0)` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter(0)` instead of defining a lambda + --> FURB118.py:30:17 | 28 | op_isnot = lambda x, y: x is not y 29 | op_in = lambda x, y: y in x 30 | op_itemgetter = lambda x: x[0] - | ^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^ 31 | op_itemgetter = lambda x: (x[0], x[1], x[2]) 32 | op_itemgetter = lambda x: (x[1:], x[2]) | - = help: Replace with `operator.itemgetter(0)` +help: Replace with `operator.itemgetter(0)` ℹ Unsafe fix 1 1 | # Errors. @@ -700,16 +727,17 @@ FURB118.py:30:17: FURB118 [*] Use `operator.itemgetter(0)` instead of defining a 32 33 | op_itemgetter = lambda x: (x[1:], x[2]) 33 34 | op_itemgetter = lambda x: x[:] -FURB118.py:31:17: FURB118 [*] Use `operator.itemgetter(0, 1, 2)` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter(0, 1, 2)` instead of defining a lambda + --> FURB118.py:31:17 | 29 | op_in = lambda x, y: y in x 30 | op_itemgetter = lambda x: x[0] 31 | op_itemgetter = lambda x: (x[0], x[1], x[2]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | op_itemgetter = lambda x: (x[1:], x[2]) 33 | op_itemgetter = lambda x: x[:] | - = help: Replace with `operator.itemgetter(0, 1, 2)` +help: Replace with `operator.itemgetter(0, 1, 2)` ℹ Unsafe fix 1 1 | # Errors. @@ -727,16 +755,17 @@ FURB118.py:31:17: FURB118 [*] Use `operator.itemgetter(0, 1, 2)` instead of defi 33 34 | op_itemgetter = lambda x: x[:] 34 35 | op_itemgetter = lambda x: x[0, 1] -FURB118.py:32:17: FURB118 [*] Use `operator.itemgetter(slice(1, None), 2)` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter(slice(1, None), 2)` instead of defining a lambda + --> FURB118.py:32:17 | 30 | op_itemgetter = lambda x: x[0] 31 | op_itemgetter = lambda x: (x[0], x[1], x[2]) 32 | op_itemgetter = lambda x: (x[1:], x[2]) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^^^^^ 33 | op_itemgetter = lambda x: x[:] 34 | op_itemgetter = lambda x: x[0, 1] | - = help: Replace with `operator.itemgetter(slice(1, None), 2)` +help: Replace with `operator.itemgetter(slice(1, None), 2)` ℹ Unsafe fix 1 1 | # Errors. @@ -754,16 +783,17 @@ FURB118.py:32:17: FURB118 [*] Use `operator.itemgetter(slice(1, None), 2)` inste 34 35 | op_itemgetter = lambda x: x[0, 1] 35 36 | op_itemgetter = lambda x: x[(0, 1)] -FURB118.py:33:17: FURB118 [*] Use `operator.itemgetter(slice(None))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter(slice(None))` instead of defining a lambda + --> FURB118.py:33:17 | 31 | op_itemgetter = lambda x: (x[0], x[1], x[2]) 32 | op_itemgetter = lambda x: (x[1:], x[2]) 33 | op_itemgetter = lambda x: x[:] - | ^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^ 34 | op_itemgetter = lambda x: x[0, 1] 35 | op_itemgetter = lambda x: x[(0, 1)] | - = help: Replace with `operator.itemgetter(slice(None))` +help: Replace with `operator.itemgetter(slice(None))` ℹ Unsafe fix 1 1 | # Errors. @@ -781,15 +811,16 @@ FURB118.py:33:17: FURB118 [*] Use `operator.itemgetter(slice(None))` instead of 35 36 | op_itemgetter = lambda x: x[(0, 1)] 36 37 | -FURB118.py:34:17: FURB118 [*] Use `operator.itemgetter((0, 1))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter((0, 1))` instead of defining a lambda + --> FURB118.py:34:17 | 32 | op_itemgetter = lambda x: (x[1:], x[2]) 33 | op_itemgetter = lambda x: x[:] 34 | op_itemgetter = lambda x: x[0, 1] - | ^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^ 35 | op_itemgetter = lambda x: x[(0, 1)] | - = help: Replace with `operator.itemgetter((0, 1))` +help: Replace with `operator.itemgetter((0, 1))` ℹ Unsafe fix 1 1 | # Errors. @@ -807,14 +838,15 @@ FURB118.py:34:17: FURB118 [*] Use `operator.itemgetter((0, 1))` instead of defin 36 37 | 37 38 | -FURB118.py:35:17: FURB118 [*] Use `operator.itemgetter((0, 1))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter((0, 1))` instead of defining a lambda + --> FURB118.py:35:17 | 33 | op_itemgetter = lambda x: x[:] 34 | op_itemgetter = lambda x: x[0, 1] 35 | op_itemgetter = lambda x: x[(0, 1)] - | ^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `operator.itemgetter((0, 1))` +help: Replace with `operator.itemgetter((0, 1))` ℹ Unsafe fix 1 1 | # Errors. @@ -832,30 +864,33 @@ FURB118.py:35:17: FURB118 [*] Use `operator.itemgetter((0, 1))` instead of defin 37 38 | 38 39 | def op_not2(x): -FURB118.py:38:5: FURB118 Use `operator.not_` instead of defining a function +FURB118 Use `operator.not_` instead of defining a function + --> FURB118.py:38:5 | 38 | def op_not2(x): - | ^^^^^^^ FURB118 + | ^^^^^^^ 39 | return not x | - = help: Replace with `operator.not_` +help: Replace with `operator.not_` -FURB118.py:42:5: FURB118 Use `operator.add` instead of defining a function +FURB118 Use `operator.add` instead of defining a function + --> FURB118.py:42:5 | 42 | def op_add2(x, y): - | ^^^^^^^ FURB118 + | ^^^^^^^ 43 | return x + y | - = help: Replace with `operator.add` +help: Replace with `operator.add` -FURB118.py:88:17: FURB118 [*] Use `operator.itemgetter((slice(None), 1))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter((slice(None), 1))` instead of defining a lambda + --> FURB118.py:88:17 | 87 | # See https://github.com/astral-sh/ruff/issues/13508 88 | op_itemgetter = lambda x: x[:, 1] - | ^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^ 89 | op_itemgetter = lambda x: x[1, :] | - = help: Replace with `operator.itemgetter((slice(None), 1))` +help: Replace with `operator.itemgetter((slice(None), 1))` ℹ Unsafe fix 1 1 | # Errors. @@ -873,16 +908,17 @@ FURB118.py:88:17: FURB118 [*] Use `operator.itemgetter((slice(None), 1))` instea 90 91 | 91 92 | # With a slice, trivia is dropped -FURB118.py:89:17: FURB118 [*] Use `operator.itemgetter((1, slice(None)))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter((1, slice(None)))` instead of defining a lambda + --> FURB118.py:89:17 | 87 | # See https://github.com/astral-sh/ruff/issues/13508 88 | op_itemgetter = lambda x: x[:, 1] 89 | op_itemgetter = lambda x: x[1, :] - | ^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^ 90 | 91 | # With a slice, trivia is dropped | - = help: Replace with `operator.itemgetter((1, slice(None)))` +help: Replace with `operator.itemgetter((1, slice(None)))` ℹ Unsafe fix 1 1 | # Errors. @@ -900,15 +936,16 @@ FURB118.py:89:17: FURB118 [*] Use `operator.itemgetter((1, slice(None)))` instea 91 92 | # With a slice, trivia is dropped 92 93 | op_itemgetter = lambda x: x[1, :] -FURB118.py:92:17: FURB118 [*] Use `operator.itemgetter((1, slice(None)))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter((1, slice(None)))` instead of defining a lambda + --> FURB118.py:92:17 | 91 | # With a slice, trivia is dropped 92 | op_itemgetter = lambda x: x[1, :] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 93 | 94 | # Without a slice, trivia is retained | - = help: Replace with `operator.itemgetter((1, slice(None)))` +help: Replace with `operator.itemgetter((1, slice(None)))` ℹ Unsafe fix 1 1 | # Errors. @@ -926,13 +963,14 @@ FURB118.py:92:17: FURB118 [*] Use `operator.itemgetter((1, slice(None)))` instea 94 95 | # Without a slice, trivia is retained 95 96 | op_itemgetter = lambda x: x[1, 2] -FURB118.py:95:17: FURB118 [*] Use `operator.itemgetter((1, 2))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter((1, 2))` instead of defining a lambda + --> FURB118.py:95:17 | 94 | # Without a slice, trivia is retained 95 | op_itemgetter = lambda x: x[1, 2] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `operator.itemgetter((1, 2))` +help: Replace with `operator.itemgetter((1, 2))` ℹ Unsafe fix 1 1 | # Errors. @@ -950,16 +988,17 @@ FURB118.py:95:17: FURB118 [*] Use `operator.itemgetter((1, 2))` instead 97 98 | 98 99 | # All methods in classes are ignored, even those defined using lambdas: -FURB118.py:129:14: FURB118 [*] Use `operator.itemgetter(slice(-2, None))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter(slice(-2, None))` instead of defining a lambda + --> FURB118.py:129:14 | 127 | "slicer, expected", 128 | [ 129 | (lambda x: x[-2:], "foo"), - | ^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^ 130 | (lambda x: x[-5:-3], "bar"), 131 | ], | - = help: Replace with `operator.itemgetter(slice(-2, None))` +help: Replace with `operator.itemgetter(slice(-2, None))` ℹ Unsafe fix 111 111 | # Lambdas wrapped in function calls could also still be method definitions! @@ -979,16 +1018,17 @@ FURB118.py:129:14: FURB118 [*] Use `operator.itemgetter(slice(-2, None))` instea 131 132 | ], 132 133 | ) -FURB118.py:130:14: FURB118 [*] Use `operator.itemgetter(slice(-5, -3))` instead of defining a lambda +FURB118 [*] Use `operator.itemgetter(slice(-5, -3))` instead of defining a lambda + --> FURB118.py:130:14 | 128 | [ 129 | (lambda x: x[-2:], "foo"), 130 | (lambda x: x[-5:-3], "bar"), - | ^^^^^^^^^^^^^^^^^^ FURB118 + | ^^^^^^^^^^^^^^^^^^ 131 | ], 132 | ) | - = help: Replace with `operator.itemgetter(slice(-5, -3))` +help: Replace with `operator.itemgetter(slice(-5, -3))` ℹ Unsafe fix 111 111 | # Lambdas wrapped in function calls could also still be method definitions! diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB122_FURB122.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB122_FURB122.py.snap index 3f90c11564..a80f7a6764 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB122_FURB122.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB122_FURB122.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB122.py:10:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:10:9 | 8 | def _(): 9 | with open("file", "w") as f: 10 | / for line in lines: 11 | | f.write(line) - | |_________________________^ FURB122 + | |_________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 7 7 | @@ -22,15 +23,16 @@ FURB122.py:10:9: FURB122 [*] Use of `f.write` in a for loop 13 12 | 14 13 | def _(): -FURB122.py:17:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:17:9 | 15 | other_line = "other line" 16 | with Path("file").open("w") as f: 17 | / for line in lines: 18 | | f.write(other_line) - | |_______________________________^ FURB122 + | |_______________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 14 14 | def _(): @@ -43,15 +45,16 @@ FURB122.py:17:9: FURB122 [*] Use of `f.write` in a for loop 20 19 | 21 20 | def _(): -FURB122.py:23:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:23:9 | 21 | def _(): 22 | with Path("file").open("w") as f: 23 | / for line in lines: 24 | | f.write(line) - | |_________________________^ FURB122 + | |_________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 20 20 | @@ -64,15 +67,16 @@ FURB122.py:23:9: FURB122 [*] Use of `f.write` in a for loop 26 25 | 27 26 | def _(): -FURB122.py:29:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:29:9 | 27 | def _(): 28 | with Path("file").open("wb") as f: 29 | / for line in lines: 30 | | f.write(line.encode()) - | |__________________________________^ FURB122 + | |__________________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 26 26 | @@ -85,15 +89,16 @@ FURB122.py:29:9: FURB122 [*] Use of `f.write` in a for loop 32 31 | 33 32 | def _(): -FURB122.py:35:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:35:9 | 33 | def _(): 34 | with Path("file").open("w") as f: 35 | / for line in lines: 36 | | f.write(line.upper()) - | |_________________________________^ FURB122 + | |_________________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 32 32 | @@ -106,15 +111,16 @@ FURB122.py:35:9: FURB122 [*] Use of `f.write` in a for loop 38 37 | 39 38 | def _(): -FURB122.py:43:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:43:9 | 41 | pass 42 | 43 | / for line in lines: 44 | | f.write(line) - | |_________________________^ FURB122 + | |_________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 40 40 | with Path("file").open("w") as f: @@ -127,16 +133,17 @@ FURB122.py:43:9: FURB122 [*] Use of `f.write` in a for loop 46 45 | 47 46 | def _(): -FURB122.py:50:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:50:9 | 48 | # Offer unsafe fix if it would delete comments 49 | with open("file","w") as f: 50 | / for line in lines: 51 | | # a really important comment 52 | | f.write(line) - | |_________________________^ FURB122 + | |_________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Unsafe fix 47 47 | def _(): @@ -150,15 +157,16 @@ FURB122.py:50:9: FURB122 [*] Use of `f.write` in a for loop 54 52 | 55 53 | def _(): -FURB122.py:57:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:57:9 | 55 | def _(): 56 | with open("file", "w") as f: 57 | / for () in a: 58 | | f.write(()) - | |_______________________^ FURB122 + | |_______________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 54 54 | @@ -171,15 +179,16 @@ FURB122.py:57:9: FURB122 [*] Use of `f.write` in a for loop 60 59 | 61 60 | def _(): -FURB122.py:63:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:63:9 | 61 | def _(): 62 | with open("file", "w") as f: 63 | / for a, b, c in d: 64 | | f.write((a, b)) - | |___________________________^ FURB122 + | |___________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 60 60 | @@ -192,15 +201,16 @@ FURB122.py:63:9: FURB122 [*] Use of `f.write` in a for loop 66 65 | 67 66 | def _(): -FURB122.py:69:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:69:9 | 67 | def _(): 68 | with open("file", "w") as f: 69 | / for [(), [a.b], (c,)] in d: 70 | | f.write(()) - | |_______________________^ FURB122 + | |_______________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 66 66 | @@ -213,15 +223,16 @@ FURB122.py:69:9: FURB122 [*] Use of `f.write` in a for loop 72 71 | 73 72 | def _(): -FURB122.py:75:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:75:9 | 73 | def _(): 74 | with open("file", "w") as f: 75 | / for [([([a[b]],)],), [], (c[d],)] in e: 76 | | f.write(()) - | |_______________________^ FURB122 + | |_______________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 72 72 | @@ -234,17 +245,18 @@ FURB122.py:75:9: FURB122 [*] Use of `f.write` in a for loop 78 77 | 79 78 | def _(): -FURB122.py:82:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:82:9 | 80 | # https://github.com/astral-sh/ruff/issues/15936 81 | with open("file", "w") as f: 82 | / for char in "a", "b": 83 | | f.write(char) - | |_________________________^ FURB122 + | |_________________________^ 84 | 85 | def _(): | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 79 79 | def _(): @@ -257,17 +269,18 @@ FURB122.py:82:9: FURB122 [*] Use of `f.write` in a for loop 85 84 | def _(): 86 85 | # https://github.com/astral-sh/ruff/issues/15936 -FURB122.py:88:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:88:9 | 86 | # https://github.com/astral-sh/ruff/issues/15936 87 | with open("file", "w") as f: 88 | / for char in "a", "b": 89 | | f.write(f"{char}") - | |______________________________^ FURB122 + | |______________________________^ 90 | 91 | def _(): | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 85 85 | def _(): @@ -280,7 +293,8 @@ FURB122.py:88:9: FURB122 [*] Use of `f.write` in a for loop 91 90 | def _(): 92 91 | with open("file", "w") as f: -FURB122.py:93:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:93:9 | 91 | def _(): 92 | with open("file", "w") as f: @@ -289,9 +303,9 @@ FURB122.py:93:9: FURB122 [*] Use of `f.write` in a for loop 95 | | "b" 96 | | ): 97 | | f.write(f"{char}") - | |______________________________^ FURB122 + | |______________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Unsafe fix 90 90 | @@ -308,15 +322,16 @@ FURB122.py:93:9: FURB122 [*] Use of `f.write` in a for loop 99 98 | 100 99 | # OK -FURB122.py:183:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:183:9 | 181 | def _(): 182 | with Path("file.txt").open("w", encoding="utf-8") as f: 183 | / for l in lambda: 0: 184 | | f.write(f"[{l}]") - | |_____________________________^ FURB122 + | |_____________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 180 180 | @@ -329,15 +344,16 @@ FURB122.py:183:9: FURB122 [*] Use of `f.write` in a for loop 186 185 | 187 186 | def _(): -FURB122.py:189:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:189:9 | 187 | def _(): 188 | with Path("file.txt").open("w", encoding="utf-8") as f: 189 | / for l in (1,) if True else (2,): 190 | | f.write(f"[{l}]") - | |_____________________________^ FURB122 + | |_____________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 186 186 | @@ -350,15 +366,16 @@ FURB122.py:189:9: FURB122 [*] Use of `f.write` in a for loop 192 191 | 193 192 | # don't need to add parentheses when making a function argument -FURB122.py:196:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:196:9 | 194 | def _(): 195 | with open("file", "w") as f: 196 | / for line in lambda: 0: 197 | | f.write(line) - | |_________________________^ FURB122 + | |_________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 193 193 | # don't need to add parentheses when making a function argument @@ -371,15 +388,16 @@ FURB122.py:196:9: FURB122 [*] Use of `f.write` in a for loop 199 198 | 200 199 | def _(): -FURB122.py:202:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:202:9 | 200 | def _(): 201 | with open("file", "w") as f: 202 | / for line in (1,) if True else (2,): 203 | | f.write(line) - | |_________________________^ FURB122 + | |_________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 199 199 | @@ -392,15 +410,16 @@ FURB122.py:202:9: FURB122 [*] Use of `f.write` in a for loop 205 204 | 206 205 | # don't add extra parentheses if they're already parenthesized -FURB122.py:209:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:209:9 | 207 | def _(): 208 | with open("file", "w") as f: 209 | / for line in (lambda: 0): 210 | | f.write(f"{line}") - | |______________________________^ FURB122 + | |______________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 206 206 | # don't add extra parentheses if they're already parenthesized @@ -413,15 +432,16 @@ FURB122.py:209:9: FURB122 [*] Use of `f.write` in a for loop 212 211 | 213 212 | def _(): -FURB122.py:215:9: FURB122 [*] Use of `f.write` in a for loop +FURB122 [*] Use of `f.write` in a for loop + --> FURB122.py:215:9 | 213 | def _(): 214 | with open("file", "w") as f: 215 | / for line in ((1,) if True else (2,)): 216 | | f.write(f"{line}") - | |______________________________^ FURB122 + | |______________________________^ | - = help: Replace with `f.writelines` +help: Replace with `f.writelines` ℹ Safe fix 212 212 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap index 6b67b28958..5a7985327d 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB129_FURB129.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB129.py:7:18: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:7:18 | 5 | # Errors 6 | with open("FURB129.py") as f: 7 | for _line in f.readlines(): - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 8 | pass 9 | a = [line.lower() for line in f.readlines()] | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 4 4 | @@ -22,16 +23,17 @@ FURB129.py:7:18: FURB129 [*] Instead of calling `readlines()`, iterate over file 9 9 | a = [line.lower() for line in f.readlines()] 10 10 | b = {line.upper() for line in f.readlines()} -FURB129.py:9:35: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:9:35 | 7 | for _line in f.readlines(): 8 | pass 9 | a = [line.lower() for line in f.readlines()] - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 10 | b = {line.upper() for line in f.readlines()} 11 | c = {line.lower(): line.upper() for line in f.readlines()} | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 6 6 | with open("FURB129.py") as f: @@ -43,15 +45,16 @@ FURB129.py:9:35: FURB129 [*] Instead of calling `readlines()`, iterate over file 11 11 | c = {line.lower(): line.upper() for line in f.readlines()} 12 12 | -FURB129.py:10:35: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:10:35 | 8 | pass 9 | a = [line.lower() for line in f.readlines()] 10 | b = {line.upper() for line in f.readlines()} - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 11 | c = {line.lower(): line.upper() for line in f.readlines()} | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 7 7 | for _line in f.readlines(): @@ -63,16 +66,17 @@ FURB129.py:10:35: FURB129 [*] Instead of calling `readlines()`, iterate over fil 12 12 | 13 13 | with Path("FURB129.py").open() as f: -FURB129.py:11:49: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:11:49 | 9 | a = [line.lower() for line in f.readlines()] 10 | b = {line.upper() for line in f.readlines()} 11 | c = {line.lower(): line.upper() for line in f.readlines()} - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 12 | 13 | with Path("FURB129.py").open() as f: | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 8 8 | pass @@ -84,14 +88,15 @@ FURB129.py:11:49: FURB129 [*] Instead of calling `readlines()`, iterate over fil 13 13 | with Path("FURB129.py").open() as f: 14 14 | for _line in f.readlines(): -FURB129.py:14:18: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:14:18 | 13 | with Path("FURB129.py").open() as f: 14 | for _line in f.readlines(): - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 15 | pass | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 11 11 | c = {line.lower(): line.upper() for line in f.readlines()} @@ -103,15 +108,16 @@ FURB129.py:14:18: FURB129 [*] Instead of calling `readlines()`, iterate over fil 16 16 | 17 17 | for _line in open("FURB129.py").readlines(): -FURB129.py:17:14: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:17:14 | 15 | pass 16 | 17 | for _line in open("FURB129.py").readlines(): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | pass | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 14 14 | for _line in f.readlines(): @@ -123,15 +129,16 @@ FURB129.py:17:14: FURB129 [*] Instead of calling `readlines()`, iterate over fil 19 19 | 20 20 | for _line in Path("FURB129.py").open().readlines(): -FURB129.py:20:14: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:20:14 | 18 | pass 19 | 20 | for _line in Path("FURB129.py").open().readlines(): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | pass | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 17 17 | for _line in open("FURB129.py").readlines(): @@ -143,16 +150,17 @@ FURB129.py:20:14: FURB129 [*] Instead of calling `readlines()`, iterate over fil 22 22 | 23 23 | -FURB129.py:26:18: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:26:18 | 24 | def func(): 25 | f = Path("FURB129.py").open() 26 | for _line in f.readlines(): - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 27 | pass 28 | f.close() | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 23 23 | @@ -164,14 +172,15 @@ FURB129.py:26:18: FURB129 [*] Instead of calling `readlines()`, iterate over fil 28 28 | f.close() 29 29 | -FURB129.py:32:18: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:32:18 | 31 | def func(f: io.BytesIO): 32 | for _line in f.readlines(): - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 33 | pass | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 29 29 | @@ -183,16 +192,17 @@ FURB129.py:32:18: FURB129 [*] Instead of calling `readlines()`, iterate over fil 34 34 | 35 35 | -FURB129.py:38:22: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:38:22 | 36 | def func(): 37 | with (open("FURB129.py") as f, foo as bar): 38 | for _line in f.readlines(): - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 39 | pass 40 | for _line in bar.readlines(): | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 35 35 | @@ -204,14 +214,15 @@ FURB129.py:38:22: FURB129 [*] Instead of calling `readlines()`, iterate over fil 40 40 | for _line in bar.readlines(): 41 41 | pass -FURB129.py:47:17: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:47:17 | 46 | with builtins.open("FURB129.py") as f: 47 | for line in f.readlines(): - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 48 | pass | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 44 44 | import builtins @@ -223,14 +234,15 @@ FURB129.py:47:17: FURB129 [*] Instead of calling `readlines()`, iterate over fil 49 49 | 50 50 | -FURB129.py:54:17: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:54:17 | 53 | with o("FURB129.py") as f: 54 | for line in f.readlines(): - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 55 | pass | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 51 51 | from builtins import open as o @@ -242,15 +254,16 @@ FURB129.py:54:17: FURB129 [*] Instead of calling `readlines()`, iterate over fil 56 56 | 57 57 | -FURB129.py:93:17: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:93:17 | 91 | # https://github.com/astral-sh/ruff/issues/18231 92 | with open("furb129.py") as f: 93 | for line in (f).readlines(): - | ^^^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^^^ 94 | pass | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 90 90 | @@ -262,13 +275,14 @@ FURB129.py:93:17: FURB129 [*] Instead of calling `readlines()`, iterate over fil 95 95 | 96 96 | with open("furb129.py") as f: -FURB129.py:97:23: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:97:23 | 96 | with open("furb129.py") as f: 97 | [line for line in (f).readlines()] - | ^^^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^^^ | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 94 94 | pass @@ -280,15 +294,16 @@ FURB129.py:97:23: FURB129 [*] Instead of calling `readlines()`, iterate over fil 99 99 | 100 100 | with open("furb129.py") as f: -FURB129.py:101:17: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:101:17 | 100 | with open("furb129.py") as f: 101 | for line in (((f))).readlines(): - | ^^^^^^^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^^^^^^^ 102 | pass 103 | for line in(f).readlines(): | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 98 98 | @@ -300,15 +315,16 @@ FURB129.py:101:17: FURB129 [*] Instead of calling `readlines()`, iterate over fi 103 103 | for line in(f).readlines(): 104 104 | pass -FURB129.py:103:16: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:103:16 | 101 | for line in (((f))).readlines(): 102 | pass 103 | for line in(f).readlines(): - | ^^^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^^^ 104 | pass | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 100 100 | with open("furb129.py") as f: @@ -320,15 +336,16 @@ FURB129.py:103:16: FURB129 [*] Instead of calling `readlines()`, iterate over fi 105 105 | 106 106 | # Test case for issue #17683 (missing space before keyword) -FURB129.py:107:29: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:107:29 | 106 | # Test case for issue #17683 (missing space before keyword) 107 | print([line for line in f.readlines()if True]) - | ^^^^^^^^^^^^^ FURB129 + | ^^^^^^^^^^^^^ 108 | 109 | # https://github.com/astral-sh/ruff/issues/18843 | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Safe fix 104 104 | pass @@ -340,18 +357,19 @@ FURB129.py:107:29: FURB129 [*] Instead of calling `readlines()`, iterate over fi 109 109 | # https://github.com/astral-sh/ruff/issues/18843 110 110 | with open("file.txt") as fp: -FURB129.py:112:9: FURB129 [*] Instead of calling `readlines()`, iterate over file object directly +FURB129 [*] Instead of calling `readlines()`, iterate over file object directly + --> FURB129.py:112:9 | 110 | with open("file.txt") as fp: 111 | for line in ( # 1 112 | / fp. # 3 # 2 113 | | readlines( # 4 114 | | ) # 5 - | |_________^ FURB129 + | |_________^ 115 | ): 116 | ... | - = help: Remove `readlines()` +help: Remove `readlines()` ℹ Unsafe fix 109 109 | # https://github.com/astral-sh/ruff/issues/18843 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap index 8928bc8483..ad12904da8 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB131.py:11:1: FURB131 [*] Prefer `clear` over deleting a full slice +FURB131 [*] Prefer `clear` over deleting a full slice + --> FURB131.py:11:1 | 10 | # FURB131 11 | del nums[:] - | ^^^^^^^^^^^ FURB131 + | ^^^^^^^^^^^ | - = help: Replace with `clear()` +help: Replace with `clear()` ℹ Unsafe fix 8 8 | # these should match @@ -19,13 +20,14 @@ FURB131.py:11:1: FURB131 [*] Prefer `clear` over deleting a full slice 13 13 | 14 14 | # FURB131 -FURB131.py:15:1: FURB131 [*] Prefer `clear` over deleting a full slice +FURB131 [*] Prefer `clear` over deleting a full slice + --> FURB131.py:15:1 | 14 | # FURB131 15 | del names[:] - | ^^^^^^^^^^^^ FURB131 + | ^^^^^^^^^^^^ | - = help: Replace with `clear()` +help: Replace with `clear()` ℹ Unsafe fix 12 12 | @@ -37,30 +39,33 @@ FURB131.py:15:1: FURB131 [*] Prefer `clear` over deleting a full slice 17 17 | 18 18 | # FURB131 -FURB131.py:19:1: FURB131 Prefer `clear` over deleting a full slice +FURB131 Prefer `clear` over deleting a full slice + --> FURB131.py:19:1 | 18 | # FURB131 19 | del x, nums[:] - | ^^^^^^^^^^^^^^ FURB131 + | ^^^^^^^^^^^^^^ | - = help: Replace with `clear()` +help: Replace with `clear()` -FURB131.py:23:1: FURB131 Prefer `clear` over deleting a full slice +FURB131 Prefer `clear` over deleting a full slice + --> FURB131.py:23:1 | 22 | # FURB131 23 | del y, names[:], x - | ^^^^^^^^^^^^^^^^^^ FURB131 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace with `clear()` +help: Replace with `clear()` -FURB131.py:28:5: FURB131 [*] Prefer `clear` over deleting a full slice +FURB131 [*] Prefer `clear` over deleting a full slice + --> FURB131.py:28:5 | 26 | def yes_one(x: list[int]): 27 | # FURB131 28 | del x[:] - | ^^^^^^^^ FURB131 + | ^^^^^^^^ | - = help: Replace with `clear()` +help: Replace with `clear()` ℹ Unsafe fix 25 25 | @@ -72,14 +77,15 @@ FURB131.py:28:5: FURB131 [*] Prefer `clear` over deleting a full slice 30 30 | 31 31 | def yes_two(x: dict[int, str]): -FURB131.py:33:5: FURB131 [*] Prefer `clear` over deleting a full slice +FURB131 [*] Prefer `clear` over deleting a full slice + --> FURB131.py:33:5 | 31 | def yes_two(x: dict[int, str]): 32 | # FURB131 33 | del x[:] - | ^^^^^^^^ FURB131 + | ^^^^^^^^ | - = help: Replace with `clear()` +help: Replace with `clear()` ℹ Unsafe fix 30 30 | @@ -91,14 +97,15 @@ FURB131.py:33:5: FURB131 [*] Prefer `clear` over deleting a full slice 35 35 | 36 36 | def yes_three(x: List[int]): -FURB131.py:38:5: FURB131 [*] Prefer `clear` over deleting a full slice +FURB131 [*] Prefer `clear` over deleting a full slice + --> FURB131.py:38:5 | 36 | def yes_three(x: List[int]): 37 | # FURB131 38 | del x[:] - | ^^^^^^^^ FURB131 + | ^^^^^^^^ | - = help: Replace with `clear()` +help: Replace with `clear()` ℹ Unsafe fix 35 35 | @@ -110,14 +117,15 @@ FURB131.py:38:5: FURB131 [*] Prefer `clear` over deleting a full slice 40 40 | 41 41 | def yes_four(x: Dict[int, str]): -FURB131.py:43:5: FURB131 [*] Prefer `clear` over deleting a full slice +FURB131 [*] Prefer `clear` over deleting a full slice + --> FURB131.py:43:5 | 41 | def yes_four(x: Dict[int, str]): 42 | # FURB131 43 | del x[:] - | ^^^^^^^^ FURB131 + | ^^^^^^^^ | - = help: Replace with `clear()` +help: Replace with `clear()` ℹ Unsafe fix 40 40 | @@ -129,16 +137,17 @@ FURB131.py:43:5: FURB131 [*] Prefer `clear` over deleting a full slice 45 45 | 46 46 | def yes_five(x: Dict[int, str]): -FURB131.py:48:5: FURB131 [*] Prefer `clear` over deleting a full slice +FURB131 [*] Prefer `clear` over deleting a full slice + --> FURB131.py:48:5 | 46 | def yes_five(x: Dict[int, str]): 47 | # FURB131 48 | del x[:] - | ^^^^^^^^ FURB131 + | ^^^^^^^^ 49 | 50 | x = 1 | - = help: Replace with `clear()` +help: Replace with `clear()` ℹ Unsafe fix 45 45 | @@ -150,16 +159,17 @@ FURB131.py:48:5: FURB131 [*] Prefer `clear` over deleting a full slice 50 50 | x = 1 51 51 | -FURB131.py:58:1: FURB131 [*] Prefer `clear` over deleting a full slice +FURB131 [*] Prefer `clear` over deleting a full slice + --> FURB131.py:58:1 | 56 | sneaky = SneakyList() 57 | # FURB131 58 | del sneaky[:] - | ^^^^^^^^^^^^^ FURB131 + | ^^^^^^^^^^^^^ 59 | 60 | # these should not | - = help: Replace with `clear()` +help: Replace with `clear()` ℹ Unsafe fix 55 55 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap index 4f3f51660f..33f04dcf7c 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- -FURB132.py:12:1: FURB132 [*] Use `s.discard("x")` instead of check and `remove` +FURB132 [*] Use `s.discard("x")` instead of check and `remove` + --> FURB132.py:12:1 | 11 | # FURB132 12 | / if "x" in s: 13 | | s.remove("x") - | |_________________^ FURB132 + | |_________________^ | - = help: Replace with `s.discard("x")` +help: Replace with `s.discard("x")` ℹ Unsafe fix 9 9 | # these should match @@ -22,14 +22,15 @@ FURB132.py:12:1: FURB132 [*] Use `s.discard("x")` instead of check and `remove` 15 14 | 16 15 | # FURB132 -FURB132.py:22:1: FURB132 [*] Use `s3.discard("x")` instead of check and `remove` +FURB132 [*] Use `s3.discard("x")` instead of check and `remove` + --> FURB132.py:22:1 | 21 | # FURB132 22 | / if "x" in s3: 23 | | s3.remove("x") - | |__________________^ FURB132 + | |__________________^ | - = help: Replace with `s3.discard("x")` +help: Replace with `s3.discard("x")` ℹ Unsafe fix 19 19 | @@ -42,15 +43,16 @@ FURB132.py:22:1: FURB132 [*] Use `s3.discard("x")` instead of check and `remove` 25 24 | 26 25 | var = "y" -FURB132.py:28:1: FURB132 [*] Use `s.discard(var)` instead of check and `remove` +FURB132 [*] Use `s.discard(var)` instead of check and `remove` + --> FURB132.py:28:1 | 26 | var = "y" 27 | # FURB132 28 | / if var in s: 29 | | s.remove(var) - | |_________________^ FURB132 + | |_________________^ | - = help: Replace with `s.discard(var)` +help: Replace with `s.discard(var)` ℹ Unsafe fix 25 25 | @@ -63,13 +65,14 @@ FURB132.py:28:1: FURB132 [*] Use `s.discard(var)` instead of check and `remove` 31 30 | 32 31 | if f"{var}:{var}" in s: -FURB132.py:32:1: FURB132 [*] Use `s.discard(f"{var}:{var}")` instead of check and `remove` +FURB132 [*] Use `s.discard(f"{var}:{var}")` instead of check and `remove` + --> FURB132.py:32:1 | 32 | / if f"{var}:{var}" in s: 33 | | s.remove(f"{var}:{var}") - | |____________________________^ FURB132 + | |____________________________^ | - = help: Replace with `s.discard(f"{var}:{var}")` +help: Replace with `s.discard(f"{var}:{var}")` ℹ Unsafe fix 29 29 | s.remove(var) diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap index 91386ad528..6cb09b7785 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB136_FURB136.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB136.py:4:1: FURB136 [*] Replace `x if x > y else y` with `max(y, x)` +FURB136 [*] Replace `x if x > y else y` with `max(y, x)` + --> FURB136.py:4:1 | 2 | y = 2 3 | 4 | x if x > y else y # FURB136 - | ^^^^^^^^^^^^^^^^^ FURB136 + | ^^^^^^^^^^^^^^^^^ 5 | 6 | x if x >= y else y # FURB136 | - = help: Replace with `max(y, x)` +help: Replace with `max(y, x)` ℹ Safe fix 1 1 | x = 1 @@ -22,16 +23,17 @@ FURB136.py:4:1: FURB136 [*] Replace `x if x > y else y` with `max(y, x)` 6 6 | x if x >= y else y # FURB136 7 7 | -FURB136.py:6:1: FURB136 [*] Replace `x if x >= y else y` with `max(x, y)` +FURB136 [*] Replace `x if x >= y else y` with `max(x, y)` + --> FURB136.py:6:1 | 4 | x if x > y else y # FURB136 5 | 6 | x if x >= y else y # FURB136 - | ^^^^^^^^^^^^^^^^^^ FURB136 + | ^^^^^^^^^^^^^^^^^^ 7 | 8 | x if x < y else y # FURB136 | - = help: Replace with `max(x, y)` +help: Replace with `max(x, y)` ℹ Safe fix 3 3 | @@ -43,16 +45,17 @@ FURB136.py:6:1: FURB136 [*] Replace `x if x >= y else y` with `max(x, y)` 8 8 | x if x < y else y # FURB136 9 9 | -FURB136.py:8:1: FURB136 [*] Replace `x if x < y else y` with `min(y, x)` +FURB136 [*] Replace `x if x < y else y` with `min(y, x)` + --> FURB136.py:8:1 | 6 | x if x >= y else y # FURB136 7 | 8 | x if x < y else y # FURB136 - | ^^^^^^^^^^^^^^^^^ FURB136 + | ^^^^^^^^^^^^^^^^^ 9 | 10 | x if x <= y else y # FURB136 | - = help: Replace with `min(y, x)` +help: Replace with `min(y, x)` ℹ Safe fix 5 5 | @@ -64,16 +67,17 @@ FURB136.py:8:1: FURB136 [*] Replace `x if x < y else y` with `min(y, x)` 10 10 | x if x <= y else y # FURB136 11 11 | -FURB136.py:10:1: FURB136 [*] Replace `x if x <= y else y` with `min(x, y)` +FURB136 [*] Replace `x if x <= y else y` with `min(x, y)` + --> FURB136.py:10:1 | 8 | x if x < y else y # FURB136 9 | 10 | x if x <= y else y # FURB136 - | ^^^^^^^^^^^^^^^^^^ FURB136 + | ^^^^^^^^^^^^^^^^^^ 11 | 12 | y if x > y else x # FURB136 | - = help: Replace with `min(x, y)` +help: Replace with `min(x, y)` ℹ Safe fix 7 7 | @@ -85,16 +89,17 @@ FURB136.py:10:1: FURB136 [*] Replace `x if x <= y else y` with `min(x, y)` 12 12 | y if x > y else x # FURB136 13 13 | -FURB136.py:12:1: FURB136 [*] Replace `y if x > y else x` with `min(x, y)` +FURB136 [*] Replace `y if x > y else x` with `min(x, y)` + --> FURB136.py:12:1 | 10 | x if x <= y else y # FURB136 11 | 12 | y if x > y else x # FURB136 - | ^^^^^^^^^^^^^^^^^ FURB136 + | ^^^^^^^^^^^^^^^^^ 13 | 14 | y if x >= y else x # FURB136 | - = help: Replace with `min(x, y)` +help: Replace with `min(x, y)` ℹ Safe fix 9 9 | @@ -106,16 +111,17 @@ FURB136.py:12:1: FURB136 [*] Replace `y if x > y else x` with `min(x, y)` 14 14 | y if x >= y else x # FURB136 15 15 | -FURB136.py:14:1: FURB136 [*] Replace `y if x >= y else x` with `min(y, x)` +FURB136 [*] Replace `y if x >= y else x` with `min(y, x)` + --> FURB136.py:14:1 | 12 | y if x > y else x # FURB136 13 | 14 | y if x >= y else x # FURB136 - | ^^^^^^^^^^^^^^^^^^ FURB136 + | ^^^^^^^^^^^^^^^^^^ 15 | 16 | y if x < y else x # FURB136 | - = help: Replace with `min(y, x)` +help: Replace with `min(y, x)` ℹ Safe fix 11 11 | @@ -127,16 +133,17 @@ FURB136.py:14:1: FURB136 [*] Replace `y if x >= y else x` with `min(y, x)` 16 16 | y if x < y else x # FURB136 17 17 | -FURB136.py:16:1: FURB136 [*] Replace `y if x < y else x` with `max(x, y)` +FURB136 [*] Replace `y if x < y else x` with `max(x, y)` + --> FURB136.py:16:1 | 14 | y if x >= y else x # FURB136 15 | 16 | y if x < y else x # FURB136 - | ^^^^^^^^^^^^^^^^^ FURB136 + | ^^^^^^^^^^^^^^^^^ 17 | 18 | y if x <= y else x # FURB136 | - = help: Replace with `max(x, y)` +help: Replace with `max(x, y)` ℹ Safe fix 13 13 | @@ -148,16 +155,17 @@ FURB136.py:16:1: FURB136 [*] Replace `y if x < y else x` with `max(x, y)` 18 18 | y if x <= y else x # FURB136 19 19 | -FURB136.py:18:1: FURB136 [*] Replace `y if x <= y else x` with `max(y, x)` +FURB136 [*] Replace `y if x <= y else x` with `max(y, x)` + --> FURB136.py:18:1 | 16 | y if x < y else x # FURB136 17 | 18 | y if x <= y else x # FURB136 - | ^^^^^^^^^^^^^^^^^^ FURB136 + | ^^^^^^^^^^^^^^^^^^ 19 | 20 | x + y if x > y else y # OK | - = help: Replace with `max(y, x)` +help: Replace with `max(y, x)` ℹ Safe fix 15 15 | @@ -169,7 +177,8 @@ FURB136.py:18:1: FURB136 [*] Replace `y if x <= y else x` with `max(y, x)` 20 20 | x + y if x > y else y # OK 21 21 | -FURB136.py:22:1: FURB136 [*] Replace `if` expression with `max(y, x)` +FURB136 [*] Replace `if` expression with `max(y, x)` + --> FURB136.py:22:1 | 20 | x + y if x > y else y # OK 21 | @@ -177,9 +186,9 @@ FURB136.py:22:1: FURB136 [*] Replace `if` expression with `max(y, x)` 23 | | x 24 | | > y 25 | | ) else y # FURB136 - | |________^ FURB136 + | |________^ | - = help: Replace with `max(y, x)` +help: Replace with `max(y, x)` ℹ Safe fix 19 19 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap index 7748edac5a..28058f73ce 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB140.py:7:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:7:1 | 6 | # FURB140 7 | [print(x, y) for x, y in zipped()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # FURB140 | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 1 |+from itertools import starmap @@ -25,15 +26,16 @@ FURB140.py:7:1: FURB140 [*] Use `itertools.starmap` instead of the generator 9 10 | # FURB140 10 11 | (print(x, y) for x, y in zipped()) -FURB140.py:10:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:10:1 | 9 | # FURB140 10 | (print(x, y) for x, y in zipped()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | # FURB140 | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 1 |+from itertools import starmap @@ -50,13 +52,14 @@ FURB140.py:10:1: FURB140 [*] Use `itertools.starmap` instead of the generator 12 13 | # FURB140 13 14 | {print(x, y) for x, y in zipped()} -FURB140.py:13:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:13:1 | 12 | # FURB140 13 | {print(x, y) for x, y in zipped()} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 1 |+from itertools import starmap @@ -73,15 +76,16 @@ FURB140.py:13:1: FURB140 [*] Use `itertools.starmap` instead of the generator 15 16 | 16 17 | from itertools import starmap as sm -FURB140.py:19:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:19:1 | 18 | # FURB140 19 | [print(x, y) for x, y in zipped()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | # FURB140 | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 16 16 | from itertools import starmap as sm @@ -93,15 +97,16 @@ FURB140.py:19:1: FURB140 [*] Use `itertools.starmap` instead of the generator 21 21 | # FURB140 22 22 | (print(x, y) for x, y in zipped()) -FURB140.py:22:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:22:1 | 21 | # FURB140 22 | (print(x, y) for x, y in zipped()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | 24 | # FURB140 | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 19 19 | [print(x, y) for x, y in zipped()] @@ -113,15 +118,16 @@ FURB140.py:22:1: FURB140 [*] Use `itertools.starmap` instead of the generator 24 24 | # FURB140 25 25 | {print(x, y) for x, y in zipped()} -FURB140.py:25:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:25:1 | 24 | # FURB140 25 | {print(x, y) for x, y in zipped()} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | # FURB140 (check it still flags starred arguments). | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 22 22 | (print(x, y) for x, y in zipped()) @@ -133,16 +139,17 @@ FURB140.py:25:1: FURB140 [*] Use `itertools.starmap` instead of the generator 27 27 | # FURB140 (check it still flags starred arguments). 28 28 | # See https://github.com/astral-sh/ruff/issues/7636 -FURB140.py:29:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:29:1 | 27 | # FURB140 (check it still flags starred arguments). 28 | # See https://github.com/astral-sh/ruff/issues/7636 29 | [foo(*t) for t in [(85, 60), (100, 80)]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | (foo(*t) for t in [(85, 60), (100, 80)]) 31 | {foo(*t) for t in [(85, 60), (100, 80)]} | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 26 26 | @@ -154,15 +161,16 @@ FURB140.py:29:1: FURB140 [*] Use `itertools.starmap` instead of the generator 31 31 | {foo(*t) for t in [(85, 60), (100, 80)]} 32 32 | -FURB140.py:30:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:30:1 | 28 | # See https://github.com/astral-sh/ruff/issues/7636 29 | [foo(*t) for t in [(85, 60), (100, 80)]] 30 | (foo(*t) for t in [(85, 60), (100, 80)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | {foo(*t) for t in [(85, 60), (100, 80)]} | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 27 27 | # FURB140 (check it still flags starred arguments). @@ -174,16 +182,17 @@ FURB140.py:30:1: FURB140 [*] Use `itertools.starmap` instead of the generator 32 32 | 33 33 | # Non-errors. -FURB140.py:31:1: FURB140 [*] Use `itertools.starmap` instead of the generator +FURB140 [*] Use `itertools.starmap` instead of the generator + --> FURB140.py:31:1 | 29 | [foo(*t) for t in [(85, 60), (100, 80)]] 30 | (foo(*t) for t in [(85, 60), (100, 80)]) 31 | {foo(*t) for t in [(85, 60), (100, 80)]} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | # Non-errors. | - = help: Replace with `itertools.starmap` +help: Replace with `itertools.starmap` ℹ Safe fix 28 28 | # See https://github.com/astral-sh/ruff/issues/7636 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap index be96dc7fcd..b37a7c2d17 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB142_FURB142.py.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB142.py:5:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:5:1 | 3 | s = set() 4 | 5 | / for x in [1, 2, 3]: 6 | | s.add(x) - | |____________^ FURB142 + | |____________^ 7 | 8 | for x in {1, 2, 3}: | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 2 2 | @@ -24,17 +25,18 @@ FURB142.py:5:1: FURB142 [*] Use of `set.add()` in a for loop 8 7 | for x in {1, 2, 3}: 9 8 | s.add(x) -FURB142.py:8:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:8:1 | 6 | s.add(x) 7 | 8 | / for x in {1, 2, 3}: 9 | | s.add(x) - | |____________^ FURB142 + | |____________^ 10 | 11 | for x in (1, 2, 3): | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 5 5 | for x in [1, 2, 3]: @@ -47,17 +49,18 @@ FURB142.py:8:1: FURB142 [*] Use of `set.add()` in a for loop 11 10 | for x in (1, 2, 3): 12 11 | s.add(x) -FURB142.py:11:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:11:1 | 9 | s.add(x) 10 | 11 | / for x in (1, 2, 3): 12 | | s.add(x) - | |____________^ FURB142 + | |____________^ 13 | 14 | for x in (1, 2, 3): | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 8 8 | for x in {1, 2, 3}: @@ -70,17 +73,18 @@ FURB142.py:11:1: FURB142 [*] Use of `set.add()` in a for loop 14 13 | for x in (1, 2, 3): 15 14 | s.discard(x) -FURB142.py:14:1: FURB142 [*] Use of `set.discard()` in a for loop +FURB142 [*] Use of `set.discard()` in a for loop + --> FURB142.py:14:1 | 12 | s.add(x) 13 | 14 | / for x in (1, 2, 3): 15 | | s.discard(x) - | |________________^ FURB142 + | |________________^ 16 | 17 | for x in (1, 2, 3): | - = help: Replace with `.difference_update()` +help: Replace with `.difference_update()` ℹ Safe fix 11 11 | for x in (1, 2, 3): @@ -93,17 +97,18 @@ FURB142.py:14:1: FURB142 [*] Use of `set.discard()` in a for loop 17 16 | for x in (1, 2, 3): 18 17 | s.add(x + 1) -FURB142.py:17:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:17:1 | 15 | s.discard(x) 16 | 17 | / for x in (1, 2, 3): 18 | | s.add(x + 1) - | |________________^ FURB142 + | |________________^ 19 | 20 | for x, y in ((1, 2), (3, 4)): | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 14 14 | for x in (1, 2, 3): @@ -116,17 +121,18 @@ FURB142.py:17:1: FURB142 [*] Use of `set.add()` in a for loop 20 19 | for x, y in ((1, 2), (3, 4)): 21 20 | s.add((x, y)) -FURB142.py:20:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:20:1 | 18 | s.add(x + 1) 19 | 20 | / for x, y in ((1, 2), (3, 4)): 21 | | s.add((x, y)) - | |_________________^ FURB142 + | |_________________^ 22 | 23 | num = 123 | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 17 17 | for x in (1, 2, 3): @@ -139,17 +145,18 @@ FURB142.py:20:1: FURB142 [*] Use of `set.add()` in a for loop 23 22 | num = 123 24 23 | -FURB142.py:25:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:25:1 | 23 | num = 123 24 | 25 | / for x in (1, 2, 3): 26 | | s.add(num) - | |______________^ FURB142 + | |______________^ 27 | 28 | for x in (1, 2, 3): | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 22 22 | @@ -162,17 +169,18 @@ FURB142.py:25:1: FURB142 [*] Use of `set.add()` in a for loop 28 27 | for x in (1, 2, 3): 29 28 | s.add((num, x)) -FURB142.py:28:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:28:1 | 26 | s.add(num) 27 | 28 | / for x in (1, 2, 3): 29 | | s.add((num, x)) - | |___________________^ FURB142 + | |___________________^ 30 | 31 | for x in (1, 2, 3): | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 25 25 | for x in (1, 2, 3): @@ -185,17 +193,18 @@ FURB142.py:28:1: FURB142 [*] Use of `set.add()` in a for loop 31 30 | for x in (1, 2, 3): 32 31 | s.add(x + num) -FURB142.py:31:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:31:1 | 29 | s.add((num, x)) 30 | 31 | / for x in (1, 2, 3): 32 | | s.add(x + num) - | |__________________^ FURB142 + | |__________________^ 33 | 34 | # https://github.com/astral-sh/ruff/issues/15936 | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 28 28 | for x in (1, 2, 3): @@ -208,16 +217,17 @@ FURB142.py:31:1: FURB142 [*] Use of `set.add()` in a for loop 34 33 | # https://github.com/astral-sh/ruff/issues/15936 35 34 | for x in 1, 2, 3: -FURB142.py:35:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:35:1 | 34 | # https://github.com/astral-sh/ruff/issues/15936 35 | / for x in 1, 2, 3: 36 | | s.add(x) - | |____________^ FURB142 + | |____________^ 37 | 38 | for x in 1, 2, 3: | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 32 32 | s.add(x + num) @@ -230,17 +240,18 @@ FURB142.py:35:1: FURB142 [*] Use of `set.add()` in a for loop 38 37 | for x in 1, 2, 3: 39 38 | s.add(f"{x}") -FURB142.py:38:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:38:1 | 36 | s.add(x) 37 | 38 | / for x in 1, 2, 3: 39 | | s.add(f"{x}") - | |_________________^ FURB142 + | |_________________^ 40 | 41 | for x in ( | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 35 35 | for x in 1, 2, 3: @@ -253,7 +264,8 @@ FURB142.py:38:1: FURB142 [*] Use of `set.add()` in a for loop 41 40 | for x in ( 42 41 | 1, # Comment -FURB142.py:41:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:41:1 | 39 | s.add(f"{x}") 40 | @@ -262,9 +274,9 @@ FURB142.py:41:1: FURB142 [*] Use of `set.add()` in a for loop 43 | | 2, 3 44 | | ): 45 | | s.add(f"{x}") - | |_________________^ FURB142 + | |_________________^ | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Unsafe fix 38 38 | for x in 1, 2, 3: @@ -281,17 +293,18 @@ FURB142.py:41:1: FURB142 [*] Use of `set.add()` in a for loop 47 46 | 48 47 | # False negative -FURB142.py:83:1: FURB142 [*] Use of `set.discard()` in a for loop +FURB142 [*] Use of `set.discard()` in a for loop + --> FURB142.py:83:1 | 81 | s = set() 82 | 83 | / for x in lambda: 0: 84 | | s.discard(-x) - | |_________________^ FURB142 + | |_________________^ 85 | 86 | for x in (1,) if True else (2,): | - = help: Replace with `.difference_update()` +help: Replace with `.difference_update()` ℹ Safe fix 80 80 | @@ -304,17 +317,18 @@ FURB142.py:83:1: FURB142 [*] Use of `set.discard()` in a for loop 86 85 | for x in (1,) if True else (2,): 87 86 | s.add(-x) -FURB142.py:86:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:86:1 | 84 | s.discard(-x) 85 | 86 | / for x in (1,) if True else (2,): 87 | | s.add(-x) - | |_____________^ FURB142 + | |_____________^ 88 | 89 | # don't add extra parens | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 83 83 | for x in lambda: 0: @@ -327,16 +341,17 @@ FURB142.py:86:1: FURB142 [*] Use of `set.add()` in a for loop 89 88 | # don't add extra parens 90 89 | for x in (lambda: 0): -FURB142.py:90:1: FURB142 [*] Use of `set.discard()` in a for loop +FURB142 [*] Use of `set.discard()` in a for loop + --> FURB142.py:90:1 | 89 | # don't add extra parens 90 | / for x in (lambda: 0): 91 | | s.discard(-x) - | |_________________^ FURB142 + | |_________________^ 92 | 93 | for x in ((1,) if True else (2,)): | - = help: Replace with `.difference_update()` +help: Replace with `.difference_update()` ℹ Safe fix 87 87 | s.add(-x) @@ -349,17 +364,18 @@ FURB142.py:90:1: FURB142 [*] Use of `set.discard()` in a for loop 93 92 | for x in ((1,) if True else (2,)): 94 93 | s.add(-x) -FURB142.py:93:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:93:1 | 91 | s.discard(-x) 92 | 93 | / for x in ((1,) if True else (2,)): 94 | | s.add(-x) - | |_____________^ FURB142 + | |_____________^ 95 | 96 | # don't add parens directly in function call | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 90 90 | for x in (lambda: 0): @@ -372,16 +388,17 @@ FURB142.py:93:1: FURB142 [*] Use of `set.add()` in a for loop 96 95 | # don't add parens directly in function call 97 96 | for x in lambda: 0: -FURB142.py:97:1: FURB142 [*] Use of `set.discard()` in a for loop +FURB142 [*] Use of `set.discard()` in a for loop + --> FURB142.py:97:1 | 96 | # don't add parens directly in function call 97 | / for x in lambda: 0: 98 | | s.discard(x) - | |________________^ FURB142 + | |________________^ 99 | 100 | for x in (1,) if True else (2,): | - = help: Replace with `.difference_update()` +help: Replace with `.difference_update()` ℹ Safe fix 94 94 | s.add(-x) @@ -394,15 +411,16 @@ FURB142.py:97:1: FURB142 [*] Use of `set.discard()` in a for loop 100 99 | for x in (1,) if True else (2,): 101 100 | s.add(x) -FURB142.py:100:1: FURB142 [*] Use of `set.add()` in a for loop +FURB142 [*] Use of `set.add()` in a for loop + --> FURB142.py:100:1 | 98 | s.discard(x) 99 | 100 | / for x in (1,) if True else (2,): 101 | | s.add(x) - | |____________^ FURB142 + | |____________^ | - = help: Replace with `.update()` +help: Replace with `.update()` ℹ Safe fix 97 97 | for x in lambda: 0: diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap index 176f2c59e5..1c83a4a236 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB145.py:4:5: FURB145 [*] Prefer `copy` method over slicing +FURB145 [*] Prefer `copy` method over slicing + --> FURB145.py:4:5 | 3 | # Errors. 4 | a = l[:] - | ^^^^ FURB145 + | ^^^^ 5 | b, c = 1, l[:] 6 | d, e = l[:], 1 | - = help: Replace with `copy()` +help: Replace with `copy()` ℹ Safe fix 1 1 | l = [1, 2, 3, 4, 5] @@ -21,16 +22,17 @@ FURB145.py:4:5: FURB145 [*] Prefer `copy` method over slicing 6 6 | d, e = l[:], 1 7 7 | m = l[::] -FURB145.py:5:11: FURB145 [*] Prefer `copy` method over slicing +FURB145 [*] Prefer `copy` method over slicing + --> FURB145.py:5:11 | 3 | # Errors. 4 | a = l[:] 5 | b, c = 1, l[:] - | ^^^^ FURB145 + | ^^^^ 6 | d, e = l[:], 1 7 | m = l[::] | - = help: Replace with `copy()` +help: Replace with `copy()` ℹ Safe fix 2 2 | @@ -42,16 +44,17 @@ FURB145.py:5:11: FURB145 [*] Prefer `copy` method over slicing 7 7 | m = l[::] 8 8 | l[:] -FURB145.py:6:8: FURB145 [*] Prefer `copy` method over slicing +FURB145 [*] Prefer `copy` method over slicing + --> FURB145.py:6:8 | 4 | a = l[:] 5 | b, c = 1, l[:] 6 | d, e = l[:], 1 - | ^^^^ FURB145 + | ^^^^ 7 | m = l[::] 8 | l[:] | - = help: Replace with `copy()` +help: Replace with `copy()` ℹ Safe fix 3 3 | # Errors. @@ -63,16 +66,17 @@ FURB145.py:6:8: FURB145 [*] Prefer `copy` method over slicing 8 8 | l[:] 9 9 | print(l[:]) -FURB145.py:7:5: FURB145 [*] Prefer `copy` method over slicing +FURB145 [*] Prefer `copy` method over slicing + --> FURB145.py:7:5 | 5 | b, c = 1, l[:] 6 | d, e = l[:], 1 7 | m = l[::] - | ^^^^^ FURB145 + | ^^^^^ 8 | l[:] 9 | print(l[:]) | - = help: Replace with `copy()` +help: Replace with `copy()` ℹ Safe fix 4 4 | a = l[:] @@ -84,15 +88,16 @@ FURB145.py:7:5: FURB145 [*] Prefer `copy` method over slicing 9 9 | print(l[:]) 10 10 | -FURB145.py:8:1: FURB145 [*] Prefer `copy` method over slicing +FURB145 [*] Prefer `copy` method over slicing + --> FURB145.py:8:1 | 6 | d, e = l[:], 1 7 | m = l[::] 8 | l[:] - | ^^^^ FURB145 + | ^^^^ 9 | print(l[:]) | - = help: Replace with `copy()` +help: Replace with `copy()` ℹ Safe fix 5 5 | b, c = 1, l[:] @@ -104,16 +109,17 @@ FURB145.py:8:1: FURB145 [*] Prefer `copy` method over slicing 10 10 | 11 11 | # False negatives. -FURB145.py:9:7: FURB145 [*] Prefer `copy` method over slicing +FURB145 [*] Prefer `copy` method over slicing + --> FURB145.py:9:7 | 7 | m = l[::] 8 | l[:] 9 | print(l[:]) - | ^^^^ FURB145 + | ^^^^ 10 | 11 | # False negatives. | - = help: Replace with `copy()` +help: Replace with `copy()` ℹ Safe fix 6 6 | d, e = l[:], 1 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap index a6b220ffee..bc19dd98ab 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB148.py:14:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:14:17 | 13 | # Errors 14 | for index, _ in enumerate(books): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 15 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 11 11 | books_tuple = ("Dune", "Foundation", "Neuromancer") @@ -20,15 +21,16 @@ FURB148.py:14:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l 16 16 | 17 17 | for index, _ in enumerate(books, start=0): -FURB148.py:17:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:17:17 | 15 | print(index) 16 | 17 | for index, _ in enumerate(books, start=0): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 18 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 14 14 | for index, _ in enumerate(books): @@ -40,15 +42,16 @@ FURB148.py:17:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l 19 19 | 20 20 | for index, _ in enumerate(books, 0): -FURB148.py:20:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:20:17 | 18 | print(index) 19 | 20 | for index, _ in enumerate(books, 0): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 21 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 17 17 | for index, _ in enumerate(books, start=0): @@ -60,55 +63,60 @@ FURB148.py:20:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l 22 22 | 23 23 | for index, _ in enumerate(books, start=1): -FURB148.py:23:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:23:17 | 21 | print(index) 22 | 23 | for index, _ in enumerate(books, start=1): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 24 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` -FURB148.py:26:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:26:17 | 24 | print(index) 25 | 26 | for index, _ in enumerate(books, 1): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 27 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` -FURB148.py:29:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:29:17 | 27 | print(index) 28 | 29 | for index, _ in enumerate(books, start=x): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 30 | print(book) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` -FURB148.py:32:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:32:17 | 30 | print(book) 31 | 32 | for index, _ in enumerate(books, x): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 33 | print(book) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` -FURB148.py:35:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:35:16 | 33 | print(book) 34 | 35 | for _, book in enumerate(books): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 36 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 32 32 | for index, _ in enumerate(books, x): @@ -120,15 +128,16 @@ FURB148.py:35:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 37 37 | 38 38 | for _, book in enumerate(books, start=0): -FURB148.py:38:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:38:16 | 36 | print(book) 37 | 38 | for _, book in enumerate(books, start=0): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 39 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 35 35 | for _, book in enumerate(books): @@ -140,15 +149,16 @@ FURB148.py:38:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 40 40 | 41 41 | for _, book in enumerate(books, 0): -FURB148.py:41:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:41:16 | 39 | print(book) 40 | 41 | for _, book in enumerate(books, 0): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 42 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 38 38 | for _, book in enumerate(books, start=0): @@ -160,15 +170,16 @@ FURB148.py:41:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 43 43 | 44 44 | for _, book in enumerate(books, start=1): -FURB148.py:44:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:44:16 | 42 | print(book) 43 | 44 | for _, book in enumerate(books, start=1): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 45 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 41 41 | for _, book in enumerate(books, 0): @@ -180,15 +191,16 @@ FURB148.py:44:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 46 46 | 47 47 | for _, book in enumerate(books, 1): -FURB148.py:47:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:47:16 | 45 | print(book) 46 | 47 | for _, book in enumerate(books, 1): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 48 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 44 44 | for _, book in enumerate(books, start=1): @@ -200,15 +212,16 @@ FURB148.py:47:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 49 49 | 50 50 | for _, book in enumerate(books, start=x): -FURB148.py:50:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:50:16 | 48 | print(book) 49 | 50 | for _, book in enumerate(books, start=x): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 51 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 47 47 | for _, book in enumerate(books, 1): @@ -220,15 +233,16 @@ FURB148.py:50:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 52 52 | 53 53 | for _, book in enumerate(books, x): -FURB148.py:53:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:53:16 | 51 | print(book) 52 | 53 | for _, book in enumerate(books, x): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 54 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 50 50 | for _, book in enumerate(books, start=x): @@ -240,15 +254,16 @@ FURB148.py:53:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 55 55 | 56 56 | for index, (_, _) in enumerate(books): -FURB148.py:56:22: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:56:22 | 54 | print(book) 55 | 56 | for index, (_, _) in enumerate(books): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 57 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 53 53 | for _, book in enumerate(books, x): @@ -260,15 +275,16 @@ FURB148.py:56:22: FURB148 [*] `enumerate` value is unused, use `for x in range(l 58 58 | 59 59 | for (_, _), book in enumerate(books): -FURB148.py:59:21: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:59:21 | 57 | print(index) 58 | 59 | for (_, _), book in enumerate(books): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 60 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 56 56 | for index, (_, _) in enumerate(books): @@ -280,15 +296,16 @@ FURB148.py:59:21: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 61 61 | 62 62 | for(index, _)in enumerate(books): -FURB148.py:62:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:62:17 | 60 | print(book) 61 | 62 | for(index, _)in enumerate(books): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 63 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 59 59 | for (_, _), book in enumerate(books): @@ -300,15 +317,16 @@ FURB148.py:62:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l 64 64 | 65 65 | for(index), _ in enumerate(books): -FURB148.py:65:18: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:65:18 | 63 | print(index) 64 | 65 | for(index), _ in enumerate(books): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 66 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 62 62 | for(index, _)in enumerate(books): @@ -320,15 +338,16 @@ FURB148.py:65:18: FURB148 [*] `enumerate` value is unused, use `for x in range(l 67 67 | 68 68 | for index, _ in enumerate(books_and_authors): -FURB148.py:68:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:68:17 | 66 | print(index) 67 | 68 | for index, _ in enumerate(books_and_authors): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 69 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 65 65 | for(index), _ in enumerate(books): @@ -340,15 +359,16 @@ FURB148.py:68:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l 70 70 | 71 71 | for _, book in enumerate(books_and_authors): -FURB148.py:71:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:71:16 | 69 | print(index) 70 | 71 | for _, book in enumerate(books_and_authors): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 72 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 68 68 | for index, _ in enumerate(books_and_authors): @@ -360,15 +380,16 @@ FURB148.py:71:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 73 73 | 74 74 | for index, _ in enumerate(books_set): -FURB148.py:74:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:74:17 | 72 | print(book) 73 | 74 | for index, _ in enumerate(books_set): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 75 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 71 71 | for _, book in enumerate(books_and_authors): @@ -380,15 +401,16 @@ FURB148.py:74:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l 76 76 | 77 77 | for _, book in enumerate(books_set): -FURB148.py:77:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:77:16 | 75 | print(index) 76 | 77 | for _, book in enumerate(books_set): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 78 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 74 74 | for index, _ in enumerate(books_set): @@ -400,15 +422,16 @@ FURB148.py:77:16: FURB148 [*] `enumerate` index is unused, use `for x in y` inst 79 79 | 80 80 | for index, _ in enumerate(books_tuple): -FURB148.py:80:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead +FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + --> FURB148.py:80:17 | 78 | print(book) 79 | 80 | for index, _ in enumerate(books_tuple): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 81 | print(index) | - = help: Replace with `range(len(...))` +help: Replace with `range(len(...))` ℹ Unsafe fix 77 77 | for _, book in enumerate(books_set): @@ -420,15 +443,16 @@ FURB148.py:80:17: FURB148 [*] `enumerate` value is unused, use `for x in range(l 82 82 | 83 83 | for _, book in enumerate(books_tuple): -FURB148.py:83:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead +FURB148 [*] `enumerate` index is unused, use `for x in y` instead + --> FURB148.py:83:16 | 81 | print(index) 82 | 83 | for _, book in enumerate(books_tuple): - | ^^^^^^^^^ FURB148 + | ^^^^^^^^^ 84 | print(book) | - = help: Remove `enumerate` +help: Remove `enumerate` ℹ Unsafe fix 80 80 | for index, _ in enumerate(books_tuple): diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap index c51afdd85a..160659757e 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB152_FURB152.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB152.py:3:5: FURB152 [*] Replace `3.14` with `math.pi` +FURB152 [*] Replace `3.14` with `math.pi` + --> FURB152.py:3:5 | 1 | r = 3.1 # OK 2 | 3 | A = 3.14 * r ** 2 # FURB152 - | ^^^^ FURB152 + | ^^^^ 4 | 5 | C = 6.28 * r # FURB152 | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -22,16 +23,17 @@ FURB152.py:3:5: FURB152 [*] Replace `3.14` with `math.pi` 5 6 | C = 6.28 * r # FURB152 6 7 | -FURB152.py:5:5: FURB152 [*] Replace `6.28` with `math.tau` +FURB152 [*] Replace `6.28` with `math.tau` + --> FURB152.py:5:5 | 3 | A = 3.14 * r ** 2 # FURB152 4 | 5 | C = 6.28 * r # FURB152 - | ^^^^ FURB152 + | ^^^^ 6 | 7 | e = 2.71 # FURB152 | - = help: Use `math.tau` +help: Use `math.tau` ℹ Safe fix 1 |+import math @@ -45,16 +47,17 @@ FURB152.py:5:5: FURB152 [*] Replace `6.28` with `math.tau` 7 8 | e = 2.71 # FURB152 8 9 | -FURB152.py:7:5: FURB152 [*] Replace `2.71` with `math.e` +FURB152 [*] Replace `2.71` with `math.e` + --> FURB152.py:7:5 | 5 | C = 6.28 * r # FURB152 6 | 7 | e = 2.71 # FURB152 - | ^^^^ FURB152 + | ^^^^ 8 | 9 | r = 3.15 # OK | - = help: Use `math.e` +help: Use `math.e` ℹ Safe fix 1 |+import math @@ -70,16 +73,17 @@ FURB152.py:7:5: FURB152 [*] Replace `2.71` with `math.e` 9 10 | r = 3.15 # OK 10 11 | -FURB152.py:11:5: FURB152 [*] Replace `3.141` with `math.pi` +FURB152 [*] Replace `3.141` with `math.pi` + --> FURB152.py:11:5 | 9 | r = 3.15 # OK 10 | 11 | r = 3.141 # FURB152 - | ^^^^^ FURB152 + | ^^^^^ 12 | 13 | r = 3.142 # FURB152 | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -96,16 +100,17 @@ FURB152.py:11:5: FURB152 [*] Replace `3.141` with `math.pi` 13 14 | r = 3.142 # FURB152 14 15 | -FURB152.py:13:5: FURB152 [*] Replace `3.142` with `math.pi` +FURB152 [*] Replace `3.142` with `math.pi` + --> FURB152.py:13:5 | 11 | r = 3.141 # FURB152 12 | 13 | r = 3.142 # FURB152 - | ^^^^^ FURB152 + | ^^^^^ 14 | 15 | r = 3.1415 # FURB152 | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -122,16 +127,17 @@ FURB152.py:13:5: FURB152 [*] Replace `3.142` with `math.pi` 15 16 | r = 3.1415 # FURB152 16 17 | -FURB152.py:15:5: FURB152 [*] Replace `3.1415` with `math.pi` +FURB152 [*] Replace `3.1415` with `math.pi` + --> FURB152.py:15:5 | 13 | r = 3.142 # FURB152 14 | 15 | r = 3.1415 # FURB152 - | ^^^^^^ FURB152 + | ^^^^^^ 16 | 17 | r = 3.1416 # FURB152 | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -148,16 +154,17 @@ FURB152.py:15:5: FURB152 [*] Replace `3.1415` with `math.pi` 17 18 | r = 3.1416 # FURB152 18 19 | -FURB152.py:17:5: FURB152 [*] Replace `3.1416` with `math.pi` +FURB152 [*] Replace `3.1416` with `math.pi` + --> FURB152.py:17:5 | 15 | r = 3.1415 # FURB152 16 | 17 | r = 3.1416 # FURB152 - | ^^^^^^ FURB152 + | ^^^^^^ 18 | 19 | r = 3.141592 # FURB152 | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -174,16 +181,17 @@ FURB152.py:17:5: FURB152 [*] Replace `3.1416` with `math.pi` 19 20 | r = 3.141592 # FURB152 20 21 | -FURB152.py:19:5: FURB152 [*] Replace `3.141592` with `math.pi` +FURB152 [*] Replace `3.141592` with `math.pi` + --> FURB152.py:19:5 | 17 | r = 3.1416 # FURB152 18 | 19 | r = 3.141592 # FURB152 - | ^^^^^^^^ FURB152 + | ^^^^^^^^ 20 | 21 | r = 3.141593 # FURB152 | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -200,16 +208,17 @@ FURB152.py:19:5: FURB152 [*] Replace `3.141592` with `math.pi` 21 22 | r = 3.141593 # FURB152 22 23 | -FURB152.py:21:5: FURB152 [*] Replace `3.141593` with `math.pi` +FURB152 [*] Replace `3.141593` with `math.pi` + --> FURB152.py:21:5 | 19 | r = 3.141592 # FURB152 20 | 21 | r = 3.141593 # FURB152 - | ^^^^^^^^ FURB152 + | ^^^^^^^^ 22 | 23 | r = 3.14159265 # FURB152 | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -226,16 +235,17 @@ FURB152.py:21:5: FURB152 [*] Replace `3.141593` with `math.pi` 23 24 | r = 3.14159265 # FURB152 24 25 | -FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` +FURB152 [*] Replace `3.14159265` with `math.pi` + --> FURB152.py:23:5 | 21 | r = 3.141593 # FURB152 22 | 23 | r = 3.14159265 # FURB152 - | ^^^^^^^^^^ FURB152 + | ^^^^^^^^^^ 24 | 25 | r = 3.141592653589793238462643383279 # FURB152 | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -252,16 +262,17 @@ FURB152.py:23:5: FURB152 [*] Replace `3.14159265` with `math.pi` 25 26 | r = 3.141592653589793238462643383279 # FURB152 26 27 | -FURB152.py:25:5: FURB152 [*] Replace `3.141592653589793238462643383279` with `math.pi` +FURB152 [*] Replace `3.141592653589793238462643383279` with `math.pi` + --> FURB152.py:25:5 | 23 | r = 3.14159265 # FURB152 24 | 25 | r = 3.141592653589793238462643383279 # FURB152 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB152 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | r = 3.14159266 # OK | - = help: Use `math.pi` +help: Use `math.pi` ℹ Safe fix 1 |+import math @@ -278,16 +289,17 @@ FURB152.py:25:5: FURB152 [*] Replace `3.141592653589793238462643383279` with `ma 27 28 | r = 3.14159266 # OK 28 29 | -FURB152.py:31:5: FURB152 [*] Replace `2.718` with `math.e` +FURB152 [*] Replace `2.718` with `math.e` + --> FURB152.py:31:5 | 29 | e = 2.7 # OK 30 | 31 | e = 2.718 # FURB152 - | ^^^^^ FURB152 + | ^^^^^ 32 | 33 | e = 2.7182 # FURB152 | - = help: Use `math.e` +help: Use `math.e` ℹ Safe fix 1 |+import math @@ -304,16 +316,17 @@ FURB152.py:31:5: FURB152 [*] Replace `2.718` with `math.e` 33 34 | e = 2.7182 # FURB152 34 35 | -FURB152.py:33:5: FURB152 [*] Replace `2.7182` with `math.e` +FURB152 [*] Replace `2.7182` with `math.e` + --> FURB152.py:33:5 | 31 | e = 2.718 # FURB152 32 | 33 | e = 2.7182 # FURB152 - | ^^^^^^ FURB152 + | ^^^^^^ 34 | 35 | e = 2.7183 # FURB152 | - = help: Use `math.e` +help: Use `math.e` ℹ Safe fix 1 |+import math @@ -330,16 +343,17 @@ FURB152.py:33:5: FURB152 [*] Replace `2.7182` with `math.e` 35 36 | e = 2.7183 # FURB152 36 37 | -FURB152.py:35:5: FURB152 [*] Replace `2.7183` with `math.e` +FURB152 [*] Replace `2.7183` with `math.e` + --> FURB152.py:35:5 | 33 | e = 2.7182 # FURB152 34 | 35 | e = 2.7183 # FURB152 - | ^^^^^^ FURB152 + | ^^^^^^ 36 | 37 | e = 2.719 # OK | - = help: Use `math.e` +help: Use `math.e` ℹ Safe fix 1 |+import math @@ -356,14 +370,15 @@ FURB152.py:35:5: FURB152 [*] Replace `2.7183` with `math.e` 37 38 | e = 2.719 # OK 38 39 | -FURB152.py:45:5: FURB152 [*] Replace `2.7182000000000001` with `math.e` +FURB152 [*] Replace `2.7182000000000001` with `math.e` + --> FURB152.py:45:5 | 43 | e = 2.718200000000001 # OK 44 | 45 | e = 2.7182000000000001 # FURB152 - | ^^^^^^^^^^^^^^^^^^ FURB152 + | ^^^^^^^^^^^^^^^^^^ | - = help: Use `math.e` +help: Use `math.e` ℹ Safe fix 1 |+import math diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap index cb55d4165e..31a980d84d 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB154_FURB154.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB154.py:4:5: FURB154 [*] Use of repeated consecutive `global` +FURB154 [*] Use of repeated consecutive `global` + --> FURB154.py:4:5 | 3 | def f1(): 4 | / global x 5 | | global y - | |____________^ FURB154 + | |____________^ | - = help: Merge `global` statements +help: Merge `global` statements ℹ Safe fix 1 1 | # Errors @@ -21,15 +22,16 @@ FURB154.py:4:5: FURB154 [*] Use of repeated consecutive `global` 7 6 | 8 7 | def f3(): -FURB154.py:9:5: FURB154 [*] Use of repeated consecutive `global` +FURB154 [*] Use of repeated consecutive `global` + --> FURB154.py:9:5 | 8 | def f3(): 9 | / global x 10 | | global y 11 | | global z - | |____________^ FURB154 + | |____________^ | - = help: Merge `global` statements +help: Merge `global` statements ℹ Safe fix 6 6 | @@ -43,16 +45,17 @@ FURB154.py:9:5: FURB154 [*] Use of repeated consecutive `global` 13 11 | 14 12 | def f4(): -FURB154.py:15:5: FURB154 [*] Use of repeated consecutive `global` +FURB154 [*] Use of repeated consecutive `global` + --> FURB154.py:15:5 | 14 | def f4(): 15 | / global x 16 | | global y - | |____________^ FURB154 + | |____________^ 17 | pass 18 | global x | - = help: Merge `global` statements +help: Merge `global` statements ℹ Safe fix 12 12 | @@ -65,15 +68,16 @@ FURB154.py:15:5: FURB154 [*] Use of repeated consecutive `global` 18 17 | global x 19 18 | global y -FURB154.py:18:5: FURB154 [*] Use of repeated consecutive `global` +FURB154 [*] Use of repeated consecutive `global` + --> FURB154.py:18:5 | 16 | global y 17 | pass 18 | / global x 19 | | global y - | |____________^ FURB154 + | |____________^ | - = help: Merge `global` statements +help: Merge `global` statements ℹ Safe fix 15 15 | global x @@ -86,16 +90,17 @@ FURB154.py:18:5: FURB154 [*] Use of repeated consecutive `global` 21 20 | 22 21 | def f2(): -FURB154.py:26:9: FURB154 [*] Use of repeated consecutive `nonlocal` +FURB154 [*] Use of repeated consecutive `nonlocal` + --> FURB154.py:26:9 | 25 | def inner(): 26 | / nonlocal x 27 | | nonlocal y - | |__________________^ FURB154 + | |__________________^ 28 | 29 | def inner2(): | - = help: Merge `nonlocal` statements +help: Merge `nonlocal` statements ℹ Safe fix 23 23 | x = y = z = 1 @@ -108,17 +113,18 @@ FURB154.py:26:9: FURB154 [*] Use of repeated consecutive `nonlocal` 29 28 | def inner2(): 30 29 | nonlocal x -FURB154.py:30:9: FURB154 [*] Use of repeated consecutive `nonlocal` +FURB154 [*] Use of repeated consecutive `nonlocal` + --> FURB154.py:30:9 | 29 | def inner2(): 30 | / nonlocal x 31 | | nonlocal y 32 | | nonlocal z - | |__________________^ FURB154 + | |__________________^ 33 | 34 | def inner3(): | - = help: Merge `nonlocal` statements +help: Merge `nonlocal` statements ℹ Safe fix 27 27 | nonlocal y @@ -132,16 +138,17 @@ FURB154.py:30:9: FURB154 [*] Use of repeated consecutive `nonlocal` 34 32 | def inner3(): 35 33 | nonlocal x -FURB154.py:35:9: FURB154 [*] Use of repeated consecutive `nonlocal` +FURB154 [*] Use of repeated consecutive `nonlocal` + --> FURB154.py:35:9 | 34 | def inner3(): 35 | / nonlocal x 36 | | nonlocal y - | |__________________^ FURB154 + | |__________________^ 37 | pass 38 | nonlocal x | - = help: Merge `nonlocal` statements +help: Merge `nonlocal` statements ℹ Safe fix 32 32 | nonlocal z @@ -154,15 +161,16 @@ FURB154.py:35:9: FURB154 [*] Use of repeated consecutive `nonlocal` 38 37 | nonlocal x 39 38 | nonlocal y -FURB154.py:38:9: FURB154 [*] Use of repeated consecutive `nonlocal` +FURB154 [*] Use of repeated consecutive `nonlocal` + --> FURB154.py:38:9 | 36 | nonlocal y 37 | pass 38 | / nonlocal x 39 | | nonlocal y - | |__________________^ FURB154 + | |__________________^ | - = help: Merge `nonlocal` statements +help: Merge `nonlocal` statements ℹ Safe fix 35 35 | nonlocal x @@ -175,16 +183,17 @@ FURB154.py:38:9: FURB154 [*] Use of repeated consecutive `nonlocal` 41 40 | 42 41 | def f5(): -FURB154.py:46:9: FURB154 [*] Use of repeated consecutive `global` +FURB154 [*] Use of repeated consecutive `global` + --> FURB154.py:46:9 | 45 | def inner(): 46 | / global w 47 | | global x - | |________________^ FURB154 + | |________________^ 48 | nonlocal y 49 | nonlocal z | - = help: Merge `global` statements +help: Merge `global` statements ℹ Safe fix 43 43 | w = x = y = z = 1 @@ -197,17 +206,18 @@ FURB154.py:46:9: FURB154 [*] Use of repeated consecutive `global` 49 48 | nonlocal z 50 49 | -FURB154.py:48:9: FURB154 [*] Use of repeated consecutive `nonlocal` +FURB154 [*] Use of repeated consecutive `nonlocal` + --> FURB154.py:48:9 | 46 | global w 47 | global x 48 | / nonlocal y 49 | | nonlocal z - | |__________________^ FURB154 + | |__________________^ 50 | 51 | def inner2(): | - = help: Merge `nonlocal` statements +help: Merge `nonlocal` statements ℹ Safe fix 45 45 | def inner(): @@ -220,15 +230,16 @@ FURB154.py:48:9: FURB154 [*] Use of repeated consecutive `nonlocal` 51 50 | def inner2(): 52 51 | global x -FURB154.py:53:9: FURB154 [*] Use of repeated consecutive `nonlocal` +FURB154 [*] Use of repeated consecutive `nonlocal` + --> FURB154.py:53:9 | 51 | def inner2(): 52 | global x 53 | / nonlocal y 54 | | nonlocal z - | |__________________^ FURB154 + | |__________________^ | - = help: Merge `nonlocal` statements +help: Merge `nonlocal` statements ℹ Safe fix 50 50 | @@ -241,15 +252,16 @@ FURB154.py:53:9: FURB154 [*] Use of repeated consecutive `nonlocal` 56 55 | 57 56 | def f6(): -FURB154.py:58:5: FURB154 [*] Use of repeated consecutive `global` +FURB154 [*] Use of repeated consecutive `global` + --> FURB154.py:58:5 | 57 | def f6(): 58 | / global x, y, z 59 | | global a, b, c 60 | | global d, e, f - | |__________________^ FURB154 + | |__________________^ | - = help: Merge `global` statements +help: Merge `global` statements ℹ Safe fix 55 55 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB156_FURB156.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB156_FURB156.py.snap index 2041d7694f..110c33052e 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB156_FURB156.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB156_FURB156.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB156.py:3:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:3:5 | 1 | # Errors 2 | 3 | _ = "0123456789" - | ^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^ 4 | _ = "01234567" 5 | _ = "0123456789abcdefABCDEF" | - = help: Replace hardcoded charset with `string.digits` +help: Replace hardcoded charset with `string.digits` ℹ Safe fix 1 1 | # Errors @@ -22,15 +23,16 @@ FURB156.py:3:5: FURB156 [*] Use of hardcoded string charset 5 6 | _ = "0123456789abcdefABCDEF" 6 7 | _ = "abcdefghijklmnopqrstuvwxyz" -FURB156.py:4:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:4:5 | 3 | _ = "0123456789" 4 | _ = "01234567" - | ^^^^^^^^^^ FURB156 + | ^^^^^^^^^^ 5 | _ = "0123456789abcdefABCDEF" 6 | _ = "abcdefghijklmnopqrstuvwxyz" | - = help: Replace hardcoded charset with `string.octdigits` +help: Replace hardcoded charset with `string.octdigits` ℹ Safe fix 1 1 | # Errors @@ -43,16 +45,17 @@ FURB156.py:4:5: FURB156 [*] Use of hardcoded string charset 6 7 | _ = "abcdefghijklmnopqrstuvwxyz" 7 8 | _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -FURB156.py:5:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:5:5 | 3 | _ = "0123456789" 4 | _ = "01234567" 5 | _ = "0123456789abcdefABCDEF" - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 6 | _ = "abcdefghijklmnopqrstuvwxyz" 7 | _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | - = help: Replace hardcoded charset with `string.hexdigits` +help: Replace hardcoded charset with `string.hexdigits` ℹ Safe fix 1 1 | # Errors @@ -66,16 +69,17 @@ FURB156.py:5:5: FURB156 [*] Use of hardcoded string charset 7 8 | _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 8 9 | _ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" -FURB156.py:6:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:6:5 | 4 | _ = "01234567" 5 | _ = "0123456789abcdefABCDEF" 6 | _ = "abcdefghijklmnopqrstuvwxyz" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 8 | _ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | - = help: Replace hardcoded charset with `string.ascii_lowercase` +help: Replace hardcoded charset with `string.ascii_lowercase` ℹ Safe fix 1 1 | # Errors @@ -90,16 +94,17 @@ FURB156.py:6:5: FURB156 [*] Use of hardcoded string charset 8 9 | _ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 9 10 | _ = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" -FURB156.py:7:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:7:5 | 5 | _ = "0123456789abcdefABCDEF" 6 | _ = "abcdefghijklmnopqrstuvwxyz" 7 | _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | _ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 9 | _ = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" | - = help: Replace hardcoded charset with `string.ascii_uppercase` +help: Replace hardcoded charset with `string.ascii_uppercase` ℹ Safe fix 1 1 | # Errors @@ -115,16 +120,17 @@ FURB156.py:7:5: FURB156 [*] Use of hardcoded string charset 9 10 | _ = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" 10 11 | _ = " \t\n\r\v\f" -FURB156.py:8:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:8:5 | 6 | _ = "abcdefghijklmnopqrstuvwxyz" 7 | _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 8 | _ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | _ = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" 10 | _ = " \t\n\r\v\f" | - = help: Replace hardcoded charset with `string.ascii_letters` +help: Replace hardcoded charset with `string.ascii_letters` ℹ Safe fix 1 1 | # Errors @@ -141,15 +147,16 @@ FURB156.py:8:5: FURB156 [*] Use of hardcoded string charset 10 11 | _ = " \t\n\r\v\f" 11 12 | -FURB156.py:9:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:9:5 | 7 | _ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 8 | _ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 9 | _ = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | _ = " \t\n\r\v\f" | - = help: Replace hardcoded charset with `string.punctuation` +help: Replace hardcoded charset with `string.punctuation` ℹ Safe fix 1 1 | # Errors @@ -167,16 +174,17 @@ FURB156.py:9:5: FURB156 [*] Use of hardcoded string charset 11 12 | 12 13 | _ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' -FURB156.py:10:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:10:5 | 8 | _ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 9 | _ = r"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" 10 | _ = " \t\n\r\v\f" - | ^^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^^ 11 | 12 | _ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' | - = help: Replace hardcoded charset with `string.whitespace` +help: Replace hardcoded charset with `string.whitespace` ℹ Safe fix 1 1 | # Errors @@ -194,16 +202,17 @@ FURB156.py:10:5: FURB156 [*] Use of hardcoded string charset 12 13 | _ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' 13 14 | _ = ( -FURB156.py:12:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:12:5 | 10 | _ = " \t\n\r\v\f" 11 | 12 | _ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | _ = ( 14 | '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&' | - = help: Replace hardcoded charset with `string.printable` +help: Replace hardcoded charset with `string.printable` ℹ Safe fix 1 1 | # Errors @@ -221,17 +230,18 @@ FURB156.py:12:5: FURB156 [*] Use of hardcoded string charset 14 15 | '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&' 15 16 | "'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c" -FURB156.py:14:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:14:5 | 12 | _ = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c' 13 | _ = ( 14 | / '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&' 15 | | "'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c" - | |________________________________________________^ FURB156 + | |________________________________________________^ 16 | ) 17 | _ = id("0123" | - = help: Replace hardcoded charset with `string.printable` +help: Replace hardcoded charset with `string.printable` ℹ Safe fix 1 1 | # Errors @@ -250,7 +260,8 @@ FURB156.py:14:5: FURB156 [*] Use of hardcoded string charset 17 17 | _ = id("0123" 18 18 | "4567" -FURB156.py:17:8: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:17:8 | 15 | "'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c" 16 | ) @@ -258,11 +269,11 @@ FURB156.py:17:8: FURB156 [*] Use of hardcoded string charset | ________^ 18 | | "4567" 19 | | "89") - | |___________^ FURB156 + | |___________^ 20 | 21 | _ = ( | - = help: Replace hardcoded charset with `string.digits` +help: Replace hardcoded charset with `string.digits` ℹ Safe fix 1 1 | # Errors @@ -282,14 +293,15 @@ FURB156.py:17:8: FURB156 [*] Use of hardcoded string charset 21 20 | _ = ( 22 21 | "0123456789" -FURB156.py:22:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:22:5 | 21 | _ = ( 22 | "0123456789" - | ^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^ 23 | ).capitalize() | - = help: Replace hardcoded charset with `string.digits` +help: Replace hardcoded charset with `string.digits` ℹ Safe fix 1 1 | # Errors @@ -307,15 +319,16 @@ FURB156.py:22:5: FURB156 [*] Use of hardcoded string charset 24 25 | 25 26 | _ = ( -FURB156.py:26:5: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:26:5 | 25 | _ = ( 26 | "0123456789" - | ^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^ 27 | # with comment 28 | ).capitalize() | - = help: Replace hardcoded charset with `string.digits` +help: Replace hardcoded charset with `string.digits` ℹ Safe fix 1 1 | # Errors @@ -333,15 +346,16 @@ FURB156.py:26:5: FURB156 [*] Use of hardcoded string charset 28 29 | ).capitalize() 29 30 | -FURB156.py:31:6: FURB156 [*] Use of hardcoded string charset +FURB156 [*] Use of hardcoded string charset + --> FURB156.py:31:6 | 30 | # example with augmented assignment 31 | _ += "0123456789" - | ^^^^^^^^^^^^ FURB156 + | ^^^^^^^^^^^^ 32 | 33 | # OK | - = help: Replace hardcoded charset with `string.digits` +help: Replace hardcoded charset with `string.digits` ℹ Safe fix 1 1 | # Errors diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap index fec07e7943..8b422fc66a 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB157_FURB157.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB157.py:5:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:5:9 | 4 | # Errors 5 | Decimal("0") - | ^^^ FURB157 + | ^^^ 6 | Decimal("-42") 7 | Decimal(float("Infinity")) | - = help: Replace with `0` +help: Replace with `0` ℹ Safe fix 2 2 | from decimal import Decimal @@ -21,16 +22,17 @@ FURB157.py:5:9: FURB157 [*] Verbose expression in `Decimal` constructor 7 7 | Decimal(float("Infinity")) 8 8 | Decimal(float("-Infinity")) -FURB157.py:6:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:6:9 | 4 | # Errors 5 | Decimal("0") 6 | Decimal("-42") - | ^^^^^ FURB157 + | ^^^^^ 7 | Decimal(float("Infinity")) 8 | Decimal(float("-Infinity")) | - = help: Replace with `-42` +help: Replace with `-42` ℹ Safe fix 3 3 | @@ -42,16 +44,17 @@ FURB157.py:6:9: FURB157 [*] Verbose expression in `Decimal` constructor 8 8 | Decimal(float("-Infinity")) 9 9 | Decimal(float("inf")) -FURB157.py:7:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:7:9 | 5 | Decimal("0") 6 | Decimal("-42") 7 | Decimal(float("Infinity")) - | ^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^ 8 | Decimal(float("-Infinity")) 9 | Decimal(float("inf")) | - = help: Replace with `"Infinity"` +help: Replace with `"Infinity"` ℹ Safe fix 4 4 | # Errors @@ -63,16 +66,17 @@ FURB157.py:7:9: FURB157 [*] Verbose expression in `Decimal` constructor 9 9 | Decimal(float("inf")) 10 10 | Decimal(float("-inf")) -FURB157.py:8:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:8:9 | 6 | Decimal("-42") 7 | Decimal(float("Infinity")) 8 | Decimal(float("-Infinity")) - | ^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^ 9 | Decimal(float("inf")) 10 | Decimal(float("-inf")) | - = help: Replace with `"-Infinity"` +help: Replace with `"-Infinity"` ℹ Safe fix 5 5 | Decimal("0") @@ -84,16 +88,17 @@ FURB157.py:8:9: FURB157 [*] Verbose expression in `Decimal` constructor 10 10 | Decimal(float("-inf")) 11 11 | Decimal(float("nan")) -FURB157.py:9:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:9:9 | 7 | Decimal(float("Infinity")) 8 | Decimal(float("-Infinity")) 9 | Decimal(float("inf")) - | ^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^ 10 | Decimal(float("-inf")) 11 | Decimal(float("nan")) | - = help: Replace with `"inf"` +help: Replace with `"inf"` ℹ Safe fix 6 6 | Decimal("-42") @@ -105,16 +110,17 @@ FURB157.py:9:9: FURB157 [*] Verbose expression in `Decimal` constructor 11 11 | Decimal(float("nan")) 12 12 | decimal.Decimal("0") -FURB157.py:10:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:10:9 | 8 | Decimal(float("-Infinity")) 9 | Decimal(float("inf")) 10 | Decimal(float("-inf")) - | ^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^ 11 | Decimal(float("nan")) 12 | decimal.Decimal("0") | - = help: Replace with `"-inf"` +help: Replace with `"-inf"` ℹ Safe fix 7 7 | Decimal(float("Infinity")) @@ -126,15 +132,16 @@ FURB157.py:10:9: FURB157 [*] Verbose expression in `Decimal` constructor 12 12 | decimal.Decimal("0") 13 13 | -FURB157.py:11:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:11:9 | 9 | Decimal(float("inf")) 10 | Decimal(float("-inf")) 11 | Decimal(float("nan")) - | ^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^ 12 | decimal.Decimal("0") | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 8 8 | Decimal(float("-Infinity")) @@ -146,16 +153,17 @@ FURB157.py:11:9: FURB157 [*] Verbose expression in `Decimal` constructor 13 13 | 14 14 | # OK -FURB157.py:12:17: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:12:17 | 10 | Decimal(float("-inf")) 11 | Decimal(float("nan")) 12 | decimal.Decimal("0") - | ^^^ FURB157 + | ^^^ 13 | 14 | # OK | - = help: Replace with `0` +help: Replace with `0` ℹ Safe fix 9 9 | Decimal(float("inf")) @@ -167,14 +175,15 @@ FURB157.py:12:17: FURB157 [*] Verbose expression in `Decimal` constructor 14 14 | # OK 15 15 | Decimal(0) -FURB157.py:23:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:23:9 | 22 | # Errors 23 | Decimal("1_000") - | ^^^^^^^ FURB157 + | ^^^^^^^ 24 | Decimal("__1____000") | - = help: Replace with `1000` +help: Replace with `1000` ℹ Safe fix 20 20 | # See https://github.com/astral-sh/ruff/issues/13807 @@ -186,16 +195,17 @@ FURB157.py:23:9: FURB157 [*] Verbose expression in `Decimal` constructor 25 25 | 26 26 | # Ok -FURB157.py:24:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:24:9 | 22 | # Errors 23 | Decimal("1_000") 24 | Decimal("__1____000") - | ^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^ 25 | 26 | # Ok | - = help: Replace with `1000` +help: Replace with `1000` ℹ Safe fix 21 21 | @@ -207,16 +217,17 @@ FURB157.py:24:9: FURB157 [*] Verbose expression in `Decimal` constructor 26 26 | # Ok 27 27 | Decimal("2e-4") -FURB157.py:48:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:48:9 | 46 | # Non-finite variants 47 | # https://github.com/astral-sh/ruff/issues/14587 48 | Decimal(float(" nan ")) # Decimal(" nan ") - | ^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^ 49 | Decimal(float(" +nan ")) # Decimal(" +nan ") 50 | # In this one case, " -nan ", the fix has to be | - = help: Replace with `" nan "` +help: Replace with `" nan "` ℹ Safe fix 45 45 | @@ -228,16 +239,17 @@ FURB157.py:48:9: FURB157 [*] Verbose expression in `Decimal` constructor 50 50 | # In this one case, " -nan ", the fix has to be 51 51 | # `Decimal(" nan ")`` because `Decimal("-nan") != Decimal(float("-nan"))` -FURB157.py:49:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:49:9 | 47 | # https://github.com/astral-sh/ruff/issues/14587 48 | Decimal(float(" nan ")) # Decimal(" nan ") 49 | Decimal(float(" +nan ")) # Decimal(" +nan ") - | ^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^ 50 | # In this one case, " -nan ", the fix has to be 51 | # `Decimal(" nan ")`` because `Decimal("-nan") != Decimal(float("-nan"))` | - = help: Replace with `" +nan "` +help: Replace with `" +nan "` ℹ Safe fix 46 46 | # Non-finite variants @@ -249,16 +261,17 @@ FURB157.py:49:9: FURB157 [*] Verbose expression in `Decimal` constructor 51 51 | # `Decimal(" nan ")`` because `Decimal("-nan") != Decimal(float("-nan"))` 52 52 | Decimal(float(" -nan ")) # Decimal("nan") -FURB157.py:52:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:52:9 | 50 | # In this one case, " -nan ", the fix has to be 51 | # `Decimal(" nan ")`` because `Decimal("-nan") != Decimal(float("-nan"))` 52 | Decimal(float(" -nan ")) # Decimal("nan") - | ^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^ 53 | Decimal(float(" inf ")) # Decimal(" inf ") 54 | Decimal(float(" +inf ")) # Decimal(" +inf ") | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 49 49 | Decimal(float(" +nan ")) # Decimal(" +nan ") @@ -270,16 +283,17 @@ FURB157.py:52:9: FURB157 [*] Verbose expression in `Decimal` constructor 54 54 | Decimal(float(" +inf ")) # Decimal(" +inf ") 55 55 | Decimal(float(" -inf ")) # Decimal(" -inf ") -FURB157.py:53:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:53:9 | 51 | # `Decimal(" nan ")`` because `Decimal("-nan") != Decimal(float("-nan"))` 52 | Decimal(float(" -nan ")) # Decimal("nan") 53 | Decimal(float(" inf ")) # Decimal(" inf ") - | ^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^ 54 | Decimal(float(" +inf ")) # Decimal(" +inf ") 55 | Decimal(float(" -inf ")) # Decimal(" -inf ") | - = help: Replace with `" inf "` +help: Replace with `" inf "` ℹ Safe fix 50 50 | # In this one case, " -nan ", the fix has to be @@ -291,16 +305,17 @@ FURB157.py:53:9: FURB157 [*] Verbose expression in `Decimal` constructor 55 55 | Decimal(float(" -inf ")) # Decimal(" -inf ") 56 56 | Decimal(float(" infinity ")) # Decimal(" infinity ") -FURB157.py:54:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:54:9 | 52 | Decimal(float(" -nan ")) # Decimal("nan") 53 | Decimal(float(" inf ")) # Decimal(" inf ") 54 | Decimal(float(" +inf ")) # Decimal(" +inf ") - | ^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^ 55 | Decimal(float(" -inf ")) # Decimal(" -inf ") 56 | Decimal(float(" infinity ")) # Decimal(" infinity ") | - = help: Replace with `" +inf "` +help: Replace with `" +inf "` ℹ Safe fix 51 51 | # `Decimal(" nan ")`` because `Decimal("-nan") != Decimal(float("-nan"))` @@ -312,16 +327,17 @@ FURB157.py:54:9: FURB157 [*] Verbose expression in `Decimal` constructor 56 56 | Decimal(float(" infinity ")) # Decimal(" infinity ") 57 57 | Decimal(float(" +infinity ")) # Decimal(" +infinity ") -FURB157.py:55:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:55:9 | 53 | Decimal(float(" inf ")) # Decimal(" inf ") 54 | Decimal(float(" +inf ")) # Decimal(" +inf ") 55 | Decimal(float(" -inf ")) # Decimal(" -inf ") - | ^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^ 56 | Decimal(float(" infinity ")) # Decimal(" infinity ") 57 | Decimal(float(" +infinity ")) # Decimal(" +infinity ") | - = help: Replace with `" -inf "` +help: Replace with `" -inf "` ℹ Safe fix 52 52 | Decimal(float(" -nan ")) # Decimal("nan") @@ -333,16 +349,17 @@ FURB157.py:55:9: FURB157 [*] Verbose expression in `Decimal` constructor 57 57 | Decimal(float(" +infinity ")) # Decimal(" +infinity ") 58 58 | Decimal(float(" -infinity ")) # Decimal(" -infinity ") -FURB157.py:56:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:56:9 | 54 | Decimal(float(" +inf ")) # Decimal(" +inf ") 55 | Decimal(float(" -inf ")) # Decimal(" -inf ") 56 | Decimal(float(" infinity ")) # Decimal(" infinity ") - | ^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^ 57 | Decimal(float(" +infinity ")) # Decimal(" +infinity ") 58 | Decimal(float(" -infinity ")) # Decimal(" -infinity ") | - = help: Replace with `" infinity "` +help: Replace with `" infinity "` ℹ Safe fix 53 53 | Decimal(float(" inf ")) # Decimal(" inf ") @@ -354,15 +371,16 @@ FURB157.py:56:9: FURB157 [*] Verbose expression in `Decimal` constructor 58 58 | Decimal(float(" -infinity ")) # Decimal(" -infinity ") 59 59 | -FURB157.py:57:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:57:9 | 55 | Decimal(float(" -inf ")) # Decimal(" -inf ") 56 | Decimal(float(" infinity ")) # Decimal(" infinity ") 57 | Decimal(float(" +infinity ")) # Decimal(" +infinity ") - | ^^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^^ 58 | Decimal(float(" -infinity ")) # Decimal(" -infinity ") | - = help: Replace with `" +infinity "` +help: Replace with `" +infinity "` ℹ Safe fix 54 54 | Decimal(float(" +inf ")) # Decimal(" +inf ") @@ -374,16 +392,17 @@ FURB157.py:57:9: FURB157 [*] Verbose expression in `Decimal` constructor 59 59 | 60 60 | # Escape sequence handling in "-nan" case -FURB157.py:58:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:58:9 | 56 | Decimal(float(" infinity ")) # Decimal(" infinity ") 57 | Decimal(float(" +infinity ")) # Decimal(" +infinity ") 58 | Decimal(float(" -infinity ")) # Decimal(" -infinity ") - | ^^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^^ 59 | 60 | # Escape sequence handling in "-nan" case | - = help: Replace with `" -infinity "` +help: Replace with `" -infinity "` ℹ Safe fix 55 55 | Decimal(float(" -inf ")) # Decimal(" -inf ") @@ -395,16 +414,17 @@ FURB157.py:58:9: FURB157 [*] Verbose expression in `Decimal` constructor 60 60 | # Escape sequence handling in "-nan" case 61 61 | # Here we do not bother respecting the original whitespace -FURB157.py:64:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:64:9 | 62 | # and other trivia when offering a fix. 63 | # https://github.com/astral-sh/ruff/issues/16771 64 | Decimal(float("\x2dnan")) - | ^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^ 65 | Decimal(float("\x20\x2dnan")) 66 | Decimal(float("\x20\u002dnan")) | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 61 61 | # Here we do not bother respecting the original whitespace @@ -416,16 +436,17 @@ FURB157.py:64:9: FURB157 [*] Verbose expression in `Decimal` constructor 66 66 | Decimal(float("\x20\u002dnan")) 67 67 | Decimal(float("\x20\U0000002dnan")) -FURB157.py:65:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:65:9 | 63 | # https://github.com/astral-sh/ruff/issues/16771 64 | Decimal(float("\x2dnan")) 65 | Decimal(float("\x20\x2dnan")) - | ^^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^^ 66 | Decimal(float("\x20\u002dnan")) 67 | Decimal(float("\x20\U0000002dnan")) | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 62 62 | # and other trivia when offering a fix. @@ -437,16 +458,17 @@ FURB157.py:65:9: FURB157 [*] Verbose expression in `Decimal` constructor 67 67 | Decimal(float("\x20\U0000002dnan")) 68 68 | Decimal(float("\N{space}\N{hyPHen-MINus}nan")) -FURB157.py:66:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:66:9 | 64 | Decimal(float("\x2dnan")) 65 | Decimal(float("\x20\x2dnan")) 66 | Decimal(float("\x20\u002dnan")) - | ^^^^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^^^^ 67 | Decimal(float("\x20\U0000002dnan")) 68 | Decimal(float("\N{space}\N{hyPHen-MINus}nan")) | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 63 63 | # https://github.com/astral-sh/ruff/issues/16771 @@ -458,16 +480,17 @@ FURB157.py:66:9: FURB157 [*] Verbose expression in `Decimal` constructor 68 68 | Decimal(float("\N{space}\N{hyPHen-MINus}nan")) 69 69 | Decimal(float("\x20\N{character tabulation}\N{hyphen-minus}nan")) -FURB157.py:67:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:67:9 | 65 | Decimal(float("\x20\x2dnan")) 66 | Decimal(float("\x20\u002dnan")) 67 | Decimal(float("\x20\U0000002dnan")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 68 | Decimal(float("\N{space}\N{hyPHen-MINus}nan")) 69 | Decimal(float("\x20\N{character tabulation}\N{hyphen-minus}nan")) | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 64 64 | Decimal(float("\x2dnan")) @@ -479,16 +502,17 @@ FURB157.py:67:9: FURB157 [*] Verbose expression in `Decimal` constructor 69 69 | Decimal(float("\x20\N{character tabulation}\N{hyphen-minus}nan")) 70 70 | Decimal(float(" -" "nan")) -FURB157.py:68:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:68:9 | 66 | Decimal(float("\x20\u002dnan")) 67 | Decimal(float("\x20\U0000002dnan")) 68 | Decimal(float("\N{space}\N{hyPHen-MINus}nan")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 69 | Decimal(float("\x20\N{character tabulation}\N{hyphen-minus}nan")) 70 | Decimal(float(" -" "nan")) | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 65 65 | Decimal(float("\x20\x2dnan")) @@ -500,16 +524,17 @@ FURB157.py:68:9: FURB157 [*] Verbose expression in `Decimal` constructor 70 70 | Decimal(float(" -" "nan")) 71 71 | Decimal(float("-nAn")) -FURB157.py:69:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:69:9 | 67 | Decimal(float("\x20\U0000002dnan")) 68 | Decimal(float("\N{space}\N{hyPHen-MINus}nan")) 69 | Decimal(float("\x20\N{character tabulation}\N{hyphen-minus}nan")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | Decimal(float(" -" "nan")) 71 | Decimal(float("-nAn")) | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 66 66 | Decimal(float("\x20\u002dnan")) @@ -520,15 +545,16 @@ FURB157.py:69:9: FURB157 [*] Verbose expression in `Decimal` constructor 70 70 | Decimal(float(" -" "nan")) 71 71 | Decimal(float("-nAn")) -FURB157.py:70:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:70:9 | 68 | Decimal(float("\N{space}\N{hyPHen-MINus}nan")) 69 | Decimal(float("\x20\N{character tabulation}\N{hyphen-minus}nan")) 70 | Decimal(float(" -" "nan")) - | ^^^^^^^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^^^^^^^ 71 | Decimal(float("-nAn")) | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 67 67 | Decimal(float("\x20\U0000002dnan")) @@ -538,14 +564,15 @@ FURB157.py:70:9: FURB157 [*] Verbose expression in `Decimal` constructor 70 |+Decimal("nan") 71 71 | Decimal(float("-nAn")) -FURB157.py:71:9: FURB157 [*] Verbose expression in `Decimal` constructor +FURB157 [*] Verbose expression in `Decimal` constructor + --> FURB157.py:71:9 | 69 | Decimal(float("\x20\N{character tabulation}\N{hyphen-minus}nan")) 70 | Decimal(float(" -" "nan")) 71 | Decimal(float("-nAn")) - | ^^^^^^^^^^^^^ FURB157 + | ^^^^^^^^^^^^^ | - = help: Replace with `"nan"` +help: Replace with `"nan"` ℹ Safe fix 68 68 | Decimal(float("\N{space}\N{hyPHen-MINus}nan")) diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap index 2bff822228..8c499ed411 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB161_FURB161.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB161.py:6:9: FURB161 [*] Use of `bin(x).count('1')` +FURB161 [*] Use of `bin(x).count('1')` + --> FURB161.py:6:9 | 4 | return 10 5 | 6 | count = bin(x).count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^ 7 | count = bin(10).count("1") # FURB161 8 | count = bin(0b1010).count("1") # FURB161 | - = help: Replace with `(x).bit_count()` +help: Replace with `(x).bit_count()` ℹ Unsafe fix 3 3 | def ten() -> int: @@ -22,15 +23,16 @@ FURB161.py:6:9: FURB161 [*] Use of `bin(x).count('1')` 8 8 | count = bin(0b1010).count("1") # FURB161 9 9 | count = bin(0xA).count("1") # FURB161 -FURB161.py:7:9: FURB161 [*] Use of `bin(10).count('1')` +FURB161 [*] Use of `bin(10).count('1')` + --> FURB161.py:7:9 | 6 | count = bin(x).count("1") # FURB161 7 | count = bin(10).count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^ 8 | count = bin(0b1010).count("1") # FURB161 9 | count = bin(0xA).count("1") # FURB161 | - = help: Replace with `(10).bit_count()` +help: Replace with `(10).bit_count()` ℹ Safe fix 4 4 | return 10 @@ -42,16 +44,17 @@ FURB161.py:7:9: FURB161 [*] Use of `bin(10).count('1')` 9 9 | count = bin(0xA).count("1") # FURB161 10 10 | count = bin(0o12).count("1") # FURB161 -FURB161.py:8:9: FURB161 [*] Use of `bin(0b1010).count('1')` +FURB161 [*] Use of `bin(0b1010).count('1')` + --> FURB161.py:8:9 | 6 | count = bin(x).count("1") # FURB161 7 | count = bin(10).count("1") # FURB161 8 | count = bin(0b1010).count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^^^^^ 9 | count = bin(0xA).count("1") # FURB161 10 | count = bin(0o12).count("1") # FURB161 | - = help: Replace with `0b1010.bit_count()` +help: Replace with `0b1010.bit_count()` ℹ Safe fix 5 5 | @@ -63,16 +66,17 @@ FURB161.py:8:9: FURB161 [*] Use of `bin(0b1010).count('1')` 10 10 | count = bin(0o12).count("1") # FURB161 11 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 -FURB161.py:9:9: FURB161 [*] Use of `bin(0xA).count('1')` +FURB161 [*] Use of `bin(0xA).count('1')` + --> FURB161.py:9:9 | 7 | count = bin(10).count("1") # FURB161 8 | count = bin(0b1010).count("1") # FURB161 9 | count = bin(0xA).count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^^ 10 | count = bin(0o12).count("1") # FURB161 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 | - = help: Replace with `0xA.bit_count()` +help: Replace with `0xA.bit_count()` ℹ Safe fix 6 6 | count = bin(x).count("1") # FURB161 @@ -84,16 +88,17 @@ FURB161.py:9:9: FURB161 [*] Use of `bin(0xA).count('1')` 11 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 12 12 | count = bin(ten()).count("1") # FURB161 -FURB161.py:10:9: FURB161 [*] Use of `bin(0o12).count('1')` +FURB161 [*] Use of `bin(0o12).count('1')` + --> FURB161.py:10:9 | 8 | count = bin(0b1010).count("1") # FURB161 9 | count = bin(0xA).count("1") # FURB161 10 | count = bin(0o12).count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^^^ 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 12 | count = bin(ten()).count("1") # FURB161 | - = help: Replace with `0o12.bit_count()` +help: Replace with `0o12.bit_count()` ℹ Safe fix 7 7 | count = bin(10).count("1") # FURB161 @@ -105,16 +110,17 @@ FURB161.py:10:9: FURB161 [*] Use of `bin(0o12).count('1')` 12 12 | count = bin(ten()).count("1") # FURB161 13 13 | count = bin((10)).count("1") # FURB161 -FURB161.py:11:9: FURB161 [*] Use of `bin(0x10 + 0x1000).count('1')` +FURB161 [*] Use of `bin(0x10 + 0x1000).count('1')` + --> FURB161.py:11:9 | 9 | count = bin(0xA).count("1") # FURB161 10 | count = bin(0o12).count("1") # FURB161 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | count = bin(ten()).count("1") # FURB161 13 | count = bin((10)).count("1") # FURB161 | - = help: Replace with `(0x10 + 0x1000).bit_count()` +help: Replace with `(0x10 + 0x1000).bit_count()` ℹ Safe fix 8 8 | count = bin(0b1010).count("1") # FURB161 @@ -126,16 +132,17 @@ FURB161.py:11:9: FURB161 [*] Use of `bin(0x10 + 0x1000).count('1')` 13 13 | count = bin((10)).count("1") # FURB161 14 14 | count = bin("10" "15").count("1") # FURB161 -FURB161.py:12:9: FURB161 [*] Use of `bin(ten()).count('1')` +FURB161 [*] Use of `bin(ten()).count('1')` + --> FURB161.py:12:9 | 10 | count = bin(0o12).count("1") # FURB161 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 12 | count = bin(ten()).count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^^^^ 13 | count = bin((10)).count("1") # FURB161 14 | count = bin("10" "15").count("1") # FURB161 | - = help: Replace with `ten().bit_count()` +help: Replace with `ten().bit_count()` ℹ Unsafe fix 9 9 | count = bin(0xA).count("1") # FURB161 @@ -147,16 +154,17 @@ FURB161.py:12:9: FURB161 [*] Use of `bin(ten()).count('1')` 14 14 | count = bin("10" "15").count("1") # FURB161 15 15 | count = bin("123").count("1") # FURB161 -FURB161.py:13:9: FURB161 [*] Use of `bin(10).count('1')` +FURB161 [*] Use of `bin(10).count('1')` + --> FURB161.py:13:9 | 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 12 | count = bin(ten()).count("1") # FURB161 13 | count = bin((10)).count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^^^ 14 | count = bin("10" "15").count("1") # FURB161 15 | count = bin("123").count("1") # FURB161 | - = help: Replace with `(10).bit_count()` +help: Replace with `(10).bit_count()` ℹ Safe fix 10 10 | count = bin(0o12).count("1") # FURB161 @@ -168,15 +176,16 @@ FURB161.py:13:9: FURB161 [*] Use of `bin(10).count('1')` 15 15 | count = bin("123").count("1") # FURB161 16 16 | -FURB161.py:14:9: FURB161 [*] Use of `bin("10" "15").count('1')` +FURB161 [*] Use of `bin("10" "15").count('1')` + --> FURB161.py:14:9 | 12 | count = bin(ten()).count("1") # FURB161 13 | count = bin((10)).count("1") # FURB161 14 | count = bin("10" "15").count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | count = bin("123").count("1") # FURB161 | - = help: Replace with `("10" "15").bit_count()` +help: Replace with `("10" "15").bit_count()` ℹ Unsafe fix 11 11 | count = bin(0x10 + 0x1000).count("1") # FURB161 @@ -188,16 +197,17 @@ FURB161.py:14:9: FURB161 [*] Use of `bin("10" "15").count('1')` 16 16 | 17 17 | count = x.bit_count() # OK -FURB161.py:15:9: FURB161 [*] Use of `bin("123").count('1')` +FURB161 [*] Use of `bin("123").count('1')` + --> FURB161.py:15:9 | 13 | count = bin((10)).count("1") # FURB161 14 | count = bin("10" "15").count("1") # FURB161 15 | count = bin("123").count("1") # FURB161 - | ^^^^^^^^^^^^^^^^^^^^^ FURB161 + | ^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | count = x.bit_count() # OK | - = help: Replace with `"123".bit_count()` +help: Replace with `"123".bit_count()` ℹ Unsafe fix 12 12 | count = bin(ten()).count("1") # FURB161 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB162_FURB162.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB162_FURB162.py.snap index 43ab280fcf..d34aad2d15 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB162_FURB162.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB162_FURB162.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB162.py:8:24: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:8:24 | 6 | ### Errors 7 | 8 | datetime.fromisoformat(date.replace("Z", "+00:00")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB162 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | datetime.fromisoformat(date.replace("Z", "-00:" "00")) | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 5 5 | @@ -21,15 +22,16 @@ FURB162.py:8:24: FURB162 [*] Unnecessary timezone replacement with zero offset 10 10 | 11 11 | datetime.fromisoformat(date[:-1] + "-00") -FURB162.py:9:24: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:9:24 | 8 | datetime.fromisoformat(date.replace("Z", "+00:00")) 9 | datetime.fromisoformat(date.replace("Z", "-00:" "00")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB162 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | datetime.fromisoformat(date[:-1] + "-00") | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 6 6 | ### Errors @@ -41,15 +43,16 @@ FURB162.py:9:24: FURB162 [*] Unnecessary timezone replacement with zero offset 11 11 | datetime.fromisoformat(date[:-1] + "-00") 12 12 | datetime.fromisoformat(date[:-1:] + "-0000") -FURB162.py:11:24: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:11:24 | 9 | datetime.fromisoformat(date.replace("Z", "-00:" "00")) 10 | 11 | datetime.fromisoformat(date[:-1] + "-00") - | ^^^^^^^^^^^^^^^^^ FURB162 + | ^^^^^^^^^^^^^^^^^ 12 | datetime.fromisoformat(date[:-1:] + "-0000") | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 8 8 | datetime.fromisoformat(date.replace("Z", "+00:00")) @@ -61,15 +64,16 @@ FURB162.py:11:24: FURB162 [*] Unnecessary timezone replacement with zero offset 13 13 | 14 14 | datetime.fromisoformat(date.strip("Z") + """+0""" -FURB162.py:12:24: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:12:24 | 11 | datetime.fromisoformat(date[:-1] + "-00") 12 | datetime.fromisoformat(date[:-1:] + "-0000") - | ^^^^^^^^^^^^^^^^^^^^ FURB162 + | ^^^^^^^^^^^^^^^^^^^^ 13 | 14 | datetime.fromisoformat(date.strip("Z") + """+0""" | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 9 9 | datetime.fromisoformat(date.replace("Z", "-00:" "00")) @@ -81,17 +85,18 @@ FURB162.py:12:24: FURB162 [*] Unnecessary timezone replacement with zero offset 14 14 | datetime.fromisoformat(date.strip("Z") + """+0""" 15 15 | """0""") -FURB162.py:14:24: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:14:24 | 12 | datetime.fromisoformat(date[:-1:] + "-0000") 13 | 14 | datetime.fromisoformat(date.strip("Z") + """+0""" | ________________________^ 15 | | """0""") - | |________________________________________________^ FURB162 + | |________________________________________________^ 16 | datetime.fromisoformat(date.rstrip("Z") + "+\x30\60" '\u0030\N{DIGIT ZERO}') | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 11 11 | datetime.fromisoformat(date[:-1] + "-00") @@ -104,16 +109,17 @@ FURB162.py:14:24: FURB162 [*] Unnecessary timezone replacement with zero offset 17 16 | 18 17 | datetime.fromisoformat( -FURB162.py:16:24: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:16:24 | 14 | datetime.fromisoformat(date.strip("Z") + """+0""" 15 | """0""") 16 | datetime.fromisoformat(date.rstrip("Z") + "+\x30\60" '\u0030\N{DIGIT ZERO}') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB162 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | datetime.fromisoformat( | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 13 13 | @@ -125,17 +131,18 @@ FURB162.py:16:24: FURB162 [*] Unnecessary timezone replacement with zero offset 18 18 | datetime.fromisoformat( 19 19 | # Preserved -FURB162.py:20:5: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:20:5 | 18 | datetime.fromisoformat( 19 | # Preserved 20 | / ( # Preserved 21 | | date 22 | | ).replace("Z", "+00") - | |_________________________^ FURB162 + | |_________________________^ 23 | ) | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 19 19 | # Preserved @@ -147,7 +154,8 @@ FURB162.py:20:5: FURB162 [*] Unnecessary timezone replacement with zero offset 24 24 | 25 25 | datetime.fromisoformat( -FURB162.py:26:5: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:26:5 | 25 | datetime.fromisoformat( 26 | / (date @@ -157,10 +165,10 @@ FURB162.py:26:5: FURB162 [*] Unnecessary timezone replacement with zero offset 30 | | rstrip("Z" 31 | | # Unsafe 32 | | ) + "-00" # Preserved - | |________________________^ FURB162 + | |________________________^ 33 | ) | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 25 25 | datetime.fromisoformat( @@ -176,16 +184,17 @@ FURB162.py:26:5: FURB162 [*] Unnecessary timezone replacement with zero offset 34 30 | 35 31 | datetime.fromisoformat( -FURB162.py:36:5: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:36:5 | 35 | datetime.fromisoformat( 36 | / ( # Preserved 37 | | date 38 | | ).strip("Z") + "+0000" - | |__________________________^ FURB162 + | |__________________________^ 39 | ) | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 35 35 | datetime.fromisoformat( @@ -197,7 +206,8 @@ FURB162.py:36:5: FURB162 [*] Unnecessary timezone replacement with zero offset 40 40 | 41 41 | datetime.fromisoformat( -FURB162.py:42:5: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:42:5 | 41 | datetime.fromisoformat( 42 | / (date @@ -206,10 +216,10 @@ FURB162.py:42:5: FURB162 [*] Unnecessary timezone replacement with zero offset 45 | | [ # Unsafe 46 | | :-1 47 | | ] + "-00" - | |_____________^ FURB162 + | |_____________^ 48 | ) | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 42 42 | (date @@ -222,13 +232,14 @@ FURB162.py:42:5: FURB162 [*] Unnecessary timezone replacement with zero offset 49 46 | 50 47 | -FURB162.py:52:24: FURB162 [*] Unnecessary timezone replacement with zero offset +FURB162 [*] Unnecessary timezone replacement with zero offset + --> FURB162.py:52:24 | 51 | # Edge case 52 | datetime.fromisoformat("Z2025-01-01T00:00:00Z".strip("Z") + "+00:00") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB162 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove `.replace()` call +help: Remove `.replace()` call ℹ Unsafe fix 49 49 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap index 14c40084ba..3966ed43d0 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB163_FURB163.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB163.py:4:1: FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redundant base + --> FURB163.py:4:1 | 3 | # Errors 4 | math.log(1, 2) - | ^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^ 5 | math.log(1, 10) 6 | math.log(1, math.e) | - = help: Replace with `math.log2(1)` +help: Replace with `math.log2(1)` ℹ Unsafe fix 1 1 | import math @@ -21,16 +22,17 @@ FURB163.py:4:1: FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redunda 6 6 | math.log(1, math.e) 7 7 | foo = ... -FURB163.py:5:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base + --> FURB163.py:5:1 | 3 | # Errors 4 | math.log(1, 2) 5 | math.log(1, 10) - | ^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^ 6 | math.log(1, math.e) 7 | foo = ... | - = help: Replace with `math.log10(1)` +help: Replace with `math.log10(1)` ℹ Unsafe fix 2 2 | @@ -42,16 +44,17 @@ FURB163.py:5:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redund 7 7 | foo = ... 8 8 | math.log(foo, 2) -FURB163.py:6:1: FURB163 [*] Prefer `math.log(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log(1)` over `math.log` with a redundant base + --> FURB163.py:6:1 | 4 | math.log(1, 2) 5 | math.log(1, 10) 6 | math.log(1, math.e) - | ^^^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^^^ 7 | foo = ... 8 | math.log(foo, 2) | - = help: Replace with `math.log(1)` +help: Replace with `math.log(1)` ℹ Safe fix 3 3 | # Errors @@ -63,16 +66,17 @@ FURB163.py:6:1: FURB163 [*] Prefer `math.log(1)` over `math.log` with a redundan 8 8 | math.log(foo, 2) 9 9 | math.log(foo, 10) -FURB163.py:8:1: FURB163 [*] Prefer `math.log2(foo)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log2(foo)` over `math.log` with a redundant base + --> FURB163.py:8:1 | 6 | math.log(1, math.e) 7 | foo = ... 8 | math.log(foo, 2) - | ^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^ 9 | math.log(foo, 10) 10 | math.log(foo, math.e) | - = help: Replace with `math.log2(foo)` +help: Replace with `math.log2(foo)` ℹ Unsafe fix 5 5 | math.log(1, 10) @@ -84,16 +88,17 @@ FURB163.py:8:1: FURB163 [*] Prefer `math.log2(foo)` over `math.log` with a redun 10 10 | math.log(foo, math.e) 11 11 | math.log(1, 2.0) -FURB163.py:9:1: FURB163 [*] Prefer `math.log10(foo)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log10(foo)` over `math.log` with a redundant base + --> FURB163.py:9:1 | 7 | foo = ... 8 | math.log(foo, 2) 9 | math.log(foo, 10) - | ^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^ 10 | math.log(foo, math.e) 11 | math.log(1, 2.0) | - = help: Replace with `math.log10(foo)` +help: Replace with `math.log10(foo)` ℹ Unsafe fix 6 6 | math.log(1, math.e) @@ -105,16 +110,17 @@ FURB163.py:9:1: FURB163 [*] Prefer `math.log10(foo)` over `math.log` with a redu 11 11 | math.log(1, 2.0) 12 12 | math.log(1, 10.0) -FURB163.py:10:1: FURB163 [*] Prefer `math.log(foo)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log(foo)` over `math.log` with a redundant base + --> FURB163.py:10:1 | 8 | math.log(foo, 2) 9 | math.log(foo, 10) 10 | math.log(foo, math.e) - | ^^^^^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^^^^^ 11 | math.log(1, 2.0) 12 | math.log(1, 10.0) | - = help: Replace with `math.log(foo)` +help: Replace with `math.log(foo)` ℹ Safe fix 7 7 | foo = ... @@ -126,15 +132,16 @@ FURB163.py:10:1: FURB163 [*] Prefer `math.log(foo)` over `math.log` with a redun 12 12 | math.log(1, 10.0) 13 13 | -FURB163.py:11:1: FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redundant base + --> FURB163.py:11:1 | 9 | math.log(foo, 10) 10 | math.log(foo, math.e) 11 | math.log(1, 2.0) - | ^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^ 12 | math.log(1, 10.0) | - = help: Replace with `math.log2(1)` +help: Replace with `math.log2(1)` ℹ Unsafe fix 8 8 | math.log(foo, 2) @@ -146,16 +153,17 @@ FURB163.py:11:1: FURB163 [*] Prefer `math.log2(1)` over `math.log` with a redund 13 13 | 14 14 | # OK -FURB163.py:12:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base + --> FURB163.py:12:1 | 10 | math.log(foo, math.e) 11 | math.log(1, 2.0) 12 | math.log(1, 10.0) - | ^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^ 13 | 14 | # OK | - = help: Replace with `math.log10(1)` +help: Replace with `math.log10(1)` ℹ Unsafe fix 9 9 | math.log(foo, 10) @@ -167,14 +175,15 @@ FURB163.py:12:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun 14 14 | # OK 15 15 | math.log2(1) -FURB163.py:49:11: FURB163 [*] Prefer `math.log(yield)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log(yield)` over `math.log` with a redundant base + --> FURB163.py:49:11 | 47 | # https://github.com/astral-sh/ruff/issues/18747 48 | def log(): 49 | yield math.log((yield), math.e) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `math.log(yield)` +help: Replace with `math.log(yield)` ℹ Safe fix 46 46 | @@ -186,15 +195,16 @@ FURB163.py:49:11: FURB163 [*] Prefer `math.log(yield)` over `math.log` with a re 51 51 | 52 52 | def log(): -FURB163.py:53:11: FURB163 [*] Prefer `math.log(yield from x)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log(yield from x)` over `math.log` with a redundant base + --> FURB163.py:53:11 | 52 | def log(): 53 | yield math.log((yield from x), math.e) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | 55 | # see: https://github.com/astral-sh/ruff/issues/18639 | - = help: Replace with `math.log(yield from x)` +help: Replace with `math.log(yield from x)` ℹ Safe fix 50 50 | @@ -206,16 +216,17 @@ FURB163.py:53:11: FURB163 [*] Prefer `math.log(yield from x)` over `math.log` wi 55 55 | # see: https://github.com/astral-sh/ruff/issues/18639 56 56 | math.log(1, 10 # comment -FURB163.py:56:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base + --> FURB163.py:56:1 | 55 | # see: https://github.com/astral-sh/ruff/issues/18639 56 | / math.log(1, 10 # comment 57 | | ) - | |__________^ FURB163 + | |__________^ 58 | 59 | math.log(1, | - = help: Replace with `math.log10(1)` +help: Replace with `math.log10(1)` ℹ Unsafe fix 53 53 | yield math.log((yield from x), math.e) @@ -228,18 +239,19 @@ FURB163.py:56:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun 59 58 | math.log(1, 60 59 | 10 # comment -FURB163.py:59:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base + --> FURB163.py:59:1 | 57 | ) 58 | 59 | / math.log(1, 60 | | 10 # comment 61 | | ) - | |__________^ FURB163 + | |__________^ 62 | 63 | math.log(1 # comment | - = help: Replace with `math.log10(1)` +help: Replace with `math.log10(1)` ℹ Unsafe fix 56 56 | math.log(1, 10 # comment @@ -253,7 +265,8 @@ FURB163.py:59:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun 63 61 | math.log(1 # comment 64 62 | , # comment -FURB163.py:63:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base + --> FURB163.py:63:1 | 61 | ) 62 | @@ -261,11 +274,11 @@ FURB163.py:63:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun 64 | | , # comment 65 | | 10 # comment 66 | | ) - | |__________^ FURB163 + | |__________^ 67 | 68 | math.log( | - = help: Replace with `math.log10(1)` +help: Replace with `math.log10(1)` ℹ Unsafe fix 60 60 | 10 # comment @@ -280,7 +293,8 @@ FURB163.py:63:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun 68 65 | math.log( 69 66 | 1 # comment -FURB163.py:68:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redundant base + --> FURB163.py:68:1 | 66 | ) 67 | @@ -289,11 +303,11 @@ FURB163.py:68:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun 70 | | , 71 | | 10 # comment 72 | | ) - | |_^ FURB163 + | |_^ 73 | 74 | math.log(4.13e223, 2) | - = help: Replace with `math.log10(1)` +help: Replace with `math.log10(1)` ℹ Unsafe fix 65 65 | 10 # comment @@ -309,15 +323,16 @@ FURB163.py:68:1: FURB163 [*] Prefer `math.log10(1)` over `math.log` with a redun 74 70 | math.log(4.13e223, 2) 75 71 | math.log(4.14e223, 10) -FURB163.py:74:1: FURB163 [*] Prefer `math.log2(4.13e223)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log2(4.13e223)` over `math.log` with a redundant base + --> FURB163.py:74:1 | 72 | ) 73 | 74 | math.log(4.13e223, 2) - | ^^^^^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^^^^^ 75 | math.log(4.14e223, 10) | - = help: Replace with `math.log2(4.13e223)` +help: Replace with `math.log2(4.13e223)` ℹ Unsafe fix 71 71 | 10 # comment @@ -329,13 +344,14 @@ FURB163.py:74:1: FURB163 [*] Prefer `math.log2(4.13e223)` over `math.log` with a 76 76 | 77 77 | -FURB163.py:75:1: FURB163 [*] Prefer `math.log10(4.14e223)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log10(4.14e223)` over `math.log` with a redundant base + --> FURB163.py:75:1 | 74 | math.log(4.13e223, 2) 75 | math.log(4.14e223, 10) - | ^^^^^^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `math.log10(4.14e223)` +help: Replace with `math.log10(4.14e223)` ℹ Unsafe fix 72 72 | ) @@ -347,16 +363,17 @@ FURB163.py:75:1: FURB163 [*] Prefer `math.log10(4.14e223)` over `math.log` with 77 77 | 78 78 | def print_log(*args): -FURB163.py:80:15: FURB163 [*] Prefer `math.log(*args)` over `math.log` with a redundant base +FURB163 [*] Prefer `math.log(*args)` over `math.log` with a redundant base + --> FURB163.py:80:15 | 78 | def print_log(*args): 79 | try: 80 | print(math.log(*args, math.e)) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB163 + | ^^^^^^^^^^^^^^^^^^^^^^^ 81 | except TypeError as e: 82 | print(repr(e)) | - = help: Replace with `math.log(*args)` +help: Replace with `math.log(*args)` ℹ Unsafe fix 77 77 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap index c667687090..2d866ca424 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB164_FURB164.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB164.py:7:5: FURB164 [*] Verbose method `from_float` in `Fraction` construction +FURB164 [*] Verbose method `from_float` in `Fraction` construction + --> FURB164.py:7:5 | 6 | # Errors 7 | _ = Fraction.from_float(0.1) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 8 | _ = Fraction.from_float(-0.5) 9 | _ = Fraction.from_float(5.0) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Safe fix 4 4 | import fractions @@ -21,16 +22,17 @@ FURB164.py:7:5: FURB164 [*] Verbose method `from_float` in `Fraction` constructi 9 9 | _ = Fraction.from_float(5.0) 10 10 | _ = fractions.Fraction.from_float(4.2) -FURB164.py:8:5: FURB164 [*] Verbose method `from_float` in `Fraction` construction +FURB164 [*] Verbose method `from_float` in `Fraction` construction + --> FURB164.py:8:5 | 6 | # Errors 7 | _ = Fraction.from_float(0.1) 8 | _ = Fraction.from_float(-0.5) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | _ = Fraction.from_float(5.0) 10 | _ = fractions.Fraction.from_float(4.2) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Safe fix 5 5 | @@ -42,16 +44,17 @@ FURB164.py:8:5: FURB164 [*] Verbose method `from_float` in `Fraction` constructi 10 10 | _ = fractions.Fraction.from_float(4.2) 11 11 | _ = Fraction.from_decimal(Decimal("4.2")) -FURB164.py:9:5: FURB164 [*] Verbose method `from_float` in `Fraction` construction +FURB164 [*] Verbose method `from_float` in `Fraction` construction + --> FURB164.py:9:5 | 7 | _ = Fraction.from_float(0.1) 8 | _ = Fraction.from_float(-0.5) 9 | _ = Fraction.from_float(5.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 10 | _ = fractions.Fraction.from_float(4.2) 11 | _ = Fraction.from_decimal(Decimal("4.2")) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Safe fix 6 6 | # Errors @@ -63,16 +66,17 @@ FURB164.py:9:5: FURB164 [*] Verbose method `from_float` in `Fraction` constructi 11 11 | _ = Fraction.from_decimal(Decimal("4.2")) 12 12 | _ = Fraction.from_decimal(Decimal("-4.2")) -FURB164.py:10:5: FURB164 [*] Verbose method `from_float` in `Fraction` construction +FURB164 [*] Verbose method `from_float` in `Fraction` construction + --> FURB164.py:10:5 | 8 | _ = Fraction.from_float(-0.5) 9 | _ = Fraction.from_float(5.0) 10 | _ = fractions.Fraction.from_float(4.2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | _ = Fraction.from_decimal(Decimal("4.2")) 12 | _ = Fraction.from_decimal(Decimal("-4.2")) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Safe fix 7 7 | _ = Fraction.from_float(0.1) @@ -84,16 +88,17 @@ FURB164.py:10:5: FURB164 [*] Verbose method `from_float` in `Fraction` construct 12 12 | _ = Fraction.from_decimal(Decimal("-4.2")) 13 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) -FURB164.py:11:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` construction +FURB164 [*] Verbose method `from_decimal` in `Fraction` construction + --> FURB164.py:11:5 | 9 | _ = Fraction.from_float(5.0) 10 | _ = fractions.Fraction.from_float(4.2) 11 | _ = Fraction.from_decimal(Decimal("4.2")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | _ = Fraction.from_decimal(Decimal("-4.2")) 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Unsafe fix 8 8 | _ = Fraction.from_float(-0.5) @@ -105,16 +110,17 @@ FURB164.py:11:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` constru 13 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) 14 14 | _ = Decimal.from_float(0.1) -FURB164.py:12:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` construction +FURB164 [*] Verbose method `from_decimal` in `Fraction` construction + --> FURB164.py:12:5 | 10 | _ = fractions.Fraction.from_float(4.2) 11 | _ = Fraction.from_decimal(Decimal("4.2")) 12 | _ = Fraction.from_decimal(Decimal("-4.2")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) 14 | _ = Decimal.from_float(0.1) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Unsafe fix 9 9 | _ = Fraction.from_float(5.0) @@ -126,16 +132,17 @@ FURB164.py:12:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` constru 14 14 | _ = Decimal.from_float(0.1) 15 15 | _ = Decimal.from_float(-0.5) -FURB164.py:13:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` construction +FURB164 [*] Verbose method `from_decimal` in `Fraction` construction + --> FURB164.py:13:5 | 11 | _ = Fraction.from_decimal(Decimal("4.2")) 12 | _ = Fraction.from_decimal(Decimal("-4.2")) 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | _ = Decimal.from_float(0.1) 15 | _ = Decimal.from_float(-0.5) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Unsafe fix 10 10 | _ = fractions.Fraction.from_float(4.2) @@ -147,16 +154,17 @@ FURB164.py:13:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` constru 15 15 | _ = Decimal.from_float(-0.5) 16 16 | _ = Decimal.from_float(5.0) -FURB164.py:13:27: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:13:27 | 11 | _ = Fraction.from_decimal(Decimal("4.2")) 12 | _ = Fraction.from_decimal(Decimal("-4.2")) 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | _ = Decimal.from_float(0.1) 15 | _ = Decimal.from_float(-0.5) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Unsafe fix 10 10 | _ = fractions.Fraction.from_float(4.2) @@ -168,16 +176,17 @@ FURB164.py:13:27: FURB164 [*] Verbose method `from_float` in `Decimal` construct 15 15 | _ = Decimal.from_float(-0.5) 16 16 | _ = Decimal.from_float(5.0) -FURB164.py:14:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:14:5 | 12 | _ = Fraction.from_decimal(Decimal("-4.2")) 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) 14 | _ = Decimal.from_float(0.1) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^ 15 | _ = Decimal.from_float(-0.5) 16 | _ = Decimal.from_float(5.0) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Unsafe fix 11 11 | _ = Fraction.from_decimal(Decimal("4.2")) @@ -189,16 +198,17 @@ FURB164.py:14:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 16 16 | _ = Decimal.from_float(5.0) 17 17 | _ = decimal.Decimal.from_float(4.2) -FURB164.py:15:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:15:5 | 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) 14 | _ = Decimal.from_float(0.1) 15 | _ = Decimal.from_float(-0.5) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 16 | _ = Decimal.from_float(5.0) 17 | _ = decimal.Decimal.from_float(4.2) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Unsafe fix 12 12 | _ = Fraction.from_decimal(Decimal("-4.2")) @@ -210,16 +220,17 @@ FURB164.py:15:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 17 17 | _ = decimal.Decimal.from_float(4.2) 18 18 | _ = Decimal.from_float(float("inf")) -FURB164.py:16:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:16:5 | 14 | _ = Decimal.from_float(0.1) 15 | _ = Decimal.from_float(-0.5) 16 | _ = Decimal.from_float(5.0) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^ 17 | _ = decimal.Decimal.from_float(4.2) 18 | _ = Decimal.from_float(float("inf")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Unsafe fix 13 13 | _ = Fraction.from_decimal(Decimal.from_float(4.2)) @@ -231,16 +242,17 @@ FURB164.py:16:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 18 18 | _ = Decimal.from_float(float("inf")) 19 19 | _ = Decimal.from_float(float("-inf")) -FURB164.py:17:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:17:5 | 15 | _ = Decimal.from_float(-0.5) 16 | _ = Decimal.from_float(5.0) 17 | _ = decimal.Decimal.from_float(4.2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | _ = Decimal.from_float(float("inf")) 19 | _ = Decimal.from_float(float("-inf")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Unsafe fix 14 14 | _ = Decimal.from_float(0.1) @@ -252,16 +264,17 @@ FURB164.py:17:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 19 19 | _ = Decimal.from_float(float("-inf")) 20 20 | _ = Decimal.from_float(float("Infinity")) -FURB164.py:18:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:18:5 | 16 | _ = Decimal.from_float(5.0) 17 | _ = decimal.Decimal.from_float(4.2) 18 | _ = Decimal.from_float(float("inf")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | _ = Decimal.from_float(float("-inf")) 20 | _ = Decimal.from_float(float("Infinity")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 15 15 | _ = Decimal.from_float(-0.5) @@ -273,16 +286,17 @@ FURB164.py:18:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 20 20 | _ = Decimal.from_float(float("Infinity")) 21 21 | _ = Decimal.from_float(float("-Infinity")) -FURB164.py:19:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:19:5 | 17 | _ = decimal.Decimal.from_float(4.2) 18 | _ = Decimal.from_float(float("inf")) 19 | _ = Decimal.from_float(float("-inf")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | _ = Decimal.from_float(float("Infinity")) 21 | _ = Decimal.from_float(float("-Infinity")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 16 16 | _ = Decimal.from_float(5.0) @@ -294,16 +308,17 @@ FURB164.py:19:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 21 21 | _ = Decimal.from_float(float("-Infinity")) 22 22 | _ = Decimal.from_float(float("nan")) -FURB164.py:20:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:20:5 | 18 | _ = Decimal.from_float(float("inf")) 19 | _ = Decimal.from_float(float("-inf")) 20 | _ = Decimal.from_float(float("Infinity")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | _ = Decimal.from_float(float("-Infinity")) 22 | _ = Decimal.from_float(float("nan")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 17 17 | _ = decimal.Decimal.from_float(4.2) @@ -315,16 +330,17 @@ FURB164.py:20:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 22 22 | _ = Decimal.from_float(float("nan")) 23 23 | _ = Decimal.from_float(float("-NaN ")) -FURB164.py:21:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:21:5 | 19 | _ = Decimal.from_float(float("-inf")) 20 | _ = Decimal.from_float(float("Infinity")) 21 | _ = Decimal.from_float(float("-Infinity")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | _ = Decimal.from_float(float("nan")) 23 | _ = Decimal.from_float(float("-NaN ")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 18 18 | _ = Decimal.from_float(float("inf")) @@ -336,16 +352,17 @@ FURB164.py:21:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 23 23 | _ = Decimal.from_float(float("-NaN ")) 24 24 | _ = Decimal.from_float(float(" \n+nan \t")) -FURB164.py:22:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:22:5 | 20 | _ = Decimal.from_float(float("Infinity")) 21 | _ = Decimal.from_float(float("-Infinity")) 22 | _ = Decimal.from_float(float("nan")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | _ = Decimal.from_float(float("-NaN ")) 24 | _ = Decimal.from_float(float(" \n+nan \t")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 19 19 | _ = Decimal.from_float(float("-inf")) @@ -357,16 +374,17 @@ FURB164.py:22:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 24 24 | _ = Decimal.from_float(float(" \n+nan \t")) 25 25 | _ = Decimal.from_float(float(" iNf \n\t ")) -FURB164.py:23:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:23:5 | 21 | _ = Decimal.from_float(float("-Infinity")) 22 | _ = Decimal.from_float(float("nan")) 23 | _ = Decimal.from_float(float("-NaN ")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | _ = Decimal.from_float(float(" \n+nan \t")) 25 | _ = Decimal.from_float(float(" iNf \n\t ")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 20 20 | _ = Decimal.from_float(float("Infinity")) @@ -378,16 +396,17 @@ FURB164.py:23:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 25 25 | _ = Decimal.from_float(float(" iNf \n\t ")) 26 26 | _ = Decimal.from_float(float("  -inF\n \t")) -FURB164.py:24:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:24:5 | 22 | _ = Decimal.from_float(float("nan")) 23 | _ = Decimal.from_float(float("-NaN ")) 24 | _ = Decimal.from_float(float(" \n+nan \t")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | _ = Decimal.from_float(float(" iNf \n\t ")) 26 | _ = Decimal.from_float(float("  -inF\n \t")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 21 21 | _ = Decimal.from_float(float("-Infinity")) @@ -399,16 +418,17 @@ FURB164.py:24:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 26 26 | _ = Decimal.from_float(float("  -inF\n \t")) 27 27 | _ = Decimal.from_float(float(" InfinIty \n\t ")) -FURB164.py:25:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:25:5 | 23 | _ = Decimal.from_float(float("-NaN ")) 24 | _ = Decimal.from_float(float(" \n+nan \t")) 25 | _ = Decimal.from_float(float(" iNf \n\t ")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | _ = Decimal.from_float(float("  -inF\n \t")) 27 | _ = Decimal.from_float(float(" InfinIty \n\t ")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 22 22 | _ = Decimal.from_float(float("nan")) @@ -420,16 +440,17 @@ FURB164.py:25:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 27 27 | _ = Decimal.from_float(float(" InfinIty \n\t ")) 28 28 | _ = Decimal.from_float(float("  -InfinIty\n \t")) -FURB164.py:26:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:26:5 | 24 | _ = Decimal.from_float(float(" \n+nan \t")) 25 | _ = Decimal.from_float(float(" iNf \n\t ")) 26 | _ = Decimal.from_float(float("  -inF\n \t")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | _ = Decimal.from_float(float(" InfinIty \n\t ")) 28 | _ = Decimal.from_float(float("  -InfinIty\n \t")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 23 23 | _ = Decimal.from_float(float("-NaN ")) @@ -441,15 +462,16 @@ FURB164.py:26:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 28 28 | _ = Decimal.from_float(float("  -InfinIty\n \t")) 29 29 | -FURB164.py:27:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:27:5 | 25 | _ = Decimal.from_float(float(" iNf \n\t ")) 26 | _ = Decimal.from_float(float("  -inF\n \t")) 27 | _ = Decimal.from_float(float(" InfinIty \n\t ")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | _ = Decimal.from_float(float("  -InfinIty\n \t")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 24 24 | _ = Decimal.from_float(float(" \n+nan \t")) @@ -461,16 +483,17 @@ FURB164.py:27:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 29 29 | 30 30 | # Cases with keyword arguments - should produce unsafe fixes -FURB164.py:28:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:28:5 | 26 | _ = Decimal.from_float(float("  -inF\n \t")) 27 | _ = Decimal.from_float(float(" InfinIty \n\t ")) 28 | _ = Decimal.from_float(float("  -InfinIty\n \t")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | 30 | # Cases with keyword arguments - should produce unsafe fixes | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 25 25 | _ = Decimal.from_float(float(" iNf \n\t ")) @@ -482,14 +505,15 @@ FURB164.py:28:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 30 30 | # Cases with keyword arguments - should produce unsafe fixes 31 31 | _ = Fraction.from_decimal(dec=Decimal("4.2")) -FURB164.py:31:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` construction +FURB164 [*] Verbose method `from_decimal` in `Fraction` construction + --> FURB164.py:31:5 | 30 | # Cases with keyword arguments - should produce unsafe fixes 31 | _ = Fraction.from_decimal(dec=Decimal("4.2")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | _ = Decimal.from_float(f=4.2) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Unsafe fix 28 28 | _ = Decimal.from_float(float("  -InfinIty\n \t")) @@ -501,66 +525,72 @@ FURB164.py:31:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` constru 33 33 | 34 34 | # Cases with invalid argument counts - should not get fixes -FURB164.py:32:5: FURB164 Verbose method `from_float` in `Decimal` construction +FURB164 Verbose method `from_float` in `Decimal` construction + --> FURB164.py:32:5 | 30 | # Cases with keyword arguments - should produce unsafe fixes 31 | _ = Fraction.from_decimal(dec=Decimal("4.2")) 32 | _ = Decimal.from_float(f=4.2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | 34 | # Cases with invalid argument counts - should not get fixes | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor -FURB164.py:35:5: FURB164 Verbose method `from_decimal` in `Fraction` construction +FURB164 Verbose method `from_decimal` in `Fraction` construction + --> FURB164.py:35:5 | 34 | # Cases with invalid argument counts - should not get fixes 35 | _ = Fraction.from_decimal(Decimal("4.2"), 1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | _ = Decimal.from_float(4.2, None) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor -FURB164.py:36:5: FURB164 Verbose method `from_float` in `Decimal` construction +FURB164 Verbose method `from_float` in `Decimal` construction + --> FURB164.py:36:5 | 34 | # Cases with invalid argument counts - should not get fixes 35 | _ = Fraction.from_decimal(Decimal("4.2"), 1) 36 | _ = Decimal.from_float(4.2, None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | 38 | # Cases with wrong keyword arguments - should not get fixes | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor -FURB164.py:39:5: FURB164 Verbose method `from_decimal` in `Fraction` construction +FURB164 Verbose method `from_decimal` in `Fraction` construction + --> FURB164.py:39:5 | 38 | # Cases with wrong keyword arguments - should not get fixes 39 | _ = Fraction.from_decimal(numerator=Decimal("4.2")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | _ = Decimal.from_float(value=4.2) | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor -FURB164.py:40:5: FURB164 Verbose method `from_float` in `Decimal` construction +FURB164 Verbose method `from_float` in `Decimal` construction + --> FURB164.py:40:5 | 38 | # Cases with wrong keyword arguments - should not get fixes 39 | _ = Fraction.from_decimal(numerator=Decimal("4.2")) 40 | _ = Decimal.from_float(value=4.2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 41 | 42 | # Cases with type validation issues - should produce unsafe fixes | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor -FURB164.py:43:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:43:5 | 42 | # Cases with type validation issues - should produce unsafe fixes 43 | _ = Decimal.from_float("4.2") # Invalid type for from_float - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | _ = Fraction.from_decimal(4.2) # Invalid type for from_decimal 45 | _ = Fraction.from_float("4.2") # Invalid type for from_float | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Unsafe fix 40 40 | _ = Decimal.from_float(value=4.2) @@ -572,15 +602,16 @@ FURB164.py:43:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 45 45 | _ = Fraction.from_float("4.2") # Invalid type for from_float 46 46 | -FURB164.py:44:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` construction +FURB164 [*] Verbose method `from_decimal` in `Fraction` construction + --> FURB164.py:44:5 | 42 | # Cases with type validation issues - should produce unsafe fixes 43 | _ = Decimal.from_float("4.2") # Invalid type for from_float 44 | _ = Fraction.from_decimal(4.2) # Invalid type for from_decimal - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | _ = Fraction.from_float("4.2") # Invalid type for from_float | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Unsafe fix 41 41 | @@ -592,16 +623,17 @@ FURB164.py:44:5: FURB164 [*] Verbose method `from_decimal` in `Fraction` constru 46 46 | 47 47 | # OK - should not trigger the rule -FURB164.py:45:5: FURB164 [*] Verbose method `from_float` in `Fraction` construction +FURB164 [*] Verbose method `from_float` in `Fraction` construction + --> FURB164.py:45:5 | 43 | _ = Decimal.from_float("4.2") # Invalid type for from_float 44 | _ = Fraction.from_decimal(4.2) # Invalid type for from_decimal 45 | _ = Fraction.from_float("4.2") # Invalid type for from_float - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 46 | 47 | # OK - should not trigger the rule | - = help: Replace with `Fraction` constructor +help: Replace with `Fraction` constructor ℹ Unsafe fix 42 42 | # Cases with type validation issues - should produce unsafe fixes @@ -613,14 +645,15 @@ FURB164.py:45:5: FURB164 [*] Verbose method `from_float` in `Fraction` construct 47 47 | # OK - should not trigger the rule 48 48 | _ = Fraction(0.1) -FURB164.py:60:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:60:5 | 59 | # Cases with int and bool - should produce safe fixes 60 | _ = Decimal.from_float(1) - | ^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^ 61 | _ = Decimal.from_float(True) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 57 57 | _ = decimal.Decimal(4.2) @@ -632,16 +665,17 @@ FURB164.py:60:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 62 62 | 63 63 | # Cases with non-finite floats - should produce safe fixes -FURB164.py:61:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:61:5 | 59 | # Cases with int and bool - should produce safe fixes 60 | _ = Decimal.from_float(1) 61 | _ = Decimal.from_float(True) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 62 | 63 | # Cases with non-finite floats - should produce safe fixes | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 58 58 | @@ -653,15 +687,16 @@ FURB164.py:61:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 63 63 | # Cases with non-finite floats - should produce safe fixes 64 64 | _ = Decimal.from_float(float("-nan")) -FURB164.py:64:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:64:5 | 63 | # Cases with non-finite floats - should produce safe fixes 64 | _ = Decimal.from_float(float("-nan")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65 | _ = Decimal.from_float(float("\x2dnan")) 66 | _ = Decimal.from_float(float("\N{HYPHEN-MINUS}nan")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 61 61 | _ = Decimal.from_float(True) @@ -672,15 +707,16 @@ FURB164.py:64:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 65 65 | _ = Decimal.from_float(float("\x2dnan")) 66 66 | _ = Decimal.from_float(float("\N{HYPHEN-MINUS}nan")) -FURB164.py:65:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:65:5 | 63 | # Cases with non-finite floats - should produce safe fixes 64 | _ = Decimal.from_float(float("-nan")) 65 | _ = Decimal.from_float(float("\x2dnan")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 66 | _ = Decimal.from_float(float("\N{HYPHEN-MINUS}nan")) | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 62 62 | @@ -690,14 +726,15 @@ FURB164.py:65:5: FURB164 [*] Verbose method `from_float` in `Decimal` constructi 65 |+_ = Decimal("-nan") 66 66 | _ = Decimal.from_float(float("\N{HYPHEN-MINUS}nan")) -FURB164.py:66:5: FURB164 [*] Verbose method `from_float` in `Decimal` construction +FURB164 [*] Verbose method `from_float` in `Decimal` construction + --> FURB164.py:66:5 | 64 | _ = Decimal.from_float(float("-nan")) 65 | _ = Decimal.from_float(float("\x2dnan")) 66 | _ = Decimal.from_float(float("\N{HYPHEN-MINUS}nan")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB164 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `Decimal` constructor +help: Replace with `Decimal` constructor ℹ Safe fix 63 63 | # Cases with non-finite floats - should produce safe fixes diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap index 162b036f6a..2ea45e5340 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB166_FURB166.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB166.py:3:5: FURB166 [*] Use of `int` with explicit `base=2` after removing prefix +FURB166 [*] Use of `int` with explicit `base=2` after removing prefix + --> FURB166.py:3:5 | 1 | # Errors 2 | 3 | _ = int("0b1010"[2:], 2) - | ^^^^^^^^^^^^^^^^^^^^ FURB166 + | ^^^^^^^^^^^^^^^^^^^^ 4 | _ = int("0o777"[2:], 8) 5 | _ = int("0xFFFF"[2:], 16) | - = help: Replace with `base=0` +help: Replace with `base=0` ℹ Unsafe fix 1 1 | # Errors @@ -21,14 +22,15 @@ FURB166.py:3:5: FURB166 [*] Use of `int` with explicit `base=2` after removing p 5 5 | _ = int("0xFFFF"[2:], 16) 6 6 | -FURB166.py:4:5: FURB166 [*] Use of `int` with explicit `base=8` after removing prefix +FURB166 [*] Use of `int` with explicit `base=8` after removing prefix + --> FURB166.py:4:5 | 3 | _ = int("0b1010"[2:], 2) 4 | _ = int("0o777"[2:], 8) - | ^^^^^^^^^^^^^^^^^^^ FURB166 + | ^^^^^^^^^^^^^^^^^^^ 5 | _ = int("0xFFFF"[2:], 16) | - = help: Replace with `base=0` +help: Replace with `base=0` ℹ Unsafe fix 1 1 | # Errors @@ -40,16 +42,17 @@ FURB166.py:4:5: FURB166 [*] Use of `int` with explicit `base=8` after removing p 6 6 | 7 7 | b = "0b11" -FURB166.py:5:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix +FURB166 [*] Use of `int` with explicit `base=16` after removing prefix + --> FURB166.py:5:5 | 3 | _ = int("0b1010"[2:], 2) 4 | _ = int("0o777"[2:], 8) 5 | _ = int("0xFFFF"[2:], 16) - | ^^^^^^^^^^^^^^^^^^^^^ FURB166 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | b = "0b11" | - = help: Replace with `base=0` +help: Replace with `base=0` ℹ Unsafe fix 2 2 | @@ -61,15 +64,16 @@ FURB166.py:5:5: FURB166 [*] Use of `int` with explicit `base=16` after removing 7 7 | b = "0b11" 8 8 | _ = int(b[2:], 2) -FURB166.py:8:5: FURB166 [*] Use of `int` with explicit `base=2` after removing prefix +FURB166 [*] Use of `int` with explicit `base=2` after removing prefix + --> FURB166.py:8:5 | 7 | b = "0b11" 8 | _ = int(b[2:], 2) - | ^^^^^^^^^^^^^ FURB166 + | ^^^^^^^^^^^^^ 9 | 10 | _ = int("0xFFFF"[2:], base=16) | - = help: Replace with `base=0` +help: Replace with `base=0` ℹ Unsafe fix 5 5 | _ = int("0xFFFF"[2:], 16) @@ -81,16 +85,17 @@ FURB166.py:8:5: FURB166 [*] Use of `int` with explicit `base=2` after removing p 10 10 | _ = int("0xFFFF"[2:], base=16) 11 11 | -FURB166.py:10:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix +FURB166 [*] Use of `int` with explicit `base=16` after removing prefix + --> FURB166.py:10:5 | 8 | _ = int(b[2:], 2) 9 | 10 | _ = int("0xFFFF"[2:], base=16) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB166 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | _ = int(b"0xFFFF"[2:], 16) | - = help: Replace with `base=0` +help: Replace with `base=0` ℹ Unsafe fix 7 7 | b = "0b11" @@ -102,14 +107,15 @@ FURB166.py:10:5: FURB166 [*] Use of `int` with explicit `base=16` after removing 12 12 | _ = int(b"0xFFFF"[2:], 16) 13 13 | -FURB166.py:12:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix +FURB166 [*] Use of `int` with explicit `base=16` after removing prefix + --> FURB166.py:12:5 | 10 | _ = int("0xFFFF"[2:], base=16) 11 | 12 | _ = int(b"0xFFFF"[2:], 16) - | ^^^^^^^^^^^^^^^^^^^^^^ FURB166 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `base=0` +help: Replace with `base=0` ℹ Unsafe fix 9 9 | @@ -121,14 +127,15 @@ FURB166.py:12:5: FURB166 [*] Use of `int` with explicit `base=16` after removing 14 14 | 15 15 | def get_str(): -FURB166.py:19:5: FURB166 [*] Use of `int` with explicit `base=16` after removing prefix +FURB166 [*] Use of `int` with explicit `base=16` after removing prefix + --> FURB166.py:19:5 | 19 | _ = int(get_str()[2:], 16) - | ^^^^^^^^^^^^^^^^^^^^^^ FURB166 + | ^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | # OK | - = help: Replace with `base=0` +help: Replace with `base=0` ℹ Unsafe fix 16 16 | return "0xFFF" diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap index a34ef22a7a..63c13cf4d4 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB167_FURB167.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- -FURB167.py:13:42: FURB167 [*] Use of regular expression alias `re.I` +FURB167 [*] Use of regular expression alias `re.I` + --> FURB167.py:13:42 | 12 | # FURB167 13 | if re.match("^hello", "hello world", re.I): - | ^^^^ FURB167 + | ^^^^ 14 | pass | - = help: Replace with `re.IGNORECASE` +help: Replace with `re.IGNORECASE` ℹ Safe fix 10 10 | import re @@ -21,14 +21,15 @@ FURB167.py:13:42: FURB167 [*] Use of regular expression alias `re.I` 15 15 | 16 16 | -FURB167.py:21:39: FURB167 [*] Use of regular expression alias `re.I` +FURB167 [*] Use of regular expression alias `re.I` + --> FURB167.py:21:39 | 20 | # FURB167 21 | if match("^hello", "hello world", I): - | ^ FURB167 + | ^ 22 | pass | - = help: Replace with `re.IGNORECASE` +help: Replace with `re.IGNORECASE` ℹ Safe fix 1 |+import re diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap index c9b6165ff5..b8a8552814 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB168_FURB168.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB168.py:5:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:5:4 | 3 | # Errors. 4 | 5 | if isinstance(foo, type(None)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | pass | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 2 2 | @@ -21,15 +22,16 @@ FURB168.py:5:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if a 7 7 | 8 8 | if isinstance(foo and bar, type(None)): -FURB168.py:8:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:8:4 | 6 | pass 7 | 8 | if isinstance(foo and bar, type(None)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | pass | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 5 5 | if isinstance(foo, type(None)): @@ -41,15 +43,16 @@ FURB168.py:8:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if a 10 10 | 11 11 | if isinstance(foo, (type(None), type(None), type(None))): -FURB168.py:11:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:11:4 | 9 | pass 10 | 11 | if isinstance(foo, (type(None), type(None), type(None))): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | pass | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 8 8 | if isinstance(foo and bar, type(None)): @@ -61,15 +64,16 @@ FURB168.py:11:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if 13 13 | 14 14 | if isinstance(foo, type(None)) is True: -FURB168.py:14:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:14:4 | 12 | pass 13 | 14 | if isinstance(foo, type(None)) is True: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | pass | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 11 11 | if isinstance(foo, (type(None), type(None), type(None))): @@ -81,15 +85,16 @@ FURB168.py:14:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if 16 16 | 17 17 | if -isinstance(foo, type(None)): -FURB168.py:17:5: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:17:5 | 15 | pass 16 | 17 | if -isinstance(foo, type(None)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | pass | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 14 14 | if isinstance(foo, type(None)) is True: @@ -101,15 +106,16 @@ FURB168.py:17:5: FURB168 [*] Prefer `is` operator over `isinstance` to check if 19 19 | 20 20 | if isinstance(foo, None | type(None)): -FURB168.py:20:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:20:4 | 18 | pass 19 | 20 | if isinstance(foo, None | type(None)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | pass | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 17 17 | if -isinstance(foo, type(None)): @@ -121,15 +127,16 @@ FURB168.py:20:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if 22 22 | 23 23 | if isinstance(foo, type(None) | type(None)): -FURB168.py:23:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:23:4 | 21 | pass 22 | 23 | if isinstance(foo, type(None) | type(None)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | pass | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 20 20 | if isinstance(foo, None | type(None)): @@ -141,14 +148,15 @@ FURB168.py:23:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if 25 25 | 26 26 | # A bit contrived, but is both technically valid and equivalent to the above. -FURB168.py:27:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:27:4 | 26 | # A bit contrived, but is both technically valid and equivalent to the above. 27 | if isinstance(foo, (type(None) | ((((type(None))))) | ((None | type(None))))): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | pass | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 24 24 | pass @@ -160,15 +168,16 @@ FURB168.py:27:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if 29 29 | 30 30 | if isinstance( -FURB168.py:38:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:38:4 | 36 | from typing import Union 37 | 38 | if isinstance(foo, Union[None]): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | ... | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 35 35 | @@ -180,15 +189,16 @@ FURB168.py:38:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if 40 40 | 41 41 | if isinstance(foo, Union[None, None]): -FURB168.py:41:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:41:4 | 39 | ... 40 | 41 | if isinstance(foo, Union[None, None]): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | ... | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 38 38 | if isinstance(foo, Union[None]): @@ -200,15 +210,16 @@ FURB168.py:41:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if 43 43 | 44 44 | if isinstance(foo, Union[None, type(None)]): -FURB168.py:44:4: FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` +FURB168 [*] Prefer `is` operator over `isinstance` to check if an object is `None` + --> FURB168.py:44:4 | 42 | ... 43 | 44 | if isinstance(foo, Union[None, type(None)]): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB168 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 45 | ... | - = help: Replace with `is` operator +help: Replace with `is` operator ℹ Safe fix 41 41 | if isinstance(foo, Union[None, None]): diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap index 4a711ebcfc..93c3f0d88b 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB169_FURB169.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB169.py:5:1: FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` + --> FURB169.py:5:1 | 3 | # Error. 4 | 5 | type(foo) is type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | type(None) is type(foo) | - = help: Replace with `is None` +help: Replace with `is None` ℹ Safe fix 2 2 | @@ -22,16 +23,17 @@ FURB169.py:5:1: FURB169 [*] When checking against `None`, use `is` instead of co 7 7 | type(None) is type(foo) 8 8 | -FURB169.py:7:1: FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` + --> FURB169.py:7:1 | 5 | type(foo) is type(None) 6 | 7 | type(None) is type(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | type(None) is type(None) | - = help: Replace with `is None` +help: Replace with `is None` ℹ Safe fix 4 4 | @@ -43,16 +45,17 @@ FURB169.py:7:1: FURB169 [*] When checking against `None`, use `is` instead of co 9 9 | type(None) is type(None) 10 10 | -FURB169.py:9:1: FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` + --> FURB169.py:9:1 | 7 | type(None) is type(foo) 8 | 9 | type(None) is type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | type(foo) is not type(None) | - = help: Replace with `is None` +help: Replace with `is None` ℹ Safe fix 6 6 | @@ -64,16 +67,17 @@ FURB169.py:9:1: FURB169 [*] When checking against `None`, use `is` instead of co 11 11 | type(foo) is not type(None) 12 12 | -FURB169.py:11:1: FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` + --> FURB169.py:11:1 | 9 | type(None) is type(None) 10 | 11 | type(foo) is not type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | type(None) is not type(foo) | - = help: Replace with `is not None` +help: Replace with `is not None` ℹ Safe fix 8 8 | @@ -85,16 +89,17 @@ FURB169.py:11:1: FURB169 [*] When checking against `None`, use `is not` instead 13 13 | type(None) is not type(foo) 14 14 | -FURB169.py:13:1: FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` + --> FURB169.py:13:1 | 11 | type(foo) is not type(None) 12 | 13 | type(None) is not type(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | type(None) is not type(None) | - = help: Replace with `is not None` +help: Replace with `is not None` ℹ Safe fix 10 10 | @@ -106,16 +111,17 @@ FURB169.py:13:1: FURB169 [*] When checking against `None`, use `is not` instead 15 15 | type(None) is not type(None) 16 16 | -FURB169.py:15:1: FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` + --> FURB169.py:15:1 | 13 | type(None) is not type(foo) 14 | 15 | type(None) is not type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | type(foo) == type(None) | - = help: Replace with `is not None` +help: Replace with `is not None` ℹ Safe fix 12 12 | @@ -127,16 +133,17 @@ FURB169.py:15:1: FURB169 [*] When checking against `None`, use `is not` instead 17 17 | type(foo) == type(None) 18 18 | -FURB169.py:17:1: FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` + --> FURB169.py:17:1 | 15 | type(None) is not type(None) 16 | 17 | type(foo) == type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | type(None) == type(foo) | - = help: Replace with `is None` +help: Replace with `is None` ℹ Safe fix 14 14 | @@ -148,16 +155,17 @@ FURB169.py:17:1: FURB169 [*] When checking against `None`, use `is` instead of c 19 19 | type(None) == type(foo) 20 20 | -FURB169.py:19:1: FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` + --> FURB169.py:19:1 | 17 | type(foo) == type(None) 18 | 19 | type(None) == type(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | type(None) == type(None) | - = help: Replace with `is None` +help: Replace with `is None` ℹ Safe fix 16 16 | @@ -169,16 +177,17 @@ FURB169.py:19:1: FURB169 [*] When checking against `None`, use `is` instead of c 21 21 | type(None) == type(None) 22 22 | -FURB169.py:21:1: FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` + --> FURB169.py:21:1 | 19 | type(None) == type(foo) 20 | 21 | type(None) == type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | type(foo) != type(None) | - = help: Replace with `is None` +help: Replace with `is None` ℹ Safe fix 18 18 | @@ -190,16 +199,17 @@ FURB169.py:21:1: FURB169 [*] When checking against `None`, use `is` instead of c 23 23 | type(foo) != type(None) 24 24 | -FURB169.py:23:1: FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` + --> FURB169.py:23:1 | 21 | type(None) == type(None) 22 | 23 | type(foo) != type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^ 24 | 25 | type(None) != type(foo) | - = help: Replace with `is not None` +help: Replace with `is not None` ℹ Safe fix 20 20 | @@ -211,16 +221,17 @@ FURB169.py:23:1: FURB169 [*] When checking against `None`, use `is not` instead 25 25 | type(None) != type(foo) 26 26 | -FURB169.py:25:1: FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` + --> FURB169.py:25:1 | 23 | type(foo) != type(None) 24 | 25 | type(None) != type(foo) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | type(None) != type(None) | - = help: Replace with `is not None` +help: Replace with `is not None` ℹ Safe fix 22 22 | @@ -232,16 +243,17 @@ FURB169.py:25:1: FURB169 [*] When checking against `None`, use `is not` instead 27 27 | type(None) != type(None) 28 28 | -FURB169.py:27:1: FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` + --> FURB169.py:27:1 | 25 | type(None) != type(foo) 26 | 27 | type(None) != type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | type(a.b) is type(None) | - = help: Replace with `is not None` +help: Replace with `is not None` ℹ Safe fix 24 24 | @@ -253,16 +265,17 @@ FURB169.py:27:1: FURB169 [*] When checking against `None`, use `is not` instead 29 29 | type(a.b) is type(None) 30 30 | -FURB169.py:29:1: FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` + --> FURB169.py:29:1 | 27 | type(None) != type(None) 28 | 29 | type(a.b) is type(None) - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB169 + | ^^^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | type( | - = help: Replace with `is None` +help: Replace with `is None` ℹ Safe fix 26 26 | @@ -274,7 +287,8 @@ FURB169.py:29:1: FURB169 [*] When checking against `None`, use `is` instead of c 31 31 | type( 32 32 | a( -FURB169.py:31:1: FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` + --> FURB169.py:31:1 | 29 | type(a.b) is type(None) 30 | @@ -283,11 +297,11 @@ FURB169.py:31:1: FURB169 [*] When checking against `None`, use `is not` instead 33 | | # Comment 34 | | ) 35 | | ) != type(None) - | |_______________^ FURB169 + | |_______________^ 36 | 37 | type( | - = help: Replace with `is not None` +help: Replace with `is not None` ℹ Unsafe fix 28 28 | @@ -303,18 +317,19 @@ FURB169.py:31:1: FURB169 [*] When checking against `None`, use `is not` instead 37 33 | type( 38 34 | a := 1 -FURB169.py:37:1: FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is` instead of comparison with `type(None)` + --> FURB169.py:37:1 | 35 | ) != type(None) 36 | 37 | / type( 38 | | a := 1 39 | | ) == type(None) - | |_______________^ FURB169 + | |_______________^ 40 | 41 | type( | - = help: Replace with `is None` +help: Replace with `is None` ℹ Safe fix 34 34 | ) @@ -328,16 +343,17 @@ FURB169.py:37:1: FURB169 [*] When checking against `None`, use `is` instead of c 41 39 | type( 42 40 | a for a in range(0) -FURB169.py:41:1: FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` +FURB169 [*] When checking against `None`, use `is not` instead of comparison with `type(None)` + --> FURB169.py:41:1 | 39 | ) == type(None) 40 | 41 | / type( 42 | | a for a in range(0) 43 | | ) is not type(None) - | |___________________^ FURB169 + | |___________________^ | - = help: Replace with `is not None` +help: Replace with `is not None` ℹ Safe fix 38 38 | a := 1 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171_0.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171_0.py.snap index 8bc2c8a6af..d9a8c46147 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171_0.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB171_0.py:3:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:3:4 | 1 | # Errors. 2 | 3 | if 1 in (1,): - | ^^^^^^^^^ FURB171 + | ^^^^^^^^^ 4 | print("Single-element tuple") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 1 1 | # Errors. @@ -20,15 +21,16 @@ FURB171_0.py:3:4: FURB171 [*] Membership test against single-item container 5 5 | 6 6 | if 1 in [1]: -FURB171_0.py:6:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:6:4 | 4 | print("Single-element tuple") 5 | 6 | if 1 in [1]: - | ^^^^^^^^ FURB171 + | ^^^^^^^^ 7 | print("Single-element list") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 3 3 | if 1 in (1,): @@ -40,15 +42,16 @@ FURB171_0.py:6:4: FURB171 [*] Membership test against single-item container 8 8 | 9 9 | if 1 in {1}: -FURB171_0.py:9:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:9:4 | 7 | print("Single-element list") 8 | 9 | if 1 in {1}: - | ^^^^^^^^ FURB171 + | ^^^^^^^^ 10 | print("Single-element set") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 6 6 | if 1 in [1]: @@ -60,15 +63,16 @@ FURB171_0.py:9:4: FURB171 [*] Membership test against single-item container 11 11 | 12 12 | if "a" in "a": -FURB171_0.py:12:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:12:4 | 10 | print("Single-element set") 11 | 12 | if "a" in "a": - | ^^^^^^^^^^ FURB171 + | ^^^^^^^^^^ 13 | print("Single-element string") | - = help: Convert to equality test +help: Convert to equality test ℹ Unsafe fix 9 9 | if 1 in {1}: @@ -80,15 +84,16 @@ FURB171_0.py:12:4: FURB171 [*] Membership test against single-item container 14 14 | 15 15 | if 1 not in (1,): -FURB171_0.py:15:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:15:4 | 13 | print("Single-element string") 14 | 15 | if 1 not in (1,): - | ^^^^^^^^^^^^^ FURB171 + | ^^^^^^^^^^^^^ 16 | print("Check `not in` membership test") | - = help: Convert to inequality test +help: Convert to inequality test ℹ Safe fix 12 12 | if "a" in "a": @@ -100,15 +105,16 @@ FURB171_0.py:15:4: FURB171 [*] Membership test against single-item container 17 17 | 18 18 | if not 1 in (1,): -FURB171_0.py:18:8: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:18:8 | 16 | print("Check `not in` membership test") 17 | 18 | if not 1 in (1,): - | ^^^^^^^^^ FURB171 + | ^^^^^^^^^ 19 | print("Check the negated membership test") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 15 15 | if 1 not in (1,): @@ -120,7 +126,8 @@ FURB171_0.py:18:8: FURB171 [*] Membership test against single-item container 20 20 | 21 21 | # Non-errors. -FURB171_0.py:52:5: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:52:5 | 51 | # https://github.com/astral-sh/ruff/issues/10063 52 | _ = a in ( @@ -128,11 +135,11 @@ FURB171_0.py:52:5: FURB171 [*] Membership test against single-item container 53 | | # Foo 54 | | b, 55 | | ) - | |_^ FURB171 + | |_^ 56 | 57 | _ = a in ( # Foo1 | - = help: Convert to equality test +help: Convert to equality test ℹ Unsafe fix 49 49 | @@ -147,7 +154,8 @@ FURB171_0.py:52:5: FURB171 [*] Membership test against single-item container 57 54 | _ = a in ( # Foo1 58 55 | ( # Foo2 -FURB171_0.py:57:5: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:57:5 | 55 | ) 56 | @@ -168,11 +176,11 @@ FURB171_0.py:57:5: FURB171 [*] Membership test against single-item container 70 | | # Foo6 71 | | ) 72 | | ) - | |_^ FURB171 + | |_^ 73 | 74 | foo = ( | - = help: Convert to equality test +help: Convert to equality test ℹ Unsafe fix 54 54 | b, @@ -199,7 +207,8 @@ FURB171_0.py:57:5: FURB171 [*] Membership test against single-item container 74 63 | foo = ( 75 64 | lorem() -FURB171_0.py:77:28: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:77:28 | 75 | lorem() 76 | .ipsum() @@ -209,10 +218,10 @@ FURB171_0.py:77:28: FURB171 [*] Membership test against single-item container 79 | | # Foo2 80 | | amet, 81 | | )) - | |_________^ FURB171 + | |_________^ 82 | ) | - = help: Convert to equality test +help: Convert to equality test ℹ Unsafe fix 74 74 | foo = ( @@ -228,7 +237,8 @@ FURB171_0.py:77:28: FURB171 [*] Membership test against single-item container 83 79 | 84 80 | foo = ( -FURB171_0.py:87:28: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:87:28 | 85 | lorem() 86 | .ipsum() @@ -240,10 +250,10 @@ FURB171_0.py:87:28: FURB171 [*] Membership test against single-item container 91 | | amet 92 | | ), 93 | | )) - | |_________^ FURB171 + | |_________^ 94 | ) | - = help: Convert to equality test +help: Convert to equality test ℹ Unsafe fix 84 84 | foo = ( @@ -262,7 +272,8 @@ FURB171_0.py:87:28: FURB171 [*] Membership test against single-item container 95 93 | 96 94 | foo = lorem() \ -FURB171_0.py:98:24: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:98:24 | 96 | foo = lorem() \ 97 | .ipsum() \ @@ -272,11 +283,11 @@ FURB171_0.py:98:24: FURB171 [*] Membership test against single-item container 100 | | # Foo2 101 | | amet, 102 | | )) - | |_____^ FURB171 + | |_____^ 103 | 104 | def _(): | - = help: Convert to equality test +help: Convert to equality test ℹ Unsafe fix 95 95 | @@ -292,7 +303,8 @@ FURB171_0.py:98:24: FURB171 [*] Membership test against single-item container 104 100 | def _(): 105 101 | if foo not \ -FURB171_0.py:105:8: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:105:8 | 104 | def _(): 105 | if foo not \ @@ -302,11 +314,11 @@ FURB171_0.py:105:8: FURB171 [*] Membership test against single-item container 108 | | bar 109 | | # After 110 | | ]: ... - | |_____^ FURB171 + | |_____^ 111 | 112 | def _(): | - = help: Convert to inequality test +help: Convert to inequality test ℹ Unsafe fix 102 102 | )) @@ -323,7 +335,8 @@ FURB171_0.py:105:8: FURB171 [*] Membership test against single-item container 112 107 | def _(): 113 108 | if foo not \ -FURB171_0.py:113:8: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_0.py:113:8 | 112 | def _(): 113 | if foo not \ @@ -333,10 +346,10 @@ FURB171_0.py:113:8: FURB171 [*] Membership test against single-item container 116 | | bar 117 | | # After 118 | | ] and \ - | |_____^ FURB171 + | |_____^ 119 | 0 < 1: ... | - = help: Convert to inequality test +help: Convert to inequality test ℹ Unsafe fix 110 110 | ]: ... diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171_1.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171_1.py.snap index 01e249adf5..06bb3cfc0d 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171_1.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB171_FURB171_1.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB171_1.py:3:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_1.py:3:4 | 1 | # Errors. 2 | 3 | if 1 in set([1]): - | ^^^^^^^^^^^^^ FURB171 + | ^^^^^^^^^^^^^ 4 | print("Single-element set") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 1 1 | # Errors. @@ -20,15 +21,16 @@ FURB171_1.py:3:4: FURB171 [*] Membership test against single-item container 5 5 | 6 6 | if 1 in set((1,)): -FURB171_1.py:6:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_1.py:6:4 | 4 | print("Single-element set") 5 | 6 | if 1 in set((1,)): - | ^^^^^^^^^^^^^^ FURB171 + | ^^^^^^^^^^^^^^ 7 | print("Single-element set") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 3 3 | if 1 in set([1]): @@ -40,15 +42,16 @@ FURB171_1.py:6:4: FURB171 [*] Membership test against single-item container 8 8 | 9 9 | if 1 in set({1}): -FURB171_1.py:9:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_1.py:9:4 | 7 | print("Single-element set") 8 | 9 | if 1 in set({1}): - | ^^^^^^^^^^^^^ FURB171 + | ^^^^^^^^^^^^^ 10 | print("Single-element set") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 6 6 | if 1 in set((1,)): @@ -60,15 +63,16 @@ FURB171_1.py:9:4: FURB171 [*] Membership test against single-item container 11 11 | 12 12 | if 1 in frozenset([1]): -FURB171_1.py:12:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_1.py:12:4 | 10 | print("Single-element set") 11 | 12 | if 1 in frozenset([1]): - | ^^^^^^^^^^^^^^^^^^^ FURB171 + | ^^^^^^^^^^^^^^^^^^^ 13 | print("Single-element set") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 9 9 | if 1 in set({1}): @@ -80,15 +84,16 @@ FURB171_1.py:12:4: FURB171 [*] Membership test against single-item container 14 14 | 15 15 | if 1 in frozenset((1,)): -FURB171_1.py:15:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_1.py:15:4 | 13 | print("Single-element set") 14 | 15 | if 1 in frozenset((1,)): - | ^^^^^^^^^^^^^^^^^^^^ FURB171 + | ^^^^^^^^^^^^^^^^^^^^ 16 | print("Single-element set") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 12 12 | if 1 in frozenset([1]): @@ -100,15 +105,16 @@ FURB171_1.py:15:4: FURB171 [*] Membership test against single-item container 17 17 | 18 18 | if 1 in frozenset({1}): -FURB171_1.py:18:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_1.py:18:4 | 16 | print("Single-element set") 17 | 18 | if 1 in frozenset({1}): - | ^^^^^^^^^^^^^^^^^^^ FURB171 + | ^^^^^^^^^^^^^^^^^^^ 19 | print("Single-element set") | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 15 15 | if 1 in frozenset((1,)): @@ -120,15 +126,16 @@ FURB171_1.py:18:4: FURB171 [*] Membership test against single-item container 20 20 | 21 21 | if 1 in set(set([1])): -FURB171_1.py:21:4: FURB171 [*] Membership test against single-item container +FURB171 [*] Membership test against single-item container + --> FURB171_1.py:21:4 | 19 | print("Single-element set") 20 | 21 | if 1 in set(set([1])): - | ^^^^^^^^^^^^^^^^^^ FURB171 + | ^^^^^^^^^^^^^^^^^^ 22 | print('Recursive solution') | - = help: Convert to equality test +help: Convert to equality test ℹ Safe fix 18 18 | if 1 in frozenset({1}): diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB177_FURB177.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB177_FURB177.py.snap index 567479ed72..d93305cf69 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB177_FURB177.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB177_FURB177.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB177.py:5:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:5:5 | 4 | # Errors 5 | _ = Path().resolve() - | ^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^ 6 | _ = pathlib.Path().resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 2 2 | from pathlib import Path @@ -20,16 +21,17 @@ FURB177.py:5:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for curr 7 7 | 8 8 | _ = Path("").resolve() -FURB177.py:6:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:6:5 | 4 | # Errors 5 | _ = Path().resolve() 6 | _ = pathlib.Path().resolve() - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | _ = Path("").resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 3 3 | @@ -41,15 +43,16 @@ FURB177.py:6:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for curr 8 8 | _ = Path("").resolve() 9 9 | _ = pathlib.Path("").resolve() -FURB177.py:8:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:8:5 | 6 | _ = pathlib.Path().resolve() 7 | 8 | _ = Path("").resolve() - | ^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^ 9 | _ = pathlib.Path("").resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 5 5 | _ = Path().resolve() @@ -61,15 +64,16 @@ FURB177.py:8:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for curr 10 10 | 11 11 | _ = Path(".").resolve() -FURB177.py:9:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:9:5 | 8 | _ = Path("").resolve() 9 | _ = pathlib.Path("").resolve() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | _ = Path(".").resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 6 6 | _ = pathlib.Path().resolve() @@ -81,15 +85,16 @@ FURB177.py:9:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for curr 11 11 | _ = Path(".").resolve() 12 12 | _ = pathlib.Path(".").resolve() -FURB177.py:11:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:11:5 | 9 | _ = pathlib.Path("").resolve() 10 | 11 | _ = Path(".").resolve() - | ^^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^^ 12 | _ = pathlib.Path(".").resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 8 8 | _ = Path("").resolve() @@ -101,15 +106,16 @@ FURB177.py:11:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur 13 13 | 14 14 | _ = Path("", **kwargs).resolve() -FURB177.py:12:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:12:5 | 11 | _ = Path(".").resolve() 12 | _ = pathlib.Path(".").resolve() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | 14 | _ = Path("", **kwargs).resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 9 9 | _ = pathlib.Path("").resolve() @@ -121,15 +127,16 @@ FURB177.py:12:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur 14 14 | _ = Path("", **kwargs).resolve() 15 15 | _ = pathlib.Path("", **kwargs).resolve() -FURB177.py:14:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:14:5 | 12 | _ = pathlib.Path(".").resolve() 13 | 14 | _ = Path("", **kwargs).resolve() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | _ = pathlib.Path("", **kwargs).resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 11 11 | _ = Path(".").resolve() @@ -141,15 +148,16 @@ FURB177.py:14:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur 16 16 | 17 17 | _ = Path(".", **kwargs).resolve() -FURB177.py:15:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:15:5 | 14 | _ = Path("", **kwargs).resolve() 15 | _ = pathlib.Path("", **kwargs).resolve() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 16 | 17 | _ = Path(".", **kwargs).resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 12 12 | _ = pathlib.Path(".").resolve() @@ -161,15 +169,16 @@ FURB177.py:15:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur 17 17 | _ = Path(".", **kwargs).resolve() 18 18 | _ = pathlib.Path(".", **kwargs).resolve() -FURB177.py:17:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:17:5 | 15 | _ = pathlib.Path("", **kwargs).resolve() 16 | 17 | _ = Path(".", **kwargs).resolve() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | _ = pathlib.Path(".", **kwargs).resolve() | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 14 14 | _ = Path("", **kwargs).resolve() @@ -181,15 +190,16 @@ FURB177.py:17:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for cur 19 19 | 20 20 | # OK -FURB177.py:18:5: FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups +FURB177 [*] Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups + --> FURB177.py:18:5 | 17 | _ = Path(".", **kwargs).resolve() 18 | _ = pathlib.Path(".", **kwargs).resolve() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB177 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # OK | - = help: Replace `Path().resolve()` with `Path.cwd()` +help: Replace `Path().resolve()` with `Path.cwd()` ℹ Unsafe fix 15 15 | _ = pathlib.Path("", **kwargs).resolve() diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap index d351d92f93..5461e27403 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB180_FURB180.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB180.py:7:10: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class +FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class + --> FURB180.py:7:10 | 5 | # Errors 6 | 7 | class A0(metaclass=abc.ABCMeta): - | ^^^^^^^^^^^^^^^^^^^^^ FURB180 + | ^^^^^^^^^^^^^^^^^^^^^ 8 | @abstractmethod 9 | def foo(self): pass | - = help: Replace with `abc.ABC` +help: Replace with `abc.ABC` ℹ Safe fix 4 4 | @@ -22,14 +23,15 @@ FURB180.py:7:10: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract b 9 9 | def foo(self): pass 10 10 | -FURB180.py:12:10: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class +FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class + --> FURB180.py:12:10 | 12 | class A1(metaclass=ABCMeta): - | ^^^^^^^^^^^^^^^^^ FURB180 + | ^^^^^^^^^^^^^^^^^ 13 | @abstractmethod 14 | def foo(self): pass | - = help: Replace with `abc.ABC` +help: Replace with `abc.ABC` ℹ Safe fix 9 9 | def foo(self): pass @@ -41,14 +43,15 @@ FURB180.py:12:10: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract 14 14 | def foo(self): pass 15 15 | -FURB180.py:26:18: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class +FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class + --> FURB180.py:26:18 | 26 | class A2(B0, B1, metaclass=ABCMeta): - | ^^^^^^^^^^^^^^^^^ FURB180 + | ^^^^^^^^^^^^^^^^^ 27 | @abstractmethod 28 | def foo(self): pass | - = help: Replace with `abc.ABC` +help: Replace with `abc.ABC` ℹ Unsafe fix 23 23 | pass @@ -60,13 +63,14 @@ FURB180.py:26:18: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract 28 28 | def foo(self): pass 29 29 | -FURB180.py:31:34: FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class +FURB180 [*] Use of `metaclass=abc.ABCMeta` to define abstract base class + --> FURB180.py:31:34 | 31 | class A3(B0, before_metaclass=1, metaclass=abc.ABCMeta): - | ^^^^^^^^^^^^^^^^^^^^^ FURB180 + | ^^^^^^^^^^^^^^^^^^^^^ 32 | pass | - = help: Replace with `abc.ABC` +help: Replace with `abc.ABC` ℹ Unsafe fix 28 28 | def foo(self): pass diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap index 82cea760ea..8bf362eba6 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB181_FURB181.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB181.py:19:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:19:1 | 17 | # these will match 18 | 19 | blake2b().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 20 | blake2s().digest().hex() 21 | md5().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 16 16 | @@ -22,15 +23,16 @@ FURB181.py:19:1: FURB181 [*] Use of hashlib's `.digest().hex()` 21 21 | md5().digest().hex() 22 22 | sha1().digest().hex() -FURB181.py:20:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:20:1 | 19 | blake2b().digest().hex() 20 | blake2s().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 21 | md5().digest().hex() 22 | sha1().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 17 17 | # these will match @@ -42,16 +44,17 @@ FURB181.py:20:1: FURB181 [*] Use of hashlib's `.digest().hex()` 22 22 | sha1().digest().hex() 23 23 | sha224().digest().hex() -FURB181.py:21:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:21:1 | 19 | blake2b().digest().hex() 20 | blake2s().digest().hex() 21 | md5().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^ 22 | sha1().digest().hex() 23 | sha224().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 18 18 | @@ -63,16 +66,17 @@ FURB181.py:21:1: FURB181 [*] Use of hashlib's `.digest().hex()` 23 23 | sha224().digest().hex() 24 24 | sha256().digest().hex() -FURB181.py:22:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:22:1 | 20 | blake2s().digest().hex() 21 | md5().digest().hex() 22 | sha1().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^ 23 | sha224().digest().hex() 24 | sha256().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 19 19 | blake2b().digest().hex() @@ -84,16 +88,17 @@ FURB181.py:22:1: FURB181 [*] Use of hashlib's `.digest().hex()` 24 24 | sha256().digest().hex() 25 25 | sha384().digest().hex() -FURB181.py:23:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:23:1 | 21 | md5().digest().hex() 22 | sha1().digest().hex() 23 | sha224().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^ 24 | sha256().digest().hex() 25 | sha384().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 20 20 | blake2s().digest().hex() @@ -105,16 +110,17 @@ FURB181.py:23:1: FURB181 [*] Use of hashlib's `.digest().hex()` 25 25 | sha384().digest().hex() 26 26 | sha3_224().digest().hex() -FURB181.py:24:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:24:1 | 22 | sha1().digest().hex() 23 | sha224().digest().hex() 24 | sha256().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^ 25 | sha384().digest().hex() 26 | sha3_224().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 21 21 | md5().digest().hex() @@ -126,16 +132,17 @@ FURB181.py:24:1: FURB181 [*] Use of hashlib's `.digest().hex()` 26 26 | sha3_224().digest().hex() 27 27 | sha3_256().digest().hex() -FURB181.py:25:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:25:1 | 23 | sha224().digest().hex() 24 | sha256().digest().hex() 25 | sha384().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^ 26 | sha3_224().digest().hex() 27 | sha3_256().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 22 22 | sha1().digest().hex() @@ -147,16 +154,17 @@ FURB181.py:25:1: FURB181 [*] Use of hashlib's `.digest().hex()` 27 27 | sha3_256().digest().hex() 28 28 | sha3_384().digest().hex() -FURB181.py:26:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:26:1 | 24 | sha256().digest().hex() 25 | sha384().digest().hex() 26 | sha3_224().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | sha3_256().digest().hex() 28 | sha3_384().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 23 23 | sha224().digest().hex() @@ -168,16 +176,17 @@ FURB181.py:26:1: FURB181 [*] Use of hashlib's `.digest().hex()` 28 28 | sha3_384().digest().hex() 29 29 | sha3_512().digest().hex() -FURB181.py:27:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:27:1 | 25 | sha384().digest().hex() 26 | sha3_224().digest().hex() 27 | sha3_256().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | sha3_384().digest().hex() 29 | sha3_512().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 24 24 | sha256().digest().hex() @@ -189,16 +198,17 @@ FURB181.py:27:1: FURB181 [*] Use of hashlib's `.digest().hex()` 29 29 | sha3_512().digest().hex() 30 30 | sha512().digest().hex() -FURB181.py:28:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:28:1 | 26 | sha3_224().digest().hex() 27 | sha3_256().digest().hex() 28 | sha3_384().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | sha3_512().digest().hex() 30 | sha512().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 25 25 | sha384().digest().hex() @@ -210,16 +220,17 @@ FURB181.py:28:1: FURB181 [*] Use of hashlib's `.digest().hex()` 30 30 | sha512().digest().hex() 31 31 | shake_128().digest(10).hex() -FURB181.py:29:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:29:1 | 27 | sha3_256().digest().hex() 28 | sha3_384().digest().hex() 29 | sha3_512().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | sha512().digest().hex() 31 | shake_128().digest(10).hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 26 26 | sha3_224().digest().hex() @@ -231,16 +242,17 @@ FURB181.py:29:1: FURB181 [*] Use of hashlib's `.digest().hex()` 31 31 | shake_128().digest(10).hex() 32 32 | shake_256().digest(10).hex() -FURB181.py:30:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:30:1 | 28 | sha3_384().digest().hex() 29 | sha3_512().digest().hex() 30 | sha512().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^ 31 | shake_128().digest(10).hex() 32 | shake_256().digest(10).hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 27 27 | sha3_256().digest().hex() @@ -252,37 +264,40 @@ FURB181.py:30:1: FURB181 [*] Use of hashlib's `.digest().hex()` 32 32 | shake_256().digest(10).hex() 33 33 | -FURB181.py:31:1: FURB181 Use of hashlib's `.digest().hex()` +FURB181 Use of hashlib's `.digest().hex()` + --> FURB181.py:31:1 | 29 | sha3_512().digest().hex() 30 | sha512().digest().hex() 31 | shake_128().digest(10).hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | shake_256().digest(10).hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` -FURB181.py:32:1: FURB181 Use of hashlib's `.digest().hex()` +FURB181 Use of hashlib's `.digest().hex()` + --> FURB181.py:32:1 | 30 | sha512().digest().hex() 31 | shake_128().digest(10).hex() 32 | shake_256().digest(10).hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | 34 | hashlib.sha256().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` -FURB181.py:34:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:34:1 | 32 | shake_256().digest(10).hex() 33 | 34 | hashlib.sha256().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | sha256(b"text").digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 31 31 | shake_128().digest(10).hex() @@ -294,16 +309,17 @@ FURB181.py:34:1: FURB181 [*] Use of hashlib's `.digest().hex()` 36 36 | sha256(b"text").digest().hex() 37 37 | -FURB181.py:36:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:36:1 | 34 | hashlib.sha256().digest().hex() 35 | 36 | sha256(b"text").digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | 38 | hash_algo().digest().hex() | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 33 33 | @@ -315,16 +331,17 @@ FURB181.py:36:1: FURB181 [*] Use of hashlib's `.digest().hex()` 38 38 | hash_algo().digest().hex() 39 39 | -FURB181.py:38:1: FURB181 [*] Use of hashlib's `.digest().hex()` +FURB181 [*] Use of hashlib's `.digest().hex()` + --> FURB181.py:38:1 | 36 | sha256(b"text").digest().hex() 37 | 38 | hash_algo().digest().hex() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB181 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 39 | 40 | # not yet supported | - = help: Replace with `.hexdigest()` +help: Replace with `.hexdigest()` ℹ Safe fix 35 35 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB187_FURB187.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB187_FURB187.py.snap index 8da31baa69..4287365e6a 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB187_FURB187.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB187_FURB187.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- -FURB187.py:6:5: FURB187 [*] Use of assignment of `reversed` on list `l` +FURB187 [*] Use of assignment of `reversed` on list `l` + --> FURB187.py:6:5 | 4 | def a(): 5 | l = [] 6 | l = reversed(l) - | ^^^^^^^^^^^^^^^ FURB187 + | ^^^^^^^^^^^^^^^ | - = help: Replace with `l.reverse()` +help: Replace with `l.reverse()` ℹ Unsafe fix 3 3 | @@ -21,14 +21,15 @@ FURB187.py:6:5: FURB187 [*] Use of assignment of `reversed` on list `l` 8 8 | 9 9 | def b(): -FURB187.py:11:5: FURB187 [*] Use of assignment of `reversed` on list `l` +FURB187 [*] Use of assignment of `reversed` on list `l` + --> FURB187.py:11:5 | 9 | def b(): 10 | l = [] 11 | l = list(reversed(l)) - | ^^^^^^^^^^^^^^^^^^^^^ FURB187 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `l.reverse()` +help: Replace with `l.reverse()` ℹ Unsafe fix 8 8 | @@ -40,14 +41,15 @@ FURB187.py:11:5: FURB187 [*] Use of assignment of `reversed` on list `l` 13 13 | 14 14 | def c(): -FURB187.py:16:5: FURB187 [*] Use of assignment of `reversed` on list `l` +FURB187 [*] Use of assignment of `reversed` on list `l` + --> FURB187.py:16:5 | 14 | def c(): 15 | l = [] 16 | l = l[::-1] - | ^^^^^^^^^^^ FURB187 + | ^^^^^^^^^^^ | - = help: Replace with `l.reverse()` +help: Replace with `l.reverse()` ℹ Unsafe fix 13 13 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB188_FURB188.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB188_FURB188.py.snap index 70966a24be..6231a0d701 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB188_FURB188.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB188_FURB188.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB188.py:7:5: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. + --> FURB188.py:7:5 | 6 | def remove_extension_via_slice(filename: str) -> str: 7 | / if filename.endswith(".txt"): 8 | | filename = filename[:-4] - | |________________________________^ FURB188 + | |________________________________^ 9 | 10 | return filename | - = help: Use removesuffix instead of assignment conditional upon endswith. +help: Use removesuffix instead of assignment conditional upon endswith. ℹ Safe fix 4 4 | # these should match @@ -23,16 +24,17 @@ FURB188.py:7:5: FURB188 [*] Prefer `str.removesuffix()` over conditionally repla 10 9 | return filename 11 10 | -FURB188.py:14:5: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. + --> FURB188.py:14:5 | 13 | def remove_extension_via_slice_len(filename: str, extension: str) -> str: 14 | / if filename.endswith(extension): 15 | | filename = filename[:-len(extension)] - | |_____________________________________________^ FURB188 + | |_____________________________________________^ 16 | 17 | return filename | - = help: Use removesuffix instead of assignment conditional upon endswith. +help: Use removesuffix instead of assignment conditional upon endswith. ℹ Safe fix 11 11 | @@ -45,13 +47,14 @@ FURB188.py:14:5: FURB188 [*] Prefer `str.removesuffix()` over conditionally repl 17 16 | return filename 18 17 | -FURB188.py:21:12: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. + --> FURB188.py:21:12 | 20 | def remove_extension_via_ternary(filename: str) -> str: 21 | return filename[:-4] if filename.endswith(".txt") else filename - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use removesuffix instead of ternary expression conditional upon endswith. +help: Use removesuffix instead of ternary expression conditional upon endswith. ℹ Safe fix 18 18 | @@ -63,13 +66,14 @@ FURB188.py:21:12: FURB188 [*] Prefer `str.removesuffix()` over conditionally rep 23 23 | 24 24 | def remove_extension_via_ternary_with_len(filename: str, extension: str) -> str: -FURB188.py:25:12: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. + --> FURB188.py:25:12 | 24 | def remove_extension_via_ternary_with_len(filename: str, extension: str) -> str: 25 | return filename[:-len(extension)] if filename.endswith(extension) else filename - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use removesuffix instead of ternary expression conditional upon endswith. +help: Use removesuffix instead of ternary expression conditional upon endswith. ℹ Safe fix 22 22 | @@ -81,13 +85,14 @@ FURB188.py:25:12: FURB188 [*] Prefer `str.removesuffix()` over conditionally rep 27 27 | 28 28 | def remove_prefix(filename: str) -> str: -FURB188.py:29:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:29:12 | 28 | def remove_prefix(filename: str) -> str: 29 | return filename[4:] if filename.startswith("abc-") else filename - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use removeprefix instead of ternary expression conditional upon startswith. +help: Use removeprefix instead of ternary expression conditional upon startswith. ℹ Safe fix 26 26 | @@ -99,13 +104,14 @@ FURB188.py:29:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep 31 31 | 32 32 | def remove_prefix_via_len(filename: str, prefix: str) -> str: -FURB188.py:33:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:33:12 | 32 | def remove_prefix_via_len(filename: str, prefix: str) -> str: 33 | return filename[len(prefix):] if filename.startswith(prefix) else filename - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use removeprefix instead of ternary expression conditional upon startswith. +help: Use removeprefix instead of ternary expression conditional upon startswith. ℹ Safe fix 30 30 | @@ -117,16 +123,17 @@ FURB188.py:33:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep 35 35 | 36 36 | # these should not -FURB188.py:146:9: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. + --> FURB188.py:146:9 | 144 | SUFFIX = "suffix" 145 | 146 | x = foo.bar.baz[:-len(SUFFIX)] if foo.bar.baz.endswith(SUFFIX) else foo.bar.baz - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 147 | 148 | def remove_prefix_comparable_literal_expr() -> None: | - = help: Use removesuffix instead of ternary expression conditional upon endswith. +help: Use removesuffix instead of ternary expression conditional upon endswith. ℹ Safe fix 143 143 | @@ -138,15 +145,16 @@ FURB188.py:146:9: FURB188 [*] Prefer `str.removesuffix()` over conditionally rep 148 148 | def remove_prefix_comparable_literal_expr() -> None: 149 149 | return ("abc" "def")[3:] if ("abc" "def").startswith("abc") else "abc" "def" -FURB188.py:149:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:149:12 | 148 | def remove_prefix_comparable_literal_expr() -> None: 149 | return ("abc" "def")[3:] if ("abc" "def").startswith("abc") else "abc" "def" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 150 | 151 | def shadow_builtins(filename: str, extension: str) -> None: | - = help: Use removeprefix instead of ternary expression conditional upon startswith. +help: Use removeprefix instead of ternary expression conditional upon startswith. ℹ Safe fix 146 146 | x = foo.bar.baz[:-len(SUFFIX)] if foo.bar.baz.endswith(SUFFIX) else foo.bar.baz @@ -158,16 +166,17 @@ FURB188.py:149:12: FURB188 [*] Prefer `str.removeprefix()` over conditionally re 151 151 | def shadow_builtins(filename: str, extension: str) -> None: 152 152 | from builtins import len as builtins_len -FURB188.py:154:12: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. + --> FURB188.py:154:12 | 152 | from builtins import len as builtins_len 153 | 154 | return filename[:-builtins_len(extension)] if filename.endswith(extension) else filename - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB188 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 155 | 156 | def okay_steps(): | - = help: Use removesuffix instead of ternary expression conditional upon endswith. +help: Use removesuffix instead of ternary expression conditional upon endswith. ℹ Safe fix 151 151 | def shadow_builtins(filename: str, extension: str) -> None: @@ -179,17 +188,18 @@ FURB188.py:154:12: FURB188 [*] Prefer `str.removesuffix()` over conditionally re 156 156 | def okay_steps(): 157 157 | text = "!x!y!z" -FURB188.py:158:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:158:5 | 156 | def okay_steps(): 157 | text = "!x!y!z" 158 | / if text.startswith("!"): 159 | | text = text[1::1] - | |_________________________^ FURB188 + | |_________________________^ 160 | if text.startswith("!"): 161 | text = text[1::True] | - = help: Use removeprefix instead of assignment conditional upon startswith. +help: Use removeprefix instead of assignment conditional upon startswith. ℹ Safe fix 155 155 | @@ -202,17 +212,18 @@ FURB188.py:158:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep 161 160 | text = text[1::True] 162 161 | if text.startswith("!"): -FURB188.py:160:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:160:5 | 158 | if text.startswith("!"): 159 | text = text[1::1] 160 | / if text.startswith("!"): 161 | | text = text[1::True] - | |____________________________^ FURB188 + | |____________________________^ 162 | if text.startswith("!"): 163 | text = text[1::None] | - = help: Use removeprefix instead of assignment conditional upon startswith. +help: Use removeprefix instead of assignment conditional upon startswith. ℹ Safe fix 157 157 | text = "!x!y!z" @@ -225,16 +236,17 @@ FURB188.py:160:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep 163 162 | text = text[1::None] 164 163 | print(text) -FURB188.py:162:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:162:5 | 160 | if text.startswith("!"): 161 | text = text[1::True] 162 | / if text.startswith("!"): 163 | | text = text[1::None] - | |____________________________^ FURB188 + | |____________________________^ 164 | print(text) | - = help: Use removeprefix instead of assignment conditional upon startswith. +help: Use removeprefix instead of assignment conditional upon startswith. ℹ Safe fix 159 159 | text = text[1::1] @@ -247,15 +259,16 @@ FURB188.py:162:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep 165 164 | 166 165 | -FURB188.py:183:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:183:5 | 181 | # with fix `text = text.removeprefix("ř")` 182 | text = "řetězec" 183 | / if text.startswith("ř"): 184 | | text = text[1:] - | |_______________________^ FURB188 + | |_______________________^ | - = help: Use removeprefix instead of assignment conditional upon startswith. +help: Use removeprefix instead of assignment conditional upon startswith. ℹ Safe fix 180 180 | # should be linted @@ -268,17 +281,18 @@ FURB188.py:183:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep 186 185 | 187 186 | def handle_surrogates(): -FURB188.py:190:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:190:5 | 188 | # should be linted 189 | text = "\ud800\udc00heythere" 190 | / if text.startswith("\ud800\udc00"): 191 | | text = text[2:] - | |_______________________^ FURB188 + | |_______________________^ 192 | text = "\U00010000heythere" 193 | if text.startswith("\U00010000"): | - = help: Use removeprefix instead of assignment conditional upon startswith. +help: Use removeprefix instead of assignment conditional upon startswith. ℹ Safe fix 187 187 | def handle_surrogates(): @@ -291,17 +305,18 @@ FURB188.py:190:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep 193 192 | if text.startswith("\U00010000"): 194 193 | text = text[1:] -FURB188.py:193:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removeprefix()` over conditionally replacing with slice. + --> FURB188.py:193:5 | 191 | text = text[2:] 192 | text = "\U00010000heythere" 193 | / if text.startswith("\U00010000"): 194 | | text = text[1:] - | |_______________________^ FURB188 + | |_______________________^ 195 | 196 | # should not be linted | - = help: Use removeprefix instead of assignment conditional upon startswith. +help: Use removeprefix instead of assignment conditional upon startswith. ℹ Safe fix 190 190 | if text.startswith("\ud800\udc00"): @@ -314,16 +329,17 @@ FURB188.py:193:5: FURB188 [*] Prefer `str.removeprefix()` over conditionally rep 196 195 | # should not be linted 197 196 | text = "\ud800\udc00heythere" -FURB188.py:205:5: FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. +FURB188 [*] Prefer `str.removesuffix()` over conditionally replacing with slice. + --> FURB188.py:205:5 | 203 | def func(): 204 | a = "sjdfaskldjfakljklfoo" 205 | / if a.endswith("foo"): 206 | | a = a[: -len("foo")] - | |____________________________^ FURB188 + | |____________________________^ 207 | print(a) | - = help: Use removesuffix instead of assignment conditional upon endswith. +help: Use removesuffix instead of assignment conditional upon endswith. ℹ Safe fix 202 202 | # https://github.com/astral-sh/ruff/issues/16231 diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB189_FURB189.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB189_FURB189.py.snap index 9fc4626b5a..24184590d2 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB189_FURB189.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB189_FURB189.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB189.py:17:9: FURB189 [*] Subclassing `dict` can be error prone, use `collections.UserDict` instead +FURB189 [*] Subclassing `dict` can be error prone, use `collections.UserDict` instead + --> FURB189.py:17:9 | 16 | # positives 17 | class D(dict): - | ^^^^ FURB189 + | ^^^^ 18 | pass | - = help: Replace with `collections.UserDict` +help: Replace with `collections.UserDict` ℹ Unsafe fix 1 1 | # setup @@ -28,15 +29,16 @@ FURB189.py:17:9: FURB189 [*] Subclassing `dict` can be error prone, use `collect 19 19 | 20 20 | class L(list): -FURB189.py:20:9: FURB189 [*] Subclassing `list` can be error prone, use `collections.UserList` instead +FURB189 [*] Subclassing `list` can be error prone, use `collections.UserList` instead + --> FURB189.py:20:9 | 18 | pass 19 | 20 | class L(list): - | ^^^^ FURB189 + | ^^^^ 21 | pass | - = help: Replace with `collections.UserList` +help: Replace with `collections.UserList` ℹ Unsafe fix 17 17 | class D(dict): @@ -48,15 +50,16 @@ FURB189.py:20:9: FURB189 [*] Subclassing `list` can be error prone, use `collect 22 22 | 23 23 | class S(str): -FURB189.py:23:9: FURB189 [*] Subclassing `str` can be error prone, use `collections.UserString` instead +FURB189 [*] Subclassing `str` can be error prone, use `collections.UserString` instead + --> FURB189.py:23:9 | 21 | pass 22 | 23 | class S(str): - | ^^^ FURB189 + | ^^^ 24 | pass | - = help: Replace with `collections.UserString` +help: Replace with `collections.UserString` ℹ Unsafe fix 1 1 | # setup @@ -76,15 +79,16 @@ FURB189.py:23:9: FURB189 [*] Subclassing `str` can be error prone, use `collecti 25 25 | 26 26 | class SubscriptDict(dict[str, str]): -FURB189.py:26:21: FURB189 [*] Subclassing `dict` can be error prone, use `collections.UserDict` instead +FURB189 [*] Subclassing `dict` can be error prone, use `collections.UserDict` instead + --> FURB189.py:26:21 | 24 | pass 25 | 26 | class SubscriptDict(dict[str, str]): - | ^^^^ FURB189 + | ^^^^ 27 | pass | - = help: Replace with `collections.UserDict` +help: Replace with `collections.UserDict` ℹ Unsafe fix 1 1 | # setup @@ -104,15 +108,16 @@ FURB189.py:26:21: FURB189 [*] Subclassing `dict` can be error prone, use `collec 28 28 | 29 29 | class SubscriptList(list[str]): -FURB189.py:29:21: FURB189 [*] Subclassing `list` can be error prone, use `collections.UserList` instead +FURB189 [*] Subclassing `list` can be error prone, use `collections.UserList` instead + --> FURB189.py:29:21 | 27 | pass 28 | 29 | class SubscriptList(list[str]): - | ^^^^ FURB189 + | ^^^^ 30 | pass | - = help: Replace with `collections.UserList` +help: Replace with `collections.UserList` ℹ Unsafe fix 26 26 | class SubscriptDict(dict[str, str]): diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap index fdec3718d9..8db1953f8f 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB192_FURB192.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB192.py:3:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence +FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence + --> FURB192.py:3:1 | 1 | # Errors 2 | 3 | sorted(l)[0] - | ^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^ 4 | 5 | sorted(l)[-1] | - = help: Replace with `min` +help: Replace with `min` ℹ Safe fix 1 1 | # Errors @@ -21,16 +22,17 @@ FURB192.py:3:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum 5 5 | sorted(l)[-1] 6 6 | -FURB192.py:5:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence +FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence + --> FURB192.py:5:1 | 3 | sorted(l)[0] 4 | 5 | sorted(l)[-1] - | ^^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^^ 6 | 7 | sorted(l, reverse=False)[-1] | - = help: Replace with `max` +help: Replace with `max` ℹ Safe fix 2 2 | @@ -42,16 +44,17 @@ FURB192.py:5:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum 7 7 | sorted(l, reverse=False)[-1] 8 8 | -FURB192.py:7:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence +FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence + --> FURB192.py:7:1 | 5 | sorted(l)[-1] 6 | 7 | sorted(l, reverse=False)[-1] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | sorted(l, key=lambda x: x)[0] | - = help: Replace with `max` +help: Replace with `max` ℹ Safe fix 4 4 | @@ -63,16 +66,17 @@ FURB192.py:7:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum 9 9 | sorted(l, key=lambda x: x)[0] 10 10 | -FURB192.py:9:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence +FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence + --> FURB192.py:9:1 | 7 | sorted(l, reverse=False)[-1] 8 | 9 | sorted(l, key=lambda x: x)[0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | sorted(l, key=key_fn)[0] | - = help: Replace with `min` +help: Replace with `min` ℹ Safe fix 6 6 | @@ -84,16 +88,17 @@ FURB192.py:9:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum 11 11 | sorted(l, key=key_fn)[0] 12 12 | -FURB192.py:11:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence +FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence + --> FURB192.py:11:1 | 9 | sorted(l, key=lambda x: x)[0] 10 | 11 | sorted(l, key=key_fn)[0] - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | sorted([1, 2, 3])[0] | - = help: Replace with `min` +help: Replace with `min` ℹ Safe fix 8 8 | @@ -105,16 +110,17 @@ FURB192.py:11:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum 13 13 | sorted([1, 2, 3])[0] 14 14 | -FURB192.py:13:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence +FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence + --> FURB192.py:13:1 | 11 | sorted(l, key=key_fn)[0] 12 | 13 | sorted([1, 2, 3])[0] - | ^^^^^^^^^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^^^^^^^^^ 14 | 15 | # Unsafe | - = help: Replace with `min` +help: Replace with `min` ℹ Safe fix 10 10 | @@ -126,16 +132,17 @@ FURB192.py:13:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum 15 15 | # Unsafe 16 16 | -FURB192.py:17:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence +FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence + --> FURB192.py:17:1 | 15 | # Unsafe 16 | 17 | sorted(l, key=key_fn, reverse=True)[-1] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | sorted(l, reverse=True)[0] | - = help: Replace with `min` +help: Replace with `min` ℹ Unsafe fix 14 14 | @@ -147,16 +154,17 @@ FURB192.py:17:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum 19 19 | sorted(l, reverse=True)[0] 20 20 | -FURB192.py:19:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence +FURB192 [*] Prefer `max` over `sorted()` to compute the maximum value in a sequence + --> FURB192.py:19:1 | 17 | sorted(l, key=key_fn, reverse=True)[-1] 18 | 19 | sorted(l, reverse=True)[0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | sorted(l, reverse=True)[-1] | - = help: Replace with `max` +help: Replace with `max` ℹ Unsafe fix 16 16 | @@ -168,16 +176,17 @@ FURB192.py:19:1: FURB192 [*] Prefer `max` over `sorted()` to compute the maximum 21 21 | sorted(l, reverse=True)[-1] 22 22 | -FURB192.py:21:1: FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence +FURB192 [*] Prefer `min` over `sorted()` to compute the minimum value in a sequence + --> FURB192.py:21:1 | 19 | sorted(l, reverse=True)[0] 20 | 21 | sorted(l, reverse=True)[-1] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB192 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | # Non-errors | - = help: Replace with `min` +help: Replace with `min` ℹ Unsafe fix 18 18 | diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__fstring_number_format_python_311.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__fstring_number_format_python_311.snap index 37b1e3aea6..a6796cea74 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__fstring_number_format_python_311.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__fstring_number_format_python_311.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs --- -FURB116.py:9:7: FURB116 Replace `oct` call with `f"{num:o}"` +FURB116 Replace `oct` call with `f"{num:o}"` + --> FURB116.py:9:7 | 7 | return num 8 | 9 | print(oct(num)[2:]) # FURB116 - | ^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^ 10 | print(hex(num)[2:]) # FURB116 11 | print(bin(num)[2:]) # FURB116 | - = help: Replace with `f"{num:o}"` +help: Replace with `f"{num:o}"` ℹ Display-only fix 6 6 | def return_num() -> int: @@ -22,14 +23,15 @@ FURB116.py:9:7: FURB116 Replace `oct` call with `f"{num:o}"` 11 11 | print(bin(num)[2:]) # FURB116 12 12 | -FURB116.py:10:7: FURB116 Replace `hex` call with `f"{num:x}"` +FURB116 Replace `hex` call with `f"{num:x}"` + --> FURB116.py:10:7 | 9 | print(oct(num)[2:]) # FURB116 10 | print(hex(num)[2:]) # FURB116 - | ^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^ 11 | print(bin(num)[2:]) # FURB116 | - = help: Replace with `f"{num:x}"` +help: Replace with `f"{num:x}"` ℹ Display-only fix 7 7 | return num @@ -41,16 +43,17 @@ FURB116.py:10:7: FURB116 Replace `hex` call with `f"{num:x}"` 12 12 | 13 13 | print(oct(1337)[2:]) # FURB116 -FURB116.py:11:7: FURB116 Replace `bin` call with `f"{num:b}"` +FURB116 Replace `bin` call with `f"{num:b}"` + --> FURB116.py:11:7 | 9 | print(oct(num)[2:]) # FURB116 10 | print(hex(num)[2:]) # FURB116 11 | print(bin(num)[2:]) # FURB116 - | ^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^ 12 | 13 | print(oct(1337)[2:]) # FURB116 | - = help: Replace with `f"{num:b}"` +help: Replace with `f"{num:b}"` ℹ Display-only fix 8 8 | @@ -62,16 +65,17 @@ FURB116.py:11:7: FURB116 Replace `bin` call with `f"{num:b}"` 13 13 | print(oct(1337)[2:]) # FURB116 14 14 | print(hex(1337)[2:]) # FURB116 -FURB116.py:13:7: FURB116 [*] Replace `oct` call with `f"{1337:o}"` +FURB116 [*] Replace `oct` call with `f"{1337:o}"` + --> FURB116.py:13:7 | 11 | print(bin(num)[2:]) # FURB116 12 | 13 | print(oct(1337)[2:]) # FURB116 - | ^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^ 14 | print(hex(1337)[2:]) # FURB116 15 | print(bin(1337)[2:]) # FURB116 | - = help: Replace with `f"{1337:o}"` +help: Replace with `f"{1337:o}"` ℹ Safe fix 10 10 | print(hex(num)[2:]) # FURB116 @@ -83,15 +87,16 @@ FURB116.py:13:7: FURB116 [*] Replace `oct` call with `f"{1337:o}"` 15 15 | print(bin(1337)[2:]) # FURB116 16 16 | print(bin(+1337)[2:]) # FURB116 -FURB116.py:14:7: FURB116 [*] Replace `hex` call with `f"{1337:x}"` +FURB116 [*] Replace `hex` call with `f"{1337:x}"` + --> FURB116.py:14:7 | 13 | print(oct(1337)[2:]) # FURB116 14 | print(hex(1337)[2:]) # FURB116 - | ^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^ 15 | print(bin(1337)[2:]) # FURB116 16 | print(bin(+1337)[2:]) # FURB116 | - = help: Replace with `f"{1337:x}"` +help: Replace with `f"{1337:x}"` ℹ Safe fix 11 11 | print(bin(num)[2:]) # FURB116 @@ -103,15 +108,16 @@ FURB116.py:14:7: FURB116 [*] Replace `hex` call with `f"{1337:x}"` 16 16 | print(bin(+1337)[2:]) # FURB116 17 17 | -FURB116.py:15:7: FURB116 [*] Replace `bin` call with `f"{1337:b}"` +FURB116 [*] Replace `bin` call with `f"{1337:b}"` + --> FURB116.py:15:7 | 13 | print(oct(1337)[2:]) # FURB116 14 | print(hex(1337)[2:]) # FURB116 15 | print(bin(1337)[2:]) # FURB116 - | ^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^ 16 | print(bin(+1337)[2:]) # FURB116 | - = help: Replace with `f"{1337:b}"` +help: Replace with `f"{1337:b}"` ℹ Safe fix 12 12 | @@ -123,16 +129,17 @@ FURB116.py:15:7: FURB116 [*] Replace `bin` call with `f"{1337:b}"` 17 17 | 18 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) -FURB116.py:16:7: FURB116 [*] Replace `bin` call with `f"{+1337:b}"` +FURB116 [*] Replace `bin` call with `f"{+1337:b}"` + --> FURB116.py:16:7 | 14 | print(hex(1337)[2:]) # FURB116 15 | print(bin(1337)[2:]) # FURB116 16 | print(bin(+1337)[2:]) # FURB116 - | ^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^ 17 | 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) | - = help: Replace with `f"{+1337:b}"` +help: Replace with `f"{+1337:b}"` ℹ Safe fix 13 13 | print(oct(1337)[2:]) # FURB116 @@ -144,36 +151,39 @@ FURB116.py:16:7: FURB116 [*] Replace `bin` call with `f"{+1337:b}"` 18 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) 19 19 | print(bin(int(f"{num}"))[2:]) # FURB116 (no autofix) -FURB116.py:18:7: FURB116 Replace `bin` call with f-string +FURB116 Replace `bin` call with f-string + --> FURB116.py:18:7 | 16 | print(bin(+1337)[2:]) # FURB116 17 | 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) - | ^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^ 19 | print(bin(int(f"{num}"))[2:]) # FURB116 (no autofix) | - = help: Replace with f-string +help: Replace with f-string -FURB116.py:19:7: FURB116 Replace `bin` call with f-string +FURB116 Replace `bin` call with f-string + --> FURB116.py:19:7 | 18 | print(bin(return_num())[2:]) # FURB116 (no autofix) 19 | print(bin(int(f"{num}"))[2:]) # FURB116 (no autofix) - | ^^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | ## invalid | - = help: Replace with f-string +help: Replace with f-string -FURB116.py:32:7: FURB116 Replace `bin` call with `f"{d:b}"` +FURB116 Replace `bin` call with `f"{d:b}"` + --> FURB116.py:32:7 | 30 | d = datetime.datetime.now(tz=datetime.UTC) 31 | # autofix is display-only 32 | print(bin(d)[2:]) - | ^^^^^^^^^^ FURB116 + | ^^^^^^^^^^ 33 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 34 | print(bin(len("xyz").numerator)[2:]) | - = help: Replace with `f"{d:b}"` +help: Replace with `f"{d:b}"` ℹ Display-only fix 29 29 | @@ -185,26 +195,28 @@ FURB116.py:32:7: FURB116 Replace `bin` call with `f"{d:b}"` 34 34 | print(bin(len("xyz").numerator)[2:]) 35 35 | -FURB116.py:34:7: FURB116 Replace `bin` call with f-string +FURB116 Replace `bin` call with f-string + --> FURB116.py:34:7 | 32 | print(bin(d)[2:]) 33 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 34 | print(bin(len("xyz").numerator)[2:]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 35 | 36 | # autofix is display-only | - = help: Replace with f-string +help: Replace with f-string -FURB116.py:37:7: FURB116 Replace `bin` call with `f"{ {0: 1}[0].numerator:b}"` +FURB116 Replace `bin` call with `f"{ {0: 1}[0].numerator:b}"` + --> FURB116.py:37:7 | 36 | # autofix is display-only 37 | print(bin({0: 1}[0].numerator)[2:]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 39 | print(bin(ord("\\").numerator)[2:]) | - = help: Replace with `f"{ {0: 1}[0].numerator:b}"` +help: Replace with `f"{ {0: 1}[0].numerator:b}"` ℹ Display-only fix 34 34 | print(bin(len("xyz").numerator)[2:]) @@ -216,37 +228,40 @@ FURB116.py:37:7: FURB116 Replace `bin` call with `f"{ {0: 1}[0].numerator:b}"` 39 39 | print(bin(ord("\\").numerator)[2:]) 40 40 | print(hex(sys -FURB116.py:39:7: FURB116 Replace `bin` call with f-string +FURB116 Replace `bin` call with f-string + --> FURB116.py:39:7 | 37 | print(bin({0: 1}[0].numerator)[2:]) 38 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 39 | print(bin(ord("\\").numerator)[2:]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 40 | print(hex(sys 41 | .maxunicode)[2:]) | - = help: Replace with f-string +help: Replace with f-string -FURB116.py:40:7: FURB116 Replace `hex` call with f-string +FURB116 Replace `hex` call with f-string + --> FURB116.py:40:7 | 38 | # no autofix for Python 3.11 and earlier, as it introduces a syntax error 39 | print(bin(ord("\\").numerator)[2:]) 40 | print(hex(sys | _______^ 41 | | .maxunicode)[2:]) - | |________________^ FURB116 + | |________________^ 42 | 43 | # for negatives numbers autofix is display-only | - = help: Replace with f-string +help: Replace with f-string -FURB116.py:44:7: FURB116 Replace `bin` call with `f"{-1:b}"` +FURB116 Replace `bin` call with `f"{-1:b}"` + --> FURB116.py:44:7 | 43 | # for negatives numbers autofix is display-only 44 | print(bin(-1)[2:]) - | ^^^^^^^^^^^ FURB116 + | ^^^^^^^^^^^ | - = help: Replace with `f"{-1:b}"` +help: Replace with `f"{-1:b}"` ℹ Display-only fix 41 41 | .maxunicode)[2:]) diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__write_whole_file_python_39.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__write_whole_file_python_39.snap index 9a82d01f8e..de6a020f87 100644 --- a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__write_whole_file_python_39.snap +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__write_whole_file_python_39.snap @@ -1,87 +1,96 @@ --- source: crates/ruff_linter/src/rules/refurb/mod.rs -snapshot_kind: text --- -FURB103.py:12:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text("test")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text("test")` + --> FURB103.py:12:6 | 11 | # FURB103 12 | with open("file.txt", "w") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | f.write("test") | -FURB103.py:16:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_bytes(foobar)` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_bytes(foobar)` + --> FURB103.py:16:6 | 15 | # FURB103 16 | with open("file.txt", "wb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | f.write(foobar) | -FURB103.py:20:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_bytes(b"abc")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_bytes(b"abc")` + --> FURB103.py:20:6 | 19 | # FURB103 20 | with open("file.txt", mode="wb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | f.write(b"abc") | -FURB103.py:24:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, encoding="utf8")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, encoding="utf8")` + --> FURB103.py:24:6 | 23 | # FURB103 24 | with open("file.txt", "w", encoding="utf8") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | f.write(foobar) | -FURB103.py:28:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, errors="ignore")` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar, errors="ignore")` + --> FURB103.py:28:6 | 27 | # FURB103 28 | with open("file.txt", "w", errors="ignore") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 29 | f.write(foobar) | -FURB103.py:32:6: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar)` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(foobar)` + --> FURB103.py:32:6 | 31 | # FURB103 32 | with open("file.txt", mode="w") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 33 | f.write(foobar) | -FURB103.py:36:6: FURB103 `open` and `write` should be replaced by `Path(foo()).write_bytes(bar())` +FURB103 `open` and `write` should be replaced by `Path(foo()).write_bytes(bar())` + --> FURB103.py:36:6 | 35 | # FURB103 36 | with open(foo(), "wb") as f: - | ^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^ 37 | # The body of `with` is non-trivial, but the recommendation holds. 38 | bar("pre") | -FURB103.py:44:6: FURB103 `open` and `write` should be replaced by `Path("a.txt").write_text(x)` +FURB103 `open` and `write` should be replaced by `Path("a.txt").write_text(x)` + --> FURB103.py:44:6 | 43 | # FURB103 44 | with open("a.txt", "w") as a, open("b.txt", "wb") as b: - | ^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^ 45 | a.write(x) 46 | b.write(y) | -FURB103.py:44:31: FURB103 `open` and `write` should be replaced by `Path("b.txt").write_bytes(y)` +FURB103 `open` and `write` should be replaced by `Path("b.txt").write_bytes(y)` + --> FURB103.py:44:31 | 43 | # FURB103 44 | with open("a.txt", "w") as a, open("b.txt", "wb") as b: - | ^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 45 | a.write(x) 46 | b.write(y) | -FURB103.py:49:18: FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(bar(bar(a + x)))` +FURB103 `open` and `write` should be replaced by `Path("file.txt").write_text(bar(bar(a + x)))` + --> FURB103.py:49:18 | 48 | # FURB103 49 | with foo() as a, open("file.txt", "w") as b, foo() as c: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB103 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | # We have other things in here, multiple with items, but the user 51 | # writes a single time to file and that bit they can replace. | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap index 2617077336..b72fdd934e 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF013_0.py:20:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:20:12 | 20 | def f(arg: int = None): # RUF013 - | ^^^ RUF013 + | ^^^ 21 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 17 17 | pass @@ -20,13 +20,14 @@ RUF013_0.py:20:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 22 22 | 23 23 | -RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:24:12 | 24 | def f(arg: str = None): # RUF013 - | ^^^ RUF013 + | ^^^ 25 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 21 21 | pass @@ -38,13 +39,14 @@ RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 26 26 | 27 27 | -RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:28:12 | 28 | def f(arg: Tuple[str] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 29 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 25 25 | pass @@ -56,13 +58,14 @@ RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 30 30 | 31 31 | -RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:58:12 | 58 | def f(arg: Union = None): # RUF013 - | ^^^^^ RUF013 + | ^^^^^ 59 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 55 55 | pass @@ -74,13 +77,14 @@ RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 60 60 | 61 61 | -RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:62:12 | 62 | def f(arg: Union[int] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 63 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 59 59 | pass @@ -92,13 +96,14 @@ RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 64 64 | 65 65 | -RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:66:12 | 66 | def f(arg: Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^ 67 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 63 63 | pass @@ -110,13 +115,14 @@ RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 68 68 | 69 69 | -RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:85:12 | 85 | def f(arg: int | float = None): # RUF013 - | ^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^ 86 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 82 82 | pass @@ -128,13 +134,14 @@ RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 87 87 | 88 88 | -RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:89:12 | 89 | def f(arg: int | float | str | bytes = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 86 86 | pass @@ -146,13 +153,14 @@ RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 91 91 | 92 92 | -RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:108:12 | 108 | def f(arg: Literal[1] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 109 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 105 105 | pass @@ -164,13 +172,14 @@ RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 110 110 | 111 111 | -RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:112:12 | 112 | def f(arg: Literal[1, "foo"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^ 113 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 109 109 | pass @@ -182,13 +191,14 @@ RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 114 114 | 115 115 | -RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:131:22 | 131 | def f(arg: Annotated[int, ...] = None): # RUF013 - | ^^^ RUF013 + | ^^^ 132 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 128 128 | pass @@ -200,13 +210,14 @@ RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` 133 133 | 134 134 | -RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:135:32 | 135 | def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - | ^^^^^^^^^ RUF013 + | ^^^^^^^^^ 136 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 132 132 | pass @@ -218,15 +229,16 @@ RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` 137 137 | 138 138 | -RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:151:11 | 150 | def f( 151 | arg1: int = None, # RUF013 - | ^^^ RUF013 + | ^^^ 152 | arg2: Union[int, float] = None, # RUF013 153 | arg3: Literal[1, 2, 3] = None, # RUF013 | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 148 148 | @@ -238,16 +250,17 @@ RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 153 153 | arg3: Literal[1, 2, 3] = None, # RUF013 154 154 | ): -RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:152:11 | 150 | def f( 151 | arg1: int = None, # RUF013 152 | arg2: Union[int, float] = None, # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^ 153 | arg3: Literal[1, 2, 3] = None, # RUF013 154 | ): | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 149 149 | @@ -259,16 +272,17 @@ RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 154 154 | ): 155 155 | pass -RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:153:11 | 151 | arg1: int = None, # RUF013 152 | arg2: Union[int, float] = None, # RUF013 153 | arg3: Literal[1, 2, 3] = None, # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^ 154 | ): 155 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 150 150 | def f( @@ -280,13 +294,14 @@ RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 155 155 | pass 156 156 | -RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:181:12 | 181 | def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 182 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 178 178 | pass @@ -298,13 +313,14 @@ RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 183 183 | 184 184 | -RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:188:13 | 188 | def f(arg: "int" = None): # RUF013 - | ^^^ RUF013 + | ^^^ 189 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 185 185 | # Quoted @@ -316,13 +332,14 @@ RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` 190 190 | 191 191 | -RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:192:13 | 192 | def f(arg: "str" = None): # RUF013 - | ^^^ RUF013 + | ^^^ 193 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 189 189 | pass @@ -334,21 +351,23 @@ RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` 194 194 | 195 195 | -RUF013_0.py:196:12: RUF013 PEP 484 prohibits implicit `Optional` +RUF013 PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:196:12 | 196 | def f(arg: "st" "r" = None): # RUF013 - | ^^^^^^^^ RUF013 + | ^^^^^^^^ 197 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` -RUF013_0.py:204:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:204:12 | 204 | def f(arg: Union["int", "str"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^ 205 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 201 201 | pass diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap index cf0db90939..05e593b1d1 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_1.py:4:12 | 4 | def f(arg: int = None): # RUF013 - | ^^^ RUF013 + | ^^^ 5 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 1 1 | # No `typing.Optional` import diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap index 14b7c0d363..e9c0fc8f02 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap @@ -1,31 +1,34 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF005.py:4:1: RUF005 Consider `[*foo]` instead of concatenation +RUF005 Consider `[*foo]` instead of concatenation + --> RUF005.py:4:1 | 2 | # Non-fixable Errors. 3 | ### 4 | / foo + [ # This will be preserved. 5 | | ] - | |_^ RUF005 + | |_^ 6 | [*foo] + [ # This will be preserved. 7 | ] | - = help: Replace with `[*foo]` +help: Replace with `[*foo]` -RUF005.py:6:1: RUF005 Consider `[*foo]` instead of concatenation +RUF005 Consider `[*foo]` instead of concatenation + --> RUF005.py:6:1 | 4 | foo + [ # This will be preserved. 5 | ] 6 | / [*foo] + [ # This will be preserved. 7 | | ] - | |_^ RUF005 + | |_^ 8 | first = [ 9 | # The order | - = help: Replace with `[*foo]` +help: Replace with `[*foo]` -RUF005.py:16:10: RUF005 Consider `[*first, 4, 5, 6]` instead of concatenation +RUF005 Consider `[*first, 4, 5, 6]` instead of concatenation + --> RUF005.py:16:10 | 14 | # to preserve 15 | ] @@ -38,19 +41,20 @@ RUF005.py:16:10: RUF005 Consider `[*first, 4, 5, 6]` instead of concatenation 21 | | # touch 22 | | 6, 23 | | ] - | |_^ RUF005 + | |_^ | - = help: Replace with `[*first, 4, 5, 6]` +help: Replace with `[*first, 4, 5, 6]` -RUF005.py:39:7: RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation +RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation + --> RUF005.py:39:7 | 38 | foo = [4, 5, 6] 39 | bar = [1, 2, 3] + foo - | ^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^ 40 | zoob = tuple(bar) 41 | quux = (7, 8, 9) + zoob | - = help: Replace with `[1, 2, 3, *foo]` +help: Replace with `[1, 2, 3, *foo]` ℹ Unsafe fix 36 36 | yay = Fun().yay @@ -62,16 +66,17 @@ RUF005.py:39:7: RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation 41 41 | quux = (7, 8, 9) + zoob 42 42 | spam = quux + (10, 11, 12) -RUF005.py:41:8: RUF005 [*] Consider `(7, 8, 9, *zoob)` instead of concatenation +RUF005 [*] Consider `(7, 8, 9, *zoob)` instead of concatenation + --> RUF005.py:41:8 | 39 | bar = [1, 2, 3] + foo 40 | zoob = tuple(bar) 41 | quux = (7, 8, 9) + zoob - | ^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^ 42 | spam = quux + (10, 11, 12) 43 | spom = list(spam) | - = help: Replace with `(7, 8, 9, *zoob)` +help: Replace with `(7, 8, 9, *zoob)` ℹ Unsafe fix 38 38 | foo = [4, 5, 6] @@ -83,16 +88,17 @@ RUF005.py:41:8: RUF005 [*] Consider `(7, 8, 9, *zoob)` instead of concatenation 43 43 | spom = list(spam) 44 44 | eggs = spom + [13, 14, 15] -RUF005.py:42:8: RUF005 [*] Consider `(*quux, 10, 11, 12)` instead of concatenation +RUF005 [*] Consider `(*quux, 10, 11, 12)` instead of concatenation + --> RUF005.py:42:8 | 40 | zoob = tuple(bar) 41 | quux = (7, 8, 9) + zoob 42 | spam = quux + (10, 11, 12) - | ^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^ 43 | spom = list(spam) 44 | eggs = spom + [13, 14, 15] | - = help: Replace with `(*quux, 10, 11, 12)` +help: Replace with `(*quux, 10, 11, 12)` ℹ Unsafe fix 39 39 | bar = [1, 2, 3] + foo @@ -104,16 +110,17 @@ RUF005.py:42:8: RUF005 [*] Consider `(*quux, 10, 11, 12)` instead of concatenati 44 44 | eggs = spom + [13, 14, 15] 45 45 | elatement = ("we all say",) + yay() -RUF005.py:44:8: RUF005 [*] Consider `[*spom, 13, 14, 15]` instead of concatenation +RUF005 [*] Consider `[*spom, 13, 14, 15]` instead of concatenation + --> RUF005.py:44:8 | 42 | spam = quux + (10, 11, 12) 43 | spom = list(spam) 44 | eggs = spom + [13, 14, 15] - | ^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^ 45 | elatement = ("we all say",) + yay() 46 | excitement = ("we all think",) + Fun().yay() | - = help: Replace with `[*spom, 13, 14, 15]` +help: Replace with `[*spom, 13, 14, 15]` ℹ Unsafe fix 41 41 | quux = (7, 8, 9) + zoob @@ -125,16 +132,17 @@ RUF005.py:44:8: RUF005 [*] Consider `[*spom, 13, 14, 15]` instead of concatenati 46 46 | excitement = ("we all think",) + Fun().yay() 47 47 | astonishment = ("we all feel",) + Fun.words -RUF005.py:45:13: RUF005 [*] Consider `("we all say", *yay())` instead of concatenation +RUF005 [*] Consider `("we all say", *yay())` instead of concatenation + --> RUF005.py:45:13 | 43 | spom = list(spam) 44 | eggs = spom + [13, 14, 15] 45 | elatement = ("we all say",) + yay() - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^^^^^ 46 | excitement = ("we all think",) + Fun().yay() 47 | astonishment = ("we all feel",) + Fun.words | - = help: Replace with `("we all say", *yay())` +help: Replace with `("we all say", *yay())` ℹ Unsafe fix 42 42 | spam = quux + (10, 11, 12) @@ -146,15 +154,16 @@ RUF005.py:45:13: RUF005 [*] Consider `("we all say", *yay())` instead of concate 47 47 | astonishment = ("we all feel",) + Fun.words 48 48 | -RUF005.py:46:14: RUF005 [*] Consider `("we all think", *Fun().yay())` instead of concatenation +RUF005 [*] Consider `("we all think", *Fun().yay())` instead of concatenation + --> RUF005.py:46:14 | 44 | eggs = spom + [13, 14, 15] 45 | elatement = ("we all say",) + yay() 46 | excitement = ("we all think",) + Fun().yay() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | astonishment = ("we all feel",) + Fun.words | - = help: Replace with `("we all think", *Fun().yay())` +help: Replace with `("we all think", *Fun().yay())` ℹ Unsafe fix 43 43 | spom = list(spam) @@ -166,16 +175,17 @@ RUF005.py:46:14: RUF005 [*] Consider `("we all think", *Fun().yay())` instead of 48 48 | 49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) -RUF005.py:47:16: RUF005 [*] Consider `("we all feel", *Fun.words)` instead of concatenation +RUF005 [*] Consider `("we all feel", *Fun.words)` instead of concatenation + --> RUF005.py:47:16 | 45 | elatement = ("we all say",) + yay() 46 | excitement = ("we all think",) + Fun().yay() 47 | astonishment = ("we all feel",) + Fun.words - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) | - = help: Replace with `("we all feel", *Fun.words)` +help: Replace with `("we all feel", *Fun.words)` ℹ Unsafe fix 44 44 | eggs = spom + [13, 14, 15] @@ -187,16 +197,17 @@ RUF005.py:47:16: RUF005 [*] Consider `("we all feel", *Fun.words)` instead of co 49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) 50 50 | -RUF005.py:49:9: RUF005 [*] Consider iterable unpacking instead of concatenation +RUF005 [*] Consider iterable unpacking instead of concatenation + --> RUF005.py:49:9 | 47 | astonishment = ("we all feel",) + Fun.words 48 | 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | baz = () + zoob | - = help: Replace with iterable unpacking +help: Replace with iterable unpacking ℹ Unsafe fix 46 46 | excitement = ("we all think",) + Fun().yay() @@ -208,16 +219,17 @@ RUF005.py:49:9: RUF005 [*] Consider iterable unpacking instead of concatenation 51 51 | baz = () + zoob 52 52 | -RUF005.py:49:39: RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of concatenation +RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of concatenation + --> RUF005.py:49:39 | 47 | astonishment = ("we all feel",) + Fun.words 48 | 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | baz = () + zoob | - = help: Replace with `("yes", "no", "pants", *zoob)` +help: Replace with `("yes", "no", "pants", *zoob)` ℹ Unsafe fix 46 46 | excitement = ("we all think",) + Fun().yay() @@ -229,16 +241,17 @@ RUF005.py:49:39: RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of 51 51 | baz = () + zoob 52 52 | -RUF005.py:51:7: RUF005 [*] Consider `(*zoob,)` instead of concatenation +RUF005 [*] Consider `(*zoob,)` instead of concatenation + --> RUF005.py:51:7 | 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) 50 | 51 | baz = () + zoob - | ^^^^^^^^^ RUF005 + | ^^^^^^^^^ 52 | 53 | [] + foo + [ | - = help: Replace with `(*zoob,)` +help: Replace with `(*zoob,)` ℹ Unsafe fix 48 48 | @@ -250,17 +263,18 @@ RUF005.py:51:7: RUF005 [*] Consider `(*zoob,)` instead of concatenation 53 53 | [] + foo + [ 54 54 | ] -RUF005.py:53:1: RUF005 [*] Consider `[*foo]` instead of concatenation +RUF005 [*] Consider `[*foo]` instead of concatenation + --> RUF005.py:53:1 | 51 | baz = () + zoob 52 | 53 | / [] + foo + [ 54 | | ] - | |_^ RUF005 + | |_^ 55 | 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] | - = help: Replace with `[*foo]` +help: Replace with `[*foo]` ℹ Unsafe fix 50 50 | @@ -273,16 +287,17 @@ RUF005.py:53:1: RUF005 [*] Consider `[*foo]` instead of concatenation 56 55 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] 57 56 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) -RUF005.py:56:15: RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, path]` instead of concatenation +RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, path]` instead of concatenation + --> RUF005.py:56:15 | 54 | ] 55 | 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) 58 | b = a + [2, 3] + [4] | - = help: Replace with `[sys.executable, "-m", "pylint", *args, path]` +help: Replace with `[sys.executable, "-m", "pylint", *args, path]` ℹ Unsafe fix 53 53 | [] + foo + [ @@ -294,14 +309,15 @@ RUF005.py:56:15: RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, pa 58 58 | b = a + [2, 3] + [4] 59 59 | -RUF005.py:57:21: RUF005 [*] Consider iterable unpacking instead of concatenation +RUF005 [*] Consider iterable unpacking instead of concatenation + --> RUF005.py:57:21 | 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 58 | b = a + [2, 3] + [4] | - = help: Replace with iterable unpacking +help: Replace with iterable unpacking ℹ Unsafe fix 54 54 | ] @@ -313,16 +329,17 @@ RUF005.py:57:21: RUF005 [*] Consider iterable unpacking instead of concatenation 59 59 | 60 60 | # Uses the non-preferred quote style, which should be retained. -RUF005.py:58:5: RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation +RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation + --> RUF005.py:58:5 | 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) 58 | b = a + [2, 3] + [4] - | ^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^ 59 | 60 | # Uses the non-preferred quote style, which should be retained. | - = help: Replace with `[*a, 2, 3, 4]` +help: Replace with `[*a, 2, 3, 4]` ℹ Unsafe fix 55 55 | @@ -334,15 +351,16 @@ RUF005.py:58:5: RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation 60 60 | # Uses the non-preferred quote style, which should be retained. 61 61 | f"{a() + ['b']}" -RUF005.py:61:4: RUF005 [*] Consider `[*a(), 'b']` instead of concatenation +RUF005 [*] Consider `[*a(), 'b']` instead of concatenation + --> RUF005.py:61:4 | 60 | # Uses the non-preferred quote style, which should be retained. 61 | f"{a() + ['b']}" - | ^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^ 62 | 63 | ### | - = help: Replace with `[*a(), 'b']` +help: Replace with `[*a(), 'b']` ℹ Unsafe fix 58 58 | b = a + [2, 3] + [4] diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005_slices.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005_slices.py.snap index 25a182d790..3b32b1c582 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005_slices.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005_slices.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF005_slices.py:2:7: RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation +RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation + --> RUF005_slices.py:2:7 | 1 | foo = [4, 5, 6] 2 | bar = [1, 2, 3] + foo - | ^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^ 3 | slicing1 = foo[:1] + [7, 8, 9] 4 | slicing2 = [7, 8, 9] + bar[1:] | - = help: Replace with `[1, 2, 3, *foo]` +help: Replace with `[1, 2, 3, *foo]` ℹ Unsafe fix 1 1 | foo = [4, 5, 6] @@ -19,16 +20,17 @@ RUF005_slices.py:2:7: RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatena 4 4 | slicing2 = [7, 8, 9] + bar[1:] 5 5 | slicing3 = foo[:1] + [7, 8, 9] + bar[1:] -RUF005_slices.py:3:12: RUF005 [*] Consider `[*foo[:1], 7, 8, 9]` instead of concatenation +RUF005 [*] Consider `[*foo[:1], 7, 8, 9]` instead of concatenation + --> RUF005_slices.py:3:12 | 1 | foo = [4, 5, 6] 2 | bar = [1, 2, 3] + foo 3 | slicing1 = foo[:1] + [7, 8, 9] - | ^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^ 4 | slicing2 = [7, 8, 9] + bar[1:] 5 | slicing3 = foo[:1] + [7, 8, 9] + bar[1:] | - = help: Replace with `[*foo[:1], 7, 8, 9]` +help: Replace with `[*foo[:1], 7, 8, 9]` ℹ Unsafe fix 1 1 | foo = [4, 5, 6] @@ -39,16 +41,17 @@ RUF005_slices.py:3:12: RUF005 [*] Consider `[*foo[:1], 7, 8, 9]` instead of conc 5 5 | slicing3 = foo[:1] + [7, 8, 9] + bar[1:] 6 6 | indexing = foo[0] + [7, 8, 9] + bar[1] # Not changed; looks a little suspect for concatenation. -RUF005_slices.py:4:12: RUF005 [*] Consider `[7, 8, 9, *bar[1:]]` instead of concatenation +RUF005 [*] Consider `[7, 8, 9, *bar[1:]]` instead of concatenation + --> RUF005_slices.py:4:12 | 2 | bar = [1, 2, 3] + foo 3 | slicing1 = foo[:1] + [7, 8, 9] 4 | slicing2 = [7, 8, 9] + bar[1:] - | ^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^ 5 | slicing3 = foo[:1] + [7, 8, 9] + bar[1:] 6 | indexing = foo[0] + [7, 8, 9] + bar[1] # Not changed; looks a little suspect for concatenation. | - = help: Replace with `[7, 8, 9, *bar[1:]]` +help: Replace with `[7, 8, 9, *bar[1:]]` ℹ Unsafe fix 1 1 | foo = [4, 5, 6] @@ -59,15 +62,16 @@ RUF005_slices.py:4:12: RUF005 [*] Consider `[7, 8, 9, *bar[1:]]` instead of conc 5 5 | slicing3 = foo[:1] + [7, 8, 9] + bar[1:] 6 6 | indexing = foo[0] + [7, 8, 9] + bar[1] # Not changed; looks a little suspect for concatenation. -RUF005_slices.py:5:12: RUF005 [*] Consider `[*foo[:1], 7, 8, 9, *bar[1:]]` instead of concatenation +RUF005 [*] Consider `[*foo[:1], 7, 8, 9, *bar[1:]]` instead of concatenation + --> RUF005_slices.py:5:12 | 3 | slicing1 = foo[:1] + [7, 8, 9] 4 | slicing2 = [7, 8, 9] + bar[1:] 5 | slicing3 = foo[:1] + [7, 8, 9] + bar[1:] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | indexing = foo[0] + [7, 8, 9] + bar[1] # Not changed; looks a little suspect for concatenation. | - = help: Replace with `[*foo[:1], 7, 8, 9, *bar[1:]]` +help: Replace with `[*foo[:1], 7, 8, 9, *bar[1:]]` ℹ Unsafe fix 2 2 | bar = [1, 2, 3] + foo diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap index 1df2682c60..65efeca6a0 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap @@ -1,72 +1,80 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF006.py:6:5: RUF006 Store a reference to the return value of `asyncio.create_task` +RUF006 Store a reference to the return value of `asyncio.create_task` + --> RUF006.py:6:5 | 4 | # Error 5 | def f(): 6 | asyncio.create_task(coordinator.ws_connect()) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -RUF006.py:11:5: RUF006 Store a reference to the return value of `asyncio.ensure_future` +RUF006 Store a reference to the return value of `asyncio.ensure_future` + --> RUF006.py:11:5 | 9 | # Error 10 | def f(): 11 | asyncio.ensure_future(coordinator.ws_connect()) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -RUF006.py:68:12: RUF006 Store a reference to the return value of `asyncio.create_task` +RUF006 Store a reference to the return value of `asyncio.create_task` + --> RUF006.py:68:12 | 66 | # Error 67 | def f(): 68 | task = asyncio.create_task(coordinator.ws_connect()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -RUF006.py:74:26: RUF006 Store a reference to the return value of `loop.create_task` +RUF006 Store a reference to the return value of `loop.create_task` + --> RUF006.py:74:26 | 72 | def f(): 73 | loop = asyncio.get_running_loop() 74 | task: asyncio.Task = loop.create_task(coordinator.ws_connect()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -RUF006.py:97:5: RUF006 Store a reference to the return value of `loop.create_task` +RUF006 Store a reference to the return value of `loop.create_task` + --> RUF006.py:97:5 | 95 | def f(): 96 | loop = asyncio.get_running_loop() 97 | loop.create_task(coordinator.ws_connect()) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -RUF006.py:152:13: RUF006 Store a reference to the return value of `asyncio.create_task` +RUF006 Store a reference to the return value of `asyncio.create_task` + --> RUF006.py:152:13 | 150 | async def f(x: bool): 151 | if x: 152 | t = asyncio.create_task(asyncio.sleep(1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 153 | else: 154 | t = None | -RUF006.py:170:5: RUF006 Store a reference to the return value of `loop.create_task` +RUF006 Store a reference to the return value of `loop.create_task` + --> RUF006.py:170:5 | 168 | def f(): 169 | loop = asyncio.new_event_loop() 170 | loop.create_task(main()) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 171 | 172 | # Error | -RUF006.py:175:5: RUF006 Store a reference to the return value of `loop.create_task` +RUF006 Store a reference to the return value of `loop.create_task` + --> RUF006.py:175:5 | 173 | def f(): 174 | loop = asyncio.get_event_loop() 175 | loop.create_task(main()) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 176 | 177 | # OK | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF007_RUF007.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF007_RUF007.py.snap index b12828b3ac..660348b7da 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF007_RUF007.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF007_RUF007.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF007.py:16:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:16:1 | 15 | # Errors 16 | zip(input, input[1:]) - | ^^^ RUF007 + | ^^^ 17 | zip(input, input[1::1]) 18 | zip(input[:-1], input[1:]) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -26,16 +27,17 @@ RUF007.py:16:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 18 19 | zip(input[:-1], input[1:]) 19 20 | zip(input[1:], input[2:]) -RUF007.py:17:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:17:1 | 15 | # Errors 16 | zip(input, input[1:]) 17 | zip(input, input[1::1]) - | ^^^ RUF007 + | ^^^ 18 | zip(input[:-1], input[1:]) 19 | zip(input[1:], input[2:]) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -52,16 +54,17 @@ RUF007.py:17:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 19 20 | zip(input[1:], input[2:]) 20 21 | zip(input[1:-1], input[2:]) -RUF007.py:18:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:18:1 | 16 | zip(input, input[1:]) 17 | zip(input, input[1::1]) 18 | zip(input[:-1], input[1:]) - | ^^^ RUF007 + | ^^^ 19 | zip(input[1:], input[2:]) 20 | zip(input[1:-1], input[2:]) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -78,16 +81,17 @@ RUF007.py:18:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 20 21 | zip(input[1:-1], input[2:]) 21 22 | list(zip(input, input[1:])) -RUF007.py:19:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:19:1 | 17 | zip(input, input[1::1]) 18 | zip(input[:-1], input[1:]) 19 | zip(input[1:], input[2:]) - | ^^^ RUF007 + | ^^^ 20 | zip(input[1:-1], input[2:]) 21 | list(zip(input, input[1:])) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -104,16 +108,17 @@ RUF007.py:19:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 21 22 | list(zip(input, input[1:])) 22 23 | list(zip(input[:-1], input[1:])) -RUF007.py:20:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:20:1 | 18 | zip(input[:-1], input[1:]) 19 | zip(input[1:], input[2:]) 20 | zip(input[1:-1], input[2:]) - | ^^^ RUF007 + | ^^^ 21 | list(zip(input, input[1:])) 22 | list(zip(input[:-1], input[1:])) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -130,16 +135,17 @@ RUF007.py:20:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 22 23 | list(zip(input[:-1], input[1:])) 23 24 | zip(foo[:-1], foo[1:], strict=True) -RUF007.py:21:6: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:21:6 | 19 | zip(input[1:], input[2:]) 20 | zip(input[1:-1], input[2:]) 21 | list(zip(input, input[1:])) - | ^^^ RUF007 + | ^^^ 22 | list(zip(input[:-1], input[1:])) 23 | zip(foo[:-1], foo[1:], strict=True) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -156,16 +162,17 @@ RUF007.py:21:6: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 23 24 | zip(foo[:-1], foo[1:], strict=True) 24 25 | zip(foo[:-1], foo[1:], strict=False) -RUF007.py:22:6: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:22:6 | 20 | zip(input[1:-1], input[2:]) 21 | list(zip(input, input[1:])) 22 | list(zip(input[:-1], input[1:])) - | ^^^ RUF007 + | ^^^ 23 | zip(foo[:-1], foo[1:], strict=True) 24 | zip(foo[:-1], foo[1:], strict=False) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -182,16 +189,17 @@ RUF007.py:22:6: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 24 25 | zip(foo[:-1], foo[1:], strict=False) 25 26 | zip(foo[:-1], foo[1:], strict=bool(foo)) -RUF007.py:23:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:23:1 | 21 | list(zip(input, input[1:])) 22 | list(zip(input[:-1], input[1:])) 23 | zip(foo[:-1], foo[1:], strict=True) - | ^^^ RUF007 + | ^^^ 24 | zip(foo[:-1], foo[1:], strict=False) 25 | zip(foo[:-1], foo[1:], strict=bool(foo)) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -207,15 +215,16 @@ RUF007.py:23:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 24 25 | zip(foo[:-1], foo[1:], strict=False) 25 26 | zip(foo[:-1], foo[1:], strict=bool(foo)) -RUF007.py:24:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:24:1 | 22 | list(zip(input[:-1], input[1:])) 23 | zip(foo[:-1], foo[1:], strict=True) 24 | zip(foo[:-1], foo[1:], strict=False) - | ^^^ RUF007 + | ^^^ 25 | zip(foo[:-1], foo[1:], strict=bool(foo)) | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools @@ -230,14 +239,15 @@ RUF007.py:24:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when itera 25 |+itertools.pairwise(foo) 25 26 | zip(foo[:-1], foo[1:], strict=bool(foo)) -RUF007.py:25:1: RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs +RUF007 [*] Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + --> RUF007.py:25:1 | 23 | zip(foo[:-1], foo[1:], strict=True) 24 | zip(foo[:-1], foo[1:], strict=False) 25 | zip(foo[:-1], foo[1:], strict=bool(foo)) - | ^^^ RUF007 + | ^^^ | - = help: Replace `zip()` with `itertools.pairwise()` +help: Replace `zip()` with `itertools.pairwise()` ℹ Unsafe fix 1 |+import itertools diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008.py.snap index c3762051ba..790e5ff0d5 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008.py.snap @@ -1,50 +1,55 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF008.py:10:34: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008.py:10:34 | 8 | @dataclass 9 | class A: 10 | mutable_default: list[int] = [] - | ^^ RUF008 + | ^^ 11 | immutable_annotation: typing.Sequence[int] = [] 12 | without_annotation = [] | -RUF008.py:20:34: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008.py:20:34 | 18 | @dataclass 19 | class B: 20 | mutable_default: list[int] = [] - | ^^ RUF008 + | ^^ 21 | immutable_annotation: Sequence[int] = [] 22 | without_annotation = [] | -RUF008.py:31:36: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008.py:31:36 | 29 | @dataclass 30 | class AWithQuotes: 31 | mutable_default: 'list[int]' = [] - | ^^ RUF008 + | ^^ 32 | immutable_annotation: 'typing.Sequence[int]' = [] 33 | without_annotation = [] | -RUF008.py:32:52: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008.py:32:52 | 30 | class AWithQuotes: 31 | mutable_default: 'list[int]' = [] 32 | immutable_annotation: 'typing.Sequence[int]' = [] - | ^^ RUF008 + | ^^ 33 | without_annotation = [] 34 | correct_code: 'list[int]' = KNOWINGLY_MUTABLE_DEFAULT | -RUF008.py:36:51: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008.py:36:51 | 34 | correct_code: 'list[int]' = KNOWINGLY_MUTABLE_DEFAULT 35 | perfectly_fine: 'list[int]' = field(default_factory=list) 36 | class_variable: 'typing.ClassVar[list[int]]'= [] - | ^^ RUF008 + | ^^ | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008_attrs.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008_attrs.py.snap index 0b4772e491..b83ec43907 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008_attrs.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008_attrs.py.snap @@ -1,43 +1,46 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF008_attrs.py:13:34: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008_attrs.py:13:34 | 11 | @define 12 | class A: 13 | mutable_default: list[int] = [] - | ^^ RUF008 + | ^^ 14 | immutable_annotation: typing.Sequence[int] = [] 15 | without_annotation = [] | -RUF008_attrs.py:23:34: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008_attrs.py:23:34 | 21 | @frozen 22 | class B: 23 | mutable_default: list[int] = [] - | ^^ RUF008 + | ^^ 24 | immutable_annotation: Sequence[int] = [] 25 | without_annotation = [] | -RUF008_attrs.py:33:34: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008_attrs.py:33:34 | 31 | @attr.s 32 | class C: 33 | mutable_default: list[int] = [] - | ^^ RUF008 + | ^^ 34 | immutable_annotation: Sequence[int] = [] 35 | without_annotation = [] | -RUF008_attrs.py:42:34: RUF008 Do not use mutable default values for dataclass attributes +RUF008 Do not use mutable default values for dataclass attributes + --> RUF008_attrs.py:42:34 | 40 | @s 41 | class D: 42 | mutable_default: list[int] = [] - | ^^ RUF008 + | ^^ 43 | immutable_annotation: Sequence[int] = [] 44 | without_annotation = [] | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009.py.snap index 8a297d3c15..d06f02a051 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009.py.snap @@ -1,102 +1,111 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF009.py:20:41: RUF009 Do not perform function call `default_function` in dataclass defaults +RUF009 Do not perform function call `default_function` in dataclass defaults + --> RUF009.py:20:41 | 18 | @dataclass() 19 | class A: 20 | hidden_mutable_default: list[int] = default_function() - | ^^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^^ 21 | class_variable: typing.ClassVar[list[int]] = default_function() 22 | another_class_var: ClassVar[list[int]] = default_function() | -RUF009.py:43:41: RUF009 Do not perform function call `default_function` in dataclass defaults +RUF009 Do not perform function call `default_function` in dataclass defaults + --> RUF009.py:43:41 | 41 | @dataclass 42 | class B: 43 | hidden_mutable_default: list[int] = default_function() - | ^^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^^ 44 | another_dataclass: A = A() 45 | not_optimal: ImmutableType = ImmutableType(20) | -RUF009.py:44:28: RUF009 Do not perform function call `A` in dataclass defaults +RUF009 Do not perform function call `A` in dataclass defaults + --> RUF009.py:44:28 | 42 | class B: 43 | hidden_mutable_default: list[int] = default_function() 44 | another_dataclass: A = A() - | ^^^ RUF009 + | ^^^ 45 | not_optimal: ImmutableType = ImmutableType(20) 46 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES | -RUF009.py:45:34: RUF009 Do not perform function call `ImmutableType` in dataclass defaults +RUF009 Do not perform function call `ImmutableType` in dataclass defaults + --> RUF009.py:45:34 | 43 | hidden_mutable_default: list[int] = default_function() 44 | another_dataclass: A = A() 45 | not_optimal: ImmutableType = ImmutableType(20) - | ^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^ 46 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES 47 | okay_variant: A = DEFAULT_A_FOR_ALL_DATACLASSES | -RUF009.py:91:24: RUF009 Do not perform function call `ListOfStrings` in dataclass defaults +RUF009 Do not perform function call `ListOfStrings` in dataclass defaults + --> RUF009.py:91:24 | 89 | class DataclassWithNewTypeFields: 90 | # Errors 91 | a: ListOfStrings = ListOfStrings([]) - | ^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^ 92 | b: StringsToInts = StringsToInts() 93 | c: Invalid1 = Invalid1() | -RUF009.py:92:24: RUF009 Do not perform function call `StringsToInts` in dataclass defaults +RUF009 Do not perform function call `StringsToInts` in dataclass defaults + --> RUF009.py:92:24 | 90 | # Errors 91 | a: ListOfStrings = ListOfStrings([]) 92 | b: StringsToInts = StringsToInts() - | ^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^ 93 | c: Invalid1 = Invalid1() 94 | d: Invalid2 = Invalid2() | -RUF009.py:93:19: RUF009 Do not perform function call `Invalid1` in dataclass defaults +RUF009 Do not perform function call `Invalid1` in dataclass defaults + --> RUF009.py:93:19 | 91 | a: ListOfStrings = ListOfStrings([]) 92 | b: StringsToInts = StringsToInts() 93 | c: Invalid1 = Invalid1() - | ^^^^^^^^^^ RUF009 + | ^^^^^^^^^^ 94 | d: Invalid2 = Invalid2() 95 | e: Invalid3 = Invalid3() | -RUF009.py:94:19: RUF009 Do not perform function call `Invalid2` in dataclass defaults +RUF009 Do not perform function call `Invalid2` in dataclass defaults + --> RUF009.py:94:19 | 92 | b: StringsToInts = StringsToInts() 93 | c: Invalid1 = Invalid1() 94 | d: Invalid2 = Invalid2() - | ^^^^^^^^^^ RUF009 + | ^^^^^^^^^^ 95 | e: Invalid3 = Invalid3() | -RUF009.py:95:19: RUF009 Do not perform function call `Invalid3` in dataclass defaults +RUF009 Do not perform function call `Invalid3` in dataclass defaults + --> RUF009.py:95:19 | 93 | c: Invalid1 = Invalid1() 94 | d: Invalid2 = Invalid2() 95 | e: Invalid3 = Invalid3() - | ^^^^^^^^^^ RUF009 + | ^^^^^^^^^^ 96 | 97 | # No errors | -RUF009.py:109:35: RUF009 Do not perform function call `default_function` in dataclass defaults +RUF009 Do not perform function call `default_function` in dataclass defaults + --> RUF009.py:109:35 | 107 | @dataclass 108 | class ShouldMatchB008RuleOfImmutableTypeAnnotationIgnored: 109 | this_is_not_fine: list[int] = default_function() - | ^^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^^ 110 | # ignored 111 | this_is_fine: int = f() | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009_attrs.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009_attrs.py.snap index 08faee3866..c50c1d506a 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009_attrs.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009_attrs.py.snap @@ -1,108 +1,120 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF009_attrs.py:46:41: RUF009 Do not perform function call `default_function` in dataclass defaults +RUF009 Do not perform function call `default_function` in dataclass defaults + --> RUF009_attrs.py:46:41 | 44 | @define 45 | class B: 46 | hidden_mutable_default: list[int] = default_function() - | ^^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^^ 47 | another_dataclass: A = A() 48 | not_optimal: ImmutableType = ImmutableType(20) | -RUF009_attrs.py:47:28: RUF009 Do not perform function call `A` in dataclass defaults +RUF009 Do not perform function call `A` in dataclass defaults + --> RUF009_attrs.py:47:28 | 45 | class B: 46 | hidden_mutable_default: list[int] = default_function() 47 | another_dataclass: A = A() - | ^^^ RUF009 + | ^^^ 48 | not_optimal: ImmutableType = ImmutableType(20) 49 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES | -RUF009_attrs.py:48:34: RUF009 Do not perform function call `ImmutableType` in dataclass defaults +RUF009 Do not perform function call `ImmutableType` in dataclass defaults + --> RUF009_attrs.py:48:34 | 46 | hidden_mutable_default: list[int] = default_function() 47 | another_dataclass: A = A() 48 | not_optimal: ImmutableType = ImmutableType(20) - | ^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^ 49 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES 50 | okay_variant: A = DEFAULT_A_FOR_ALL_DATACLASSES | -RUF009_attrs.py:108:12: RUF009 Do not perform function call `F` in dataclass defaults +RUF009 Do not perform function call `F` in dataclass defaults + --> RUF009_attrs.py:108:12 | 106 | @attr.attrs 107 | class H: 108 | f: F = F() - | ^^^ RUF009 + | ^^^ 109 | g: G = G() | -RUF009_attrs.py:109:12: RUF009 Do not perform function call `G` in dataclass defaults +RUF009 Do not perform function call `G` in dataclass defaults + --> RUF009_attrs.py:109:12 | 107 | class H: 108 | f: F = F() 109 | g: G = G() - | ^^^ RUF009 + | ^^^ | -RUF009_attrs.py:114:12: RUF009 Do not perform function call `F` in dataclass defaults +RUF009 Do not perform function call `F` in dataclass defaults + --> RUF009_attrs.py:114:12 | 112 | @attr.define 113 | class I: 114 | f: F = F() - | ^^^ RUF009 + | ^^^ 115 | g: G = G() | -RUF009_attrs.py:115:12: RUF009 Do not perform function call `G` in dataclass defaults +RUF009 Do not perform function call `G` in dataclass defaults + --> RUF009_attrs.py:115:12 | 113 | class I: 114 | f: F = F() 115 | g: G = G() - | ^^^ RUF009 + | ^^^ | -RUF009_attrs.py:120:12: RUF009 Do not perform function call `F` in dataclass defaults +RUF009 Do not perform function call `F` in dataclass defaults + --> RUF009_attrs.py:120:12 | 118 | @attr.frozen 119 | class J: 120 | f: F = F() - | ^^^ RUF009 + | ^^^ 121 | g: G = G() | -RUF009_attrs.py:121:12: RUF009 Do not perform function call `G` in dataclass defaults +RUF009 Do not perform function call `G` in dataclass defaults + --> RUF009_attrs.py:121:12 | 119 | class J: 120 | f: F = F() 121 | g: G = G() - | ^^^ RUF009 + | ^^^ | -RUF009_attrs.py:126:12: RUF009 Do not perform function call `F` in dataclass defaults +RUF009 Do not perform function call `F` in dataclass defaults + --> RUF009_attrs.py:126:12 | 124 | @attr.mutable 125 | class K: 126 | f: F = F() - | ^^^ RUF009 + | ^^^ 127 | g: G = G() | -RUF009_attrs.py:127:12: RUF009 Do not perform function call `G` in dataclass defaults +RUF009 Do not perform function call `G` in dataclass defaults + --> RUF009_attrs.py:127:12 | 125 | class K: 126 | f: F = F() 127 | g: G = G() - | ^^^ RUF009 + | ^^^ | -RUF009_attrs.py:144:20: RUF009 Do not perform function call `list` in dataclass defaults +RUF009 Do not perform function call `list` in dataclass defaults + --> RUF009_attrs.py:144:20 | 142 | @attr.attributes 143 | class TestAttrAttributes: 144 | x: list[int] = list() # RUF009 - | ^^^^^^ RUF009 + | ^^^^^^ | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009_deferred.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009_deferred.py.snap index 91607116fb..a355ef3955 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009_deferred.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009_deferred.py.snap @@ -1,21 +1,23 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF009_deferred.py:10:41: RUF009 Do not perform function call `default_function` in dataclass defaults +RUF009 Do not perform function call `default_function` in dataclass defaults + --> RUF009_deferred.py:10:41 | 8 | @dataclass() 9 | class A: 10 | hidden_mutable_default: list[int] = default_function() - | ^^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^^ 11 | class_variable: typing.ClassVar[list[int]] = default_function() 12 | another_class_var: ClassVar[list[int]] = default_function() | -RUF009_deferred.py:11:50: RUF009 Do not perform function call `default_function` in dataclass defaults +RUF009 Do not perform function call `default_function` in dataclass defaults + --> RUF009_deferred.py:11:50 | 9 | class A: 10 | hidden_mutable_default: list[int] = default_function() 11 | class_variable: typing.ClassVar[list[int]] = default_function() - | ^^^^^^^^^^^^^^^^^^ RUF009 + | ^^^^^^^^^^^^^^^^^^ 12 | another_class_var: ClassVar[list[int]] = default_function() | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap index 64f777d1cb..0ebd46dd4f 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF010.py:9:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:9:4 | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - | ^^^^^^^^ RUF010 + | ^^^^^^^^ 10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 6 6 | pass @@ -20,14 +21,15 @@ RUF010.py:9:4: RUF010 [*] Use explicit conversion flag 11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 12 | -RUF010.py:9:16: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:9:16 | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - | ^^^^^^^^^ RUF010 + | ^^^^^^^^^ 10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 6 6 | pass @@ -39,14 +41,15 @@ RUF010.py:9:16: RUF010 [*] Use explicit conversion flag 11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 12 | -RUF010.py:9:29: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:9:29 | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - | ^^^^^^^^^^ RUF010 + | ^^^^^^^^^^ 10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 6 6 | pass @@ -58,16 +61,17 @@ RUF010.py:9:29: RUF010 [*] Use explicit conversion flag 11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 12 | -RUF010.py:11:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:11:4 | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | ^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^ 12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 8 8 | @@ -79,16 +83,17 @@ RUF010.py:11:4: RUF010 [*] Use explicit conversion flag 13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 14 14 | -RUF010.py:11:19: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:11:19 | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | ^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^ 12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 8 8 | @@ -100,16 +105,17 @@ RUF010.py:11:19: RUF010 [*] Use explicit conversion flag 13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 14 14 | -RUF010.py:11:35: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:11:35 | 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 10 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | ^^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^^ 12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 8 8 | @@ -121,16 +127,17 @@ RUF010.py:11:35: RUF010 [*] Use explicit conversion flag 13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 14 14 | -RUF010.py:13:5: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:13:5 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^ RUF010 + | ^^^^^^^^ 14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 10 10 | @@ -142,16 +149,17 @@ RUF010.py:13:5: RUF010 [*] Use explicit conversion flag 15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 16 16 | -RUF010.py:13:19: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:13:19 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^^ RUF010 + | ^^^^^^^^^ 14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 10 10 | @@ -163,16 +171,17 @@ RUF010.py:13:19: RUF010 [*] Use explicit conversion flag 15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 16 16 | -RUF010.py:13:34: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:13:34 | 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 12 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^^^ RUF010 + | ^^^^^^^^^^ 14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 10 10 | @@ -184,16 +193,17 @@ RUF010.py:13:34: RUF010 [*] Use explicit conversion flag 15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 16 16 | -RUF010.py:15:14: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:15:14 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^^ RUF010 + | ^^^^^^^^^ 16 | 17 | f"{foo(bla)}" # OK | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 12 12 | @@ -205,16 +215,17 @@ RUF010.py:15:14: RUF010 [*] Use explicit conversion flag 17 17 | f"{foo(bla)}" # OK 18 18 | -RUF010.py:15:29: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:15:29 | 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 14 | 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^^^ RUF010 + | ^^^^^^^^^^ 16 | 17 | f"{foo(bla)}" # OK | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 12 12 | @@ -226,15 +237,16 @@ RUF010.py:15:29: RUF010 [*] Use explicit conversion flag 17 17 | f"{foo(bla)}" # OK 18 18 | -RUF010.py:35:20: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:35:20 | 33 | f"Member of tuple mismatches type at index {i}. Expected {of_shape_i}. Got " 34 | " intermediary content " 35 | f" that flows {repr(obj)} of type {type(obj)}.{additional_message}" # RUF010 - | ^^^^^^^^^ RUF010 + | ^^^^^^^^^ 36 | ) | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 32 32 | ( @@ -246,15 +258,16 @@ RUF010.py:35:20: RUF010 [*] Use explicit conversion flag 37 37 | 38 38 | -RUF010.py:40:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:40:4 | 39 | # https://github.com/astral-sh/ruff/issues/16325 40 | f"{str({})}" - | ^^^^^^^ RUF010 + | ^^^^^^^ 41 | 42 | f"{str({} | {})}" | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 37 37 | @@ -266,16 +279,17 @@ RUF010.py:40:4: RUF010 [*] Use explicit conversion flag 42 42 | f"{str({} | {})}" 43 43 | -RUF010.py:42:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:42:4 | 40 | f"{str({})}" 41 | 42 | f"{str({} | {})}" - | ^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^ 43 | 44 | import builtins | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 39 39 | # https://github.com/astral-sh/ruff/issues/16325 @@ -287,16 +301,17 @@ RUF010.py:42:4: RUF010 [*] Use explicit conversion flag 44 44 | import builtins 45 45 | -RUF010.py:46:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:46:4 | 44 | import builtins 45 | 46 | f"{builtins.repr(1)}" - | ^^^^^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^^^^^ 47 | 48 | f"{repr(1)=}" | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 43 43 | @@ -308,27 +323,29 @@ RUF010.py:46:4: RUF010 [*] Use explicit conversion flag 48 48 | f"{repr(1)=}" 49 49 | -RUF010.py:48:4: RUF010 Use explicit conversion flag +RUF010 Use explicit conversion flag + --> RUF010.py:48:4 | 46 | f"{builtins.repr(1)}" 47 | 48 | f"{repr(1)=}" - | ^^^^^^^ RUF010 + | ^^^^^^^ 49 | 50 | f"{repr(lambda: 1)}" | - = help: Replace with conversion flag +help: Replace with conversion flag -RUF010.py:50:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:50:4 | 48 | f"{repr(1)=}" 49 | 50 | f"{repr(lambda: 1)}" - | ^^^^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^^^^ 51 | 52 | f"{repr(x := 2)}" | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 47 47 | @@ -340,16 +357,17 @@ RUF010.py:50:4: RUF010 [*] Use explicit conversion flag 52 52 | f"{repr(x := 2)}" 53 53 | -RUF010.py:52:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:52:4 | 50 | f"{repr(lambda: 1)}" 51 | 52 | f"{repr(x := 2)}" - | ^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^ 53 | 54 | f"{str(object=3)}" | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 49 49 | @@ -361,16 +379,17 @@ RUF010.py:52:4: RUF010 [*] Use explicit conversion flag 54 54 | f"{str(object=3)}" 55 55 | -RUF010.py:54:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:54:4 | 52 | f"{repr(x := 2)}" 53 | 54 | f"{str(object=3)}" - | ^^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^^ 55 | 56 | f"{str(x for x in [])}" | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 51 51 | @@ -382,16 +401,17 @@ RUF010.py:54:4: RUF010 [*] Use explicit conversion flag 56 56 | f"{str(x for x in [])}" 57 57 | -RUF010.py:56:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:56:4 | 54 | f"{str(object=3)}" 55 | 56 | f"{str(x for x in [])}" - | ^^^^^^^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^^^^^^^ 57 | 58 | f"{str((x for x in []))}" | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 53 53 | @@ -402,14 +422,15 @@ RUF010.py:56:4: RUF010 [*] Use explicit conversion flag 57 57 | 58 58 | f"{str((x for x in []))}" -RUF010.py:58:4: RUF010 [*] Use explicit conversion flag +RUF010 [*] Use explicit conversion flag + --> RUF010.py:58:4 | 56 | f"{str(x for x in [])}" 57 | 58 | f"{str((x for x in []))}" - | ^^^^^^^^^^^^^^^^^^^^ RUF010 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with conversion flag +help: Replace with conversion flag ℹ Safe fix 55 55 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap index c83fb86785..7adb158ab3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap @@ -1,108 +1,119 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF012.py:9:34: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:9:34 | 7 | } 8 | 9 | mutable_default: list[int] = [] - | ^^ RUF012 + | ^^ 10 | immutable_annotation: Sequence[int] = [] 11 | without_annotation = [] | -RUF012.py:11:26: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:11:26 | 9 | mutable_default: list[int] = [] 10 | immutable_annotation: Sequence[int] = [] 11 | without_annotation = [] - | ^^ RUF012 + | ^^ 12 | class_variable: ClassVar[list[int]] = [] 13 | final_variable: Final[list[int]] = [] | -RUF012.py:25:26: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:25:26 | 23 | mutable_default: list[int] = [] 24 | immutable_annotation: Sequence[int] = [] 25 | without_annotation = [] - | ^^ RUF012 + | ^^ 26 | perfectly_fine: list[int] = field(default_factory=list) 27 | class_variable: ClassVar[list[int]] = [] | -RUF012.py:103:38: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:103:38 | 101 | class K(SQLModel): 102 | id: int 103 | mutable_default: list[int] = [] - | ^^ RUF012 + | ^^ 104 | 105 | from sqlmodel import SQLModel | -RUF012.py:128:36: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:128:36 | 126 | } 127 | 128 | mutable_default: 'list[int]' = [] - | ^^ RUF012 + | ^^ 129 | immutable_annotation: 'Sequence[int]'= [] 130 | without_annotation = [] | -RUF012.py:129:44: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:129:44 | 128 | mutable_default: 'list[int]' = [] 129 | immutable_annotation: 'Sequence[int]'= [] - | ^^ RUF012 + | ^^ 130 | without_annotation = [] 131 | class_variable: 'ClassVar[list[int]]' = [] | -RUF012.py:130:26: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:130:26 | 128 | mutable_default: 'list[int]' = [] 129 | immutable_annotation: 'Sequence[int]'= [] 130 | without_annotation = [] - | ^^ RUF012 + | ^^ 131 | class_variable: 'ClassVar[list[int]]' = [] 132 | final_variable: 'Final[list[int]]' = [] | -RUF012.py:131:45: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:131:45 | 129 | immutable_annotation: 'Sequence[int]'= [] 130 | without_annotation = [] 131 | class_variable: 'ClassVar[list[int]]' = [] - | ^^ RUF012 + | ^^ 132 | final_variable: 'Final[list[int]]' = [] 133 | class_variable_without_subscript: 'ClassVar' = [] | -RUF012.py:132:42: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:132:42 | 130 | without_annotation = [] 131 | class_variable: 'ClassVar[list[int]]' = [] 132 | final_variable: 'Final[list[int]]' = [] - | ^^ RUF012 + | ^^ 133 | class_variable_without_subscript: 'ClassVar' = [] 134 | final_variable_without_subscript: 'Final' = [] | -RUF012.py:133:52: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:133:52 | 131 | class_variable: 'ClassVar[list[int]]' = [] 132 | final_variable: 'Final[list[int]]' = [] 133 | class_variable_without_subscript: 'ClassVar' = [] - | ^^ RUF012 + | ^^ 134 | final_variable_without_subscript: 'Final' = [] | -RUF012.py:134:49: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` +RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + --> RUF012.py:134:49 | 132 | final_variable: 'Final[list[int]]' = [] 133 | class_variable_without_subscript: 'ClassVar' = [] 134 | final_variable_without_subscript: 'Final' = [] - | ^^ RUF012 + | ^^ | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap index ded2a1770c..7c2a377ade 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF013_0.py:20:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:20:12 | 20 | def f(arg: int = None): # RUF013 - | ^^^ RUF013 + | ^^^ 21 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 17 17 | pass @@ -20,13 +20,14 @@ RUF013_0.py:20:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 22 22 | 23 23 | -RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:24:12 | 24 | def f(arg: str = None): # RUF013 - | ^^^ RUF013 + | ^^^ 25 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 21 21 | pass @@ -38,13 +39,14 @@ RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 26 26 | 27 27 | -RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:28:12 | 28 | def f(arg: Tuple[str] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 29 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 25 25 | pass @@ -56,13 +58,14 @@ RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 30 30 | 31 31 | -RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:58:12 | 58 | def f(arg: Union = None): # RUF013 - | ^^^^^ RUF013 + | ^^^^^ 59 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 55 55 | pass @@ -74,13 +77,14 @@ RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 60 60 | 61 61 | -RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:62:12 | 62 | def f(arg: Union[int] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 63 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 59 59 | pass @@ -92,13 +96,14 @@ RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 64 64 | 65 65 | -RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:66:12 | 66 | def f(arg: Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^ 67 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 63 63 | pass @@ -110,13 +115,14 @@ RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 68 68 | 69 69 | -RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:85:12 | 85 | def f(arg: int | float = None): # RUF013 - | ^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^ 86 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 82 82 | pass @@ -128,13 +134,14 @@ RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 87 87 | 88 88 | -RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:89:12 | 89 | def f(arg: int | float | str | bytes = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 86 86 | pass @@ -146,13 +153,14 @@ RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 91 91 | 92 92 | -RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:108:12 | 108 | def f(arg: Literal[1] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 109 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 105 105 | pass @@ -164,13 +172,14 @@ RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 110 110 | 111 111 | -RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:112:12 | 112 | def f(arg: Literal[1, "foo"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^ 113 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 109 109 | pass @@ -182,13 +191,14 @@ RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 114 114 | 115 115 | -RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:131:22 | 131 | def f(arg: Annotated[int, ...] = None): # RUF013 - | ^^^ RUF013 + | ^^^ 132 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 128 128 | pass @@ -200,13 +210,14 @@ RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` 133 133 | 134 134 | -RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:135:32 | 135 | def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - | ^^^^^^^^^ RUF013 + | ^^^^^^^^^ 136 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 132 132 | pass @@ -218,15 +229,16 @@ RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` 137 137 | 138 138 | -RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:151:11 | 150 | def f( 151 | arg1: int = None, # RUF013 - | ^^^ RUF013 + | ^^^ 152 | arg2: Union[int, float] = None, # RUF013 153 | arg3: Literal[1, 2, 3] = None, # RUF013 | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 148 148 | @@ -238,16 +250,17 @@ RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 153 153 | arg3: Literal[1, 2, 3] = None, # RUF013 154 154 | ): -RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:152:11 | 150 | def f( 151 | arg1: int = None, # RUF013 152 | arg2: Union[int, float] = None, # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^ 153 | arg3: Literal[1, 2, 3] = None, # RUF013 154 | ): | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 149 149 | @@ -259,16 +272,17 @@ RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 154 154 | ): 155 155 | pass -RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:153:11 | 151 | arg1: int = None, # RUF013 152 | arg2: Union[int, float] = None, # RUF013 153 | arg3: Literal[1, 2, 3] = None, # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^ 154 | ): 155 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 150 150 | def f( @@ -280,13 +294,14 @@ RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 155 155 | pass 156 156 | -RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:181:12 | 181 | def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 182 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 178 178 | pass @@ -298,13 +313,14 @@ RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 183 183 | 184 184 | -RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:188:13 | 188 | def f(arg: "int" = None): # RUF013 - | ^^^ RUF013 + | ^^^ 189 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 185 185 | # Quoted @@ -316,13 +332,14 @@ RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` 190 190 | 191 191 | -RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:192:13 | 192 | def f(arg: "str" = None): # RUF013 - | ^^^ RUF013 + | ^^^ 193 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 189 189 | pass @@ -334,21 +351,23 @@ RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` 194 194 | 195 195 | -RUF013_0.py:196:12: RUF013 PEP 484 prohibits implicit `Optional` +RUF013 PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:196:12 | 196 | def f(arg: "st" "r" = None): # RUF013 - | ^^^^^^^^ RUF013 + | ^^^^^^^^ 197 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` -RUF013_0.py:204:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:204:12 | 204 | def f(arg: Union["int", "str"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^ 205 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 201 201 | pass diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap index c132eee6a9..c91c0f4574 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_1.py:4:12 | 4 | def f(arg: int = None): # RUF013 - | ^^^ RUF013 + | ^^^ 5 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 1 | # No `typing.Optional` import diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_3.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_3.py.snap index 2c90acd338..d56804b898 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_3.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_3.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF013_3.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_3.py:4:12 | 4 | def f(arg: typing.List[str] = None): # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^ 5 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 1 | import typing @@ -20,13 +20,14 @@ RUF013_3.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 6 6 | 7 7 | -RUF013_3.py:22:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_3.py:22:12 | 22 | def f(arg: typing.Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 19 19 | pass @@ -38,13 +39,14 @@ RUF013_3.py:22:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 24 24 | 25 25 | -RUF013_3.py:29:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_3.py:29:12 | 29 | def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 26 26 | # Literal diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_4.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_4.py.snap index 1e4ea1f4ee..a32c119f25 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_4.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_4.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF013_4.py:15:61: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_4.py:15:61 | 15 | def multiple_2(arg1: Optional, arg2: Optional = None, arg3: int = None): ... - | ^^^ RUF013 + | ^^^ | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 12 12 | def multiple_1(arg1: Optional, arg2: Optional = None): ... diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap index e0dcb01a6a..a079cdb11d 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF015.py:4:1: RUF015 [*] Prefer `next(iter(x))` over single element slice +RUF015 [*] Prefer `next(iter(x))` over single element slice + --> RUF015.py:4:1 | 3 | # RUF015 4 | list(x)[0] - | ^^^^^^^^^^ RUF015 + | ^^^^^^^^^^ 5 | tuple(x)[0] 6 | list(i for i in x)[0] | - = help: Replace with `next(iter(x))` +help: Replace with `next(iter(x))` ℹ Unsafe fix 1 1 | x = range(10) @@ -21,16 +22,17 @@ RUF015.py:4:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 6 6 | list(i for i in x)[0] 7 7 | [i for i in x][0] -RUF015.py:5:1: RUF015 [*] Prefer `next(iter(x))` over single element slice +RUF015 [*] Prefer `next(iter(x))` over single element slice + --> RUF015.py:5:1 | 3 | # RUF015 4 | list(x)[0] 5 | tuple(x)[0] - | ^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^ 6 | list(i for i in x)[0] 7 | [i for i in x][0] | - = help: Replace with `next(iter(x))` +help: Replace with `next(iter(x))` ℹ Unsafe fix 2 2 | @@ -42,15 +44,16 @@ RUF015.py:5:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 7 7 | [i for i in x][0] 8 8 | -RUF015.py:6:1: RUF015 [*] Prefer `next(iter(x))` over single element slice +RUF015 [*] Prefer `next(iter(x))` over single element slice + --> RUF015.py:6:1 | 4 | list(x)[0] 5 | tuple(x)[0] 6 | list(i for i in x)[0] - | ^^^^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^^^^ 7 | [i for i in x][0] | - = help: Replace with `next(iter(x))` +help: Replace with `next(iter(x))` ℹ Unsafe fix 3 3 | # RUF015 @@ -62,16 +65,17 @@ RUF015.py:6:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 8 8 | 9 9 | # OK (not indexing (solely) the first element) -RUF015.py:7:1: RUF015 [*] Prefer `next(iter(x))` over single element slice +RUF015 [*] Prefer `next(iter(x))` over single element slice + --> RUF015.py:7:1 | 5 | tuple(x)[0] 6 | list(i for i in x)[0] 7 | [i for i in x][0] - | ^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^ 8 | 9 | # OK (not indexing (solely) the first element) | - = help: Replace with `next(iter(x))` +help: Replace with `next(iter(x))` ℹ Unsafe fix 4 4 | list(x)[0] @@ -83,15 +87,16 @@ RUF015.py:7:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 9 9 | # OK (not indexing (solely) the first element) 10 10 | list(x) -RUF015.py:29:1: RUF015 [*] Prefer `next(i + 1 for i in x)` over single element slice +RUF015 [*] Prefer `next(i + 1 for i in x)` over single element slice + --> RUF015.py:29:1 | 28 | # RUF015 (doesn't mirror the underlying list) 29 | [i + 1 for i in x][0] - | ^^^^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^^^^ 30 | [i for i in x if i > 5][0] 31 | [(i, i + 1) for i in x][0] | - = help: Replace with `next(i + 1 for i in x)` +help: Replace with `next(i + 1 for i in x)` ℹ Unsafe fix 26 26 | [i for i in x][::] @@ -103,15 +108,16 @@ RUF015.py:29:1: RUF015 [*] Prefer `next(i + 1 for i in x)` over single element s 31 31 | [(i, i + 1) for i in x][0] 32 32 | -RUF015.py:30:1: RUF015 [*] Prefer `next(i for i in x if i > 5)` over single element slice +RUF015 [*] Prefer `next(i for i in x if i > 5)` over single element slice + --> RUF015.py:30:1 | 28 | # RUF015 (doesn't mirror the underlying list) 29 | [i + 1 for i in x][0] 30 | [i for i in x if i > 5][0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 31 | [(i, i + 1) for i in x][0] | - = help: Replace with `next(i for i in x if i > 5)` +help: Replace with `next(i for i in x if i > 5)` ℹ Unsafe fix 27 27 | @@ -123,16 +129,17 @@ RUF015.py:30:1: RUF015 [*] Prefer `next(i for i in x if i > 5)` over single elem 32 32 | 33 33 | # RUF015 (multiple generators) -RUF015.py:31:1: RUF015 [*] Prefer `next((i, i + 1) for i in x)` over single element slice +RUF015 [*] Prefer `next((i, i + 1) for i in x)` over single element slice + --> RUF015.py:31:1 | 29 | [i + 1 for i in x][0] 30 | [i for i in x if i > 5][0] 31 | [(i, i + 1) for i in x][0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | # RUF015 (multiple generators) | - = help: Replace with `next((i, i + 1) for i in x)` +help: Replace with `next((i, i + 1) for i in x)` ℹ Unsafe fix 28 28 | # RUF015 (doesn't mirror the underlying list) @@ -144,16 +151,17 @@ RUF015.py:31:1: RUF015 [*] Prefer `next((i, i + 1) for i in x)` over single elem 33 33 | # RUF015 (multiple generators) 34 34 | y = range(10) -RUF015.py:35:1: RUF015 [*] Prefer `next(i + j for i in x for j in y)` over single element slice +RUF015 [*] Prefer `next(i + j for i in x for j in y)` over single element slice + --> RUF015.py:35:1 | 33 | # RUF015 (multiple generators) 34 | y = range(10) 35 | [i + j for i in x for j in y][0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | 37 | # RUF015 | - = help: Replace with `next(i + j for i in x for j in y)` +help: Replace with `next(i + j for i in x for j in y)` ℹ Unsafe fix 32 32 | @@ -165,15 +173,16 @@ RUF015.py:35:1: RUF015 [*] Prefer `next(i + j for i in x for j in y)` over singl 37 37 | # RUF015 38 38 | list(range(10))[0] -RUF015.py:38:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element slice +RUF015 [*] Prefer `next(iter(range(10)))` over single element slice + --> RUF015.py:38:1 | 37 | # RUF015 38 | list(range(10))[0] - | ^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^ 39 | list(x.y)[0] 40 | list(x["y"])[0] | - = help: Replace with `next(iter(range(10)))` +help: Replace with `next(iter(range(10)))` ℹ Unsafe fix 35 35 | [i + j for i in x for j in y][0] @@ -185,16 +194,17 @@ RUF015.py:38:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element sl 40 40 | list(x["y"])[0] 41 41 | [*range(10)][0] -RUF015.py:39:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice +RUF015 [*] Prefer `next(iter(x.y))` over single element slice + --> RUF015.py:39:1 | 37 | # RUF015 38 | list(range(10))[0] 39 | list(x.y)[0] - | ^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^ 40 | list(x["y"])[0] 41 | [*range(10)][0] | - = help: Replace with `next(iter(x.y))` +help: Replace with `next(iter(x.y))` ℹ Unsafe fix 36 36 | @@ -206,16 +216,17 @@ RUF015.py:39:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice 41 41 | [*range(10)][0] 42 42 | [*x["y"]][0] -RUF015.py:40:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice +RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice + --> RUF015.py:40:1 | 38 | list(range(10))[0] 39 | list(x.y)[0] 40 | list(x["y"])[0] - | ^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^ 41 | [*range(10)][0] 42 | [*x["y"]][0] | - = help: Replace with `next(iter(x["y"]))` +help: Replace with `next(iter(x["y"]))` ℹ Unsafe fix 37 37 | # RUF015 @@ -227,16 +238,17 @@ RUF015.py:40:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice 42 42 | [*x["y"]][0] 43 43 | [*x.y][0] -RUF015.py:41:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element slice +RUF015 [*] Prefer `next(iter(range(10)))` over single element slice + --> RUF015.py:41:1 | 39 | list(x.y)[0] 40 | list(x["y"])[0] 41 | [*range(10)][0] - | ^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^ 42 | [*x["y"]][0] 43 | [*x.y][0] | - = help: Replace with `next(iter(range(10)))` +help: Replace with `next(iter(range(10)))` ℹ Unsafe fix 38 38 | list(range(10))[0] @@ -248,16 +260,17 @@ RUF015.py:41:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element sl 43 43 | [*x.y][0] 44 44 | [* x.y][0] -RUF015.py:42:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice +RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice + --> RUF015.py:42:1 | 40 | list(x["y"])[0] 41 | [*range(10)][0] 42 | [*x["y"]][0] - | ^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^ 43 | [*x.y][0] 44 | [* x.y][0] | - = help: Replace with `next(iter(x["y"]))` +help: Replace with `next(iter(x["y"]))` ℹ Unsafe fix 39 39 | list(x.y)[0] @@ -269,16 +282,17 @@ RUF015.py:42:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice 44 44 | [* x.y][0] 45 45 | [ -RUF015.py:43:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice +RUF015 [*] Prefer `next(iter(x.y))` over single element slice + --> RUF015.py:43:1 | 41 | [*range(10)][0] 42 | [*x["y"]][0] 43 | [*x.y][0] - | ^^^^^^^^^ RUF015 + | ^^^^^^^^^ 44 | [* x.y][0] 45 | [ | - = help: Replace with `next(iter(x.y))` +help: Replace with `next(iter(x.y))` ℹ Unsafe fix 40 40 | list(x["y"])[0] @@ -290,16 +304,17 @@ RUF015.py:43:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice 45 45 | [ 46 46 | *x.y -RUF015.py:44:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice +RUF015 [*] Prefer `next(iter(x.y))` over single element slice + --> RUF015.py:44:1 | 42 | [*x["y"]][0] 43 | [*x.y][0] 44 | [* x.y][0] - | ^^^^^^^^^^ RUF015 + | ^^^^^^^^^^ 45 | [ 46 | *x.y | - = help: Replace with `next(iter(x.y))` +help: Replace with `next(iter(x.y))` ℹ Unsafe fix 41 41 | [*range(10)][0] @@ -311,18 +326,19 @@ RUF015.py:44:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice 46 46 | *x.y 47 47 | ][0] -RUF015.py:45:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice +RUF015 [*] Prefer `next(iter(x.y))` over single element slice + --> RUF015.py:45:1 | 43 | [*x.y][0] 44 | [* x.y][0] 45 | / [ 46 | | *x.y 47 | | ][0] - | |____^ RUF015 + | |____^ 48 | 49 | # RUF015 (multi-line) | - = help: Replace with `next(iter(x.y))` +help: Replace with `next(iter(x.y))` ℹ Unsafe fix 42 42 | [*x["y"]][0] @@ -336,7 +352,8 @@ RUF015.py:45:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice 49 47 | # RUF015 (multi-line) 50 48 | revision_heads_map_ast = [ -RUF015.py:50:26: RUF015 [*] Prefer `next(...)` over single element slice +RUF015 [*] Prefer `next(...)` over single element slice + --> RUF015.py:50:26 | 49 | # RUF015 (multi-line) 50 | revision_heads_map_ast = [ @@ -345,11 +362,11 @@ RUF015.py:50:26: RUF015 [*] Prefer `next(...)` over single element slice 52 | | for a in revision_heads_map_ast_obj.body 53 | | if isinstance(a, ast.Assign) and a.targets[0].id == "REVISION_HEADS_MAP" 54 | | ][0] - | |____^ RUF015 + | |____^ 55 | 56 | # RUF015 (zip) | - = help: Replace with `next(...)` +help: Replace with `next(...)` ℹ Unsafe fix 47 47 | ][0] @@ -366,14 +383,15 @@ RUF015.py:50:26: RUF015 [*] Prefer `next(...)` over single element slice 56 56 | # RUF015 (zip) 57 57 | list(zip(x, y))[0] -RUF015.py:57:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice +RUF015 [*] Prefer `next(zip(x, y))` over single element slice + --> RUF015.py:57:1 | 56 | # RUF015 (zip) 57 | list(zip(x, y))[0] - | ^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^ 58 | [*zip(x, y)][0] | - = help: Replace with `next(zip(x, y))` +help: Replace with `next(zip(x, y))` ℹ Unsafe fix 54 54 | ][0] @@ -385,16 +403,17 @@ RUF015.py:57:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice 59 59 | 60 60 | # RUF015 (pop) -RUF015.py:58:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice +RUF015 [*] Prefer `next(zip(x, y))` over single element slice + --> RUF015.py:58:1 | 56 | # RUF015 (zip) 57 | list(zip(x, y))[0] 58 | [*zip(x, y)][0] - | ^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^ 59 | 60 | # RUF015 (pop) | - = help: Replace with `next(zip(x, y))` +help: Replace with `next(zip(x, y))` ℹ Unsafe fix 55 55 | @@ -406,15 +425,16 @@ RUF015.py:58:1: RUF015 [*] Prefer `next(zip(x, y))` over single element slice 60 60 | # RUF015 (pop) 61 61 | list(x).pop(0) -RUF015.py:61:1: RUF015 [*] Prefer `next(iter(x))` over single element slice +RUF015 [*] Prefer `next(iter(x))` over single element slice + --> RUF015.py:61:1 | 60 | # RUF015 (pop) 61 | list(x).pop(0) - | ^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^ 62 | [i for i in x].pop(0) 63 | list(i for i in x).pop(0) | - = help: Replace with `next(iter(x))` +help: Replace with `next(iter(x))` ℹ Unsafe fix 58 58 | [*zip(x, y)][0] @@ -426,15 +446,16 @@ RUF015.py:61:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 63 63 | list(i for i in x).pop(0) 64 64 | -RUF015.py:62:1: RUF015 [*] Prefer `next(iter(x))` over single element slice +RUF015 [*] Prefer `next(iter(x))` over single element slice + --> RUF015.py:62:1 | 60 | # RUF015 (pop) 61 | list(x).pop(0) 62 | [i for i in x].pop(0) - | ^^^^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^^^^ 63 | list(i for i in x).pop(0) | - = help: Replace with `next(iter(x))` +help: Replace with `next(iter(x))` ℹ Unsafe fix 59 59 | @@ -446,16 +467,17 @@ RUF015.py:62:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 64 64 | 65 65 | # OK -RUF015.py:63:1: RUF015 [*] Prefer `next(iter(x))` over single element slice +RUF015 [*] Prefer `next(iter(x))` over single element slice + --> RUF015.py:63:1 | 61 | list(x).pop(0) 62 | [i for i in x].pop(0) 63 | list(i for i in x).pop(0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 64 | 65 | # OK | - = help: Replace with `next(iter(x))` +help: Replace with `next(iter(x))` ℹ Unsafe fix 60 60 | # RUF015 (pop) @@ -467,14 +489,15 @@ RUF015.py:63:1: RUF015 [*] Prefer `next(iter(x))` over single element slice 65 65 | # OK 66 66 | list(x).pop(1) -RUF015.py:73:5: RUF015 [*] Prefer `next(iter(zip(x, y)))` over single element slice +RUF015 [*] Prefer `next(iter(zip(x, y)))` over single element slice + --> RUF015.py:73:5 | 71 | def test(): 72 | zip = list # Overwrite the builtin zip 73 | list(zip(x, y))[0] - | ^^^^^^^^^^^^^^^^^^ RUF015 + | ^^^^^^^^^^^^^^^^^^ | - = help: Replace with `next(iter(zip(x, y)))` +help: Replace with `next(iter(zip(x, y)))` ℹ Unsafe fix 70 70 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap index 32d0727cc8..e2f4ab0278 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap @@ -1,377 +1,417 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF016.py:20:13: RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice +RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice + --> RUF016.py:20:13 | 19 | # Should emit for invalid access on strings 20 | var = "abc"["x"] - | ^^^ RUF016 + | ^^^ 21 | var = f"abc"["x"] | -RUF016.py:21:14: RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice +RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice + --> RUF016.py:21:14 | 19 | # Should emit for invalid access on strings 20 | var = "abc"["x"] 21 | var = f"abc"["x"] - | ^^^ RUF016 + | ^^^ 22 | 23 | # Should emit for invalid access on bytes | -RUF016.py:24:14: RUF016 Indexed access to type `bytes` uses type `str` instead of an integer or slice +RUF016 Indexed access to type `bytes` uses type `str` instead of an integer or slice + --> RUF016.py:24:14 | 23 | # Should emit for invalid access on bytes 24 | var = b"abc"["x"] - | ^^^ RUF016 + | ^^^ 25 | 26 | # Should emit for invalid access on lists and tuples | -RUF016.py:27:17: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice + --> RUF016.py:27:17 | 26 | # Should emit for invalid access on lists and tuples 27 | var = [1, 2, 3]["x"] - | ^^^ RUF016 + | ^^^ 28 | var = (1, 2, 3)["x"] | -RUF016.py:28:17: RUF016 Indexed access to type `tuple` uses type `str` instead of an integer or slice +RUF016 Indexed access to type `tuple` uses type `str` instead of an integer or slice + --> RUF016.py:28:17 | 26 | # Should emit for invalid access on lists and tuples 27 | var = [1, 2, 3]["x"] 28 | var = (1, 2, 3)["x"] - | ^^^ RUF016 + | ^^^ 29 | 30 | # Should emit for invalid access on list comprehensions | -RUF016.py:31:30: RUF016 Indexed access to type `list comprehension` uses type `str` instead of an integer or slice +RUF016 Indexed access to type `list comprehension` uses type `str` instead of an integer or slice + --> RUF016.py:31:30 | 30 | # Should emit for invalid access on list comprehensions 31 | var = [x for x in range(10)]["x"] - | ^^^ RUF016 + | ^^^ 32 | 33 | # Should emit for invalid access using tuple | -RUF016.py:34:13: RUF016 Indexed access to type `str` uses type `tuple` instead of an integer or slice +RUF016 Indexed access to type `str` uses type `tuple` instead of an integer or slice + --> RUF016.py:34:13 | 33 | # Should emit for invalid access using tuple 34 | var = "abc"[1, 2] - | ^^^^ RUF016 + | ^^^^ 35 | 36 | # Should emit for invalid access using string | -RUF016.py:37:14: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice + --> RUF016.py:37:14 | 36 | # Should emit for invalid access using string 37 | var = [1, 2]["x"] - | ^^^ RUF016 + | ^^^ 38 | 39 | # Should emit for invalid access using float | -RUF016.py:40:14: RUF016 Indexed access to type `list` uses type `float` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `float` instead of an integer or slice + --> RUF016.py:40:14 | 39 | # Should emit for invalid access using float 40 | var = [1, 2][0.25] - | ^^^^ RUF016 + | ^^^^ 41 | 42 | # Should emit for invalid access using dict | -RUF016.py:43:14: RUF016 Indexed access to type `list` uses type `dict` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `dict` instead of an integer or slice + --> RUF016.py:43:14 | 42 | # Should emit for invalid access using dict 43 | var = [1, 2][{"x": "y"}] - | ^^^^^^^^^^ RUF016 + | ^^^^^^^^^^ 44 | 45 | # Should emit for invalid access using dict comp | -RUF016.py:46:14: RUF016 Indexed access to type `list` uses type `dict comprehension` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `dict comprehension` instead of an integer or slice + --> RUF016.py:46:14 | 45 | # Should emit for invalid access using dict comp 46 | var = [1, 2][{x: "y" for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | 48 | # Should emit for invalid access using list | -RUF016.py:49:14: RUF016 Indexed access to type `list` uses type `tuple` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `tuple` instead of an integer or slice + --> RUF016.py:49:14 | 48 | # Should emit for invalid access using list 49 | var = [1, 2][2, 3] - | ^^^^ RUF016 + | ^^^^ 50 | 51 | # Should emit for invalid access using list comp | -RUF016.py:52:14: RUF016 Indexed access to type `list` uses type `list comprehension` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `list comprehension` instead of an integer or slice + --> RUF016.py:52:14 | 51 | # Should emit for invalid access using list comp 52 | var = [1, 2][[x for x in range(2)]] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^ 53 | 54 | # Should emit on invalid access using set | -RUF016.py:55:14: RUF016 Indexed access to type `list` uses type `set` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `set` instead of an integer or slice + --> RUF016.py:55:14 | 54 | # Should emit on invalid access using set 55 | var = [1, 2][{"x", "y"}] - | ^^^^^^^^^^ RUF016 + | ^^^^^^^^^^ 56 | 57 | # Should emit on invalid access using set comp | -RUF016.py:58:14: RUF016 Indexed access to type `list` uses type `set comprehension` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `set comprehension` instead of an integer or slice + --> RUF016.py:58:14 | 57 | # Should emit on invalid access using set comp 58 | var = [1, 2][{x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^ 59 | 60 | # Should emit on invalid access using bytes | -RUF016.py:61:14: RUF016 Indexed access to type `list` uses type `bytes` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `bytes` instead of an integer or slice + --> RUF016.py:61:14 | 60 | # Should emit on invalid access using bytes 61 | var = [1, 2][b"x"] - | ^^^^ RUF016 + | ^^^^ 62 | 63 | # Should emit for non-integer slice start | -RUF016.py:64:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer + --> RUF016.py:64:17 | 63 | # Should emit for non-integer slice start 64 | var = [1, 2, 3]["x":2] - | ^^^ RUF016 + | ^^^ 65 | var = [1, 2, 3][f"x":2] 66 | var = [1, 2, 3][1.2:2] | -RUF016.py:65:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer + --> RUF016.py:65:17 | 63 | # Should emit for non-integer slice start 64 | var = [1, 2, 3]["x":2] 65 | var = [1, 2, 3][f"x":2] - | ^^^^ RUF016 + | ^^^^ 66 | var = [1, 2, 3][1.2:2] 67 | var = [1, 2, 3][{"x"}:2] | -RUF016.py:66:17: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer + --> RUF016.py:66:17 | 64 | var = [1, 2, 3]["x":2] 65 | var = [1, 2, 3][f"x":2] 66 | var = [1, 2, 3][1.2:2] - | ^^^ RUF016 + | ^^^ 67 | var = [1, 2, 3][{"x"}:2] 68 | var = [1, 2, 3][{x for x in range(2)}:2] | -RUF016.py:67:17: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer + --> RUF016.py:67:17 | 65 | var = [1, 2, 3][f"x":2] 66 | var = [1, 2, 3][1.2:2] 67 | var = [1, 2, 3][{"x"}:2] - | ^^^^^ RUF016 + | ^^^^^ 68 | var = [1, 2, 3][{x for x in range(2)}:2] 69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] | -RUF016.py:68:17: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer + --> RUF016.py:68:17 | 66 | var = [1, 2, 3][1.2:2] 67 | var = [1, 2, 3][{"x"}:2] 68 | var = [1, 2, 3][{x for x in range(2)}:2] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^ 69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] 70 | var = [1, 2, 3][[x for x in range(2)]:2] | -RUF016.py:69:17: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer + --> RUF016.py:69:17 | 67 | var = [1, 2, 3][{"x"}:2] 68 | var = [1, 2, 3][{x for x in range(2)}:2] 69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | var = [1, 2, 3][[x for x in range(2)]:2] | -RUF016.py:70:17: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer + --> RUF016.py:70:17 | 68 | var = [1, 2, 3][{x for x in range(2)}:2] 69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] 70 | var = [1, 2, 3][[x for x in range(2)]:2] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^ 71 | 72 | # Should emit for non-integer slice end | -RUF016.py:73:19: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer + --> RUF016.py:73:19 | 72 | # Should emit for non-integer slice end 73 | var = [1, 2, 3][0:"x"] - | ^^^ RUF016 + | ^^^ 74 | var = [1, 2, 3][0:f"x"] 75 | var = [1, 2, 3][0:1.2] | -RUF016.py:74:19: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer + --> RUF016.py:74:19 | 72 | # Should emit for non-integer slice end 73 | var = [1, 2, 3][0:"x"] 74 | var = [1, 2, 3][0:f"x"] - | ^^^^ RUF016 + | ^^^^ 75 | var = [1, 2, 3][0:1.2] 76 | var = [1, 2, 3][0:{"x"}] | -RUF016.py:75:19: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer + --> RUF016.py:75:19 | 73 | var = [1, 2, 3][0:"x"] 74 | var = [1, 2, 3][0:f"x"] 75 | var = [1, 2, 3][0:1.2] - | ^^^ RUF016 + | ^^^ 76 | var = [1, 2, 3][0:{"x"}] 77 | var = [1, 2, 3][0:{x for x in range(2)}] | -RUF016.py:76:19: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer + --> RUF016.py:76:19 | 74 | var = [1, 2, 3][0:f"x"] 75 | var = [1, 2, 3][0:1.2] 76 | var = [1, 2, 3][0:{"x"}] - | ^^^^^ RUF016 + | ^^^^^ 77 | var = [1, 2, 3][0:{x for x in range(2)}] 78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] | -RUF016.py:77:19: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer + --> RUF016.py:77:19 | 75 | var = [1, 2, 3][0:1.2] 76 | var = [1, 2, 3][0:{"x"}] 77 | var = [1, 2, 3][0:{x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^ 78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] 79 | var = [1, 2, 3][0:[x for x in range(2)]] | -RUF016.py:78:19: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer + --> RUF016.py:78:19 | 76 | var = [1, 2, 3][0:{"x"}] 77 | var = [1, 2, 3][0:{x for x in range(2)}] 78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 79 | var = [1, 2, 3][0:[x for x in range(2)]] | -RUF016.py:79:19: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer + --> RUF016.py:79:19 | 77 | var = [1, 2, 3][0:{x for x in range(2)}] 78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] 79 | var = [1, 2, 3][0:[x for x in range(2)]] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^ 80 | 81 | # Should emit for non-integer slice step | -RUF016.py:82:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer + --> RUF016.py:82:21 | 81 | # Should emit for non-integer slice step 82 | var = [1, 2, 3][0:1:"x"] - | ^^^ RUF016 + | ^^^ 83 | var = [1, 2, 3][0:1:f"x"] 84 | var = [1, 2, 3][0:1:1.2] | -RUF016.py:83:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer + --> RUF016.py:83:21 | 81 | # Should emit for non-integer slice step 82 | var = [1, 2, 3][0:1:"x"] 83 | var = [1, 2, 3][0:1:f"x"] - | ^^^^ RUF016 + | ^^^^ 84 | var = [1, 2, 3][0:1:1.2] 85 | var = [1, 2, 3][0:1:{"x"}] | -RUF016.py:84:21: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer + --> RUF016.py:84:21 | 82 | var = [1, 2, 3][0:1:"x"] 83 | var = [1, 2, 3][0:1:f"x"] 84 | var = [1, 2, 3][0:1:1.2] - | ^^^ RUF016 + | ^^^ 85 | var = [1, 2, 3][0:1:{"x"}] 86 | var = [1, 2, 3][0:1:{x for x in range(2)}] | -RUF016.py:85:21: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer + --> RUF016.py:85:21 | 83 | var = [1, 2, 3][0:1:f"x"] 84 | var = [1, 2, 3][0:1:1.2] 85 | var = [1, 2, 3][0:1:{"x"}] - | ^^^^^ RUF016 + | ^^^^^ 86 | var = [1, 2, 3][0:1:{x for x in range(2)}] 87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] | -RUF016.py:86:21: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer + --> RUF016.py:86:21 | 84 | var = [1, 2, 3][0:1:1.2] 85 | var = [1, 2, 3][0:1:{"x"}] 86 | var = [1, 2, 3][0:1:{x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^ 87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] 88 | var = [1, 2, 3][0:1:[x for x in range(2)]] | -RUF016.py:87:21: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer + --> RUF016.py:87:21 | 85 | var = [1, 2, 3][0:1:{"x"}] 86 | var = [1, 2, 3][0:1:{x for x in range(2)}] 87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 88 | var = [1, 2, 3][0:1:[x for x in range(2)]] | -RUF016.py:88:21: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer + --> RUF016.py:88:21 | 86 | var = [1, 2, 3][0:1:{x for x in range(2)}] 87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] 88 | var = [1, 2, 3][0:1:[x for x in range(2)]] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 + | ^^^^^^^^^^^^^^^^^^^^^ 89 | 90 | # Should emit for non-integer slice start and end; should emit twice with specific ranges | -RUF016.py:91:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer + --> RUF016.py:91:17 | 90 | # Should emit for non-integer slice start and end; should emit twice with specific ranges 91 | var = [1, 2, 3]["x":"y"] - | ^^^ RUF016 + | ^^^ 92 | 93 | # Should emit once for repeated invalid access | -RUF016.py:91:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer +RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer + --> RUF016.py:91:21 | 90 | # Should emit for non-integer slice start and end; should emit twice with specific ranges 91 | var = [1, 2, 3]["x":"y"] - | ^^^ RUF016 + | ^^^ 92 | 93 | # Should emit once for repeated invalid access | -RUF016.py:94:17: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice +RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice + --> RUF016.py:94:17 | 93 | # Should emit once for repeated invalid access 94 | var = [1, 2, 3]["x"]["y"]["z"] - | ^^^ RUF016 + | ^^^ 95 | 96 | # Cannot emit on invalid access using variable in index | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap index 71be7e5fb5..298419f4b3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF017_0.py:5:1: RUF017 [*] Avoid quadratic list summation +RUF017 [*] Avoid quadratic list summation + --> RUF017_0.py:5:1 | 4 | # RUF017 5 | sum([x, y], start=[]) - | ^^^^^^^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | sum([x, y], []) 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) | - = help: Replace with `functools.reduce` +help: Replace with `functools.reduce` ℹ Unsafe fix 1 |+import functools @@ -24,16 +25,17 @@ RUF017_0.py:5:1: RUF017 [*] Avoid quadratic list summation 7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) 8 10 | sum([[1, 2, 3], [4, 5, 6]], []) -RUF017_0.py:6:1: RUF017 [*] Avoid quadratic list summation +RUF017 [*] Avoid quadratic list summation + --> RUF017_0.py:6:1 | 4 | # RUF017 5 | sum([x, y], start=[]) 6 | sum([x, y], []) - | ^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^ 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) 8 | sum([[1, 2, 3], [4, 5, 6]], []) | - = help: Replace with `functools.reduce` +help: Replace with `functools.reduce` ℹ Unsafe fix 1 |+import functools @@ -49,16 +51,17 @@ RUF017_0.py:6:1: RUF017 [*] Avoid quadratic list summation 8 10 | sum([[1, 2, 3], [4, 5, 6]], []) 9 11 | sum([[1, 2, 3], [4, 5, 6]], -RUF017_0.py:7:1: RUF017 [*] Avoid quadratic list summation +RUF017 [*] Avoid quadratic list summation + --> RUF017_0.py:7:1 | 5 | sum([x, y], start=[]) 6 | sum([x, y], []) 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | sum([[1, 2, 3], [4, 5, 6]], []) 9 | sum([[1, 2, 3], [4, 5, 6]], | - = help: Replace with `functools.reduce` +help: Replace with `functools.reduce` ℹ Unsafe fix 1 |+import functools @@ -75,16 +78,17 @@ RUF017_0.py:7:1: RUF017 [*] Avoid quadratic list summation 9 11 | sum([[1, 2, 3], [4, 5, 6]], 10 12 | []) -RUF017_0.py:8:1: RUF017 [*] Avoid quadratic list summation +RUF017 [*] Avoid quadratic list summation + --> RUF017_0.py:8:1 | 6 | sum([x, y], []) 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) 8 | sum([[1, 2, 3], [4, 5, 6]], []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | sum([[1, 2, 3], [4, 5, 6]], 10 | []) | - = help: Replace with `functools.reduce` +help: Replace with `functools.reduce` ℹ Unsafe fix 1 |+import functools @@ -102,17 +106,18 @@ RUF017_0.py:8:1: RUF017 [*] Avoid quadratic list summation 10 12 | []) 11 13 | -RUF017_0.py:9:1: RUF017 [*] Avoid quadratic list summation +RUF017 [*] Avoid quadratic list summation + --> RUF017_0.py:9:1 | 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) 8 | sum([[1, 2, 3], [4, 5, 6]], []) 9 | / sum([[1, 2, 3], [4, 5, 6]], 10 | | []) - | |_______^ RUF017 + | |_______^ 11 | 12 | # OK | - = help: Replace with `functools.reduce` +help: Replace with `functools.reduce` ℹ Unsafe fix 1 |+import functools @@ -131,14 +136,15 @@ RUF017_0.py:9:1: RUF017 [*] Avoid quadratic list summation 12 13 | # OK 13 14 | sum([x, y]) -RUF017_0.py:21:5: RUF017 [*] Avoid quadratic list summation +RUF017 [*] Avoid quadratic list summation + --> RUF017_0.py:21:5 | 19 | import functools, operator 20 | 21 | sum([x, y], []) - | ^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^ | - = help: Replace with `functools.reduce` +help: Replace with `functools.reduce` ℹ Unsafe fix 18 18 | def func(): @@ -150,14 +156,15 @@ RUF017_0.py:21:5: RUF017 [*] Avoid quadratic list summation 23 23 | 24 24 | # Regression test for: https://github.com/astral-sh/ruff/issues/7718 -RUF017_0.py:26:5: RUF017 [*] Avoid quadratic list summation +RUF017 [*] Avoid quadratic list summation + --> RUF017_0.py:26:5 | 24 | # Regression test for: https://github.com/astral-sh/ruff/issues/7718 25 | def func(): 26 | sum((factor.dims for factor in bases), []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `functools.reduce` +help: Replace with `functools.reduce` ℹ Unsafe fix 1 |+import functools diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_1.py.snap index 4622f8eb6e..f85dbf7125 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017_1.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF017_1.py:1:1: RUF017 [*] Avoid quadratic list summation +RUF017 [*] Avoid quadratic list summation + --> RUF017_1.py:1:1 | 1 | sum((factor.dims for factor in bases), []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `functools.reduce` +help: Replace with `functools.reduce` ℹ Unsafe fix 1 |-sum((factor.dims for factor in bases), []) diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF018_RUF018.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF018_RUF018.py.snap index 4ca2e189db..554abfb2d9 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF018_RUF018.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF018_RUF018.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF018.py:2:9: RUF018 Avoid assignment expressions in `assert` statements +RUF018 Avoid assignment expressions in `assert` statements + --> RUF018.py:2:9 | 1 | # RUF018 2 | assert (x := 0) == 0 - | ^^^^^^ RUF018 + | ^^^^^^ 3 | assert x, (y := "error") 4 | print(x, y) | -RUF018.py:3:12: RUF018 Avoid assignment expressions in `assert` statements +RUF018 Avoid assignment expressions in `assert` statements + --> RUF018.py:3:12 | 1 | # RUF018 2 | assert (x := 0) == 0 3 | assert x, (y := "error") - | ^^^^^^^^^^^^ RUF018 + | ^^^^^^^^^^^^ 4 | print(x, y) | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap index 24416b08b7..18047142fa 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF019_RUF019.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF019.py:3:4: RUF019 [*] Unnecessary key check before dictionary access +RUF019 [*] Unnecessary key check before dictionary access + --> RUF019.py:3:4 | 1 | d = {} 2 | # RUF019 3 | if "k" in d and d["k"]: - | ^^^^^^^^^^^^^^^^^^^ RUF019 + | ^^^^^^^^^^^^^^^^^^^ 4 | pass | - = help: Replace with `dict.get` +help: Replace with `dict.get` ℹ Safe fix 1 1 | d = {} @@ -20,14 +21,15 @@ RUF019.py:3:4: RUF019 [*] Unnecessary key check before dictionary access 5 5 | 6 6 | k = "k" -RUF019.py:7:4: RUF019 [*] Unnecessary key check before dictionary access +RUF019 [*] Unnecessary key check before dictionary access + --> RUF019.py:7:4 | 6 | k = "k" 7 | if k in d and d[k]: - | ^^^^^^^^^^^^^^^ RUF019 + | ^^^^^^^^^^^^^^^ 8 | pass | - = help: Replace with `dict.get` +help: Replace with `dict.get` ℹ Safe fix 4 4 | pass @@ -39,15 +41,16 @@ RUF019.py:7:4: RUF019 [*] Unnecessary key check before dictionary access 9 9 | 10 10 | if (k) in d and d[k]: -RUF019.py:10:4: RUF019 [*] Unnecessary key check before dictionary access +RUF019 [*] Unnecessary key check before dictionary access + --> RUF019.py:10:4 | 8 | pass 9 | 10 | if (k) in d and d[k]: - | ^^^^^^^^^^^^^^^^^ RUF019 + | ^^^^^^^^^^^^^^^^^ 11 | pass | - = help: Replace with `dict.get` +help: Replace with `dict.get` ℹ Safe fix 7 7 | if k in d and d[k]: @@ -59,15 +62,16 @@ RUF019.py:10:4: RUF019 [*] Unnecessary key check before dictionary access 12 12 | 13 13 | if k in d and d[(k)]: -RUF019.py:13:4: RUF019 [*] Unnecessary key check before dictionary access +RUF019 [*] Unnecessary key check before dictionary access + --> RUF019.py:13:4 | 11 | pass 12 | 13 | if k in d and d[(k)]: - | ^^^^^^^^^^^^^^^^^ RUF019 + | ^^^^^^^^^^^^^^^^^ 14 | pass | - = help: Replace with `dict.get` +help: Replace with `dict.get` ℹ Safe fix 10 10 | if (k) in d and d[k]: @@ -79,16 +83,17 @@ RUF019.py:13:4: RUF019 [*] Unnecessary key check before dictionary access 15 15 | 16 16 | not ("key" in dct and dct["key"]) -RUF019.py:16:6: RUF019 [*] Unnecessary key check before dictionary access +RUF019 [*] Unnecessary key check before dictionary access + --> RUF019.py:16:6 | 14 | pass 15 | 16 | not ("key" in dct and dct["key"]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | bool("key" in dct and dct["key"]) | - = help: Replace with `dict.get` +help: Replace with `dict.get` ℹ Safe fix 13 13 | if k in d and d[(k)]: @@ -100,16 +105,17 @@ RUF019.py:16:6: RUF019 [*] Unnecessary key check before dictionary access 18 18 | bool("key" in dct and dct["key"]) 19 19 | -RUF019.py:18:6: RUF019 [*] Unnecessary key check before dictionary access +RUF019 [*] Unnecessary key check before dictionary access + --> RUF019.py:18:6 | 16 | not ("key" in dct and dct["key"]) 17 | 18 | bool("key" in dct and dct["key"]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF019 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | 20 | # OK | - = help: Replace with `dict.get` +help: Replace with `dict.get` ℹ Safe fix 15 15 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap index 93eccd0055..622af1339b 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF020_RUF020.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF020.py:3:7: RUF020 [*] `Union[Never, T]` is equivalent to `T` +RUF020 [*] `Union[Never, T]` is equivalent to `T` + --> RUF020.py:3:7 | 1 | from typing import Never, NoReturn, Union 2 | 3 | Union[Never, int] - | ^^^^^ RUF020 + | ^^^^^ 4 | Union[NoReturn, int] 5 | Never | int | - = help: Remove `Never` +help: Remove `Never` ℹ Safe fix 1 1 | from typing import Never, NoReturn, Union @@ -21,15 +22,16 @@ RUF020.py:3:7: RUF020 [*] `Union[Never, T]` is equivalent to `T` 5 5 | Never | int 6 6 | NoReturn | int -RUF020.py:4:7: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` +RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` + --> RUF020.py:4:7 | 3 | Union[Never, int] 4 | Union[NoReturn, int] - | ^^^^^^^^ RUF020 + | ^^^^^^^^ 5 | Never | int 6 | NoReturn | int | - = help: Remove `NoReturn` +help: Remove `NoReturn` ℹ Safe fix 1 1 | from typing import Never, NoReturn, Union @@ -41,16 +43,17 @@ RUF020.py:4:7: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` 6 6 | NoReturn | int 7 7 | Union[Union[Never, int], Union[NoReturn, int]] -RUF020.py:5:1: RUF020 [*] `Never | T` is equivalent to `T` +RUF020 [*] `Never | T` is equivalent to `T` + --> RUF020.py:5:1 | 3 | Union[Never, int] 4 | Union[NoReturn, int] 5 | Never | int - | ^^^^^ RUF020 + | ^^^^^ 6 | NoReturn | int 7 | Union[Union[Never, int], Union[NoReturn, int]] | - = help: Remove `Never` +help: Remove `Never` ℹ Safe fix 2 2 | @@ -62,16 +65,17 @@ RUF020.py:5:1: RUF020 [*] `Never | T` is equivalent to `T` 7 7 | Union[Union[Never, int], Union[NoReturn, int]] 8 8 | Union[NoReturn, int, float] -RUF020.py:6:1: RUF020 [*] `NoReturn | T` is equivalent to `T` +RUF020 [*] `NoReturn | T` is equivalent to `T` + --> RUF020.py:6:1 | 4 | Union[NoReturn, int] 5 | Never | int 6 | NoReturn | int - | ^^^^^^^^ RUF020 + | ^^^^^^^^ 7 | Union[Union[Never, int], Union[NoReturn, int]] 8 | Union[NoReturn, int, float] | - = help: Remove `NoReturn` +help: Remove `NoReturn` ℹ Safe fix 3 3 | Union[Never, int] @@ -83,15 +87,16 @@ RUF020.py:6:1: RUF020 [*] `NoReturn | T` is equivalent to `T` 8 8 | Union[NoReturn, int, float] 9 9 | -RUF020.py:7:13: RUF020 [*] `Union[Never, T]` is equivalent to `T` +RUF020 [*] `Union[Never, T]` is equivalent to `T` + --> RUF020.py:7:13 | 5 | Never | int 6 | NoReturn | int 7 | Union[Union[Never, int], Union[NoReturn, int]] - | ^^^^^ RUF020 + | ^^^^^ 8 | Union[NoReturn, int, float] | - = help: Remove `Never` +help: Remove `Never` ℹ Safe fix 4 4 | Union[NoReturn, int] @@ -103,15 +108,16 @@ RUF020.py:7:13: RUF020 [*] `Union[Never, T]` is equivalent to `T` 9 9 | 10 10 | -RUF020.py:7:32: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` +RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` + --> RUF020.py:7:32 | 5 | Never | int 6 | NoReturn | int 7 | Union[Union[Never, int], Union[NoReturn, int]] - | ^^^^^^^^ RUF020 + | ^^^^^^^^ 8 | Union[NoReturn, int, float] | - = help: Remove `NoReturn` +help: Remove `NoReturn` ℹ Safe fix 4 4 | Union[NoReturn, int] @@ -123,14 +129,15 @@ RUF020.py:7:32: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` 9 9 | 10 10 | -RUF020.py:8:7: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` +RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` + --> RUF020.py:8:7 | 6 | NoReturn | int 7 | Union[Union[Never, int], Union[NoReturn, int]] 8 | Union[NoReturn, int, float] - | ^^^^^^^^ RUF020 + | ^^^^^^^^ | - = help: Remove `NoReturn` +help: Remove `NoReturn` ℹ Safe fix 5 5 | Never | int @@ -142,59 +149,65 @@ RUF020.py:8:7: RUF020 [*] `Union[NoReturn, T]` is equivalent to `T` 10 10 | 11 11 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 -RUF020.py:12:11: RUF020 `Never | T` is equivalent to `T` +RUF020 `Never | T` is equivalent to `T` + --> RUF020.py:12:11 | 11 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 12 | x: None | Never | None - | ^^^^^ RUF020 + | ^^^^^ 13 | y: (None | Never) | None 14 | z: None | (Never | None) | - = help: Remove `Never` +help: Remove `Never` -RUF020.py:13:12: RUF020 `Never | T` is equivalent to `T` +RUF020 `Never | T` is equivalent to `T` + --> RUF020.py:13:12 | 11 | # Regression tests for https://github.com/astral-sh/ruff/issues/14567 12 | x: None | Never | None 13 | y: (None | Never) | None - | ^^^^^ RUF020 + | ^^^^^ 14 | z: None | (Never | None) | - = help: Remove `Never` +help: Remove `Never` -RUF020.py:14:12: RUF020 `Never | T` is equivalent to `T` +RUF020 `Never | T` is equivalent to `T` + --> RUF020.py:14:12 | 12 | x: None | Never | None 13 | y: (None | Never) | None 14 | z: None | (Never | None) - | ^^^^^ RUF020 + | ^^^^^ 15 | 16 | a: int | Never | None | - = help: Remove `Never` +help: Remove `Never` -RUF020.py:16:10: RUF020 `Never | T` is equivalent to `T` +RUF020 `Never | T` is equivalent to `T` + --> RUF020.py:16:10 | 14 | z: None | (Never | None) 15 | 16 | a: int | Never | None - | ^^^^^ RUF020 + | ^^^^^ 17 | b: Never | Never | None | - = help: Remove `Never` +help: Remove `Never` -RUF020.py:17:4: RUF020 `Never | T` is equivalent to `T` +RUF020 `Never | T` is equivalent to `T` + --> RUF020.py:17:4 | 16 | a: int | Never | None 17 | b: Never | Never | None - | ^^^^^ RUF020 + | ^^^^^ | - = help: Remove `Never` +help: Remove `Never` -RUF020.py:17:12: RUF020 `Never | T` is equivalent to `T` +RUF020 `Never | T` is equivalent to `T` + --> RUF020.py:17:12 | 16 | a: int | Never | None 17 | b: Never | Never | None - | ^^^^^ RUF020 + | ^^^^^ | - = help: Remove `Never` +help: Remove `Never` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap index 5239070ff1..6ea60e2fbe 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF021_RUF021.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF021.py:12:10: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:12:10 | 11 | a, b, c = 1, 0, 2 12 | x = a or b and c # RUF021: => `a or (b and c)` - | ^^^^^^^ RUF021 + | ^^^^^^^ 13 | x = a or b and c # looooooooooooooooooooooooooooooong comment but it won't prevent an autofix | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 9 9 | # as part of a chain. @@ -20,16 +21,17 @@ RUF021.py:12:10: RUF021 [*] Parenthesize `a and b` expressions when chaining `an 14 14 | 15 15 | a, b, c = 0, 1, 2 -RUF021.py:13:10: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:13:10 | 11 | a, b, c = 1, 0, 2 12 | x = a or b and c # RUF021: => `a or (b and c)` 13 | x = a or b and c # looooooooooooooooooooooooooooooong comment but it won't prevent an autofix - | ^^^^^^^ RUF021 + | ^^^^^^^ 14 | 15 | a, b, c = 0, 1, 2 | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 10 10 | @@ -41,15 +43,16 @@ RUF021.py:13:10: RUF021 [*] Parenthesize `a and b` expressions when chaining `an 15 15 | a, b, c = 0, 1, 2 16 16 | y = a and b or c # RUF021: => `(a and b) or c` -RUF021.py:16:5: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:16:5 | 15 | a, b, c = 0, 1, 2 16 | y = a and b or c # RUF021: => `(a and b) or c` - | ^^^^^^^ RUF021 + | ^^^^^^^ 17 | 18 | a, b, c, d = 1, 2, 0, 3 | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 13 13 | x = a or b and c # looooooooooooooooooooooooooooooong comment but it won't prevent an autofix @@ -61,14 +64,15 @@ RUF021.py:16:5: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 18 18 | a, b, c, d = 1, 2, 0, 3 19 19 | if a or b or c and d: # RUF021: => `a or b or (c and d)` -RUF021.py:19:14: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:19:14 | 18 | a, b, c, d = 1, 2, 0, 3 19 | if a or b or c and d: # RUF021: => `a or b or (c and d)` - | ^^^^^^^ RUF021 + | ^^^^^^^ 20 | pass | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 16 16 | y = a and b or c # RUF021: => `(a and b) or c` @@ -80,15 +84,16 @@ RUF021.py:19:14: RUF021 [*] Parenthesize `a and b` expressions when chaining `an 21 21 | 22 22 | a, b, c, d = 0, 0, 2, 3 -RUF021.py:26:11: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:26:11 | 24 | if bool(): 25 | pass 26 | elif a or b and c or d: # RUF021: => `a or (b and c) or d` - | ^^^^^^^ RUF021 + | ^^^^^^^ 27 | pass | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 23 23 | @@ -100,14 +105,15 @@ RUF021.py:26:11: RUF021 [*] Parenthesize `a and b` expressions when chaining `an 28 28 | 29 29 | a, b, c, d = 0, 1, 0, 2 -RUF021.py:30:7: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:30:7 | 29 | a, b, c, d = 0, 1, 0, 2 30 | while a and b or c and d: # RUF021: => `(and b) or (c and d)` - | ^^^^^^^ RUF021 + | ^^^^^^^ 31 | pass | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 27 27 | pass @@ -119,14 +125,15 @@ RUF021.py:30:7: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 32 32 | 33 33 | b, c, d, e = 2, 3, 0, 4 -RUF021.py:30:18: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:30:18 | 29 | a, b, c, d = 0, 1, 0, 2 30 | while a and b or c and d: # RUF021: => `(and b) or (c and d)` - | ^^^^^^^ RUF021 + | ^^^^^^^ 31 | pass | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 27 27 | pass @@ -138,16 +145,17 @@ RUF021.py:30:18: RUF021 [*] Parenthesize `a and b` expressions when chaining `an 32 32 | 33 33 | b, c, d, e = 2, 3, 0, 4 -RUF021.py:35:44: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:35:44 | 33 | b, c, d, e = 2, 3, 0, 4 34 | # RUF021: => `a or b or c or (d and e)`: 35 | z = [a for a in range(5) if a or b or c or d and e] - | ^^^^^^^ RUF021 + | ^^^^^^^ 36 | 37 | a, b, c, d = 0, 1, 3, 0 | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 32 32 | @@ -159,15 +167,16 @@ RUF021.py:35:44: RUF021 [*] Parenthesize `a and b` expressions when chaining `an 37 37 | a, b, c, d = 0, 1, 3, 0 38 38 | assert not a and b or c or d # RUF021: => `(not a and b) or c or d` -RUF021.py:38:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:38:8 | 37 | a, b, c, d = 0, 1, 3, 0 38 | assert not a and b or c or d # RUF021: => `(not a and b) or c or d` - | ^^^^^^^^^^^ RUF021 + | ^^^^^^^^^^^ 39 | 40 | if (not a) and b or c or d: # RUF021: => `((not a) and b) or c or d` | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 35 35 | z = [a for a in range(5) if a or b or c or d and e] @@ -179,16 +188,17 @@ RUF021.py:38:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 40 40 | if (not a) and b or c or d: # RUF021: => `((not a) and b) or c or d` 41 41 | if (not a and b) or c or d: # OK -RUF021.py:40:4: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:40:4 | 38 | assert not a and b or c or d # RUF021: => `(not a and b) or c or d` 39 | 40 | if (not a) and b or c or d: # RUF021: => `((not a) and b) or c or d` - | ^^^^^^^^^^^^^ RUF021 + | ^^^^^^^^^^^^^ 41 | if (not a and b) or c or d: # OK 42 | pass | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 37 37 | a, b, c, d = 0, 1, 3, 0 @@ -200,18 +210,19 @@ RUF021.py:40:4: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 42 42 | pass 43 43 | -RUF021.py:46:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:46:8 | 44 | if ( 45 | some_reasonably_long_condition 46 | or some_other_reasonably_long_condition | ________^ 47 | | and some_third_reasonably_long_condition - | |____________________________________________^ RUF021 + | |____________________________________________^ 48 | or some_fourth_reasonably_long_condition 49 | and some_fifth_reasonably_long_condition | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 43 43 | @@ -225,7 +236,8 @@ RUF021.py:46:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 49 49 | and some_fifth_reasonably_long_condition 50 50 | # a comment -RUF021.py:48:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear +RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear + --> RUF021.py:48:8 | 46 | or some_other_reasonably_long_condition 47 | and some_third_reasonably_long_condition @@ -235,11 +247,11 @@ RUF021.py:48:8: RUF021 [*] Parenthesize `a and b` expressions when chaining `and 50 | | # a comment 51 | | and some_sixth_reasonably_long_condition 52 | | and some_seventh_reasonably_long_condition - | |______________________________________________^ RUF021 + | |______________________________________________^ 53 | # another comment 54 | or some_eighth_reasonably_long_condition | - = help: Parenthesize the `and` subexpression +help: Parenthesize the `and` subexpression ℹ Safe fix 45 45 | some_reasonably_long_condition diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap index f512d92a1d..bc41f1e126 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF022_RUF022.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF022.py:5:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:5:11 | 3 | ################################################## 4 | 5 | __all__ = ["d", "c", "b", "a"] # a comment that is untouched - | ^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^ 6 | __all__ += ["foo", "bar", "antipasti"] 7 | __all__ = ("d", "c", "b", "a") | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 2 2 | # Single-line __all__ definitions (nice 'n' easy!) @@ -22,14 +23,15 @@ RUF022.py:5:11: RUF022 [*] `__all__` is not sorted 7 7 | __all__ = ("d", "c", "b", "a") 8 8 | -RUF022.py:6:12: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:6:12 | 5 | __all__ = ["d", "c", "b", "a"] # a comment that is untouched 6 | __all__ += ["foo", "bar", "antipasti"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | __all__ = ("d", "c", "b", "a") | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 3 3 | ################################################## @@ -41,16 +43,17 @@ RUF022.py:6:12: RUF022 [*] `__all__` is not sorted 8 8 | 9 9 | # Quoting style is retained, -RUF022.py:7:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:7:11 | 5 | __all__ = ["d", "c", "b", "a"] # a comment that is untouched 6 | __all__ += ["foo", "bar", "antipasti"] 7 | __all__ = ("d", "c", "b", "a") - | ^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # Quoting style is retained, | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 4 4 | @@ -62,16 +65,17 @@ RUF022.py:7:11: RUF022 [*] `__all__` is not sorted 9 9 | # Quoting style is retained, 10 10 | # but unnecessary parens are not -RUF022.py:11:17: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:11:17 | 9 | # Quoting style is retained, 10 | # but unnecessary parens are not 11 | __all__: list = ['b', "c", ((('a')))] - | ^^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^^ 12 | # Trailing commas are also not retained in single-line `__all__` definitions 13 | # (but they are in multiline `__all__` definitions) | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 8 8 | @@ -83,16 +87,17 @@ RUF022.py:11:17: RUF022 [*] `__all__` is not sorted 13 13 | # (but they are in multiline `__all__` definitions) 14 14 | __all__: tuple = ("b", "c", "a",) -RUF022.py:14:18: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:14:18 | 12 | # Trailing commas are also not retained in single-line `__all__` definitions 13 | # (but they are in multiline `__all__` definitions) 14 | __all__: tuple = ("b", "c", "a",) - | ^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^ 15 | 16 | if bool(): | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 11 11 | __all__: list = ['b', "c", ((('a')))] @@ -104,15 +109,16 @@ RUF022.py:14:18: RUF022 [*] `__all__` is not sorted 16 16 | if bool(): 17 17 | __all__ += ("x", "m", "a", "s") -RUF022.py:17:16: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:17:16 | 16 | if bool(): 17 | __all__ += ("x", "m", "a", "s") - | ^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^ 18 | else: 19 | __all__ += "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 14 14 | __all__: tuple = ("b", "c", "a",) @@ -124,16 +130,17 @@ RUF022.py:17:16: RUF022 [*] `__all__` is not sorted 19 19 | __all__ += "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) 20 20 | -RUF022.py:19:16: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:19:16 | 17 | __all__ += ("x", "m", "a", "s") 18 | else: 19 | __all__ += "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) - | ^^^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | __all__: list[str] = ["the", "three", "little", "pigs"] | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 16 16 | if bool(): @@ -145,16 +152,17 @@ RUF022.py:19:16: RUF022 [*] `__all__` is not sorted 21 21 | __all__: list[str] = ["the", "three", "little", "pigs"] 22 22 | -RUF022.py:21:22: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:21:22 | 19 | __all__ += "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) 20 | 21 | __all__: list[str] = ["the", "three", "little", "pigs"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 18 18 | else: @@ -166,16 +174,17 @@ RUF022.py:21:22: RUF022 [*] `__all__` is not sorted 23 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") 24 24 | __all__.extend(["foo", "bar"]) -RUF022.py:23:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:23:11 | 21 | __all__: list[str] = ["the", "three", "little", "pigs"] 22 | 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | __all__.extend(["foo", "bar"]) 25 | __all__.extend(("foo", "bar")) | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 20 20 | @@ -187,15 +196,16 @@ RUF022.py:23:11: RUF022 [*] `__all__` is not sorted 25 25 | __all__.extend(("foo", "bar")) 26 26 | __all__.extend((((["foo", "bar"])))) -RUF022.py:24:16: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:24:16 | 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") 24 | __all__.extend(["foo", "bar"]) - | ^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^ 25 | __all__.extend(("foo", "bar")) 26 | __all__.extend((((["foo", "bar"])))) | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 21 21 | __all__: list[str] = ["the", "three", "little", "pigs"] @@ -207,15 +217,16 @@ RUF022.py:24:16: RUF022 [*] `__all__` is not sorted 26 26 | __all__.extend((((["foo", "bar"])))) 27 27 | -RUF022.py:25:16: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:25:16 | 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") 24 | __all__.extend(["foo", "bar"]) 25 | __all__.extend(("foo", "bar")) - | ^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^ 26 | __all__.extend((((["foo", "bar"])))) | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 22 22 | @@ -227,16 +238,17 @@ RUF022.py:25:16: RUF022 [*] `__all__` is not sorted 27 27 | 28 28 | #################################### -RUF022.py:26:19: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:26:19 | 24 | __all__.extend(["foo", "bar"]) 25 | __all__.extend(("foo", "bar")) 26 | __all__.extend((((["foo", "bar"])))) - | ^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^ 27 | 28 | #################################### | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 23 23 | __all__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") @@ -248,7 +260,8 @@ RUF022.py:26:19: RUF022 [*] `__all__` is not sorted 28 28 | #################################### 29 29 | # Neat multiline __all__ definitions -RUF022.py:32:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:32:11 | 30 | #################################### 31 | @@ -260,11 +273,11 @@ RUF022.py:32:11: RUF022 [*] `__all__` is not sorted 36 | | # a comment regarding 'a0': 37 | | "a0" 38 | | ) - | |_^ RUF022 + | |_^ 39 | 40 | __all__ = [ | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 30 30 | #################################### @@ -283,7 +296,8 @@ RUF022.py:32:11: RUF022 [*] `__all__` is not sorted 39 39 | 40 40 | __all__ = [ -RUF022.py:40:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:40:11 | 38 | ) 39 | @@ -295,11 +309,11 @@ RUF022.py:40:11: RUF022 [*] `__all__` is not sorted 44 | | # a comment regarding 'a': 45 | | "a" 46 | | ] - | |_^ RUF022 + | |_^ 47 | 48 | # we implement an "isort-style sort": | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 38 38 | ) @@ -318,7 +332,8 @@ RUF022.py:40:11: RUF022 [*] `__all__` is not sorted 47 47 | 48 48 | # we implement an "isort-style sort": -RUF022.py:54:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:54:11 | 52 | # This (which is currently alphabetically sorted) 53 | # should get reordered accordingly: @@ -354,11 +369,11 @@ RUF022.py:54:11: RUF022 [*] `__all__` is not sorted 82 | | "timegm", 83 | | "weekday", 84 | | "weekheader"] - | |_________________^ RUF022 + | |_________________^ 85 | 86 | ########################################## | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 54 54 | __all__ = [ @@ -405,7 +420,8 @@ RUF022.py:54:11: RUF022 [*] `__all__` is not sorted 86 87 | ########################################## 87 88 | # Messier multiline __all__ definitions... -RUF022.py:91:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:91:11 | 90 | # comment0 91 | __all__ = ("d", "a", # comment1 @@ -417,10 +433,10 @@ RUF022.py:91:11: RUF022 [*] `__all__` is not sorted 96 | | "formatted", 97 | | # comment5 98 | | ) # comment6 - | |_^ RUF022 + | |_^ 99 | # comment7 | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 88 88 | ########################################## @@ -444,7 +460,8 @@ RUF022.py:91:11: RUF022 [*] `__all__` is not sorted 98 101 | ) # comment6 99 102 | # comment7 -RUF022.py:101:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:101:11 | 99 | # comment7 100 | @@ -457,11 +474,11 @@ RUF022.py:101:11: RUF022 [*] `__all__` is not sorted 106 | | # comment5 107 | | # comment6 108 | | ] # comment7 - | |_^ RUF022 + | |_^ 109 | 110 | __all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE", | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 99 99 | # comment7 @@ -478,7 +495,8 @@ RUF022.py:101:11: RUF022 [*] `__all__` is not sorted 106 109 | # comment5 107 110 | # comment6 -RUF022.py:110:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:110:11 | 108 | ] # comment7 109 | @@ -497,11 +515,11 @@ RUF022.py:110:11: RUF022 [*] `__all__` is not sorted 121 | | "xmlcharrefreplace_errors", 122 | | "backslashreplace_errors", "namereplace_errors", 123 | | "register_error", "lookup_error"] - | |____________________________________________^ RUF022 + | |____________________________________________^ 124 | 125 | __all__: tuple[str, ...] = ( # a comment about the opening paren | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 107 107 | # comment6 @@ -571,7 +589,8 @@ RUF022.py:110:11: RUF022 [*] `__all__` is not sorted 125 157 | __all__: tuple[str, ...] = ( # a comment about the opening paren 126 158 | # multiline comment about "bbb" part 1 -RUF022.py:125:28: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:125:28 | 123 | "register_error", "lookup_error"] 124 | @@ -584,11 +603,11 @@ RUF022.py:125:28: RUF022 [*] `__all__` is not sorted 130 | | # multiline comment about "aaa" part 2 131 | | "aaa", 132 | | ) - | |_^ RUF022 + | |_^ 133 | 134 | # we use natural sort for `__all__`, | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 123 123 | "register_error", "lookup_error"] @@ -607,7 +626,8 @@ RUF022.py:125:28: RUF022 [*] `__all__` is not sorted 133 133 | 134 134 | # we use natural sort for `__all__`, -RUF022.py:138:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:138:11 | 136 | # Also, this doesn't end with a trailing comma, 137 | # so the autofix shouldn't introduce one: @@ -618,11 +638,11 @@ RUF022.py:138:11: RUF022 [*] `__all__` is not sorted 141 | | "aadvark174", # the very long whitespace span before this comment is retained 142 | | "aadvark532" # the even longer whitespace span before this comment is retained 143 | | ) - | |_^ RUF022 + | |_^ 144 | 145 | __all__.extend(( # comment0 | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 136 136 | # Also, this doesn't end with a trailing comma, @@ -639,7 +659,8 @@ RUF022.py:138:11: RUF022 [*] `__all__` is not sorted 144 144 | 145 145 | __all__.extend(( # comment0 -RUF022.py:145:16: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:145:16 | 143 | ) 144 | @@ -651,11 +672,11 @@ RUF022.py:145:16: RUF022 [*] `__all__` is not sorted 149 | | "bar" # comment about bar 150 | | # comment1 151 | | )) # comment2 - | |_^ RUF022 + | |_^ 152 | 153 | __all__.extend( # comment0 | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 143 143 | ) @@ -672,7 +693,8 @@ RUF022.py:145:16: RUF022 [*] `__all__` is not sorted 151 151 | )) # comment2 152 152 | -RUF022.py:155:5: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:155:5 | 153 | __all__.extend( # comment0 154 | # comment1 @@ -683,10 +705,10 @@ RUF022.py:155:5: RUF022 [*] `__all__` is not sorted 159 | | "bar" # comment about bar 160 | | # comment3 161 | | ) # comment4 - | |_____^ RUF022 + | |_____^ 162 | ) # comment2 | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 153 153 | __all__.extend( # comment0 @@ -703,7 +725,8 @@ RUF022.py:155:5: RUF022 [*] `__all__` is not sorted 161 161 | ) # comment4 162 162 | ) # comment2 -RUF022.py:164:16: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:164:16 | 162 | ) # comment2 163 | @@ -715,11 +738,11 @@ RUF022.py:164:16: RUF022 [*] `__all__` is not sorted 168 | | "bar" # comment about bar 169 | | # comment1 170 | | ]) # comment2 - | |_^ RUF022 + | |_^ 171 | 172 | __all__.extend( # comment0 | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 162 162 | ) # comment2 @@ -736,7 +759,8 @@ RUF022.py:164:16: RUF022 [*] `__all__` is not sorted 170 170 | ]) # comment2 171 171 | -RUF022.py:174:5: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:174:5 | 172 | __all__.extend( # comment0 173 | # comment1 @@ -747,10 +771,10 @@ RUF022.py:174:5: RUF022 [*] `__all__` is not sorted 178 | | "bar" # comment about bar 179 | | # comment3 180 | | ] # comment4 - | |_____^ RUF022 + | |_____^ 181 | ) # comment2 | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 172 172 | __all__.extend( # comment0 @@ -767,7 +791,8 @@ RUF022.py:174:5: RUF022 [*] `__all__` is not sorted 180 180 | ] # comment4 181 181 | ) # comment2 -RUF022.py:183:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:183:11 | 181 | ) # comment2 182 | @@ -776,11 +801,11 @@ RUF022.py:183:11: RUF022 [*] `__all__` is not sorted 184 | | # Extensions 185 | | "LabeledScale", "OptionMenu", 186 | | ] - | |_^ RUF022 + | |_^ 187 | 188 | __all__ = ["Awaitable", "Coroutine", | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 180 180 | ] # comment4 @@ -799,7 +824,8 @@ RUF022.py:183:11: RUF022 [*] `__all__` is not sorted 187 190 | 188 191 | __all__ = ["Awaitable", "Coroutine", -RUF022.py:188:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:188:11 | 186 | ] 187 | @@ -807,11 +833,11 @@ RUF022.py:188:11: RUF022 [*] `__all__` is not sorted | ___________^ 189 | | "AsyncIterable", "AsyncIterator", "AsyncGenerator", 190 | | ] - | |____________^ RUF022 + | |____________^ 191 | 192 | __all__ = [ | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 185 185 | "LabeledScale", "OptionMenu", @@ -831,7 +857,8 @@ RUF022.py:188:11: RUF022 [*] `__all__` is not sorted 192 196 | __all__ = [ 193 197 | "foo", -RUF022.py:192:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:192:11 | 190 | ] 191 | @@ -841,11 +868,11 @@ RUF022.py:192:11: RUF022 [*] `__all__` is not sorted 194 | | "bar", 195 | | "baz", 196 | | ] - | |_____^ RUF022 + | |_____^ 197 | 198 | ######################################################################### | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 190 190 | ] @@ -859,7 +886,8 @@ RUF022.py:192:11: RUF022 [*] `__all__` is not sorted 197 197 | 198 198 | ######################################################################### -RUF022.py:204:11: RUF022 `__all__` is not sorted +RUF022 `__all__` is not sorted + --> RUF022.py:204:11 | 202 | ######################################################################### 203 | @@ -870,13 +898,14 @@ RUF022.py:204:11: RUF022 `__all__` is not sorted 207 | | "a_veeeeeeeeeeeeeeeeeeery_long_parenthesized_item" 208 | | ), 209 | | ) - | |_^ RUF022 + | |_^ 210 | 211 | __all__ = ( | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` -RUF022.py:211:11: RUF022 `__all__` is not sorted +RUF022 `__all__` is not sorted + --> RUF022.py:211:11 | 209 | ) 210 | @@ -888,24 +917,26 @@ RUF022.py:211:11: RUF022 `__all__` is not sorted 215 | | )), 216 | | "a" 217 | | ) - | |_^ RUF022 + | |_^ 218 | 219 | __all__ = ("don't" "care" "about", "__all__" "with", "concatenated" "strings") | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` -RUF022.py:219:11: RUF022 `__all__` is not sorted +RUF022 `__all__` is not sorted + --> RUF022.py:219:11 | 217 | ) 218 | 219 | __all__ = ("don't" "care" "about", "__all__" "with", "concatenated" "strings") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF022 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 220 | 221 | ############################################################ | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` -RUF022.py:225:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:225:11 | 223 | ############################################################ 224 | @@ -913,11 +944,11 @@ RUF022.py:225:11: RUF022 [*] `__all__` is not sorted | ___________^ 226 | | "loads", 227 | | "dumps",) - | |_____________^ RUF022 + | |_____________^ 228 | 229 | __all__ = [ | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 223 223 | ############################################################ @@ -931,7 +962,8 @@ RUF022.py:225:11: RUF022 [*] `__all__` is not sorted 229 230 | __all__ = [ 230 231 | "loads", -RUF022.py:229:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:229:11 | 227 | "dumps",) 228 | @@ -939,11 +971,11 @@ RUF022.py:229:11: RUF022 [*] `__all__` is not sorted | ___________^ 230 | | "loads", 231 | | "dumps" , ] - | |_________________________^ RUF022 + | |_________________________^ 232 | 233 | __all__ = ['xp', 'yp', | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 227 227 | "dumps",) @@ -957,7 +989,8 @@ RUF022.py:229:11: RUF022 [*] `__all__` is not sorted 233 233 | __all__ = ['xp', 'yp', 234 234 | 'canvas' -RUF022.py:233:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:233:11 | 231 | "dumps" , ] 232 | @@ -971,11 +1004,11 @@ RUF022.py:233:11: RUF022 [*] `__all__` is not sorted 239 | | 240 | | # another strangely placed comment 241 | | ] - | |_________________^ RUF022 + | |_________________^ 242 | 243 | __all__ = ( | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Safe fix 230 230 | "loads", @@ -991,7 +1024,8 @@ RUF022.py:233:11: RUF022 [*] `__all__` is not sorted 236 238 | # very strangely placed comment 237 239 | -RUF022.py:243:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:243:11 | 241 | ] 242 | @@ -1005,11 +1039,11 @@ RUF022.py:243:11: RUF022 [*] `__all__` is not sorted 249 | | # strange comment 2 250 | | , 251 | | ) - | |_^ RUF022 + | |_^ 252 | 253 | __all__ = ( # comment about the opening paren | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 241 241 | ] @@ -1026,7 +1060,8 @@ RUF022.py:243:11: RUF022 [*] `__all__` is not sorted 250 249 | , 251 250 | ) -RUF022.py:253:11: RUF022 [*] `__all__` is not sorted +RUF022 [*] `__all__` is not sorted + --> RUF022.py:253:11 | 251 | ) 252 | @@ -1047,11 +1082,11 @@ RUF022.py:253:11: RUF022 [*] `__all__` is not sorted 266 | | # strange multiline comment 3a 267 | | # strange multiline comment 3b 268 | | ) # comment about the closing paren - | |_^ RUF022 + | |_^ 269 | 270 | ################################### | - = help: Apply an isort-style sorting to `__all__` +help: Apply an isort-style sorting to `__all__` ℹ Unsafe fix 251 251 | ) diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap index 452195dad7..a65d4c791d 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF023_RUF023.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF023.py:6:17: RUF023 [*] `Klass.__slots__` is not sorted +RUF023 [*] `Klass.__slots__` is not sorted + --> RUF023.py:6:17 | 5 | class Klass: 6 | __slots__ = ["d", "c", "b", "a"] # a comment that is untouched - | ^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^ 7 | __slots__ = ("d", "c", "b", "a") | - = help: Apply a natural sort to `Klass.__slots__` +help: Apply a natural sort to `Klass.__slots__` ℹ Safe fix 3 3 | ######################### @@ -20,16 +21,17 @@ RUF023.py:6:17: RUF023 [*] `Klass.__slots__` is not sorted 8 8 | 9 9 | # Quoting style is retained, -RUF023.py:7:17: RUF023 [*] `Klass.__slots__` is not sorted +RUF023 [*] `Klass.__slots__` is not sorted + --> RUF023.py:7:17 | 5 | class Klass: 6 | __slots__ = ["d", "c", "b", "a"] # a comment that is untouched 7 | __slots__ = ("d", "c", "b", "a") - | ^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # Quoting style is retained, | - = help: Apply a natural sort to `Klass.__slots__` +help: Apply a natural sort to `Klass.__slots__` ℹ Safe fix 4 4 | @@ -41,16 +43,17 @@ RUF023.py:7:17: RUF023 [*] `Klass.__slots__` is not sorted 9 9 | # Quoting style is retained, 10 10 | # but unnecessary parens are not -RUF023.py:11:22: RUF023 [*] `Klass.__slots__` is not sorted +RUF023 [*] `Klass.__slots__` is not sorted + --> RUF023.py:11:22 | 9 | # Quoting style is retained, 10 | # but unnecessary parens are not 11 | __slots__: set = {'b', "c", ((('a')))} - | ^^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^^ 12 | # Trailing commas are also not retained for single-line definitions 13 | # (but they are in multiline definitions) | - = help: Apply a natural sort to `Klass.__slots__` +help: Apply a natural sort to `Klass.__slots__` ℹ Safe fix 8 8 | @@ -62,16 +65,17 @@ RUF023.py:11:22: RUF023 [*] `Klass.__slots__` is not sorted 13 13 | # (but they are in multiline definitions) 14 14 | __slots__: tuple = ("b", "c", "a",) -RUF023.py:14:24: RUF023 [*] `Klass.__slots__` is not sorted +RUF023 [*] `Klass.__slots__` is not sorted + --> RUF023.py:14:24 | 12 | # Trailing commas are also not retained for single-line definitions 13 | # (but they are in multiline definitions) 14 | __slots__: tuple = ("b", "c", "a",) - | ^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^ 15 | 16 | class Klass2: | - = help: Apply a natural sort to `Klass.__slots__` +help: Apply a natural sort to `Klass.__slots__` ℹ Safe fix 11 11 | __slots__: set = {'b', "c", ((('a')))} @@ -83,16 +87,17 @@ RUF023.py:14:24: RUF023 [*] `Klass.__slots__` is not sorted 16 16 | class Klass2: 17 17 | if bool(): -RUF023.py:18:21: RUF023 [*] `Klass2.__slots__` is not sorted +RUF023 [*] `Klass2.__slots__` is not sorted + --> RUF023.py:18:21 | 16 | class Klass2: 17 | if bool(): 18 | __slots__ = {"x": "docs for x", "m": "docs for m", "a": "docs for a"} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 19 | else: 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) | - = help: Apply a natural sort to `Klass2.__slots__` +help: Apply a natural sort to `Klass2.__slots__` ℹ Safe fix 15 15 | @@ -104,16 +109,17 @@ RUF023.py:18:21: RUF023 [*] `Klass2.__slots__` is not sorted 20 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) 21 21 | -RUF023.py:20:21: RUF023 [*] `Klass2.__slots__` is not sorted +RUF023 [*] `Klass2.__slots__` is not sorted + --> RUF023.py:20:21 | 18 | __slots__ = {"x": "docs for x", "m": "docs for m", "a": "docs for a"} 19 | else: 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) - | ^^^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^^^ 21 | 22 | __slots__: list[str] = ["the", "three", "little", "pigs"] | - = help: Apply a natural sort to `Klass2.__slots__` +help: Apply a natural sort to `Klass2.__slots__` ℹ Safe fix 17 17 | if bool(): @@ -125,16 +131,17 @@ RUF023.py:20:21: RUF023 [*] `Klass2.__slots__` is not sorted 22 22 | __slots__: list[str] = ["the", "three", "little", "pigs"] 23 23 | __slots__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") -RUF023.py:22:28: RUF023 [*] `Klass2.__slots__` is not sorted +RUF023 [*] `Klass2.__slots__` is not sorted + --> RUF023.py:22:28 | 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) 21 | 22 | __slots__: list[str] = ["the", "three", "little", "pigs"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 23 | __slots__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") 24 | # we use natural sort, | - = help: Apply a natural sort to `Klass2.__slots__` +help: Apply a natural sort to `Klass2.__slots__` ℹ Safe fix 19 19 | else: @@ -146,15 +153,16 @@ RUF023.py:22:28: RUF023 [*] `Klass2.__slots__` is not sorted 24 24 | # we use natural sort, 25 25 | # not alphabetical sort or "isort-style" sort -RUF023.py:23:17: RUF023 [*] `Klass2.__slots__` is not sorted +RUF023 [*] `Klass2.__slots__` is not sorted + --> RUF023.py:23:17 | 22 | __slots__: list[str] = ["the", "three", "little", "pigs"] 23 | __slots__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 | # we use natural sort, 25 | # not alphabetical sort or "isort-style" sort | - = help: Apply a natural sort to `Klass2.__slots__` +help: Apply a natural sort to `Klass2.__slots__` ℹ Safe fix 20 20 | __slots__ = "foo3", "foo2", "foo1" # NB: an implicit tuple (without parens) @@ -166,16 +174,17 @@ RUF023.py:23:17: RUF023 [*] `Klass2.__slots__` is not sorted 25 25 | # not alphabetical sort or "isort-style" sort 26 26 | __slots__ = {"aadvark237", "aadvark10092", "aadvark174", "aadvark532"} -RUF023.py:26:17: RUF023 [*] `Klass2.__slots__` is not sorted +RUF023 [*] `Klass2.__slots__` is not sorted + --> RUF023.py:26:17 | 24 | # we use natural sort, 25 | # not alphabetical sort or "isort-style" sort 26 | __slots__ = {"aadvark237", "aadvark10092", "aadvark174", "aadvark532"} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | ############################ | - = help: Apply a natural sort to `Klass2.__slots__` +help: Apply a natural sort to `Klass2.__slots__` ℹ Safe fix 23 23 | __slots__ = ("parenthesized_item"), "in", ("an_unparenthesized_tuple") @@ -187,7 +196,8 @@ RUF023.py:26:17: RUF023 [*] `Klass2.__slots__` is not sorted 28 28 | ############################ 29 29 | # Neat multiline definitions -RUF023.py:33:17: RUF023 [*] `Klass3.__slots__` is not sorted +RUF023 [*] `Klass3.__slots__` is not sorted + --> RUF023.py:33:17 | 32 | class Klass3: 33 | __slots__ = ( @@ -198,11 +208,11 @@ RUF023.py:33:17: RUF023 [*] `Klass3.__slots__` is not sorted 37 | | # a comment regarding 'a0': 38 | | "a0" 39 | | ) - | |_____^ RUF023 + | |_____^ 40 | __slots__ = [ 41 | "d", | - = help: Apply a natural sort to `Klass3.__slots__` +help: Apply a natural sort to `Klass3.__slots__` ℹ Unsafe fix 31 31 | @@ -221,7 +231,8 @@ RUF023.py:33:17: RUF023 [*] `Klass3.__slots__` is not sorted 40 40 | __slots__ = [ 41 41 | "d", -RUF023.py:40:17: RUF023 [*] `Klass3.__slots__` is not sorted +RUF023 [*] `Klass3.__slots__` is not sorted + --> RUF023.py:40:17 | 38 | "a0" 39 | ) @@ -233,11 +244,11 @@ RUF023.py:40:17: RUF023 [*] `Klass3.__slots__` is not sorted 44 | | # a comment regarding 'a': 45 | | "a" 46 | | ] - | |_____^ RUF023 + | |_____^ 47 | 48 | ################################## | - = help: Apply a natural sort to `Klass3.__slots__` +help: Apply a natural sort to `Klass3.__slots__` ℹ Unsafe fix 38 38 | "a0" @@ -256,7 +267,8 @@ RUF023.py:40:17: RUF023 [*] `Klass3.__slots__` is not sorted 47 47 | 48 48 | ################################## -RUF023.py:54:17: RUF023 [*] `Klass4.__slots__` is not sorted +RUF023 [*] `Klass4.__slots__` is not sorted + --> RUF023.py:54:17 | 52 | class Klass4: 53 | # comment0 @@ -269,10 +281,10 @@ RUF023.py:54:17: RUF023 [*] `Klass4.__slots__` is not sorted 59 | | "formatted", 60 | | # comment5 61 | | ) # comment6 - | |_____^ RUF023 + | |_____^ 62 | # comment7 | - = help: Apply a natural sort to `Klass4.__slots__` +help: Apply a natural sort to `Klass4.__slots__` ℹ Unsafe fix 51 51 | @@ -296,7 +308,8 @@ RUF023.py:54:17: RUF023 [*] `Klass4.__slots__` is not sorted 61 64 | ) # comment6 62 65 | # comment7 -RUF023.py:64:17: RUF023 [*] `Klass4.__slots__` is not sorted +RUF023 [*] `Klass4.__slots__` is not sorted + --> RUF023.py:64:17 | 62 | # comment7 63 | @@ -309,11 +322,11 @@ RUF023.py:64:17: RUF023 [*] `Klass4.__slots__` is not sorted 69 | | # comment5 70 | | # comment6 71 | | ] # comment7 - | |_____^ RUF023 + | |_____^ 72 | 73 | # from cpython/Lib/pathlib/__init__.py | - = help: Apply a natural sort to `Klass4.__slots__` +help: Apply a natural sort to `Klass4.__slots__` ℹ Unsafe fix 62 62 | # comment7 @@ -330,7 +343,8 @@ RUF023.py:64:17: RUF023 [*] `Klass4.__slots__` is not sorted 69 72 | # comment5 70 73 | # comment6 -RUF023.py:75:17: RUF023 [*] `PurePath.__slots__` is not sorted +RUF023 [*] `PurePath.__slots__` is not sorted + --> RUF023.py:75:17 | 73 | # from cpython/Lib/pathlib/__init__.py 74 | class PurePath: @@ -370,11 +384,11 @@ RUF023.py:75:17: RUF023 [*] `PurePath.__slots__` is not sorted 107 | | # path. It's set when `__hash__()` is called for the first time. 108 | | '_hash', 109 | | ) - | |_____^ RUF023 + | |_____^ 110 | 111 | # From cpython/Lib/pickletools.py | - = help: Apply a natural sort to `PurePath.__slots__` +help: Apply a natural sort to `PurePath.__slots__` ℹ Unsafe fix 73 73 | # from cpython/Lib/pathlib/__init__.py @@ -431,7 +445,8 @@ RUF023.py:75:17: RUF023 [*] `PurePath.__slots__` is not sorted 110 107 | 111 108 | # From cpython/Lib/pickletools.py -RUF023.py:113:17: RUF023 [*] `ArgumentDescriptor.__slots__` is not sorted +RUF023 [*] `ArgumentDescriptor.__slots__` is not sorted + --> RUF023.py:113:17 | 111 | # From cpython/Lib/pickletools.py 112 | class ArgumentDescriptor(object): @@ -453,11 +468,11 @@ RUF023.py:113:17: RUF023 [*] `ArgumentDescriptor.__slots__` is not sorted 127 | | # human-readable docs for this arg descriptor; a string 128 | | 'doc', 129 | | ) - | |_____^ RUF023 + | |_____^ 130 | 131 | #################################### | - = help: Apply a natural sort to `ArgumentDescriptor.__slots__` +help: Apply a natural sort to `ArgumentDescriptor.__slots__` ℹ Unsafe fix 111 111 | # From cpython/Lib/pickletools.py @@ -486,20 +501,22 @@ RUF023.py:113:17: RUF023 [*] `ArgumentDescriptor.__slots__` is not sorted 130 127 | 131 128 | #################################### -RUF023.py:138:17: RUF023 `SlotUser.__slots__` is not sorted +RUF023 `SlotUser.__slots__` is not sorted + --> RUF023.py:138:17 | 136 | # Multiline dicts are out of scope. 137 | class SlotUser: 138 | __slots__ = {'power': 'measured in kilowatts', | _________________^ 139 | | 'distance': 'measured in kilometers'} - | |______________________________________________________^ RUF023 + | |______________________________________________________^ 140 | 141 | class Klass5: | - = help: Apply a natural sort to `SlotUser.__slots__` +help: Apply a natural sort to `SlotUser.__slots__` -RUF023.py:142:17: RUF023 `Klass5.__slots__` is not sorted +RUF023 `Klass5.__slots__` is not sorted + --> RUF023.py:142:17 | 141 | class Klass5: 142 | __slots__ = ( @@ -509,13 +526,14 @@ RUF023.py:142:17: RUF023 `Klass5.__slots__` is not sorted 145 | | "a_veeeeeeeeeeeeeeeeeeery_long_parenthesized_item" 146 | | ), 147 | | ) - | |_____^ RUF023 + | |_____^ 148 | __slots__ = ( 149 | "b", | - = help: Apply a natural sort to `Klass5.__slots__` +help: Apply a natural sort to `Klass5.__slots__` -RUF023.py:148:17: RUF023 `Klass5.__slots__` is not sorted +RUF023 `Klass5.__slots__` is not sorted + --> RUF023.py:148:17 | 146 | ), 147 | ) @@ -527,33 +545,35 @@ RUF023.py:148:17: RUF023 `Klass5.__slots__` is not sorted 152 | | )), 153 | | "a" 154 | | ) - | |_____^ RUF023 + | |_____^ 155 | __slots__ = ("don't" "care" "about", "__slots__" "with", "concatenated" "strings") | - = help: Apply a natural sort to `Klass5.__slots__` +help: Apply a natural sort to `Klass5.__slots__` -RUF023.py:155:17: RUF023 `Klass5.__slots__` is not sorted +RUF023 `Klass5.__slots__` is not sorted + --> RUF023.py:155:17 | 153 | "a" 154 | ) 155 | __slots__ = ("don't" "care" "about", "__slots__" "with", "concatenated" "strings") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 156 | 157 | ############################################################ | - = help: Apply a natural sort to `Klass5.__slots__` +help: Apply a natural sort to `Klass5.__slots__` -RUF023.py:162:17: RUF023 [*] `BezierBuilder.__slots__` is not sorted +RUF023 [*] `BezierBuilder.__slots__` is not sorted + --> RUF023.py:162:17 | 161 | class BezierBuilder: 162 | __slots__ = ('xp', 'yp', | _________________^ 163 | | 'canvas',) - | |___________________________^ RUF023 + | |___________________________^ 164 | 165 | class BezierBuilder2: | - = help: Apply a natural sort to `BezierBuilder.__slots__` +help: Apply a natural sort to `BezierBuilder.__slots__` ℹ Safe fix 159 159 | ############################################################ @@ -570,17 +590,18 @@ RUF023.py:162:17: RUF023 [*] `BezierBuilder.__slots__` is not sorted 165 168 | class BezierBuilder2: 166 169 | __slots__ = {'xp', 'yp', -RUF023.py:166:17: RUF023 [*] `BezierBuilder2.__slots__` is not sorted +RUF023 [*] `BezierBuilder2.__slots__` is not sorted + --> RUF023.py:166:17 | 165 | class BezierBuilder2: 166 | __slots__ = {'xp', 'yp', | _________________^ 167 | | 'canvas' , } - | |___________________________________________^ RUF023 + | |___________________________________________^ 168 | 169 | class BezierBuilder3: | - = help: Apply a natural sort to `BezierBuilder2.__slots__` +help: Apply a natural sort to `BezierBuilder2.__slots__` ℹ Safe fix 163 163 | 'canvas',) @@ -596,7 +617,8 @@ RUF023.py:166:17: RUF023 [*] `BezierBuilder2.__slots__` is not sorted 169 171 | class BezierBuilder3: 170 172 | __slots__ = ['xp', 'yp', -RUF023.py:170:17: RUF023 [*] `BezierBuilder3.__slots__` is not sorted +RUF023 [*] `BezierBuilder3.__slots__` is not sorted + --> RUF023.py:170:17 | 169 | class BezierBuilder3: 170 | __slots__ = ['xp', 'yp', @@ -609,11 +631,11 @@ RUF023.py:170:17: RUF023 [*] `BezierBuilder3.__slots__` is not sorted 176 | | 177 | | # another strangely placed comment 178 | | ] - | |__________________^ RUF023 + | |__________________^ 179 | 180 | class BezierBuilder4: | - = help: Apply a natural sort to `BezierBuilder3.__slots__` +help: Apply a natural sort to `BezierBuilder3.__slots__` ℹ Safe fix 167 167 | 'canvas' , } @@ -629,7 +651,8 @@ RUF023.py:170:17: RUF023 [*] `BezierBuilder3.__slots__` is not sorted 173 175 | # very strangely placed comment 174 176 | -RUF023.py:181:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted +RUF023 [*] `BezierBuilder4.__slots__` is not sorted + --> RUF023.py:181:17 | 180 | class BezierBuilder4: 181 | __slots__ = ( @@ -642,11 +665,11 @@ RUF023.py:181:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted 187 | | # strange comment 2 188 | | , 189 | | ) - | |_____^ RUF023 + | |_____^ 190 | 191 | __slots__ = {"foo", "bar", | - = help: Apply a natural sort to `BezierBuilder4.__slots__` +help: Apply a natural sort to `BezierBuilder4.__slots__` ℹ Unsafe fix 179 179 | @@ -663,7 +686,8 @@ RUF023.py:181:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted 188 187 | , 189 188 | ) -RUF023.py:191:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted +RUF023 [*] `BezierBuilder4.__slots__` is not sorted + --> RUF023.py:191:17 | 189 | ) 190 | @@ -671,9 +695,9 @@ RUF023.py:191:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted | _________________^ 192 | | "baz", "bingo" 193 | | } - | |__________________^ RUF023 + | |__________________^ | - = help: Apply a natural sort to `BezierBuilder4.__slots__` +help: Apply a natural sort to `BezierBuilder4.__slots__` ℹ Safe fix 188 188 | , @@ -692,15 +716,16 @@ RUF023.py:191:17: RUF023 [*] `BezierBuilder4.__slots__` is not sorted 195 198 | 196 199 | class VeryDRY: -RUF023.py:199:17: RUF023 [*] `VeryDRY.__slots__` is not sorted +RUF023 [*] `VeryDRY.__slots__` is not sorted + --> RUF023.py:199:17 | 197 | # This should get flagged, *but* the fix is unsafe, 198 | # since the `__slots__` binding is used by the `__match_args__` definition 199 | __slots__ = ("foo", "bar") - | ^^^^^^^^^^^^^^ RUF023 + | ^^^^^^^^^^^^^^ 200 | __match_args__ = __slots__ | - = help: Apply a natural sort to `VeryDRY.__slots__` +help: Apply a natural sort to `VeryDRY.__slots__` ℹ Unsafe fix 196 196 | class VeryDRY: diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap index 4c361c8639..ce97d23957 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF024_RUF024.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF024.py:9:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` +RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` + --> RUF024.py:9:1 | 8 | # Errors. 9 | dict.fromkeys(pierogi_fillings, []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | dict.fromkeys(pierogi_fillings, list()) 11 | dict.fromkeys(pierogi_fillings, {}) | - = help: Replace with comprehension +help: Replace with comprehension ℹ Unsafe fix 6 6 | ] @@ -21,16 +22,17 @@ RUF024.py:9:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkey 11 11 | dict.fromkeys(pierogi_fillings, {}) 12 12 | dict.fromkeys(pierogi_fillings, set()) -RUF024.py:10:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` +RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` + --> RUF024.py:10:1 | 8 | # Errors. 9 | dict.fromkeys(pierogi_fillings, []) 10 | dict.fromkeys(pierogi_fillings, list()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | dict.fromkeys(pierogi_fillings, {}) 12 | dict.fromkeys(pierogi_fillings, set()) | - = help: Replace with comprehension +help: Replace with comprehension ℹ Unsafe fix 7 7 | @@ -42,16 +44,17 @@ RUF024.py:10:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke 12 12 | dict.fromkeys(pierogi_fillings, set()) 13 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) -RUF024.py:11:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` +RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` + --> RUF024.py:11:1 | 9 | dict.fromkeys(pierogi_fillings, []) 10 | dict.fromkeys(pierogi_fillings, list()) 11 | dict.fromkeys(pierogi_fillings, {}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | dict.fromkeys(pierogi_fillings, set()) 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) | - = help: Replace with comprehension +help: Replace with comprehension ℹ Unsafe fix 8 8 | # Errors. @@ -63,16 +66,17 @@ RUF024.py:11:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke 13 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) 14 14 | dict.fromkeys(pierogi_fillings, dict()) -RUF024.py:12:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` +RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` + --> RUF024.py:12:1 | 10 | dict.fromkeys(pierogi_fillings, list()) 11 | dict.fromkeys(pierogi_fillings, {}) 12 | dict.fromkeys(pierogi_fillings, set()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) 14 | dict.fromkeys(pierogi_fillings, dict()) | - = help: Replace with comprehension +help: Replace with comprehension ℹ Unsafe fix 9 9 | dict.fromkeys(pierogi_fillings, []) @@ -84,16 +88,17 @@ RUF024.py:12:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke 14 14 | dict.fromkeys(pierogi_fillings, dict()) 15 15 | import builtins -RUF024.py:13:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` +RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` + --> RUF024.py:13:1 | 11 | dict.fromkeys(pierogi_fillings, {}) 12 | dict.fromkeys(pierogi_fillings, set()) 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | dict.fromkeys(pierogi_fillings, dict()) 15 | import builtins | - = help: Replace with comprehension +help: Replace with comprehension ℹ Unsafe fix 10 10 | dict.fromkeys(pierogi_fillings, list()) @@ -105,16 +110,17 @@ RUF024.py:13:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke 15 15 | import builtins 16 16 | builtins.dict.fromkeys(pierogi_fillings, dict()) -RUF024.py:14:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` +RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` + --> RUF024.py:14:1 | 12 | dict.fromkeys(pierogi_fillings, set()) 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) 14 | dict.fromkeys(pierogi_fillings, dict()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | import builtins 16 | builtins.dict.fromkeys(pierogi_fillings, dict()) | - = help: Replace with comprehension +help: Replace with comprehension ℹ Unsafe fix 11 11 | dict.fromkeys(pierogi_fillings, {}) @@ -126,16 +132,17 @@ RUF024.py:14:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromke 16 16 | builtins.dict.fromkeys(pierogi_fillings, dict()) 17 17 | -RUF024.py:16:1: RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` +RUF024 [*] Do not pass mutable objects as values to `dict.fromkeys` + --> RUF024.py:16:1 | 14 | dict.fromkeys(pierogi_fillings, dict()) 15 | import builtins 16 | builtins.dict.fromkeys(pierogi_fillings, dict()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF024 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | # Okay. | - = help: Replace with comprehension +help: Replace with comprehension ℹ Unsafe fix 13 13 | dict.fromkeys(pierogi_fillings, {"pre": "populated!"}) diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap index aa55a48204..d04a3b3768 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF026_RUF026.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF026.py:11:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:11:5 | 10 | def func(): 11 | defaultdict(default_factory=int) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=int)` +help: Replace with `defaultdict(default_factory=int)` ℹ Unsafe fix 8 8 | @@ -19,13 +20,14 @@ RUF026.py:11:5: RUF026 [*] `default_factory` is a positional-only argument to `d 13 13 | 14 14 | def func(): -RUF026.py:15:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:15:5 | 14 | def func(): 15 | defaultdict(default_factory=float) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=float)` +help: Replace with `defaultdict(default_factory=float)` ℹ Unsafe fix 12 12 | @@ -37,13 +39,14 @@ RUF026.py:15:5: RUF026 [*] `default_factory` is a positional-only argument to `d 17 17 | 18 18 | def func(): -RUF026.py:19:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:19:5 | 18 | def func(): 19 | defaultdict(default_factory=dict) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=dict)` +help: Replace with `defaultdict(default_factory=dict)` ℹ Unsafe fix 16 16 | @@ -55,13 +58,14 @@ RUF026.py:19:5: RUF026 [*] `default_factory` is a positional-only argument to `d 21 21 | 22 22 | def func(): -RUF026.py:23:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:23:5 | 22 | def func(): 23 | defaultdict(default_factory=list) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=list)` +help: Replace with `defaultdict(default_factory=list)` ℹ Unsafe fix 20 20 | @@ -73,13 +77,14 @@ RUF026.py:23:5: RUF026 [*] `default_factory` is a positional-only argument to `d 25 25 | 26 26 | def func(): -RUF026.py:27:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:27:5 | 26 | def func(): 27 | defaultdict(default_factory=tuple) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=tuple)` +help: Replace with `defaultdict(default_factory=tuple)` ℹ Unsafe fix 24 24 | @@ -91,14 +96,15 @@ RUF026.py:27:5: RUF026 [*] `default_factory` is a positional-only argument to `d 29 29 | 30 30 | def func(): -RUF026.py:34:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:34:5 | 32 | pass 33 | 34 | defaultdict(default_factory=foo) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=foo)` +help: Replace with `defaultdict(default_factory=foo)` ℹ Unsafe fix 31 31 | def foo(): @@ -110,13 +116,14 @@ RUF026.py:34:5: RUF026 [*] `default_factory` is a positional-only argument to `d 36 36 | 37 37 | def func(): -RUF026.py:38:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:38:5 | 37 | def func(): 38 | defaultdict(default_factory=lambda: 1) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=lambda: 1)` +help: Replace with `defaultdict(default_factory=lambda: 1)` ℹ Unsafe fix 35 35 | @@ -128,14 +135,15 @@ RUF026.py:38:5: RUF026 [*] `default_factory` is a positional-only argument to `d 40 40 | 41 41 | def func(): -RUF026.py:44:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:44:5 | 42 | from collections import deque 43 | 44 | defaultdict(default_factory=deque) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=deque)` +help: Replace with `defaultdict(default_factory=deque)` ℹ Unsafe fix 41 41 | def func(): @@ -147,14 +155,15 @@ RUF026.py:44:5: RUF026 [*] `default_factory` is a positional-only argument to `d 46 46 | 47 47 | def func(): -RUF026.py:52:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:52:5 | 50 | pass 51 | 52 | defaultdict(default_factory=MyCallable()) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=MyCallable())` +help: Replace with `defaultdict(default_factory=MyCallable())` ℹ Unsafe fix 49 49 | def __call__(self): @@ -166,13 +175,14 @@ RUF026.py:52:5: RUF026 [*] `default_factory` is a positional-only argument to `d 54 54 | 55 55 | def func(): -RUF026.py:56:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:56:5 | 55 | def func(): 56 | defaultdict(default_factory=tuple, member=1) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=tuple)` +help: Replace with `defaultdict(default_factory=tuple)` ℹ Unsafe fix 53 53 | @@ -184,13 +194,14 @@ RUF026.py:56:5: RUF026 [*] `default_factory` is a positional-only argument to `d 58 58 | 59 59 | def func(): -RUF026.py:60:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:60:5 | 59 | def func(): 60 | defaultdict(member=1, default_factory=tuple) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=tuple)` +help: Replace with `defaultdict(default_factory=tuple)` ℹ Unsafe fix 57 57 | @@ -202,13 +213,14 @@ RUF026.py:60:5: RUF026 [*] `default_factory` is a positional-only argument to `d 62 62 | 63 63 | def func(): -RUF026.py:64:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:64:5 | 63 | def func(): 64 | defaultdict(member=1, default_factory=tuple,) # RUF026 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF026 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `defaultdict(default_factory=tuple)` +help: Replace with `defaultdict(default_factory=tuple)` ℹ Unsafe fix 61 61 | @@ -220,16 +232,17 @@ RUF026.py:64:5: RUF026 [*] `default_factory` is a positional-only argument to `d 66 66 | 67 67 | def func(): -RUF026.py:68:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:68:5 | 67 | def func(): 68 | / defaultdict( 69 | | member=1, 70 | | default_factory=tuple, 71 | | ) # RUF026 - | |_____^ RUF026 + | |_____^ | - = help: Replace with `defaultdict(default_factory=tuple)` +help: Replace with `defaultdict(default_factory=tuple)` ℹ Unsafe fix 66 66 | @@ -242,16 +255,17 @@ RUF026.py:68:5: RUF026 [*] `default_factory` is a positional-only argument to `d 72 71 | 73 72 | -RUF026.py:75:5: RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` +RUF026 [*] `default_factory` is a positional-only argument to `defaultdict` + --> RUF026.py:75:5 | 74 | def func(): 75 | / defaultdict( 76 | | default_factory=tuple, 77 | | member=1, 78 | | ) # RUF026 - | |_____^ RUF026 + | |_____^ | - = help: Replace with `defaultdict(default_factory=tuple)` +help: Replace with `defaultdict(default_factory=tuple)` ℹ Unsafe fix 73 73 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap index 590ff57921..755a39d5df 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF027_RUF027_0.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF027_0.py:5:7: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:5:7 | 3 | "always ignore this: {val}" 4 | 5 | print("but don't ignore this: {val}") # RUF027 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 2 2 | @@ -20,15 +21,16 @@ RUF027_0.py:5:7: RUF027 [*] Possible f-string without an `f` prefix 7 7 | 8 8 | def simple_cases(): -RUF027_0.py:10:9: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:10:9 | 8 | def simple_cases(): 9 | a = 4 10 | b = "{a}" # RUF027 - | ^^^^^ RUF027 + | ^^^^^ 11 | c = "{a} {b} f'{val}' " # RUF027 | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 7 7 | @@ -40,14 +42,15 @@ RUF027_0.py:10:9: RUF027 [*] Possible f-string without an `f` prefix 12 12 | 13 13 | -RUF027_0.py:11:9: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:11:9 | 9 | a = 4 10 | b = "{a}" # RUF027 11 | c = "{a} {b} f'{val}' " # RUF027 - | ^^^^^^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 8 8 | def simple_cases(): @@ -59,15 +62,16 @@ RUF027_0.py:11:9: RUF027 [*] Possible f-string without an `f` prefix 13 13 | 14 14 | def escaped_string(): -RUF027_0.py:21:9: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:21:9 | 19 | def raw_string(): 20 | a = 4 21 | b = r"raw string with formatting: {a}" # RUF027 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | c = r"raw string with \backslashes\ and \"escaped quotes\": {a}" # RUF027 | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 18 18 | @@ -79,14 +83,15 @@ RUF027_0.py:21:9: RUF027 [*] Possible f-string without an `f` prefix 23 23 | 24 24 | -RUF027_0.py:22:9: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:22:9 | 20 | a = 4 21 | b = r"raw string with formatting: {a}" # RUF027 22 | c = r"raw string with \backslashes\ and \"escaped quotes\": {a}" # RUF027 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 19 19 | def raw_string(): @@ -98,15 +103,16 @@ RUF027_0.py:22:9: RUF027 [*] Possible f-string without an `f` prefix 24 24 | 25 25 | def print_name(name: str): -RUF027_0.py:27:11: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:27:11 | 25 | def print_name(name: str): 26 | a = 4 27 | print("Hello, {name}!") # RUF027 - | ^^^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^^^ 28 | print("The test value we're using today is {a}") # RUF027 | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 24 24 | @@ -118,14 +124,15 @@ RUF027_0.py:27:11: RUF027 [*] Possible f-string without an `f` prefix 29 29 | 30 30 | -RUF027_0.py:28:11: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:28:11 | 26 | a = 4 27 | print("Hello, {name}!") # RUF027 28 | print("The test value we're using today is {a}") # RUF027 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 25 25 | def print_name(name: str): @@ -137,14 +144,15 @@ RUF027_0.py:28:11: RUF027 [*] Possible f-string without an `f` prefix 30 30 | 31 31 | def nested_funcs(): -RUF027_0.py:33:33: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:33:33 | 31 | def nested_funcs(): 32 | a = 4 33 | print(do_nothing(do_nothing("{a}"))) # RUF027 - | ^^^^^ RUF027 + | ^^^^^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 30 30 | @@ -156,16 +164,17 @@ RUF027_0.py:33:33: RUF027 [*] Possible f-string without an `f` prefix 35 35 | 36 36 | def tripled_quoted(): -RUF027_0.py:39:19: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:39:19 | 37 | a = 4 38 | c = a 39 | single_line = """ {a} """ # RUF027 - | ^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^ 40 | # RUF027 41 | multi_line = a = """b { # comment | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 36 36 | def tripled_quoted(): @@ -177,7 +186,8 @@ RUF027_0.py:39:19: RUF027 [*] Possible f-string without an `f` prefix 41 41 | multi_line = a = """b { # comment 42 42 | c} d -RUF027_0.py:41:22: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:41:22 | 39 | single_line = """ {a} """ # RUF027 40 | # RUF027 @@ -185,9 +195,9 @@ RUF027_0.py:41:22: RUF027 [*] Possible f-string without an `f` prefix | ______________________^ 42 | | c} d 43 | | """ - | |_______^ RUF027 + | |_______^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 38 38 | c = a @@ -199,7 +209,8 @@ RUF027_0.py:41:22: RUF027 [*] Possible f-string without an `f` prefix 43 43 | """ 44 44 | -RUF027_0.py:49:9: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:49:9 | 47 | a = 4 48 | # RUF027 @@ -207,9 +218,9 @@ RUF027_0.py:49:9: RUF027 [*] Possible f-string without an `f` prefix | _________^ 50 | | a} \ 51 | | " - | |_____^ RUF027 + | |_____^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 46 46 | def single_quoted_multi_line(): @@ -221,15 +232,16 @@ RUF027_0.py:49:9: RUF027 [*] Possible f-string without an `f` prefix 51 51 | " 52 52 | -RUF027_0.py:56:9: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:56:9 | 54 | def implicit_concat(): 55 | a = 4 56 | b = "{a}" "+" "{b}" r" \\ " # RUF027 for the first part only - | ^^^^^ RUF027 + | ^^^^^ 57 | print(f"{a}" "{a}" f"{b}") # RUF027 | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 53 53 | @@ -241,14 +253,15 @@ RUF027_0.py:56:9: RUF027 [*] Possible f-string without an `f` prefix 58 58 | 59 59 | -RUF027_0.py:57:18: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:57:18 | 55 | a = 4 56 | b = "{a}" "+" "{b}" r" \\ " # RUF027 for the first part only 57 | print(f"{a}" "{a}" f"{b}") # RUF027 - | ^^^^^ RUF027 + | ^^^^^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 54 54 | def implicit_concat(): @@ -260,14 +273,15 @@ RUF027_0.py:57:18: RUF027 [*] Possible f-string without an `f` prefix 59 59 | 60 60 | def escaped_chars(): -RUF027_0.py:62:9: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:62:9 | 60 | def escaped_chars(): 61 | a = 4 62 | b = "\"not escaped:\" '{a}' \"escaped:\": '{{c}}'" # RUF027 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 59 59 | @@ -279,16 +293,17 @@ RUF027_0.py:62:9: RUF027 [*] Possible f-string without an `f` prefix 64 64 | 65 65 | def method_calls(): -RUF027_0.py:70:18: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:70:18 | 68 | first = "Wendy" 69 | last = "Appleseed" 70 | value.method("{first} {last}") # RUF027 - | ^^^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^^^ 71 | 72 | def format_specifiers(): | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 67 67 | value.method = print_name @@ -300,16 +315,17 @@ RUF027_0.py:70:18: RUF027 [*] Possible f-string without an `f` prefix 72 72 | def format_specifiers(): 73 73 | a = 4 -RUF027_0.py:74:9: RUF027 [*] Possible f-string without an `f` prefix +RUF027 [*] Possible f-string without an `f` prefix + --> RUF027_0.py:74:9 | 72 | def format_specifiers(): 73 | a = 4 74 | b = "{a:b} {a:^5}" - | ^^^^^^^^^^^^^^ RUF027 + | ^^^^^^^^^^^^^^ 75 | 76 | # fstrings are never correct as type definitions | - = help: Add `f` prefix +help: Add `f` prefix ℹ Unsafe fix 71 71 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF028_RUF028.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF028_RUF028.py.snap index c3504d7828..4c37b85d0a 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF028_RUF028.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF028_RUF028.py.snap @@ -1,17 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF028.py:3:9: RUF028 [*] This suppression comment is invalid because it cannot be in an expression, pattern, argument list, or other non-statement +RUF028 [*] This suppression comment is invalid because it cannot be in an expression, pattern, argument list, or other non-statement + --> RUF028.py:3:9 | 1 | def fmt_off_between_lists(): 2 | test_list = [ 3 | # fmt: off - | ^^^^^^^^^^ RUF028 + | ^^^^^^^^^^ 4 | 1, 5 | 2, | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 1 1 | def fmt_off_between_lists(): @@ -21,15 +21,16 @@ RUF028.py:3:9: RUF028 [*] This suppression comment is invalid because it cannot 5 4 | 2, 6 5 | 3, -RUF028.py:12:5: RUF028 [*] This suppression comment is invalid because it cannot be on its own line +RUF028 [*] This suppression comment is invalid because it cannot be on its own line + --> RUF028.py:12:5 | 10 | # note: the second `fmt: skip`` should be OK 11 | def fmt_skip_on_own_line(): 12 | # fmt: skip - | ^^^^^^^^^^^ RUF028 + | ^^^^^^^^^^^ 13 | pass # fmt: skip | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 9 9 | @@ -40,15 +41,16 @@ RUF028.py:12:5: RUF028 [*] This suppression comment is invalid because it cannot 14 13 | 15 14 | -RUF028.py:17:1: RUF028 [*] This suppression comment is invalid because it cannot be after a decorator +RUF028 [*] This suppression comment is invalid because it cannot be after a decorator + --> RUF028.py:17:1 | 16 | @fmt_skip_on_own_line 17 | # fmt: off - | ^^^^^^^^^^ RUF028 + | ^^^^^^^^^^ 18 | @fmt_off_between_lists 19 | def fmt_off_between_decorators(): | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 14 14 | @@ -59,15 +61,16 @@ RUF028.py:17:1: RUF028 [*] This suppression comment is invalid because it cannot 19 18 | def fmt_off_between_decorators(): 20 19 | pass -RUF028.py:24:1: RUF028 [*] This suppression comment is invalid because it cannot be after a decorator +RUF028 [*] This suppression comment is invalid because it cannot be after a decorator + --> RUF028.py:24:1 | 23 | @fmt_off_between_decorators 24 | # fmt: off - | ^^^^^^^^^^ RUF028 + | ^^^^^^^^^^ 25 | class FmtOffBetweenClassDecorators: 26 | ... | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 21 21 | @@ -78,16 +81,17 @@ RUF028.py:24:1: RUF028 [*] This suppression comment is invalid because it cannot 26 25 | ... 27 26 | -RUF028.py:33:5: RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body +RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body + --> RUF028.py:33:5 | 31 | for val in x: 32 | print(x) 33 | # fmt: off - | ^^^^^^^^^^ RUF028 + | ^^^^^^^^^^ 34 | else: 35 | print("done") | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 30 30 | x = [1, 2, 3] @@ -98,16 +102,17 @@ RUF028.py:33:5: RUF028 [*] This suppression comment is invalid because it cannot 35 34 | print("done") 36 35 | while False: -RUF028.py:39:5: RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body +RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body + --> RUF028.py:39:5 | 37 | print("while") 38 | # fmt: off 39 | # fmt: off - | ^^^^^^^^^^ RUF028 + | ^^^^^^^^^^ 40 | else: 41 | print("done") | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 36 36 | while False: @@ -118,16 +123,17 @@ RUF028.py:39:5: RUF028 [*] This suppression comment is invalid because it cannot 41 40 | print("done") 42 41 | if len(x) > 3: -RUF028.py:45:5: RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body +RUF028 [*] This suppression comment is invalid because it cannot be directly above an alternate body + --> RUF028.py:45:5 | 43 | print("huh?") 44 | # fmt: on 45 | # fmt: off - | ^^^^^^^^^^ RUF028 + | ^^^^^^^^^^ 46 | else: 47 | print("expected") | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 42 42 | if len(x) > 3: @@ -138,16 +144,17 @@ RUF028.py:45:5: RUF028 [*] This suppression comment is invalid because it cannot 47 46 | print("expected") 48 47 | -RUF028.py:52:5: RUF028 [*] This suppression comment is invalid because it cannot be after a decorator +RUF028 [*] This suppression comment is invalid because it cannot be after a decorator + --> RUF028.py:52:5 | 50 | class Test: 51 | @classmethod 52 | # fmt: off - | ^^^^^^^^^^ RUF028 + | ^^^^^^^^^^ 53 | def cls_method_a( 54 | # fmt: off | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 49 49 | @@ -158,16 +165,17 @@ RUF028.py:52:5: RUF028 [*] This suppression comment is invalid because it cannot 54 53 | # fmt: off 55 54 | cls, -RUF028.py:54:9: RUF028 [*] This suppression comment is invalid because it cannot be in an expression, pattern, argument list, or other non-statement +RUF028 [*] This suppression comment is invalid because it cannot be in an expression, pattern, argument list, or other non-statement + --> RUF028.py:54:9 | 52 | # fmt: off 53 | def cls_method_a( 54 | # fmt: off - | ^^^^^^^^^^ RUF028 + | ^^^^^^^^^^ 55 | cls, 56 | ) -> None: # noqa: test # fmt: skip | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 51 51 | @classmethod @@ -178,15 +186,16 @@ RUF028.py:54:9: RUF028 [*] This suppression comment is invalid because it cannot 56 55 | ) -> None: # noqa: test # fmt: skip 57 56 | pass -RUF028.py:62:13: RUF028 [*] This suppression comment is invalid because it cannot be at the end of a line +RUF028 [*] This suppression comment is invalid because it cannot be at the end of a line + --> RUF028.py:62:13 | 60 | def fmt_on_trailing(): 61 | # fmt: off 62 | val = 5 # fmt: on - | ^^^^^^^^^ RUF028 + | ^^^^^^^^^ 63 | pass # fmt: on | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 59 59 | @@ -198,14 +207,15 @@ RUF028.py:62:13: RUF028 [*] This suppression comment is invalid because it canno 64 64 | 65 65 | -RUF028.py:63:10: RUF028 [*] This suppression comment is invalid because it cannot be at the end of a line +RUF028 [*] This suppression comment is invalid because it cannot be at the end of a line + --> RUF028.py:63:10 | 61 | # fmt: off 62 | val = 5 # fmt: on 63 | pass # fmt: on - | ^^^^^^^^^ RUF028 + | ^^^^^^^^^ | - = help: Remove this comment +help: Remove this comment ℹ Unsafe fix 60 60 | def fmt_on_trailing(): diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF029_RUF029.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF029_RUF029.py.snap index dbd3b6c632..f1f4117ecb 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF029_RUF029.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF029_RUF029.py.snap @@ -1,49 +1,54 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF029.py:38:11: RUF029 Function `fail_1a` is declared `async`, but doesn't `await` or use `async` features. +RUF029 Function `fail_1a` is declared `async`, but doesn't `await` or use `async` features. + --> RUF029.py:38:11 | 38 | async def fail_1a(): # RUF029 - | ^^^^^^^ RUF029 + | ^^^^^^^ 39 | time.sleep(1) | -RUF029.py:42:11: RUF029 Function `fail_1b` is declared `async`, but doesn't `await` or use `async` features. +RUF029 Function `fail_1b` is declared `async`, but doesn't `await` or use `async` features. + --> RUF029.py:42:11 | 42 | async def fail_1b(): # RUF029: yield does not require async - | ^^^^^^^ RUF029 + | ^^^^^^^ 43 | yield "hello" | -RUF029.py:46:11: RUF029 Function `fail_2` is declared `async`, but doesn't `await` or use `async` features. +RUF029 Function `fail_2` is declared `async`, but doesn't `await` or use `async` features. + --> RUF029.py:46:11 | 46 | async def fail_2(): # RUF029 - | ^^^^^^ RUF029 + | ^^^^^^ 47 | with None as i: 48 | pass | -RUF029.py:51:11: RUF029 Function `fail_3` is declared `async`, but doesn't `await` or use `async` features. +RUF029 Function `fail_3` is declared `async`, but doesn't `await` or use `async` features. + --> RUF029.py:51:11 | 51 | async def fail_3(): # RUF029 - | ^^^^^^ RUF029 + | ^^^^^^ 52 | for i in []: 53 | pass | -RUF029.py:58:11: RUF029 Function `fail_4a` is declared `async`, but doesn't `await` or use `async` features. +RUF029 Function `fail_4a` is declared `async`, but doesn't `await` or use `async` features. + --> RUF029.py:58:11 | 58 | async def fail_4a(): # RUF029: the /outer/ function does not await - | ^^^^^^^ RUF029 + | ^^^^^^^ 59 | async def foo(): 60 | await bla | -RUF029.py:63:11: RUF029 Function `fail_4b` is declared `async`, but doesn't `await` or use `async` features. +RUF029 Function `fail_4b` is declared `async`, but doesn't `await` or use `async` features. + --> RUF029.py:63:11 | 63 | async def fail_4b(): # RUF029: the /outer/ function does not await - | ^^^^^^^ RUF029 + | ^^^^^^^ 64 | class Foo: 65 | async def foo(self): | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap index 8b6a2c3935..72d4b03736 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF030_RUF030.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF030.py:6:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:6:14 | 4 | # Expects: 5 | # - single StringLiteral 6 | assert True, print("This print is not intentional.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | # Concatenated string literals | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 3 3 | # Standard Case @@ -22,16 +23,17 @@ RUF030.py:6:14: RUF030 [*] `print()` call in `assert` statement is likely uninte 8 8 | # Concatenated string literals 9 9 | # Expects: -RUF030.py:11:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:11:14 | 9 | # Expects: 10 | # - single StringLiteral 11 | assert True, print("This print" " is not intentional.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | # Positional arguments, string literals | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 8 8 | # Concatenated string literals @@ -43,16 +45,17 @@ RUF030.py:11:14: RUF030 [*] `print()` call in `assert` statement is likely unint 13 13 | # Positional arguments, string literals 14 14 | # Expects: -RUF030.py:16:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:16:14 | 14 | # Expects: 15 | # - single StringLiteral concatenated with " " 16 | assert True, print("This print", "is not intentional") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | 18 | # Concatenated string literals combined with Positional arguments | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 13 13 | # Positional arguments, string literals @@ -64,16 +67,17 @@ RUF030.py:16:14: RUF030 [*] `print()` call in `assert` statement is likely unint 18 18 | # Concatenated string literals combined with Positional arguments 19 19 | # Expects: -RUF030.py:21:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:21:14 | 19 | # Expects: 20 | # - single stringliteral concatenated with " " only between `print` and `is` 21 | assert True, print("This " "print", "is not intentional.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 22 | 23 | # Positional arguments, string literals with a variable | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 18 18 | # Concatenated string literals combined with Positional arguments @@ -85,16 +89,17 @@ RUF030.py:21:14: RUF030 [*] `print()` call in `assert` statement is likely unint 23 23 | # Positional arguments, string literals with a variable 24 24 | # Expects: -RUF030.py:26:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:26:14 | 24 | # Expects: 25 | # - single FString concatenated with " " 26 | assert True, print("This", print.__name__, "is not intentional.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 27 | 28 | # Mixed brackets string literals | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 23 23 | # Positional arguments, string literals with a variable @@ -106,16 +111,17 @@ RUF030.py:26:14: RUF030 [*] `print()` call in `assert` statement is likely unint 28 28 | # Mixed brackets string literals 29 29 | # Expects: -RUF030.py:31:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:31:14 | 29 | # Expects: 30 | # - single StringLiteral concatenated with " " 31 | assert True, print("This print", 'is not intentional', """and should be removed""") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | # Mixed brackets with other brackets inside | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 28 28 | # Mixed brackets string literals @@ -127,16 +133,17 @@ RUF030.py:31:14: RUF030 [*] `print()` call in `assert` statement is likely unint 33 33 | # Mixed brackets with other brackets inside 34 34 | # Expects: -RUF030.py:36:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:36:14 | 34 | # Expects: 35 | # - single StringLiteral concatenated with " " and escaped brackets 36 | assert True, print("This print", 'is not "intentional"', """and "should" be 'removed'""") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 37 | 38 | # Positional arguments, string literals with a separator | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 33 33 | # Mixed brackets with other brackets inside @@ -148,16 +155,17 @@ RUF030.py:36:14: RUF030 [*] `print()` call in `assert` statement is likely unint 38 38 | # Positional arguments, string literals with a separator 39 39 | # Expects: -RUF030.py:41:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:41:14 | 39 | # Expects: 40 | # - single StringLiteral concatenated with "|" 41 | assert True, print("This print", "is not intentional", sep="|") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 42 | 43 | # Positional arguments, string literals with None as separator | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 38 38 | # Positional arguments, string literals with a separator @@ -169,16 +177,17 @@ RUF030.py:41:14: RUF030 [*] `print()` call in `assert` statement is likely unint 43 43 | # Positional arguments, string literals with None as separator 44 44 | # Expects: -RUF030.py:46:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:46:14 | 44 | # Expects: 45 | # - single StringLiteral concatenated with " " 46 | assert True, print("This print", "is not intentional", sep=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | 48 | # Positional arguments, string literals with variable as separator, needs f-string | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 43 43 | # Positional arguments, string literals with None as separator @@ -190,16 +199,17 @@ RUF030.py:46:14: RUF030 [*] `print()` call in `assert` statement is likely unint 48 48 | # Positional arguments, string literals with variable as separator, needs f-string 49 49 | # Expects: -RUF030.py:51:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:51:14 | 49 | # Expects: 50 | # - single FString concatenated with "{U00A0}" 51 | assert True, print("This print", "is not intentional", sep=U00A0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 52 | 53 | # Unnecessary f-string | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 48 48 | # Positional arguments, string literals with variable as separator, needs f-string @@ -211,16 +221,17 @@ RUF030.py:51:14: RUF030 [*] `print()` call in `assert` statement is likely unint 53 53 | # Unnecessary f-string 54 54 | # Expects: -RUF030.py:56:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:56:14 | 54 | # Expects: 55 | # - single StringLiteral 56 | assert True, print(f"This f-string is just a literal.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 57 | 58 | # Positional arguments, string literals and f-strings | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 53 53 | # Unnecessary f-string @@ -232,16 +243,17 @@ RUF030.py:56:14: RUF030 [*] `print()` call in `assert` statement is likely unint 58 58 | # Positional arguments, string literals and f-strings 59 59 | # Expects: -RUF030.py:61:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:61:14 | 59 | # Expects: 60 | # - single FString concatenated with " " 61 | assert True, print("This print", f"is not {'intentional':s}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 62 | 63 | # Positional arguments, string literals and f-strings with a separator | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 58 58 | # Positional arguments, string literals and f-strings @@ -253,16 +265,17 @@ RUF030.py:61:14: RUF030 [*] `print()` call in `assert` statement is likely unint 63 63 | # Positional arguments, string literals and f-strings with a separator 64 64 | # Expects: -RUF030.py:66:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:66:14 | 64 | # Expects: 65 | # - single FString concatenated with "|" 66 | assert True, print("This print", f"is not {'intentional':s}", sep="|") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 | 68 | # A single f-string | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 63 63 | # Positional arguments, string literals and f-strings with a separator @@ -274,16 +287,17 @@ RUF030.py:66:14: RUF030 [*] `print()` call in `assert` statement is likely unint 68 68 | # A single f-string 69 69 | # Expects: -RUF030.py:71:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:71:14 | 69 | # Expects: 70 | # - single FString 71 | assert True, print(f"This print is not {'intentional':s}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 72 | 73 | # A single f-string with a redundant separator | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 68 68 | # A single f-string @@ -295,16 +309,17 @@ RUF030.py:71:14: RUF030 [*] `print()` call in `assert` statement is likely unint 73 73 | # A single f-string with a redundant separator 74 74 | # Expects: -RUF030.py:76:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:76:14 | 74 | # Expects: 75 | # - single FString 76 | assert True, print(f"This print is not {'intentional':s}", sep="|") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 77 | 78 | # Complex f-string with variable as separator | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 73 73 | # A single f-string with a redundant separator @@ -316,16 +331,17 @@ RUF030.py:76:14: RUF030 [*] `print()` call in `assert` statement is likely unint 78 78 | # Complex f-string with variable as separator 79 79 | # Expects: -RUF030.py:83:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:83:14 | 81 | condition = "True is True" 82 | maintainer = "John Doe" 83 | assert True, print("Unreachable due to", condition, f", ask {maintainer} for advice", sep=U00A0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 84 | 85 | # Empty print | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 80 80 | # - single FString concatenated with "{U00A0}", all placeholders preserved @@ -337,16 +353,17 @@ RUF030.py:83:14: RUF030 [*] `print()` call in `assert` statement is likely unint 85 85 | # Empty print 86 86 | # Expects: -RUF030.py:88:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:88:14 | 86 | # Expects: 87 | # - `msg` entirely removed from assertion 88 | assert True, print() - | ^^^^^^^ RUF030 + | ^^^^^^^ 89 | 90 | # Empty print with separator | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 85 85 | # Empty print @@ -358,16 +375,17 @@ RUF030.py:88:14: RUF030 [*] `print()` call in `assert` statement is likely unint 90 90 | # Empty print with separator 91 91 | # Expects: -RUF030.py:93:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:93:14 | 91 | # Expects: 92 | # - `msg` entirely removed from assertion 93 | assert True, print(sep=" ") - | ^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^ 94 | 95 | # Custom print function that actually returns a string | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 90 90 | # Empty print with separator @@ -379,14 +397,15 @@ RUF030.py:93:14: RUF030 [*] `print()` call in `assert` statement is likely unint 95 95 | # Custom print function that actually returns a string 96 96 | # Expects: -RUF030.py:108:14: RUF030 [*] `print()` call in `assert` statement is likely unintentional +RUF030 [*] `print()` call in `assert` statement is likely unintentional + --> RUF030.py:108:14 | 106 | # Expects: 107 | # - single StringLiteral 108 | assert True, builtins.print("This print should be removed.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF030 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove `print` +help: Remove `print` ℹ Unsafe fix 105 105 | # Use of `builtins.print` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF031_RUF031.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF031_RUF031.py.snap index 3c1b4128b7..95d2710e2c 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF031_RUF031.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF031_RUF031.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:2:3 | 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} 2 | d[(1,2)] - | ^^^^^ RUF031 + | ^^^^^ 3 | d[( 4 | 1, | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} @@ -19,7 +20,8 @@ RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts 4 4 | 1, 5 5 | 2 -RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:3:3 | 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} 2 | d[(1,2)] @@ -28,11 +30,11 @@ RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts 4 | | 1, 5 | | 2 6 | | )] - | |_^ RUF031 + | |_^ 7 | d[ 8 | 1, | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} @@ -47,16 +49,17 @@ RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts 8 8 | 1, 9 9 | 2 -RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:11:3 | 9 | 2 10 | ] 11 | d[(2,4)] - | ^^^^^ RUF031 + | ^^^^^ 12 | d[(5,6,7)] 13 | d[(8,)] | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 8 8 | 1, @@ -68,16 +71,17 @@ RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts 13 13 | d[(8,)] 14 14 | d[tuple(1,2)] -RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:12:3 | 10 | ] 11 | d[(2,4)] 12 | d[(5,6,7)] - | ^^^^^^^ RUF031 + | ^^^^^^^ 13 | d[(8,)] 14 | d[tuple(1,2)] | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 9 9 | 2 @@ -89,16 +93,17 @@ RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts 14 14 | d[tuple(1,2)] 15 15 | d[tuple(8)] -RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:13:3 | 11 | d[(2,4)] 12 | d[(5,6,7)] 13 | d[(8,)] - | ^^^^ RUF031 + | ^^^^ 14 | d[tuple(1,2)] 15 | d[tuple(8)] | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 10 10 | ] @@ -110,15 +115,16 @@ RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts 15 15 | d[tuple(8)] 16 16 | d[1,2] -RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:20:3 | 18 | d[5,6,7] 19 | e = {((1,2),(3,4)):"a"} 20 | e[((1,2),(3,4))] - | ^^^^^^^^^^^^^ RUF031 + | ^^^^^^^^^^^^^ 21 | e[(1,2),(3,4)] | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 17 17 | d[3,4] @@ -131,14 +137,15 @@ RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts 23 23 | token_features[ 24 24 | (window_position, feature_name) -RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:24:5 | 23 | token_features[ 24 | (window_position, feature_name) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | ] = self._extract_raw_features_from_token | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 21 21 | e[(1,2),(3,4)] @@ -150,15 +157,16 @@ RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts 26 26 | 27 27 | d[1,] -RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:28:3 | 27 | d[1,] 28 | d[(1,)] - | ^^^^ RUF031 + | ^^^^ 29 | d[()] # empty tuples should be ignored 30 | d[:,] # slices in the subscript lead to syntax error if parens are added | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 25 25 | ] = self._extract_raw_features_from_token @@ -170,16 +178,17 @@ RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts 30 30 | d[:,] # slices in the subscript lead to syntax error if parens are added 31 31 | d[1,2,:] -RUF031.py:36:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:36:3 | 34 | # Python <=3.10 to avoid syntax error. 35 | # https://github.com/astral-sh/ruff/issues/12776 36 | d[(*foo,bar)] - | ^^^^^^^^^^ RUF031 + | ^^^^^^^^^^ 37 | 38 | x: dict[str, int] # tuples inside type annotations should never be altered | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 33 33 | # Should keep these parentheses in diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF032_RUF032.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF032_RUF032.py.snap index 98e940a88a..03c1b8af41 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF032_RUF032.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF032_RUF032.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF032.py:6:17: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:6:17 | 4 | decimal.Decimal(0) 5 | 6 | decimal.Decimal(0.0) # Should error - | ^^^ RUF032 + | ^^^ 7 | 8 | decimal.Decimal("0.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 3 3 | # Tests with fully qualified import @@ -22,16 +23,17 @@ RUF032.py:6:17: RUF032 [*] `Decimal()` called with float literal argument 8 8 | decimal.Decimal("0.0") 9 9 | -RUF032.py:12:17: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:12:17 | 10 | decimal.Decimal(10) 11 | 12 | decimal.Decimal(10.0) # Should error - | ^^^^ RUF032 + | ^^^^ 13 | 14 | decimal.Decimal("10.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 9 9 | @@ -43,16 +45,17 @@ RUF032.py:12:17: RUF032 [*] `Decimal()` called with float literal argument 14 14 | decimal.Decimal("10.0") 15 15 | -RUF032.py:18:17: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:18:17 | 16 | decimal.Decimal(-10) 17 | 18 | decimal.Decimal(-10.0) # Should error - | ^^^^^ RUF032 + | ^^^^^ 19 | 20 | decimal.Decimal("-10.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 15 15 | @@ -64,16 +67,17 @@ RUF032.py:18:17: RUF032 [*] `Decimal()` called with float literal argument 20 20 | decimal.Decimal("-10.0") 21 21 | -RUF032.py:33:15: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:33:15 | 31 | val = Decimal(0) 32 | 33 | val = Decimal(0.0) # Should error - | ^^^ RUF032 + | ^^^ 34 | 35 | val = Decimal("0.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 30 30 | @@ -85,16 +89,17 @@ RUF032.py:33:15: RUF032 [*] `Decimal()` called with float literal argument 35 35 | val = Decimal("0.0") 36 36 | -RUF032.py:39:15: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:39:15 | 37 | val = Decimal(10) 38 | 39 | val = Decimal(10.0) # Should error - | ^^^^ RUF032 + | ^^^^ 40 | 41 | val = Decimal("10.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 36 36 | @@ -106,16 +111,17 @@ RUF032.py:39:15: RUF032 [*] `Decimal()` called with float literal argument 41 41 | val = Decimal("10.0") 42 42 | -RUF032.py:45:15: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:45:15 | 43 | val = Decimal(-10) 44 | 45 | val = Decimal(-10.0) # Should error - | ^^^^^ RUF032 + | ^^^^^ 46 | 47 | val = Decimal("-10.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 42 42 | @@ -127,16 +133,17 @@ RUF032.py:45:15: RUF032 [*] `Decimal()` called with float literal argument 47 47 | val = Decimal("-10.0") 48 48 | -RUF032.py:56:15: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:56:15 | 54 | val = Decimal(~4.0) # Skip 55 | 56 | val = Decimal(++4.0) # Suggest `Decimal("4.0")` - | ^^^^^ RUF032 + | ^^^^^ 57 | 58 | val = Decimal(-+--++--4.0) # Suggest `Decimal("-4.0")` | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 53 53 | # See https://github.com/astral-sh/ruff/issues/13258 @@ -148,14 +155,15 @@ RUF032.py:56:15: RUF032 [*] `Decimal()` called with float literal argument 58 58 | val = Decimal(-+--++--4.0) # Suggest `Decimal("-4.0")` 59 59 | -RUF032.py:58:15: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:58:15 | 56 | val = Decimal(++4.0) # Suggest `Decimal("4.0")` 57 | 58 | val = Decimal(-+--++--4.0) # Suggest `Decimal("-4.0")` - | ^^^^^^^^^^^ RUF032 + | ^^^^^^^^^^^ | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 55 55 | @@ -167,16 +175,17 @@ RUF032.py:58:15: RUF032 [*] `Decimal()` called with float literal argument 60 60 | 61 61 | # Tests with shadowed name -RUF032.py:88:23: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:88:23 | 86 | # Retest with fully qualified import 87 | 88 | val = decimal.Decimal(0.0) # Should error - | ^^^ RUF032 + | ^^^ 89 | 90 | val = decimal.Decimal("0.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 85 85 | @@ -188,16 +197,17 @@ RUF032.py:88:23: RUF032 [*] `Decimal()` called with float literal argument 90 90 | val = decimal.Decimal("0.0") 91 91 | -RUF032.py:92:23: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:92:23 | 90 | val = decimal.Decimal("0.0") 91 | 92 | val = decimal.Decimal(10.0) # Should error - | ^^^^ RUF032 + | ^^^^ 93 | 94 | val = decimal.Decimal("10.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 89 89 | @@ -209,16 +219,17 @@ RUF032.py:92:23: RUF032 [*] `Decimal()` called with float literal argument 94 94 | val = decimal.Decimal("10.0") 95 95 | -RUF032.py:96:23: RUF032 [*] `Decimal()` called with float literal argument +RUF032 [*] `Decimal()` called with float literal argument + --> RUF032.py:96:23 | 94 | val = decimal.Decimal("10.0") 95 | 96 | val = decimal.Decimal(-10.0) # Should error - | ^^^^^ RUF032 + | ^^^^^ 97 | 98 | val = decimal.Decimal("-10.0") | - = help: Replace with string literal +help: Replace with string literal ℹ Unsafe fix 93 93 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF033_RUF033.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF033_RUF033.py.snap index ee5aa75ddb..f73734afe8 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF033_RUF033.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF033_RUF033.py.snap @@ -1,32 +1,35 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF033.py:19:35: RUF033 `__post_init__` method with argument defaults +RUF033 `__post_init__` method with argument defaults + --> RUF033.py:19:35 | 17 | baz: InitVar[int] = 1 18 | 19 | def __post_init__(self, bar = 11, baz = 11) -> None: ... - | ^^ RUF033 + | ^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead -RUF033.py:19:45: RUF033 `__post_init__` method with argument defaults +RUF033 `__post_init__` method with argument defaults + --> RUF033.py:19:45 | 17 | baz: InitVar[int] = 1 18 | 19 | def __post_init__(self, bar = 11, baz = 11) -> None: ... - | ^^ RUF033 + | ^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead -RUF033.py:25:35: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:25:35 | 23 | @dataclass 24 | class Foo: 25 | def __post_init__(self, bar = 11, baz = 11) -> None: ... - | ^^ RUF033 + | ^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 22 22 | # RUF033 @@ -39,14 +42,15 @@ RUF033.py:25:35: RUF033 [*] `__post_init__` method with argument defaults 27 28 | 28 29 | # OK -RUF033.py:25:45: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:25:45 | 23 | @dataclass 24 | class Foo: 25 | def __post_init__(self, bar = 11, baz = 11) -> None: ... - | ^^ RUF033 + | ^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 22 22 | # RUF033 @@ -59,14 +63,15 @@ RUF033.py:25:45: RUF033 [*] `__post_init__` method with argument defaults 27 28 | 28 29 | # OK -RUF033.py:46:40: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:46:40 | 44 | @dataclass 45 | class Foo: 46 | def __post_init__(self, bar: int = 11, baz: Something[Whatever | None] = 11) -> None: ... - | ^^ RUF033 + | ^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 43 43 | # RUF033 @@ -79,14 +84,15 @@ RUF033.py:46:40: RUF033 [*] `__post_init__` method with argument defaults 48 49 | 49 50 | # RUF033 -RUF033.py:46:78: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:46:78 | 44 | @dataclass 45 | class Foo: 46 | def __post_init__(self, bar: int = 11, baz: Something[Whatever | None] = 11) -> None: ... - | ^^ RUF033 + | ^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 43 43 | # RUF033 @@ -99,14 +105,15 @@ RUF033.py:46:78: RUF033 [*] `__post_init__` method with argument defaults 48 49 | 49 50 | # RUF033 -RUF033.py:59:40: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:59:40 | 57 | ping = "pong" 58 | 59 | def __post_init__(self, bar: int = 11, baz: int = 12) -> None: ... - | ^^ RUF033 + | ^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 56 56 | @@ -119,14 +126,15 @@ RUF033.py:59:40: RUF033 [*] `__post_init__` method with argument defaults 61 62 | 62 63 | # RUF033 -RUF033.py:59:55: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:59:55 | 57 | ping = "pong" 58 | 59 | def __post_init__(self, bar: int = 11, baz: int = 12) -> None: ... - | ^^ RUF033 + | ^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 56 56 | @@ -139,33 +147,36 @@ RUF033.py:59:55: RUF033 [*] `__post_init__` method with argument defaults 61 62 | 62 63 | # RUF033 -RUF033.py:67:40: RUF033 `__post_init__` method with argument defaults +RUF033 `__post_init__` method with argument defaults + --> RUF033.py:67:40 | 65 | bar = "should've used attrs" 66 | 67 | def __post_init__(self, bar: str = "ahhh", baz: str = "hmm") -> None: ... - | ^^^^^^ RUF033 + | ^^^^^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead -RUF033.py:67:59: RUF033 `__post_init__` method with argument defaults +RUF033 `__post_init__` method with argument defaults + --> RUF033.py:67:59 | 65 | bar = "should've used attrs" 66 | 67 | def __post_init__(self, bar: str = "ahhh", baz: str = "hmm") -> None: ... - | ^^^^^ RUF033 + | ^^^^^ | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead -RUF033.py:73:41: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:73:41 | 71 | @dataclass 72 | class Foo: 73 | def __post_init__(self, bar: int = (x := 1)) -> None: - | ^^^^^^ RUF033 + | ^^^^^^ 74 | pass | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 70 70 | # https://github.com/astral-sh/ruff/issues/18950 @@ -178,16 +189,17 @@ RUF033.py:73:41: RUF033 [*] `__post_init__` method with argument defaults 75 76 | 76 77 | -RUF033.py:81:21: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:81:21 | 79 | def __post_init__( 80 | self, 81 | bar: int = (x := 1) # comment - | ^^^^^^ RUF033 + | ^^^^^^ 82 | , 83 | baz: int = (y := 2), # comment | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 76 76 | @@ -202,16 +214,17 @@ RUF033.py:81:21: RUF033 [*] `__post_init__` method with argument defaults 83 84 | baz: int = (y := 2), # comment 84 85 | foo = (a := 1) # comment -RUF033.py:83:21: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:83:21 | 81 | bar: int = (x := 1) # comment 82 | , 83 | baz: int = (y := 2), # comment - | ^^^^^^ RUF033 + | ^^^^^^ 84 | foo = (a := 1) # comment 85 | , | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 76 76 | @@ -228,16 +241,17 @@ RUF033.py:83:21: RUF033 [*] `__post_init__` method with argument defaults 85 86 | , 86 87 | faz = (b := 2), # comment -RUF033.py:84:16: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:84:16 | 82 | , 83 | baz: int = (y := 2), # comment 84 | foo = (a := 1) # comment - | ^^^^^^ RUF033 + | ^^^^^^ 85 | , 86 | faz = (b := 2), # comment | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 76 76 | @@ -255,16 +269,17 @@ RUF033.py:84:16: RUF033 [*] `__post_init__` method with argument defaults 86 87 | faz = (b := 2), # comment 87 88 | ) -> None: -RUF033.py:86:16: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:86:16 | 84 | foo = (a := 1) # comment 85 | , 86 | faz = (b := 2), # comment - | ^^^^^^ RUF033 + | ^^^^^^ 87 | ) -> None: 88 | pass | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 76 76 | @@ -284,16 +299,17 @@ RUF033.py:86:16: RUF033 [*] `__post_init__` method with argument defaults 88 89 | pass 89 90 | -RUF033.py:95:20: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:95:20 | 93 | def __post_init__( 94 | self, 95 | bar: int = 1, # comment - | ^ RUF033 + | ^ 96 | baz: int = 2, # comment 97 | ) -> None: | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 90 90 | @@ -308,16 +324,17 @@ RUF033.py:95:20: RUF033 [*] `__post_init__` method with argument defaults 97 98 | ) -> None: 98 99 | pass -RUF033.py:96:20: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:96:20 | 94 | self, 95 | bar: int = 1, # comment 96 | baz: int = 2, # comment - | ^ RUF033 + | ^ 97 | ) -> None: 98 | pass | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 90 90 | @@ -333,16 +350,17 @@ RUF033.py:96:20: RUF033 [*] `__post_init__` method with argument defaults 98 99 | pass 99 100 | -RUF033.py:105:22: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:105:22 | 103 | def __post_init__( 104 | self, 105 | arg1: int = (1) # comment - | ^ RUF033 + | ^ 106 | , 107 | arg2: int = ((1)) # comment | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 100 100 | @@ -357,16 +375,17 @@ RUF033.py:105:22: RUF033 [*] `__post_init__` method with argument defaults 107 108 | arg2: int = ((1)) # comment 108 109 | , -RUF033.py:107:23: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:107:23 | 105 | arg1: int = (1) # comment 106 | , 107 | arg2: int = ((1)) # comment - | ^ RUF033 + | ^ 108 | , 109 | arg2: int = (i for i in range(10)) # comment | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 100 100 | @@ -383,16 +402,17 @@ RUF033.py:107:23: RUF033 [*] `__post_init__` method with argument defaults 109 110 | arg2: int = (i for i in range(10)) # comment 110 111 | , -RUF033.py:109:21: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:109:21 | 107 | arg2: int = ((1)) # comment 108 | , 109 | arg2: int = (i for i in range(10)) # comment - | ^^^^^^^^^^^^^^^^^^^^^^ RUF033 + | ^^^^^^^^^^^^^^^^^^^^^^ 110 | , 111 | ) -> None: | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 100 100 | @@ -411,16 +431,17 @@ RUF033.py:109:21: RUF033 [*] `__post_init__` method with argument defaults 111 112 | ) -> None: 112 113 | pass -RUF033.py:121:27: RUF033 [*] `__post_init__` method with argument defaults +RUF033 [*] `__post_init__` method with argument defaults + --> RUF033.py:121:27 | 119 | def __post_init__( 120 | self, 121 | bar: (int) = (yield from range(5)) # comment - | ^^^^^^^^^^^^^^^^^^^ RUF033 + | ^^^^^^^^^^^^^^^^^^^ 122 | , 123 | ) -> None: | - = help: Use `dataclasses.InitVar` instead +help: Use `dataclasses.InitVar` instead ℹ Unsafe fix 116 116 | def fun_with_python_syntax(): diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF034_RUF034.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF034_RUF034.py.snap index 769e8dbce1..1ab0762fc7 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF034_RUF034.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF034_RUF034.py.snap @@ -1,27 +1,30 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF034.py:5:5: RUF034 Useless `if`-`else` condition +RUF034 Useless `if`-`else` condition + --> RUF034.py:5:5 | 4 | # Invalid 5 | x = 1 if True else 1 - | ^^^^^^^^^^^^^^^^ RUF034 + | ^^^^^^^^^^^^^^^^ 6 | 7 | # Invalid | -RUF034.py:8:5: RUF034 Useless `if`-`else` condition +RUF034 Useless `if`-`else` condition + --> RUF034.py:8:5 | 7 | # Invalid 8 | x = "a" if True else "a" - | ^^^^^^^^^^^^^^^^^^^^ RUF034 + | ^^^^^^^^^^^^^^^^^^^^ 9 | 10 | # Invalid | -RUF034.py:11:5: RUF034 Useless `if`-`else` condition +RUF034 Useless `if`-`else` condition + --> RUF034.py:11:5 | 10 | # Invalid 11 | x = 0.1 if False else 0.1 - | ^^^^^^^^^^^^^^^^^^^^^ RUF034 + | ^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.py.snap index 62619ff4b2..5c5c432059 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.py.snap @@ -1,59 +1,66 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF036.py:4:16: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.py:4:16 | 4 | def func1(arg: None | int): - | ^^^^ RUF036 + | ^^^^ 5 | ... | -RUF036.py:8:16: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.py:8:16 | 8 | def func2() -> None | int: - | ^^^^ RUF036 + | ^^^^ 9 | ... | -RUF036.py:12:16: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.py:12:16 | 12 | def func3(arg: None | None | int): - | ^^^^ RUF036 + | ^^^^ 13 | ... | -RUF036.py:12:23: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.py:12:23 | 12 | def func3(arg: None | None | int): - | ^^^^ RUF036 + | ^^^^ 13 | ... | -RUF036.py:16:18: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.py:16:18 | 16 | def func4(arg: U[None, int]): - | ^^^^ RUF036 + | ^^^^ 17 | ... | -RUF036.py:20:18: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.py:20:18 | 20 | def func5() -> U[None, int]: - | ^^^^ RUF036 + | ^^^^ 21 | ... | -RUF036.py:24:18: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.py:24:18 | 24 | def func6(arg: U[None, None, int]): - | ^^^^ RUF036 + | ^^^^ 25 | ... | -RUF036.py:24:24: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.py:24:24 | 24 | def func6(arg: U[None, None, int]): - | ^^^^ RUF036 + | ^^^^ 25 | ... | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.pyi.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.pyi.snap index 64bb14120a..649e716628 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.pyi.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF036_RUF036.pyi.snap @@ -1,80 +1,88 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF036.pyi:4:16: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.pyi:4:16 | 4 | def func1(arg: None | int): ... - | ^^^^ RUF036 + | ^^^^ 5 | 6 | def func2() -> None | int: ... | -RUF036.pyi:6:16: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.pyi:6:16 | 4 | def func1(arg: None | int): ... 5 | 6 | def func2() -> None | int: ... - | ^^^^ RUF036 + | ^^^^ 7 | 8 | def func3(arg: None | None | int): ... | -RUF036.pyi:8:16: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.pyi:8:16 | 6 | def func2() -> None | int: ... 7 | 8 | def func3(arg: None | None | int): ... - | ^^^^ RUF036 + | ^^^^ 9 | 10 | def func4(arg: U[None, int]): ... | -RUF036.pyi:8:23: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.pyi:8:23 | 6 | def func2() -> None | int: ... 7 | 8 | def func3(arg: None | None | int): ... - | ^^^^ RUF036 + | ^^^^ 9 | 10 | def func4(arg: U[None, int]): ... | -RUF036.pyi:10:18: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.pyi:10:18 | 8 | def func3(arg: None | None | int): ... 9 | 10 | def func4(arg: U[None, int]): ... - | ^^^^ RUF036 + | ^^^^ 11 | 12 | def func5() -> U[None, int]: ... | -RUF036.pyi:12:18: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.pyi:12:18 | 10 | def func4(arg: U[None, int]): ... 11 | 12 | def func5() -> U[None, int]: ... - | ^^^^ RUF036 + | ^^^^ 13 | 14 | def func6(arg: U[None, None, int]): ... | -RUF036.pyi:14:18: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.pyi:14:18 | 12 | def func5() -> U[None, int]: ... 13 | 14 | def func6(arg: U[None, None, int]): ... - | ^^^^ RUF036 + | ^^^^ 15 | 16 | # Ok | -RUF036.pyi:14:24: RUF036 `None` not at the end of the type annotation. +RUF036 `None` not at the end of the type annotation. + --> RUF036.pyi:14:24 | 12 | def func5() -> U[None, int]: ... 13 | 14 | def func6(arg: U[None, None, int]): ... - | ^^^^ RUF036 + | ^^^^ 15 | 16 | # Ok | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF037_RUF037.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF037_RUF037.py.snap index caf3f33b3d..f396239316 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF037_RUF037.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF037_RUF037.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF037.py:6:13: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:6:13 | 5 | def f(): 6 | queue = collections.deque([]) # RUF037 - | ^^^^^^^^^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 3 3 | @@ -19,13 +20,14 @@ RUF037.py:6:13: RUF037 [*] Unnecessary empty iterable within a deque call 8 8 | 9 9 | def f(): -RUF037.py:10:13: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:10:13 | 9 | def f(): 10 | queue = collections.deque([], maxlen=10) # RUF037 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `deque(maxlen=...)` +help: Replace with `deque(maxlen=...)` ℹ Safe fix 7 7 | @@ -37,13 +39,14 @@ RUF037.py:10:13: RUF037 [*] Unnecessary empty iterable within a deque call 12 12 | 13 13 | def f(): -RUF037.py:14:13: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:14:13 | 13 | def f(): 14 | queue = deque([]) # RUF037 - | ^^^^^^^^^ RUF037 + | ^^^^^^^^^ | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 11 11 | @@ -55,13 +58,14 @@ RUF037.py:14:13: RUF037 [*] Unnecessary empty iterable within a deque call 16 16 | 17 17 | def f(): -RUF037.py:18:13: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:18:13 | 17 | def f(): 18 | queue = deque(()) # RUF037 - | ^^^^^^^^^ RUF037 + | ^^^^^^^^^ | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 15 15 | @@ -73,13 +77,14 @@ RUF037.py:18:13: RUF037 [*] Unnecessary empty iterable within a deque call 20 20 | 21 21 | def f(): -RUF037.py:22:13: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:22:13 | 21 | def f(): 22 | queue = deque({}) # RUF037 - | ^^^^^^^^^ RUF037 + | ^^^^^^^^^ | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 19 19 | @@ -91,13 +96,14 @@ RUF037.py:22:13: RUF037 [*] Unnecessary empty iterable within a deque call 24 24 | 25 25 | def f(): -RUF037.py:26:13: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:26:13 | 25 | def f(): 26 | queue = deque(set()) # RUF037 - | ^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^ | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 23 23 | @@ -109,13 +115,14 @@ RUF037.py:26:13: RUF037 [*] Unnecessary empty iterable within a deque call 28 28 | 29 29 | def f(): -RUF037.py:30:13: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:30:13 | 29 | def f(): 30 | queue = collections.deque([], maxlen=10) # RUF037 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `deque(maxlen=...)` +help: Replace with `deque(maxlen=...)` ℹ Safe fix 27 27 | @@ -127,13 +134,14 @@ RUF037.py:30:13: RUF037 [*] Unnecessary empty iterable within a deque call 32 32 | 33 33 | def f(): -RUF037.py:61:13: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:61:13 | 60 | def f(): 61 | x = 0 or(deque)([]) - | ^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^ | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 58 58 | queue = deque() # Ok @@ -145,26 +153,28 @@ RUF037.py:61:13: RUF037 [*] Unnecessary empty iterable within a deque call 63 63 | 64 64 | # regression tests for https://github.com/astral-sh/ruff/issues/18612 -RUF037.py:66:5: RUF037 Unnecessary empty iterable within a deque call +RUF037 Unnecessary empty iterable within a deque call + --> RUF037.py:66:5 | 64 | # regression tests for https://github.com/astral-sh/ruff/issues/18612 65 | def f(): 66 | deque([], *[10]) # RUF037 but no fix - | ^^^^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^^^^ 67 | deque([], **{"maxlen": 10}) # RUF037 68 | deque([], foo=1) # RUF037 | - = help: Replace with `deque()` +help: Replace with `deque()` -RUF037.py:67:5: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:67:5 | 65 | def f(): 66 | deque([], *[10]) # RUF037 but no fix 67 | deque([], **{"maxlen": 10}) # RUF037 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 68 | deque([], foo=1) # RUF037 | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Unsafe fix 64 64 | # regression tests for https://github.com/astral-sh/ruff/issues/18612 @@ -176,14 +186,15 @@ RUF037.py:67:5: RUF037 [*] Unnecessary empty iterable within a deque call 69 69 | 70 70 | -RUF037.py:68:5: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:68:5 | 66 | deque([], *[10]) # RUF037 but no fix 67 | deque([], **{"maxlen": 10}) # RUF037 68 | deque([], foo=1) # RUF037 - | ^^^^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^^^^ | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Unsafe fix 65 65 | def f(): @@ -195,7 +206,8 @@ RUF037.py:68:5: RUF037 [*] Unnecessary empty iterable within a deque call 70 70 | 71 71 | # Somewhat related to the issue, both okay because we can't generally look -RUF037.py:80:5: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:80:5 | 78 | # are deleted 79 | def f(): @@ -204,9 +216,9 @@ RUF037.py:80:5: RUF037 [*] Unnecessary empty iterable within a deque call 82 | | ], # a comment after the list, deleted 83 | | maxlen=10, # a comment on maxlen, deleted 84 | | ) # only this is preserved - | |_________^ RUF037 + | |_________^ | - = help: Replace with `deque(maxlen=...)` +help: Replace with `deque(maxlen=...)` ℹ Unsafe fix 77 77 | # The fix was actually always unsafe in the presence of comments. all of these @@ -222,14 +234,15 @@ RUF037.py:80:5: RUF037 [*] Unnecessary empty iterable within a deque call 86 82 | 87 83 | # `maxlen` can also be passed positionally -RUF037.py:89:5: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:89:5 | 87 | # `maxlen` can also be passed positionally 88 | def f(): 89 | deque([], 10) - | ^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^ | - = help: Replace with `deque(maxlen=...)` +help: Replace with `deque(maxlen=...)` ℹ Safe fix 86 86 | @@ -241,15 +254,16 @@ RUF037.py:89:5: RUF037 [*] Unnecessary empty iterable within a deque call 91 91 | 92 92 | def f(): -RUF037.py:93:5: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:93:5 | 92 | def f(): 93 | deque([], iterable=[]) - | ^^^^^^^^^^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^^^^^^^^^^ 94 | 95 | # https://github.com/astral-sh/ruff/issues/18854 | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Unsafe fix 90 90 | @@ -261,15 +275,16 @@ RUF037.py:93:5: RUF037 [*] Unnecessary empty iterable within a deque call 95 95 | # https://github.com/astral-sh/ruff/issues/18854 96 96 | deque("") -RUF037.py:96:1: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:96:1 | 95 | # https://github.com/astral-sh/ruff/issues/18854 96 | deque("") - | ^^^^^^^^^ RUF037 + | ^^^^^^^^^ 97 | deque(b"") 98 | deque(f"") | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 93 93 | deque([], iterable=[]) @@ -281,16 +296,17 @@ RUF037.py:96:1: RUF037 [*] Unnecessary empty iterable within a deque call 98 98 | deque(f"") 99 99 | deque(f"" "") -RUF037.py:97:1: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:97:1 | 95 | # https://github.com/astral-sh/ruff/issues/18854 96 | deque("") 97 | deque(b"") - | ^^^^^^^^^^ RUF037 + | ^^^^^^^^^^ 98 | deque(f"") 99 | deque(f"" "") | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 94 94 | @@ -302,16 +318,17 @@ RUF037.py:97:1: RUF037 [*] Unnecessary empty iterable within a deque call 99 99 | deque(f"" "") 100 100 | deque(f"" f"") -RUF037.py:98:1: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:98:1 | 96 | deque("") 97 | deque(b"") 98 | deque(f"") - | ^^^^^^^^^^ RUF037 + | ^^^^^^^^^^ 99 | deque(f"" "") 100 | deque(f"" f"") | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 95 95 | # https://github.com/astral-sh/ruff/issues/18854 @@ -323,16 +340,17 @@ RUF037.py:98:1: RUF037 [*] Unnecessary empty iterable within a deque call 100 100 | deque(f"" f"") 101 101 | deque("abc") # OK -RUF037.py:99:1: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:99:1 | 97 | deque(b"") 98 | deque(f"") 99 | deque(f"" "") - | ^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^ 100 | deque(f"" f"") 101 | deque("abc") # OK | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 96 96 | deque("") @@ -344,16 +362,17 @@ RUF037.py:99:1: RUF037 [*] Unnecessary empty iterable within a deque call 101 101 | deque("abc") # OK 102 102 | deque(b"abc") # OK -RUF037.py:100:1: RUF037 [*] Unnecessary empty iterable within a deque call +RUF037 [*] Unnecessary empty iterable within a deque call + --> RUF037.py:100:1 | 98 | deque(f"") 99 | deque(f"" "") 100 | deque(f"" f"") - | ^^^^^^^^^^^^^^ RUF037 + | ^^^^^^^^^^^^^^ 101 | deque("abc") # OK 102 | deque(b"abc") # OK | - = help: Replace with `deque()` +help: Replace with `deque()` ℹ Safe fix 97 97 | deque(b"") diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.py.snap index a5a0ffa385..a52ca0b528 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF038.py:4:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.py:4:17 | 4 | def func1(arg1: Literal[True, False]): - | ^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^ 5 | ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 1 1 | from typing import Literal @@ -19,13 +20,14 @@ RUF038.py:4:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 6 6 | 7 7 | -RUF038.py:8:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.py:8:17 | 8 | def func2(arg1: Literal[True, False, True]): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 5 5 | ... @@ -37,13 +39,14 @@ RUF038.py:8:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 10 10 | 11 11 | -RUF038.py:12:16: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.py:12:16 | 12 | def func3() -> Literal[True, False]: - | ^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^ 13 | ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 9 9 | ... @@ -55,13 +58,14 @@ RUF038.py:12:16: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 14 14 | 15 15 | -RUF038.py:16:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.py:16:17 | 16 | def func4(arg1: Literal[True, False] | bool): - | ^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^ 17 | ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 13 13 | ... @@ -73,13 +77,14 @@ RUF038.py:16:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 18 18 | 19 19 | -RUF038.py:20:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.py:20:17 | 20 | def func5(arg1: Literal[False, True]): - | ^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^ 21 | ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 17 17 | ... @@ -91,10 +96,11 @@ RUF038.py:20:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 22 22 | 23 23 | -RUF038.py:24:17: RUF038 `Literal[True, False, ...]` can be replaced with `Literal[...] | bool` +RUF038 `Literal[True, False, ...]` can be replaced with `Literal[...] | bool` + --> RUF038.py:24:17 | 24 | def func6(arg1: Literal[True, False, "hello", "world"]): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | ... | - = help: Replace with `Literal[...] | bool` +help: Replace with `Literal[...] | bool` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.pyi.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.pyi.snap index ec4ffb9e79..0f4170e303 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.pyi.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF038_RUF038.pyi.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF038.pyi:4:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.pyi:4:17 | 4 | def func1(arg1: Literal[True, False]): ... - | ^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^ 5 | 6 | def func2(arg1: Literal[True, False, True]): ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 1 1 | from typing import Literal @@ -20,16 +21,17 @@ RUF038.pyi:4:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 6 6 | def func2(arg1: Literal[True, False, True]): ... 7 7 | -RUF038.pyi:6:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.pyi:6:17 | 4 | def func1(arg1: Literal[True, False]): ... 5 | 6 | def func2(arg1: Literal[True, False, True]): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | def func3() -> Literal[True, False]: ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 3 3 | @@ -41,16 +43,17 @@ RUF038.pyi:6:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 8 8 | def func3() -> Literal[True, False]: ... 9 9 | -RUF038.pyi:8:16: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.pyi:8:16 | 6 | def func2(arg1: Literal[True, False, True]): ... 7 | 8 | def func3() -> Literal[True, False]: ... - | ^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^ 9 | 10 | def func4(arg1: Literal[True, False] | bool): ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 5 5 | @@ -62,16 +65,17 @@ RUF038.pyi:8:16: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 10 10 | def func4(arg1: Literal[True, False] | bool): ... 11 11 | -RUF038.pyi:10:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.pyi:10:17 | 8 | def func3() -> Literal[True, False]: ... 9 | 10 | def func4(arg1: Literal[True, False] | bool): ... - | ^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^ 11 | 12 | def func5(arg1: Literal[False, True]): ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 7 7 | @@ -83,16 +87,17 @@ RUF038.pyi:10:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 12 12 | def func5(arg1: Literal[False, True]): ... 13 13 | -RUF038.pyi:12:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` +RUF038 [*] `Literal[True, False]` can be replaced with `bool` + --> RUF038.pyi:12:17 | 10 | def func4(arg1: Literal[True, False] | bool): ... 11 | 12 | def func5(arg1: Literal[False, True]): ... - | ^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^ 13 | 14 | def func6(arg1: Literal[True, False, "hello", "world"]): ... | - = help: Replace with `bool` +help: Replace with `bool` ℹ Unsafe fix 9 9 | @@ -104,13 +109,14 @@ RUF038.pyi:12:17: RUF038 [*] `Literal[True, False]` can be replaced with `bool` 14 14 | def func6(arg1: Literal[True, False, "hello", "world"]): ... 15 15 | -RUF038.pyi:14:17: RUF038 `Literal[True, False, ...]` can be replaced with `Literal[...] | bool` +RUF038 `Literal[True, False, ...]` can be replaced with `Literal[...] | bool` + --> RUF038.pyi:14:17 | 12 | def func5(arg1: Literal[False, True]): ... 13 | 14 | def func6(arg1: Literal[True, False, "hello", "world"]): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF038 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | # ok | - = help: Replace with `Literal[...] | bool` +help: Replace with `Literal[...] | bool` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF040_RUF040.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF040_RUF040.py.snap index 4102fe32b8..9bac13d7fe 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF040_RUF040.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF040_RUF040.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF040.py:3:21: RUF040 Non-string literal used as assert message +RUF040 Non-string literal used as assert message + --> RUF040.py:3:21 | 1 | fruits = ["apples", "plums", "pear"] 2 | fruits.filter(lambda fruit: fruit.startwith("p")) 3 | assert len(fruits), 2 - | ^ RUF040 + | ^ 4 | 5 | assert True, "always true" | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.py.snap index d09f2bde4e..3f44d5eee8 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF041.py:6:4: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:6:4 | 6 | y: Literal[1, print("hello"), 3, Literal[4, 1]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | Literal[1, Literal[1]] 8 | Literal[1, 2, Literal[1, 2]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 3 3 | import typing_extensions @@ -20,15 +21,16 @@ RUF041.py:6:4: RUF041 [*] Unnecessary nested `Literal` 8 8 | Literal[1, 2, Literal[1, 2]] 9 9 | Literal[1, Literal[1], Literal[1]] -RUF041.py:7:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:7:1 | 6 | y: Literal[1, print("hello"), 3, Literal[4, 1]] 7 | Literal[1, Literal[1]] - | ^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^ 8 | Literal[1, 2, Literal[1, 2]] 9 | Literal[1, Literal[1], Literal[1]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 4 4 | @@ -40,16 +42,17 @@ RUF041.py:7:1: RUF041 [*] Unnecessary nested `Literal` 9 9 | Literal[1, Literal[1], Literal[1]] 10 10 | Literal[1, Literal[2], Literal[2]] -RUF041.py:8:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:8:1 | 6 | y: Literal[1, print("hello"), 3, Literal[4, 1]] 7 | Literal[1, Literal[1]] 8 | Literal[1, 2, Literal[1, 2]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | Literal[1, Literal[1], Literal[1]] 10 | Literal[1, Literal[2], Literal[2]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 5 5 | @@ -61,16 +64,17 @@ RUF041.py:8:1: RUF041 [*] Unnecessary nested `Literal` 10 10 | Literal[1, Literal[2], Literal[2]] 11 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] -RUF041.py:9:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:9:1 | 7 | Literal[1, Literal[1]] 8 | Literal[1, 2, Literal[1, 2]] 9 | Literal[1, Literal[1], Literal[1]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | Literal[1, Literal[2], Literal[2]] 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 6 6 | y: Literal[1, print("hello"), 3, Literal[4, 1]] @@ -82,16 +86,17 @@ RUF041.py:9:1: RUF041 [*] Unnecessary nested `Literal` 11 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] 12 12 | Literal[ -RUF041.py:10:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:10:1 | 8 | Literal[1, 2, Literal[1, 2]] 9 | Literal[1, Literal[1], Literal[1]] 10 | Literal[1, Literal[2], Literal[2]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] 12 | Literal[ | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 7 7 | Literal[1, Literal[1]] @@ -103,16 +108,17 @@ RUF041.py:10:1: RUF041 [*] Unnecessary nested `Literal` 12 12 | Literal[ 13 13 | 1, # comment 1 -RUF041.py:11:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:11:1 | 9 | Literal[1, Literal[1], Literal[1]] 10 | Literal[1, Literal[2], Literal[2]] 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | Literal[ 13 | 1, # comment 1 | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 8 8 | Literal[1, 2, Literal[1, 2]] @@ -124,7 +130,8 @@ RUF041.py:11:1: RUF041 [*] Unnecessary nested `Literal` 13 13 | 1, # comment 1 14 14 | Literal[ # another comment -RUF041.py:12:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:12:1 | 10 | Literal[1, Literal[2], Literal[2]] 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] @@ -134,11 +141,11 @@ RUF041.py:12:1: RUF041 [*] Unnecessary nested `Literal` 15 | | 1 # yet another comment 16 | | ] 17 | | ] # once - | |_^ RUF041 + | |_^ 18 | 19 | # Ensure issue is only raised once, even on nested literals | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Unsafe fix 9 9 | Literal[1, Literal[1], Literal[1]] @@ -155,15 +162,16 @@ RUF041.py:12:1: RUF041 [*] Unnecessary nested `Literal` 19 14 | # Ensure issue is only raised once, even on nested literals 20 15 | MyType = Literal["foo", Literal[True, False, True], "bar"] -RUF041.py:20:10: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:20:10 | 19 | # Ensure issue is only raised once, even on nested literals 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | 22 | # nested literals, all equivalent to `Literal[1]` | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 17 17 | ] # once @@ -175,15 +183,16 @@ RUF041.py:20:10: RUF041 [*] Unnecessary nested `Literal` 22 22 | # nested literals, all equivalent to `Literal[1]` 23 23 | Literal[Literal[1]] -RUF041.py:23:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:23:1 | 22 | # nested literals, all equivalent to `Literal[1]` 23 | Literal[Literal[1]] - | ^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^ 24 | Literal[Literal[Literal[1], Literal[1]]] 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 20 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] @@ -195,15 +204,16 @@ RUF041.py:23:1: RUF041 [*] Unnecessary nested `Literal` 25 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] 26 26 | -RUF041.py:24:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:24:1 | 22 | # nested literals, all equivalent to `Literal[1]` 23 | Literal[Literal[1]] 24 | Literal[Literal[Literal[1], Literal[1]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 21 21 | @@ -215,16 +225,17 @@ RUF041.py:24:1: RUF041 [*] Unnecessary nested `Literal` 26 26 | 27 27 | # OK -RUF041.py:25:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.py:25:1 | 23 | Literal[Literal[1]] 24 | Literal[Literal[Literal[1], Literal[1]]] 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | # OK | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 22 22 | # nested literals, all equivalent to `Literal[1]` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.pyi.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.pyi.snap index 6b146bdc64..c62475a490 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.pyi.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF041_RUF041.pyi.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF041.pyi:6:4: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:6:4 | 6 | y: Literal[1, print("hello"), 3, Literal[4, 1]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | Literal[1, Literal[1]] 8 | Literal[1, 2, Literal[1, 2]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 3 3 | import typing_extensions @@ -20,15 +21,16 @@ RUF041.pyi:6:4: RUF041 [*] Unnecessary nested `Literal` 8 8 | Literal[1, 2, Literal[1, 2]] 9 9 | Literal[1, Literal[1], Literal[1]] -RUF041.pyi:7:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:7:1 | 6 | y: Literal[1, print("hello"), 3, Literal[4, 1]] 7 | Literal[1, Literal[1]] - | ^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^ 8 | Literal[1, 2, Literal[1, 2]] 9 | Literal[1, Literal[1], Literal[1]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 4 4 | @@ -40,16 +42,17 @@ RUF041.pyi:7:1: RUF041 [*] Unnecessary nested `Literal` 9 9 | Literal[1, Literal[1], Literal[1]] 10 10 | Literal[1, Literal[2], Literal[2]] -RUF041.pyi:8:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:8:1 | 6 | y: Literal[1, print("hello"), 3, Literal[4, 1]] 7 | Literal[1, Literal[1]] 8 | Literal[1, 2, Literal[1, 2]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | Literal[1, Literal[1], Literal[1]] 10 | Literal[1, Literal[2], Literal[2]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 5 5 | @@ -61,16 +64,17 @@ RUF041.pyi:8:1: RUF041 [*] Unnecessary nested `Literal` 10 10 | Literal[1, Literal[2], Literal[2]] 11 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] -RUF041.pyi:9:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:9:1 | 7 | Literal[1, Literal[1]] 8 | Literal[1, 2, Literal[1, 2]] 9 | Literal[1, Literal[1], Literal[1]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | Literal[1, Literal[2], Literal[2]] 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 6 6 | y: Literal[1, print("hello"), 3, Literal[4, 1]] @@ -82,16 +86,17 @@ RUF041.pyi:9:1: RUF041 [*] Unnecessary nested `Literal` 11 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] 12 12 | Literal[ -RUF041.pyi:10:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:10:1 | 8 | Literal[1, 2, Literal[1, 2]] 9 | Literal[1, Literal[1], Literal[1]] 10 | Literal[1, Literal[2], Literal[2]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] 12 | Literal[ | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 7 7 | Literal[1, Literal[1]] @@ -103,16 +108,17 @@ RUF041.pyi:10:1: RUF041 [*] Unnecessary nested `Literal` 12 12 | Literal[ 13 13 | 1, # comment 1 -RUF041.pyi:11:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:11:1 | 9 | Literal[1, Literal[1], Literal[1]] 10 | Literal[1, Literal[2], Literal[2]] 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | Literal[ 13 | 1, # comment 1 | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 8 8 | Literal[1, 2, Literal[1, 2]] @@ -124,7 +130,8 @@ RUF041.pyi:11:1: RUF041 [*] Unnecessary nested `Literal` 13 13 | 1, # comment 1 14 14 | Literal[ # another comment -RUF041.pyi:12:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:12:1 | 10 | Literal[1, Literal[2], Literal[2]] 11 | t.Literal[1, t.Literal[2, t.Literal[1]]] @@ -134,11 +141,11 @@ RUF041.pyi:12:1: RUF041 [*] Unnecessary nested `Literal` 15 | | 1 # yet another comment 16 | | ] 17 | | ] # once - | |_^ RUF041 + | |_^ 18 | 19 | # Ensure issue is only raised once, even on nested literals | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Unsafe fix 9 9 | Literal[1, Literal[1], Literal[1]] @@ -155,15 +162,16 @@ RUF041.pyi:12:1: RUF041 [*] Unnecessary nested `Literal` 19 14 | # Ensure issue is only raised once, even on nested literals 20 15 | MyType = Literal["foo", Literal[True, False, True], "bar"] -RUF041.pyi:20:10: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:20:10 | 19 | # Ensure issue is only raised once, even on nested literals 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | 22 | # nested literals, all equivalent to `Literal[1]` | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 17 17 | ] # once @@ -175,15 +183,16 @@ RUF041.pyi:20:10: RUF041 [*] Unnecessary nested `Literal` 22 22 | # nested literals, all equivalent to `Literal[1]` 23 23 | Literal[Literal[1]] -RUF041.pyi:23:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:23:1 | 22 | # nested literals, all equivalent to `Literal[1]` 23 | Literal[Literal[1]] - | ^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^ 24 | Literal[Literal[Literal[1], Literal[1]]] 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 20 20 | MyType = Literal["foo", Literal[True, False, True], "bar"] @@ -195,15 +204,16 @@ RUF041.pyi:23:1: RUF041 [*] Unnecessary nested `Literal` 25 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] 26 26 | -RUF041.pyi:24:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:24:1 | 22 | # nested literals, all equivalent to `Literal[1]` 23 | Literal[Literal[1]] 24 | Literal[Literal[Literal[1], Literal[1]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 21 21 | @@ -215,16 +225,17 @@ RUF041.pyi:24:1: RUF041 [*] Unnecessary nested `Literal` 26 26 | 27 27 | # OK -RUF041.pyi:25:1: RUF041 [*] Unnecessary nested `Literal` +RUF041 [*] Unnecessary nested `Literal` + --> RUF041.pyi:25:1 | 23 | Literal[Literal[1]] 24 | Literal[Literal[Literal[1], Literal[1]]] 25 | Literal[Literal[1], Literal[Literal[Literal[1]]]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 26 | 27 | # OK | - = help: Replace with flattened `Literal` +help: Replace with flattened `Literal` ℹ Safe fix 22 22 | # nested literals, all equivalent to `Literal[1]` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046.py.snap index f4d9f4d465..31fdadacf3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF046.py:10:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:10:1 | 8 | ### Safely fixable 9 | 10 | int(id()) - | ^^^^^^^^^ RUF046 + | ^^^^^^^^^ 11 | int(len([])) 12 | int(ord(foo)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 7 7 | @@ -22,15 +23,16 @@ RUF046.py:10:1: RUF046 [*] Value being cast to `int` is already an integer 12 12 | int(ord(foo)) 13 13 | int(hash(foo, bar)) -RUF046.py:11:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:11:1 | 10 | int(id()) 11 | int(len([])) - | ^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^ 12 | int(ord(foo)) 13 | int(hash(foo, bar)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 8 8 | ### Safely fixable @@ -42,16 +44,17 @@ RUF046.py:11:1: RUF046 [*] Value being cast to `int` is already an integer 13 13 | int(hash(foo, bar)) 14 14 | int(int('')) -RUF046.py:12:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:12:1 | 10 | int(id()) 11 | int(len([])) 12 | int(ord(foo)) - | ^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^ 13 | int(hash(foo, bar)) 14 | int(int('')) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 9 9 | @@ -63,15 +66,16 @@ RUF046.py:12:1: RUF046 [*] Value being cast to `int` is already an integer 14 14 | int(int('')) 15 15 | -RUF046.py:13:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:13:1 | 11 | int(len([])) 12 | int(ord(foo)) 13 | int(hash(foo, bar)) - | ^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^ 14 | int(int('')) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 10 10 | int(id()) @@ -83,16 +87,17 @@ RUF046.py:13:1: RUF046 [*] Value being cast to `int` is already an integer 15 15 | 16 16 | int(math.comb()) -RUF046.py:14:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:14:1 | 12 | int(ord(foo)) 13 | int(hash(foo, bar)) 14 | int(int('')) - | ^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^ 15 | 16 | int(math.comb()) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 11 11 | int(len([])) @@ -104,16 +109,17 @@ RUF046.py:14:1: RUF046 [*] Value being cast to `int` is already an integer 16 16 | int(math.comb()) 17 17 | int(math.factorial()) -RUF046.py:16:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:16:1 | 14 | int(int('')) 15 | 16 | int(math.comb()) - | ^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^ 17 | int(math.factorial()) 18 | int(math.gcd()) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 13 13 | int(hash(foo, bar)) @@ -125,15 +131,16 @@ RUF046.py:16:1: RUF046 [*] Value being cast to `int` is already an integer 18 18 | int(math.gcd()) 19 19 | int(math.lcm()) -RUF046.py:17:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:17:1 | 16 | int(math.comb()) 17 | int(math.factorial()) - | ^^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^^ 18 | int(math.gcd()) 19 | int(math.lcm()) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 14 14 | int(int('')) @@ -145,16 +152,17 @@ RUF046.py:17:1: RUF046 [*] Value being cast to `int` is already an integer 19 19 | int(math.lcm()) 20 20 | int(math.isqrt()) -RUF046.py:18:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:18:1 | 16 | int(math.comb()) 17 | int(math.factorial()) 18 | int(math.gcd()) - | ^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^ 19 | int(math.lcm()) 20 | int(math.isqrt()) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 15 15 | @@ -166,16 +174,17 @@ RUF046.py:18:1: RUF046 [*] Value being cast to `int` is already an integer 20 20 | int(math.isqrt()) 21 21 | int(math.perm()) -RUF046.py:19:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:19:1 | 17 | int(math.factorial()) 18 | int(math.gcd()) 19 | int(math.lcm()) - | ^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^ 20 | int(math.isqrt()) 21 | int(math.perm()) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 16 16 | int(math.comb()) @@ -187,15 +196,16 @@ RUF046.py:19:1: RUF046 [*] Value being cast to `int` is already an integer 21 21 | int(math.perm()) 22 22 | -RUF046.py:20:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:20:1 | 18 | int(math.gcd()) 19 | int(math.lcm()) 20 | int(math.isqrt()) - | ^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^ 21 | int(math.perm()) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 17 17 | int(math.factorial()) @@ -207,16 +217,17 @@ RUF046.py:20:1: RUF046 [*] Value being cast to `int` is already an integer 22 22 | 23 23 | int(round(1, 0)) -RUF046.py:21:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:21:1 | 19 | int(math.lcm()) 20 | int(math.isqrt()) 21 | int(math.perm()) - | ^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^ 22 | 23 | int(round(1, 0)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 18 18 | int(math.gcd()) @@ -228,15 +239,16 @@ RUF046.py:21:1: RUF046 [*] Value being cast to `int` is already an integer 23 23 | int(round(1, 0)) 24 24 | int(round(1, 10)) -RUF046.py:23:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:23:1 | 21 | int(math.perm()) 22 | 23 | int(round(1, 0)) - | ^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^ 24 | int(round(1, 10)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 20 20 | int(math.isqrt()) @@ -248,15 +260,16 @@ RUF046.py:23:1: RUF046 [*] Value being cast to `int` is already an integer 25 25 | 26 26 | int(round(1)) -RUF046.py:24:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:24:1 | 23 | int(round(1, 0)) 24 | int(round(1, 10)) - | ^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^ 25 | 26 | int(round(1)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 21 21 | int(math.perm()) @@ -268,15 +281,16 @@ RUF046.py:24:1: RUF046 [*] Value being cast to `int` is already an integer 26 26 | int(round(1)) 27 27 | int(round(1, None)) -RUF046.py:26:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:26:1 | 24 | int(round(1, 10)) 25 | 26 | int(round(1)) - | ^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^ 27 | int(round(1, None)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 23 23 | int(round(1, 0)) @@ -288,15 +302,16 @@ RUF046.py:26:1: RUF046 [*] Value being cast to `int` is already an integer 28 28 | 29 29 | int(round(1.)) -RUF046.py:27:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:27:1 | 26 | int(round(1)) 27 | int(round(1, None)) - | ^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^ 28 | 29 | int(round(1.)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 24 24 | int(round(1, 10)) @@ -308,15 +323,16 @@ RUF046.py:27:1: RUF046 [*] Value being cast to `int` is already an integer 29 29 | int(round(1.)) 30 30 | int(round(1., None)) -RUF046.py:29:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:29:1 | 27 | int(round(1, None)) 28 | 29 | int(round(1.)) - | ^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^ 30 | int(round(1., None)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 26 26 | int(round(1)) @@ -328,15 +344,16 @@ RUF046.py:29:1: RUF046 [*] Value being cast to `int` is already an integer 31 31 | 32 32 | int(1) -RUF046.py:30:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:30:1 | 29 | int(round(1.)) 30 | int(round(1., None)) - | ^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^ 31 | 32 | int(1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 27 27 | int(round(1, None)) @@ -348,16 +365,17 @@ RUF046.py:30:1: RUF046 [*] Value being cast to `int` is already an integer 32 32 | int(1) 33 33 | int(v := 1) -RUF046.py:32:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:32:1 | 30 | int(round(1., None)) 31 | 32 | int(1) - | ^^^^^^ RUF046 + | ^^^^^^ 33 | int(v := 1) 34 | int(~1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 29 29 | int(round(1.)) @@ -369,15 +387,16 @@ RUF046.py:32:1: RUF046 [*] Value being cast to `int` is already an integer 34 34 | int(~1) 35 35 | int(-1) -RUF046.py:33:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:33:1 | 32 | int(1) 33 | int(v := 1) - | ^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^ 34 | int(~1) 35 | int(-1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 30 30 | int(round(1., None)) @@ -389,16 +408,17 @@ RUF046.py:33:1: RUF046 [*] Value being cast to `int` is already an integer 35 35 | int(-1) 36 36 | int(+1) -RUF046.py:34:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:34:1 | 32 | int(1) 33 | int(v := 1) 34 | int(~1) - | ^^^^^^^ RUF046 + | ^^^^^^^ 35 | int(-1) 36 | int(+1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 31 31 | @@ -410,15 +430,16 @@ RUF046.py:34:1: RUF046 [*] Value being cast to `int` is already an integer 36 36 | int(+1) 37 37 | -RUF046.py:35:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:35:1 | 33 | int(v := 1) 34 | int(~1) 35 | int(-1) - | ^^^^^^^ RUF046 + | ^^^^^^^ 36 | int(+1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 32 32 | int(1) @@ -430,16 +451,17 @@ RUF046.py:35:1: RUF046 [*] Value being cast to `int` is already an integer 37 37 | 38 38 | int(1 + 1) -RUF046.py:36:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:36:1 | 34 | int(~1) 35 | int(-1) 36 | int(+1) - | ^^^^^^^ RUF046 + | ^^^^^^^ 37 | 38 | int(1 + 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 33 33 | int(v := 1) @@ -451,16 +473,17 @@ RUF046.py:36:1: RUF046 [*] Value being cast to `int` is already an integer 38 38 | int(1 + 1) 39 39 | int(1 - 1) -RUF046.py:38:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:38:1 | 36 | int(+1) 37 | 38 | int(1 + 1) - | ^^^^^^^^^^ RUF046 + | ^^^^^^^^^^ 39 | int(1 - 1) 40 | int(1 * 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 35 35 | int(-1) @@ -472,15 +495,16 @@ RUF046.py:38:1: RUF046 [*] Value being cast to `int` is already an integer 40 40 | int(1 * 1) 41 41 | int(1 % 1) -RUF046.py:39:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:39:1 | 38 | int(1 + 1) 39 | int(1 - 1) - | ^^^^^^^^^^ RUF046 + | ^^^^^^^^^^ 40 | int(1 * 1) 41 | int(1 % 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 36 36 | int(+1) @@ -492,16 +516,17 @@ RUF046.py:39:1: RUF046 [*] Value being cast to `int` is already an integer 41 41 | int(1 % 1) 42 42 | int(1 ** 1) -RUF046.py:40:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:40:1 | 38 | int(1 + 1) 39 | int(1 - 1) 40 | int(1 * 1) - | ^^^^^^^^^^ RUF046 + | ^^^^^^^^^^ 41 | int(1 % 1) 42 | int(1 ** 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 37 37 | @@ -513,16 +538,17 @@ RUF046.py:40:1: RUF046 [*] Value being cast to `int` is already an integer 42 42 | int(1 ** 1) 43 43 | int(1 << 1) -RUF046.py:41:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:41:1 | 39 | int(1 - 1) 40 | int(1 * 1) 41 | int(1 % 1) - | ^^^^^^^^^^ RUF046 + | ^^^^^^^^^^ 42 | int(1 ** 1) 43 | int(1 << 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 38 38 | int(1 + 1) @@ -534,16 +560,17 @@ RUF046.py:41:1: RUF046 [*] Value being cast to `int` is already an integer 43 43 | int(1 << 1) 44 44 | int(1 >> 1) -RUF046.py:42:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:42:1 | 40 | int(1 * 1) 41 | int(1 % 1) 42 | int(1 ** 1) - | ^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^ 43 | int(1 << 1) 44 | int(1 >> 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 39 39 | int(1 - 1) @@ -555,16 +582,17 @@ RUF046.py:42:1: RUF046 [*] Value being cast to `int` is already an integer 44 44 | int(1 >> 1) 45 45 | int(1 | 1) -RUF046.py:43:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:43:1 | 41 | int(1 % 1) 42 | int(1 ** 1) 43 | int(1 << 1) - | ^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^ 44 | int(1 >> 1) 45 | int(1 | 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 40 40 | int(1 * 1) @@ -576,16 +604,17 @@ RUF046.py:43:1: RUF046 [*] Value being cast to `int` is already an integer 45 45 | int(1 | 1) 46 46 | int(1 ^ 1) -RUF046.py:44:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:44:1 | 42 | int(1 ** 1) 43 | int(1 << 1) 44 | int(1 >> 1) - | ^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^ 45 | int(1 | 1) 46 | int(1 ^ 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 41 41 | int(1 % 1) @@ -597,16 +626,17 @@ RUF046.py:44:1: RUF046 [*] Value being cast to `int` is already an integer 46 46 | int(1 ^ 1) 47 47 | int(1 & 1) -RUF046.py:45:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:45:1 | 43 | int(1 << 1) 44 | int(1 >> 1) 45 | int(1 | 1) - | ^^^^^^^^^^ RUF046 + | ^^^^^^^^^^ 46 | int(1 ^ 1) 47 | int(1 & 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 42 42 | int(1 ** 1) @@ -618,16 +648,17 @@ RUF046.py:45:1: RUF046 [*] Value being cast to `int` is already an integer 47 47 | int(1 & 1) 48 48 | int(1 // 1) -RUF046.py:46:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:46:1 | 44 | int(1 >> 1) 45 | int(1 | 1) 46 | int(1 ^ 1) - | ^^^^^^^^^^ RUF046 + | ^^^^^^^^^^ 47 | int(1 & 1) 48 | int(1 // 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 43 43 | int(1 << 1) @@ -639,15 +670,16 @@ RUF046.py:46:1: RUF046 [*] Value being cast to `int` is already an integer 48 48 | int(1 // 1) 49 49 | -RUF046.py:47:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:47:1 | 45 | int(1 | 1) 46 | int(1 ^ 1) 47 | int(1 & 1) - | ^^^^^^^^^^ RUF046 + | ^^^^^^^^^^ 48 | int(1 // 1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 44 44 | int(1 >> 1) @@ -659,16 +691,17 @@ RUF046.py:47:1: RUF046 [*] Value being cast to `int` is already an integer 49 49 | 50 50 | int(1 if ... else 2) -RUF046.py:48:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:48:1 | 46 | int(1 ^ 1) 47 | int(1 & 1) 48 | int(1 // 1) - | ^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^ 49 | 50 | int(1 if ... else 2) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 45 45 | int(1 | 1) @@ -680,16 +713,17 @@ RUF046.py:48:1: RUF046 [*] Value being cast to `int` is already an integer 50 50 | int(1 if ... else 2) 51 51 | -RUF046.py:50:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:50:1 | 48 | int(1 // 1) 49 | 50 | int(1 if ... else 2) - | ^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^ 51 | 52 | int(1 and 0) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 47 47 | int(1 & 1) @@ -701,15 +735,16 @@ RUF046.py:50:1: RUF046 [*] Value being cast to `int` is already an integer 52 52 | int(1 and 0) 53 53 | int(0 or -1) -RUF046.py:52:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:52:1 | 50 | int(1 if ... else 2) 51 | 52 | int(1 and 0) - | ^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^ 53 | int(0 or -1) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 49 49 | @@ -721,13 +756,14 @@ RUF046.py:52:1: RUF046 [*] Value being cast to `int` is already an integer 54 54 | 55 55 | -RUF046.py:53:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:53:1 | 52 | int(1 and 0) 53 | int(0 or -1) - | ^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^ | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 50 50 | int(1 if ... else 2) @@ -739,13 +775,14 @@ RUF046.py:53:1: RUF046 [*] Value being cast to `int` is already an integer 55 55 | 56 56 | if int(1 + 2) * 3: -RUF046.py:56:4: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:56:4 | 56 | if int(1 + 2) * 3: - | ^^^^^^^^^^ RUF046 + | ^^^^^^^^^^ 57 | ... | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 53 53 | int(0 or -1) @@ -757,16 +794,17 @@ RUF046.py:56:4: RUF046 [*] Value being cast to `int` is already an integer 58 58 | 59 59 | -RUF046.py:62:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:62:1 | 60 | ### Unsafe 61 | 62 | int(math.ceil()) - | ^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^ 63 | int(math.floor()) 64 | int(math.trunc()) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 59 59 | @@ -778,14 +816,15 @@ RUF046.py:62:1: RUF046 [*] Value being cast to `int` is already an integer 64 64 | int(math.trunc()) 65 65 | -RUF046.py:63:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:63:1 | 62 | int(math.ceil()) 63 | int(math.floor()) - | ^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^ 64 | int(math.trunc()) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 60 60 | ### Unsafe @@ -797,16 +836,17 @@ RUF046.py:63:1: RUF046 [*] Value being cast to `int` is already an integer 65 65 | 66 66 | int(round(inferred_int, 0)) -RUF046.py:64:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:64:1 | 62 | int(math.ceil()) 63 | int(math.floor()) 64 | int(math.trunc()) - | ^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^ 65 | 66 | int(round(inferred_int, 0)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 61 61 | @@ -818,15 +858,16 @@ RUF046.py:64:1: RUF046 [*] Value being cast to `int` is already an integer 66 66 | int(round(inferred_int, 0)) 67 67 | int(round(inferred_int, 10)) -RUF046.py:66:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:66:1 | 64 | int(math.trunc()) 65 | 66 | int(round(inferred_int, 0)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 67 | int(round(inferred_int, 10)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 63 63 | int(math.floor()) @@ -838,15 +879,16 @@ RUF046.py:66:1: RUF046 [*] Value being cast to `int` is already an integer 68 68 | 69 69 | int(round(inferred_int)) -RUF046.py:67:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:67:1 | 66 | int(round(inferred_int, 0)) 67 | int(round(inferred_int, 10)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 68 | 69 | int(round(inferred_int)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 64 64 | int(math.trunc()) @@ -858,15 +900,16 @@ RUF046.py:67:1: RUF046 [*] Value being cast to `int` is already an integer 69 69 | int(round(inferred_int)) 70 70 | int(round(inferred_int, None)) -RUF046.py:69:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:69:1 | 67 | int(round(inferred_int, 10)) 68 | 69 | int(round(inferred_int)) - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 70 | int(round(inferred_int, None)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 66 66 | int(round(inferred_int, 0)) @@ -878,15 +921,16 @@ RUF046.py:69:1: RUF046 [*] Value being cast to `int` is already an integer 71 71 | 72 72 | int(round(inferred_float)) -RUF046.py:70:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:70:1 | 69 | int(round(inferred_int)) 70 | int(round(inferred_int, None)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 71 | 72 | int(round(inferred_float)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 67 67 | int(round(inferred_int, 10)) @@ -898,15 +942,16 @@ RUF046.py:70:1: RUF046 [*] Value being cast to `int` is already an integer 72 72 | int(round(inferred_float)) 73 73 | int(round(inferred_float, None)) -RUF046.py:72:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:72:1 | 70 | int(round(inferred_int, None)) 71 | 72 | int(round(inferred_float)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 73 | int(round(inferred_float, None)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 69 69 | int(round(inferred_int)) @@ -918,15 +963,16 @@ RUF046.py:72:1: RUF046 [*] Value being cast to `int` is already an integer 74 74 | 75 75 | int(round(unknown)) -RUF046.py:73:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:73:1 | 72 | int(round(inferred_float)) 73 | int(round(inferred_float, None)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 74 | 75 | int(round(unknown)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 70 70 | int(round(inferred_int, None)) @@ -938,15 +984,16 @@ RUF046.py:73:1: RUF046 [*] Value being cast to `int` is already an integer 75 75 | int(round(unknown)) 76 76 | int(round(unknown, None)) -RUF046.py:75:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:75:1 | 73 | int(round(inferred_float, None)) 74 | 75 | int(round(unknown)) - | ^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^ 76 | int(round(unknown, None)) | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 72 72 | int(round(inferred_float)) @@ -958,13 +1005,14 @@ RUF046.py:75:1: RUF046 [*] Value being cast to `int` is already an integer 77 77 | 78 78 | -RUF046.py:76:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:76:1 | 75 | int(round(unknown)) 76 | int(round(unknown, None)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 73 73 | int(round(inferred_float, None)) @@ -976,17 +1024,18 @@ RUF046.py:76:1: RUF046 [*] Value being cast to `int` is already an integer 78 78 | 79 79 | ### No errors -RUF046.py:158:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:158:1 | 156 | int(1. if ... else .2) 157 | 158 | / int(1 + 159 | | 1) - | |______^ RUF046 + | |______^ 160 | 161 | int(round(1, | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 155 155 | @@ -998,17 +1047,18 @@ RUF046.py:158:1: RUF046 [*] Value being cast to `int` is already an integer 160 160 | 161 161 | int(round(1, -RUF046.py:161:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:161:1 | 159 | 1) 160 | 161 | / int(round(1, 162 | | 0)) - | |_____________^ RUF046 + | |_____________^ 163 | 164 | # function calls may need to retain parentheses | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 158 158 | int(1 + @@ -1022,17 +1072,18 @@ RUF046.py:161:1: RUF046 [*] Value being cast to `int` is already an integer 164 164 | # function calls may need to retain parentheses 165 165 | # if the parentheses for the call itself -RUF046.py:168:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:168:1 | 166 | # lie on the next line. 167 | # See https://github.com/astral-sh/ruff/issues/15263 168 | / int(round 169 | | (1)) - | |____^ RUF046 + | |____^ 170 | 171 | int(round # a comment | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 165 165 | # if the parentheses for the call itself @@ -1044,7 +1095,8 @@ RUF046.py:168:1: RUF046 [*] Value being cast to `int` is already an integer 170 170 | 171 171 | int(round # a comment -RUF046.py:171:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:171:1 | 169 | (1)) 170 | @@ -1052,11 +1104,11 @@ RUF046.py:171:1: RUF046 [*] Value being cast to `int` is already an integer 172 | | # and another comment 173 | | (10) 174 | | ) - | |_^ RUF046 + | |_^ 175 | 176 | int(round (17)) # this is safe without parens | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 168 168 | int(round @@ -1072,16 +1124,17 @@ RUF046.py:171:1: RUF046 [*] Value being cast to `int` is already an integer 176 175 | int(round (17)) # this is safe without parens 177 176 | -RUF046.py:176:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:176:1 | 174 | ) 175 | 176 | int(round (17)) # this is safe without parens - | ^^^^^^^^^^^^^^^ RUF046 + | ^^^^^^^^^^^^^^^ 177 | 178 | int( round ( | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 173 173 | (10) @@ -1093,18 +1146,19 @@ RUF046.py:176:1: RUF046 [*] Value being cast to `int` is already an integer 178 178 | int( round ( 179 179 | 17 -RUF046.py:178:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:178:1 | 176 | int(round (17)) # this is safe without parens 177 | 178 | / int( round ( 179 | | 17 180 | | )) # this is also safe without parens - | |______________^ RUF046 + | |______________^ 181 | 182 | int((round) # Comment | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 175 175 | @@ -1119,18 +1173,19 @@ RUF046.py:178:1: RUF046 [*] Value being cast to `int` is already an integer 182 182 | int((round) # Comment 183 183 | (42) -RUF046.py:182:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:182:1 | 180 | )) # this is also safe without parens 181 | 182 | / int((round) # Comment 183 | | (42) 184 | | ) - | |_^ RUF046 + | |_^ 185 | 186 | int((round # Comment | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 179 179 | 17 @@ -1145,18 +1200,19 @@ RUF046.py:182:1: RUF046 [*] Value being cast to `int` is already an integer 186 185 | int((round # Comment 187 186 | )(42) -RUF046.py:186:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:186:1 | 184 | ) 185 | 186 | / int((round # Comment 187 | | )(42) 188 | | ) - | |_^ RUF046 + | |_^ 189 | 190 | int( # Unsafe fix because of this comment | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 183 183 | (42) @@ -1170,7 +1226,8 @@ RUF046.py:186:1: RUF046 [*] Value being cast to `int` is already an integer 190 189 | int( # Unsafe fix because of this comment 191 190 | ( # Comment -RUF046.py:190:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:190:1 | 188 | ) 189 | @@ -1180,11 +1237,11 @@ RUF046.py:190:1: RUF046 [*] Value being cast to `int` is already an integer 193 | | ) # Comment 194 | | )(42) 195 | | ) - | |_^ RUF046 + | |_^ 196 | 197 | int( | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 187 187 | )(42) @@ -1200,7 +1257,8 @@ RUF046.py:190:1: RUF046 [*] Value being cast to `int` is already an integer 197 195 | int( 198 196 | round( -RUF046.py:197:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:197:1 | 195 | ) 196 | @@ -1209,11 +1267,11 @@ RUF046.py:197:1: RUF046 [*] Value being cast to `int` is already an integer 199 | | 42 200 | | ) # unsafe fix because of this comment 201 | | ) - | |_^ RUF046 + | |_^ 202 | 203 | int( | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 194 194 | )(42) @@ -1230,7 +1288,8 @@ RUF046.py:197:1: RUF046 [*] Value being cast to `int` is already an integer 203 201 | int( 204 202 | round( -RUF046.py:203:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046.py:203:1 | 201 | ) 202 | @@ -1240,9 +1299,9 @@ RUF046.py:203:1: RUF046 [*] Value being cast to `int` is already an integer 206 | | ) 207 | | # unsafe fix because of this comment 208 | | ) - | |_^ RUF046 + | |_^ | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Unsafe fix 200 200 | ) # unsafe fix because of this comment diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046_CR.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046_CR.py.snap index 61b9115357..9451245979 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046_CR.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046_CR.py.snap @@ -1,12 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF046_CR.py:1:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046_CR.py:1:1 | -1 | int(- 1) # Carriage return as newline - | ^^^^^^^^^^^ RUF046 +1 | / int(- +2 | | 1) # Carriage return as newline + | |______^ | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 1 |-int(- 1 |+(- 2 2 | 1) # Carriage return as newline diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046_LF.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046_LF.py.snap index 97d44c191d..97b2815ed0 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046_LF.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF046_RUF046_LF.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF046_LF.py:2:1: RUF046 [*] Value being cast to `int` is already an integer +RUF046 [*] Value being cast to `int` is already an integer + --> RUF046_LF.py:2:1 | 1 | # \n as newline 2 | / int(- 3 | | 1) - | |______^ RUF046 + | |______^ | - = help: Remove unnecessary `int` call +help: Remove unnecessary `int` call ℹ Safe fix 1 1 | # \n as newline diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_for.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_for.py.snap index 3a0d9bc7a9..d3418eb4ab 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_for.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_for.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF047_for.py:6:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_for.py:6:1 | 4 | loop_body_is_not_checked() 5 | break 6 | / else: 7 | | pass - | |________^ RUF047 + | |________^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 3 3 | for _ in range(0): @@ -21,15 +22,16 @@ RUF047_for.py:6:1: RUF047 [*] Empty `else` clause 9 7 | 10 8 | for this in comment: -RUF047_for.py:12:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_for.py:12:1 | 10 | for this in comment: 11 | belongs_to() # `for` 12 | / else: 13 | | ... - | |_______^ RUF047 + | |_______^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 9 9 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_if.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_if.py.snap index b84cff6ad2..dedd1f90f0 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_if.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_if.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF047_if.py:5:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_if.py:5:1 | 3 | if False: 4 | condition_is_not_evaluated() 5 | / else: 6 | | pass - | |________^ RUF047 + | |________^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 2 2 | @@ -21,15 +22,16 @@ RUF047_if.py:5:1: RUF047 [*] Empty `else` clause 8 6 | 9 7 | if this_comment(): -RUF047_if.py:11:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_if.py:11:1 | 9 | if this_comment(): 10 | belongs_to() # `if` 11 | / else: 12 | | ... - | |_______^ RUF047 + | |_______^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 8 8 | @@ -41,15 +43,16 @@ RUF047_if.py:11:1: RUF047 [*] Empty `else` clause 14 12 | 15 13 | if elif_is(): -RUF047_if.py:19:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_if.py:19:1 | 17 | elif the_same(): 18 | as_if() 19 | / else: 20 | | pass - | |________^ RUF047 + | |________^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 16 16 | treated() @@ -61,17 +64,18 @@ RUF047_if.py:19:1: RUF047 [*] Empty `else` clause 22 20 | 23 21 | if this_second_comment(): -RUF047_if.py:26:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_if.py:26:1 | 24 | belongs() # to 25 | # `if` 26 | / else: 27 | | pass - | |________^ RUF047 + | |________^ 28 | 29 | if this_second_comment(): | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 23 23 | if this_second_comment(): @@ -83,15 +87,16 @@ RUF047_if.py:26:1: RUF047 [*] Empty `else` clause 29 27 | if this_second_comment(): 30 28 | belongs() # to -RUF047_if.py:32:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_if.py:32:1 | 30 | belongs() # to 31 | # `if` 32 | / else: 33 | | pass - | |________^ RUF047 + | |________^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 29 29 | if this_second_comment(): @@ -103,13 +108,14 @@ RUF047_if.py:32:1: RUF047 [*] Empty `else` clause 35 33 | 36 34 | if of_course(): -RUF047_if.py:44:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_if.py:44:1 | 43 | if of_course: this() 44 | else: ... - | ^^^^^^^^^ RUF047 + | ^^^^^^^^^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 41 41 | @@ -120,14 +126,15 @@ RUF047_if.py:44:1: RUF047 [*] Empty `else` clause 46 45 | 47 46 | if of_course: -RUF047_if.py:49:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_if.py:49:1 | 47 | if of_course: 48 | this() # comment 49 | else: ... - | ^^^^^^^^^ RUF047 + | ^^^^^^^^^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 46 46 | @@ -138,15 +145,16 @@ RUF047_if.py:49:1: RUF047 [*] Empty `else` clause 51 50 | 52 51 | def nested(): -RUF047_if.py:55:5: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_if.py:55:5 | 53 | if a: 54 | b() 55 | / else: 56 | | ... - | |___________^ RUF047 + | |___________^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 52 52 | def nested(): diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_try.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_try.py.snap index e27078492c..1677b1ca0d 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_try.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_try.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF047_try.py:7:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_try.py:7:1 | 5 | except: 6 | pass 7 | / else: 8 | | pass - | |________^ RUF047 + | |________^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 4 4 | raise try_body_is_not_checked() @@ -21,15 +22,16 @@ RUF047_try.py:7:1: RUF047 [*] Empty `else` clause 10 8 | 11 9 | try: -RUF047_try.py:17:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_try.py:17:1 | 15 | except: 16 | to() # `except` 17 | / else: 18 | | ... - | |_______^ RUF047 + | |_______^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 14 14 | belongs() diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_while.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_while.py.snap index c149edd4ed..dd8bbd01fc 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_while.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF047_RUF047_while.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF047_while.py:6:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_while.py:6:1 | 4 | loop_body_is_not_checked() 5 | break 6 | / else: 7 | | pass - | |________^ RUF047 + | |________^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 3 3 | while True: @@ -21,15 +22,16 @@ RUF047_while.py:6:1: RUF047 [*] Empty `else` clause 9 7 | 10 8 | while this_comment: -RUF047_while.py:12:1: RUF047 [*] Empty `else` clause +RUF047 [*] Empty `else` clause + --> RUF047_while.py:12:1 | 10 | while this_comment: 11 | belongs_to() # `for` 12 | / else: 13 | | ... - | |_______^ RUF047 + | |_______^ | - = help: Remove the `else` clause +help: Remove the `else` clause ℹ Safe fix 9 9 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF048_RUF048.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF048_RUF048.py.snap index 94348d4363..4c721ffa32 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF048_RUF048.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF048_RUF048.py.snap @@ -1,26 +1,29 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF048.py:4:7: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048.py:4:7 | 4 | tuple(map(int, __version__.split("."))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | list(map(int, __version__.split("."))) | -RUF048.py:5:6: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048.py:5:6 | 4 | tuple(map(int, __version__.split("."))) 5 | list(map(int, __version__.split("."))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | # `sep` passed as keyword argument | -RUF048.py:8:13: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048.py:8:13 | 7 | # `sep` passed as keyword argument 8 | for part in map(int, __version__.split(sep=".")): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | print(part) | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF048_RUF048_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF048_RUF048_1.py.snap index ae6ce29c4e..c1fd33ec95 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF048_RUF048_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF048_RUF048_1.py.snap @@ -1,55 +1,61 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF048_1.py:5:7: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048_1.py:5:7 | 5 | tuple(map(int, __version__.split("."))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | list(map(int, __version__.split("."))) 7 | tuple(map(int, bar.__version__.split("."))) | -RUF048_1.py:6:6: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048_1.py:6:6 | 5 | tuple(map(int, __version__.split("."))) 6 | list(map(int, __version__.split("."))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | tuple(map(int, bar.__version__.split("."))) 8 | list(map(int, bar.__version__.split("."))) | -RUF048_1.py:7:7: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048_1.py:7:7 | 5 | tuple(map(int, __version__.split("."))) 6 | list(map(int, __version__.split("."))) 7 | tuple(map(int, bar.__version__.split("."))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | list(map(int, bar.__version__.split("."))) | -RUF048_1.py:8:6: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048_1.py:8:6 | 6 | list(map(int, __version__.split("."))) 7 | tuple(map(int, bar.__version__.split("."))) 8 | list(map(int, bar.__version__.split("."))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | 10 | # `sep` passed as keyword argument | -RUF048_1.py:11:13: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048_1.py:11:13 | 10 | # `sep` passed as keyword argument 11 | for part in map(int, bar.__version__.split(sep=".")): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 | print(part) | -RUF048_1.py:14:13: RUF048 `__version__` may contain non-integral-like elements +RUF048 `__version__` may contain non-integral-like elements + --> RUF048_1.py:14:13 | 12 | print(part) 13 | 14 | for part in map(int, __version__.split(sep=".")): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF048 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | print(part) | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF049_RUF049.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF049_RUF049.py.snap index a2189975df..b5d1dd5e76 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF049_RUF049.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF049_RUF049.py.snap @@ -1,66 +1,73 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF049.py:10:1: RUF049 An enum class should not be decorated with `@dataclass` +RUF049 An enum class should not be decorated with `@dataclass` + --> RUF049.py:10:1 | 8 | ## Errors 9 | 10 | @dataclass - | ^^^^^^^^^^ RUF049 + | ^^^^^^^^^^ 11 | class E(Enum): ... | - = help: Remove either `@dataclass` or `Enum` +help: Remove either `@dataclass` or `Enum` -RUF049.py:14:1: RUF049 An enum class should not be decorated with `@dataclass` +RUF049 An enum class should not be decorated with `@dataclass` + --> RUF049.py:14:1 | 14 | @dataclass # Foobar - | ^^^^^^^^^^ RUF049 + | ^^^^^^^^^^ 15 | class E(Flag): ... | - = help: Remove either `@dataclass` or `Enum` +help: Remove either `@dataclass` or `Enum` -RUF049.py:18:1: RUF049 An enum class should not be decorated with `@dataclass` +RUF049 An enum class should not be decorated with `@dataclass` + --> RUF049.py:18:1 | 18 | @dataclass() - | ^^^^^^^^^^^^ RUF049 + | ^^^^^^^^^^^^ 19 | class E(IntEnum): ... | - = help: Remove either `@dataclass` or `Enum` +help: Remove either `@dataclass` or `Enum` -RUF049.py:22:1: RUF049 An enum class should not be decorated with `@dataclass` +RUF049 An enum class should not be decorated with `@dataclass` + --> RUF049.py:22:1 | 22 | @dataclass() # Foobar - | ^^^^^^^^^^^^ RUF049 + | ^^^^^^^^^^^^ 23 | class E(IntFlag): ... | - = help: Remove either `@dataclass` or `Enum` +help: Remove either `@dataclass` or `Enum` -RUF049.py:26:1: RUF049 An enum class should not be decorated with `@dataclass` +RUF049 An enum class should not be decorated with `@dataclass` + --> RUF049.py:26:1 | 26 | / @dataclass( 27 | | frozen=True 28 | | ) - | |_^ RUF049 + | |_^ 29 | class E(StrEnum): ... | - = help: Remove either `@dataclass` or `Enum` +help: Remove either `@dataclass` or `Enum` -RUF049.py:32:1: RUF049 An enum class should not be decorated with `@dataclass` +RUF049 An enum class should not be decorated with `@dataclass` + --> RUF049.py:32:1 | 32 | / @dataclass( # Foobar 33 | | frozen=True 34 | | ) - | |_^ RUF049 + | |_^ 35 | class E(ReprEnum): ... | - = help: Remove either `@dataclass` or `Enum` +help: Remove either `@dataclass` or `Enum` -RUF049.py:38:1: RUF049 An enum class should not be decorated with `@dataclass` +RUF049 An enum class should not be decorated with `@dataclass` + --> RUF049.py:38:1 | 38 | / @dataclass( 39 | | frozen=True 40 | | ) # Foobar - | |_^ RUF049 + | |_^ 41 | class E(Enum): ... | - = help: Remove either `@dataclass` or `Enum` +help: Remove either `@dataclass` or `Enum` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF051_RUF051.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF051_RUF051.py.snap index d164c38b8c..c64bab5ddc 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF051_RUF051.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF051_RUF051.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF051.py:8:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:8:5 | 7 | if k in d: # Bare name 8 | del d[k] - | ^^^^^^^^ RUF051 + | ^^^^^^^^ 9 | 10 | if '' in d: # String | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 4 4 | @@ -22,15 +23,16 @@ RUF051.py:8:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del di 10 9 | if '' in d: # String 11 10 | del d[""] # Different quotes -RUF051.py:11:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:11:5 | 10 | if '' in d: # String 11 | del d[""] # Different quotes - | ^^^^^^^^^ RUF051 + | ^^^^^^^^^ 12 | 13 | if b"" in d: # Bytes | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 7 7 | if k in d: # Bare name @@ -43,17 +45,18 @@ RUF051.py:11:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 13 12 | if b"" in d: # Bytes 14 13 | del d[ # Multiline slice -RUF051.py:14:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:14:5 | 13 | if b"" in d: # Bytes 14 | / del d[ # Multiline slice 15 | | b'''''' # Triple quotes 16 | | ] - | |_____^ RUF051 + | |_____^ 17 | 18 | if 0 in d: del d[0] # Single-line statement | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 10 10 | if '' in d: # String @@ -68,16 +71,17 @@ RUF051.py:14:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 18 15 | if 0 in d: del d[0] # Single-line statement 19 16 | -RUF051.py:18:12: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:18:12 | 16 | ] 17 | 18 | if 0 in d: del d[0] # Single-line statement - | ^^^^^^^^ RUF051 + | ^^^^^^^^ 19 | 20 | if 3j in d: # Complex | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 15 15 | b'''''' # Triple quotes @@ -89,15 +93,16 @@ RUF051.py:18:12: RUF051 [*] Use `pop` instead of `key in dict` followed by `del 20 20 | if 3j in d: # Complex 21 21 | del d[3j] -RUF051.py:21:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:21:5 | 20 | if 3j in d: # Complex 21 | del d[3j] - | ^^^^^^^^^ RUF051 + | ^^^^^^^^^ 22 | 23 | if 0.1234 in d: # Float | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 17 17 | @@ -110,15 +115,16 @@ RUF051.py:21:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 23 22 | if 0.1234 in d: # Float 24 23 | del d[.1_2_3_4] # Number separators and shorthand syntax -RUF051.py:24:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:24:5 | 23 | if 0.1234 in d: # Float 24 | del d[.1_2_3_4] # Number separators and shorthand syntax - | ^^^^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^^^^ 25 | 26 | if True in d: # True | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 20 20 | if 3j in d: # Complex @@ -131,15 +137,16 @@ RUF051.py:24:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 26 25 | if True in d: # True 27 26 | del d[True] -RUF051.py:27:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:27:5 | 26 | if True in d: # True 27 | del d[True] - | ^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^ 28 | 29 | if False in d: # False | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 23 23 | if 0.1234 in d: # Float @@ -152,15 +159,16 @@ RUF051.py:27:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 29 28 | if False in d: # False 30 29 | del d[False] -RUF051.py:30:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:30:5 | 29 | if False in d: # False 30 | del d[False] - | ^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^ 31 | 32 | if None in d: # None | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 26 26 | if True in d: # True @@ -173,18 +181,19 @@ RUF051.py:30:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 32 31 | if None in d: # None 33 32 | del d[ -RUF051.py:33:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:33:5 | 32 | if None in d: # None 33 | / del d[ 34 | | # Comment in the middle 35 | | None 36 | | ] - | |_____^ RUF051 + | |_____^ 37 | 38 | if ... in d: # Ellipsis | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 29 29 | if False in d: # False @@ -200,17 +209,18 @@ RUF051.py:33:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 38 34 | if ... in d: # Ellipsis 39 35 | del d[ -RUF051.py:39:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:39:5 | 38 | if ... in d: # Ellipsis 39 | / del d[ 40 | | # Comment in the middle, indented 41 | | ...] - | |____________^ RUF051 + | |____________^ 42 | 43 | if "a" "bc" in d: # String concatenation | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 35 35 | None @@ -225,15 +235,16 @@ RUF051.py:39:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 43 40 | if "a" "bc" in d: # String concatenation 44 41 | del d['abc'] -RUF051.py:44:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:44:5 | 43 | if "a" "bc" in d: # String concatenation 44 | del d['abc'] - | ^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^ 45 | 46 | if r"\foo" in d: # Raw string | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 40 40 | # Comment in the middle, indented @@ -246,15 +257,16 @@ RUF051.py:44:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 46 45 | if r"\foo" in d: # Raw string 47 46 | del d['\\foo'] -RUF051.py:47:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:47:5 | 46 | if r"\foo" in d: # Raw string 47 | del d['\\foo'] - | ^^^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^^^ 48 | 49 | if b'yt' b'es' in d: # Bytes concatenation | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 43 43 | if "a" "bc" in d: # String concatenation @@ -267,15 +279,16 @@ RUF051.py:47:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 49 48 | if b'yt' b'es' in d: # Bytes concatenation 50 49 | del d[rb"""ytes"""] # Raw bytes -RUF051.py:50:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:50:5 | 49 | if b'yt' b'es' in d: # Bytes concatenation 50 | del d[rb"""ytes"""] # Raw bytes - | ^^^^^^^^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^^^^^^^^ 51 | 52 | if k in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 46 46 | if r"\foo" in d: # Raw string @@ -288,16 +301,17 @@ RUF051.py:50:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 52 51 | if k in d: 53 52 | # comment that gets dropped -RUF051.py:54:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:54:5 | 52 | if k in d: 53 | # comment that gets dropped 54 | del d[k] - | ^^^^^^^^ RUF051 + | ^^^^^^^^ 55 | 56 | ### Safely fixable | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Unsafe fix 49 49 | if b'yt' b'es' in d: # Bytes concatenation @@ -311,15 +325,16 @@ RUF051.py:54:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 56 54 | ### Safely fixable 57 55 | -RUF051.py:59:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:59:5 | 58 | if k in d: 59 | del d[k] - | ^^^^^^^^ RUF051 + | ^^^^^^^^ 60 | 61 | if '' in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 55 55 | @@ -332,15 +347,16 @@ RUF051.py:59:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 61 60 | if '' in d: 62 61 | del d[""] -RUF051.py:62:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:62:5 | 61 | if '' in d: 62 | del d[""] - | ^^^^^^^^^ RUF051 + | ^^^^^^^^^ 63 | 64 | if b"" in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 58 58 | if k in d: @@ -353,17 +369,18 @@ RUF051.py:62:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 64 63 | if b"" in d: 65 64 | del d[ -RUF051.py:65:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:65:5 | 64 | if b"" in d: 65 | / del d[ 66 | | b'''''' 67 | | ] - | |_____^ RUF051 + | |_____^ 68 | 69 | if 0 in d: del d[0] | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 61 61 | if '' in d: @@ -378,16 +395,17 @@ RUF051.py:65:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 69 66 | if 0 in d: del d[0] 70 67 | -RUF051.py:69:12: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:69:12 | 67 | ] 68 | 69 | if 0 in d: del d[0] - | ^^^^^^^^ RUF051 + | ^^^^^^^^ 70 | 71 | if 3j in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 66 66 | b'''''' @@ -399,15 +417,16 @@ RUF051.py:69:12: RUF051 [*] Use `pop` instead of `key in dict` followed by `del 71 71 | if 3j in d: 72 72 | del d[3j] -RUF051.py:72:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:72:5 | 71 | if 3j in d: 72 | del d[3j] - | ^^^^^^^^^ RUF051 + | ^^^^^^^^^ 73 | 74 | if 0.1234 in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 68 68 | @@ -420,15 +439,16 @@ RUF051.py:72:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 74 73 | if 0.1234 in d: 75 74 | del d[.1_2_3_4] -RUF051.py:75:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:75:5 | 74 | if 0.1234 in d: 75 | del d[.1_2_3_4] - | ^^^^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^^^^ 76 | 77 | if True in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 71 71 | if 3j in d: @@ -441,15 +461,16 @@ RUF051.py:75:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 77 76 | if True in d: 78 77 | del d[True] -RUF051.py:78:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:78:5 | 77 | if True in d: 78 | del d[True] - | ^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^ 79 | 80 | if False in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 74 74 | if 0.1234 in d: @@ -462,15 +483,16 @@ RUF051.py:78:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 80 79 | if False in d: 81 80 | del d[False] -RUF051.py:81:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:81:5 | 80 | if False in d: 81 | del d[False] - | ^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^ 82 | 83 | if None in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 77 77 | if True in d: @@ -483,17 +505,18 @@ RUF051.py:81:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 83 82 | if None in d: 84 83 | del d[ -RUF051.py:84:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:84:5 | 83 | if None in d: 84 | / del d[ 85 | | None 86 | | ] - | |_____^ RUF051 + | |_____^ 87 | 88 | if ... in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 80 80 | if False in d: @@ -508,16 +531,17 @@ RUF051.py:84:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 88 85 | if ... in d: 89 86 | del d[ -RUF051.py:89:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:89:5 | 88 | if ... in d: 89 | / del d[ 90 | | ...] - | |____________^ RUF051 + | |____________^ 91 | 92 | if "a" "bc" in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 85 85 | None @@ -531,15 +555,16 @@ RUF051.py:89:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 92 90 | if "a" "bc" in d: 93 91 | del d['abc'] -RUF051.py:93:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:93:5 | 92 | if "a" "bc" in d: 93 | del d['abc'] - | ^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^ 94 | 95 | if r"\foo" in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 89 89 | del d[ @@ -552,15 +577,16 @@ RUF051.py:93:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 95 94 | if r"\foo" in d: 96 95 | del d['\\foo'] -RUF051.py:96:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:96:5 | 95 | if r"\foo" in d: 96 | del d['\\foo'] - | ^^^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^^^ 97 | 98 | if b'yt' b'es' in d: | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 92 92 | if "a" "bc" in d: @@ -573,13 +599,14 @@ RUF051.py:96:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del d 98 97 | if b'yt' b'es' in d: 99 98 | del d[rb"""ytes"""] # This should not make the fix unsafe -RUF051.py:99:5: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` +RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]` + --> RUF051.py:99:5 | 98 | if b'yt' b'es' in d: 99 | del d[rb"""ytes"""] # This should not make the fix unsafe - | ^^^^^^^^^^^^^^^^^^^ RUF051 + | ^^^^^^^^^^^^^^^^^^^ | - = help: Replace `if` statement with `.pop(..., None)` +help: Replace `if` statement with `.pop(..., None)` ℹ Safe fix 95 95 | if r"\foo" in d: diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF052_RUF052.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF052_RUF052.py.snap index d9d8b1e402..9c7eaadd88 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF052_RUF052.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF052_RUF052.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF052.py:92:9: RUF052 [*] Local dummy variable `_var` is accessed +RUF052 [*] Local dummy variable `_var` is accessed + --> RUF052.py:92:9 | 90 | class Class_: 91 | def fun(self): 92 | _var = "method variable" # [RUF052] - | ^^^^ RUF052 + | ^^^^ 93 | return _var | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 89 89 | @@ -23,14 +24,15 @@ RUF052.py:92:9: RUF052 [*] Local dummy variable `_var` is accessed 95 95 | def fun(_var): # parameters are ignored 96 96 | return _var -RUF052.py:99:5: RUF052 [*] Local dummy variable `_list` is accessed +RUF052 [*] Local dummy variable `_list` is accessed + --> RUF052.py:99:5 | 98 | def fun(): 99 | _list = "built-in" # [RUF052] - | ^^^^^ RUF052 + | ^^^^^ 100 | return _list | - = help: Prefer using trailing underscores to avoid shadowing a built-in +help: Prefer using trailing underscores to avoid shadowing a built-in ℹ Unsafe fix 96 96 | return _var @@ -44,15 +46,16 @@ RUF052.py:99:5: RUF052 [*] Local dummy variable `_list` is accessed 102 102 | x = "global" 103 103 | -RUF052.py:106:5: RUF052 [*] Local dummy variable `_x` is accessed +RUF052 [*] Local dummy variable `_x` is accessed + --> RUF052.py:106:5 | 104 | def fun(): 105 | global x 106 | _x = "shadows global" # [RUF052] - | ^^ RUF052 + | ^^ 107 | return _x | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable ℹ Unsafe fix 103 103 | @@ -66,16 +69,17 @@ RUF052.py:106:5: RUF052 [*] Local dummy variable `_x` is accessed 109 109 | def foo(): 110 110 | x = "outer" -RUF052.py:113:5: RUF052 [*] Local dummy variable `_x` is accessed +RUF052 [*] Local dummy variable `_x` is accessed + --> RUF052.py:113:5 | 111 | def bar(): 112 | nonlocal x 113 | _x = "shadows nonlocal" # [RUF052] - | ^^ RUF052 + | ^^ 114 | return _x 115 | bar() | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable ℹ Unsafe fix 110 110 | x = "outer" @@ -89,15 +93,16 @@ RUF052.py:113:5: RUF052 [*] Local dummy variable `_x` is accessed 116 116 | return x 117 117 | -RUF052.py:120:5: RUF052 [*] Local dummy variable `_x` is accessed +RUF052 [*] Local dummy variable `_x` is accessed + --> RUF052.py:120:5 | 118 | def fun(): 119 | x = "local" 120 | _x = "shadows local" # [RUF052] - | ^^ RUF052 + | ^^ 121 | return _x | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable ℹ Unsafe fix 117 117 | @@ -111,54 +116,59 @@ RUF052.py:120:5: RUF052 [*] Local dummy variable `_x` is accessed 123 123 | 124 124 | GLOBAL_1 = "global 1" -RUF052.py:128:5: RUF052 Local dummy variable `_GLOBAL_1` is accessed +RUF052 Local dummy variable `_GLOBAL_1` is accessed + --> RUF052.py:128:5 | 127 | def unfixables(): 128 | _GLOBAL_1 = "foo" - | ^^^^^^^^^ RUF052 + | ^^^^^^^^^ 129 | # unfixable because the rename would shadow a global variable 130 | print(_GLOBAL_1) # [RUF052] | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:136:5: RUF052 Local dummy variable `_local` is accessed +RUF052 Local dummy variable `_local` is accessed + --> RUF052.py:136:5 | 135 | # unfixable because the rename would shadow a local variable 136 | _local = "local3" # [RUF052] - | ^^^^^^ RUF052 + | ^^^^^^ 137 | print(_local) | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:140:9: RUF052 Local dummy variable `_GLOBAL_1` is accessed +RUF052 Local dummy variable `_GLOBAL_1` is accessed + --> RUF052.py:140:9 | 139 | def nested(): 140 | _GLOBAL_1 = "foo" - | ^^^^^^^^^ RUF052 + | ^^^^^^^^^ 141 | # unfixable because the rename would shadow a global variable 142 | print(_GLOBAL_1) # [RUF052] | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:145:9: RUF052 Local dummy variable `_local` is accessed +RUF052 Local dummy variable `_local` is accessed + --> RUF052.py:145:9 | 144 | # unfixable because the rename would shadow a variable from the outer function 145 | _local = "local4" - | ^^^^^^ RUF052 + | ^^^^^^ 146 | print(_local) | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:153:5: RUF052 [*] Local dummy variable `_P` is accessed +RUF052 [*] Local dummy variable `_P` is accessed + --> RUF052.py:153:5 | 151 | from collections import namedtuple 152 | 153 | _P = ParamSpec("_P") - | ^^ RUF052 + | ^^ 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 150 150 | from enum import Enum @@ -179,15 +189,16 @@ RUF052.py:153:5: RUF052 [*] Local dummy variable `_P` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:154:5: RUF052 [*] Local dummy variable `_T` is accessed +RUF052 [*] Local dummy variable `_T` is accessed + --> RUF052.py:154:5 | 153 | _P = ParamSpec("_P") 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) - | ^^ RUF052 + | ^^ 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 151 151 | from collections import namedtuple @@ -208,16 +219,17 @@ RUF052.py:154:5: RUF052 [*] Local dummy variable `_T` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:155:5: RUF052 [*] Local dummy variable `_NT` is accessed +RUF052 [*] Local dummy variable `_NT` is accessed + --> RUF052.py:155:5 | 153 | _P = ParamSpec("_P") 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) - | ^^^ RUF052 + | ^^^ 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 152 152 | @@ -237,16 +249,17 @@ RUF052.py:155:5: RUF052 [*] Local dummy variable `_NT` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:156:5: RUF052 [*] Local dummy variable `_E` is accessed +RUF052 [*] Local dummy variable `_E` is accessed + --> RUF052.py:156:5 | 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) - | ^^ RUF052 + | ^^ 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 153 153 | _P = ParamSpec("_P") @@ -265,16 +278,17 @@ RUF052.py:156:5: RUF052 [*] Local dummy variable `_E` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:157:5: RUF052 [*] Local dummy variable `_NT2` is accessed +RUF052 [*] Local dummy variable `_NT2` is accessed + --> RUF052.py:157:5 | 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) - | ^^^^ RUF052 + | ^^^^ 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 154 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) @@ -292,16 +306,17 @@ RUF052.py:157:5: RUF052 [*] Local dummy variable `_NT2` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:158:5: RUF052 [*] Local dummy variable `_NT3` is accessed +RUF052 [*] Local dummy variable `_NT3` is accessed + --> RUF052.py:158:5 | 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) - | ^^^^ RUF052 + | ^^^^ 159 | _DynamicClass = type("_DynamicClass", (), {}) 160 | _NotADynamicClass = type("_NotADynamicClass") | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 155 155 | _NT = NamedTuple("_NT", [("foo", int)]) @@ -318,15 +333,16 @@ RUF052.py:158:5: RUF052 [*] Local dummy variable `_NT3` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:159:5: RUF052 [*] Local dummy variable `_DynamicClass` is accessed +RUF052 [*] Local dummy variable `_DynamicClass` is accessed + --> RUF052.py:159:5 | 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) - | ^^^^^^^^^^^^^ RUF052 + | ^^^^^^^^^^^^^ 160 | _NotADynamicClass = type("_NotADynamicClass") | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 156 156 | _E = Enum("_E", ["a", "b", "c"]) @@ -342,16 +358,17 @@ RUF052.py:159:5: RUF052 [*] Local dummy variable `_DynamicClass` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:160:5: RUF052 [*] Local dummy variable `_NotADynamicClass` is accessed +RUF052 [*] Local dummy variable `_NotADynamicClass` is accessed + --> RUF052.py:160:5 | 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) 160 | _NotADynamicClass = type("_NotADynamicClass") - | ^^^^^^^^^^^^^^^^^ RUF052 + | ^^^^^^^^^^^^^^^^^ 161 | 162 | print(_T, _P, _NT, _E, _NT2, _NT3, _DynamicClass, _NotADynamicClass) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 157 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) @@ -366,15 +383,16 @@ RUF052.py:160:5: RUF052 [*] Local dummy variable `_NotADynamicClass` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:182:5: RUF052 [*] Local dummy variable `_dummy_var` is accessed +RUF052 [*] Local dummy variable `_dummy_var` is accessed + --> RUF052.py:182:5 | 181 | def foo(): 182 | _dummy_var = 42 - | ^^^^^^^^^^ RUF052 + | ^^^^^^^^^^ 183 | 184 | def bar(): | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable ℹ Unsafe fix 179 179 | @@ -391,13 +409,14 @@ RUF052.py:182:5: RUF052 [*] Local dummy variable `_dummy_var` is accessed 188 188 | 189 189 | def foo(): -RUF052.py:192:5: RUF052 Local dummy variable `_dummy_var` is accessed +RUF052 Local dummy variable `_dummy_var` is accessed + --> RUF052.py:192:5 | 190 | # Unfixable because both possible candidates for the new name are shadowed 191 | # in the scope of one of the references to the variable 192 | _dummy_var = 42 - | ^^^^^^^^^^ RUF052 + | ^^^^^^^^^^ 193 | 194 | def bar(): | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF053_RUF053.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF053_RUF053.py.snap index 8d308ab552..c1c1e734e1 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF053_RUF053.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF053_RUF053.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF053.py:23:12: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:23:12 | 21 | ### Errors 22 | 23 | class C[T](Generic[_A]): ... - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ 24 | class C[T](Generic[_B], str): ... 25 | class C[T](int, Generic[_C]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 20 20 | @@ -22,15 +23,16 @@ RUF053.py:23:12: RUF053 [*] Class with type parameter list inherits from `Generi 25 25 | class C[T](int, Generic[_C]): ... 26 26 | class C[T](bytes, Generic[_D], bool): ... # TODO: Type parameter defaults -RUF053.py:24:12: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:24:12 | 23 | class C[T](Generic[_A]): ... 24 | class C[T](Generic[_B], str): ... - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ 25 | class C[T](int, Generic[_C]): ... 26 | class C[T](bytes, Generic[_D], bool): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 21 21 | ### Errors @@ -42,16 +44,17 @@ RUF053.py:24:12: RUF053 [*] Class with type parameter list inherits from `Generi 26 26 | class C[T](bytes, Generic[_D], bool): ... # TODO: Type parameter defaults 27 27 | class C[T](Generic[_E], list[_E]): ... # TODO: Type parameter defaults -RUF053.py:25:17: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:25:17 | 23 | class C[T](Generic[_A]): ... 24 | class C[T](Generic[_B], str): ... 25 | class C[T](int, Generic[_C]): ... - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ 26 | class C[T](bytes, Generic[_D], bool): ... # TODO: Type parameter defaults 27 | class C[T](Generic[_E], list[_E]): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 22 22 | @@ -63,48 +66,52 @@ RUF053.py:25:17: RUF053 [*] Class with type parameter list inherits from `Generi 27 27 | class C[T](Generic[_E], list[_E]): ... # TODO: Type parameter defaults 28 28 | class C[T](list[_F], Generic[_F]): ... # TODO: Type parameter defaults -RUF053.py:26:19: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:26:19 | 24 | class C[T](Generic[_B], str): ... 25 | class C[T](int, Generic[_C]): ... 26 | class C[T](bytes, Generic[_D], bool): ... # TODO: Type parameter defaults - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ 27 | class C[T](Generic[_E], list[_E]): ... # TODO: Type parameter defaults 28 | class C[T](list[_F], Generic[_F]): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:27:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:27:12 | 25 | class C[T](int, Generic[_C]): ... 26 | class C[T](bytes, Generic[_D], bool): ... # TODO: Type parameter defaults 27 | class C[T](Generic[_E], list[_E]): ... # TODO: Type parameter defaults - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ 28 | class C[T](list[_F], Generic[_F]): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:28:22: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:28:22 | 26 | class C[T](bytes, Generic[_D], bool): ... # TODO: Type parameter defaults 27 | class C[T](Generic[_E], list[_E]): ... # TODO: Type parameter defaults 28 | class C[T](list[_F], Generic[_F]): ... # TODO: Type parameter defaults - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ 29 | 30 | class C[*Ts](Generic[*_As]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:30:14: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:30:14 | 28 | class C[T](list[_F], Generic[_F]): ... # TODO: Type parameter defaults 29 | 30 | class C[*Ts](Generic[*_As]): ... - | ^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^ 31 | class C[*Ts](Generic[Unpack[_As]]): ... 32 | class C[*Ts](Generic[Unpack[_Bs]], tuple[*Bs]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 27 27 | class C[T](Generic[_E], list[_E]): ... # TODO: Type parameter defaults @@ -116,15 +123,16 @@ RUF053.py:30:14: RUF053 [*] Class with type parameter list inherits from `Generi 32 32 | class C[*Ts](Generic[Unpack[_Bs]], tuple[*Bs]): ... 33 33 | class C[*Ts](Callable[[*_Cs], tuple[*Ts]], Generic[_Cs]): ... # TODO: Type parameter defaults -RUF053.py:31:14: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:31:14 | 30 | class C[*Ts](Generic[*_As]): ... 31 | class C[*Ts](Generic[Unpack[_As]]): ... - | ^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^ 32 | class C[*Ts](Generic[Unpack[_Bs]], tuple[*Bs]): ... 33 | class C[*Ts](Callable[[*_Cs], tuple[*Ts]], Generic[_Cs]): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 28 28 | class C[T](list[_F], Generic[_F]): ... # TODO: Type parameter defaults @@ -136,33 +144,36 @@ RUF053.py:31:14: RUF053 [*] Class with type parameter list inherits from `Generi 33 33 | class C[*Ts](Callable[[*_Cs], tuple[*Ts]], Generic[_Cs]): ... # TODO: Type parameter defaults 34 34 | -RUF053.py:32:14: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:32:14 | 30 | class C[*Ts](Generic[*_As]): ... 31 | class C[*Ts](Generic[Unpack[_As]]): ... 32 | class C[*Ts](Generic[Unpack[_Bs]], tuple[*Bs]): ... - | ^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^ 33 | class C[*Ts](Callable[[*_Cs], tuple[*Ts]], Generic[_Cs]): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:33:44: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:33:44 | 31 | class C[*Ts](Generic[Unpack[_As]]): ... 32 | class C[*Ts](Generic[Unpack[_Bs]], tuple[*Bs]): ... 33 | class C[*Ts](Callable[[*_Cs], tuple[*Ts]], Generic[_Cs]): ... # TODO: Type parameter defaults - | ^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:36:14: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:36:14 | 36 | class C[**P](Generic[_P1]): ... - | ^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^ 37 | class C[**P](Generic[_P2]): ... 38 | class C[**P](Generic[_P3]): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 33 33 | class C[*Ts](Callable[[*_Cs], tuple[*Ts]], Generic[_Cs]): ... # TODO: Type parameter defaults @@ -174,30 +185,33 @@ RUF053.py:36:14: RUF053 [*] Class with type parameter list inherits from `Generi 38 38 | class C[**P](Generic[_P3]): ... # TODO: Type parameter defaults 39 39 | -RUF053.py:37:14: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:37:14 | 36 | class C[**P](Generic[_P1]): ... 37 | class C[**P](Generic[_P2]): ... - | ^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^ 38 | class C[**P](Generic[_P3]): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:38:14: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:38:14 | 36 | class C[**P](Generic[_P1]): ... 37 | class C[**P](Generic[_P2]): ... 38 | class C[**P](Generic[_P3]): ... # TODO: Type parameter defaults - | ^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:41:12: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:41:12 | 41 | class C[T](Generic[T, _A]): ... - | ^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 38 38 | class C[**P](Generic[_P3]): ... # TODO: Type parameter defaults @@ -209,22 +223,24 @@ RUF053.py:41:12: RUF053 [*] Class with type parameter list inherits from `Generi 43 43 | 44 44 | # See `is_existing_param_of_same_class`. -RUF053.py:47:35: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:47:35 | 45 | # `expr_name_to_type_var` doesn't handle named expressions, 46 | # only simple assignments, so there is no fix. 47 | class C[T: (_Z := TypeVar('_Z'))](Generic[_Z]): ... - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:51:16: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:51:16 | 50 | class C(Generic[_B]): 51 | class D[T](Generic[_B, T]): ... - | ^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 48 48 | @@ -236,23 +252,25 @@ RUF053.py:51:16: RUF053 [*] Class with type parameter list inherits from `Generi 53 53 | 54 54 | class C[T]: -RUF053.py:55:16: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:55:16 | 54 | class C[T]: 55 | class D[U](Generic[T, U]): ... - | ^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:60:12: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:60:12 | 58 | # In a single run, only the first is reported. 59 | # Others will be reported/fixed in following iterations. 60 | class C[T](Generic[_C], Generic[_D]): ... - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ 61 | class C[T, _C: (str, bytes)](Generic[_D]): ... # TODO: Type parameter defaults | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 57 57 | @@ -264,92 +282,101 @@ RUF053.py:60:12: RUF053 [*] Class with type parameter list inherits from `Generi 62 62 | 63 63 | -RUF053.py:61:30: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:61:30 | 59 | # Others will be reported/fixed in following iterations. 60 | class C[T](Generic[_C], Generic[_D]): ... 61 | class C[T, _C: (str, bytes)](Generic[_D]): ... # TODO: Type parameter defaults - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:66:3: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:66:3 | 64 | class C[ 65 | T # Comment 66 | ](Generic[_E]): ... # TODO: Type parameter defaults - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:69:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:69:12 | 69 | class C[T](Generic[Generic[_F]]): ... - | ^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^ 70 | class C[T](Generic[Unpack[_A]]): ... 71 | class C[T](Generic[Unpack[_P1]]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:70:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:70:12 | 69 | class C[T](Generic[Generic[_F]]): ... 70 | class C[T](Generic[Unpack[_A]]): ... - | ^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^ 71 | class C[T](Generic[Unpack[_P1]]): ... 72 | class C[T](Generic[Unpack[Unpack[_P2]]]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:71:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:71:12 | 69 | class C[T](Generic[Generic[_F]]): ... 70 | class C[T](Generic[Unpack[_A]]): ... 71 | class C[T](Generic[Unpack[_P1]]): ... - | ^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^ 72 | class C[T](Generic[Unpack[Unpack[_P2]]]): ... 73 | class C[T](Generic[Unpack[*_As]]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:72:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:72:12 | 70 | class C[T](Generic[Unpack[_A]]): ... 71 | class C[T](Generic[Unpack[_P1]]): ... 72 | class C[T](Generic[Unpack[Unpack[_P2]]]): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 73 | class C[T](Generic[Unpack[*_As]]): ... 74 | class C[T](Generic[Unpack[_As, _Bs]]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:73:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:73:12 | 71 | class C[T](Generic[Unpack[_P1]]): ... 72 | class C[T](Generic[Unpack[Unpack[_P2]]]): ... 73 | class C[T](Generic[Unpack[*_As]]): ... - | ^^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^^ 74 | class C[T](Generic[Unpack[_As, _Bs]]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:74:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:74:12 | 72 | class C[T](Generic[Unpack[Unpack[_P2]]]): ... 73 | class C[T](Generic[Unpack[*_As]]): ... 74 | class C[T](Generic[Unpack[_As, _Bs]]): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:77:12: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:77:12 | 77 | class C[T](Generic[_A, _A]): ... - | ^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^ 78 | class C[T](Generic[_A, Unpack[_As]]): ... 79 | class C[T](Generic[*_As, _A]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 74 74 | class C[T](Generic[Unpack[_As, _Bs]]): ... @@ -361,14 +388,15 @@ RUF053.py:77:12: RUF053 [*] Class with type parameter list inherits from `Generi 79 79 | class C[T](Generic[*_As, _A]): ... 80 80 | -RUF053.py:78:12: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:78:12 | 77 | class C[T](Generic[_A, _A]): ... 78 | class C[T](Generic[_A, Unpack[_As]]): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 79 | class C[T](Generic[*_As, _A]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 75 75 | @@ -380,14 +408,15 @@ RUF053.py:78:12: RUF053 [*] Class with type parameter list inherits from `Generi 80 80 | 81 81 | -RUF053.py:79:12: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:79:12 | 77 | class C[T](Generic[_A, _A]): ... 78 | class C[T](Generic[_A, Unpack[_As]]): ... 79 | class C[T](Generic[*_As, _A]): ... - | ^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 76 76 | @@ -399,32 +428,35 @@ RUF053.py:79:12: RUF053 [*] Class with type parameter list inherits from `Generi 81 81 | 82 82 | from somewhere import APublicTypeVar -RUF053.py:83:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:83:12 | 82 | from somewhere import APublicTypeVar 83 | class C[T](Generic[APublicTypeVar]): ... - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^^^^ 84 | class C[T](Generic[APublicTypeVar, _A]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:84:12: RUF053 Class with type parameter list inherits from `Generic` +RUF053 Class with type parameter list inherits from `Generic` + --> RUF053.py:84:12 | 82 | from somewhere import APublicTypeVar 83 | class C[T](Generic[APublicTypeVar]): ... 84 | class C[T](Generic[APublicTypeVar, _A]): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class -RUF053.py:91:12: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:91:12 | 89 | # as named expressions are forbidden within type parameter lists. 90 | # See also the `_Z` example above. 91 | class C[T](Generic[_G]): ... # Should be moved down below eventually - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 88 88 | # The latter cannot be used as a PEP 695 constraint, @@ -436,14 +468,15 @@ RUF053.py:91:12: RUF053 [*] Class with type parameter list inherits from `Generi 93 93 | 94 94 | # Single-element constraints should not be converted to a bound. -RUF053.py:95:20: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:95:20 | 94 | # Single-element constraints should not be converted to a bound. 95 | class C[T: (str,)](Generic[_A]): ... - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ 96 | class C[T: [a]](Generic[_A]): ... | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 92 92 | @@ -455,14 +488,15 @@ RUF053.py:95:20: RUF053 [*] Class with type parameter list inherits from `Generi 97 97 | 98 98 | -RUF053.py:96:17: RUF053 [*] Class with type parameter list inherits from `Generic` +RUF053 [*] Class with type parameter list inherits from `Generic` + --> RUF053.py:96:17 | 94 | # Single-element constraints should not be converted to a bound. 95 | class C[T: (str,)](Generic[_A]): ... 96 | class C[T: [a]](Generic[_A]): ... - | ^^^^^^^^^^^ RUF053 + | ^^^^^^^^^^^ | - = help: Remove `Generic` base class +help: Remove `Generic` base class ℹ Unsafe fix 93 93 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF056_RUF056.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF056_RUF056.py.snap index 4d6d820f87..a54df64cc7 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF056_RUF056.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF056_RUF056.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF056.py:117:43: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:117:43 | 116 | # dict.get in ternary expression 117 | value = "not found" if my_dict.get("key", False) else "default" # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 118 | 119 | # dict.get in an if statement | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 114 114 | # Invalid falsy fallbacks are when the call to dict.get is used in a boolean context @@ -21,14 +22,15 @@ RUF056.py:117:43: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 119 119 | # dict.get in an if statement 120 120 | if my_dict.get("key", False): # [RUF056] -RUF056.py:120:23: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:120:23 | 119 | # dict.get in an if statement 120 | if my_dict.get("key", False): # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 121 | pass | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 117 117 | value = "not found" if my_dict.get("key", False) else "default" # [RUF056] @@ -40,14 +42,15 @@ RUF056.py:120:23: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 122 122 | 123 123 | # dict.get in compound if statement -RUF056.py:124:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:124:32 | 123 | # dict.get in compound if statement 124 | if True and my_dict.get("key", False): # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 125 | pass | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 121 121 | pass @@ -59,15 +62,16 @@ RUF056.py:124:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 126 126 | 127 127 | if my_dict.get("key", False) or True: # [RUF056] -RUF056.py:127:23: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:127:23 | 125 | pass 126 | 127 | if my_dict.get("key", False) or True: # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 128 | pass | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 124 124 | if True and my_dict.get("key", False): # [RUF056] @@ -79,15 +83,16 @@ RUF056.py:127:23: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 129 129 | 130 130 | # dict.get in an assert statement -RUF056.py:131:27: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:131:27 | 130 | # dict.get in an assert statement 131 | assert my_dict.get("key", False) # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 132 | 133 | # dict.get in a while statement | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 128 128 | pass @@ -99,14 +104,15 @@ RUF056.py:131:27: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 133 133 | # dict.get in a while statement 134 134 | while my_dict.get("key", False): # [RUF056] -RUF056.py:134:26: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:134:26 | 133 | # dict.get in a while statement 134 | while my_dict.get("key", False): # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 135 | pass | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 131 131 | assert my_dict.get("key", False) # [RUF056] @@ -118,15 +124,16 @@ RUF056.py:134:26: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 136 136 | 137 137 | # dict.get in unary not expression -RUF056.py:138:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:138:32 | 137 | # dict.get in unary not expression 138 | value = not my_dict.get("key", False) # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 139 | 140 | # testing all falsy fallbacks | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 135 135 | pass @@ -138,15 +145,16 @@ RUF056.py:138:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 140 140 | # testing all falsy fallbacks 141 141 | value = not my_dict.get("key", False) # [RUF056] -RUF056.py:141:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:141:32 | 140 | # testing all falsy fallbacks 141 | value = not my_dict.get("key", False) # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 142 | value = not my_dict.get("key", []) # [RUF056] 143 | value = not my_dict.get("key", list()) # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 138 138 | value = not my_dict.get("key", False) # [RUF056] @@ -158,16 +166,17 @@ RUF056.py:141:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 143 143 | value = not my_dict.get("key", list()) # [RUF056] 144 144 | value = not my_dict.get("key", {}) # [RUF056] -RUF056.py:142:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:142:32 | 140 | # testing all falsy fallbacks 141 | value = not my_dict.get("key", False) # [RUF056] 142 | value = not my_dict.get("key", []) # [RUF056] - | ^^ RUF056 + | ^^ 143 | value = not my_dict.get("key", list()) # [RUF056] 144 | value = not my_dict.get("key", {}) # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 139 139 | @@ -179,16 +188,17 @@ RUF056.py:142:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 144 144 | value = not my_dict.get("key", {}) # [RUF056] 145 145 | value = not my_dict.get("key", dict()) # [RUF056] -RUF056.py:143:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:143:32 | 141 | value = not my_dict.get("key", False) # [RUF056] 142 | value = not my_dict.get("key", []) # [RUF056] 143 | value = not my_dict.get("key", list()) # [RUF056] - | ^^^^^^ RUF056 + | ^^^^^^ 144 | value = not my_dict.get("key", {}) # [RUF056] 145 | value = not my_dict.get("key", dict()) # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 140 140 | # testing all falsy fallbacks @@ -200,16 +210,17 @@ RUF056.py:143:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 145 145 | value = not my_dict.get("key", dict()) # [RUF056] 146 146 | value = not my_dict.get("key", set()) # [RUF056] -RUF056.py:144:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:144:32 | 142 | value = not my_dict.get("key", []) # [RUF056] 143 | value = not my_dict.get("key", list()) # [RUF056] 144 | value = not my_dict.get("key", {}) # [RUF056] - | ^^ RUF056 + | ^^ 145 | value = not my_dict.get("key", dict()) # [RUF056] 146 | value = not my_dict.get("key", set()) # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 141 141 | value = not my_dict.get("key", False) # [RUF056] @@ -221,16 +232,17 @@ RUF056.py:144:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 146 146 | value = not my_dict.get("key", set()) # [RUF056] 147 147 | value = not my_dict.get("key", None) # [RUF056] -RUF056.py:145:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:145:32 | 143 | value = not my_dict.get("key", list()) # [RUF056] 144 | value = not my_dict.get("key", {}) # [RUF056] 145 | value = not my_dict.get("key", dict()) # [RUF056] - | ^^^^^^ RUF056 + | ^^^^^^ 146 | value = not my_dict.get("key", set()) # [RUF056] 147 | value = not my_dict.get("key", None) # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 142 142 | value = not my_dict.get("key", []) # [RUF056] @@ -242,16 +254,17 @@ RUF056.py:145:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 147 147 | value = not my_dict.get("key", None) # [RUF056] 148 148 | value = not my_dict.get("key", 0) # [RUF056] -RUF056.py:146:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:146:32 | 144 | value = not my_dict.get("key", {}) # [RUF056] 145 | value = not my_dict.get("key", dict()) # [RUF056] 146 | value = not my_dict.get("key", set()) # [RUF056] - | ^^^^^ RUF056 + | ^^^^^ 147 | value = not my_dict.get("key", None) # [RUF056] 148 | value = not my_dict.get("key", 0) # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 143 143 | value = not my_dict.get("key", list()) # [RUF056] @@ -263,16 +276,17 @@ RUF056.py:146:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 148 148 | value = not my_dict.get("key", 0) # [RUF056] 149 149 | value = not my_dict.get("key", 0.0) # [RUF056] -RUF056.py:147:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:147:32 | 145 | value = not my_dict.get("key", dict()) # [RUF056] 146 | value = not my_dict.get("key", set()) # [RUF056] 147 | value = not my_dict.get("key", None) # [RUF056] - | ^^^^ RUF056 + | ^^^^ 148 | value = not my_dict.get("key", 0) # [RUF056] 149 | value = not my_dict.get("key", 0.0) # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 144 144 | value = not my_dict.get("key", {}) # [RUF056] @@ -284,16 +298,17 @@ RUF056.py:147:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 149 149 | value = not my_dict.get("key", 0.0) # [RUF056] 150 150 | value = not my_dict.get("key", "") # [RUF056] -RUF056.py:148:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:148:32 | 146 | value = not my_dict.get("key", set()) # [RUF056] 147 | value = not my_dict.get("key", None) # [RUF056] 148 | value = not my_dict.get("key", 0) # [RUF056] - | ^ RUF056 + | ^ 149 | value = not my_dict.get("key", 0.0) # [RUF056] 150 | value = not my_dict.get("key", "") # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 145 145 | value = not my_dict.get("key", dict()) # [RUF056] @@ -305,15 +320,16 @@ RUF056.py:148:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 150 150 | value = not my_dict.get("key", "") # [RUF056] 151 151 | -RUF056.py:149:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:149:32 | 147 | value = not my_dict.get("key", None) # [RUF056] 148 | value = not my_dict.get("key", 0) # [RUF056] 149 | value = not my_dict.get("key", 0.0) # [RUF056] - | ^^^ RUF056 + | ^^^ 150 | value = not my_dict.get("key", "") # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 146 146 | value = not my_dict.get("key", set()) # [RUF056] @@ -325,16 +341,17 @@ RUF056.py:149:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 151 151 | 152 152 | # testing invalid dict.get call with inline comment -RUF056.py:150:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:150:32 | 148 | value = not my_dict.get("key", 0) # [RUF056] 149 | value = not my_dict.get("key", 0.0) # [RUF056] 150 | value = not my_dict.get("key", "") # [RUF056] - | ^^ RUF056 + | ^^ 151 | 152 | # testing invalid dict.get call with inline comment | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 147 147 | value = not my_dict.get("key", None) # [RUF056] @@ -346,15 +363,16 @@ RUF056.py:150:32: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 152 152 | # testing invalid dict.get call with inline comment 153 153 | value = not my_dict.get("key", # comment1 -RUF056.py:154:22: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:154:22 | 152 | # testing invalid dict.get call with inline comment 153 | value = not my_dict.get("key", # comment1 154 | [] # comment2 - | ^^ RUF056 + | ^^ 155 | ) # [RUF056] | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Unsafe fix 150 150 | value = not my_dict.get("key", "") # [RUF056] @@ -367,121 +385,132 @@ RUF056.py:154:22: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in 156 155 | 157 156 | # regression tests for https://github.com/astral-sh/ruff/issues/18628 -RUF056.py:163:24: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:163:24 | 162 | # extra positional 163 | not my_dict.get("key", False, "?!") - | ^^^^^ RUF056 + | ^^^^^ 164 | 165 | # `default` is positional-only, so these are invalid | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:166:24: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:166:24 | 165 | # `default` is positional-only, so these are invalid 166 | not my_dict.get("key", default=False) - | ^^^^^^^^^^^^^ RUF056 + | ^^^^^^^^^^^^^ 167 | not my_dict.get(key="key", default=False) 168 | not my_dict.get(default=[], key="key") | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:167:28: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:167:28 | 165 | # `default` is positional-only, so these are invalid 166 | not my_dict.get("key", default=False) 167 | not my_dict.get(key="key", default=False) - | ^^^^^^^^^^^^^ RUF056 + | ^^^^^^^^^^^^^ 168 | not my_dict.get(default=[], key="key") 169 | not my_dict.get(default=False) | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:168:17: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:168:17 | 166 | not my_dict.get("key", default=False) 167 | not my_dict.get(key="key", default=False) 168 | not my_dict.get(default=[], key="key") - | ^^^^^^^^^^ RUF056 + | ^^^^^^^^^^ 169 | not my_dict.get(default=False) 170 | not my_dict.get(key="key", other="something", default=False) | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:169:17: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:169:17 | 167 | not my_dict.get(key="key", default=False) 168 | not my_dict.get(default=[], key="key") 169 | not my_dict.get(default=False) - | ^^^^^^^^^^^^^ RUF056 + | ^^^^^^^^^^^^^ 170 | not my_dict.get(key="key", other="something", default=False) 171 | not my_dict.get(default=False, other="something", key="test") | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:170:47: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:170:47 | 168 | not my_dict.get(default=[], key="key") 169 | not my_dict.get(default=False) 170 | not my_dict.get(key="key", other="something", default=False) - | ^^^^^^^^^^^^^ RUF056 + | ^^^^^^^^^^^^^ 171 | not my_dict.get(default=False, other="something", key="test") | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:171:17: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:171:17 | 169 | not my_dict.get(default=False) 170 | not my_dict.get(key="key", other="something", default=False) 171 | not my_dict.get(default=False, other="something", key="test") - | ^^^^^^^^^^^^^ RUF056 + | ^^^^^^^^^^^^^ 172 | 173 | # comments don't really matter here because of the kwargs but include them for | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:177:5: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:177:5 | 175 | not my_dict.get( 176 | key="key", # comment1 177 | default=False, # comment2 - | ^^^^^^^^^^^^^ RUF056 + | ^^^^^^^^^^^^^ 178 | ) # comment 3 179 | not my_dict.get( | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:180:5: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:180:5 | 178 | ) # comment 3 179 | not my_dict.get( 180 | default=[], # comment1 - | ^^^^^^^^^^ RUF056 + | ^^^^^^^^^^ 181 | key="key", # comment2 182 | ) # comment 3 | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:187:24: RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:187:24 | 185 | # TypeError is raised at runtime before and after the fix, but we still bail 186 | # out for having an unrecognized number of arguments 187 | not my_dict.get("key", False, foo=...) - | ^^^^^ RUF056 + | ^^^^^ 188 | 189 | # https://github.com/astral-sh/ruff/issues/18798 | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` -RUF056.py:191:19: RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. +RUF056 [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy. + --> RUF056.py:191:19 | 189 | # https://github.com/astral-sh/ruff/issues/18798 190 | d = {} 191 | not d.get("key", (False)) - | ^^^^^ RUF056 + | ^^^^^ | - = help: Remove falsy fallback from `dict.get()` +help: Remove falsy fallback from `dict.get()` ℹ Safe fix 188 188 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF057_RUF057.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF057_RUF057.py.snap index 6b24910fb3..63e33ff282 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF057_RUF057.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF057_RUF057.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF057.py:6:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:6:1 | 6 | round(42) # Error (safe) - | ^^^^^^^^^ RUF057 + | ^^^^^^^^^ 7 | round(42, None) # Error (safe) 8 | round(42, 2) # Error (safe) | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Safe fix 3 3 | @@ -20,15 +21,16 @@ RUF057.py:6:1: RUF057 [*] Value being rounded is already an integer 8 8 | round(42, 2) # Error (safe) 9 9 | round(42, -2) # No error -RUF057.py:7:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:7:1 | 6 | round(42) # Error (safe) 7 | round(42, None) # Error (safe) - | ^^^^^^^^^^^^^^^ RUF057 + | ^^^^^^^^^^^^^^^ 8 | round(42, 2) # Error (safe) 9 | round(42, -2) # No error | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Safe fix 4 4 | @@ -40,16 +42,17 @@ RUF057.py:7:1: RUF057 [*] Value being rounded is already an integer 9 9 | round(42, -2) # No error 10 10 | round(42, inferred_int) # No error -RUF057.py:8:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:8:1 | 6 | round(42) # Error (safe) 7 | round(42, None) # Error (safe) 8 | round(42, 2) # Error (safe) - | ^^^^^^^^^^^^ RUF057 + | ^^^^^^^^^^^^ 9 | round(42, -2) # No error 10 | round(42, inferred_int) # No error | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Safe fix 5 5 | @@ -61,14 +64,15 @@ RUF057.py:8:1: RUF057 [*] Value being rounded is already an integer 10 10 | round(42, inferred_int) # No error 11 11 | round(42, 3 + 4) # No error -RUF057.py:24:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:24:1 | 24 | round(4 + 2) # Error (safe) - | ^^^^^^^^^^^^ RUF057 + | ^^^^^^^^^^^^ 25 | round(4 + 2, None) # Error (safe) 26 | round(4 + 2, 2) # Error (safe) | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Safe fix 21 21 | round(42., foo) # No error @@ -80,15 +84,16 @@ RUF057.py:24:1: RUF057 [*] Value being rounded is already an integer 26 26 | round(4 + 2, 2) # Error (safe) 27 27 | round(4 + 2, -2) # No error -RUF057.py:25:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:25:1 | 24 | round(4 + 2) # Error (safe) 25 | round(4 + 2, None) # Error (safe) - | ^^^^^^^^^^^^^^^^^^ RUF057 + | ^^^^^^^^^^^^^^^^^^ 26 | round(4 + 2, 2) # Error (safe) 27 | round(4 + 2, -2) # No error | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Safe fix 22 22 | @@ -100,16 +105,17 @@ RUF057.py:25:1: RUF057 [*] Value being rounded is already an integer 27 27 | round(4 + 2, -2) # No error 28 28 | round(4 + 2, inferred_int) # No error -RUF057.py:26:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:26:1 | 24 | round(4 + 2) # Error (safe) 25 | round(4 + 2, None) # Error (safe) 26 | round(4 + 2, 2) # Error (safe) - | ^^^^^^^^^^^^^^^ RUF057 + | ^^^^^^^^^^^^^^^ 27 | round(4 + 2, -2) # No error 28 | round(4 + 2, inferred_int) # No error | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Safe fix 23 23 | @@ -121,14 +127,15 @@ RUF057.py:26:1: RUF057 [*] Value being rounded is already an integer 28 28 | round(4 + 2, inferred_int) # No error 29 29 | round(4 + 2, 3 + 4) # No error -RUF057.py:42:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:42:1 | 42 | round(inferred_int) # Error (unsafe) - | ^^^^^^^^^^^^^^^^^^^ RUF057 + | ^^^^^^^^^^^^^^^^^^^ 43 | round(inferred_int, None) # Error (unsafe) 44 | round(inferred_int, 2) # Error (unsafe) | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Unsafe fix 39 39 | round(4. + 2., foo) # No error @@ -140,15 +147,16 @@ RUF057.py:42:1: RUF057 [*] Value being rounded is already an integer 44 44 | round(inferred_int, 2) # Error (unsafe) 45 45 | round(inferred_int, -2) # No error -RUF057.py:43:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:43:1 | 42 | round(inferred_int) # Error (unsafe) 43 | round(inferred_int, None) # Error (unsafe) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF057 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 44 | round(inferred_int, 2) # Error (unsafe) 45 | round(inferred_int, -2) # No error | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Unsafe fix 40 40 | @@ -160,16 +168,17 @@ RUF057.py:43:1: RUF057 [*] Value being rounded is already an integer 45 45 | round(inferred_int, -2) # No error 46 46 | round(inferred_int, inferred_int) # No error -RUF057.py:44:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:44:1 | 42 | round(inferred_int) # Error (unsafe) 43 | round(inferred_int, None) # Error (unsafe) 44 | round(inferred_int, 2) # Error (unsafe) - | ^^^^^^^^^^^^^^^^^^^^^^ RUF057 + | ^^^^^^^^^^^^^^^^^^^^^^ 45 | round(inferred_int, -2) # No error 46 | round(inferred_int, inferred_int) # No error | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Unsafe fix 41 41 | @@ -181,17 +190,18 @@ RUF057.py:44:1: RUF057 [*] Value being rounded is already an integer 46 46 | round(inferred_int, inferred_int) # No error 47 47 | round(inferred_int, 3 + 4) # No error -RUF057.py:71:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:71:1 | 69 | # contains newline. 70 | # See https://github.com/astral-sh/ruff/issues/15598 71 | / round(- 72 | | 1) - | |__^ RUF057 + | |__^ 73 | round(1 74 | *1 | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Safe fix 68 68 | # Fixes should preserve parentheses when argument @@ -203,18 +213,19 @@ RUF057.py:71:1: RUF057 [*] Value being rounded is already an integer 73 73 | round(1 74 74 | *1 -RUF057.py:73:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:73:1 | 71 | round(- 72 | 1) 73 | / round(1 74 | | *1 75 | | ) - | |_^ RUF057 + | |_^ 76 | 77 | # fix should be unsafe if comment is in call range | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Safe fix 70 70 | # See https://github.com/astral-sh/ruff/issues/15598 @@ -229,17 +240,18 @@ RUF057.py:73:1: RUF057 [*] Value being rounded is already an integer 77 76 | # fix should be unsafe if comment is in call range 78 77 | round(# a comment -RUF057.py:78:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:78:1 | 77 | # fix should be unsafe if comment is in call range 78 | / round(# a comment 79 | | 17 80 | | ) - | |_^ RUF057 + | |_^ 81 | round( 82 | 17 # a comment | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Unsafe fix 75 75 | ) @@ -252,16 +264,17 @@ RUF057.py:78:1: RUF057 [*] Value being rounded is already an integer 82 80 | 17 # a comment 83 81 | ) -RUF057.py:81:1: RUF057 [*] Value being rounded is already an integer +RUF057 [*] Value being rounded is already an integer + --> RUF057.py:81:1 | 79 | 17 80 | ) 81 | / round( 82 | | 17 # a comment 83 | | ) - | |_^ RUF057 + | |_^ | - = help: Remove unnecessary `round` call +help: Remove unnecessary `round` call ℹ Unsafe fix 78 78 | round(# a comment diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF058_RUF058_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF058_RUF058_0.py.snap index 4316cc714a..faec036b07 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF058_RUF058_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF058_RUF058_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF058_0.py:7:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_0.py:7:1 | 5 | # Errors 6 | 7 | starmap(func, zip()) - | ^^^^^^^^^^^^^^^^^^^^ RUF058 + | ^^^^^^^^^^^^^^^^^^^^ 8 | starmap(func, zip([])) | - = help: Use `map` instead +help: Use `map` instead ℹ Safe fix 4 4 | @@ -21,13 +22,14 @@ RUF058_0.py:7:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 9 9 | 10 10 | -RUF058_0.py:8:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_0.py:8:1 | 7 | starmap(func, zip()) 8 | starmap(func, zip([])) - | ^^^^^^^^^^^^^^^^^^^^^^ RUF058 + | ^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `map` instead +help: Use `map` instead ℹ Safe fix 5 5 | # Errors @@ -39,12 +41,13 @@ RUF058_0.py:8:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 10 10 | 11 11 | starmap(func, zip(a, b, c,),) -RUF058_0.py:11:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_0.py:11:1 | 11 | starmap(func, zip(a, b, c,),) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF058 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `map` instead +help: Use `map` instead ℹ Safe fix 8 8 | starmap(func, zip([])) @@ -56,7 +59,8 @@ RUF058_0.py:11:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 13 13 | 14 14 | starmap( -RUF058_0.py:14:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_0.py:14:1 | 14 | / starmap( 15 | | func, # Foo @@ -65,11 +69,11 @@ RUF058_0.py:14:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 18 | | 19 | | ) 20 | | ) - | |_^ RUF058 + | |_^ 21 | 22 | ( # Foo | - = help: Use `map` instead +help: Use `map` instead ℹ Unsafe fix 11 11 | starmap(func, zip(a, b, c,),) @@ -88,7 +92,8 @@ RUF058_0.py:14:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 21 21 | 22 22 | ( # Foo -RUF058_0.py:22:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_0.py:22:1 | 20 | ) 21 | @@ -100,11 +105,11 @@ RUF058_0.py:22:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 27 | | a, b, c, 28 | | ), 29 | | ) - | |_^ RUF058 + | |_^ 30 | 31 | ( # Foobar | - = help: Use `map` instead +help: Use `map` instead ℹ Unsafe fix 19 19 | ) @@ -124,7 +129,8 @@ RUF058_0.py:22:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 30 28 | 31 29 | ( # Foobar -RUF058_0.py:31:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_0.py:31:1 | 29 | ) 30 | @@ -147,11 +153,11 @@ RUF058_0.py:31:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 47 | | ) ) 48 | | ), 49 | | ) - | |_^ RUF058 + | |_^ 50 | 51 | starmap( | - = help: Use `map` instead +help: Use `map` instead ℹ Unsafe fix 29 29 | ) @@ -182,7 +188,8 @@ RUF058_0.py:31:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 50 42 | 51 43 | starmap( -RUF058_0.py:51:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_0.py:51:1 | 49 | ) 50 | @@ -196,9 +203,9 @@ RUF058_0.py:51:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 58 | | c,\ 59 | | ) 60 | | ) - | |_^ RUF058 + | |_^ | - = help: Use `map` instead +help: Use `map` instead ℹ Safe fix 48 48 | ), diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF058_RUF058_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF058_RUF058_1.py.snap index 49f3892fd4..366d0cdb1f 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF058_RUF058_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF058_RUF058_1.py.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF058_1.py:10:10: RUF058 `itertools.starmap` called on `zip` iterable +RUF058 `itertools.starmap` called on `zip` iterable + --> RUF058_1.py:10:10 | 9 | map = {} 10 | for _ in starmap(print, zip("A", "12")): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF058 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | pass | - = help: Use `map` instead +help: Use `map` instead diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_0.py.snap index 0f7d1505c3..a6d9e9ab12 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_0.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF059_0.py:24:6: RUF059 [*] Unpacked variable `c` is never used +RUF059 [*] Unpacked variable `c` is never used + --> RUF059_0.py:24:6 | 23 | bar = (1, 2) 24 | (c, d) = bar - | ^ RUF059 + | ^ 25 | 26 | (x, y) = baz = bar | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 21 21 | (a, b) = (1, 2) @@ -21,15 +22,16 @@ RUF059_0.py:24:6: RUF059 [*] Unpacked variable `c` is never used 26 26 | (x, y) = baz = bar 27 27 | -RUF059_0.py:24:9: RUF059 [*] Unpacked variable `d` is never used +RUF059 [*] Unpacked variable `d` is never used + --> RUF059_0.py:24:9 | 23 | bar = (1, 2) 24 | (c, d) = bar - | ^ RUF059 + | ^ 25 | 26 | (x, y) = baz = bar | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 21 21 | (a, b) = (1, 2) @@ -41,14 +43,15 @@ RUF059_0.py:24:9: RUF059 [*] Unpacked variable `d` is never used 26 26 | (x, y) = baz = bar 27 27 | -RUF059_0.py:26:6: RUF059 [*] Unpacked variable `x` is never used +RUF059 [*] Unpacked variable `x` is never used + --> RUF059_0.py:26:6 | 24 | (c, d) = bar 25 | 26 | (x, y) = baz = bar - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 23 23 | bar = (1, 2) @@ -60,14 +63,15 @@ RUF059_0.py:26:6: RUF059 [*] Unpacked variable `x` is never used 28 28 | 29 29 | def f(): -RUF059_0.py:26:9: RUF059 [*] Unpacked variable `y` is never used +RUF059 [*] Unpacked variable `y` is never used + --> RUF059_0.py:26:9 | 24 | (c, d) = bar 25 | 26 | (x, y) = baz = bar - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 23 23 | bar = (1, 2) @@ -79,15 +83,16 @@ RUF059_0.py:26:9: RUF059 [*] Unpacked variable `y` is never used 28 28 | 29 29 | def f(): -RUF059_0.py:66:24: RUF059 [*] Unpacked variable `connection` is never used +RUF059 [*] Unpacked variable `connection` is never used + --> RUF059_0.py:66:24 | 64 | return None, None 65 | 66 | with connect() as (connection, cursor): - | ^^^^^^^^^^ RUF059 + | ^^^^^^^^^^ 67 | cursor.execute("SELECT * FROM users") | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 63 63 | def connect(): @@ -99,15 +104,16 @@ RUF059_0.py:66:24: RUF059 [*] Unpacked variable `connection` is never used 68 68 | 69 69 | -RUF059_0.py:74:24: RUF059 [*] Unpacked variable `connection` is never used +RUF059 [*] Unpacked variable `connection` is never used + --> RUF059_0.py:74:24 | 72 | return None, None 73 | 74 | with connect() as (connection, cursor): - | ^^^^^^^^^^ RUF059 + | ^^^^^^^^^^ 75 | cursor.execute("SELECT * FROM users") | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 71 71 | def connect(): @@ -119,14 +125,15 @@ RUF059_0.py:74:24: RUF059 [*] Unpacked variable `connection` is never used 76 76 | 77 77 | -RUF059_0.py:79:49: RUF059 [*] Unpacked variable `this` is never used +RUF059 [*] Unpacked variable `this` is never used + --> RUF059_0.py:79:49 | 78 | def f(): 79 | with open("file") as my_file, open("") as ((this, that)): - | ^^^^ RUF059 + | ^^^^ 80 | print("hello") | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 76 76 | @@ -138,14 +145,15 @@ RUF059_0.py:79:49: RUF059 [*] Unpacked variable `this` is never used 81 81 | 82 82 | -RUF059_0.py:79:55: RUF059 [*] Unpacked variable `that` is never used +RUF059 [*] Unpacked variable `that` is never used + --> RUF059_0.py:79:55 | 78 | def f(): 79 | with open("file") as my_file, open("") as ((this, that)): - | ^^^^ RUF059 + | ^^^^ 80 | print("hello") | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 76 76 | @@ -157,16 +165,17 @@ RUF059_0.py:79:55: RUF059 [*] Unpacked variable `that` is never used 81 81 | 82 82 | -RUF059_0.py:86:23: RUF059 [*] Unpacked variable `this` is never used +RUF059 [*] Unpacked variable `this` is never used + --> RUF059_0.py:86:23 | 84 | with ( 85 | open("file") as my_file, 86 | open("") as ((this, that)), - | ^^^^ RUF059 + | ^^^^ 87 | ): 88 | print("hello") | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 83 83 | def f(): @@ -178,16 +187,17 @@ RUF059_0.py:86:23: RUF059 [*] Unpacked variable `this` is never used 88 88 | print("hello") 89 89 | -RUF059_0.py:86:29: RUF059 [*] Unpacked variable `that` is never used +RUF059 [*] Unpacked variable `that` is never used + --> RUF059_0.py:86:29 | 84 | with ( 85 | open("file") as my_file, 86 | open("") as ((this, that)), - | ^^^^ RUF059 + | ^^^^ 87 | ): 88 | print("hello") | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 83 83 | def f(): @@ -199,12 +209,13 @@ RUF059_0.py:86:29: RUF059 [*] Unpacked variable `that` is never used 88 88 | print("hello") 89 89 | -RUF059_0.py:101:5: RUF059 Unpacked variable `x` is never used +RUF059 Unpacked variable `x` is never used + --> RUF059_0.py:101:5 | 99 | # see: https://github.com/astral-sh/ruff/issues/18507 100 | def f(_x): 101 | x, = "1" - | ^ RUF059 + | ^ 102 | print(_x) | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_1.py.snap index 4172040bf2..b748594e1f 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_1.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF059_1.py:2:5: RUF059 [*] Unpacked variable `x` is never used +RUF059 [*] Unpacked variable `x` is never used + --> RUF059_1.py:2:5 | 1 | def f(tup): 2 | x, y = tup - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 1 1 | def f(tup): @@ -17,13 +18,14 @@ RUF059_1.py:2:5: RUF059 [*] Unpacked variable `x` is never used 4 4 | 5 5 | def f(): -RUF059_1.py:2:8: RUF059 [*] Unpacked variable `y` is never used +RUF059 [*] Unpacked variable `y` is never used + --> RUF059_1.py:2:8 | 1 | def f(tup): 2 | x, y = tup - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 1 1 | def f(tup): @@ -33,15 +35,16 @@ RUF059_1.py:2:8: RUF059 [*] Unpacked variable `y` is never used 4 4 | 5 5 | def f(): -RUF059_1.py:10:9: RUF059 [*] Unpacked variable `y` is never used +RUF059 [*] Unpacked variable `y` is never used + --> RUF059_1.py:10:9 | 9 | def f(): 10 | (x, y) = coords = 1, 2 - | ^ RUF059 + | ^ 11 | if x > 1: 12 | print(coords) | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 7 7 | @@ -53,13 +56,14 @@ RUF059_1.py:10:9: RUF059 [*] Unpacked variable `y` is never used 12 12 | print(coords) 13 13 | -RUF059_1.py:16:6: RUF059 [*] Unpacked variable `x` is never used +RUF059 [*] Unpacked variable `x` is never used + --> RUF059_1.py:16:6 | 15 | def f(): 16 | (x, y) = coords = 1, 2 - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 13 13 | @@ -71,13 +75,14 @@ RUF059_1.py:16:6: RUF059 [*] Unpacked variable `x` is never used 18 18 | 19 19 | def f(): -RUF059_1.py:16:9: RUF059 [*] Unpacked variable `y` is never used +RUF059 [*] Unpacked variable `y` is never used + --> RUF059_1.py:16:9 | 15 | def f(): 16 | (x, y) = coords = 1, 2 - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 13 13 | @@ -89,13 +94,14 @@ RUF059_1.py:16:9: RUF059 [*] Unpacked variable `y` is never used 18 18 | 19 19 | def f(): -RUF059_1.py:20:15: RUF059 [*] Unpacked variable `x` is never used +RUF059 [*] Unpacked variable `x` is never used + --> RUF059_1.py:20:15 | 19 | def f(): 20 | coords = (x, y) = 1, 2 - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 17 17 | @@ -107,13 +113,14 @@ RUF059_1.py:20:15: RUF059 [*] Unpacked variable `x` is never used 22 22 | 23 23 | def f(): -RUF059_1.py:20:18: RUF059 [*] Unpacked variable `y` is never used +RUF059 [*] Unpacked variable `y` is never used + --> RUF059_1.py:20:18 | 19 | def f(): 20 | coords = (x, y) = 1, 2 - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 17 17 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_2.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_2.py.snap index b7f265321e..9ff869dde6 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_2.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_2.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF059_2.py:8:20: RUF059 [*] Unpacked variable `x2` is never used +RUF059 [*] Unpacked variable `x2` is never used + --> RUF059_2.py:8:20 | 6 | pass 7 | 8 | with foo() as (x2, y2): - | ^^ RUF059 + | ^^ 9 | pass | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 5 5 | with foo() as x1: @@ -21,15 +22,16 @@ RUF059_2.py:8:20: RUF059 [*] Unpacked variable `x2` is never used 10 10 | 11 11 | with (foo() as x3, foo() as y3, foo() as z3): -RUF059_2.py:8:24: RUF059 [*] Unpacked variable `y2` is never used +RUF059 [*] Unpacked variable `y2` is never used + --> RUF059_2.py:8:24 | 6 | pass 7 | 8 | with foo() as (x2, y2): - | ^^ RUF059 + | ^^ 9 | pass | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 5 5 | with foo() as x1: @@ -41,15 +43,16 @@ RUF059_2.py:8:24: RUF059 [*] Unpacked variable `y2` is never used 10 10 | 11 11 | with (foo() as x3, foo() as y3, foo() as z3): -RUF059_2.py:17:6: RUF059 [*] Unpacked variable `x2` is never used +RUF059 [*] Unpacked variable `x2` is never used + --> RUF059_2.py:17:6 | 15 | def f(): 16 | (x1, y1) = (1, 2) 17 | (x2, y2) = coords2 = (1, 2) - | ^^ RUF059 + | ^^ 18 | coords3 = (x3, y3) = (1, 2) | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 14 14 | @@ -61,15 +64,16 @@ RUF059_2.py:17:6: RUF059 [*] Unpacked variable `x2` is never used 19 19 | 20 20 | -RUF059_2.py:17:10: RUF059 [*] Unpacked variable `y2` is never used +RUF059 [*] Unpacked variable `y2` is never used + --> RUF059_2.py:17:10 | 15 | def f(): 16 | (x1, y1) = (1, 2) 17 | (x2, y2) = coords2 = (1, 2) - | ^^ RUF059 + | ^^ 18 | coords3 = (x3, y3) = (1, 2) | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 14 14 | @@ -81,14 +85,15 @@ RUF059_2.py:17:10: RUF059 [*] Unpacked variable `y2` is never used 19 19 | 20 20 | -RUF059_2.py:18:16: RUF059 [*] Unpacked variable `x3` is never used +RUF059 [*] Unpacked variable `x3` is never used + --> RUF059_2.py:18:16 | 16 | (x1, y1) = (1, 2) 17 | (x2, y2) = coords2 = (1, 2) 18 | coords3 = (x3, y3) = (1, 2) - | ^^ RUF059 + | ^^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 15 15 | def f(): @@ -100,14 +105,15 @@ RUF059_2.py:18:16: RUF059 [*] Unpacked variable `x3` is never used 20 20 | 21 21 | def f(): -RUF059_2.py:18:20: RUF059 [*] Unpacked variable `y3` is never used +RUF059 [*] Unpacked variable `y3` is never used + --> RUF059_2.py:18:20 | 16 | (x1, y1) = (1, 2) 17 | (x2, y2) = coords2 = (1, 2) 18 | coords3 = (x3, y3) = (1, 2) - | ^^ RUF059 + | ^^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 15 15 | def f(): @@ -119,14 +125,15 @@ RUF059_2.py:18:20: RUF059 [*] Unpacked variable `y3` is never used 20 20 | 21 21 | def f(): -RUF059_2.py:22:24: RUF059 [*] Unpacked variable `x` is never used +RUF059 [*] Unpacked variable `x` is never used + --> RUF059_2.py:22:24 | 21 | def f(): 22 | with Nested(m) as (x, y): - | ^ RUF059 + | ^ 23 | pass | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 19 19 | @@ -138,14 +145,15 @@ RUF059_2.py:22:24: RUF059 [*] Unpacked variable `x` is never used 24 24 | 25 25 | -RUF059_2.py:22:27: RUF059 [*] Unpacked variable `y` is never used +RUF059 [*] Unpacked variable `y` is never used + --> RUF059_2.py:22:27 | 21 | def f(): 22 | with Nested(m) as (x, y): - | ^ RUF059 + | ^ 23 | pass | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 19 19 | @@ -157,13 +165,14 @@ RUF059_2.py:22:27: RUF059 [*] Unpacked variable `y` is never used 24 24 | 25 25 | -RUF059_2.py:27:17: RUF059 [*] Unpacked variable `a` is never used +RUF059 [*] Unpacked variable `a` is never used + --> RUF059_2.py:27:17 | 26 | def f(): 27 | toplevel = (a, b) = lexer.get_token() - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 24 24 | @@ -175,13 +184,14 @@ RUF059_2.py:27:17: RUF059 [*] Unpacked variable `a` is never used 29 29 | 30 30 | def f(): -RUF059_2.py:27:20: RUF059 [*] Unpacked variable `b` is never used +RUF059 [*] Unpacked variable `b` is never used + --> RUF059_2.py:27:20 | 26 | def f(): 27 | toplevel = (a, b) = lexer.get_token() - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 24 24 | @@ -193,13 +203,14 @@ RUF059_2.py:27:20: RUF059 [*] Unpacked variable `b` is never used 29 29 | 30 30 | def f(): -RUF059_2.py:31:6: RUF059 [*] Unpacked variable `a` is never used +RUF059 [*] Unpacked variable `a` is never used + --> RUF059_2.py:31:6 | 30 | def f(): 31 | (a, b) = toplevel = lexer.get_token() - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 28 28 | @@ -208,13 +219,14 @@ RUF059_2.py:31:6: RUF059 [*] Unpacked variable `a` is never used 31 |- (a, b) = toplevel = lexer.get_token() 31 |+ (_a, b) = toplevel = lexer.get_token() -RUF059_2.py:31:9: RUF059 [*] Unpacked variable `b` is never used +RUF059 [*] Unpacked variable `b` is never used + --> RUF059_2.py:31:9 | 30 | def f(): 31 | (a, b) = toplevel = lexer.get_token() - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 28 28 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_3.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_3.py.snap index 754acdcc6f..4f8d754651 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_3.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF059_RUF059_3.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF059_3.py:13:5: RUF059 [*] Unpacked variable `b` is never used +RUF059 [*] Unpacked variable `b` is never used + --> RUF059_3.py:13:5 | 11 | def bar(): 12 | a = foo() 13 | b, c = foo() - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 10 10 | @@ -20,14 +21,15 @@ RUF059_3.py:13:5: RUF059 [*] Unpacked variable `b` is never used 15 15 | 16 16 | def baz(): -RUF059_3.py:13:8: RUF059 [*] Unpacked variable `c` is never used +RUF059 [*] Unpacked variable `c` is never used + --> RUF059_3.py:13:8 | 11 | def bar(): 12 | a = foo() 13 | b, c = foo() - | ^ RUF059 + | ^ | - = help: Prefix it with an underscore or any other dummy variable pattern +help: Prefix it with an underscore or any other dummy variable pattern ℹ Unsafe fix 10 10 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF060_RUF060.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF060_RUF060.py.snap index ac92e967a9..20e8cf9f42 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF060_RUF060.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF060_RUF060.py.snap @@ -1,230 +1,253 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF060.py:2:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:2:1 | 1 | # Errors 2 | 1 in [] - | ^^^^^^^ RUF060 + | ^^^^^^^ 3 | 1 not in [] 4 | 2 in list() | -RUF060.py:3:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:3:1 | 1 | # Errors 2 | 1 in [] 3 | 1 not in [] - | ^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^ 4 | 2 in list() 5 | 2 not in list() | -RUF060.py:4:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:4:1 | 2 | 1 in [] 3 | 1 not in [] 4 | 2 in list() - | ^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^ 5 | 2 not in list() 6 | _ in () | -RUF060.py:5:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:5:1 | 3 | 1 not in [] 4 | 2 in list() 5 | 2 not in list() - | ^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^ 6 | _ in () 7 | _ not in () | -RUF060.py:6:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:6:1 | 4 | 2 in list() 5 | 2 not in list() 6 | _ in () - | ^^^^^^^ RUF060 + | ^^^^^^^ 7 | _ not in () 8 | 'x' in tuple() | -RUF060.py:7:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:7:1 | 5 | 2 not in list() 6 | _ in () 7 | _ not in () - | ^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^ 8 | 'x' in tuple() 9 | 'y' not in tuple() | -RUF060.py:8:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:8:1 | 6 | _ in () 7 | _ not in () 8 | 'x' in tuple() - | ^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^ 9 | 'y' not in tuple() 10 | 'a' in set() | -RUF060.py:9:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:9:1 | 7 | _ not in () 8 | 'x' in tuple() 9 | 'y' not in tuple() - | ^^^^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^^^^ 10 | 'a' in set() 11 | 'a' not in set() | -RUF060.py:10:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:10:1 | 8 | 'x' in tuple() 9 | 'y' not in tuple() 10 | 'a' in set() - | ^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^ 11 | 'a' not in set() 12 | 'b' in {} | -RUF060.py:11:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:11:1 | 9 | 'y' not in tuple() 10 | 'a' in set() 11 | 'a' not in set() - | ^^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^^ 12 | 'b' in {} 13 | 'b' not in {} | -RUF060.py:12:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:12:1 | 10 | 'a' in set() 11 | 'a' not in set() 12 | 'b' in {} - | ^^^^^^^^^ RUF060 + | ^^^^^^^^^ 13 | 'b' not in {} 14 | 1 in dict() | -RUF060.py:13:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:13:1 | 11 | 'a' not in set() 12 | 'b' in {} 13 | 'b' not in {} - | ^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^ 14 | 1 in dict() 15 | 2 not in dict() | -RUF060.py:14:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:14:1 | 12 | 'b' in {} 13 | 'b' not in {} 14 | 1 in dict() - | ^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^ 15 | 2 not in dict() 16 | "a" in "" | -RUF060.py:15:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:15:1 | 13 | 'b' not in {} 14 | 1 in dict() 15 | 2 not in dict() - | ^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^ 16 | "a" in "" 17 | b'c' in b"" | -RUF060.py:16:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:16:1 | 14 | 1 in dict() 15 | 2 not in dict() 16 | "a" in "" - | ^^^^^^^^^ RUF060 + | ^^^^^^^^^ 17 | b'c' in b"" 18 | "b" in f"" | -RUF060.py:17:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:17:1 | 15 | 2 not in dict() 16 | "a" in "" 17 | b'c' in b"" - | ^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^ 18 | "b" in f"" 19 | b"a" in bytearray() | -RUF060.py:18:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:18:1 | 16 | "a" in "" 17 | b'c' in b"" 18 | "b" in f"" - | ^^^^^^^^^^ RUF060 + | ^^^^^^^^^^ 19 | b"a" in bytearray() 20 | b"a" in bytes() | -RUF060.py:19:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:19:1 | 17 | b'c' in b"" 18 | "b" in f"" 19 | b"a" in bytearray() - | ^^^^^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^^^^^ 20 | b"a" in bytes() 21 | 1 in frozenset() | -RUF060.py:20:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:20:1 | 18 | "b" in f"" 19 | b"a" in bytearray() 20 | b"a" in bytes() - | ^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^ 21 | 1 in frozenset() 22 | 1 in set(set()) | -RUF060.py:21:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:21:1 | 19 | b"a" in bytearray() 20 | b"a" in bytes() 21 | 1 in frozenset() - | ^^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^^ 22 | 1 in set(set()) 23 | 2 in frozenset([]) | -RUF060.py:22:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:22:1 | 20 | b"a" in bytes() 21 | 1 in frozenset() 22 | 1 in set(set()) - | ^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^ 23 | 2 in frozenset([]) 24 | '' in set("") | -RUF060.py:23:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:23:1 | 21 | 1 in frozenset() 22 | 1 in set(set()) 23 | 2 in frozenset([]) - | ^^^^^^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^^^^^^ 24 | '' in set("") | -RUF060.py:24:1: RUF060 Unnecessary membership test on empty collection +RUF060 Unnecessary membership test on empty collection + --> RUF060.py:24:1 | 22 | 1 in set(set()) 23 | 2 in frozenset([]) 24 | '' in set("") - | ^^^^^^^^^^^^^ RUF060 + | ^^^^^^^^^^^^^ 25 | 26 | # OK | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_deprecated_call.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_deprecated_call.py.snap index 57f0c51fe1..f25897d788 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_deprecated_call.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_deprecated_call.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF061_deprecated_call.py:16:5: RUF061 [*] Use context-manager form of `pytest.deprecated_call()` +RUF061 [*] Use context-manager form of `pytest.deprecated_call()` + --> RUF061_deprecated_call.py:16:5 | 15 | def test_error_trivial(): 16 | pytest.deprecated_call(raise_deprecation_warning, "deprecated") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.deprecated_call()` as a context-manager +help: Use `pytest.deprecated_call()` as a context-manager ℹ Unsafe fix 13 13 | @@ -20,14 +21,15 @@ RUF061_deprecated_call.py:16:5: RUF061 [*] Use context-manager form of `pytest.d 18 19 | 19 20 | def test_error_assign(): -RUF061_deprecated_call.py:20:9: RUF061 [*] Use context-manager form of `pytest.deprecated_call()` +RUF061 [*] Use context-manager form of `pytest.deprecated_call()` + --> RUF061_deprecated_call.py:20:9 | 19 | def test_error_assign(): 20 | s = pytest.deprecated_call(raise_deprecation_warning, "deprecated") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | print(s) | - = help: Use `pytest.deprecated_call()` as a context-manager +help: Use `pytest.deprecated_call()` as a context-manager ℹ Unsafe fix 17 17 | @@ -40,13 +42,14 @@ RUF061_deprecated_call.py:20:9: RUF061 [*] Use context-manager form of `pytest.d 22 23 | 23 24 | -RUF061_deprecated_call.py:25:5: RUF061 [*] Use context-manager form of `pytest.deprecated_call()` +RUF061 [*] Use context-manager form of `pytest.deprecated_call()` + --> RUF061_deprecated_call.py:25:5 | 24 | def test_error_lambda(): 25 | pytest.deprecated_call(lambda: warnings.warn("", DeprecationWarning)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.deprecated_call()` as a context-manager +help: Use `pytest.deprecated_call()` as a context-manager ℹ Unsafe fix 22 22 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_raises.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_raises.py.snap index be2efdaee9..59cd74756d 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_raises.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_raises.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF061_raises.py:19:5: RUF061 [*] Use context-manager form of `pytest.raises()` +RUF061 [*] Use context-manager form of `pytest.raises()` + --> RUF061_raises.py:19:5 | 18 | def test_error_trivial(): 19 | pytest.raises(ZeroDivisionError, func, 1, b=0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.raises()` as a context-manager +help: Use `pytest.raises()` as a context-manager ℹ Unsafe fix 16 16 | @@ -20,13 +21,14 @@ RUF061_raises.py:19:5: RUF061 [*] Use context-manager form of `pytest.raises()` 21 22 | 22 23 | def test_error_match(): -RUF061_raises.py:23:5: RUF061 [*] Use context-manager form of `pytest.raises()` +RUF061 [*] Use context-manager form of `pytest.raises()` + --> RUF061_raises.py:23:5 | 22 | def test_error_match(): 23 | pytest.raises(ZeroDivisionError, func, 1, b=0).match("division by zero") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.raises()` as a context-manager +help: Use `pytest.raises()` as a context-manager ℹ Unsafe fix 20 20 | @@ -39,13 +41,14 @@ RUF061_raises.py:23:5: RUF061 [*] Use context-manager form of `pytest.raises()` 25 26 | 26 27 | def test_error_assign(): -RUF061_raises.py:27:15: RUF061 [*] Use context-manager form of `pytest.raises()` +RUF061 [*] Use context-manager form of `pytest.raises()` + --> RUF061_raises.py:27:15 | 26 | def test_error_assign(): 27 | excinfo = pytest.raises(ZeroDivisionError, func, 1, b=0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.raises()` as a context-manager +help: Use `pytest.raises()` as a context-manager ℹ Unsafe fix 24 24 | @@ -58,13 +61,14 @@ RUF061_raises.py:27:15: RUF061 [*] Use context-manager form of `pytest.raises()` 29 30 | 30 31 | def test_error_kwargs(): -RUF061_raises.py:31:5: RUF061 [*] Use context-manager form of `pytest.raises()` +RUF061 [*] Use context-manager form of `pytest.raises()` + --> RUF061_raises.py:31:5 | 30 | def test_error_kwargs(): 31 | pytest.raises(func=func, expected_exception=ZeroDivisionError) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.raises()` as a context-manager +help: Use `pytest.raises()` as a context-manager ℹ Unsafe fix 28 28 | @@ -77,14 +81,15 @@ RUF061_raises.py:31:5: RUF061 [*] Use context-manager form of `pytest.raises()` 33 34 | 34 35 | def test_error_multi_statement(): -RUF061_raises.py:35:15: RUF061 [*] Use context-manager form of `pytest.raises()` +RUF061 [*] Use context-manager form of `pytest.raises()` + --> RUF061_raises.py:35:15 | 34 | def test_error_multi_statement(): 35 | excinfo = pytest.raises(ValueError, int, "hello") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 | assert excinfo.match("^invalid literal") | - = help: Use `pytest.raises()` as a context-manager +help: Use `pytest.raises()` as a context-manager ℹ Unsafe fix 32 32 | @@ -97,13 +102,14 @@ RUF061_raises.py:35:15: RUF061 [*] Use context-manager form of `pytest.raises()` 37 38 | 38 39 | -RUF061_raises.py:40:5: RUF061 [*] Use context-manager form of `pytest.raises()` +RUF061 [*] Use context-manager form of `pytest.raises()` + --> RUF061_raises.py:40:5 | 39 | def test_error_lambda(): 40 | pytest.raises(ZeroDivisionError, lambda: 1 / 0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.raises()` as a context-manager +help: Use `pytest.raises()` as a context-manager ℹ Unsafe fix 37 37 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_warns.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_warns.py.snap index e47eb6307e..cbe5d04a21 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_warns.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF061_RUF061_warns.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF061_warns.py:16:5: RUF061 [*] Use context-manager form of `pytest.warns()` +RUF061 [*] Use context-manager form of `pytest.warns()` + --> RUF061_warns.py:16:5 | 15 | def test_error_trivial(): 16 | pytest.warns(UserWarning, raise_user_warning, "warning") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.warns()` as a context-manager +help: Use `pytest.warns()` as a context-manager ℹ Unsafe fix 13 13 | @@ -20,14 +21,15 @@ RUF061_warns.py:16:5: RUF061 [*] Use context-manager form of `pytest.warns()` 18 19 | 19 20 | def test_error_assign(): -RUF061_warns.py:20:9: RUF061 [*] Use context-manager form of `pytest.warns()` +RUF061 [*] Use context-manager form of `pytest.warns()` + --> RUF061_warns.py:20:9 | 19 | def test_error_assign(): 20 | s = pytest.warns(UserWarning, raise_user_warning, "warning") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | print(s) | - = help: Use `pytest.warns()` as a context-manager +help: Use `pytest.warns()` as a context-manager ℹ Unsafe fix 17 17 | @@ -40,13 +42,14 @@ RUF061_warns.py:20:9: RUF061 [*] Use context-manager form of `pytest.warns()` 22 23 | 23 24 | -RUF061_warns.py:25:5: RUF061 [*] Use context-manager form of `pytest.warns()` +RUF061 [*] Use context-manager form of `pytest.warns()` + --> RUF061_warns.py:25:5 | 24 | def test_error_lambda(): 25 | pytest.warns(UserWarning, lambda: warnings.warn("", UserWarning)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF061 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `pytest.warns()` as a context-manager +help: Use `pytest.warns()` as a context-manager ℹ Unsafe fix 22 22 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF064_RUF064.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF064_RUF064.py.snap index e42b87b266..acdb6555d2 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF064_RUF064.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF064_RUF064.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF064.py:6:17: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:6:17 | 4 | from pathlib import Path 5 | 6 | os.chmod("foo", 444) # Error - | ^^^ RUF064 + | ^^^ 7 | os.chmod("foo", 0o444) # OK 8 | os.chmod("foo", 7777) # Error | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 3 3 | import os @@ -22,47 +23,51 @@ RUF064.py:6:17: RUF064 [*] Non-octal mode 8 8 | os.chmod("foo", 7777) # Error 9 9 | os.chmod("foo", 10000) # Error -RUF064.py:8:17: RUF064 Non-octal mode +RUF064 Non-octal mode + --> RUF064.py:8:17 | 6 | os.chmod("foo", 444) # Error 7 | os.chmod("foo", 0o444) # OK 8 | os.chmod("foo", 7777) # Error - | ^^^^ RUF064 + | ^^^^ 9 | os.chmod("foo", 10000) # Error 10 | os.chmod("foo", 99999) # Error | - = help: Replace with octal literal +help: Replace with octal literal -RUF064.py:9:17: RUF064 Non-octal mode +RUF064 Non-octal mode + --> RUF064.py:9:17 | 7 | os.chmod("foo", 0o444) # OK 8 | os.chmod("foo", 7777) # Error 9 | os.chmod("foo", 10000) # Error - | ^^^^^ RUF064 + | ^^^^^ 10 | os.chmod("foo", 99999) # Error | - = help: Replace with octal literal +help: Replace with octal literal -RUF064.py:10:17: RUF064 Non-octal mode +RUF064 Non-octal mode + --> RUF064.py:10:17 | 8 | os.chmod("foo", 7777) # Error 9 | os.chmod("foo", 10000) # Error 10 | os.chmod("foo", 99999) # Error - | ^^^^^ RUF064 + | ^^^^^ 11 | 12 | os.umask(777) # Error | - = help: Replace with octal literal +help: Replace with octal literal -RUF064.py:12:10: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:12:10 | 10 | os.chmod("foo", 99999) # Error 11 | 12 | os.umask(777) # Error - | ^^^ RUF064 + | ^^^ 13 | os.umask(0o777) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 9 9 | os.chmod("foo", 10000) # Error @@ -74,15 +79,16 @@ RUF064.py:12:10: RUF064 [*] Non-octal mode 14 14 | 15 15 | os.fchmod(0, 400) # Error -RUF064.py:15:14: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:15:14 | 13 | os.umask(0o777) # OK 14 | 15 | os.fchmod(0, 400) # Error - | ^^^ RUF064 + | ^^^ 16 | os.fchmod(0, 0o400) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 12 12 | os.umask(777) # Error @@ -94,15 +100,16 @@ RUF064.py:15:14: RUF064 [*] Non-octal mode 17 17 | 18 18 | os.lchmod("foo", 755) # Error -RUF064.py:18:18: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:18:18 | 16 | os.fchmod(0, 0o400) # OK 17 | 18 | os.lchmod("foo", 755) # Error - | ^^^ RUF064 + | ^^^ 19 | os.lchmod("foo", 0o755) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 15 15 | os.fchmod(0, 400) # Error @@ -114,15 +121,16 @@ RUF064.py:18:18: RUF064 [*] Non-octal mode 20 20 | 21 21 | os.mkdir("foo", 600) # Error -RUF064.py:21:17: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:21:17 | 19 | os.lchmod("foo", 0o755) # OK 20 | 21 | os.mkdir("foo", 600) # Error - | ^^^ RUF064 + | ^^^ 22 | os.mkdir("foo", 0o600) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 18 18 | os.lchmod("foo", 755) # Error @@ -134,15 +142,16 @@ RUF064.py:21:17: RUF064 [*] Non-octal mode 23 23 | 24 24 | os.makedirs("foo", 644) # Error -RUF064.py:24:20: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:24:20 | 22 | os.mkdir("foo", 0o600) # OK 23 | 24 | os.makedirs("foo", 644) # Error - | ^^^ RUF064 + | ^^^ 25 | os.makedirs("foo", 0o644) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 21 21 | os.mkdir("foo", 600) # Error @@ -154,15 +163,16 @@ RUF064.py:24:20: RUF064 [*] Non-octal mode 26 26 | 27 27 | os.mkfifo("foo", 640) # Error -RUF064.py:27:18: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:27:18 | 25 | os.makedirs("foo", 0o644) # OK 26 | 27 | os.mkfifo("foo", 640) # Error - | ^^^ RUF064 + | ^^^ 28 | os.mkfifo("foo", 0o640) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 24 24 | os.makedirs("foo", 644) # Error @@ -174,15 +184,16 @@ RUF064.py:27:18: RUF064 [*] Non-octal mode 29 29 | 30 30 | os.mknod("foo", 660) # Error -RUF064.py:30:17: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:30:17 | 28 | os.mkfifo("foo", 0o640) # OK 29 | 30 | os.mknod("foo", 660) # Error - | ^^^ RUF064 + | ^^^ 31 | os.mknod("foo", 0o660) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 27 27 | os.mkfifo("foo", 640) # Error @@ -194,15 +205,16 @@ RUF064.py:30:17: RUF064 [*] Non-octal mode 32 32 | 33 33 | os.open("foo", os.O_CREAT, 644) # Error -RUF064.py:33:28: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:33:28 | 31 | os.mknod("foo", 0o660) # OK 32 | 33 | os.open("foo", os.O_CREAT, 644) # Error - | ^^^ RUF064 + | ^^^ 34 | os.open("foo", os.O_CREAT, 0o644) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 30 30 | os.mknod("foo", 660) # Error @@ -214,15 +226,16 @@ RUF064.py:33:28: RUF064 [*] Non-octal mode 35 35 | 36 36 | Path("bar").chmod(755) # Error -RUF064.py:36:19: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:36:19 | 34 | os.open("foo", os.O_CREAT, 0o644) # OK 35 | 36 | Path("bar").chmod(755) # Error - | ^^^ RUF064 + | ^^^ 37 | Path("bar").chmod(0o755) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 33 33 | os.open("foo", os.O_CREAT, 644) # Error @@ -234,14 +247,15 @@ RUF064.py:36:19: RUF064 [*] Non-octal mode 38 38 | 39 39 | path = Path("bar") -RUF064.py:40:12: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:40:12 | 39 | path = Path("bar") 40 | path.chmod(755) # Error - | ^^^ RUF064 + | ^^^ 41 | path.chmod(0o755) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 37 37 | Path("bar").chmod(0o755) # OK @@ -253,15 +267,16 @@ RUF064.py:40:12: RUF064 [*] Non-octal mode 42 42 | 43 43 | dbm.open("db", "r", 600) # Error -RUF064.py:43:21: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:43:21 | 41 | path.chmod(0o755) # OK 42 | 43 | dbm.open("db", "r", 600) # Error - | ^^^ RUF064 + | ^^^ 44 | dbm.open("db", "r", 0o600) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 40 40 | path.chmod(755) # Error @@ -273,15 +288,16 @@ RUF064.py:43:21: RUF064 [*] Non-octal mode 45 45 | 46 46 | dbm.gnu.open("db", "r", 600) # Error -RUF064.py:46:25: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:46:25 | 44 | dbm.open("db", "r", 0o600) # OK 45 | 46 | dbm.gnu.open("db", "r", 600) # Error - | ^^^ RUF064 + | ^^^ 47 | dbm.gnu.open("db", "r", 0o600) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 43 43 | dbm.open("db", "r", 600) # Error @@ -293,15 +309,16 @@ RUF064.py:46:25: RUF064 [*] Non-octal mode 48 48 | 49 49 | dbm.ndbm.open("db", "r", 600) # Error -RUF064.py:49:26: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:49:26 | 47 | dbm.gnu.open("db", "r", 0o600) # OK 48 | 49 | dbm.ndbm.open("db", "r", 600) # Error - | ^^^ RUF064 + | ^^^ 50 | dbm.ndbm.open("db", "r", 0o600) # OK | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 46 46 | dbm.gnu.open("db", "r", 600) # Error @@ -313,15 +330,16 @@ RUF064.py:49:26: RUF064 [*] Non-octal mode 51 51 | 52 52 | os.fchmod(0, 256) # 0o400 -RUF064.py:52:14: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:52:14 | 50 | dbm.ndbm.open("db", "r", 0o600) # OK 51 | 52 | os.fchmod(0, 256) # 0o400 - | ^^^ RUF064 + | ^^^ 53 | os.fchmod(0, 493) # 0o755 | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 49 49 | dbm.ndbm.open("db", "r", 600) # Error @@ -331,13 +349,14 @@ RUF064.py:52:14: RUF064 [*] Non-octal mode 52 |+os.fchmod(0, 0o400) # 0o400 53 53 | os.fchmod(0, 493) # 0o755 -RUF064.py:53:14: RUF064 [*] Non-octal mode +RUF064 [*] Non-octal mode + --> RUF064.py:53:14 | 52 | os.fchmod(0, 256) # 0o400 53 | os.fchmod(0, 493) # 0o755 - | ^^^ RUF064 + | ^^^ | - = help: Replace with octal literal +help: Replace with octal literal ℹ Unsafe fix 50 50 | dbm.ndbm.open("db", "r", 0o600) # OK diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_0.py.snap index 3a43790129..2041f3a696 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_0.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF101_0.py:1:15: RUF101 [*] `RUF940` is a redirect to `RUF950` +RUF101 [*] `RUF940` is a redirect to `RUF950` + --> RUF101_0.py:1:15 | 1 | x = 2 # noqa: RUF940 - | ^^^^^^ RUF101 + | ^^^^^^ 2 | x = 2 # noqa: RUF950 3 | x = 2 # noqa: RUF940, RUF950 | - = help: Replace with `RUF950` +help: Replace with `RUF950` ℹ Safe fix 1 |-x = 2 # noqa: RUF940 @@ -19,16 +19,17 @@ RUF101_0.py:1:15: RUF101 [*] `RUF940` is a redirect to `RUF950` 4 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 5 5 | x = 2 # noqa: RUF940, RUF950, RUF940 -RUF101_0.py:3:15: RUF101 [*] `RUF940` is a redirect to `RUF950` +RUF101 [*] `RUF940` is a redirect to `RUF950` + --> RUF101_0.py:3:15 | 1 | x = 2 # noqa: RUF940 2 | x = 2 # noqa: RUF950 3 | x = 2 # noqa: RUF940, RUF950 - | ^^^^^^ RUF101 + | ^^^^^^ 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 5 | x = 2 # noqa: RUF940, RUF950, RUF940 | - = help: Replace with `RUF950` +help: Replace with `RUF950` ℹ Safe fix 1 1 | x = 2 # noqa: RUF940 @@ -39,16 +40,17 @@ RUF101_0.py:3:15: RUF101 [*] `RUF940` is a redirect to `RUF950` 5 5 | x = 2 # noqa: RUF940, RUF950, RUF940 6 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 -RUF101_0.py:4:23: RUF101 [*] `RUF940` is a redirect to `RUF950` +RUF101 [*] `RUF940` is a redirect to `RUF950` + --> RUF101_0.py:4:23 | 2 | x = 2 # noqa: RUF950 3 | x = 2 # noqa: RUF940, RUF950 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 - | ^^^^^^ RUF101 + | ^^^^^^ 5 | x = 2 # noqa: RUF940, RUF950, RUF940 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 | - = help: Replace with `RUF950` +help: Replace with `RUF950` ℹ Safe fix 1 1 | x = 2 # noqa: RUF940 @@ -59,15 +61,16 @@ RUF101_0.py:4:23: RUF101 [*] `RUF940` is a redirect to `RUF950` 5 5 | x = 2 # noqa: RUF940, RUF950, RUF940 6 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 -RUF101_0.py:5:15: RUF101 [*] `RUF940` is a redirect to `RUF950` +RUF101 [*] `RUF940` is a redirect to `RUF950` + --> RUF101_0.py:5:15 | 3 | x = 2 # noqa: RUF940, RUF950 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 5 | x = 2 # noqa: RUF940, RUF950, RUF940 - | ^^^^^^ RUF101 + | ^^^^^^ 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 | - = help: Replace with `RUF950` +help: Replace with `RUF950` ℹ Safe fix 2 2 | x = 2 # noqa: RUF950 @@ -77,15 +80,16 @@ RUF101_0.py:5:15: RUF101 [*] `RUF940` is a redirect to `RUF950` 5 |+x = 2 # noqa: RUF950, RUF950, RUF940 6 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 -RUF101_0.py:5:31: RUF101 [*] `RUF940` is a redirect to `RUF950` +RUF101 [*] `RUF940` is a redirect to `RUF950` + --> RUF101_0.py:5:31 | 3 | x = 2 # noqa: RUF940, RUF950 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 5 | x = 2 # noqa: RUF940, RUF950, RUF940 - | ^^^^^^ RUF101 + | ^^^^^^ 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 | - = help: Replace with `RUF950` +help: Replace with `RUF950` ℹ Safe fix 2 2 | x = 2 # noqa: RUF950 @@ -95,14 +99,15 @@ RUF101_0.py:5:31: RUF101 [*] `RUF940` is a redirect to `RUF950` 5 |+x = 2 # noqa: RUF940, RUF950, RUF950 6 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 -RUF101_0.py:6:15: RUF101 [*] `RUF940` is a redirect to `RUF950` +RUF101 [*] `RUF940` is a redirect to `RUF950` + --> RUF101_0.py:6:15 | 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 5 | x = 2 # noqa: RUF940, RUF950, RUF940 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 - | ^^^^^^ RUF101 + | ^^^^^^ | - = help: Replace with `RUF950` +help: Replace with `RUF950` ℹ Safe fix 3 3 | x = 2 # noqa: RUF940, RUF950 @@ -111,14 +116,15 @@ RUF101_0.py:6:15: RUF101 [*] `RUF940` is a redirect to `RUF950` 6 |-x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 6 |+x = 2 # noqa: RUF950, RUF950, RUF940, RUF950 -RUF101_0.py:6:31: RUF101 [*] `RUF940` is a redirect to `RUF950` +RUF101 [*] `RUF940` is a redirect to `RUF950` + --> RUF101_0.py:6:31 | 4 | x = 2 # noqa: RUF950, RUF940, RUF950, RUF950, RUF950 5 | x = 2 # noqa: RUF940, RUF950, RUF940 6 | x = 2 # noqa: RUF940, RUF950, RUF940, RUF950 - | ^^^^^^ RUF101 + | ^^^^^^ | - = help: Replace with `RUF950` +help: Replace with `RUF950` ℹ Safe fix 3 3 | x = 2 # noqa: RUF940, RUF950 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_1.py.snap index 2b1d4b2b8b..2f65f2f208 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF101_RUF101_1.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF101_1.py:5:15: RUF101 [*] `TCH002` is a redirect to `TC002` +RUF101 [*] `TCH002` is a redirect to `TC002` + --> RUF101_1.py:5:15 | 3 | RUF101 should trigger here because the TCH rules have been recoded to TC. 4 | """ 5 | # ruff: noqa: TCH002 - | ^^^^^^ RUF101 + | ^^^^^^ 6 | 7 | from __future__ import annotations | - = help: Replace with `TC002` +help: Replace with `TC002` ℹ Safe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF102_RUF102.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF102_RUF102.py.snap index c70fa01b6c..c29d27335f 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF102_RUF102.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF102_RUF102.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF102.py:2:12: RUF102 [*] Invalid rule code in `# noqa`: INVALID123 +RUF102 [*] Invalid rule code in `# noqa`: INVALID123 + --> RUF102.py:2:12 | 1 | # Invalid code 2 | import os # noqa: INVALID123 - | ^^^^^^^^^^^^^^^^^^ RUF102 + | ^^^^^^^^^^^^^^^^^^ 3 | # External code 4 | import re # noqa: V123 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 1 1 | # Invalid code @@ -19,16 +20,17 @@ RUF102.py:2:12: RUF102 [*] Invalid rule code in `# noqa`: INVALID123 4 4 | import re # noqa: V123 5 5 | # Valid noqa -RUF102.py:4:12: RUF102 [*] Invalid rule code in `# noqa`: V123 +RUF102 [*] Invalid rule code in `# noqa`: V123 + --> RUF102.py:4:12 | 2 | import os # noqa: INVALID123 3 | # External code 4 | import re # noqa: V123 - | ^^^^^^^^^^^^ RUF102 + | ^^^^^^^^^^^^ 5 | # Valid noqa 6 | import sys # noqa: E402 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 1 1 | # Invalid code @@ -40,16 +42,17 @@ RUF102.py:4:12: RUF102 [*] Invalid rule code in `# noqa`: V123 6 6 | import sys # noqa: E402 7 7 | from functools import cache # Preceeding comment # noqa: F401, INVALID456 -RUF102.py:7:65: RUF102 [*] Invalid rule code in `# noqa`: INVALID456 +RUF102 [*] Invalid rule code in `# noqa`: INVALID456 + --> RUF102.py:7:65 | 5 | # Valid noqa 6 | import sys # noqa: E402 7 | from functools import cache # Preceeding comment # noqa: F401, INVALID456 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 8 | from itertools import product # Preceeding comment # noqa: INVALID789 9 | # Succeeding comment | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 4 4 | import re # noqa: V123 @@ -61,16 +64,17 @@ RUF102.py:7:65: RUF102 [*] Invalid rule code in `# noqa`: INVALID456 9 9 | # Succeeding comment 10 10 | import math # noqa: INVALID000 # Succeeding comment -RUF102.py:8:53: RUF102 [*] Invalid rule code in `# noqa`: INVALID789 +RUF102 [*] Invalid rule code in `# noqa`: INVALID789 + --> RUF102.py:8:53 | 6 | import sys # noqa: E402 7 | from functools import cache # Preceeding comment # noqa: F401, INVALID456 8 | from itertools import product # Preceeding comment # noqa: INVALID789 - | ^^^^^^^^^^^^^^^^^^ RUF102 + | ^^^^^^^^^^^^^^^^^^ 9 | # Succeeding comment 10 | import math # noqa: INVALID000 # Succeeding comment | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 5 5 | # Valid noqa @@ -82,16 +86,17 @@ RUF102.py:8:53: RUF102 [*] Invalid rule code in `# noqa`: INVALID789 10 10 | import math # noqa: INVALID000 # Succeeding comment 11 11 | # Mixed valid and invalid -RUF102.py:10:13: RUF102 [*] Invalid rule code in `# noqa`: INVALID000 +RUF102 [*] Invalid rule code in `# noqa`: INVALID000 + --> RUF102.py:10:13 | 8 | from itertools import product # Preceeding comment # noqa: INVALID789 9 | # Succeeding comment 10 | import math # noqa: INVALID000 # Succeeding comment - | ^^^^^^^^^^^^^^^^^^ RUF102 + | ^^^^^^^^^^^^^^^^^^ 11 | # Mixed valid and invalid 12 | from typing import List # noqa: F401, INVALID123 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 7 7 | from functools import cache # Preceeding comment # noqa: F401, INVALID456 @@ -103,16 +108,17 @@ RUF102.py:10:13: RUF102 [*] Invalid rule code in `# noqa`: INVALID000 12 12 | from typing import List # noqa: F401, INVALID123 13 13 | # Test for multiple invalid -RUF102.py:12:40: RUF102 [*] Invalid rule code in `# noqa`: INVALID123 +RUF102 [*] Invalid rule code in `# noqa`: INVALID123 + --> RUF102.py:12:40 | 10 | import math # noqa: INVALID000 # Succeeding comment 11 | # Mixed valid and invalid 12 | from typing import List # noqa: F401, INVALID123 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 13 | # Test for multiple invalid 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 9 9 | # Succeeding comment @@ -124,16 +130,17 @@ RUF102.py:12:40: RUF102 [*] Invalid rule code in `# noqa`: INVALID123 14 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 15 15 | # Test for preserving valid codes when fixing -RUF102.py:14:46: RUF102 [*] Invalid rule code in `# noqa`: INVALID100 +RUF102 [*] Invalid rule code in `# noqa`: INVALID100 + --> RUF102.py:14:46 | 12 | from typing import List # noqa: F401, INVALID123 13 | # Test for multiple invalid 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 15 | # Test for preserving valid codes when fixing 16 | from itertools import chain # noqa: E402, INVALID300, F401 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 11 11 | # Mixed valid and invalid @@ -145,16 +152,17 @@ RUF102.py:14:46: RUF102 [*] Invalid rule code in `# noqa`: INVALID100 16 16 | from itertools import chain # noqa: E402, INVALID300, F401 17 17 | # Test for mixed code types -RUF102.py:14:58: RUF102 [*] Invalid rule code in `# noqa`: INVALID200 +RUF102 [*] Invalid rule code in `# noqa`: INVALID200 + --> RUF102.py:14:58 | 12 | from typing import List # noqa: F401, INVALID123 13 | # Test for multiple invalid 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 15 | # Test for preserving valid codes when fixing 16 | from itertools import chain # noqa: E402, INVALID300, F401 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 11 11 | # Mixed valid and invalid @@ -166,16 +174,17 @@ RUF102.py:14:58: RUF102 [*] Invalid rule code in `# noqa`: INVALID200 16 16 | from itertools import chain # noqa: E402, INVALID300, F401 17 17 | # Test for mixed code types -RUF102.py:16:44: RUF102 [*] Invalid rule code in `# noqa`: INVALID300 +RUF102 [*] Invalid rule code in `# noqa`: INVALID300 + --> RUF102.py:16:44 | 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 15 | # Test for preserving valid codes when fixing 16 | from itertools import chain # noqa: E402, INVALID300, F401 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 17 | # Test for mixed code types 18 | import json # noqa: E402, INVALID400, V100 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 13 13 | # Test for multiple invalid @@ -186,14 +195,15 @@ RUF102.py:16:44: RUF102 [*] Invalid rule code in `# noqa`: INVALID300 17 17 | # Test for mixed code types 18 18 | import json # noqa: E402, INVALID400, V100 -RUF102.py:18:28: RUF102 [*] Invalid rule code in `# noqa`: INVALID400 +RUF102 [*] Invalid rule code in `# noqa`: INVALID400 + --> RUF102.py:18:28 | 16 | from itertools import chain # noqa: E402, INVALID300, F401 17 | # Test for mixed code types 18 | import json # noqa: E402, INVALID400, V100 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 15 15 | # Test for preserving valid codes when fixing @@ -202,14 +212,15 @@ RUF102.py:18:28: RUF102 [*] Invalid rule code in `# noqa`: INVALID400 18 |-import json # noqa: E402, INVALID400, V100 18 |+import json # noqa: E402, V100 -RUF102.py:18:40: RUF102 [*] Invalid rule code in `# noqa`: V100 +RUF102 [*] Invalid rule code in `# noqa`: V100 + --> RUF102.py:18:40 | 16 | from itertools import chain # noqa: E402, INVALID300, F401 17 | # Test for mixed code types 18 | import json # noqa: E402, INVALID400, V100 - | ^^^^ RUF102 + | ^^^^ | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 15 15 | # Test for preserving valid codes when fixing diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_bleach.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_bleach.snap index 170a923b43..069209c9aa 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_bleach.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_bleach.snap @@ -1,10 +1,10 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -pyproject.toml:5:16: RUF200 Failed to parse pyproject.toml: after parsing `1.1.0`, found `<1.2`, which is not part of a valid version +RUF200 Failed to parse pyproject.toml: after parsing `1.1.0`, found `<1.2`, which is not part of a valid version tinycss2>=1.1.0<1.2 ^^^^^^^^^^^ + --> pyproject.toml:5:16 | 3 | version = "0.1.0" 4 | # There's a comma missing here @@ -12,5 +12,5 @@ tinycss2>=1.1.0<1.2 | ________________^ 6 | | "tinycss2>=1.1.0<1.2", 7 | | ] - | |_^ RUF200 + | |_^ | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_invalid_author.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_invalid_author.snap index da4c911caa..112f023679 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_invalid_author.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_invalid_author.snap @@ -1,8 +1,8 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -pyproject.toml:5:11: RUF200 Failed to parse pyproject.toml: a table with 'name' and/or 'email' keys +RUF200 Failed to parse pyproject.toml: a table with 'name' and/or 'email' keys + --> pyproject.toml:5:11 | 3 | version = "0.1.0" 4 | # Ensure that the spans from toml handle utf-8 correctly @@ -10,5 +10,5 @@ pyproject.toml:5:11: RUF200 Failed to parse pyproject.toml: a table with 'name' | ___________^ 6 | | { name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 } 7 | | ] - | |_^ RUF200 + | |_^ | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_various_invalid.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_various_invalid.snap index aa79926ea2..def6996c48 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_various_invalid.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_various_invalid.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -pyproject.toml:10:16: RUF200 Failed to parse pyproject.toml: URL requirement must be preceded by a package name. Add the name of the package before the URL (e.g., `package_name @ /path/to/file`). +RUF200 Failed to parse pyproject.toml: URL requirement must be preceded by a package name. Add the name of the package before the URL (e.g., `package_name @ /path/to/file`). ... ^^^ + --> pyproject.toml:10:16 | 8 | requires-python = ">=3.8" 9 | requires-dist = [ "maturin>=0.14", "...",] 10 | dependencies = [ "packaging", "...",] - | ^^^^^^^^^^^^^^^^^^^^^^ RUF200 + | ^^^^^^^^^^^^^^^^^^^^^^ 11 | zip-safe = false 12 | version = "..." | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py310.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py310.snap index 06274f1af2..fd922887f1 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py310.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py310.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF063.py:4:1: RUF063 Use `inspect.get_annotations` instead of `__dict__` access +RUF063 Use `inspect.get_annotations` instead of `__dict__` access + --> RUF063.py:4:1 | 2 | # Cases that should trigger the violation 3 | 4 | foo.__dict__.get("__annotations__") # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 | -RUF063.py:5:1: RUF063 Use `inspect.get_annotations` instead of `__dict__` access +RUF063 Use `inspect.get_annotations` instead of `__dict__` access + --> RUF063.py:5:1 | 4 | foo.__dict__.get("__annotations__") # RUF063 5 | foo.__dict__.get("__annotations__", None) # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | foo.__dict__.get("__annotations__", {}) # RUF063 7 | foo.__dict__["__annotations__"] # RUF063 | -RUF063.py:6:1: RUF063 Use `inspect.get_annotations` instead of `__dict__` access +RUF063 Use `inspect.get_annotations` instead of `__dict__` access + --> RUF063.py:6:1 | 4 | foo.__dict__.get("__annotations__") # RUF063 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | foo.__dict__["__annotations__"] # RUF063 | -RUF063.py:7:1: RUF063 Use `inspect.get_annotations` instead of `__dict__` access +RUF063 Use `inspect.get_annotations` instead of `__dict__` access + --> RUF063.py:7:1 | 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 7 | foo.__dict__["__annotations__"] # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # Cases that should NOT trigger the violation | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py314.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py314.snap index 0f07c9a8e9..273949864b 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py314.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py314.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF063.py:4:1: RUF063 Use `annotationlib.get_annotations` instead of `__dict__` access +RUF063 Use `annotationlib.get_annotations` instead of `__dict__` access + --> RUF063.py:4:1 | 2 | # Cases that should trigger the violation 3 | 4 | foo.__dict__.get("__annotations__") # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 | -RUF063.py:5:1: RUF063 Use `annotationlib.get_annotations` instead of `__dict__` access +RUF063 Use `annotationlib.get_annotations` instead of `__dict__` access + --> RUF063.py:5:1 | 4 | foo.__dict__.get("__annotations__") # RUF063 5 | foo.__dict__.get("__annotations__", None) # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | foo.__dict__.get("__annotations__", {}) # RUF063 7 | foo.__dict__["__annotations__"] # RUF063 | -RUF063.py:6:1: RUF063 Use `annotationlib.get_annotations` instead of `__dict__` access +RUF063 Use `annotationlib.get_annotations` instead of `__dict__` access + --> RUF063.py:6:1 | 4 | foo.__dict__.get("__annotations__") # RUF063 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | foo.__dict__["__annotations__"] # RUF063 | -RUF063.py:7:1: RUF063 Use `annotationlib.get_annotations` instead of `__dict__` access +RUF063 Use `annotationlib.get_annotations` instead of `__dict__` access + --> RUF063.py:7:1 | 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 7 | foo.__dict__["__annotations__"] # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # Cases that should NOT trigger the violation | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py39_with_typing_extensions.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py39_with_typing_extensions.snap index c5ef0419ba..2adbc3b46d 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py39_with_typing_extensions.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__access_annotations_from_class_dict_py39_with_typing_extensions.snap @@ -1,40 +1,44 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF063.py:4:1: RUF063 Use `typing_extensions.get_annotations` instead of `__dict__` access +RUF063 Use `typing_extensions.get_annotations` instead of `__dict__` access + --> RUF063.py:4:1 | 2 | # Cases that should trigger the violation 3 | 4 | foo.__dict__.get("__annotations__") # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 | -RUF063.py:5:1: RUF063 Use `typing_extensions.get_annotations` instead of `__dict__` access +RUF063 Use `typing_extensions.get_annotations` instead of `__dict__` access + --> RUF063.py:5:1 | 4 | foo.__dict__.get("__annotations__") # RUF063 5 | foo.__dict__.get("__annotations__", None) # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | foo.__dict__.get("__annotations__", {}) # RUF063 7 | foo.__dict__["__annotations__"] # RUF063 | -RUF063.py:6:1: RUF063 Use `typing_extensions.get_annotations` instead of `__dict__` access +RUF063 Use `typing_extensions.get_annotations` instead of `__dict__` access + --> RUF063.py:6:1 | 4 | foo.__dict__.get("__annotations__") # RUF063 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | foo.__dict__["__annotations__"] # RUF063 | -RUF063.py:7:1: RUF063 Use `typing_extensions.get_annotations` instead of `__dict__` access +RUF063 Use `typing_extensions.get_annotations` instead of `__dict__` access + --> RUF063.py:7:1 | 5 | foo.__dict__.get("__annotations__", None) # RUF063 6 | foo.__dict__.get("__annotations__", {}) # RUF063 7 | foo.__dict__["__annotations__"] # RUF063 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF063 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 8 | 9 | # Cases that should NOT trigger the violation | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_0.py.snap index ac893508e1..08859675d6 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_0.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF013_0.py:20:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:20:12 | 20 | def f(arg: int = None): # RUF013 - | ^^^ RUF013 + | ^^^ 21 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -24,13 +25,14 @@ RUF013_0.py:20:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 22 23 | 23 24 | -RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:24:12 | 24 | def f(arg: str = None): # RUF013 - | ^^^ RUF013 + | ^^^ 25 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -47,13 +49,14 @@ RUF013_0.py:24:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 26 27 | 27 28 | -RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:28:12 | 28 | def f(arg: Tuple[str] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 29 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -70,13 +73,14 @@ RUF013_0.py:28:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 30 31 | 31 32 | -RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:58:12 | 58 | def f(arg: Union = None): # RUF013 - | ^^^^^ RUF013 + | ^^^^^ 59 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -93,13 +97,14 @@ RUF013_0.py:58:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 60 61 | 61 62 | -RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:62:12 | 62 | def f(arg: Union[int] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 63 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -116,13 +121,14 @@ RUF013_0.py:62:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 64 65 | 65 66 | -RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:66:12 | 66 | def f(arg: Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^ 67 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -139,13 +145,14 @@ RUF013_0.py:66:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 68 69 | 69 70 | -RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:85:12 | 85 | def f(arg: int | float = None): # RUF013 - | ^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^ 86 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -162,13 +169,14 @@ RUF013_0.py:85:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 87 88 | 88 89 | -RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:89:12 | 89 | def f(arg: int | float | str | bytes = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 90 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -185,13 +193,14 @@ RUF013_0.py:89:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 91 92 | 92 93 | -RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:108:12 | 108 | def f(arg: Literal[1] = None): # RUF013 - | ^^^^^^^^^^ RUF013 + | ^^^^^^^^^^ 109 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -208,13 +217,14 @@ RUF013_0.py:108:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 110 111 | 111 112 | -RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:112:12 | 112 | def f(arg: Literal[1, "foo"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^ 113 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -231,13 +241,14 @@ RUF013_0.py:112:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 114 115 | 115 116 | -RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:131:22 | 131 | def f(arg: Annotated[int, ...] = None): # RUF013 - | ^^^ RUF013 + | ^^^ 132 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -254,13 +265,14 @@ RUF013_0.py:131:22: RUF013 [*] PEP 484 prohibits implicit `Optional` 133 134 | 134 135 | -RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:135:32 | 135 | def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - | ^^^^^^^^^ RUF013 + | ^^^^^^^^^ 136 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -277,15 +289,16 @@ RUF013_0.py:135:32: RUF013 [*] PEP 484 prohibits implicit `Optional` 137 138 | 138 139 | -RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:151:11 | 150 | def f( 151 | arg1: int = None, # RUF013 - | ^^^ RUF013 + | ^^^ 152 | arg2: Union[int, float] = None, # RUF013 153 | arg3: Literal[1, 2, 3] = None, # RUF013 | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -302,16 +315,17 @@ RUF013_0.py:151:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 153 154 | arg3: Literal[1, 2, 3] = None, # RUF013 154 155 | ): -RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:152:11 | 150 | def f( 151 | arg1: int = None, # RUF013 152 | arg2: Union[int, float] = None, # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^ 153 | arg3: Literal[1, 2, 3] = None, # RUF013 154 | ): | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -328,16 +342,17 @@ RUF013_0.py:152:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 154 155 | ): 155 156 | pass -RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:153:11 | 151 | arg1: int = None, # RUF013 152 | arg2: Union[int, float] = None, # RUF013 153 | arg3: Literal[1, 2, 3] = None, # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^ 154 | ): 155 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -354,13 +369,14 @@ RUF013_0.py:153:11: RUF013 [*] PEP 484 prohibits implicit `Optional` 155 156 | pass 156 157 | -RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:181:12 | 181 | def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 182 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -377,13 +393,14 @@ RUF013_0.py:181:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 183 184 | 184 185 | -RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:188:13 | 188 | def f(arg: "int" = None): # RUF013 - | ^^^ RUF013 + | ^^^ 189 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 185 185 | # Quoted @@ -395,13 +412,14 @@ RUF013_0.py:188:13: RUF013 [*] PEP 484 prohibits implicit `Optional` 190 190 | 191 191 | -RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:192:13 | 192 | def f(arg: "str" = None): # RUF013 - | ^^^ RUF013 + | ^^^ 193 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` ℹ Unsafe fix 189 189 | pass @@ -413,21 +431,23 @@ RUF013_0.py:192:13: RUF013 [*] PEP 484 prohibits implicit `Optional` 194 194 | 195 195 | -RUF013_0.py:196:12: RUF013 PEP 484 prohibits implicit `Optional` +RUF013 PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:196:12 | 196 | def f(arg: "st" "r" = None): # RUF013 - | ^^^^^^^^ RUF013 + | ^^^^^^^^ 197 | pass | - = help: Convert to `Optional[T]` +help: Convert to `Optional[T]` -RUF013_0.py:204:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_0.py:204:12 | 204 | def f(arg: Union["int", "str"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^ 205 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_1.py.snap index f770d07c98..753c4d86f3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_1.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_1.py:4:12 | 4 | def f(arg: int = None): # RUF013 - | ^^^ RUF013 + | ^^^ 5 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 1 | # No `typing.Optional` import diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_3.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_3.py.snap index 4ec9031ff1..f02a76cb38 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_3.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_3.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF013_3.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_3.py:4:12 | 4 | def f(arg: typing.List[str] = None): # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^ 5 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -20,13 +21,14 @@ RUF013_3.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 6 7 | 7 8 | -RUF013_3.py:22:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_3.py:22:12 | 22 | def f(arg: typing.Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^ 23 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations @@ -43,13 +45,14 @@ RUF013_3.py:22:12: RUF013 [*] PEP 484 prohibits implicit `Optional` 24 25 | 25 26 | -RUF013_3.py:29:12: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_3.py:29:12 | 29 | def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | pass | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 |+from __future__ import annotations diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_4.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_4.py.snap index 6aee14956d..f9bcd454d3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_4.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__add_future_import_RUF013_4.py.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF013_4.py:15:61: RUF013 [*] PEP 484 prohibits implicit `Optional` +RUF013 [*] PEP 484 prohibits implicit `Optional` + --> RUF013_4.py:15:61 | 15 | def multiple_2(arg1: Optional, arg2: Optional = None, arg3: int = None): ... - | ^^^ RUF013 + | ^^^ | - = help: Convert to `T | None` +help: Convert to `T | None` ℹ Unsafe fix 1 1 | # https://github.com/astral-sh/ruff/issues/13833 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap index f39d03cef4..4e9ab5604c 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap @@ -1,181 +1,201 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -confusables.py:1:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:1:6 | 1 | x = "𝐁ad string" - | ^ RUF001 + | ^ 2 | y = "−" | -confusables.py:6:56: RUF002 Docstring contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? +RUF002 Docstring contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? + --> confusables.py:6:56 | 5 | def f(): 6 | """Here's a docstring with an unusual parenthesis: )""" - | ^^ RUF002 + | ^^ 7 | # And here's a comment with an unusual punctuation mark: ᜵ 8 | ... | -confusables.py:7:62: RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? +RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? + --> confusables.py:7:62 | 5 | def f(): 6 | """Here's a docstring with an unusual parenthesis: )""" 7 | # And here's a comment with an unusual punctuation mark: ᜵ - | ^ RUF003 + | ^ 8 | ... | -confusables.py:17:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:17:6 | 17 | x = "𝐁ad string" - | ^ RUF001 + | ^ 18 | x = "−" | -confusables.py:26:10: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? +RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? + --> confusables.py:26:10 | 24 | # The first word should be ignored, while the second should be included, since it 25 | # contains ASCII. 26 | x = "βα Bαd" - | ^ RUF001 + | ^ 27 | 28 | # The two characters should be flagged here. The first character is a "word" | -confusables.py:31:6: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? +RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? + --> confusables.py:31:6 | 29 | # consisting of a single ambiguous character, while the second character is a "word 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" - | ^ RUF001 + | ^ 32 | 33 | # Same test cases as above but using f-strings instead: | -confusables.py:31:7: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + --> confusables.py:31:7 | 29 | # consisting of a single ambiguous character, while the second character is a "word 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" - | ^ RUF001 + | ^ 32 | 33 | # Same test cases as above but using f-strings instead: | -confusables.py:34:7: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:34:7 | 33 | # Same test cases as above but using f-strings instead: 34 | x = f"𝐁ad string" - | ^ RUF001 + | ^ 35 | x = f"−" 36 | x = f"Русский" | -confusables.py:37:11: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? +RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? + --> confusables.py:37:11 | 35 | x = f"−" 36 | x = f"Русский" 37 | x = f"βα Bαd" - | ^ RUF001 + | ^ 38 | x = f"Р усский" | -confusables.py:38:7: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? +RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? + --> confusables.py:38:7 | 36 | x = f"Русский" 37 | x = f"βα Bαd" 38 | x = f"Р усский" - | ^ RUF001 + | ^ 39 | 40 | # Nested f-strings | -confusables.py:38:8: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + --> confusables.py:38:8 | 36 | x = f"Русский" 37 | x = f"βα Bαd" 38 | x = f"Р усский" - | ^ RUF001 + | ^ 39 | 40 | # Nested f-strings | -confusables.py:41:7: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:41:7 | 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" - | ^ RUF001 + | ^ 42 | 43 | # Comments inside f-strings | -confusables.py:41:21: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + --> confusables.py:41:21 | 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" - | ^ RUF001 + | ^ 42 | 43 | # Comments inside f-strings | -confusables.py:41:25: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? +RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? + --> confusables.py:41:25 | 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" - | ^ RUF001 + | ^ 42 | 43 | # Comments inside f-strings | -confusables.py:41:26: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + --> confusables.py:41:26 | 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" - | ^ RUF001 + | ^ 42 | 43 | # Comments inside f-strings | -confusables.py:44:68: RUF003 Comment contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? +RUF003 Comment contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? + --> confusables.py:44:68 | 43 | # Comments inside f-strings 44 | x = f"string { # And here's a comment with an unusual parenthesis: ) - | ^^ RUF003 + | ^^ 45 | # And here's a comment with a greek alpha: ∗ 46 | foo # And here's a comment with an unusual punctuation mark: ᜵ | -confusables.py:46:62: RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? +RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? + --> confusables.py:46:62 | 44 | x = f"string { # And here's a comment with an unusual parenthesis: ) 45 | # And here's a comment with a greek alpha: ∗ 46 | foo # And here's a comment with an unusual punctuation mark: ᜵ - | ^ RUF003 + | ^ 47 | }" | -confusables.py:58:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:58:6 | 57 | # Implicit string concatenation 58 | x = "𝐁ad" f"𝐁ad string" - | ^ RUF001 + | ^ 59 | 60 | from typing import Literal | -confusables.py:58:13: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:58:13 | 57 | # Implicit string concatenation 58 | x = "𝐁ad" f"𝐁ad string" - | ^ RUF001 + | ^ 59 | 60 | from typing import Literal | -confusables.py:61:20: RUF001 String contains ambiguous `ﮨ` (ARABIC LETTER HEH GOAL INITIAL FORM). Did you mean `o` (LATIN SMALL LETTER O)? +RUF001 String contains ambiguous `ﮨ` (ARABIC LETTER HEH GOAL INITIAL FORM). Did you mean `o` (LATIN SMALL LETTER O)? + --> confusables.py:61:20 | 60 | from typing import Literal 61 | x: '''"""'Literal["ﮨ"]'"""''' - | ^ RUF001 + | ^ | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_1.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_1.snap index d9d8b1e402..9c7eaadd88 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_1.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_1.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF052.py:92:9: RUF052 [*] Local dummy variable `_var` is accessed +RUF052 [*] Local dummy variable `_var` is accessed + --> RUF052.py:92:9 | 90 | class Class_: 91 | def fun(self): 92 | _var = "method variable" # [RUF052] - | ^^^^ RUF052 + | ^^^^ 93 | return _var | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 89 89 | @@ -23,14 +24,15 @@ RUF052.py:92:9: RUF052 [*] Local dummy variable `_var` is accessed 95 95 | def fun(_var): # parameters are ignored 96 96 | return _var -RUF052.py:99:5: RUF052 [*] Local dummy variable `_list` is accessed +RUF052 [*] Local dummy variable `_list` is accessed + --> RUF052.py:99:5 | 98 | def fun(): 99 | _list = "built-in" # [RUF052] - | ^^^^^ RUF052 + | ^^^^^ 100 | return _list | - = help: Prefer using trailing underscores to avoid shadowing a built-in +help: Prefer using trailing underscores to avoid shadowing a built-in ℹ Unsafe fix 96 96 | return _var @@ -44,15 +46,16 @@ RUF052.py:99:5: RUF052 [*] Local dummy variable `_list` is accessed 102 102 | x = "global" 103 103 | -RUF052.py:106:5: RUF052 [*] Local dummy variable `_x` is accessed +RUF052 [*] Local dummy variable `_x` is accessed + --> RUF052.py:106:5 | 104 | def fun(): 105 | global x 106 | _x = "shadows global" # [RUF052] - | ^^ RUF052 + | ^^ 107 | return _x | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable ℹ Unsafe fix 103 103 | @@ -66,16 +69,17 @@ RUF052.py:106:5: RUF052 [*] Local dummy variable `_x` is accessed 109 109 | def foo(): 110 110 | x = "outer" -RUF052.py:113:5: RUF052 [*] Local dummy variable `_x` is accessed +RUF052 [*] Local dummy variable `_x` is accessed + --> RUF052.py:113:5 | 111 | def bar(): 112 | nonlocal x 113 | _x = "shadows nonlocal" # [RUF052] - | ^^ RUF052 + | ^^ 114 | return _x 115 | bar() | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable ℹ Unsafe fix 110 110 | x = "outer" @@ -89,15 +93,16 @@ RUF052.py:113:5: RUF052 [*] Local dummy variable `_x` is accessed 116 116 | return x 117 117 | -RUF052.py:120:5: RUF052 [*] Local dummy variable `_x` is accessed +RUF052 [*] Local dummy variable `_x` is accessed + --> RUF052.py:120:5 | 118 | def fun(): 119 | x = "local" 120 | _x = "shadows local" # [RUF052] - | ^^ RUF052 + | ^^ 121 | return _x | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable ℹ Unsafe fix 117 117 | @@ -111,54 +116,59 @@ RUF052.py:120:5: RUF052 [*] Local dummy variable `_x` is accessed 123 123 | 124 124 | GLOBAL_1 = "global 1" -RUF052.py:128:5: RUF052 Local dummy variable `_GLOBAL_1` is accessed +RUF052 Local dummy variable `_GLOBAL_1` is accessed + --> RUF052.py:128:5 | 127 | def unfixables(): 128 | _GLOBAL_1 = "foo" - | ^^^^^^^^^ RUF052 + | ^^^^^^^^^ 129 | # unfixable because the rename would shadow a global variable 130 | print(_GLOBAL_1) # [RUF052] | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:136:5: RUF052 Local dummy variable `_local` is accessed +RUF052 Local dummy variable `_local` is accessed + --> RUF052.py:136:5 | 135 | # unfixable because the rename would shadow a local variable 136 | _local = "local3" # [RUF052] - | ^^^^^^ RUF052 + | ^^^^^^ 137 | print(_local) | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:140:9: RUF052 Local dummy variable `_GLOBAL_1` is accessed +RUF052 Local dummy variable `_GLOBAL_1` is accessed + --> RUF052.py:140:9 | 139 | def nested(): 140 | _GLOBAL_1 = "foo" - | ^^^^^^^^^ RUF052 + | ^^^^^^^^^ 141 | # unfixable because the rename would shadow a global variable 142 | print(_GLOBAL_1) # [RUF052] | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:145:9: RUF052 Local dummy variable `_local` is accessed +RUF052 Local dummy variable `_local` is accessed + --> RUF052.py:145:9 | 144 | # unfixable because the rename would shadow a variable from the outer function 145 | _local = "local4" - | ^^^^^^ RUF052 + | ^^^^^^ 146 | print(_local) | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:153:5: RUF052 [*] Local dummy variable `_P` is accessed +RUF052 [*] Local dummy variable `_P` is accessed + --> RUF052.py:153:5 | 151 | from collections import namedtuple 152 | 153 | _P = ParamSpec("_P") - | ^^ RUF052 + | ^^ 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 150 150 | from enum import Enum @@ -179,15 +189,16 @@ RUF052.py:153:5: RUF052 [*] Local dummy variable `_P` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:154:5: RUF052 [*] Local dummy variable `_T` is accessed +RUF052 [*] Local dummy variable `_T` is accessed + --> RUF052.py:154:5 | 153 | _P = ParamSpec("_P") 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) - | ^^ RUF052 + | ^^ 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 151 151 | from collections import namedtuple @@ -208,16 +219,17 @@ RUF052.py:154:5: RUF052 [*] Local dummy variable `_T` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:155:5: RUF052 [*] Local dummy variable `_NT` is accessed +RUF052 [*] Local dummy variable `_NT` is accessed + --> RUF052.py:155:5 | 153 | _P = ParamSpec("_P") 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) - | ^^^ RUF052 + | ^^^ 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 152 152 | @@ -237,16 +249,17 @@ RUF052.py:155:5: RUF052 [*] Local dummy variable `_NT` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:156:5: RUF052 [*] Local dummy variable `_E` is accessed +RUF052 [*] Local dummy variable `_E` is accessed + --> RUF052.py:156:5 | 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) - | ^^ RUF052 + | ^^ 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 153 153 | _P = ParamSpec("_P") @@ -265,16 +278,17 @@ RUF052.py:156:5: RUF052 [*] Local dummy variable `_E` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:157:5: RUF052 [*] Local dummy variable `_NT2` is accessed +RUF052 [*] Local dummy variable `_NT2` is accessed + --> RUF052.py:157:5 | 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) - | ^^^^ RUF052 + | ^^^^ 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 154 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) @@ -292,16 +306,17 @@ RUF052.py:157:5: RUF052 [*] Local dummy variable `_NT2` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:158:5: RUF052 [*] Local dummy variable `_NT3` is accessed +RUF052 [*] Local dummy variable `_NT3` is accessed + --> RUF052.py:158:5 | 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) - | ^^^^ RUF052 + | ^^^^ 159 | _DynamicClass = type("_DynamicClass", (), {}) 160 | _NotADynamicClass = type("_NotADynamicClass") | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 155 155 | _NT = NamedTuple("_NT", [("foo", int)]) @@ -318,15 +333,16 @@ RUF052.py:158:5: RUF052 [*] Local dummy variable `_NT3` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:159:5: RUF052 [*] Local dummy variable `_DynamicClass` is accessed +RUF052 [*] Local dummy variable `_DynamicClass` is accessed + --> RUF052.py:159:5 | 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) - | ^^^^^^^^^^^^^ RUF052 + | ^^^^^^^^^^^^^ 160 | _NotADynamicClass = type("_NotADynamicClass") | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 156 156 | _E = Enum("_E", ["a", "b", "c"]) @@ -342,16 +358,17 @@ RUF052.py:159:5: RUF052 [*] Local dummy variable `_DynamicClass` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:160:5: RUF052 [*] Local dummy variable `_NotADynamicClass` is accessed +RUF052 [*] Local dummy variable `_NotADynamicClass` is accessed + --> RUF052.py:160:5 | 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) 160 | _NotADynamicClass = type("_NotADynamicClass") - | ^^^^^^^^^^^^^^^^^ RUF052 + | ^^^^^^^^^^^^^^^^^ 161 | 162 | print(_T, _P, _NT, _E, _NT2, _NT3, _DynamicClass, _NotADynamicClass) | - = help: Remove leading underscores +help: Remove leading underscores ℹ Unsafe fix 157 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) @@ -366,15 +383,16 @@ RUF052.py:160:5: RUF052 [*] Local dummy variable `_NotADynamicClass` is accessed 164 164 | # Do not emit diagnostic if parameter is private 165 165 | # even if it is later shadowed in the body of the function -RUF052.py:182:5: RUF052 [*] Local dummy variable `_dummy_var` is accessed +RUF052 [*] Local dummy variable `_dummy_var` is accessed + --> RUF052.py:182:5 | 181 | def foo(): 182 | _dummy_var = 42 - | ^^^^^^^^^^ RUF052 + | ^^^^^^^^^^ 183 | 184 | def bar(): | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable ℹ Unsafe fix 179 179 | @@ -391,13 +409,14 @@ RUF052.py:182:5: RUF052 [*] Local dummy variable `_dummy_var` is accessed 188 188 | 189 189 | def foo(): -RUF052.py:192:5: RUF052 Local dummy variable `_dummy_var` is accessed +RUF052 Local dummy variable `_dummy_var` is accessed + --> RUF052.py:192:5 | 190 | # Unfixable because both possible candidates for the new name are shadowed 191 | # in the scope of one of the references to the variable 192 | _dummy_var = 42 - | ^^^^^^^^^^ RUF052 + | ^^^^^^^^^^ 193 | 194 | def bar(): | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_2.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_2.snap index ae071a393d..4fe093b951 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_2.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__custom_dummy_var_regexp_preset__RUF052_RUF052.py_2.snap @@ -1,206 +1,226 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF052.py:92:9: RUF052 Local dummy variable `_var` is accessed +RUF052 Local dummy variable `_var` is accessed + --> RUF052.py:92:9 | 90 | class Class_: 91 | def fun(self): 92 | _var = "method variable" # [RUF052] - | ^^^^ RUF052 + | ^^^^ 93 | return _var | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:99:5: RUF052 Local dummy variable `_list` is accessed +RUF052 Local dummy variable `_list` is accessed + --> RUF052.py:99:5 | 98 | def fun(): 99 | _list = "built-in" # [RUF052] - | ^^^^^ RUF052 + | ^^^^^ 100 | return _list | - = help: Prefer using trailing underscores to avoid shadowing a built-in +help: Prefer using trailing underscores to avoid shadowing a built-in -RUF052.py:106:5: RUF052 Local dummy variable `_x` is accessed +RUF052 Local dummy variable `_x` is accessed + --> RUF052.py:106:5 | 104 | def fun(): 105 | global x 106 | _x = "shadows global" # [RUF052] - | ^^ RUF052 + | ^^ 107 | return _x | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:110:3: RUF052 Local dummy variable `x` is accessed +RUF052 Local dummy variable `x` is accessed + --> RUF052.py:110:3 | 109 | def foo(): 110 | x = "outer" - | ^ RUF052 + | ^ 111 | def bar(): 112 | nonlocal x | -RUF052.py:113:5: RUF052 Local dummy variable `_x` is accessed +RUF052 Local dummy variable `_x` is accessed + --> RUF052.py:113:5 | 111 | def bar(): 112 | nonlocal x 113 | _x = "shadows nonlocal" # [RUF052] - | ^^ RUF052 + | ^^ 114 | return _x 115 | bar() | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:120:5: RUF052 Local dummy variable `_x` is accessed +RUF052 Local dummy variable `_x` is accessed + --> RUF052.py:120:5 | 118 | def fun(): 119 | x = "local" 120 | _x = "shadows local" # [RUF052] - | ^^ RUF052 + | ^^ 121 | return _x | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:128:5: RUF052 Local dummy variable `_GLOBAL_1` is accessed +RUF052 Local dummy variable `_GLOBAL_1` is accessed + --> RUF052.py:128:5 | 127 | def unfixables(): 128 | _GLOBAL_1 = "foo" - | ^^^^^^^^^ RUF052 + | ^^^^^^^^^ 129 | # unfixable because the rename would shadow a global variable 130 | print(_GLOBAL_1) # [RUF052] | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:136:5: RUF052 Local dummy variable `_local` is accessed +RUF052 Local dummy variable `_local` is accessed + --> RUF052.py:136:5 | 135 | # unfixable because the rename would shadow a local variable 136 | _local = "local3" # [RUF052] - | ^^^^^^ RUF052 + | ^^^^^^ 137 | print(_local) | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:140:9: RUF052 Local dummy variable `_GLOBAL_1` is accessed +RUF052 Local dummy variable `_GLOBAL_1` is accessed + --> RUF052.py:140:9 | 139 | def nested(): 140 | _GLOBAL_1 = "foo" - | ^^^^^^^^^ RUF052 + | ^^^^^^^^^ 141 | # unfixable because the rename would shadow a global variable 142 | print(_GLOBAL_1) # [RUF052] | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:145:9: RUF052 Local dummy variable `_local` is accessed +RUF052 Local dummy variable `_local` is accessed + --> RUF052.py:145:9 | 144 | # unfixable because the rename would shadow a variable from the outer function 145 | _local = "local4" - | ^^^^^^ RUF052 + | ^^^^^^ 146 | print(_local) | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:153:5: RUF052 Local dummy variable `_P` is accessed +RUF052 Local dummy variable `_P` is accessed + --> RUF052.py:153:5 | 151 | from collections import namedtuple 152 | 153 | _P = ParamSpec("_P") - | ^^ RUF052 + | ^^ 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:154:5: RUF052 Local dummy variable `_T` is accessed +RUF052 Local dummy variable `_T` is accessed + --> RUF052.py:154:5 | 153 | _P = ParamSpec("_P") 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) - | ^^ RUF052 + | ^^ 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:155:5: RUF052 Local dummy variable `_NT` is accessed +RUF052 Local dummy variable `_NT` is accessed + --> RUF052.py:155:5 | 153 | _P = ParamSpec("_P") 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) - | ^^^ RUF052 + | ^^^ 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:156:5: RUF052 Local dummy variable `_E` is accessed +RUF052 Local dummy variable `_E` is accessed + --> RUF052.py:156:5 | 154 | _T = TypeVar(name="_T", covariant=True, bound=int|str) 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) - | ^^ RUF052 + | ^^ 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:157:5: RUF052 Local dummy variable `_NT2` is accessed +RUF052 Local dummy variable `_NT2` is accessed + --> RUF052.py:157:5 | 155 | _NT = NamedTuple("_NT", [("foo", int)]) 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) - | ^^^^ RUF052 + | ^^^^ 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:158:5: RUF052 Local dummy variable `_NT3` is accessed +RUF052 Local dummy variable `_NT3` is accessed + --> RUF052.py:158:5 | 156 | _E = Enum("_E", ["a", "b", "c"]) 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) - | ^^^^ RUF052 + | ^^^^ 159 | _DynamicClass = type("_DynamicClass", (), {}) 160 | _NotADynamicClass = type("_NotADynamicClass") | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:159:5: RUF052 Local dummy variable `_DynamicClass` is accessed +RUF052 Local dummy variable `_DynamicClass` is accessed + --> RUF052.py:159:5 | 157 | _NT2 = namedtuple("_NT2", ['x', 'y', 'z']) 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) - | ^^^^^^^^^^^^^ RUF052 + | ^^^^^^^^^^^^^ 160 | _NotADynamicClass = type("_NotADynamicClass") | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:160:5: RUF052 Local dummy variable `_NotADynamicClass` is accessed +RUF052 Local dummy variable `_NotADynamicClass` is accessed + --> RUF052.py:160:5 | 158 | _NT3 = namedtuple(typename="_NT3", field_names=['x', 'y', 'z']) 159 | _DynamicClass = type("_DynamicClass", (), {}) 160 | _NotADynamicClass = type("_NotADynamicClass") - | ^^^^^^^^^^^^^^^^^ RUF052 + | ^^^^^^^^^^^^^^^^^ 161 | 162 | print(_T, _P, _NT, _E, _NT2, _NT3, _DynamicClass, _NotADynamicClass) | - = help: Remove leading underscores +help: Remove leading underscores -RUF052.py:182:5: RUF052 Local dummy variable `_dummy_var` is accessed +RUF052 Local dummy variable `_dummy_var` is accessed + --> RUF052.py:182:5 | 181 | def foo(): 182 | _dummy_var = 42 - | ^^^^^^^^^^ RUF052 + | ^^^^^^^^^^ 183 | 184 | def bar(): | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable -RUF052.py:192:5: RUF052 Local dummy variable `_dummy_var` is accessed +RUF052 Local dummy variable `_dummy_var` is accessed + --> RUF052.py:192:5 | 190 | # Unfixable because both possible candidates for the new name are shadowed 191 | # in the scope of one of the references to the variable 192 | _dummy_var = 42 - | ^^^^^^^^^^ RUF052 + | ^^^^^^^^^^ 193 | 194 | def bar(): | - = help: Prefer using trailing underscores to avoid shadowing a variable +help: Prefer using trailing underscores to avoid shadowing a variable diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__invalid_rule_code_external_rules.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__invalid_rule_code_external_rules.snap index 2c2e4e88db..81f24cd251 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__invalid_rule_code_external_rules.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__invalid_rule_code_external_rules.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF102.py:2:12: RUF102 [*] Invalid rule code in `# noqa`: INVALID123 +RUF102 [*] Invalid rule code in `# noqa`: INVALID123 + --> RUF102.py:2:12 | 1 | # Invalid code 2 | import os # noqa: INVALID123 - | ^^^^^^^^^^^^^^^^^^ RUF102 + | ^^^^^^^^^^^^^^^^^^ 3 | # External code 4 | import re # noqa: V123 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 1 1 | # Invalid code @@ -19,16 +20,17 @@ RUF102.py:2:12: RUF102 [*] Invalid rule code in `# noqa`: INVALID123 4 4 | import re # noqa: V123 5 5 | # Valid noqa -RUF102.py:7:65: RUF102 [*] Invalid rule code in `# noqa`: INVALID456 +RUF102 [*] Invalid rule code in `# noqa`: INVALID456 + --> RUF102.py:7:65 | 5 | # Valid noqa 6 | import sys # noqa: E402 7 | from functools import cache # Preceeding comment # noqa: F401, INVALID456 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 8 | from itertools import product # Preceeding comment # noqa: INVALID789 9 | # Succeeding comment | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 4 4 | import re # noqa: V123 @@ -40,16 +42,17 @@ RUF102.py:7:65: RUF102 [*] Invalid rule code in `# noqa`: INVALID456 9 9 | # Succeeding comment 10 10 | import math # noqa: INVALID000 # Succeeding comment -RUF102.py:8:53: RUF102 [*] Invalid rule code in `# noqa`: INVALID789 +RUF102 [*] Invalid rule code in `# noqa`: INVALID789 + --> RUF102.py:8:53 | 6 | import sys # noqa: E402 7 | from functools import cache # Preceeding comment # noqa: F401, INVALID456 8 | from itertools import product # Preceeding comment # noqa: INVALID789 - | ^^^^^^^^^^^^^^^^^^ RUF102 + | ^^^^^^^^^^^^^^^^^^ 9 | # Succeeding comment 10 | import math # noqa: INVALID000 # Succeeding comment | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 5 5 | # Valid noqa @@ -61,16 +64,17 @@ RUF102.py:8:53: RUF102 [*] Invalid rule code in `# noqa`: INVALID789 10 10 | import math # noqa: INVALID000 # Succeeding comment 11 11 | # Mixed valid and invalid -RUF102.py:10:13: RUF102 [*] Invalid rule code in `# noqa`: INVALID000 +RUF102 [*] Invalid rule code in `# noqa`: INVALID000 + --> RUF102.py:10:13 | 8 | from itertools import product # Preceeding comment # noqa: INVALID789 9 | # Succeeding comment 10 | import math # noqa: INVALID000 # Succeeding comment - | ^^^^^^^^^^^^^^^^^^ RUF102 + | ^^^^^^^^^^^^^^^^^^ 11 | # Mixed valid and invalid 12 | from typing import List # noqa: F401, INVALID123 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 7 7 | from functools import cache # Preceeding comment # noqa: F401, INVALID456 @@ -82,16 +86,17 @@ RUF102.py:10:13: RUF102 [*] Invalid rule code in `# noqa`: INVALID000 12 12 | from typing import List # noqa: F401, INVALID123 13 13 | # Test for multiple invalid -RUF102.py:12:40: RUF102 [*] Invalid rule code in `# noqa`: INVALID123 +RUF102 [*] Invalid rule code in `# noqa`: INVALID123 + --> RUF102.py:12:40 | 10 | import math # noqa: INVALID000 # Succeeding comment 11 | # Mixed valid and invalid 12 | from typing import List # noqa: F401, INVALID123 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 13 | # Test for multiple invalid 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 9 9 | # Succeeding comment @@ -103,16 +108,17 @@ RUF102.py:12:40: RUF102 [*] Invalid rule code in `# noqa`: INVALID123 14 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 15 15 | # Test for preserving valid codes when fixing -RUF102.py:14:46: RUF102 [*] Invalid rule code in `# noqa`: INVALID100 +RUF102 [*] Invalid rule code in `# noqa`: INVALID100 + --> RUF102.py:14:46 | 12 | from typing import List # noqa: F401, INVALID123 13 | # Test for multiple invalid 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 15 | # Test for preserving valid codes when fixing 16 | from itertools import chain # noqa: E402, INVALID300, F401 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 11 11 | # Mixed valid and invalid @@ -124,16 +130,17 @@ RUF102.py:14:46: RUF102 [*] Invalid rule code in `# noqa`: INVALID100 16 16 | from itertools import chain # noqa: E402, INVALID300, F401 17 17 | # Test for mixed code types -RUF102.py:14:58: RUF102 [*] Invalid rule code in `# noqa`: INVALID200 +RUF102 [*] Invalid rule code in `# noqa`: INVALID200 + --> RUF102.py:14:58 | 12 | from typing import List # noqa: F401, INVALID123 13 | # Test for multiple invalid 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 15 | # Test for preserving valid codes when fixing 16 | from itertools import chain # noqa: E402, INVALID300, F401 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 11 11 | # Mixed valid and invalid @@ -145,16 +152,17 @@ RUF102.py:14:58: RUF102 [*] Invalid rule code in `# noqa`: INVALID200 16 16 | from itertools import chain # noqa: E402, INVALID300, F401 17 17 | # Test for mixed code types -RUF102.py:16:44: RUF102 [*] Invalid rule code in `# noqa`: INVALID300 +RUF102 [*] Invalid rule code in `# noqa`: INVALID300 + --> RUF102.py:16:44 | 14 | from collections import defaultdict # noqa: INVALID100, INVALID200, F401 15 | # Test for preserving valid codes when fixing 16 | from itertools import chain # noqa: E402, INVALID300, F401 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ 17 | # Test for mixed code types 18 | import json # noqa: E402, INVALID400, V100 | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 13 13 | # Test for multiple invalid @@ -165,14 +173,15 @@ RUF102.py:16:44: RUF102 [*] Invalid rule code in `# noqa`: INVALID300 17 17 | # Test for mixed code types 18 18 | import json # noqa: E402, INVALID400, V100 -RUF102.py:18:28: RUF102 [*] Invalid rule code in `# noqa`: INVALID400 +RUF102 [*] Invalid rule code in `# noqa`: INVALID400 + --> RUF102.py:18:28 | 16 | from itertools import chain # noqa: E402, INVALID300, F401 17 | # Test for mixed code types 18 | import json # noqa: E402, INVALID400, V100 - | ^^^^^^^^^^ RUF102 + | ^^^^^^^^^^ | - = help: Remove the rule code +help: Remove the rule code ℹ Safe fix 15 15 | # Test for preserving valid codes when fixing diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__no_remove_parentheses_starred_expr_py310.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__no_remove_parentheses_starred_expr_py310.snap index 8fee3cc35a..df2659be72 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__no_remove_parentheses_starred_expr_py310.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__no_remove_parentheses_starred_expr_py310.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:2:3 | 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} 2 | d[(1,2)] - | ^^^^^ RUF031 + | ^^^^^ 3 | d[( 4 | 1, | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} @@ -20,7 +20,8 @@ RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts 4 4 | 1, 5 5 | 2 -RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:3:3 | 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} 2 | d[(1,2)] @@ -29,11 +30,11 @@ RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts 4 | | 1, 5 | | 2 6 | | )] - | |_^ RUF031 + | |_^ 7 | d[ 8 | 1, | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} @@ -48,16 +49,17 @@ RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts 8 8 | 1, 9 9 | 2 -RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:11:3 | 9 | 2 10 | ] 11 | d[(2,4)] - | ^^^^^ RUF031 + | ^^^^^ 12 | d[(5,6,7)] 13 | d[(8,)] | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 8 8 | 1, @@ -69,16 +71,17 @@ RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts 13 13 | d[(8,)] 14 14 | d[tuple(1,2)] -RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:12:3 | 10 | ] 11 | d[(2,4)] 12 | d[(5,6,7)] - | ^^^^^^^ RUF031 + | ^^^^^^^ 13 | d[(8,)] 14 | d[tuple(1,2)] | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 9 9 | 2 @@ -90,16 +93,17 @@ RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts 14 14 | d[tuple(1,2)] 15 15 | d[tuple(8)] -RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:13:3 | 11 | d[(2,4)] 12 | d[(5,6,7)] 13 | d[(8,)] - | ^^^^ RUF031 + | ^^^^ 14 | d[tuple(1,2)] 15 | d[tuple(8)] | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 10 10 | ] @@ -111,15 +115,16 @@ RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts 15 15 | d[tuple(8)] 16 16 | d[1,2] -RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:20:3 | 18 | d[5,6,7] 19 | e = {((1,2),(3,4)):"a"} 20 | e[((1,2),(3,4))] - | ^^^^^^^^^^^^^ RUF031 + | ^^^^^^^^^^^^^ 21 | e[(1,2),(3,4)] | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 17 17 | d[3,4] @@ -132,14 +137,15 @@ RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts 23 23 | token_features[ 24 24 | (window_position, feature_name) -RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:24:5 | 23 | token_features[ 24 | (window_position, feature_name) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF031 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 25 | ] = self._extract_raw_features_from_token | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 21 21 | e[(1,2),(3,4)] @@ -151,15 +157,16 @@ RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts 26 26 | 27 27 | d[1,] -RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts +RUF031 [*] Avoid parentheses for tuples in subscripts + --> RUF031.py:28:3 | 27 | d[1,] 28 | d[(1,)] - | ^^^^ RUF031 + | ^^^^ 29 | d[()] # empty tuples should be ignored 30 | d[:,] # slices in the subscript lead to syntax error if parens are added | - = help: Remove parentheses +help: Remove parentheses ℹ Safe fix 25 25 | ] = self._extract_raw_features_from_token diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap index e56c55ecce..b3933fe5ce 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap @@ -1,22 +1,24 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -noqa.py:24:5: E741 Ambiguous variable name: `I` +E741 Ambiguous variable name: `I` + --> noqa.py:24:5 | 22 | # Neither of these are ignored and warning is 23 | # logged to user 24 | I = 1 # noqa: E741.F841 - | ^ E741 + | ^ | -noqa.py:24:5: F841 [*] Local variable `I` is assigned to but never used +F841 [*] Local variable `I` is assigned to but never used + --> noqa.py:24:5 | 22 | # Neither of these are ignored and warning is 23 | # logged to user 24 | I = 1 # noqa: E741.F841 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `I` +help: Remove assignment to unused variable `I` ℹ Unsafe fix 21 21 | def f(): diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__prefer_parentheses_getitem_tuple.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__prefer_parentheses_getitem_tuple.snap index 3ea279c548..b645294b6b 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__prefer_parentheses_getitem_tuple.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__prefer_parentheses_getitem_tuple.snap @@ -1,17 +1,18 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF031_prefer_parens.py:8:5: RUF031 [*] Use parentheses for tuples in subscripts +RUF031 [*] Use parentheses for tuples in subscripts + --> RUF031_prefer_parens.py:8:5 | 6 | )] 7 | d[ 8 | / 1, 9 | | 2 - | |_____^ RUF031 + | |_____^ 10 | ] 11 | d[(2,4)] | - = help: Parenthesize tuple +help: Parenthesize tuple ℹ Safe fix 5 5 | 2 @@ -25,16 +26,17 @@ RUF031_prefer_parens.py:8:5: RUF031 [*] Use parentheses for tuples in subscripts 11 11 | d[(2,4)] 12 12 | d[(5,6,7)] -RUF031_prefer_parens.py:16:3: RUF031 [*] Use parentheses for tuples in subscripts +RUF031 [*] Use parentheses for tuples in subscripts + --> RUF031_prefer_parens.py:16:3 | 14 | d[tuple(1,2)] 15 | d[tuple(8)] 16 | d[1,2] - | ^^^ RUF031 + | ^^^ 17 | d[3,4] 18 | d[5,6,7] | - = help: Parenthesize tuple +help: Parenthesize tuple ℹ Safe fix 13 13 | d[(8,)] @@ -46,16 +48,17 @@ RUF031_prefer_parens.py:16:3: RUF031 [*] Use parentheses for tuples in subscript 18 18 | d[5,6,7] 19 19 | e = {((1,2),(3,4)):"a"} -RUF031_prefer_parens.py:17:3: RUF031 [*] Use parentheses for tuples in subscripts +RUF031 [*] Use parentheses for tuples in subscripts + --> RUF031_prefer_parens.py:17:3 | 15 | d[tuple(8)] 16 | d[1,2] 17 | d[3,4] - | ^^^ RUF031 + | ^^^ 18 | d[5,6,7] 19 | e = {((1,2),(3,4)):"a"} | - = help: Parenthesize tuple +help: Parenthesize tuple ℹ Safe fix 14 14 | d[tuple(1,2)] @@ -67,16 +70,17 @@ RUF031_prefer_parens.py:17:3: RUF031 [*] Use parentheses for tuples in subscript 19 19 | e = {((1,2),(3,4)):"a"} 20 20 | e[((1,2),(3,4))] -RUF031_prefer_parens.py:18:3: RUF031 [*] Use parentheses for tuples in subscripts +RUF031 [*] Use parentheses for tuples in subscripts + --> RUF031_prefer_parens.py:18:3 | 16 | d[1,2] 17 | d[3,4] 18 | d[5,6,7] - | ^^^^^ RUF031 + | ^^^^^ 19 | e = {((1,2),(3,4)):"a"} 20 | e[((1,2),(3,4))] | - = help: Parenthesize tuple +help: Parenthesize tuple ℹ Safe fix 15 15 | d[tuple(8)] @@ -88,16 +92,17 @@ RUF031_prefer_parens.py:18:3: RUF031 [*] Use parentheses for tuples in subscript 20 20 | e[((1,2),(3,4))] 21 21 | e[(1,2),(3,4)] -RUF031_prefer_parens.py:21:3: RUF031 [*] Use parentheses for tuples in subscripts +RUF031 [*] Use parentheses for tuples in subscripts + --> RUF031_prefer_parens.py:21:3 | 19 | e = {((1,2),(3,4)):"a"} 20 | e[((1,2),(3,4))] 21 | e[(1,2),(3,4)] - | ^^^^^^^^^^^ RUF031 + | ^^^^^^^^^^^ 22 | 23 | token_features[ | - = help: Parenthesize tuple +help: Parenthesize tuple ℹ Safe fix 18 18 | d[5,6,7] @@ -109,16 +114,17 @@ RUF031_prefer_parens.py:21:3: RUF031 [*] Use parentheses for tuples in subscript 23 23 | token_features[ 24 24 | (window_position, feature_name) -RUF031_prefer_parens.py:26:3: RUF031 [*] Use parentheses for tuples in subscripts +RUF031 [*] Use parentheses for tuples in subscripts + --> RUF031_prefer_parens.py:26:3 | 24 | (window_position, feature_name) 25 | ] = self._extract_raw_features_from_token 26 | d[1,] - | ^^ RUF031 + | ^^ 27 | d[(1,)] 28 | d[()] # empty tuples should be ignored | - = help: Parenthesize tuple +help: Parenthesize tuple ℹ Safe fix 23 23 | token_features[ diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039.py.snap index 9fade62593..1717131599 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF039.py:5:12: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039.py:5:12 | 4 | # Errors 5 | re.compile('single free-spacing', flags=re.X) - | ^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^ 6 | re.findall('si\ngle') 7 | re.finditer("dou\ble") | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 2 2 | import regex @@ -21,16 +22,17 @@ RUF039.py:5:12: RUF039 [*] First argument to `re.compile()` is not raw string 7 7 | re.finditer("dou\ble") 8 8 | re.fullmatch('''t\riple single''') -RUF039.py:6:12: RUF039 [*] First argument to `re.findall()` is not raw string +RUF039 [*] First argument to `re.findall()` is not raw string + --> RUF039.py:6:12 | 4 | # Errors 5 | re.compile('single free-spacing', flags=re.X) 6 | re.findall('si\ngle') - | ^^^^^^^^^ RUF039 + | ^^^^^^^^^ 7 | re.finditer("dou\ble") 8 | re.fullmatch('''t\riple single''') | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 3 3 | @@ -42,27 +44,29 @@ RUF039.py:6:12: RUF039 [*] First argument to `re.findall()` is not raw string 8 8 | re.fullmatch('''t\riple single''') 9 9 | re.match("""\triple double""") -RUF039.py:7:13: RUF039 First argument to `re.finditer()` is not raw string +RUF039 First argument to `re.finditer()` is not raw string + --> RUF039.py:7:13 | 5 | re.compile('single free-spacing', flags=re.X) 6 | re.findall('si\ngle') 7 | re.finditer("dou\ble") - | ^^^^^^^^^ RUF039 + | ^^^^^^^^^ 8 | re.fullmatch('''t\riple single''') 9 | re.match("""\triple double""") | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:8:14: RUF039 [*] First argument to `re.fullmatch()` is not raw string +RUF039 [*] First argument to `re.fullmatch()` is not raw string + --> RUF039.py:8:14 | 6 | re.findall('si\ngle') 7 | re.finditer("dou\ble") 8 | re.fullmatch('''t\riple single''') - | ^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^ 9 | re.match("""\triple double""") 10 | re.search('two', 'args') | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 5 5 | re.compile('single free-spacing', flags=re.X) @@ -74,16 +78,17 @@ RUF039.py:8:14: RUF039 [*] First argument to `re.fullmatch()` is not raw string 10 10 | re.search('two', 'args') 11 11 | re.split("raw", r'second') -RUF039.py:9:10: RUF039 [*] First argument to `re.match()` is not raw string +RUF039 [*] First argument to `re.match()` is not raw string + --> RUF039.py:9:10 | 7 | re.finditer("dou\ble") 8 | re.fullmatch('''t\riple single''') 9 | re.match("""\triple double""") - | ^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^ 10 | re.search('two', 'args') 11 | re.split("raw", r'second') | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 6 6 | re.findall('si\ngle') @@ -95,16 +100,17 @@ RUF039.py:9:10: RUF039 [*] First argument to `re.match()` is not raw string 11 11 | re.split("raw", r'second') 12 12 | re.sub(u'''nicode''', u"f(?i)rst") -RUF039.py:10:11: RUF039 [*] First argument to `re.search()` is not raw string +RUF039 [*] First argument to `re.search()` is not raw string + --> RUF039.py:10:11 | 8 | re.fullmatch('''t\riple single''') 9 | re.match("""\triple double""") 10 | re.search('two', 'args') - | ^^^^^ RUF039 + | ^^^^^ 11 | re.split("raw", r'second') 12 | re.sub(u'''nicode''', u"f(?i)rst") | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 7 7 | re.finditer("dou\ble") @@ -116,16 +122,17 @@ RUF039.py:10:11: RUF039 [*] First argument to `re.search()` is not raw string 12 12 | re.sub(u'''nicode''', u"f(?i)rst") 13 13 | re.subn(b"""ytes are""", f"\u006e") -RUF039.py:11:10: RUF039 [*] First argument to `re.split()` is not raw string +RUF039 [*] First argument to `re.split()` is not raw string + --> RUF039.py:11:10 | 9 | re.match("""\triple double""") 10 | re.search('two', 'args') 11 | re.split("raw", r'second') - | ^^^^^ RUF039 + | ^^^^^ 12 | re.sub(u'''nicode''', u"f(?i)rst") 13 | re.subn(b"""ytes are""", f"\u006e") | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 8 8 | re.fullmatch('''t\riple single''') @@ -137,26 +144,28 @@ RUF039.py:11:10: RUF039 [*] First argument to `re.split()` is not raw string 13 13 | re.subn(b"""ytes are""", f"\u006e") 14 14 | -RUF039.py:12:8: RUF039 First argument to `re.sub()` is not raw string +RUF039 First argument to `re.sub()` is not raw string + --> RUF039.py:12:8 | 10 | re.search('two', 'args') 11 | re.split("raw", r'second') 12 | re.sub(u'''nicode''', u"f(?i)rst") - | ^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^ 13 | re.subn(b"""ytes are""", f"\u006e") | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:13:9: RUF039 [*] First argument to `re.subn()` is not raw bytes literal +RUF039 [*] First argument to `re.subn()` is not raw bytes literal + --> RUF039.py:13:9 | 11 | re.split("raw", r'second') 12 | re.sub(u'''nicode''', u"f(?i)rst") 13 | re.subn(b"""ytes are""", f"\u006e") - | ^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^ 14 | 15 | regex.compile('single free-spacing', flags=regex.X) | - = help: Replace with raw bytes literal +help: Replace with raw bytes literal ℹ Safe fix 10 10 | re.search('two', 'args') @@ -168,16 +177,17 @@ RUF039.py:13:9: RUF039 [*] First argument to `re.subn()` is not raw bytes litera 15 15 | regex.compile('single free-spacing', flags=regex.X) 16 16 | regex.findall('si\ngle') -RUF039.py:15:15: RUF039 [*] First argument to `regex.compile()` is not raw string +RUF039 [*] First argument to `regex.compile()` is not raw string + --> RUF039.py:15:15 | 13 | re.subn(b"""ytes are""", f"\u006e") 14 | 15 | regex.compile('single free-spacing', flags=regex.X) - | ^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^ 16 | regex.findall('si\ngle') 17 | regex.finditer("dou\ble") | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 12 12 | re.sub(u'''nicode''', u"f(?i)rst") @@ -189,15 +199,16 @@ RUF039.py:15:15: RUF039 [*] First argument to `regex.compile()` is not raw strin 17 17 | regex.finditer("dou\ble") 18 18 | regex.fullmatch('''t\riple single''') -RUF039.py:16:15: RUF039 [*] First argument to `regex.findall()` is not raw string +RUF039 [*] First argument to `regex.findall()` is not raw string + --> RUF039.py:16:15 | 15 | regex.compile('single free-spacing', flags=regex.X) 16 | regex.findall('si\ngle') - | ^^^^^^^^^ RUF039 + | ^^^^^^^^^ 17 | regex.finditer("dou\ble") 18 | regex.fullmatch('''t\riple single''') | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 13 13 | re.subn(b"""ytes are""", f"\u006e") @@ -209,27 +220,29 @@ RUF039.py:16:15: RUF039 [*] First argument to `regex.findall()` is not raw strin 18 18 | regex.fullmatch('''t\riple single''') 19 19 | regex.match("""\triple double""") -RUF039.py:17:16: RUF039 First argument to `regex.finditer()` is not raw string +RUF039 First argument to `regex.finditer()` is not raw string + --> RUF039.py:17:16 | 15 | regex.compile('single free-spacing', flags=regex.X) 16 | regex.findall('si\ngle') 17 | regex.finditer("dou\ble") - | ^^^^^^^^^ RUF039 + | ^^^^^^^^^ 18 | regex.fullmatch('''t\riple single''') 19 | regex.match("""\triple double""") | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:18:17: RUF039 [*] First argument to `regex.fullmatch()` is not raw string +RUF039 [*] First argument to `regex.fullmatch()` is not raw string + --> RUF039.py:18:17 | 16 | regex.findall('si\ngle') 17 | regex.finditer("dou\ble") 18 | regex.fullmatch('''t\riple single''') - | ^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^ 19 | regex.match("""\triple double""") 20 | regex.search('two', 'args') | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 15 15 | regex.compile('single free-spacing', flags=regex.X) @@ -241,16 +254,17 @@ RUF039.py:18:17: RUF039 [*] First argument to `regex.fullmatch()` is not raw str 20 20 | regex.search('two', 'args') 21 21 | regex.split("raw", r'second') -RUF039.py:19:13: RUF039 [*] First argument to `regex.match()` is not raw string +RUF039 [*] First argument to `regex.match()` is not raw string + --> RUF039.py:19:13 | 17 | regex.finditer("dou\ble") 18 | regex.fullmatch('''t\riple single''') 19 | regex.match("""\triple double""") - | ^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^ 20 | regex.search('two', 'args') 21 | regex.split("raw", r'second') | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 16 16 | regex.findall('si\ngle') @@ -262,16 +276,17 @@ RUF039.py:19:13: RUF039 [*] First argument to `regex.match()` is not raw string 21 21 | regex.split("raw", r'second') 22 22 | regex.sub(u'''nicode''', u"f(?i)rst") -RUF039.py:20:14: RUF039 [*] First argument to `regex.search()` is not raw string +RUF039 [*] First argument to `regex.search()` is not raw string + --> RUF039.py:20:14 | 18 | regex.fullmatch('''t\riple single''') 19 | regex.match("""\triple double""") 20 | regex.search('two', 'args') - | ^^^^^ RUF039 + | ^^^^^ 21 | regex.split("raw", r'second') 22 | regex.sub(u'''nicode''', u"f(?i)rst") | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 17 17 | regex.finditer("dou\ble") @@ -283,16 +298,17 @@ RUF039.py:20:14: RUF039 [*] First argument to `regex.search()` is not raw string 22 22 | regex.sub(u'''nicode''', u"f(?i)rst") 23 23 | regex.subn(b"""ytes are""", f"\u006e") -RUF039.py:21:13: RUF039 [*] First argument to `regex.split()` is not raw string +RUF039 [*] First argument to `regex.split()` is not raw string + --> RUF039.py:21:13 | 19 | regex.match("""\triple double""") 20 | regex.search('two', 'args') 21 | regex.split("raw", r'second') - | ^^^^^ RUF039 + | ^^^^^ 22 | regex.sub(u'''nicode''', u"f(?i)rst") 23 | regex.subn(b"""ytes are""", f"\u006e") | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 18 18 | regex.fullmatch('''t\riple single''') @@ -304,26 +320,28 @@ RUF039.py:21:13: RUF039 [*] First argument to `regex.split()` is not raw string 23 23 | regex.subn(b"""ytes are""", f"\u006e") 24 24 | -RUF039.py:22:11: RUF039 First argument to `regex.sub()` is not raw string +RUF039 First argument to `regex.sub()` is not raw string + --> RUF039.py:22:11 | 20 | regex.search('two', 'args') 21 | regex.split("raw", r'second') 22 | regex.sub(u'''nicode''', u"f(?i)rst") - | ^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^ 23 | regex.subn(b"""ytes are""", f"\u006e") | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:23:12: RUF039 [*] First argument to `regex.subn()` is not raw bytes literal +RUF039 [*] First argument to `regex.subn()` is not raw bytes literal + --> RUF039.py:23:12 | 21 | regex.split("raw", r'second') 22 | regex.sub(u'''nicode''', u"f(?i)rst") 23 | regex.subn(b"""ytes are""", f"\u006e") - | ^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^ 24 | 25 | regex.template("""(?m) | - = help: Replace with raw bytes literal +help: Replace with raw bytes literal ℹ Safe fix 20 20 | regex.search('two', 'args') @@ -335,7 +353,8 @@ RUF039.py:23:12: RUF039 [*] First argument to `regex.subn()` is not raw bytes li 25 25 | regex.template("""(?m) 26 26 | (?:ulti)? -RUF039.py:25:16: RUF039 [*] First argument to `regex.template()` is not raw string +RUF039 [*] First argument to `regex.template()` is not raw string + --> RUF039.py:25:16 | 23 | regex.subn(b"""ytes are""", f"\u006e") 24 | @@ -345,9 +364,9 @@ RUF039.py:25:16: RUF039 [*] First argument to `regex.template()` is not raw stri 27 | | (?=(? RUF039.py:59:12 | 58 | # https://github.com/astral-sh/ruff/issues/16713 59 | re.compile("\a\f\n\r\t\u27F2\U0001F0A1\v\x41") # with unsafe fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 60 | re.compile("\b") # without fix 61 | re.compile("\"") # without fix | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 56 56 | @@ -379,90 +399,98 @@ RUF039.py:59:12: RUF039 [*] First argument to `re.compile()` is not raw string 61 61 | re.compile("\"") # without fix 62 62 | re.compile("\'") # without fix -RUF039.py:60:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039.py:60:12 | 58 | # https://github.com/astral-sh/ruff/issues/16713 59 | re.compile("\a\f\n\r\t\u27F2\U0001F0A1\v\x41") # with unsafe fix 60 | re.compile("\b") # without fix - | ^^^^ RUF039 + | ^^^^ 61 | re.compile("\"") # without fix 62 | re.compile("\'") # without fix | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:61:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039.py:61:12 | 59 | re.compile("\a\f\n\r\t\u27F2\U0001F0A1\v\x41") # with unsafe fix 60 | re.compile("\b") # without fix 61 | re.compile("\"") # without fix - | ^^^^ RUF039 + | ^^^^ 62 | re.compile("\'") # without fix 63 | re.compile('\"') # without fix | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:62:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039.py:62:12 | 60 | re.compile("\b") # without fix 61 | re.compile("\"") # without fix 62 | re.compile("\'") # without fix - | ^^^^ RUF039 + | ^^^^ 63 | re.compile('\"') # without fix 64 | re.compile('\'') # without fix | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:63:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039.py:63:12 | 61 | re.compile("\"") # without fix 62 | re.compile("\'") # without fix 63 | re.compile('\"') # without fix - | ^^^^ RUF039 + | ^^^^ 64 | re.compile('\'') # without fix 65 | re.compile("\\") # without fix | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:64:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039.py:64:12 | 62 | re.compile("\'") # without fix 63 | re.compile('\"') # without fix 64 | re.compile('\'') # without fix - | ^^^^ RUF039 + | ^^^^ 65 | re.compile("\\") # without fix 66 | re.compile("\101") # without fix | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:65:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039.py:65:12 | 63 | re.compile('\"') # without fix 64 | re.compile('\'') # without fix 65 | re.compile("\\") # without fix - | ^^^^ RUF039 + | ^^^^ 66 | re.compile("\101") # without fix 67 | re.compile("a\ | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:66:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039.py:66:12 | 64 | re.compile('\'') # without fix 65 | re.compile("\\") # without fix 66 | re.compile("\101") # without fix - | ^^^^^^ RUF039 + | ^^^^^^ 67 | re.compile("a\ 68 | b") # without fix | - = help: Replace with raw string +help: Replace with raw string -RUF039.py:67:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039.py:67:12 | 65 | re.compile("\\") # without fix 66 | re.compile("\101") # without fix 67 | re.compile("a\ | ____________^ 68 | | b") # without fix - | |__^ RUF039 + | |__^ | - = help: Replace with raw string +help: Replace with raw string diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039_concat.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039_concat.py.snap index 1cabbc9876..1ee8cf2707 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039_concat.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF039_RUF039_concat.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF039_concat.py:5:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:5:5 | 4 | re.compile( 5 | 'implicit' - | ^^^^^^^^^^ RUF039 + | ^^^^^^^^^^ 6 | 'concatenation' 7 | ) | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 2 2 | @@ -21,16 +22,17 @@ RUF039_concat.py:5:5: RUF039 [*] First argument to `re.compile()` is not raw str 7 7 | ) 8 8 | re.findall( -RUF039_concat.py:6:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:6:5 | 4 | re.compile( 5 | 'implicit' 6 | 'concatenation' - | ^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^ 7 | ) 8 | re.findall( | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 3 3 | @@ -42,18 +44,19 @@ RUF039_concat.py:6:5: RUF039 [*] First argument to `re.compile()` is not raw str 8 8 | re.findall( 9 9 | r''' -RUF039_concat.py:12:5: RUF039 [*] First argument to `re.findall()` is not raw string +RUF039 [*] First argument to `re.findall()` is not raw string + --> RUF039_concat.py:12:5 | 10 | multiline 11 | ''' 12 | / """ 13 | | concatenation 14 | | """ - | |_______^ RUF039 + | |_______^ 15 | ) 16 | re.finditer( | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 9 9 | r''' @@ -65,16 +68,17 @@ RUF039_concat.py:12:5: RUF039 [*] First argument to `re.findall()` is not raw st 14 14 | """ 15 15 | ) -RUF039_concat.py:26:5: RUF039 [*] First argument to `re.match()` is not raw bytes literal +RUF039 [*] First argument to `re.match()` is not raw bytes literal + --> RUF039_concat.py:26:5 | 24 | ) 25 | re.match( 26 | b'reak' - | ^^^^^^^ RUF039 + | ^^^^^^^ 27 | br'eak' 28 | ) | - = help: Replace with raw bytes literal +help: Replace with raw bytes literal ℹ Safe fix 23 23 | f'much?' @@ -86,27 +90,29 @@ RUF039_concat.py:26:5: RUF039 [*] First argument to `re.match()` is not raw byte 28 28 | ) 29 29 | re.search( -RUF039_concat.py:30:8: RUF039 First argument to `re.search()` is not raw string +RUF039 First argument to `re.search()` is not raw string + --> RUF039_concat.py:30:8 | 28 | ) 29 | re.search( 30 | r''u'' - | ^^^ RUF039 + | ^^^ 31 | '''okay?''' 32 | ) | - = help: Replace with raw string +help: Replace with raw string -RUF039_concat.py:31:5: RUF039 [*] First argument to `re.search()` is not raw string +RUF039 [*] First argument to `re.search()` is not raw string + --> RUF039_concat.py:31:5 | 29 | re.search( 30 | r''u'' 31 | '''okay?''' - | ^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^ 32 | ) 33 | re.split(''U"""w"""U'') | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 28 28 | ) @@ -118,16 +124,17 @@ RUF039_concat.py:31:5: RUF039 [*] First argument to `re.search()` is not raw str 33 33 | re.split(''U"""w"""U'') 34 34 | re.sub( -RUF039_concat.py:33:10: RUF039 [*] First argument to `re.split()` is not raw string +RUF039 [*] First argument to `re.split()` is not raw string + --> RUF039_concat.py:33:10 | 31 | '''okay?''' 32 | ) 33 | re.split(''U"""w"""U'') - | ^^ RUF039 + | ^^ 34 | re.sub( 35 | "I''m o" | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 30 30 | r''u'' @@ -139,38 +146,41 @@ RUF039_concat.py:33:10: RUF039 [*] First argument to `re.split()` is not raw str 35 35 | "I''m o" 36 36 | 'utta ideas' -RUF039_concat.py:33:12: RUF039 First argument to `re.split()` is not raw string +RUF039 First argument to `re.split()` is not raw string + --> RUF039_concat.py:33:12 | 31 | '''okay?''' 32 | ) 33 | re.split(''U"""w"""U'') - | ^^^^^^^^ RUF039 + | ^^^^^^^^ 34 | re.sub( 35 | "I''m o" | - = help: Replace with raw string +help: Replace with raw string -RUF039_concat.py:33:20: RUF039 First argument to `re.split()` is not raw string +RUF039 First argument to `re.split()` is not raw string + --> RUF039_concat.py:33:20 | 31 | '''okay?''' 32 | ) 33 | re.split(''U"""w"""U'') - | ^^^ RUF039 + | ^^^ 34 | re.sub( 35 | "I''m o" | - = help: Replace with raw string +help: Replace with raw string -RUF039_concat.py:35:5: RUF039 [*] First argument to `re.sub()` is not raw string +RUF039 [*] First argument to `re.sub()` is not raw string + --> RUF039_concat.py:35:5 | 33 | re.split(''U"""w"""U'') 34 | re.sub( 35 | "I''m o" - | ^^^^^^^^ RUF039 + | ^^^^^^^^ 36 | 'utta ideas' 37 | ) | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 32 32 | ) @@ -182,16 +192,17 @@ RUF039_concat.py:35:5: RUF039 [*] First argument to `re.sub()` is not raw string 37 37 | ) 38 38 | re.subn("()"r' am I'"??") -RUF039_concat.py:36:5: RUF039 [*] First argument to `re.sub()` is not raw string +RUF039 [*] First argument to `re.sub()` is not raw string + --> RUF039_concat.py:36:5 | 34 | re.sub( 35 | "I''m o" 36 | 'utta ideas' - | ^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^ 37 | ) 38 | re.subn("()"r' am I'"??") | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 33 33 | re.split(''U"""w"""U'') @@ -203,14 +214,15 @@ RUF039_concat.py:36:5: RUF039 [*] First argument to `re.sub()` is not raw string 38 38 | re.subn("()"r' am I'"??") 39 39 | -RUF039_concat.py:38:9: RUF039 [*] First argument to `re.subn()` is not raw string +RUF039 [*] First argument to `re.subn()` is not raw string + --> RUF039_concat.py:38:9 | 36 | 'utta ideas' 37 | ) 38 | re.subn("()"r' am I'"??") - | ^^^^ RUF039 + | ^^^^ | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 35 35 | "I''m o" @@ -222,14 +234,15 @@ RUF039_concat.py:38:9: RUF039 [*] First argument to `re.subn()` is not raw strin 40 40 | 41 41 | import regex -RUF039_concat.py:38:21: RUF039 [*] First argument to `re.subn()` is not raw string +RUF039 [*] First argument to `re.subn()` is not raw string + --> RUF039_concat.py:38:21 | 36 | 'utta ideas' 37 | ) 38 | re.subn("()"r' am I'"??") - | ^^^^ RUF039 + | ^^^^ | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 35 35 | "I''m o" @@ -241,15 +254,16 @@ RUF039_concat.py:38:21: RUF039 [*] First argument to `re.subn()` is not raw stri 40 40 | 41 41 | import regex -RUF039_concat.py:45:5: RUF039 [*] First argument to `regex.compile()` is not raw string +RUF039 [*] First argument to `regex.compile()` is not raw string + --> RUF039_concat.py:45:5 | 44 | regex.compile( 45 | 'implicit' - | ^^^^^^^^^^ RUF039 + | ^^^^^^^^^^ 46 | 'concatenation' 47 | ) | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 42 42 | @@ -261,16 +275,17 @@ RUF039_concat.py:45:5: RUF039 [*] First argument to `regex.compile()` is not raw 47 47 | ) 48 48 | regex.findall( -RUF039_concat.py:46:5: RUF039 [*] First argument to `regex.compile()` is not raw string +RUF039 [*] First argument to `regex.compile()` is not raw string + --> RUF039_concat.py:46:5 | 44 | regex.compile( 45 | 'implicit' 46 | 'concatenation' - | ^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^ 47 | ) 48 | regex.findall( | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 43 43 | @@ -282,18 +297,19 @@ RUF039_concat.py:46:5: RUF039 [*] First argument to `regex.compile()` is not raw 48 48 | regex.findall( 49 49 | r''' -RUF039_concat.py:52:5: RUF039 [*] First argument to `regex.findall()` is not raw string +RUF039 [*] First argument to `regex.findall()` is not raw string + --> RUF039_concat.py:52:5 | 50 | multiline 51 | ''' 52 | / """ 53 | | concatenation 54 | | """ - | |_______^ RUF039 + | |_______^ 55 | ) 56 | regex.finditer( | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 49 49 | r''' @@ -305,16 +321,17 @@ RUF039_concat.py:52:5: RUF039 [*] First argument to `regex.findall()` is not raw 54 54 | """ 55 55 | ) -RUF039_concat.py:66:5: RUF039 [*] First argument to `regex.match()` is not raw bytes literal +RUF039 [*] First argument to `regex.match()` is not raw bytes literal + --> RUF039_concat.py:66:5 | 64 | ) 65 | regex.match( 66 | b'reak' - | ^^^^^^^ RUF039 + | ^^^^^^^ 67 | br'eak' 68 | ) | - = help: Replace with raw bytes literal +help: Replace with raw bytes literal ℹ Safe fix 63 63 | f'much?' @@ -326,27 +343,29 @@ RUF039_concat.py:66:5: RUF039 [*] First argument to `regex.match()` is not raw b 68 68 | ) 69 69 | regex.search( -RUF039_concat.py:70:8: RUF039 First argument to `regex.search()` is not raw string +RUF039 First argument to `regex.search()` is not raw string + --> RUF039_concat.py:70:8 | 68 | ) 69 | regex.search( 70 | r''u'' - | ^^^ RUF039 + | ^^^ 71 | '''okay?''' 72 | ) | - = help: Replace with raw string +help: Replace with raw string -RUF039_concat.py:71:5: RUF039 [*] First argument to `regex.search()` is not raw string +RUF039 [*] First argument to `regex.search()` is not raw string + --> RUF039_concat.py:71:5 | 69 | regex.search( 70 | r''u'' 71 | '''okay?''' - | ^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^ 72 | ) 73 | regex.split(''U"""w"""U'') | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 68 68 | ) @@ -358,16 +377,17 @@ RUF039_concat.py:71:5: RUF039 [*] First argument to `regex.search()` is not raw 73 73 | regex.split(''U"""w"""U'') 74 74 | regex.sub( -RUF039_concat.py:73:13: RUF039 [*] First argument to `regex.split()` is not raw string +RUF039 [*] First argument to `regex.split()` is not raw string + --> RUF039_concat.py:73:13 | 71 | '''okay?''' 72 | ) 73 | regex.split(''U"""w"""U'') - | ^^ RUF039 + | ^^ 74 | regex.sub( 75 | "I''m o" | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 70 70 | r''u'' @@ -379,38 +399,41 @@ RUF039_concat.py:73:13: RUF039 [*] First argument to `regex.split()` is not raw 75 75 | "I''m o" 76 76 | 'utta ideas' -RUF039_concat.py:73:15: RUF039 First argument to `regex.split()` is not raw string +RUF039 First argument to `regex.split()` is not raw string + --> RUF039_concat.py:73:15 | 71 | '''okay?''' 72 | ) 73 | regex.split(''U"""w"""U'') - | ^^^^^^^^ RUF039 + | ^^^^^^^^ 74 | regex.sub( 75 | "I''m o" | - = help: Replace with raw string +help: Replace with raw string -RUF039_concat.py:73:23: RUF039 First argument to `regex.split()` is not raw string +RUF039 First argument to `regex.split()` is not raw string + --> RUF039_concat.py:73:23 | 71 | '''okay?''' 72 | ) 73 | regex.split(''U"""w"""U'') - | ^^^ RUF039 + | ^^^ 74 | regex.sub( 75 | "I''m o" | - = help: Replace with raw string +help: Replace with raw string -RUF039_concat.py:75:5: RUF039 [*] First argument to `regex.sub()` is not raw string +RUF039 [*] First argument to `regex.sub()` is not raw string + --> RUF039_concat.py:75:5 | 73 | regex.split(''U"""w"""U'') 74 | regex.sub( 75 | "I''m o" - | ^^^^^^^^ RUF039 + | ^^^^^^^^ 76 | 'utta ideas' 77 | ) | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 72 72 | ) @@ -422,16 +445,17 @@ RUF039_concat.py:75:5: RUF039 [*] First argument to `regex.sub()` is not raw str 77 77 | ) 78 78 | regex.subn("()"r' am I'"??") -RUF039_concat.py:76:5: RUF039 [*] First argument to `regex.sub()` is not raw string +RUF039 [*] First argument to `regex.sub()` is not raw string + --> RUF039_concat.py:76:5 | 74 | regex.sub( 75 | "I''m o" 76 | 'utta ideas' - | ^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^ 77 | ) 78 | regex.subn("()"r' am I'"??") | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 73 73 | regex.split(''U"""w"""U'') @@ -443,14 +467,15 @@ RUF039_concat.py:76:5: RUF039 [*] First argument to `regex.sub()` is not raw str 78 78 | regex.subn("()"r' am I'"??") 79 79 | -RUF039_concat.py:78:12: RUF039 [*] First argument to `regex.subn()` is not raw string +RUF039 [*] First argument to `regex.subn()` is not raw string + --> RUF039_concat.py:78:12 | 76 | 'utta ideas' 77 | ) 78 | regex.subn("()"r' am I'"??") - | ^^^^ RUF039 + | ^^^^ | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 75 75 | "I''m o" @@ -462,14 +487,15 @@ RUF039_concat.py:78:12: RUF039 [*] First argument to `regex.subn()` is not raw s 80 80 | 81 81 | regex.template( -RUF039_concat.py:78:24: RUF039 [*] First argument to `regex.subn()` is not raw string +RUF039 [*] First argument to `regex.subn()` is not raw string + --> RUF039_concat.py:78:24 | 76 | 'utta ideas' 77 | ) 78 | regex.subn("()"r' am I'"??") - | ^^^^ RUF039 + | ^^^^ | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 75 75 | "I''m o" @@ -481,16 +507,17 @@ RUF039_concat.py:78:24: RUF039 [*] First argument to `regex.subn()` is not raw s 80 80 | 81 81 | regex.template( -RUF039_concat.py:98:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:98:5 | 96 | # https://github.com/astral-sh/ruff/issues/16713 97 | re.compile( 98 | "[" - | ^^^ RUF039 + | ^^^ 99 | "\U0001F600-\U0001F64F" # emoticons 100 | "\U0001F300-\U0001F5FF" # symbols & pictographs | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 95 95 | @@ -502,16 +529,17 @@ RUF039_concat.py:98:5: RUF039 [*] First argument to `re.compile()` is not raw st 100 100 | "\U0001F300-\U0001F5FF" # symbols & pictographs 101 101 | "\U0001F680-\U0001F6FF" # transport & map symbols -RUF039_concat.py:99:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:99:5 | 97 | re.compile( 98 | "[" 99 | "\U0001F600-\U0001F64F" # emoticons - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^ 100 | "\U0001F300-\U0001F5FF" # symbols & pictographs 101 | "\U0001F680-\U0001F6FF" # transport & map symbols | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 96 96 | # https://github.com/astral-sh/ruff/issues/16713 @@ -523,16 +551,17 @@ RUF039_concat.py:99:5: RUF039 [*] First argument to `re.compile()` is not raw st 101 101 | "\U0001F680-\U0001F6FF" # transport & map symbols 102 102 | "\U0001F1E0-\U0001F1FF" # flags (iOS) -RUF039_concat.py:100:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:100:5 | 98 | "[" 99 | "\U0001F600-\U0001F64F" # emoticons 100 | "\U0001F300-\U0001F5FF" # symbols & pictographs - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^ 101 | "\U0001F680-\U0001F6FF" # transport & map symbols 102 | "\U0001F1E0-\U0001F1FF" # flags (iOS) | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 97 97 | re.compile( @@ -544,16 +573,17 @@ RUF039_concat.py:100:5: RUF039 [*] First argument to `re.compile()` is not raw s 102 102 | "\U0001F1E0-\U0001F1FF" # flags (iOS) 103 103 | "\U00002702-\U000027B0" -RUF039_concat.py:101:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:101:5 | 99 | "\U0001F600-\U0001F64F" # emoticons 100 | "\U0001F300-\U0001F5FF" # symbols & pictographs 101 | "\U0001F680-\U0001F6FF" # transport & map symbols - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^ 102 | "\U0001F1E0-\U0001F1FF" # flags (iOS) 103 | "\U00002702-\U000027B0" | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 98 98 | "[" @@ -565,16 +595,17 @@ RUF039_concat.py:101:5: RUF039 [*] First argument to `re.compile()` is not raw s 103 103 | "\U00002702-\U000027B0" 104 104 | "\U000024C2-\U0001F251" -RUF039_concat.py:102:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:102:5 | 100 | "\U0001F300-\U0001F5FF" # symbols & pictographs 101 | "\U0001F680-\U0001F6FF" # transport & map symbols 102 | "\U0001F1E0-\U0001F1FF" # flags (iOS) - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^ 103 | "\U00002702-\U000027B0" 104 | "\U000024C2-\U0001F251" | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 99 99 | "\U0001F600-\U0001F64F" # emoticons @@ -586,16 +617,17 @@ RUF039_concat.py:102:5: RUF039 [*] First argument to `re.compile()` is not raw s 104 104 | "\U000024C2-\U0001F251" 105 105 | "\u200d" # zero width joiner -RUF039_concat.py:103:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:103:5 | 101 | "\U0001F680-\U0001F6FF" # transport & map symbols 102 | "\U0001F1E0-\U0001F1FF" # flags (iOS) 103 | "\U00002702-\U000027B0" - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^ 104 | "\U000024C2-\U0001F251" 105 | "\u200d" # zero width joiner | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 100 100 | "\U0001F300-\U0001F5FF" # symbols & pictographs @@ -607,16 +639,17 @@ RUF039_concat.py:103:5: RUF039 [*] First argument to `re.compile()` is not raw s 105 105 | "\u200d" # zero width joiner 106 106 | "\u200c" # zero width non-joiner -RUF039_concat.py:104:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:104:5 | 102 | "\U0001F1E0-\U0001F1FF" # flags (iOS) 103 | "\U00002702-\U000027B0" 104 | "\U000024C2-\U0001F251" - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^ 105 | "\u200d" # zero width joiner 106 | "\u200c" # zero width non-joiner | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 101 101 | "\U0001F680-\U0001F6FF" # transport & map symbols @@ -628,16 +661,17 @@ RUF039_concat.py:104:5: RUF039 [*] First argument to `re.compile()` is not raw s 106 106 | "\u200c" # zero width non-joiner 107 107 | "\\u200c" # must not be escaped in a raw string -RUF039_concat.py:105:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:105:5 | 103 | "\U00002702-\U000027B0" 104 | "\U000024C2-\U0001F251" 105 | "\u200d" # zero width joiner - | ^^^^^^^^ RUF039 + | ^^^^^^^^ 106 | "\u200c" # zero width non-joiner 107 | "\\u200c" # must not be escaped in a raw string | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 102 102 | "\U0001F1E0-\U0001F1FF" # flags (iOS) @@ -649,16 +683,17 @@ RUF039_concat.py:105:5: RUF039 [*] First argument to `re.compile()` is not raw s 107 107 | "\\u200c" # must not be escaped in a raw string 108 108 | "]+", -RUF039_concat.py:106:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:106:5 | 104 | "\U000024C2-\U0001F251" 105 | "\u200d" # zero width joiner 106 | "\u200c" # zero width non-joiner - | ^^^^^^^^ RUF039 + | ^^^^^^^^ 107 | "\\u200c" # must not be escaped in a raw string 108 | "]+", | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 103 103 | "\U00002702-\U000027B0" @@ -670,27 +705,29 @@ RUF039_concat.py:106:5: RUF039 [*] First argument to `re.compile()` is not raw s 108 108 | "]+", 109 109 | flags=re.UNICODE, -RUF039_concat.py:107:5: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039_concat.py:107:5 | 105 | "\u200d" # zero width joiner 106 | "\u200c" # zero width non-joiner 107 | "\\u200c" # must not be escaped in a raw string - | ^^^^^^^^^ RUF039 + | ^^^^^^^^^ 108 | "]+", 109 | flags=re.UNICODE, | - = help: Replace with raw string +help: Replace with raw string -RUF039_concat.py:108:5: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_concat.py:108:5 | 106 | "\u200c" # zero width non-joiner 107 | "\\u200c" # must not be escaped in a raw string 108 | "]+", - | ^^^^ RUF039 + | ^^^^ 109 | flags=re.UNICODE, 110 | ) | - = help: Replace with raw string +help: Replace with raw string ℹ Safe fix 105 105 | "\u200d" # zero width joiner diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF043_RUF043.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF043_RUF043.py.snap index 0207b8a583..f849446a0b 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF043_RUF043.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF043_RUF043.py.snap @@ -1,330 +1,360 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF043.py:8:43: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:8:43 | 6 | ### Errors 7 | 8 | with pytest.raises(FooAtTheEnd, match="foo."): ... - | ^^^^^^ RUF043 + | ^^^^^^ 9 | with pytest.raises(PackageExtraSpecifier, match="Install `foo[bar]` to enjoy all features"): ... 10 | with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:9:53: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:9:53 | 8 | with pytest.raises(FooAtTheEnd, match="foo."): ... 9 | with pytest.raises(PackageExtraSpecifier, match="Install `foo[bar]` to enjoy all features"): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:10:48: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:10:48 | 8 | with pytest.raises(FooAtTheEnd, match="foo."): ... 9 | with pytest.raises(PackageExtraSpecifier, match="Install `foo[bar]` to enjoy all features"): ... 10 | with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11 | 12 | with pytest.raises(StringConcatenation, match="Huh" | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:12:51: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:12:51 | 10 | with pytest.raises(InnocentQuestion, match="Did you mean to use `Literal` instead?"): ... 11 | 12 | with pytest.raises(StringConcatenation, match="Huh" | ___________________________________________________^ 13 | | "?"): ... - | |_____________________________________________________^ RUF043 + | |_____________________________________________________^ 14 | with pytest.raises(ManuallyEscapedWindowsPathToDotFile, match="C:\\\\Users\\\\Foo\\\\.config"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:14:67: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:14:67 | 12 | with pytest.raises(StringConcatenation, match="Huh" 13 | "?"): ... 14 | with pytest.raises(ManuallyEscapedWindowsPathToDotFile, match="C:\\\\Users\\\\Foo\\\\.config"): ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 15 | 16 | with pytest.raises(MiddleDot, match="foo.bar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:16:41: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:16:41 | 14 | with pytest.raises(ManuallyEscapedWindowsPathToDotFile, match="C:\\\\Users\\\\Foo\\\\.config"): ... 15 | 16 | with pytest.raises(MiddleDot, match="foo.bar"): ... - | ^^^^^^^^^ RUF043 + | ^^^^^^^^^ 17 | with pytest.raises(EndDot, match="foobar."): ... 18 | with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:17:38: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:17:38 | 16 | with pytest.raises(MiddleDot, match="foo.bar"): ... 17 | with pytest.raises(EndDot, match="foobar."): ... - | ^^^^^^^^^ RUF043 + | ^^^^^^^^^ 18 | with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ... 19 | with pytest.raises(UnescapedFollowedByEscaped, match="foo.\\*bar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:18:58: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:18:58 | 16 | with pytest.raises(MiddleDot, match="foo.bar"): ... 17 | with pytest.raises(EndDot, match="foobar."): ... 18 | with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ... - | ^^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^^ 19 | with pytest.raises(UnescapedFollowedByEscaped, match="foo.\\*bar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:19:58: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:19:58 | 17 | with pytest.raises(EndDot, match="foobar."): ... 18 | with pytest.raises(EscapedFollowedByUnescaped, match="foo\\.*bar"): ... 19 | with pytest.raises(UnescapedFollowedByEscaped, match="foo.\\*bar"): ... - | ^^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^^ 20 | 21 | # https://github.com/astral-sh/ruff/issues/15316 | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:22:50: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:22:50 | 21 | # https://github.com/astral-sh/ruff/issues/15316 22 | with pytest.raises(ClosingParenthesis, match="foo)"): ... - | ^^^^^^ RUF043 + | ^^^^^^ | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:27:44: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:27:44 | 25 | ## Metasequences 26 | 27 | with pytest.raises(StartOfInput, match="foo\\Abar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 28 | with pytest.raises(WordBoundary, match="foo\\bbar"): ... 29 | with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:28:44: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:28:44 | 27 | with pytest.raises(StartOfInput, match="foo\\Abar"): ... 28 | with pytest.raises(WordBoundary, match="foo\\bbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 29 | with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ... 30 | with pytest.raises(Digit, match="foo\\dbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:29:47: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:29:47 | 27 | with pytest.raises(StartOfInput, match="foo\\Abar"): ... 28 | with pytest.raises(WordBoundary, match="foo\\bbar"): ... 29 | with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 30 | with pytest.raises(Digit, match="foo\\dbar"): ... 31 | with pytest.raises(NonDigit, match="foo\\Dbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:30:37: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:30:37 | 28 | with pytest.raises(WordBoundary, match="foo\\bbar"): ... 29 | with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ... 30 | with pytest.raises(Digit, match="foo\\dbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 31 | with pytest.raises(NonDigit, match="foo\\Dbar"): ... 32 | with pytest.raises(Whitespace, match="foo\\sbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:31:40: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:31:40 | 29 | with pytest.raises(NonWordBoundary, match="foo\\Bbar"): ... 30 | with pytest.raises(Digit, match="foo\\dbar"): ... 31 | with pytest.raises(NonDigit, match="foo\\Dbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 32 | with pytest.raises(Whitespace, match="foo\\sbar"): ... 33 | with pytest.raises(NonWhitespace, match="foo\\Sbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:32:42: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:32:42 | 30 | with pytest.raises(Digit, match="foo\\dbar"): ... 31 | with pytest.raises(NonDigit, match="foo\\Dbar"): ... 32 | with pytest.raises(Whitespace, match="foo\\sbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 33 | with pytest.raises(NonWhitespace, match="foo\\Sbar"): ... 34 | with pytest.raises(WordCharacter, match="foo\\wbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:33:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:33:45 | 31 | with pytest.raises(NonDigit, match="foo\\Dbar"): ... 32 | with pytest.raises(Whitespace, match="foo\\sbar"): ... 33 | with pytest.raises(NonWhitespace, match="foo\\Sbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 34 | with pytest.raises(WordCharacter, match="foo\\wbar"): ... 35 | with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:34:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:34:45 | 32 | with pytest.raises(Whitespace, match="foo\\sbar"): ... 33 | with pytest.raises(NonWhitespace, match="foo\\Sbar"): ... 34 | with pytest.raises(WordCharacter, match="foo\\wbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 35 | with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ... 36 | with pytest.raises(EndOfInput, match="foo\\zbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:35:48: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:35:48 | 33 | with pytest.raises(NonWhitespace, match="foo\\Sbar"): ... 34 | with pytest.raises(WordCharacter, match="foo\\wbar"): ... 35 | with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 36 | with pytest.raises(EndOfInput, match="foo\\zbar"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:36:42: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:36:42 | 34 | with pytest.raises(WordCharacter, match="foo\\wbar"): ... 35 | with pytest.raises(NonWordCharacter, match="foo\\Wbar"): ... 36 | with pytest.raises(EndOfInput, match="foo\\zbar"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 37 | 38 | with pytest.raises(StartOfInput2, match="foobar\\A"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:38:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:38:45 | 36 | with pytest.raises(EndOfInput, match="foo\\zbar"): ... 37 | 38 | with pytest.raises(StartOfInput2, match="foobar\\A"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 39 | with pytest.raises(WordBoundary2, match="foobar\\b"): ... 40 | with pytest.raises(NonWordBoundary2, match="foobar\\B"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:39:45: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:39:45 | 38 | with pytest.raises(StartOfInput2, match="foobar\\A"): ... 39 | with pytest.raises(WordBoundary2, match="foobar\\b"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 40 | with pytest.raises(NonWordBoundary2, match="foobar\\B"): ... 41 | with pytest.raises(Digit2, match="foobar\\d"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:40:48: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:40:48 | 38 | with pytest.raises(StartOfInput2, match="foobar\\A"): ... 39 | with pytest.raises(WordBoundary2, match="foobar\\b"): ... 40 | with pytest.raises(NonWordBoundary2, match="foobar\\B"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 41 | with pytest.raises(Digit2, match="foobar\\d"): ... 42 | with pytest.raises(NonDigit2, match="foobar\\D"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:41:38: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:41:38 | 39 | with pytest.raises(WordBoundary2, match="foobar\\b"): ... 40 | with pytest.raises(NonWordBoundary2, match="foobar\\B"): ... 41 | with pytest.raises(Digit2, match="foobar\\d"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 42 | with pytest.raises(NonDigit2, match="foobar\\D"): ... 43 | with pytest.raises(Whitespace2, match="foobar\\s"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:42:41: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:42:41 | 40 | with pytest.raises(NonWordBoundary2, match="foobar\\B"): ... 41 | with pytest.raises(Digit2, match="foobar\\d"): ... 42 | with pytest.raises(NonDigit2, match="foobar\\D"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 43 | with pytest.raises(Whitespace2, match="foobar\\s"): ... 44 | with pytest.raises(NonWhitespace2, match="foobar\\S"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:43:43: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:43:43 | 41 | with pytest.raises(Digit2, match="foobar\\d"): ... 42 | with pytest.raises(NonDigit2, match="foobar\\D"): ... 43 | with pytest.raises(Whitespace2, match="foobar\\s"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 44 | with pytest.raises(NonWhitespace2, match="foobar\\S"): ... 45 | with pytest.raises(WordCharacter2, match="foobar\\w"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:44:46: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:44:46 | 42 | with pytest.raises(NonDigit2, match="foobar\\D"): ... 43 | with pytest.raises(Whitespace2, match="foobar\\s"): ... 44 | with pytest.raises(NonWhitespace2, match="foobar\\S"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 45 | with pytest.raises(WordCharacter2, match="foobar\\w"): ... 46 | with pytest.raises(NonWordCharacter2, match="foobar\\W"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:45:46: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:45:46 | 43 | with pytest.raises(Whitespace2, match="foobar\\s"): ... 44 | with pytest.raises(NonWhitespace2, match="foobar\\S"): ... 45 | with pytest.raises(WordCharacter2, match="foobar\\w"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 46 | with pytest.raises(NonWordCharacter2, match="foobar\\W"): ... 47 | with pytest.raises(EndOfInput2, match="foobar\\z"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:46:49: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:46:49 | 44 | with pytest.raises(NonWhitespace2, match="foobar\\S"): ... 45 | with pytest.raises(WordCharacter2, match="foobar\\w"): ... 46 | with pytest.raises(NonWordCharacter2, match="foobar\\W"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ 47 | with pytest.raises(EndOfInput2, match="foobar\\z"): ... | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:47:43: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:47:43 | 45 | with pytest.raises(WordCharacter2, match="foobar\\w"): ... 46 | with pytest.raises(NonWordCharacter2, match="foobar\\W"): ... 47 | with pytest.raises(EndOfInput2, match="foobar\\z"): ... - | ^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^ | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit -RUF043.py:52:42: RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw +RUF043 Pattern passed to `match=` contains metacharacters but is neither escaped nor raw + --> RUF043.py:52:42 | 50 | ### Acceptable false positives 51 | 52 | with pytest.raises(NameEscape, match="\\N{EN DASH}"): ... - | ^^^^^^^^^^^^^^ RUF043 + | ^^^^^^^^^^^^^^ | - = help: Use a raw string or `re.escape()` to make the intention explicit +help: Use a raw string or `re.escape()` to make the intention explicit diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF045_RUF045.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF045_RUF045.py.snap index 5e1aa23b88..21a9178d39 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF045_RUF045.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF045_RUF045.py.snap @@ -1,34 +1,37 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF045.py:8:5: RUF045 Assignment without annotation found in dataclass body +RUF045 Assignment without annotation found in dataclass body + --> RUF045.py:8:5 | 6 | class C: 7 | # Errors 8 | no_annotation = r"foo" - | ^^^^^^^^^^^^^ RUF045 + | ^^^^^^^^^^^^^ 9 | missing = MISSING 10 | field = field() | - = help: Use `ClassVar[...]` +help: Use `ClassVar[...]` -RUF045.py:9:5: RUF045 Assignment without annotation found in dataclass body +RUF045 Assignment without annotation found in dataclass body + --> RUF045.py:9:5 | 7 | # Errors 8 | no_annotation = r"foo" 9 | missing = MISSING - | ^^^^^^^ RUF045 + | ^^^^^^^ 10 | field = field() | - = help: Use `ClassVar[...]` +help: Use `ClassVar[...]` -RUF045.py:10:5: RUF045 Assignment without annotation found in dataclass body +RUF045 Assignment without annotation found in dataclass body + --> RUF045.py:10:5 | 8 | no_annotation = r"foo" 9 | missing = MISSING 10 | field = field() - | ^^^^^ RUF045 + | ^^^^^ 11 | 12 | # No errors | - = help: Use `ClassVar[...]` +help: Use `ClassVar[...]` diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF054_RUF054.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF054_RUF054.py.snap index 923c20e32f..26ed4fcb97 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF054_RUF054.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF054_RUF054.py.snap @@ -1,39 +1,43 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF054.py:8:2: RUF054 Indented form feed +RUF054 Indented form feed + --> RUF054.py:8:2 | 6 | # Errors 7 | 8 | - | ^ RUF054 + | ^ | - = help: Remove form feed +help: Remove form feed -RUF054.py:10:3: RUF054 Indented form feed +RUF054 Indented form feed + --> RUF054.py:10:3 | 10 | - | ^ RUF054 + | ^ 11 | 12 | def _(): | - = help: Remove form feed +help: Remove form feed -RUF054.py:13:2: RUF054 Indented form feed +RUF054 Indented form feed + --> RUF054.py:13:2 | 12 | def _(): 13 | pass - | ^ RUF054 + | ^ 14 | 15 | if False: | - = help: Remove form feed +help: Remove form feed -RUF054.py:17:5: RUF054 Indented form feed +RUF054 Indented form feed + --> RUF054.py:17:5 | 15 | if False: 16 | print('F') 17 | print('T') - | ^ RUF054 + | ^ | - = help: Remove form feed +help: Remove form feed diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_0.py.snap index 0ea320d36a..7c6ff021da 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_0.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_0.py.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF055_0.py:6:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:6:1 | 5 | # this should be replaced with `s.replace("abc", "")` 6 | re.sub("abc", "", s) - | ^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `s.replace("abc", "")` +help: Replace with `s.replace("abc", "")` ℹ Safe fix 3 3 | s = "str" @@ -19,16 +20,17 @@ RUF055_0.py:6:1: RUF055 [*] Plain string pattern passed to `re` function 8 8 | 9 9 | # this example, adapted from https://docs.python.org/3/library/re.html#re.sub, -RUF055_0.py:22:4: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:22:4 | 20 | # this one should be replaced with `s.startswith("abc")` because the Match is 21 | # used in an if context for its truth value 22 | if re.match("abc", s): - | ^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^ 23 | pass 24 | if m := re.match("abc", s): # this should *not* be replaced | - = help: Replace with `s.startswith("abc")` +help: Replace with `s.startswith("abc")` ℹ Safe fix 19 19 | @@ -40,15 +42,16 @@ RUF055_0.py:22:4: RUF055 [*] Plain string pattern passed to `re` function 24 24 | if m := re.match("abc", s): # this should *not* be replaced 25 25 | pass -RUF055_0.py:29:4: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:29:4 | 28 | # this should be replaced with `"abc" in s` 29 | if re.search("abc", s): - | ^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^ 30 | pass 31 | re.search("abc", s) # this should not be replaced | - = help: Replace with `"abc" in s` +help: Replace with `"abc" in s` ℹ Safe fix 26 26 | re.match("abc", s) # this should not be replaced because match returns a Match @@ -60,15 +63,16 @@ RUF055_0.py:29:4: RUF055 [*] Plain string pattern passed to `re` function 31 31 | re.search("abc", s) # this should not be replaced 32 32 | -RUF055_0.py:34:4: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:34:4 | 33 | # this should be replaced with `"abc" == s` 34 | if re.fullmatch("abc", s): - | ^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^ 35 | pass 36 | re.fullmatch("abc", s) # this should not be replaced | - = help: Replace with `s == "abc"` +help: Replace with `s == "abc"` ℹ Safe fix 31 31 | re.search("abc", s) # this should not be replaced @@ -80,15 +84,16 @@ RUF055_0.py:34:4: RUF055 [*] Plain string pattern passed to `re` function 36 36 | re.fullmatch("abc", s) # this should not be replaced 37 37 | -RUF055_0.py:39:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:39:1 | 38 | # this should be replaced with `s.split("abc")` 39 | re.split("abc", s) - | ^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^ 40 | 41 | # these currently should not be modified because the patterns contain regex | - = help: Replace with `s.split("abc")` +help: Replace with `s.split("abc")` ℹ Safe fix 36 36 | re.fullmatch("abc", s) # this should not be replaced @@ -100,7 +105,8 @@ RUF055_0.py:39:1: RUF055 [*] Plain string pattern passed to `re` function 41 41 | # these currently should not be modified because the patterns contain regex 42 42 | # metacharacters -RUF055_0.py:71:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:71:1 | 70 | # this should trigger an unsafe fix because of the presence of comments 71 | / re.sub( @@ -110,11 +116,11 @@ RUF055_0.py:71:1: RUF055 [*] Plain string pattern passed to `re` function 75 | | "", 76 | | s, # string 77 | | ) - | |_^ RUF055 + | |_^ 78 | 79 | # A diagnostic should not be emitted for `sub` replacements with backreferences or | - = help: Replace with `s.replace("abc", "")` +help: Replace with `s.replace("abc", "")` ℹ Unsafe fix 68 68 | re.split("abc", s, maxsplit=2) @@ -132,16 +138,17 @@ RUF055_0.py:71:1: RUF055 [*] Plain string pattern passed to `re` function 79 73 | # A diagnostic should not be emitted for `sub` replacements with backreferences or 80 74 | # most other ASCII escapes -RUF055_0.py:89:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:89:1 | 87 | # *not* `some_string.replace("a", "\\n")`. 88 | # We currently emit diagnostics for some of these without fixing them. 89 | re.sub(r"a", "\n", "a") - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^ 90 | re.sub(r"a", r"\n", "a") 91 | re.sub(r"a", "\a", "a") | - = help: Replace with `"a".replace(r"a", "\n")` +help: Replace with `"a".replace(r"a", "\n")` ℹ Safe fix 86 86 | # `re.sub(r"a", r"\n", some_string)` is fixed to `some_string.replace("a", "\n")` @@ -153,25 +160,27 @@ RUF055_0.py:89:1: RUF055 [*] Plain string pattern passed to `re` function 91 91 | re.sub(r"a", "\a", "a") 92 92 | re.sub(r"a", r"\a", "a") -RUF055_0.py:90:1: RUF055 Plain string pattern passed to `re` function +RUF055 Plain string pattern passed to `re` function + --> RUF055_0.py:90:1 | 88 | # We currently emit diagnostics for some of these without fixing them. 89 | re.sub(r"a", "\n", "a") 90 | re.sub(r"a", r"\n", "a") - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 91 | re.sub(r"a", "\a", "a") 92 | re.sub(r"a", r"\a", "a") | -RUF055_0.py:91:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:91:1 | 89 | re.sub(r"a", "\n", "a") 90 | re.sub(r"a", r"\n", "a") 91 | re.sub(r"a", "\a", "a") - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^ 92 | re.sub(r"a", r"\a", "a") | - = help: Replace with `"a".replace(r"a", "\x07")` +help: Replace with `"a".replace(r"a", "\x07")` ℹ Safe fix 88 88 | # We currently emit diagnostics for some of these without fixing them. @@ -183,25 +192,27 @@ RUF055_0.py:91:1: RUF055 [*] Plain string pattern passed to `re` function 93 93 | 94 94 | re.sub(r"a", "\?", "a") -RUF055_0.py:92:1: RUF055 Plain string pattern passed to `re` function +RUF055 Plain string pattern passed to `re` function + --> RUF055_0.py:92:1 | 90 | re.sub(r"a", r"\n", "a") 91 | re.sub(r"a", "\a", "a") 92 | re.sub(r"a", r"\a", "a") - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 93 | 94 | re.sub(r"a", "\?", "a") | -RUF055_0.py:94:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:94:1 | 92 | re.sub(r"a", r"\a", "a") 93 | 94 | re.sub(r"a", "\?", "a") - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^ 95 | re.sub(r"a", r"\?", "a") | - = help: Replace with `"a".replace(r"a", "\\?")` +help: Replace with `"a".replace(r"a", "\\?")` ℹ Safe fix 91 91 | re.sub(r"a", "\a", "a") @@ -213,15 +224,16 @@ RUF055_0.py:94:1: RUF055 [*] Plain string pattern passed to `re` function 96 96 | 97 97 | # these double as tests for preserving raw string quoting style -RUF055_0.py:95:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:95:1 | 94 | re.sub(r"a", "\?", "a") 95 | re.sub(r"a", r"\?", "a") - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 96 | 97 | # these double as tests for preserving raw string quoting style | - = help: Replace with `"a".replace(r"a", r"\?")` +help: Replace with `"a".replace(r"a", r"\?")` ℹ Safe fix 92 92 | re.sub(r"a", r"\a", "a") @@ -233,15 +245,16 @@ RUF055_0.py:95:1: RUF055 [*] Plain string pattern passed to `re` function 97 97 | # these double as tests for preserving raw string quoting style 98 98 | re.sub(r'abc', "", s) -RUF055_0.py:98:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:98:1 | 97 | # these double as tests for preserving raw string quoting style 98 | re.sub(r'abc', "", s) - | ^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^ 99 | re.sub(r"""abc""", "", s) 100 | re.sub(r'''abc''', "", s) | - = help: Replace with `s.replace(r'abc', "")` +help: Replace with `s.replace(r'abc', "")` ℹ Safe fix 95 95 | re.sub(r"a", r"\?", "a") @@ -252,15 +265,16 @@ RUF055_0.py:98:1: RUF055 [*] Plain string pattern passed to `re` function 99 99 | re.sub(r"""abc""", "", s) 100 100 | re.sub(r'''abc''', "", s) -RUF055_0.py:99:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:99:1 | 97 | # these double as tests for preserving raw string quoting style 98 | re.sub(r'abc', "", s) 99 | re.sub(r"""abc""", "", s) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ 100 | re.sub(r'''abc''', "", s) | - = help: Replace with `s.replace(r"""abc""", "")` +help: Replace with `s.replace(r"""abc""", "")` ℹ Safe fix 96 96 | @@ -270,14 +284,15 @@ RUF055_0.py:99:1: RUF055 [*] Plain string pattern passed to `re` function 99 |+s.replace(r"""abc""", "") 100 100 | re.sub(r'''abc''', "", s) -RUF055_0.py:100:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_0.py:100:1 | 98 | re.sub(r'abc', "", s) 99 | re.sub(r"""abc""", "", s) 100 | re.sub(r'''abc''', "", s) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `s.replace(r'''abc''', "")` +help: Replace with `s.replace(r'''abc''', "")` ℹ Safe fix 97 97 | # these double as tests for preserving raw string quoting style diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_1.py.snap index cf97bd8909..3fcd0eaaa2 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_1.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_1.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF055_1.py:9:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_1.py:9:1 | 7 | pat1 = "needle" 8 | 9 | re.sub(pat1, "", haystack) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 10 | 11 | # aliases are not followed, so this one should not trigger the rule | - = help: Replace with `haystack.replace(pat1, "")` +help: Replace with `haystack.replace(pat1, "")` ℹ Safe fix 6 6 | @@ -22,14 +23,15 @@ RUF055_1.py:9:1: RUF055 [*] Plain string pattern passed to `re` function 11 11 | # aliases are not followed, so this one should not trigger the rule 12 12 | if pat4 := pat1: -RUF055_1.py:17:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_1.py:17:1 | 15 | # also works for the `repl` argument in sub 16 | repl = "new" 17 | re.sub(r"abc", repl, haystack) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `haystack.replace(r"abc", repl)` +help: Replace with `haystack.replace(r"abc", repl)` ℹ Safe fix 14 14 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_2.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_2.py.snap index b2d2b8017c..3c04d2be38 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_2.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_2.py.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF055_2.py:7:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_2.py:7:1 | 6 | # this should be replaced with `"abc" not in s` 7 | re.search("abc", s) is None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `"abc" not in s` +help: Replace with `"abc" not in s` ℹ Safe fix 4 4 | s = "str" @@ -20,13 +20,14 @@ RUF055_2.py:7:1: RUF055 [*] Plain string pattern passed to `re` function 9 9 | 10 10 | # this should be replaced with `"abc" in s` -RUF055_2.py:11:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_2.py:11:1 | 10 | # this should be replaced with `"abc" in s` 11 | re.search("abc", s) is not None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `"abc" in s` +help: Replace with `"abc" in s` ℹ Safe fix 8 8 | @@ -38,13 +39,14 @@ RUF055_2.py:11:1: RUF055 [*] Plain string pattern passed to `re` function 13 13 | 14 14 | # this should be replaced with `not s.startswith("abc")` -RUF055_2.py:15:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_2.py:15:1 | 14 | # this should be replaced with `not s.startswith("abc")` 15 | re.match("abc", s) is None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `not s.startswith("abc")` +help: Replace with `not s.startswith("abc")` ℹ Safe fix 12 12 | @@ -56,13 +58,14 @@ RUF055_2.py:15:1: RUF055 [*] Plain string pattern passed to `re` function 17 17 | 18 18 | # this should be replaced with `s.startswith("abc")` -RUF055_2.py:19:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_2.py:19:1 | 18 | # this should be replaced with `s.startswith("abc")` 19 | re.match("abc", s) is not None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `s.startswith("abc")` +help: Replace with `s.startswith("abc")` ℹ Safe fix 16 16 | @@ -74,13 +77,14 @@ RUF055_2.py:19:1: RUF055 [*] Plain string pattern passed to `re` function 21 21 | 22 22 | # this should be replaced with `s != "abc"` -RUF055_2.py:23:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_2.py:23:1 | 22 | # this should be replaced with `s != "abc"` 23 | re.fullmatch("abc", s) is None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `s != "abc"` +help: Replace with `s != "abc"` ℹ Safe fix 20 20 | @@ -92,13 +96,14 @@ RUF055_2.py:23:1: RUF055 [*] Plain string pattern passed to `re` function 25 25 | 26 26 | # this should be replaced with `s == "abc"` -RUF055_2.py:27:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_2.py:27:1 | 26 | # this should be replaced with `s == "abc"` 27 | re.fullmatch("abc", s) is not None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `s == "abc"` +help: Replace with `s == "abc"` ℹ Safe fix 24 24 | @@ -110,7 +115,8 @@ RUF055_2.py:27:1: RUF055 [*] Plain string pattern passed to `re` function 29 29 | 30 30 | # this should trigger an unsafe fix because of the presence of a comment within the -RUF055_2.py:33:5: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_2.py:33:5 | 31 | # expression being replaced (which we'd lose) 32 | if ( @@ -120,11 +126,11 @@ RUF055_2.py:33:5: RUF055 [*] Plain string pattern passed to `re` function 36 | | ) 37 | | # with a comment here 38 | | is None - | |___________^ RUF055 + | |___________^ 39 | ): 40 | pass | - = help: Replace with `s != "a really really really really long string"` +help: Replace with `s != "a really really really really long string"` ℹ Unsafe fix 30 30 | # this should trigger an unsafe fix because of the presence of a comment within the @@ -141,7 +147,8 @@ RUF055_2.py:33:5: RUF055 [*] Plain string pattern passed to `re` function 40 35 | pass 41 36 | -RUF055_2.py:46:5: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_2.py:46:5 | 44 | # expression) 45 | if ( # leading @@ -150,11 +157,11 @@ RUF055_2.py:46:5: RUF055 [*] Plain string pattern passed to `re` function 48 | | s, 49 | | ) 50 | | is None # trailing - | |___________^ RUF055 + | |___________^ 51 | ): 52 | pass | - = help: Replace with `s != "a really really really really long string"` +help: Replace with `s != "a really really really really long string"` ℹ Safe fix 43 43 | # this should trigger a safe fix (comments are preserved given they're outside the diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_3.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_3.py.snap index f14d70c98e..f89aacd212 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_3.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__RUF055_RUF055_3.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF055_3.py:6:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_3.py:6:1 | 5 | # Should be replaced with `b_src.replace(rb"x", b"y")` 6 | re.sub(rb"x", b"y", b_src) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | 8 | # Should be replaced with `b_src.startswith(rb"abc")` | - = help: Replace with `b_src.replace(rb"x", b"y")` +help: Replace with `b_src.replace(rb"x", b"y")` ℹ Safe fix 3 3 | b_src = b"abc" @@ -21,14 +22,15 @@ RUF055_3.py:6:1: RUF055 [*] Plain string pattern passed to `re` function 8 8 | # Should be replaced with `b_src.startswith(rb"abc")` 9 9 | if re.match(rb"abc", b_src): -RUF055_3.py:9:4: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_3.py:9:4 | 8 | # Should be replaced with `b_src.startswith(rb"abc")` 9 | if re.match(rb"abc", b_src): - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 10 | pass | - = help: Replace with `b_src.startswith(rb"abc")` +help: Replace with `b_src.startswith(rb"abc")` ℹ Safe fix 6 6 | re.sub(rb"x", b"y", b_src) @@ -40,14 +42,15 @@ RUF055_3.py:9:4: RUF055 [*] Plain string pattern passed to `re` function 11 11 | 12 12 | # Should be replaced with `rb"x" in b_src` -RUF055_3.py:13:4: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_3.py:13:4 | 12 | # Should be replaced with `rb"x" in b_src` 13 | if re.search(rb"x", b_src): - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^ 14 | pass | - = help: Replace with `rb"x" in b_src` +help: Replace with `rb"x" in b_src` ℹ Safe fix 10 10 | pass @@ -59,15 +62,16 @@ RUF055_3.py:13:4: RUF055 [*] Plain string pattern passed to `re` function 15 15 | 16 16 | # Should be replaced with `b_src.split(rb"abc")` -RUF055_3.py:17:1: RUF055 [*] Plain string pattern passed to `re` function +RUF055 [*] Plain string pattern passed to `re` function + --> RUF055_3.py:17:1 | 16 | # Should be replaced with `b_src.split(rb"abc")` 17 | re.split(rb"abc", b_src) - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF055 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | # Patterns containing metacharacters should NOT be replaced | - = help: Replace with `b_src.split(rb"abc")` +help: Replace with `b_src.split(rb"abc")` ℹ Safe fix 14 14 | pass diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__py37__RUF039_RUF039_py_version_sensitive.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__py37__RUF039_RUF039_py_version_sensitive.py.snap index 678c954a1f..58f3127ce7 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__py37__RUF039_RUF039_py_version_sensitive.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__py37__RUF039_RUF039_py_version_sensitive.py.snap @@ -1,11 +1,12 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF039_py_version_sensitive.py:3:12: RUF039 First argument to `re.compile()` is not raw string +RUF039 First argument to `re.compile()` is not raw string + --> RUF039_py_version_sensitive.py:3:12 | 1 | import re 2 | 3 | re.compile("\N{Partial Differential}") # with unsafe fix if python target is 3.8 or higher, else without fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with raw string +help: Replace with raw string diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__py38__RUF039_RUF039_py_version_sensitive.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__py38__RUF039_RUF039_py_version_sensitive.py.snap index 8bffea70b3..556b134748 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__py38__RUF039_RUF039_py_version_sensitive.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview__py38__RUF039_RUF039_py_version_sensitive.py.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF039_py_version_sensitive.py:3:12: RUF039 [*] First argument to `re.compile()` is not raw string +RUF039 [*] First argument to `re.compile()` is not raw string + --> RUF039_py_version_sensitive.py:3:12 | 1 | import re 2 | 3 | re.compile("\N{Partial Differential}") # with unsafe fix if python target is 3.8 or higher, else without fix - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF039 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with raw string +help: Replace with raw string ℹ Unsafe fix 1 1 | import re diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview_confusables.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview_confusables.snap index be9d27b76f..d9c235de30 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview_confusables.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__preview_confusables.snap @@ -1,189 +1,210 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -confusables.py:1:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:1:6 | 1 | x = "𝐁ad string" - | ^ RUF001 + | ^ 2 | y = "−" | -confusables.py:6:56: RUF002 Docstring contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? +RUF002 Docstring contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? + --> confusables.py:6:56 | 5 | def f(): 6 | """Here's a docstring with an unusual parenthesis: )""" - | ^^ RUF002 + | ^^ 7 | # And here's a comment with an unusual punctuation mark: ᜵ 8 | ... | -confusables.py:7:62: RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? +RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? + --> confusables.py:7:62 | 5 | def f(): 6 | """Here's a docstring with an unusual parenthesis: )""" 7 | # And here's a comment with an unusual punctuation mark: ᜵ - | ^ RUF003 + | ^ 8 | ... | -confusables.py:17:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:17:6 | 17 | x = "𝐁ad string" - | ^ RUF001 + | ^ 18 | x = "−" | -confusables.py:26:10: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? +RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? + --> confusables.py:26:10 | 24 | # The first word should be ignored, while the second should be included, since it 25 | # contains ASCII. 26 | x = "βα Bαd" - | ^ RUF001 + | ^ 27 | 28 | # The two characters should be flagged here. The first character is a "word" | -confusables.py:31:6: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? +RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? + --> confusables.py:31:6 | 29 | # consisting of a single ambiguous character, while the second character is a "word 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" - | ^ RUF001 + | ^ 32 | 33 | # Same test cases as above but using f-strings instead: | -confusables.py:31:7: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + --> confusables.py:31:7 | 29 | # consisting of a single ambiguous character, while the second character is a "word 30 | # boundary" (whitespace) that it itself ambiguous. 31 | x = "Р усский" - | ^ RUF001 + | ^ 32 | 33 | # Same test cases as above but using f-strings instead: | -confusables.py:34:7: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:34:7 | 33 | # Same test cases as above but using f-strings instead: 34 | x = f"𝐁ad string" - | ^ RUF001 + | ^ 35 | x = f"−" 36 | x = f"Русский" | -confusables.py:37:11: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? +RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? + --> confusables.py:37:11 | 35 | x = f"−" 36 | x = f"Русский" 37 | x = f"βα Bαd" - | ^ RUF001 + | ^ 38 | x = f"Р усский" | -confusables.py:38:7: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? +RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? + --> confusables.py:38:7 | 36 | x = f"Русский" 37 | x = f"βα Bαd" 38 | x = f"Р усский" - | ^ RUF001 + | ^ 39 | 40 | # Nested f-strings | -confusables.py:38:8: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + --> confusables.py:38:8 | 36 | x = f"Русский" 37 | x = f"βα Bαd" 38 | x = f"Р усский" - | ^ RUF001 + | ^ 39 | 40 | # Nested f-strings | -confusables.py:41:7: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:41:7 | 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" - | ^ RUF001 + | ^ 42 | 43 | # Comments inside f-strings | -confusables.py:41:21: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + --> confusables.py:41:21 | 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" - | ^ RUF001 + | ^ 42 | 43 | # Comments inside f-strings | -confusables.py:41:25: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? +RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? + --> confusables.py:41:25 | 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" - | ^ RUF001 + | ^ 42 | 43 | # Comments inside f-strings | -confusables.py:41:26: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? +RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + --> confusables.py:41:26 | 40 | # Nested f-strings 41 | x = f"𝐁ad string {f" {f"Р усский"}"}" - | ^ RUF001 + | ^ 42 | 43 | # Comments inside f-strings | -confusables.py:44:68: RUF003 Comment contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? +RUF003 Comment contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? + --> confusables.py:44:68 | 43 | # Comments inside f-strings 44 | x = f"string { # And here's a comment with an unusual parenthesis: ) - | ^^ RUF003 + | ^^ 45 | # And here's a comment with a greek alpha: ∗ 46 | foo # And here's a comment with an unusual punctuation mark: ᜵ | -confusables.py:46:62: RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? +RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? + --> confusables.py:46:62 | 44 | x = f"string { # And here's a comment with an unusual parenthesis: ) 45 | # And here's a comment with a greek alpha: ∗ 46 | foo # And here's a comment with an unusual punctuation mark: ᜵ - | ^ RUF003 + | ^ 47 | }" | -confusables.py:55:28: RUF001 String contains ambiguous `µ` (MICRO SIGN). Did you mean `μ` (GREEK SMALL LETTER MU)? +RUF001 String contains ambiguous `µ` (MICRO SIGN). Did you mean `μ` (GREEK SMALL LETTER MU)? + --> confusables.py:55:28 | 55 | assert getattr(Labware(), "µL") == 1.5 - | ^ RUF001 + | ^ 56 | 57 | # Implicit string concatenation | -confusables.py:58:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:58:6 | 57 | # Implicit string concatenation 58 | x = "𝐁ad" f"𝐁ad string" - | ^ RUF001 + | ^ 59 | 60 | from typing import Literal | -confusables.py:58:13: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? +RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + --> confusables.py:58:13 | 57 | # Implicit string concatenation 58 | x = "𝐁ad" f"𝐁ad string" - | ^ RUF001 + | ^ 59 | 60 | from typing import Literal | -confusables.py:61:20: RUF001 String contains ambiguous `ﮨ` (ARABIC LETTER HEH GOAL INITIAL FORM). Did you mean `o` (LATIN SMALL LETTER O)? +RUF001 String contains ambiguous `ﮨ` (ARABIC LETTER HEH GOAL INITIAL FORM). Did you mean `o` (LATIN SMALL LETTER O)? + --> confusables.py:61:20 | 60 | from typing import Literal 61 | x: '''"""'Literal["ﮨ"]'"""''' - | ^ RUF001 + | ^ | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__py314__RUF058_RUF058_2.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__py314__RUF058_RUF058_2.py.snap index e0ca17a67d..8128f18880 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__py314__RUF058_RUF058_2.py.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__py314__RUF058_RUF058_2.py.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF058_2.py:5:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_2.py:5:1 | 4 | # Errors in Python 3.14+ 5 | starmap(func, zip(a, b, c, strict=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF058 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | starmap(func, zip(a, b, c, strict=False)) 7 | starmap(func, zip(a, b, c, strict=strict)) | - = help: Use `map` instead +help: Use `map` instead ℹ Safe fix 2 2 | import itertools @@ -21,15 +22,16 @@ RUF058_2.py:5:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 7 7 | starmap(func, zip(a, b, c, strict=strict)) 8 8 | -RUF058_2.py:6:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_2.py:6:1 | 4 | # Errors in Python 3.14+ 5 | starmap(func, zip(a, b, c, strict=True)) 6 | starmap(func, zip(a, b, c, strict=False)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF058 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7 | starmap(func, zip(a, b, c, strict=strict)) | - = help: Use `map` instead +help: Use `map` instead ℹ Safe fix 3 3 | @@ -41,14 +43,15 @@ RUF058_2.py:6:1: RUF058 [*] `itertools.starmap` called on `zip` iterable 8 8 | 9 9 | -RUF058_2.py:7:1: RUF058 [*] `itertools.starmap` called on `zip` iterable +RUF058 [*] `itertools.starmap` called on `zip` iterable + --> RUF058_2.py:7:1 | 5 | starmap(func, zip(a, b, c, strict=True)) 6 | starmap(func, zip(a, b, c, strict=False)) 7 | starmap(func, zip(a, b, c, strict=strict)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF058 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `map` instead +help: Use `map` instead ℹ Safe fix 4 4 | # Errors in Python 3.14+ diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap index b4fc07e49e..7dae78024e 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_0.py:9:12 | 8 | # Invalid 9 | c = 1 # noqa - | ^^^^^^ RUF100 + | ^^^^^^ 10 | print(c) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 6 6 | b = 2 # noqa: F841 @@ -20,15 +21,16 @@ RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive 11 11 | 12 12 | # Invalid -RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_0.py:13:12 | 12 | # Invalid 13 | d = 1 # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 14 | 15 | # Invalid | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 10 10 | print(c) @@ -40,15 +42,16 @@ RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 15 15 | # Invalid 16 16 | d = 1 # noqa: F841, E501 -RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) +RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) + --> RUF100_0.py:16:12 | 15 | # Invalid 16 | d = 1 # noqa: F841, E501 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 17 | 18 | # Invalid (and unimplemented or not enabled) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 13 13 | d = 1 # noqa: E501 @@ -60,15 +63,16 @@ RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) 18 18 | # Invalid (and unimplemented or not enabled) 19 19 | d = 1 # noqa: F841, W191, F821 -RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; non-enabled: `F821`) +RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; non-enabled: `F821`) + --> RUF100_0.py:19:12 | 18 | # Invalid (and unimplemented or not enabled) 19 | d = 1 # noqa: F841, W191, F821 - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | # Invalid (but external) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 16 16 | d = 1 # noqa: F841, E501 @@ -80,15 +84,16 @@ RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; n 21 21 | # Invalid (but external) 22 22 | d = 1 # noqa: F841, V101 -RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) +RUF100 [*] Unused `noqa` directive (unused: `F841`) + --> RUF100_0.py:22:12 | 21 | # Invalid (but external) 22 | d = 1 # noqa: F841, V101 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 23 | 24 | # Invalid (but external) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 19 19 | d = 1 # noqa: F841, W191, F821 @@ -100,15 +105,16 @@ RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) 24 24 | # Invalid (but external) 25 25 | d = 1 # noqa: V500 -RUF100_0.py:25:12: RUF100 [*] Unused `noqa` directive (unknown: `V500`) +RUF100 [*] Unused `noqa` directive (unknown: `V500`) + --> RUF100_0.py:25:12 | 24 | # Invalid (but external) 25 | d = 1 # noqa: V500 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 26 | 27 | # fmt: off | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 22 22 | d = 1 # noqa: F841, V101 @@ -120,16 +126,17 @@ RUF100_0.py:25:12: RUF100 [*] Unused `noqa` directive (unknown: `V500`) 27 27 | # fmt: off 28 28 | # Invalid - no space before # -RUF100_0.py:29:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_0.py:29:12 | 27 | # fmt: off 28 | # Invalid - no space before # 29 | d = 1 # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 30 | 31 | # Invalid - many spaces before # | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 26 26 | @@ -141,14 +148,15 @@ RUF100_0.py:29:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 31 31 | # Invalid - many spaces before # 32 32 | d = 1 # noqa: E501 -RUF100_0.py:32:5: F841 [*] Local variable `d` is assigned to but never used +F841 [*] Local variable `d` is assigned to but never used + --> RUF100_0.py:32:5 | 31 | # Invalid - many spaces before # 32 | d = 1 # noqa: E501 - | ^ F841 + | ^ 33 | # fmt: on | - = help: Remove assignment to unused variable `d` +help: Remove assignment to unused variable `d` ℹ Unsafe fix 29 29 | d = 1 # noqa: E501 @@ -159,14 +167,15 @@ RUF100_0.py:32:5: F841 [*] Local variable `d` is assigned to but never used 34 33 | 35 34 | -RUF100_0.py:32:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_0.py:32:12 | 31 | # Invalid - many spaces before # 32 | d = 1 # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 33 | # fmt: on | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 29 29 | d = 1 # noqa: E501 @@ -178,15 +187,16 @@ RUF100_0.py:32:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 34 34 | 35 35 | -RUF100_0.py:58:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) +RUF100 [*] Unused `noqa` directive (unused: `F841`) + --> RUF100_0.py:58:6 | 57 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 58 | """ # noqa: E501, F841 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 59 | 60 | # Invalid | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 55 55 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 @@ -198,15 +208,16 @@ RUF100_0.py:58:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) 60 60 | # Invalid 61 61 | _ = """Lorem ipsum dolor sit amet. -RUF100_0.py:66:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_0.py:66:6 | 65 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. 66 | """ # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 67 | 68 | # Invalid | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 63 63 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 @@ -218,15 +229,16 @@ RUF100_0.py:66:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) 68 68 | # Invalid 69 69 | _ = """Lorem ipsum dolor sit amet. -RUF100_0.py:74:6: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_0.py:74:6 | 73 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. 74 | """ # noqa - | ^^^^^^ RUF100 + | ^^^^^^ 75 | 76 | # Valid | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 71 71 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 @@ -238,15 +250,16 @@ RUF100_0.py:74:6: RUF100 [*] Unused blanket `noqa` directive 76 76 | # Valid 77 77 | # this is a veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy long comment # noqa: E501 -RUF100_0.py:88:8: F401 [*] `shelve` imported but unused +F401 [*] `shelve` imported but unused + --> RUF100_0.py:88:8 | 86 | import collections # noqa 87 | import os # noqa: F401, RUF100 88 | import shelve # noqa: RUF100 - | ^^^^^^ F401 + | ^^^^^^ 89 | import sys # noqa: F401, RUF100 | - = help: Remove unused import: `shelve` +help: Remove unused import: `shelve` ℹ Safe fix 85 85 | @@ -257,22 +270,24 @@ RUF100_0.py:88:8: F401 [*] `shelve` imported but unused 90 89 | 91 90 | print(sys.path) -RUF100_0.py:93:89: E501 Line too long (89 > 88) +E501 Line too long (89 > 88) + --> RUF100_0.py:93:89 | 91 | print(sys.path) 92 | 93 | "shape: (6,)\nSeries: '' [duration[μs]]\n[\n\t0µs\n\t1µs\n\t2µs\n\t3µs\n\t4µs\n\t5µs\n]" # noqa: F401 - | ^ E501 + | ^ | -RUF100_0.py:93:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) +RUF100 [*] Unused `noqa` directive (unused: `F401`) + --> RUF100_0.py:93:92 | 91 | print(sys.path) 92 | 93 | "shape: (6,)\nSeries: '' [duration[μs]]\n[\n\t0µs\n\t1µs\n\t2µs\n\t3µs\n\t4µs\n\t5µs\n]" # noqa: F401 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 90 90 | @@ -284,15 +299,16 @@ RUF100_0.py:93:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) 95 95 | 96 96 | def f(): -RUF100_0.py:107:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) +RUF100 [*] Unused `noqa` directive (unknown: `E50`) + --> RUF100_0.py:107:12 | 105 | def f(): 106 | # Invalid - nonexistent error code with multibyte character 107 | d = 1 # …noqa: F841, E50 - | ^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^ 108 | e = 1 # …noqa: E50 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 104 104 | @@ -304,14 +320,15 @@ RUF100_0.py:107:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) 109 109 | 110 110 | -RUF100_0.py:108:5: F841 [*] Local variable `e` is assigned to but never used +F841 [*] Local variable `e` is assigned to but never used + --> RUF100_0.py:108:5 | 106 | # Invalid - nonexistent error code with multibyte character 107 | d = 1 # …noqa: F841, E50 108 | e = 1 # …noqa: E50 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `e` +help: Remove assignment to unused variable `e` ℹ Unsafe fix 105 105 | def f(): @@ -322,14 +339,15 @@ RUF100_0.py:108:5: F841 [*] Local variable `e` is assigned to but never used 110 109 | 111 110 | def f(): -RUF100_0.py:108:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) +RUF100 [*] Unused `noqa` directive (unknown: `E50`) + --> RUF100_0.py:108:12 | 106 | # Invalid - nonexistent error code with multibyte character 107 | d = 1 # …noqa: F841, E50 108 | e = 1 # …noqa: E50 - | ^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 105 105 | def f(): @@ -341,16 +359,17 @@ RUF100_0.py:108:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) 110 110 | 111 111 | def f(): -RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unknown: `X200`) +RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unknown: `X200`) + --> RUF100_0.py:118:12 | 116 | # Check duplicate code detection 117 | def f(): 118 | x = 2 # noqa: F841, F841, X200 - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 119 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 115 115 | @@ -362,16 +381,17 @@ RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unkn 120 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 121 121 | -RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `SIM300`) +RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `SIM300`) + --> RUF100_0.py:120:19 | 118 | x = 2 # noqa: F841, F841, X200 119 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 121 | 122 | z = 2 # noqa: F841 F841 F841, F841, F841 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 117 117 | def f(): @@ -383,16 +403,17 @@ RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `S 122 122 | z = 2 # noqa: F841 F841 F841, F841, F841 123 123 | -RUF100_0.py:122:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F841`, `F841`, `F841`) +RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F841`, `F841`, `F841`) + --> RUF100_0.py:122:12 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 121 | 122 | z = 2 # noqa: F841 F841 F841, F841, F841 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 123 | 124 | return | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 119 119 | @@ -404,16 +425,17 @@ RUF100_0.py:122:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F84 124 124 | return 125 125 | -RUF100_0.py:129:20: RUF100 [*] Unused `noqa` directive (duplicated: `S307`, `S307`, `S307`) +RUF100 [*] Unused `noqa` directive (duplicated: `S307`, `S307`, `S307`) + --> RUF100_0.py:129:20 | 127 | # Allow code redirects 128 | x = eval(command) # noqa: PGH001, S307 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 130 | x = eval(command) # noqa: PGH001, S307, PGH001 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 126 126 | @@ -424,15 +446,16 @@ RUF100_0.py:129:20: RUF100 [*] Unused `noqa` directive (duplicated: `S307`, `S30 130 130 | x = eval(command) # noqa: PGH001, S307, PGH001 131 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 -RUF100_0.py:130:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`) +RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`) + --> RUF100_0.py:130:20 | 128 | x = eval(command) # noqa: PGH001, S307 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 130 | x = eval(command) # noqa: PGH001, S307, PGH001 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 127 127 | # Allow code redirects @@ -442,14 +465,15 @@ RUF100_0.py:130:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`) 130 |+x = eval(command) # noqa: PGH001, S307 131 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 -RUF100_0.py:131:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`, `S307`) +RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`, `S307`) + --> RUF100_0.py:131:20 | 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 130 | x = eval(command) # noqa: PGH001, S307, PGH001 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 128 128 | x = eval(command) # noqa: PGH001, S307 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap index 68c0809458..2b582730bc 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0_prefix.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_0.py:9:12 | 8 | # Invalid 9 | c = 1 # noqa - | ^^^^^^ RUF100 + | ^^^^^^ 10 | print(c) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 6 6 | b = 2 # noqa: F841 @@ -20,15 +21,16 @@ RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive 11 11 | 12 12 | # Invalid -RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_0.py:13:12 | 12 | # Invalid 13 | d = 1 # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 14 | 15 | # Invalid | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 10 10 | print(c) @@ -40,15 +42,16 @@ RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 15 15 | # Invalid 16 16 | d = 1 # noqa: F841, E501 -RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) +RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) + --> RUF100_0.py:16:12 | 15 | # Invalid 16 | d = 1 # noqa: F841, E501 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 17 | 18 | # Invalid (and unimplemented or not enabled) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 13 13 | d = 1 # noqa: E501 @@ -60,15 +63,16 @@ RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) 18 18 | # Invalid (and unimplemented or not enabled) 19 19 | d = 1 # noqa: F841, W191, F821 -RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; non-enabled: `F821`) +RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; non-enabled: `F821`) + --> RUF100_0.py:19:12 | 18 | # Invalid (and unimplemented or not enabled) 19 | d = 1 # noqa: F841, W191, F821 - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 20 | 21 | # Invalid (but external) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 16 16 | d = 1 # noqa: F841, E501 @@ -80,15 +84,16 @@ RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; n 21 21 | # Invalid (but external) 22 22 | d = 1 # noqa: F841, V101 -RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) +RUF100 [*] Unused `noqa` directive (unused: `F841`) + --> RUF100_0.py:22:12 | 21 | # Invalid (but external) 22 | d = 1 # noqa: F841, V101 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 23 | 24 | # Invalid (but external) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 19 19 | d = 1 # noqa: F841, W191, F821 @@ -100,16 +105,17 @@ RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) 24 24 | # Invalid (but external) 25 25 | d = 1 # noqa: V500 -RUF100_0.py:29:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_0.py:29:12 | 27 | # fmt: off 28 | # Invalid - no space before # 29 | d = 1 # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 30 | 31 | # Invalid - many spaces before # | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 26 26 | @@ -121,14 +127,15 @@ RUF100_0.py:29:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 31 31 | # Invalid - many spaces before # 32 32 | d = 1 # noqa: E501 -RUF100_0.py:32:5: F841 [*] Local variable `d` is assigned to but never used +F841 [*] Local variable `d` is assigned to but never used + --> RUF100_0.py:32:5 | 31 | # Invalid - many spaces before # 32 | d = 1 # noqa: E501 - | ^ F841 + | ^ 33 | # fmt: on | - = help: Remove assignment to unused variable `d` +help: Remove assignment to unused variable `d` ℹ Unsafe fix 29 29 | d = 1 # noqa: E501 @@ -139,14 +146,15 @@ RUF100_0.py:32:5: F841 [*] Local variable `d` is assigned to but never used 34 33 | 35 34 | -RUF100_0.py:32:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_0.py:32:12 | 31 | # Invalid - many spaces before # 32 | d = 1 # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 33 | # fmt: on | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 29 29 | d = 1 # noqa: E501 @@ -158,15 +166,16 @@ RUF100_0.py:32:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) 34 34 | 35 35 | -RUF100_0.py:58:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) +RUF100 [*] Unused `noqa` directive (unused: `F841`) + --> RUF100_0.py:58:6 | 57 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 58 | """ # noqa: E501, F841 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 59 | 60 | # Invalid | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 55 55 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 @@ -178,15 +187,16 @@ RUF100_0.py:58:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) 60 60 | # Invalid 61 61 | _ = """Lorem ipsum dolor sit amet. -RUF100_0.py:66:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_0.py:66:6 | 65 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. 66 | """ # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 67 | 68 | # Invalid | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 63 63 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 @@ -198,15 +208,16 @@ RUF100_0.py:66:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) 68 68 | # Invalid 69 69 | _ = """Lorem ipsum dolor sit amet. -RUF100_0.py:74:6: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_0.py:74:6 | 73 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. 74 | """ # noqa - | ^^^^^^ RUF100 + | ^^^^^^ 75 | 76 | # Valid | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 71 71 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 @@ -218,15 +229,16 @@ RUF100_0.py:74:6: RUF100 [*] Unused blanket `noqa` directive 76 76 | # Valid 77 77 | # this is a veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy long comment # noqa: E501 -RUF100_0.py:88:8: F401 [*] `shelve` imported but unused +F401 [*] `shelve` imported but unused + --> RUF100_0.py:88:8 | 86 | import collections # noqa 87 | import os # noqa: F401, RUF100 88 | import shelve # noqa: RUF100 - | ^^^^^^ F401 + | ^^^^^^ 89 | import sys # noqa: F401, RUF100 | - = help: Remove unused import: `shelve` +help: Remove unused import: `shelve` ℹ Safe fix 85 85 | @@ -237,22 +249,24 @@ RUF100_0.py:88:8: F401 [*] `shelve` imported but unused 90 89 | 91 90 | print(sys.path) -RUF100_0.py:93:89: E501 Line too long (89 > 88) +E501 Line too long (89 > 88) + --> RUF100_0.py:93:89 | 91 | print(sys.path) 92 | 93 | "shape: (6,)\nSeries: '' [duration[μs]]\n[\n\t0µs\n\t1µs\n\t2µs\n\t3µs\n\t4µs\n\t5µs\n]" # noqa: F401 - | ^ E501 + | ^ | -RUF100_0.py:93:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) +RUF100 [*] Unused `noqa` directive (unused: `F401`) + --> RUF100_0.py:93:92 | 91 | print(sys.path) 92 | 93 | "shape: (6,)\nSeries: '' [duration[μs]]\n[\n\t0µs\n\t1µs\n\t2µs\n\t3µs\n\t4µs\n\t5µs\n]" # noqa: F401 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 90 90 | @@ -264,15 +278,16 @@ RUF100_0.py:93:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) 95 95 | 96 96 | def f(): -RUF100_0.py:107:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) +RUF100 [*] Unused `noqa` directive (unknown: `E50`) + --> RUF100_0.py:107:12 | 105 | def f(): 106 | # Invalid - nonexistent error code with multibyte character 107 | d = 1 # …noqa: F841, E50 - | ^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^ 108 | e = 1 # …noqa: E50 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 104 104 | @@ -284,14 +299,15 @@ RUF100_0.py:107:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) 109 109 | 110 110 | -RUF100_0.py:108:5: F841 [*] Local variable `e` is assigned to but never used +F841 [*] Local variable `e` is assigned to but never used + --> RUF100_0.py:108:5 | 106 | # Invalid - nonexistent error code with multibyte character 107 | d = 1 # …noqa: F841, E50 108 | e = 1 # …noqa: E50 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `e` +help: Remove assignment to unused variable `e` ℹ Unsafe fix 105 105 | def f(): @@ -302,14 +318,15 @@ RUF100_0.py:108:5: F841 [*] Local variable `e` is assigned to but never used 110 109 | 111 110 | def f(): -RUF100_0.py:108:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) +RUF100 [*] Unused `noqa` directive (unknown: `E50`) + --> RUF100_0.py:108:12 | 106 | # Invalid - nonexistent error code with multibyte character 107 | d = 1 # …noqa: F841, E50 108 | e = 1 # …noqa: E50 - | ^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 105 105 | def f(): @@ -321,16 +338,17 @@ RUF100_0.py:108:12: RUF100 [*] Unused `noqa` directive (unknown: `E50`) 110 110 | 111 111 | def f(): -RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unknown: `X200`) +RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unknown: `X200`) + --> RUF100_0.py:118:12 | 116 | # Check duplicate code detection 117 | def f(): 118 | x = 2 # noqa: F841, F841, X200 - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 119 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 115 115 | @@ -342,16 +360,17 @@ RUF100_0.py:118:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unkn 120 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 121 121 | -RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `SIM300`) +RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `SIM300`) + --> RUF100_0.py:120:19 | 118 | x = 2 # noqa: F841, F841, X200 119 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 121 | 122 | z = 2 # noqa: F841 F841 F841, F841, F841 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 117 117 | def f(): @@ -363,16 +382,17 @@ RUF100_0.py:120:19: RUF100 [*] Unused `noqa` directive (duplicated: `SIM300`, `S 122 122 | z = 2 # noqa: F841 F841 F841, F841, F841 123 123 | -RUF100_0.py:122:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F841`, `F841`, `F841`) +RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F841`, `F841`, `F841`) + --> RUF100_0.py:122:12 | 120 | y = 2 == bar # noqa: SIM300, F841, SIM300, SIM300 121 | 122 | z = 2 # noqa: F841 F841 F841, F841, F841 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 123 | 124 | return | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 119 119 | @@ -384,16 +404,17 @@ RUF100_0.py:122:12: RUF100 [*] Unused `noqa` directive (duplicated: `F841`, `F84 124 124 | return 125 125 | -RUF100_0.py:129:20: RUF100 [*] Unused `noqa` directive (duplicated: `S307`, `S307`, `S307`) +RUF100 [*] Unused `noqa` directive (duplicated: `S307`, `S307`, `S307`) + --> RUF100_0.py:129:20 | 127 | # Allow code redirects 128 | x = eval(command) # noqa: PGH001, S307 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 130 | x = eval(command) # noqa: PGH001, S307, PGH001 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 126 126 | @@ -404,15 +425,16 @@ RUF100_0.py:129:20: RUF100 [*] Unused `noqa` directive (duplicated: `S307`, `S30 130 130 | x = eval(command) # noqa: PGH001, S307, PGH001 131 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 -RUF100_0.py:130:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`) +RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`) + --> RUF100_0.py:130:20 | 128 | x = eval(command) # noqa: PGH001, S307 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 130 | x = eval(command) # noqa: PGH001, S307, PGH001 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 127 127 | # Allow code redirects @@ -422,14 +444,15 @@ RUF100_0.py:130:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`) 130 |+x = eval(command) # noqa: PGH001, S307 131 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 -RUF100_0.py:131:20: RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`, `S307`) +RUF100 [*] Unused `noqa` directive (duplicated: `PGH001`, `S307`) + --> RUF100_0.py:131:20 | 129 | x = eval(command) # noqa: S307, PGH001, S307, S307, S307 130 | x = eval(command) # noqa: PGH001, S307, PGH001 131 | x = eval(command) # noqa: PGH001, S307, PGH001, S307 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 128 128 | x = eval(command) # noqa: PGH001, S307 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap index 967b7a5d3b..e08e0b0fb3 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap @@ -1,16 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -RUF100_1.py:37:9: F401 [*] `typing.Union` imported but unused +F401 [*] `typing.Union` imported but unused + --> RUF100_1.py:37:9 | 35 | from typing import ( 36 | Mapping, # noqa: F401 37 | Union, - | ^^^^^ F401 + | ^^^^^ 38 | ) | - = help: Remove unused import: `typing.Union` +help: Remove unused import: `typing.Union` ℹ Safe fix 34 34 | # This should ignore the first error. @@ -23,15 +23,16 @@ RUF100_1.py:37:9: F401 [*] `typing.Union` imported but unused 40 39 | 41 40 | def f(): -RUF100_1.py:52:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) +RUF100 [*] Unused `noqa` directive (unused: `F401`) + --> RUF100_1.py:52:20 | 50 | # This should ignore the error, but the inner noqa should be marked as unused. 51 | from typing import ( # noqa: F401 52 | Optional, # noqa: F401 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 53 | ) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 49 49 | def f(): @@ -43,15 +44,16 @@ RUF100_1.py:52:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) 54 54 | 55 55 | -RUF100_1.py:59:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) +RUF100 [*] Unused `noqa` directive (unused: `F401`) + --> RUF100_1.py:59:20 | 57 | # This should ignore the error, but the inner noqa should be marked as unused. 58 | from typing import ( # noqa 59 | Optional, # noqa: F401 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 60 | ) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 56 56 | def f(): @@ -63,15 +65,16 @@ RUF100_1.py:59:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) 61 61 | 62 62 | -RUF100_1.py:66:16: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) +RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) + --> RUF100_1.py:66:16 | 64 | # This should ignore the error, but mark F501 as unused. 65 | from typing import ( # noqa: F401 66 | Dict, # noqa: F501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 67 | ) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 63 63 | def f(): @@ -83,16 +86,17 @@ RUF100_1.py:66:16: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) 68 68 | 69 69 | -RUF100_1.py:72:27: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) +RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) + --> RUF100_1.py:72:27 | 70 | def f(): 71 | # This should ignore the error, but mark F501 as unused. 72 | from typing import ( # noqa: F501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 73 | Tuple, # noqa: F401 74 | ) | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 69 69 | @@ -104,14 +108,15 @@ RUF100_1.py:72:27: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) 74 74 | ) 75 75 | -RUF100_1.py:89:24: F401 [*] `typing.Awaitable` imported but unused +F401 [*] `typing.Awaitable` imported but unused + --> RUF100_1.py:89:24 | 87 | def f(): 88 | # This should mark F501 as unused. 89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^ F401 + | ^^^^^^^^^ | - = help: Remove unused import +help: Remove unused import ℹ Safe fix 86 86 | @@ -120,14 +125,15 @@ RUF100_1.py:89:24: F401 [*] `typing.Awaitable` imported but unused 89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 89 |+ pass # noqa: F501 -RUF100_1.py:89:35: F401 [*] `typing.AwaitableGenerator` imported but unused +F401 [*] `typing.AwaitableGenerator` imported but unused + --> RUF100_1.py:89:35 | 87 | def f(): 88 | # This should mark F501 as unused. 89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^^^^^^^^^^ F401 + | ^^^^^^^^^^^^^^^^^^ | - = help: Remove unused import +help: Remove unused import ℹ Safe fix 86 86 | @@ -136,14 +142,15 @@ RUF100_1.py:89:35: F401 [*] `typing.AwaitableGenerator` imported but unused 89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 89 |+ pass # noqa: F501 -RUF100_1.py:89:55: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) +RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) + --> RUF100_1.py:89:55 | 87 | def f(): 88 | # This should mark F501 as unused. 89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 86 86 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap index b698180305..01c4a00b32 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF100_2.py:1:19: RUF100 [*] Unused `noqa` directive (non-enabled: `F401`) +RUF100 [*] Unused `noqa` directive (non-enabled: `F401`) + --> RUF100_2.py:1:19 | 1 | import itertools # noqa: F401 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 1 |-import itertools # noqa: F401 diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap index f0918df155..0f41808525 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF100_3.py:1:1: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_3.py:1:1 | 1 | # noqa - | ^^^^^^ RUF100 + | ^^^^^^ 2 | # noqa # comment 3 | print() # noqa | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 1 |-# noqa @@ -16,15 +17,16 @@ RUF100_3.py:1:1: RUF100 [*] Unused blanket `noqa` directive 3 2 | print() # noqa 4 3 | print() # noqa # comment -RUF100_3.py:2:1: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_3.py:2:1 | 1 | # noqa 2 | # noqa # comment - | ^^^^^^ RUF100 + | ^^^^^^ 3 | print() # noqa 4 | print() # noqa # comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 1 1 | # noqa @@ -34,16 +36,17 @@ RUF100_3.py:2:1: RUF100 [*] Unused blanket `noqa` directive 4 4 | print() # noqa # comment 5 5 | print() # noqa # comment -RUF100_3.py:3:10: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_3.py:3:10 | 1 | # noqa 2 | # noqa # comment 3 | print() # noqa - | ^^^^^^ RUF100 + | ^^^^^^ 4 | print() # noqa # comment 5 | print() # noqa # comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 1 1 | # noqa @@ -54,16 +57,17 @@ RUF100_3.py:3:10: RUF100 [*] Unused blanket `noqa` directive 5 5 | print() # noqa # comment 6 6 | print() # noqa comment -RUF100_3.py:4:10: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_3.py:4:10 | 2 | # noqa # comment 3 | print() # noqa 4 | print() # noqa # comment - | ^^^^^^ RUF100 + | ^^^^^^ 5 | print() # noqa # comment 6 | print() # noqa comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 1 1 | # noqa @@ -75,16 +79,17 @@ RUF100_3.py:4:10: RUF100 [*] Unused blanket `noqa` directive 6 6 | print() # noqa comment 7 7 | print() # noqa comment -RUF100_3.py:5:10: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_3.py:5:10 | 3 | print() # noqa 4 | print() # noqa # comment 5 | print() # noqa # comment - | ^^^^^^ RUF100 + | ^^^^^^ 6 | print() # noqa comment 7 | print() # noqa comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 2 2 | # noqa # comment @@ -96,16 +101,17 @@ RUF100_3.py:5:10: RUF100 [*] Unused blanket `noqa` directive 7 7 | print() # noqa comment 8 8 | print(a) # noqa -RUF100_3.py:6:10: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_3.py:6:10 | 4 | print() # noqa # comment 5 | print() # noqa # comment 6 | print() # noqa comment - | ^^^^^^ RUF100 + | ^^^^^^ 7 | print() # noqa comment 8 | print(a) # noqa | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 3 3 | print() # noqa @@ -117,16 +123,17 @@ RUF100_3.py:6:10: RUF100 [*] Unused blanket `noqa` directive 8 8 | print(a) # noqa 9 9 | print(a) # noqa # comment -RUF100_3.py:7:10: RUF100 [*] Unused blanket `noqa` directive +RUF100 [*] Unused blanket `noqa` directive + --> RUF100_3.py:7:10 | 5 | print() # noqa # comment 6 | print() # noqa comment 7 | print() # noqa comment - | ^^^^^^ RUF100 + | ^^^^^^ 8 | print(a) # noqa 9 | print(a) # noqa # comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 4 4 | print() # noqa # comment @@ -138,16 +145,17 @@ RUF100_3.py:7:10: RUF100 [*] Unused blanket `noqa` directive 9 9 | print(a) # noqa # comment 10 10 | print(a) # noqa # comment -RUF100_3.py:14:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) +RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + --> RUF100_3.py:14:1 | 12 | print(a) # noqa comment 13 | 14 | # noqa: E501, F821 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 15 | # noqa: E501, F821 # comment 16 | print() # noqa: E501, F821 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 11 11 | print(a) # noqa comment @@ -158,15 +166,16 @@ RUF100_3.py:14:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) 16 15 | print() # noqa: E501, F821 17 16 | print() # noqa: E501, F821 # comment -RUF100_3.py:15:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) +RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + --> RUF100_3.py:15:1 | 14 | # noqa: E501, F821 15 | # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 16 | print() # noqa: E501, F821 17 | print() # noqa: E501, F821 # comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 12 12 | print(a) # noqa comment @@ -178,16 +187,17 @@ RUF100_3.py:15:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) 17 17 | print() # noqa: E501, F821 # comment 18 18 | print() # noqa: E501, F821 # comment -RUF100_3.py:16:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) +RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + --> RUF100_3.py:16:10 | 14 | # noqa: E501, F821 15 | # noqa: E501, F821 # comment 16 | print() # noqa: E501, F821 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 17 | print() # noqa: E501, F821 # comment 18 | print() # noqa: E501, F821 # comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 13 13 | @@ -199,16 +209,17 @@ RUF100_3.py:16:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) 18 18 | print() # noqa: E501, F821 # comment 19 19 | print() # noqa: E501, F821 comment -RUF100_3.py:17:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) +RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + --> RUF100_3.py:17:10 | 15 | # noqa: E501, F821 # comment 16 | print() # noqa: E501, F821 17 | print() # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 18 | print() # noqa: E501, F821 # comment 19 | print() # noqa: E501, F821 comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 14 14 | # noqa: E501, F821 @@ -220,16 +231,17 @@ RUF100_3.py:17:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) 19 19 | print() # noqa: E501, F821 comment 20 20 | print() # noqa: E501, F821 comment -RUF100_3.py:18:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) +RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + --> RUF100_3.py:18:10 | 16 | print() # noqa: E501, F821 17 | print() # noqa: E501, F821 # comment 18 | print() # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 19 | print() # noqa: E501, F821 comment 20 | print() # noqa: E501, F821 comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 15 15 | # noqa: E501, F821 # comment @@ -241,16 +253,17 @@ RUF100_3.py:18:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) 20 20 | print() # noqa: E501, F821 comment 21 21 | print(a) # noqa: E501, F821 -RUF100_3.py:19:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) +RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + --> RUF100_3.py:19:10 | 17 | print() # noqa: E501, F821 # comment 18 | print() # noqa: E501, F821 # comment 19 | print() # noqa: E501, F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 20 | print() # noqa: E501, F821 comment 21 | print(a) # noqa: E501, F821 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 16 16 | print() # noqa: E501, F821 @@ -262,16 +275,17 @@ RUF100_3.py:19:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) 21 21 | print(a) # noqa: E501, F821 22 22 | print(a) # noqa: E501, F821 # comment -RUF100_3.py:20:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) +RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + --> RUF100_3.py:20:10 | 18 | print() # noqa: E501, F821 # comment 19 | print() # noqa: E501, F821 comment 20 | print() # noqa: E501, F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 21 | print(a) # noqa: E501, F821 22 | print(a) # noqa: E501, F821 # comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 17 17 | print() # noqa: E501, F821 # comment @@ -283,16 +297,17 @@ RUF100_3.py:20:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) 22 22 | print(a) # noqa: E501, F821 # comment 23 23 | print(a) # noqa: E501, F821 # comment -RUF100_3.py:21:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:21:11 | 19 | print() # noqa: E501, F821 comment 20 | print() # noqa: E501, F821 comment 21 | print(a) # noqa: E501, F821 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 22 | print(a) # noqa: E501, F821 # comment 23 | print(a) # noqa: E501, F821 # comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 18 18 | print() # noqa: E501, F821 # comment @@ -304,16 +319,17 @@ RUF100_3.py:21:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 23 23 | print(a) # noqa: E501, F821 # comment 24 24 | print(a) # noqa: E501, F821 comment -RUF100_3.py:22:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:22:11 | 20 | print() # noqa: E501, F821 comment 21 | print(a) # noqa: E501, F821 22 | print(a) # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 23 | print(a) # noqa: E501, F821 # comment 24 | print(a) # noqa: E501, F821 comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 19 19 | print() # noqa: E501, F821 comment @@ -325,16 +341,17 @@ RUF100_3.py:22:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 24 24 | print(a) # noqa: E501, F821 comment 25 25 | print(a) # noqa: E501, F821 comment -RUF100_3.py:23:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:23:11 | 21 | print(a) # noqa: E501, F821 22 | print(a) # noqa: E501, F821 # comment 23 | print(a) # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 24 | print(a) # noqa: E501, F821 comment 25 | print(a) # noqa: E501, F821 comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 20 20 | print() # noqa: E501, F821 comment @@ -346,16 +363,17 @@ RUF100_3.py:23:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 25 25 | print(a) # noqa: E501, F821 comment 26 26 | print(a) # noqa: E501,,F821 comment -RUF100_3.py:24:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:24:11 | 22 | print(a) # noqa: E501, F821 # comment 23 | print(a) # noqa: E501, F821 # comment 24 | print(a) # noqa: E501, F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 25 | print(a) # noqa: E501, F821 comment 26 | print(a) # noqa: E501,,F821 comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 21 21 | print(a) # noqa: E501, F821 @@ -367,16 +385,17 @@ RUF100_3.py:24:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 26 26 | print(a) # noqa: E501,,F821 comment 27 27 | print(a) # noqa: E501, ,F821 comment -RUF100_3.py:25:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:25:11 | 23 | print(a) # noqa: E501, F821 # comment 24 | print(a) # noqa: E501, F821 comment 25 | print(a) # noqa: E501, F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 26 | print(a) # noqa: E501,,F821 comment 27 | print(a) # noqa: E501, ,F821 comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 22 22 | print(a) # noqa: E501, F821 # comment @@ -388,16 +407,17 @@ RUF100_3.py:25:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 27 27 | print(a) # noqa: E501, ,F821 comment 28 28 | print(a) # noqa: E501 F821 comment -RUF100_3.py:26:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:26:11 | 24 | print(a) # noqa: E501, F821 comment 25 | print(a) # noqa: E501, F821 comment 26 | print(a) # noqa: E501,,F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ 27 | print(a) # noqa: E501, ,F821 comment 28 | print(a) # noqa: E501 F821 comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 23 23 | print(a) # noqa: E501, F821 # comment @@ -409,15 +429,16 @@ RUF100_3.py:26:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 28 28 | print(a) # noqa: E501 F821 comment 29 29 | -RUF100_3.py:27:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:27:11 | 25 | print(a) # noqa: E501, F821 comment 26 | print(a) # noqa: E501,,F821 comment 27 | print(a) # noqa: E501, ,F821 comment - | ^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^ 28 | print(a) # noqa: E501 F821 comment | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 24 24 | print(a) # noqa: E501, F821 comment @@ -429,16 +450,17 @@ RUF100_3.py:27:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 29 29 | 30 30 | print(a) # comment with unicode µ # noqa: E501 -RUF100_3.py:28:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:28:11 | 26 | print(a) # noqa: E501,,F821 comment 27 | print(a) # noqa: E501, ,F821 comment 28 | print(a) # noqa: E501 F821 comment - | ^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^ 29 | 30 | print(a) # comment with unicode µ # noqa: E501 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 25 25 | print(a) # noqa: E501, F821 comment @@ -450,24 +472,26 @@ RUF100_3.py:28:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) 30 30 | print(a) # comment with unicode µ # noqa: E501 31 31 | print(a) # comment with unicode µ # noqa: E501, F821 -RUF100_3.py:30:7: F821 Undefined name `a` +F821 Undefined name `a` + --> RUF100_3.py:30:7 | 28 | print(a) # noqa: E501 F821 comment 29 | 30 | print(a) # comment with unicode µ # noqa: E501 - | ^ F821 + | ^ 31 | print(a) # comment with unicode µ # noqa: E501, F821 | -RUF100_3.py:30:39: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:30:39 | 28 | print(a) # noqa: E501 F821 comment 29 | 30 | print(a) # comment with unicode µ # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 31 | print(a) # comment with unicode µ # noqa: E501, F821 | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 27 27 | print(a) # noqa: E501, ,F821 comment @@ -477,13 +501,14 @@ RUF100_3.py:30:39: RUF100 [*] Unused `noqa` directive (unused: `E501`) 30 |+print(a) # comment with unicode µ 31 31 | print(a) # comment with unicode µ # noqa: E501, F821 -RUF100_3.py:31:39: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_3.py:31:39 | 30 | print(a) # comment with unicode µ # noqa: E501 31 | print(a) # comment with unicode µ # noqa: E501, F821 - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 28 28 | print(a) # noqa: E501 F821 comment diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap index 05d515713a..e86fb19ddb 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap @@ -1,15 +1,16 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF100_5.py:7:5: ERA001 Found commented-out code +ERA001 Found commented-out code + --> RUF100_5.py:7:5 | 5 | # "key1": 123, # noqa: ERA001 6 | # "key2": 456, # noqa 7 | # "key3": 789, - | ^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^ 8 | } | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 4 4 | dictionary = { @@ -20,14 +21,15 @@ RUF100_5.py:7:5: ERA001 Found commented-out code 9 8 | 10 9 | -RUF100_5.py:11:1: ERA001 Found commented-out code +ERA001 Found commented-out code + --> RUF100_5.py:11:1 | 11 | #import os # noqa: E501 - | ^^^^^^^^^^^^^^^^^^^^^^^^ ERA001 + | ^^^^^^^^^^^^^^^^^^^^^^^^ 12 | 13 | def f(): | - = help: Remove commented-out code +help: Remove commented-out code ℹ Display-only fix 8 8 | } @@ -38,14 +40,15 @@ RUF100_5.py:11:1: ERA001 Found commented-out code 13 12 | def f(): 14 13 | data = 1 -RUF100_5.py:11:13: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_5.py:11:13 | 11 | #import os # noqa: E501 - | ^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^ 12 | 13 | def f(): | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 8 8 | } @@ -57,16 +60,17 @@ RUF100_5.py:11:13: RUF100 [*] Unused `noqa` directive (unused: `E501`) 13 13 | def f(): 14 14 | data = 1 -RUF100_5.py:16:18: RUF100 [*] Unused `noqa` directive (non-enabled: `RET504`) +RUF100 [*] Unused `noqa` directive (non-enabled: `RET504`) + --> RUF100_5.py:16:18 | 14 | data = 1 15 | # line below should autofix to `return data # fmt: skip` 16 | return data # noqa: RET504 # fmt: skip - | ^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^ 17 | 18 | def f(): | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 13 13 | def f(): @@ -78,14 +82,15 @@ RUF100_5.py:16:18: RUF100 [*] Unused `noqa` directive (non-enabled: `RET504`) 18 18 | def f(): 19 19 | data = 1 -RUF100_5.py:21:18: RUF100 [*] Unused `noqa` directive (non-enabled: `RET504`) +RUF100 [*] Unused `noqa` directive (non-enabled: `RET504`) + --> RUF100_5.py:21:18 | 19 | data = 1 20 | # line below should autofix to `return data` 21 | return data # noqa: RET504 - intentional incorrect noqa, will be removed - | ^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 18 18 | def f(): diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap index 8762e87e47..89f28d6aa6 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap @@ -1,14 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -ruff_noqa_codes.py:8:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> ruff_noqa_codes.py:8:5 | 7 | def f(): 8 | x = 1 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 5 5 | diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_filedirective_unused.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_filedirective_unused.snap index 1a570501c1..c51d812458 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_filedirective_unused.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_filedirective_unused.snap @@ -1,12 +1,13 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF100_6.py:1:1: RUF100 [*] Unused `noqa` directive (non-enabled: `F841`) +RUF100 [*] Unused `noqa` directive (non-enabled: `F841`) + --> RUF100_6.py:1:1 | 1 | # ruff: noqa: F841 -- intentional unused file directive; will be removed - | ^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 1 |-# ruff: noqa: F841 -- intentional unused file directive; will be removed diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_filedirective_unused_last_of_many.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_filedirective_unused_last_of_many.snap index 49022bf759..cf8ab449b9 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_filedirective_unused_last_of_many.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_filedirective_unused_last_of_many.snap @@ -1,13 +1,14 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs --- -RUF100_7.py:1:1: RUF100 [*] Unused `noqa` directive (unused: `E501`) +RUF100 [*] Unused `noqa` directive (unused: `E501`) + --> RUF100_7.py:1:1 | 1 | # flake8: noqa: F841, E501 -- used followed by unused code - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | # ruff: noqa: E701, F541 -- unused followed by used code | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 1 |-# flake8: noqa: F841, E501 -- used followed by unused code @@ -16,13 +17,14 @@ RUF100_7.py:1:1: RUF100 [*] Unused `noqa` directive (unused: `E501`) 3 3 | 4 4 | -RUF100_7.py:2:1: RUF100 [*] Unused `noqa` directive (non-enabled: `E701`) +RUF100 [*] Unused `noqa` directive (non-enabled: `E701`) + --> RUF100_7.py:2:1 | 1 | # flake8: noqa: F841, E501 -- used followed by unused code 2 | # ruff: noqa: E701, F541 -- unused followed by used code - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Remove unused `noqa` directive +help: Remove unused `noqa` directive ℹ Safe fix 1 1 | # flake8: noqa: F841, E501 -- used followed by unused code diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap index 2b7f08191c..bcfd68f1b4 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/ruff/mod.rs -snapshot_kind: text --- -ruff_noqa_invalid.py:1:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> ruff_noqa_invalid.py:1:8 | 1 | import os # ruff: noqa: F401 - | ^^ F401 + | ^^ | - = help: Remove unused import: `os` +help: Remove unused import: `os` ℹ Safe fix 1 |-import os # ruff: noqa: F401 @@ -15,13 +15,14 @@ ruff_noqa_invalid.py:1:8: F401 [*] `os` imported but unused 3 2 | 4 3 | def f(): -ruff_noqa_invalid.py:5:5: F841 [*] Local variable `x` is assigned to but never used +F841 [*] Local variable `x` is assigned to but never used + --> ruff_noqa_invalid.py:5:5 | 4 | def f(): 5 | x = 1 - | ^ F841 + | ^ | - = help: Remove assignment to unused variable `x` +help: Remove assignment to unused variable `x` ℹ Unsafe fix 2 2 | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap index 9e60594d46..8afdb7dffe 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs --- -TRY400.py:13:9: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:13:9 | 11 | a = 1 12 | except Exception: 13 | logging.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | if True: | - = help: Replace with `exception` +help: Replace with `exception` ℹ Safe fix 10 10 | try: @@ -22,13 +23,14 @@ TRY400.py:13:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 15 15 | if True: 16 16 | logging.error("Context message here") -TRY400.py:16:13: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:16:13 | 15 | if True: 16 | logging.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `exception` +help: Replace with `exception` ℹ Safe fix 13 13 | logging.error("Context message here") @@ -40,16 +42,17 @@ TRY400.py:16:13: TRY400 [*] Use `logging.exception` instead of `logging.error` 18 18 | 19 19 | def bad(): -TRY400.py:27:9: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:27:9 | 25 | a = 1 26 | except Exception: 27 | logger.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 28 | 29 | if True: | - = help: Replace with `exception` +help: Replace with `exception` ℹ Unsafe fix 24 24 | try: @@ -61,13 +64,14 @@ TRY400.py:27:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 29 29 | if True: 30 30 | logger.error("Context message here") -TRY400.py:30:13: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:30:13 | 29 | if True: 30 | logger.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `exception` +help: Replace with `exception` ℹ Unsafe fix 27 27 | logger.error("Context message here") @@ -79,16 +83,17 @@ TRY400.py:30:13: TRY400 [*] Use `logging.exception` instead of `logging.error` 32 32 | 33 33 | def bad(): -TRY400.py:37:9: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:37:9 | 35 | a = 1 36 | except Exception: 37 | log.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | 39 | if True: | - = help: Replace with `exception` +help: Replace with `exception` ℹ Unsafe fix 34 34 | try: @@ -100,13 +105,14 @@ TRY400.py:37:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 39 39 | if True: 40 40 | log.error("Context message here") -TRY400.py:40:13: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:40:13 | 39 | if True: 40 | log.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `exception` +help: Replace with `exception` ℹ Unsafe fix 37 37 | log.error("Context message here") @@ -118,16 +124,17 @@ TRY400.py:40:13: TRY400 [*] Use `logging.exception` instead of `logging.error` 42 42 | 43 43 | def bad(): -TRY400.py:47:9: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:47:9 | 45 | a = 1 46 | except Exception: 47 | self.logger.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 48 | 49 | if True: | - = help: Replace with `exception` +help: Replace with `exception` ℹ Unsafe fix 44 44 | try: @@ -139,13 +146,14 @@ TRY400.py:47:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 49 49 | if True: 50 50 | self.logger.error("Context message here") -TRY400.py:50:13: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:50:13 | 49 | if True: 50 | self.logger.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `exception` +help: Replace with `exception` ℹ Unsafe fix 47 47 | self.logger.error("Context message here") @@ -157,16 +165,17 @@ TRY400.py:50:13: TRY400 [*] Use `logging.exception` instead of `logging.error` 52 52 | 53 53 | def good(): -TRY400.py:100:9: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:100:9 | 98 | a = 1 99 | except Exception: 100 | error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 101 | 102 | if True: | - = help: Replace with `exception` +help: Replace with `exception` ℹ Safe fix 97 97 | try: @@ -178,13 +187,14 @@ TRY400.py:100:9: TRY400 [*] Use `logging.exception` instead of `logging.error` 102 102 | if True: 103 103 | error("Context message here") -TRY400.py:103:13: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:103:13 | 102 | if True: 103 | error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `exception` +help: Replace with `exception` ℹ Safe fix 100 100 | error("Context message here") @@ -196,14 +206,15 @@ TRY400.py:103:13: TRY400 [*] Use `logging.exception` instead of `logging.error` 105 105 | 106 106 | def good(): -TRY400.py:143:13: TRY400 [*] Use `logging.exception` instead of `logging.error` +TRY400 [*] Use `logging.exception` instead of `logging.error` + --> TRY400.py:143:13 | 141 | b = 2 142 | except Exception: 143 | error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Replace with `exception` +help: Replace with `exception` ℹ Safe fix 140 140 | try: diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap index 9c8bf58daf..c9cbe9dd20 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap @@ -1,37 +1,40 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- -TRY003.py:8:15: TRY003 Avoid specifying long messages outside the exception class +TRY003 Avoid specifying long messages outside the exception class + --> TRY003.py:8:15 | 6 | a = 1 7 | if a == 1: 8 | raise CustomException("Long message") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9 | elif a == 2: 10 | raise CustomException("Short") # This is acceptable | -TRY003.py:34:15: TRY003 Avoid specifying long messages outside the exception class +TRY003 Avoid specifying long messages outside the exception class + --> TRY003.py:34:15 | 32 | def bad(a): 33 | if a % 2 == 0: 34 | raise BadArgCantBeEven(f"The argument '{a}' should be even") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY003.py:39:15: TRY003 Avoid specifying long messages outside the exception class +TRY003 Avoid specifying long messages outside the exception class + --> TRY003.py:39:15 | 37 | def another_bad(a): 38 | if a % 2 == 0: 39 | raise BadArgCantBeEven(f"The argument {a} should not be odd.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY003.py:44:15: TRY003 Avoid specifying long messages outside the exception class +TRY003 Avoid specifying long messages outside the exception class + --> TRY003.py:44:15 | 42 | def and_another_bad(a): 43 | if a % 2 == 0: 44 | raise BadArgCantBeEven("The argument `a` should not be odd.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap index 0df2113706..a781966a17 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap @@ -1,38 +1,42 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs --- -TRY002.py:13:15: TRY002 Create your own exception +TRY002 Create your own exception + --> TRY002.py:13:15 | 11 | a = 1 12 | if a == 1: 13 | raise Exception("Custom message") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 14 | 15 | b = 1 | -TRY002.py:17:15: TRY002 Create your own exception +TRY002 Create your own exception + --> TRY002.py:17:15 | 15 | b = 1 16 | if b == 1: 17 | raise Exception - | ^^^^^^^^^ TRY002 + | ^^^^^^^^^ | -TRY002.py:37:15: TRY002 Create your own exception +TRY002 Create your own exception + --> TRY002.py:37:15 | 35 | a = 1 36 | if a == 1: 37 | raise BaseException("Custom message") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY002 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 38 | 39 | b = 1 | -TRY002.py:41:15: TRY002 Create your own exception +TRY002 Create your own exception + --> TRY002.py:41:15 | 39 | b = 1 40 | if b == 1: 41 | raise BaseException - | ^^^^^^^^^^^^^ TRY002 + | ^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap index 707345cf44..d7078faebc 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap @@ -1,62 +1,68 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs --- -TRY301.py:14:13: TRY301 Abstract `raise` to an inner function +TRY301 Abstract `raise` to an inner function + --> TRY301.py:14:13 | 12 | a = process() 13 | if not a: 14 | raise MyException(a) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 + | ^^^^^^^^^^^^^^^^^^^^ 15 | 16 | raise MyException(a) | -TRY301.py:16:9: TRY301 Abstract `raise` to an inner function +TRY301 Abstract `raise` to an inner function + --> TRY301.py:16:9 | 14 | raise MyException(a) 15 | 16 | raise MyException(a) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 + | ^^^^^^^^^^^^^^^^^^^^ 17 | 18 | try: | -TRY301.py:21:17: TRY301 Abstract `raise` to an inner function +TRY301 Abstract `raise` to an inner function + --> TRY301.py:21:17 | 19 | b = process() 20 | if not b: 21 | raise MyException(b) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 + | ^^^^^^^^^^^^^^^^^^^^ 22 | except Exception: 23 | logger.exception("something failed") | -TRY301.py:32:13: TRY301 Abstract `raise` to an inner function +TRY301 Abstract `raise` to an inner function + --> TRY301.py:32:13 | 30 | a = process() 31 | if not a: 32 | raise MyException(a) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 + | ^^^^^^^^^^^^^^^^^^^^ 33 | 34 | raise MyException(a) | -TRY301.py:34:9: TRY301 Abstract `raise` to an inner function +TRY301 Abstract `raise` to an inner function + --> TRY301.py:34:9 | 32 | raise MyException(a) 33 | 34 | raise MyException(a) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 + | ^^^^^^^^^^^^^^^^^^^^ 35 | 36 | try: | -TRY301.py:39:17: TRY301 Abstract `raise` to an inner function +TRY301 Abstract `raise` to an inner function + --> TRY301.py:39:17 | 37 | b = process() 38 | if not b: 39 | raise MyException(b) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 + | ^^^^^^^^^^^^^^^^^^^^ 40 | except* Exception: 41 | logger.exception("something failed") | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__try-consider-else_TRY300.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__try-consider-else_TRY300.py.snap index 1e5761ed6e..f6a0580b5c 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__try-consider-else_TRY300.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__try-consider-else_TRY300.py.snap @@ -1,13 +1,13 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- -TRY300.py:20:9: TRY300 Consider moving this statement to an `else` block +TRY300 Consider moving this statement to an `else` block + --> TRY300.py:20:9 | 18 | a = 1 19 | b = process() 20 | return b - | ^^^^^^^^ TRY300 + | ^^^^^^^^ 21 | except MyException: 22 | logger.exception("process failed") | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap index 1400f13f98..893ee904d6 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap @@ -1,296 +1,332 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs --- -TRY004.py:12:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:12:9 | 10 | pass 11 | else: 12 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:19:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:19:9 | 17 | pass 18 | else: 19 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:30:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:30:9 | 28 | pass 29 | else: 30 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:37:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:37:9 | 35 | pass 36 | else: 37 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:44:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:44:9 | 42 | pass 43 | else: 44 | raise ArithmeticError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:51:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:51:9 | 49 | pass 50 | else: 51 | raise AssertionError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:58:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:58:9 | 56 | pass 57 | else: 58 | raise AttributeError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:65:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:65:9 | 63 | pass 64 | else: 65 | raise BufferError # should be typeerror - | ^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^ | -TRY004.py:72:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:72:9 | 70 | pass 71 | else: 72 | raise EOFError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:79:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:79:9 | 77 | pass 78 | else: 79 | raise ImportError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:86:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:86:9 | 84 | pass 85 | else: 86 | raise LookupError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:95:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:95:9 | 93 | # should be typeerror 94 | # not multiline is on purpose for fix 95 | / raise MemoryError( 96 | | "..." 97 | | ) - | |_________^ TRY004 + | |_________^ | -TRY004.py:104:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:104:9 | 102 | pass 103 | else: 104 | raise NameError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:111:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:111:9 | 109 | pass 110 | else: 111 | raise ReferenceError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:118:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:118:9 | 116 | pass 117 | else: 118 | raise RuntimeError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:125:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:125:9 | 123 | pass 124 | else: 125 | raise SyntaxError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:132:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:132:9 | 130 | pass 131 | else: 132 | raise SystemError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:139:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:139:9 | 137 | pass 138 | else: 139 | raise ValueError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:146:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:146:9 | 144 | pass 145 | else: 146 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:153:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:153:9 | 151 | pass 152 | else: 153 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:160:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:160:9 | 158 | pass 159 | else: 160 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:167:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:167:9 | 165 | pass 166 | else: 167 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:174:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:174:9 | 172 | pass 173 | else: 174 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:181:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:181:9 | 179 | pass 180 | else: 181 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:188:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:188:9 | 186 | pass 187 | else: 188 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:195:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:195:9 | 193 | pass 194 | else: 195 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:202:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:202:9 | 200 | pass 201 | else: 202 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:209:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:209:9 | 207 | pass 208 | else: 209 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:216:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:216:9 | 214 | pass 215 | else: 216 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:223:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:223:9 | 221 | pass 222 | else: 223 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:230:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:230:9 | 228 | pass 229 | elif isinstance(arg2, int): 230 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:239:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:239:9 | 237 | pass 238 | else: 239 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:276:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:276:9 | 274 | def check_body(some_args): 275 | if isinstance(some_args, int): 276 | raise ValueError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^ | -TRY004.py:286:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:286:9 | 284 | def multiple_elifs(some_args): 285 | if not isinstance(some_args, int): 286 | raise ValueError("...") # should be typerror - | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^ 287 | elif some_args < 3: 288 | raise ValueError("...") # this is ok | -TRY004.py:297:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:297:9 | 295 | def multiple_ifs(some_args): 296 | if not isinstance(some_args, int): 297 | raise ValueError("...") # should be typerror - | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^ 298 | else: 299 | if some_args < 3: | -TRY004.py:316:9: TRY004 Prefer `TypeError` exception for invalid type +TRY004 Prefer `TypeError` exception for invalid type + --> TRY004.py:316:9 | 314 | return "CronExpression" 315 | else: 316 | raise Exception(f"Unknown object type: {obj.__class__.__name__}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY203.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY203.py.snap index 9f150810bf..0f0f3807c2 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY203.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY203.py.snap @@ -1,136 +1,148 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs --- -TRY203.py:12:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:12:5 | 10 | try: 11 | process() 12 | / except Exception: 13 | | raise - | |_____________^ TRY203 + | |_____________^ 14 | 15 | def bad(): | -TRY203.py:18:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:18:5 | 16 | try: 17 | process() 18 | / except Exception: 19 | | raise 20 | | print("this code is pointless!") - | |________________________________________^ TRY203 + | |________________________________________^ 21 | 22 | def bad(): | -TRY203.py:25:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:25:5 | 23 | try: 24 | process() 25 | / except: 26 | | # I am a comment, not a statement! 27 | | raise - | |_____________^ TRY203 + | |_____________^ 28 | 29 | def bad(): | -TRY203.py:32:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:32:5 | 30 | try: 31 | process() 32 | / except Exception: 33 | | raise - | |_____________^ TRY203 + | |_____________^ 34 | 35 | def bad(): | -TRY203.py:38:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:38:5 | 36 | try: 37 | process() 38 | / except Exception as e: 39 | | raise - | |_____________^ TRY203 + | |_____________^ 40 | 41 | def bad(): | -TRY203.py:44:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:44:5 | 42 | try: 43 | process() 44 | / except Exception as e: 45 | | raise e - | |_______________^ TRY203 + | |_______________^ 46 | 47 | def bad(): | -TRY203.py:50:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:50:5 | 48 | try: 49 | process() 50 | / except MyException: 51 | | raise - | |_____________^ TRY203 + | |_____________^ 52 | except Exception: 53 | raise | -TRY203.py:52:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:52:5 | 50 | except MyException: 51 | raise 52 | / except Exception: 53 | | raise - | |_____________^ TRY203 + | |_____________^ 54 | 55 | def bad(): | -TRY203.py:58:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:58:5 | 56 | try: 57 | process() 58 | / except MyException as e: 59 | | raise e - | |_______________^ TRY203 + | |_______________^ 60 | except Exception as e: 61 | raise e | -TRY203.py:60:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:60:5 | 58 | except MyException as e: 59 | raise e 60 | / except Exception as e: 61 | | raise e - | |_______________^ TRY203 + | |_______________^ 62 | 63 | def bad(): | -TRY203.py:66:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:66:5 | 64 | try: 65 | process() 66 | / except MyException as ex: 67 | | raise ex - | |________________^ TRY203 + | |________________^ 68 | except Exception as e: 69 | raise e | -TRY203.py:68:5: TRY203 Remove exception handler; error is immediately re-raised +TRY203 Remove exception handler; error is immediately re-raised + --> TRY203.py:68:5 | 66 | except MyException as ex: 67 | raise ex 68 | / except Exception as e: 69 | | raise e - | |_______________^ TRY203 + | |_______________^ 70 | 71 | def fine(): | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap index ddb8fc15bb..87a8944016 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap @@ -1,194 +1,216 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs --- -TRY401.py:8:45: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:8:45 | 6 | finish() 7 | except Exception as ex: 8 | logger.exception(f"Found an error: {ex}") # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:19:53: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:19:53 | 17 | if True is False: 18 | for i in range(10): 19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 - | ^^^ TRY401 + | ^^^ 20 | except IndexError as bad: 21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 | -TRY401.py:21:45: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:21:45 | 19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 20 | except IndexError as bad: 21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ 22 | except Exception as bad: 23 | logger.exception(f"Found an error: {bad}") # TRY401 | -TRY401.py:21:51: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:21:51 | 19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 20 | except IndexError as bad: 21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ 22 | except Exception as bad: 23 | logger.exception(f"Found an error: {bad}") # TRY401 | -TRY401.py:23:45: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:23:45 | 21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 22 | except Exception as bad: 23 | logger.exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ 24 | logger.exception(f"Found an error: {bad}") # TRY401 | -TRY401.py:24:45: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:24:45 | 22 | except Exception as bad: 23 | logger.exception(f"Found an error: {bad}") # TRY401 24 | logger.exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ 25 | 26 | if True: | -TRY401.py:27:49: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:27:49 | 26 | if True: 27 | logger.exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ | -TRY401.py:39:47: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:39:47 | 37 | ... 38 | except Exception as ex: 39 | logger.exception(f"Logging an error: {ex}") # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:46:53: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:46:53 | 44 | ... 45 | except Exception as ex: 46 | logger.exception("Logging an error: " + str(ex)) # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:53:47: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:53:47 | 51 | ... 52 | except Exception as ex: 53 | logger.exception("Logging an error:", ex) # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:77:38: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:77:38 | 75 | finish() 76 | except Exception as ex: 77 | exception(f"Found an error: {ex}") # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:88:46: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:88:46 | 86 | if True is False: 87 | for i in range(10): 88 | exception(f"Found an error: {bad} {good}") # TRY401 - | ^^^ TRY401 + | ^^^ 89 | except IndexError as bad: 90 | exception(f"Found an error: {bad} {bad}") # TRY401 | -TRY401.py:90:38: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:90:38 | 88 | exception(f"Found an error: {bad} {good}") # TRY401 89 | except IndexError as bad: 90 | exception(f"Found an error: {bad} {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ 91 | except Exception as bad: 92 | exception(f"Found an error: {bad}") # TRY401 | -TRY401.py:90:44: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:90:44 | 88 | exception(f"Found an error: {bad} {good}") # TRY401 89 | except IndexError as bad: 90 | exception(f"Found an error: {bad} {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ 91 | except Exception as bad: 92 | exception(f"Found an error: {bad}") # TRY401 | -TRY401.py:92:38: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:92:38 | 90 | exception(f"Found an error: {bad} {bad}") # TRY401 91 | except Exception as bad: 92 | exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ 93 | exception(f"Found an error: {bad}") # TRY401 | -TRY401.py:93:38: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:93:38 | 91 | except Exception as bad: 92 | exception(f"Found an error: {bad}") # TRY401 93 | exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ 94 | 95 | if True: | -TRY401.py:96:42: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:96:42 | 95 | if True: 96 | exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 + | ^^^ | -TRY401.py:103:40: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:103:40 | 101 | ... 102 | except Exception as ex: 103 | exception(f"Logging an error: {ex}") # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:110:46: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:110:46 | 108 | ... 109 | except Exception as ex: 110 | exception("Logging an error: " + str(ex)) # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:117:40: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:117:40 | 115 | ... 116 | except Exception as ex: 117 | exception("Logging an error:", ex) # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:139:49: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:139:49 | 137 | finish() 138 | except Exception as ex: 139 | logger.exception(f"Found an error: {ex}") # TRY401 - | ^^ TRY401 + | ^^ | -TRY401.py:150:49: TRY401 Redundant exception object included in `logging.exception` call +TRY401 Redundant exception object included in `logging.exception` call + --> TRY401.py:150:49 | 148 | finish() 149 | except Exception: 150 | logger.exception(f"Found an error: {ex}") # TRY401 - | ^^ TRY401 + | ^^ | diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap index b8383947f3..59290aae78 100644 --- a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap @@ -1,15 +1,15 @@ --- source: crates/ruff_linter/src/rules/tryceratops/mod.rs -snapshot_kind: text --- -TRY201.py:20:15: TRY201 [*] Use `raise` without specifying exception name +TRY201 [*] Use `raise` without specifying exception name + --> TRY201.py:20:15 | 18 | except MyException as e: 19 | logger.exception("process failed") 20 | raise e - | ^ TRY201 + | ^ | - = help: Remove exception name +help: Remove exception name ℹ Unsafe fix 17 17 | process() @@ -21,14 +21,15 @@ TRY201.py:20:15: TRY201 [*] Use `raise` without specifying exception name 22 22 | 23 23 | def good(): -TRY201.py:63:19: TRY201 [*] Use `raise` without specifying exception name +TRY201 [*] Use `raise` without specifying exception name + --> TRY201.py:63:19 | 61 | logger.exception("process failed") 62 | if True: 63 | raise e - | ^ TRY201 + | ^ | - = help: Remove exception name +help: Remove exception name ℹ Unsafe fix 60 60 | except MyException as e: @@ -40,13 +41,14 @@ TRY201.py:63:19: TRY201 [*] Use `raise` without specifying exception name 65 65 | 66 66 | def bad_that_needs_recursion_2(): -TRY201.py:74:23: TRY201 [*] Use `raise` without specifying exception name +TRY201 [*] Use `raise` without specifying exception name + --> TRY201.py:74:23 | 73 | def foo(): 74 | raise e - | ^ TRY201 + | ^ | - = help: Remove exception name +help: Remove exception name ℹ Unsafe fix 71 71 | if True: diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__async_comprehension.py.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__async_comprehension.py.snap index 9e570b889c..e39895d9c6 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__async_comprehension.py.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__async_comprehension.py.snap @@ -1,31 +1,34 @@ --- source: crates/ruff_linter/src/linter.rs --- -resources/test/fixtures/syntax_errors/async_comprehension.py:5:8: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> resources/test/fixtures/syntax_errors/async_comprehension.py:5:8 | 4 | def regular_function(): 5 | [x async for x in elements(1)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1142 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | 7 | async with elements(1) as x: | -resources/test/fixtures/syntax_errors/async_comprehension.py:7:5: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> resources/test/fixtures/syntax_errors/async_comprehension.py:7:5 | 5 | [x async for x in elements(1)] 6 | 7 | / async with elements(1) as x: 8 | | pass - | |____________^ PLE1142 + | |____________^ 9 | 10 | async for _ in elements(1): | -resources/test/fixtures/syntax_errors/async_comprehension.py:10:5: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> resources/test/fixtures/syntax_errors/async_comprehension.py:10:5 | 8 | pass 9 | 10 | / async for _ in elements(1): 11 | | pass - | |____________^ PLE1142 + | |____________^ | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__async_comprehension_in_sync_comprehension_notebook_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__async_comprehension_in_sync_comprehension_notebook_3.10.snap index b8f733bcbc..14c1cea362 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__async_comprehension_in_sync_comprehension_notebook_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__async_comprehension_in_sync_comprehension_notebook_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -resources/test/fixtures/syntax_errors/async_comprehension.ipynb:3:5: invalid-syntax: cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (syntax was added in 3.11) +invalid-syntax: cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (syntax was added in 3.11) + --> resources/test/fixtures/syntax_errors/async_comprehension.ipynb:3:5 | 1 | async def elements(n): yield n 2 | [x async for x in elements(5)] # okay, async at top level diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__await_outside_async_function.py.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__await_outside_async_function.py.snap index fb45718a9a..fbab466fc5 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__await_outside_async_function.py.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__await_outside_async_function.py.snap @@ -1,18 +1,20 @@ --- source: crates/ruff_linter/src/linter.rs --- -resources/test/fixtures/syntax_errors/await_outside_async_function.py:2:5: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> resources/test/fixtures/syntax_errors/await_outside_async_function.py:2:5 | 1 | def func(): 2 | await 1 - | ^^^^^^^ PLE1142 + | ^^^^^^^ 3 | 4 | # Top-level await | -resources/test/fixtures/syntax_errors/await_outside_async_function.py:5:1: PLE1142 `await` should be used within an async function +PLE1142 `await` should be used within an async function + --> resources/test/fixtures/syntax_errors/await_outside_async_function.py:5:1 | 4 | # Top-level await 5 | await 1 - | ^^^^^^^ PLE1142 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__await_scope_notebook.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__await_scope_notebook.snap index 6a7e634ca6..2038653a11 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__await_scope_notebook.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__await_scope_notebook.snap @@ -1,9 +1,10 @@ --- source: crates/ruff_linter/src/linter.rs --- -await_scope.ipynb:cell 3:2:5: F704 `await` statement outside of a function +F704 `await` statement outside of a function + --> await_scope.ipynb:cell 3:2:5 | 1 | class _: 2 | await 1 # SyntaxError: await outside function - | ^^^^^^^ F704 + | ^^^^^^^ | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_extensions.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_extensions.snap index b2537598f0..fffcf7e607 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_extensions.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_extensions.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/linter.rs --- -:7:13: PYI019 [*] Use `Self` instead of custom TypeVar `T` +PYI019 [*] Use `Self` instead of custom TypeVar `T` + --> :7:13 | 6 | class C: 7 | def __new__(cls: type[T]) -> T: - | ^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^ 8 | return cls | - = help: Replace TypeVar `T` with `Self` +help: Replace TypeVar `T` with `Self` ℹ Safe fix 1 1 | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_with_extensions_disabled.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_with_extensions_disabled.snap index 0dee5cdff1..ada2e840bd 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_with_extensions_disabled.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_with_extensions_disabled.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/linter.rs --- -:7:13: PYI019 [*] Use `Self` instead of custom TypeVar `T` +PYI019 [*] Use `Self` instead of custom TypeVar `T` + --> :7:13 | 6 | class C: 7 | def __new__(cls: type[T]) -> T: - | ^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^ 8 | return cls | - = help: Replace TypeVar `T` with `Self` +help: Replace TypeVar `T` with `Self` ℹ Safe fix 1 1 | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_without_extensions_disabled.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_without_extensions_disabled.snap index 0dee5cdff1..ada2e840bd 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_without_extensions_disabled.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__disabled_typing_extensions_pyi019_adds_typing_without_extensions_disabled.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/linter.rs --- -:7:13: PYI019 [*] Use `Self` instead of custom TypeVar `T` +PYI019 [*] Use `Self` instead of custom TypeVar `T` + --> :7:13 | 6 | class C: 7 | def __new__(cls: type[T]) -> T: - | ^^^^^^^^^^^^^^^^^^^ PYI019 + | ^^^^^^^^^^^^^^^^^^^ 8 | return cls | - = help: Replace TypeVar `T` with `Self` +help: Replace TypeVar `T` with `Self` ℹ Safe fix 1 1 | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap index 283257a8d8..d4cb049469 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/linter.rs --- -isort.ipynb:cell 1:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> isort.ipynb:cell 1:1:1 | 1 | / from pathlib import Path 2 | | import random 3 | | import math - | |___________^ I001 + | |___________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 |+import math @@ -20,15 +21,16 @@ isort.ipynb:cell 1:1:1: I001 [*] Import block is un-sorted or un-formatted 5 5 | import collections 6 6 | # Newline should be added here -isort.ipynb:cell 2:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> isort.ipynb:cell 2:1:1 | 1 | / from typing import Any 2 | | import collections - | |__________________^ I001 + | |__________________^ 3 | # Newline should be added here 4 | def foo(): | - = help: Organize imports +help: Organize imports ℹ Safe fix 1 1 | from pathlib import Path @@ -43,15 +45,16 @@ isort.ipynb:cell 2:1:1: I001 [*] Import block is un-sorted or un-formatted 7 9 | def foo(): 8 10 | pass -isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> isort.ipynb:cell 3:1:1 | 1 | / from pathlib import Path 2 | | import sys - | |__________^ I001 + | |__________^ 3 | 4 | %matplotlib \ | - = help: Organize imports +help: Organize imports ℹ Safe fix 6 6 | # Newline should be added here @@ -64,15 +67,16 @@ isort.ipynb:cell 3:1:1: I001 [*] Import block is un-sorted or un-formatted 12 12 | %matplotlib \ 13 13 | --inline -isort.ipynb:cell 3:7:1: I001 [*] Import block is un-sorted or un-formatted +I001 [*] Import block is un-sorted or un-formatted + --> isort.ipynb:cell 3:7:1 | 5 | --inline 6 | 7 | / import math 8 | | import abc - | |__________^ I001 + | |__________^ | - = help: Organize imports +help: Organize imports ℹ Safe fix 12 12 | %matplotlib \ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap index 1bf54524d9..d373e3d036 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap @@ -1,16 +1,17 @@ --- source: crates/ruff_linter/src/linter.rs --- -ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> ipy_escape_command.ipynb:cell 1:5:8 | 3 | %matplotlib inline 4 | 5 | import os - | ^^ F401 + | ^^ 6 | 7 | _ = math.pi | - = help: Remove unused import: `os` +help: Remove unused import: `os` ℹ Safe fix 2 2 | @@ -21,13 +22,14 @@ ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused 7 6 | _ = math.pi 8 7 | %%timeit -ipy_escape_command.ipynb:cell 2:2:8: F401 [*] `sys` imported but unused +F401 [*] `sys` imported but unused + --> ipy_escape_command.ipynb:cell 2:2:8 | 1 | %%timeit 2 | import sys - | ^^^ F401 + | ^^^ | - = help: Remove unused import: `sys` +help: Remove unused import: `sys` ℹ Safe fix 6 6 | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__late_future_import.py.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__late_future_import.py.snap index 6140d4cf40..0274914bac 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__late_future_import.py.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__late_future_import.py.snap @@ -1,9 +1,10 @@ --- source: crates/ruff_linter/src/linter.rs --- -resources/test/fixtures/syntax_errors/late_future_import.py:2:1: F404 `from __future__` imports must occur at the beginning of the file +F404 `from __future__` imports must occur at the beginning of the file + --> resources/test/fixtures/syntax_errors/late_future_import.py:2:1 | 1 | import random 2 | from __future__ import annotations # Error; not at top of file - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__load_before_global_declaration.py.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__load_before_global_declaration.py.snap index a917491f41..78c5451980 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__load_before_global_declaration.py.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__load_before_global_declaration.py.snap @@ -1,20 +1,22 @@ --- source: crates/ruff_linter/src/linter.rs --- -resources/test/fixtures/syntax_errors/load_before_global_declaration.py:9:5: PLE0118 Name `x` is used prior to global declaration on line 10 +PLE0118 Name `x` is used prior to global declaration on line 10 + --> resources/test/fixtures/syntax_errors/load_before_global_declaration.py:9:5 | 7 | x = 10 8 | def test_2(): 9 | x += 1 # error - | ^ PLE0118 + | ^ 10 | global x | -resources/test/fixtures/syntax_errors/load_before_global_declaration.py:13:11: PLE0118 Name `x` is used prior to global declaration on line 14 +PLE0118 Name `x` is used prior to global declaration on line 14 + --> resources/test/fixtures/syntax_errors/load_before_global_declaration.py:13:11 | 12 | def test_3(): 13 | print(x) # error - | ^ PLE0118 + | ^ 14 | global x 15 | x = 5 | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__return_outside_function.py.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__return_outside_function.py.snap index db348572fe..dd8114a6dc 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__return_outside_function.py.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__return_outside_function.py.snap @@ -1,31 +1,35 @@ --- source: crates/ruff_linter/src/linter.rs --- -resources/test/fixtures/syntax_errors/return_outside_function.py:13:1: F706 `return` statement outside of a function/method +F706 `return` statement outside of a function/method + --> resources/test/fixtures/syntax_errors/return_outside_function.py:13:1 | 13 | return 1 # error - | ^^^^^^^^ F706 + | ^^^^^^^^ 14 | return # error | -resources/test/fixtures/syntax_errors/return_outside_function.py:14:1: F706 `return` statement outside of a function/method +F706 `return` statement outside of a function/method + --> resources/test/fixtures/syntax_errors/return_outside_function.py:14:1 | 13 | return 1 # error 14 | return # error - | ^^^^^^ F706 + | ^^^^^^ | -resources/test/fixtures/syntax_errors/return_outside_function.py:18:5: F706 `return` statement outside of a function/method +F706 `return` statement outside of a function/method + --> resources/test/fixtures/syntax_errors/return_outside_function.py:18:5 | 17 | class C: 18 | return 1 # error - | ^^^^^^^^ F706 + | ^^^^^^^^ | -resources/test/fixtures/syntax_errors/return_outside_function.py:23:9: F706 `return` statement outside of a function/method +F706 `return` statement outside of a function/method + --> resources/test/fixtures/syntax_errors/return_outside_function.py:23:9 | 21 | def f(): 22 | class C: 23 | return 1 # error - | ^^^^^^^^ F706 + | ^^^^^^^^ | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_AsyncComprehensionOutsideAsyncFunction_async_in_sync_error_on_310_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_AsyncComprehensionOutsideAsyncFunction_async_in_sync_error_on_310_3.10.snap index 8f0b694212..24eeb50a9a 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_AsyncComprehensionOutsideAsyncFunction_async_in_sync_error_on_310_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_AsyncComprehensionOutsideAsyncFunction_async_in_sync_error_on_310_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:1:27: invalid-syntax: cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (syntax was added in 3.11) +invalid-syntax: cannot use an asynchronous comprehension inside of a synchronous comprehension on Python 3.10 (syntax was added in 3.11) + --> :1:27 | 1 | async def f(): return [[x async for x in foo(n)] for n in range(3)] | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateMatchClassAttribute_duplicate_match_class_attribute_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateMatchClassAttribute_duplicate_match_class_attribute_3.10.snap index c54cffce1c..5c8dcb3dea 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateMatchClassAttribute_duplicate_match_class_attribute_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateMatchClassAttribute_duplicate_match_class_attribute_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:3:21: invalid-syntax: attribute name `x` repeated in class pattern +invalid-syntax: attribute name `x` repeated in class pattern + --> :3:21 | 2 | match x: 3 | case Point(x=1, x=2): diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateMatchKey_duplicate_match_key_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateMatchKey_duplicate_match_key_3.10.snap index 0dff722356..5f4a0040a8 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateMatchKey_duplicate_match_key_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateMatchKey_duplicate_match_key_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:3:21: invalid-syntax: mapping pattern checks duplicate key `'key'` +invalid-syntax: mapping pattern checks duplicate key `'key'` + --> :3:21 | 2 | match x: 3 | case {'key': 1, 'key': 2}: diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateTypeParameter_duplicate_type_param_3.12.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateTypeParameter_duplicate_type_param_3.12.snap index a216e0014f..bfd85698f6 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateTypeParameter_duplicate_type_param_3.12.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_DuplicateTypeParameter_duplicate_type_param_3.12.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:1:12: invalid-syntax: duplicate type parameter +invalid-syntax: duplicate type parameter + --> :1:12 | 1 | class C[T, T]: pass | ^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_walrus_in_return_annotation_3.12.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_walrus_in_return_annotation_3.12.snap index 9302f2f743..8993d2acbe 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_walrus_in_return_annotation_3.12.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_walrus_in_return_annotation_3.12.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:2:22: invalid-syntax: named expression cannot be used within a generic definition +invalid-syntax: named expression cannot be used within a generic definition + --> :2:22 | 2 | def f[T](x: int) -> (y := 3): return x | ^^^^^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_from_in_base_class_3.12.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_from_in_base_class_3.12.snap index 9b53c29edd..aa0b77de19 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_from_in_base_class_3.12.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_from_in_base_class_3.12.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:2:13: invalid-syntax: yield expression cannot be used within a generic definition +invalid-syntax: yield expression cannot be used within a generic definition + --> :2:13 | 2 | class C[T]((yield from [object])): | ^^^^^^^^^^^^^^^^^^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_in_type_alias_3.12.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_in_type_alias_3.12.snap index 04022d4371..5c1135bdb3 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_in_type_alias_3.12.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_in_type_alias_3.12.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:2:11: invalid-syntax: yield expression cannot be used within a type alias +invalid-syntax: yield expression cannot be used within a type alias + --> :2:11 | 2 | type Y = (yield 1) | ^^^^^^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_in_type_param_3.12.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_in_type_param_3.12.snap index 77f409e139..97171b88c3 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_in_type_param_3.12.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidExpression_invalid_expression_yield_in_type_param_3.12.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:2:12: invalid-syntax: yield expression cannot be used within a TypeVar bound +invalid-syntax: yield expression cannot be used within a TypeVar bound + --> :2:12 | 2 | type X[T: (yield 1)] = int | ^^^^^^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_3.10.snap index 823721b5ad..0e454a7167 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:3:12: invalid-syntax: Starred expression cannot be used here +invalid-syntax: Starred expression cannot be used here + --> :3:12 | 2 | def func(): 3 | return *x diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_for_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_for_3.10.snap index 360ed91ab1..d6ea25739b 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_for_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_for_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:2:5: invalid-syntax: Starred expression cannot be used here +invalid-syntax: Starred expression cannot be used here + --> :2:5 | 2 | for *x in range(10): | ^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_yield_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_yield_3.10.snap index 250f75191b..a471ef94fd 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_yield_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_InvalidStarExpression_invalid_star_expression_yield_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:3:11: invalid-syntax: Starred expression cannot be used here +invalid-syntax: Starred expression cannot be used here + --> :3:11 | 2 | def func(): 3 | yield *x diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_IrrefutableCasePattern_irrefutable_case_pattern_capture_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_IrrefutableCasePattern_irrefutable_case_pattern_capture_3.10.snap index f4eff967a9..44ce08366d 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_IrrefutableCasePattern_irrefutable_case_pattern_capture_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_IrrefutableCasePattern_irrefutable_case_pattern_capture_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:3:10: invalid-syntax: name capture `irrefutable` makes remaining patterns unreachable +invalid-syntax: name capture `irrefutable` makes remaining patterns unreachable + --> :3:10 | 2 | match value: 3 | case irrefutable: diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_IrrefutableCasePattern_irrefutable_case_pattern_wildcard_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_IrrefutableCasePattern_irrefutable_case_pattern_wildcard_3.10.snap index ac8a5e593e..74006baae1 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_IrrefutableCasePattern_irrefutable_case_pattern_wildcard_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_IrrefutableCasePattern_irrefutable_case_pattern_wildcard_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:3:10: invalid-syntax: wildcard makes remaining patterns unreachable +invalid-syntax: wildcard makes remaining patterns unreachable + --> :3:10 | 2 | match value: 3 | case _: diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_MultipleCaseAssignment_multiple_case_assignment_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_MultipleCaseAssignment_multiple_case_assignment_3.10.snap index 6fca18778a..64e8b8e863 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_MultipleCaseAssignment_multiple_case_assignment_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_MultipleCaseAssignment_multiple_case_assignment_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:3:14: invalid-syntax: multiple assignments to name `a` in pattern +invalid-syntax: multiple assignments to name `a` in pattern + --> :3:14 | 2 | match x: 3 | case [a, a]: diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_ReboundComprehensionVariable_rebound_comprehension_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_ReboundComprehensionVariable_rebound_comprehension_3.10.snap index c08764edd5..5f7b81b610 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_ReboundComprehensionVariable_rebound_comprehension_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_ReboundComprehensionVariable_rebound_comprehension_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:1:2: invalid-syntax: assignment expression cannot rebind comprehension variable +invalid-syntax: assignment expression cannot rebind comprehension variable + --> :1:2 | 1 | [x:= 2 for x in range(2)] | ^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_SingleStarredAssignment_single_starred_assignment_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_SingleStarredAssignment_single_starred_assignment_3.10.snap index 2295dec878..e4955a4574 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_SingleStarredAssignment_single_starred_assignment_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_SingleStarredAssignment_single_starred_assignment_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:1:1: invalid-syntax: starred assignment target must be in a list or tuple +invalid-syntax: starred assignment target must be in a list or tuple + --> :1:1 | 1 | *a = [1, 2, 3, 4] | ^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_3.10.snap index 576fcb6706..52841dbfab 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:2:1: invalid-syntax: cannot assign to `__debug__` +invalid-syntax: cannot assign to `__debug__` + --> :2:1 | 2 | __debug__ = False | ^^^^^^^^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_class_type_param_3.12.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_class_type_param_3.12.snap index 7db94e4b2e..80b922ffa3 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_class_type_param_3.12.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_class_type_param_3.12.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:2:15: invalid-syntax: cannot assign to `__debug__` +invalid-syntax: cannot assign to `__debug__` + --> :2:15 | 2 | class Generic[__debug__]: | ^^^^^^^^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_in_function_param_3.10.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_in_function_param_3.10.snap index 12e6d3d0a6..0c0b86534c 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_in_function_param_3.10.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__semantic_syntax_error_WriteToDebug_write_to_debug_in_function_param_3.10.snap @@ -1,7 +1,8 @@ --- source: crates/ruff_linter/src/linter.rs --- -:2:13: invalid-syntax: cannot assign to `__debug__` +invalid-syntax: cannot assign to `__debug__` + --> :2:13 | 2 | def process(__debug__): | ^^^^^^^^^ diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__undefined_name.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__undefined_name.snap index 88cd59f63c..478ccbfead 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__undefined_name.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__undefined_name.snap @@ -1,8 +1,9 @@ --- source: crates/ruff_linter/src/linter.rs --- -undefined_name.ipynb:cell 3:1:7: F821 Undefined name `undefined` +F821 Undefined name `undefined` + --> undefined_name.ipynb:cell 3:1:7 | 1 | print(undefined) - | ^^^^^^^^^ F821 + | ^^^^^^^^^ | diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap index f59bd1aea2..3e51ee839d 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/linter.rs --- -unused_variable.ipynb:cell 1:2:5: F841 [*] Local variable `foo1` is assigned to but never used +F841 [*] Local variable `foo1` is assigned to but never used + --> unused_variable.ipynb:cell 1:2:5 | 1 | def f(): 2 | foo1 = %matplotlib --list - | ^^^^ F841 + | ^^^^ 3 | foo2: list[str] = %matplotlib --list | - = help: Remove assignment to unused variable `foo1` +help: Remove assignment to unused variable `foo1` ℹ Unsafe fix 1 1 | def f(): @@ -18,14 +19,15 @@ unused_variable.ipynb:cell 1:2:5: F841 [*] Local variable `foo1` is assigned to 4 4 | def f(): 5 5 | bar1 = !pwd -unused_variable.ipynb:cell 1:3:5: F841 [*] Local variable `foo2` is assigned to but never used +F841 [*] Local variable `foo2` is assigned to but never used + --> unused_variable.ipynb:cell 1:3:5 | 1 | def f(): 2 | foo1 = %matplotlib --list 3 | foo2: list[str] = %matplotlib --list - | ^^^^ F841 + | ^^^^ | - = help: Remove assignment to unused variable `foo2` +help: Remove assignment to unused variable `foo2` ℹ Unsafe fix 1 1 | def f(): @@ -36,14 +38,15 @@ unused_variable.ipynb:cell 1:3:5: F841 [*] Local variable `foo2` is assigned to 5 5 | bar1 = !pwd 6 6 | bar2: str = !pwd -unused_variable.ipynb:cell 2:2:5: F841 [*] Local variable `bar1` is assigned to but never used +F841 [*] Local variable `bar1` is assigned to but never used + --> unused_variable.ipynb:cell 2:2:5 | 1 | def f(): 2 | bar1 = !pwd - | ^^^^ F841 + | ^^^^ 3 | bar2: str = !pwd | - = help: Remove assignment to unused variable `bar1` +help: Remove assignment to unused variable `bar1` ℹ Unsafe fix 2 2 | foo1 = %matplotlib --list @@ -53,14 +56,15 @@ unused_variable.ipynb:cell 2:2:5: F841 [*] Local variable `bar1` is assigned to 5 |+ !pwd 6 6 | bar2: str = !pwd -unused_variable.ipynb:cell 2:3:5: F841 [*] Local variable `bar2` is assigned to but never used +F841 [*] Local variable `bar2` is assigned to but never used + --> unused_variable.ipynb:cell 2:3:5 | 1 | def f(): 2 | bar1 = !pwd 3 | bar2: str = !pwd - | ^^^^ F841 + | ^^^^ | - = help: Remove assignment to unused variable `bar2` +help: Remove assignment to unused variable `bar2` ℹ Unsafe fix 3 3 | foo2: list[str] = %matplotlib --list diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__vscode_language_id.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__vscode_language_id.snap index a8c65c981a..8bdc926bd5 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__vscode_language_id.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__vscode_language_id.snap @@ -1,14 +1,15 @@ --- source: crates/ruff_linter/src/linter.rs --- -vscode_language_id.ipynb:cell 3:1:8: F401 [*] `os` imported but unused +F401 [*] `os` imported but unused + --> vscode_language_id.ipynb:cell 3:1:8 | 1 | import os - | ^^ F401 + | ^^ 2 | 3 | print("hello world") | - = help: Remove unused import: `os` +help: Remove unused import: `os` ℹ Safe fix 1 |-import os diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__yield_scope.py.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__yield_scope.py.snap index dad54fa50e..e32c627fce 100644 --- a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__yield_scope.py.snap +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__yield_scope.py.snap @@ -1,117 +1,130 @@ --- source: crates/ruff_linter/src/linter.rs --- -resources/test/fixtures/syntax_errors/yield_scope.py:1:1: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:1:1 | 1 | yield # error - | ^^^^^ F704 + | ^^^^^ 2 | yield 1 # error 3 | yield from 1 # error | -resources/test/fixtures/syntax_errors/yield_scope.py:2:1: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:2:1 | 1 | yield # error 2 | yield 1 # error - | ^^^^^^^ F704 + | ^^^^^^^ 3 | yield from 1 # error 4 | await 1 # error | -resources/test/fixtures/syntax_errors/yield_scope.py:3:1: F704 `yield from` statement outside of a function +F704 `yield from` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:3:1 | 1 | yield # error 2 | yield 1 # error 3 | yield from 1 # error - | ^^^^^^^^^^^^ F704 + | ^^^^^^^^^^^^ 4 | await 1 # error 5 | [(yield x) for x in range(3)] # error | -resources/test/fixtures/syntax_errors/yield_scope.py:4:1: F704 `await` statement outside of a function +F704 `await` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:4:1 | 2 | yield 1 # error 3 | yield from 1 # error 4 | await 1 # error - | ^^^^^^^ F704 + | ^^^^^^^ 5 | [(yield x) for x in range(3)] # error | -resources/test/fixtures/syntax_errors/yield_scope.py:5:3: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:5:3 | 3 | yield from 1 # error 4 | await 1 # error 5 | [(yield x) for x in range(3)] # error - | ^^^^^^^ F704 + | ^^^^^^^ | -resources/test/fixtures/syntax_errors/yield_scope.py:23:9: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:23:9 | 21 | def outer(): 22 | class C: 23 | yield 1 # error - | ^^^^^^^ F704 + | ^^^^^^^ 24 | 25 | [(yield 1) for x in range(3)] # error | -resources/test/fixtures/syntax_errors/yield_scope.py:25:7: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:25:7 | 23 | yield 1 # error 24 | 25 | [(yield 1) for x in range(3)] # error - | ^^^^^^^ F704 + | ^^^^^^^ 26 | ((yield 1) for x in range(3)) # error 27 | {(yield 1) for x in range(3)} # error | -resources/test/fixtures/syntax_errors/yield_scope.py:26:7: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:26:7 | 25 | [(yield 1) for x in range(3)] # error 26 | ((yield 1) for x in range(3)) # error - | ^^^^^^^ F704 + | ^^^^^^^ 27 | {(yield 1) for x in range(3)} # error 28 | {(yield 1): 0 for x in range(3)} # error | -resources/test/fixtures/syntax_errors/yield_scope.py:27:7: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:27:7 | 25 | [(yield 1) for x in range(3)] # error 26 | ((yield 1) for x in range(3)) # error 27 | {(yield 1) for x in range(3)} # error - | ^^^^^^^ F704 + | ^^^^^^^ 28 | {(yield 1): 0 for x in range(3)} # error 29 | {0: (yield 1) for x in range(3)} # error | -resources/test/fixtures/syntax_errors/yield_scope.py:28:7: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:28:7 | 26 | ((yield 1) for x in range(3)) # error 27 | {(yield 1) for x in range(3)} # error 28 | {(yield 1): 0 for x in range(3)} # error - | ^^^^^^^ F704 + | ^^^^^^^ 29 | {0: (yield 1) for x in range(3)} # error | -resources/test/fixtures/syntax_errors/yield_scope.py:29:10: F704 `yield` statement outside of a function +F704 `yield` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:29:10 | 27 | {(yield 1) for x in range(3)} # error 28 | {(yield 1): 0 for x in range(3)} # error 29 | {0: (yield 1) for x in range(3)} # error - | ^^^^^^^ F704 + | ^^^^^^^ | -resources/test/fixtures/syntax_errors/yield_scope.py:36:10: F704 `await` statement outside of a function +F704 `await` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:36:10 | 35 | class C: 36 | [await x for x in range(3)] # error, classes break async scope - | ^^^^^^^ F704 + | ^^^^^^^ 37 | 38 | lambda x: await x # okay for now, lambda breaks _async_ scope but is a function | -resources/test/fixtures/syntax_errors/yield_scope.py:41:1: F704 `await` statement outside of a function +F704 `await` statement outside of a function + --> resources/test/fixtures/syntax_errors/yield_scope.py:41:1 | 41 | await 1 # error - | ^^^^^^^ F704 + | ^^^^^^^ |