From 1865ecb68bbc44fab5076a78ae496da0528efa09 Mon Sep 17 00:00:00 2001 From: cake-monotone Date: Tue, 10 Sep 2024 19:10:25 +0900 Subject: [PATCH] snapshots for refactored classification logic --- .../test/fixtures/flake8_unused_arguments/ARG.py | 9 +++++++++ .../flake8_pyi/rules/custom_type_var_return_type.rs | 5 ++--- ...lake8_unused_arguments__tests__ARG002_ARG.py.snap | 12 +++++------- ...lake8_unused_arguments__tests__ARG004_ARG.py.snap | 9 ++++++++- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ARG.py b/crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ARG.py index 9a8fd4c83585c..ae75a951df324 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ARG.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ARG.py @@ -189,6 +189,9 @@ def f(a, b): # Unused arguments on magic methods. ### class C: + def __new__(cls, x): + print("Hello, world!") + def __init__(self, x) -> None: print("Hello, world!") @@ -198,6 +201,12 @@ def __str__(self) -> str: def __exit__(self, exc_type, exc_value, traceback) -> None: print("Hello, world!") + def __init_subclass__(cls, x) -> None: + print("Hello, world!") + + def __class_getitem__(cls, x): + print("Hello, world!") + ### # Used arguments on chained cast. diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs index aed4234bc5e1c..dc1fe4ad9233c 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs @@ -189,9 +189,8 @@ impl<'a> ClassMethod<'a> { } } -// Dunder new methods (`__new__`, also known as magic methods) are technically static methods, -// with `cls` as their first argument. However, for the purpose of this check, we treat them -// as class methods. +// Dunder new methods (`__new__`) are technically static methods with `cls` as their first argument. +// For simplicity of implementation, we treat them as class methods. use ClassMethod as DunderNewMethod; #[derive(Debug)] 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 e235a37a5394c..e41bd736c1916 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 @@ -28,13 +28,11 @@ ARG.py:43:16: ARG002 Unused method argument: `x` 44 | print("Hello, world!") | -ARG.py:192:24: ARG002 Unused method argument: `x` +ARG.py:195:24: ARG002 Unused method argument: `x` | -190 | ### -191 | class C: -192 | def __init__(self, x) -> None: - | ^ ARG002 193 | print("Hello, world!") +194 | +195 | def __init__(self, x) -> None: + | ^ ARG002 +196 | 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 b1b046fe91c76..b86a2ad37583e 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 @@ -25,4 +25,11 @@ ARG.py:55:11: ARG004 Unused static method argument: `x` 56 | print("Hello, world!") | - +ARG.py:192:22: ARG004 Unused static method argument: `x` + | +190 | ### +191 | class C: +192 | def __new__(cls, x): + | ^ ARG004 +193 | print("Hello, world!") + |