mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:18 +00:00
[ruff 0.8][flake8-type-checking
] Rename TCH
to TC
(#14438)
Closes #9573
This commit is contained in:
parent
8c3c5ee5e3
commit
dc05b38165
102 changed files with 460 additions and 452 deletions
|
@ -1,6 +1,6 @@
|
||||||
"""Tests to determine first-party import classification.
|
"""Tests to determine first-party import classification.
|
||||||
|
|
||||||
For typing-only import detection tests, see `TCH002.py`.
|
For typing-only import detection tests, see `TC002.py`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -2,49 +2,49 @@
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
import pandas as pd # TCH002
|
import pandas as pd # TC002
|
||||||
|
|
||||||
x: pd.DataFrame
|
x: pd.DataFrame
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
from pandas import DataFrame # TCH002
|
from pandas import DataFrame # TC002
|
||||||
|
|
||||||
x: DataFrame
|
x: DataFrame
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
from pandas import DataFrame as df # TCH002
|
from pandas import DataFrame as df # TC002
|
||||||
|
|
||||||
x: df
|
x: df
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
import pandas as pd # TCH002
|
import pandas as pd # TC002
|
||||||
|
|
||||||
x: pd.DataFrame = 1
|
x: pd.DataFrame = 1
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
from pandas import DataFrame # TCH002
|
from pandas import DataFrame # TC002
|
||||||
|
|
||||||
x: DataFrame = 2
|
x: DataFrame = 2
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
from pandas import DataFrame as df # TCH002
|
from pandas import DataFrame as df # TC002
|
||||||
|
|
||||||
x: df = 3
|
x: df = 3
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
import pandas as pd # TCH002
|
import pandas as pd # TC002
|
||||||
|
|
||||||
x: "pd.DataFrame" = 1
|
x: "pd.DataFrame" = 1
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
import pandas as pd # TCH002
|
import pandas as pd # TC002
|
||||||
|
|
||||||
x = dict["pd.DataFrame", "pd.DataFrame"]
|
x = dict["pd.DataFrame", "pd.DataFrame"]
|
||||||
|
|
||||||
|
@ -153,13 +153,13 @@ def f():
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
from pandas import DataFrame # noqa: TCH002
|
from pandas import DataFrame # noqa: TC002
|
||||||
|
|
||||||
x: DataFrame = 2
|
x: DataFrame = 2
|
||||||
|
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
from pandas import ( # noqa: TCH002
|
from pandas import ( # noqa: TC002
|
||||||
DataFrame,
|
DataFrame,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Tests to determine standard library import classification.
|
"""Tests to determine standard library import classification.
|
||||||
|
|
||||||
For typing-only import detection tests, see `TCH002.py`.
|
For typing-only import detection tests, see `TC002.py`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
from typing import TYPE_CHECKING, List
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
pass # TCH005
|
pass # TC005
|
||||||
|
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
pass # TCH005
|
pass # TC005
|
||||||
|
|
||||||
if 0:
|
if 0:
|
||||||
pass # TCH005
|
pass # TC005
|
||||||
|
|
||||||
|
|
||||||
def example():
|
def example():
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
pass # TCH005
|
pass # TC005
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class Test:
|
class Test:
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
pass # TCH005
|
pass # TC005
|
||||||
x = 2
|
x = 2
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ if 0:
|
||||||
from typing_extensions import TYPE_CHECKING
|
from typing_extensions import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
pass # TCH005
|
pass # TC005
|
||||||
|
|
||||||
# https://github.com/astral-sh/ruff/issues/11368
|
# https://github.com/astral-sh/ruff/issues/11368
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
18
crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TC010_1.py
vendored
Normal file
18
crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TC010_1.py
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TypeVar
|
||||||
|
|
||||||
|
|
||||||
|
x: "int" | str # TC010
|
||||||
|
x: ("int" | str) | "bool" # TC010
|
||||||
|
|
||||||
|
|
||||||
|
def func():
|
||||||
|
x: "int" | str # OK
|
||||||
|
|
||||||
|
|
||||||
|
z: list[str, str | "int"] = [] # TC010
|
||||||
|
|
||||||
|
type A = Value["int" | str] # OK
|
||||||
|
|
||||||
|
OldS = TypeVar('OldS', int | 'str', str) # TC010
|
16
crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TC010_2.py
vendored
Normal file
16
crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TC010_2.py
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from typing import TypeVar
|
||||||
|
|
||||||
|
|
||||||
|
x: "int" | str # TC010
|
||||||
|
x: ("int" | str) | "bool" # TC010
|
||||||
|
|
||||||
|
|
||||||
|
def func():
|
||||||
|
x: "int" | str # OK
|
||||||
|
|
||||||
|
|
||||||
|
z: list[str, str | "int"] = [] # TC010
|
||||||
|
|
||||||
|
type A = Value["int" | str] # OK
|
||||||
|
|
||||||
|
OldS = TypeVar('OldS', int | 'str', str) # TC010
|
|
@ -1,18 +0,0 @@
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from typing import TypeVar
|
|
||||||
|
|
||||||
|
|
||||||
x: "int" | str # TCH010
|
|
||||||
x: ("int" | str) | "bool" # TCH010
|
|
||||||
|
|
||||||
|
|
||||||
def func():
|
|
||||||
x: "int" | str # OK
|
|
||||||
|
|
||||||
|
|
||||||
z: list[str, str | "int"] = [] # TCH010
|
|
||||||
|
|
||||||
type A = Value["int" | str] # OK
|
|
||||||
|
|
||||||
OldS = TypeVar('OldS', int | 'str', str) # TCH010
|
|
|
@ -1,16 +0,0 @@
|
||||||
from typing import TypeVar
|
|
||||||
|
|
||||||
|
|
||||||
x: "int" | str # TCH010
|
|
||||||
x: ("int" | str) | "bool" # TCH010
|
|
||||||
|
|
||||||
|
|
||||||
def func():
|
|
||||||
x: "int" | str # OK
|
|
||||||
|
|
||||||
|
|
||||||
z: list[str, str | "int"] = [] # TCH010
|
|
||||||
|
|
||||||
type A = Value["int" | str] # OK
|
|
||||||
|
|
||||||
OldS = TypeVar('OldS', int | 'str', str) # TCH010
|
|
|
@ -7,10 +7,10 @@ import pydantic
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import datetime # TCH004
|
import datetime # TC004
|
||||||
from array import array # TCH004
|
from array import array # TC004
|
||||||
|
|
||||||
import pandas # TCH004
|
import pandas # TC004
|
||||||
import pyproj
|
import pyproj
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import geopandas as gpd # TCH002
|
import geopandas as gpd # TC002
|
||||||
import pydantic
|
import pydantic
|
||||||
import pyproj # TCH002
|
import pyproj # TC002
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
|
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import pathlib
|
import pathlib
|
||||||
from uuid import UUID # TCH003
|
from uuid import UUID # TC003
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
|
@ -9,10 +9,10 @@ from attrs import frozen
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import datetime # TCH004
|
import datetime # TC004
|
||||||
from array import array # TCH004
|
from array import array # TC004
|
||||||
|
|
||||||
import pandas # TCH004
|
import pandas # TC004
|
||||||
import pyproj
|
import pyproj
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import pandas
|
||||||
import pyproj
|
import pyproj
|
||||||
from attrs import frozen
|
from attrs import frozen
|
||||||
|
|
||||||
import numpy # TCH002
|
import numpy # TC002
|
||||||
|
|
||||||
|
|
||||||
@attrs.define(auto_attribs=True)
|
@attrs.define(auto_attribs=True)
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
import datetime
|
import datetime
|
||||||
from array import array
|
from array import array
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from uuid import UUID # TCH003
|
from uuid import UUID # TC003
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from pydantic import validate_call
|
from pydantic import validate_call
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ pub enum Linter {
|
||||||
#[prefix = "TID"]
|
#[prefix = "TID"]
|
||||||
Flake8TidyImports,
|
Flake8TidyImports,
|
||||||
/// [flake8-type-checking](https://pypi.org/project/flake8-type-checking/)
|
/// [flake8-type-checking](https://pypi.org/project/flake8-type-checking/)
|
||||||
#[prefix = "TCH"]
|
#[prefix = "TC"]
|
||||||
Flake8TypeChecking,
|
Flake8TypeChecking,
|
||||||
/// [flake8-gettext](https://pypi.org/project/flake8-gettext/)
|
/// [flake8-gettext](https://pypi.org/project/flake8-gettext/)
|
||||||
#[prefix = "INT"]
|
#[prefix = "INT"]
|
||||||
|
|
|
@ -87,8 +87,8 @@ static REDIRECTS: LazyLock<HashMap<&'static str, &'static str>> = LazyLock::new(
|
||||||
("PDV90", "PD90"),
|
("PDV90", "PD90"),
|
||||||
("PDV901", "PD901"),
|
("PDV901", "PD901"),
|
||||||
// TODO(charlie): Remove by 2023-04-01.
|
// TODO(charlie): Remove by 2023-04-01.
|
||||||
("TYP", "TCH"),
|
("TYP", "TC"),
|
||||||
("TYP001", "TCH001"),
|
("TYP001", "TC001"),
|
||||||
// TODO(charlie): Remove by 2023-06-01.
|
// TODO(charlie): Remove by 2023-06-01.
|
||||||
("RUF004", "B026"),
|
("RUF004", "B026"),
|
||||||
("PIE802", "C419"),
|
("PIE802", "C419"),
|
||||||
|
@ -98,7 +98,6 @@ static REDIRECTS: LazyLock<HashMap<&'static str, &'static str>> = LazyLock::new(
|
||||||
("T003", "FIX003"),
|
("T003", "FIX003"),
|
||||||
("T004", "FIX004"),
|
("T004", "FIX004"),
|
||||||
("RUF011", "B035"),
|
("RUF011", "B035"),
|
||||||
("TCH006", "TCH010"),
|
|
||||||
("TRY200", "B904"),
|
("TRY200", "B904"),
|
||||||
("PGH001", "S307"),
|
("PGH001", "S307"),
|
||||||
("PGH002", "G010"),
|
("PGH002", "G010"),
|
||||||
|
@ -126,5 +125,14 @@ static REDIRECTS: LazyLock<HashMap<&'static str, &'static str>> = LazyLock::new(
|
||||||
("RUF025", "C420"),
|
("RUF025", "C420"),
|
||||||
// See: https://github.com/astral-sh/ruff/issues/13492
|
// See: https://github.com/astral-sh/ruff/issues/13492
|
||||||
("TRY302", "TRY203"),
|
("TRY302", "TRY203"),
|
||||||
|
// TCH renamed to TC to harmonize with flake8 plugin
|
||||||
|
("TCH", "TC"),
|
||||||
|
("TCH001", "TC001"),
|
||||||
|
("TCH002", "TC002"),
|
||||||
|
("TCH003", "TC003"),
|
||||||
|
("TCH004", "TC004"),
|
||||||
|
("TCH005", "TC005"),
|
||||||
|
("TCH006", "TC010"),
|
||||||
|
("TCH010", "TC010"),
|
||||||
])
|
])
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,29 +16,29 @@ mod tests {
|
||||||
use crate::test::{test_path, test_snippet};
|
use crate::test::{test_path, test_snippet};
|
||||||
use crate::{assert_messages, settings};
|
use crate::{assert_messages, settings};
|
||||||
|
|
||||||
#[test_case(Rule::EmptyTypeCheckingBlock, Path::new("TCH005.py"))]
|
#[test_case(Rule::EmptyTypeCheckingBlock, Path::new("TC005.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_1.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_1.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_10.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_10.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_11.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_11.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_12.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_12.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_13.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_13.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_14.pyi"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_14.pyi"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_15.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_15.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_16.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_16.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_17.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_17.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_2.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_2.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_3.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_3.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_4.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_4.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_5.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_5.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_6.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_6.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_7.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_7.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_8.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_8.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TCH004_9.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("TC004_9.py"))]
|
||||||
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("quote.py"))]
|
#[test_case(Rule::RuntimeImportInTypeCheckingBlock, Path::new("quote.py"))]
|
||||||
#[test_case(Rule::RuntimeStringUnion, Path::new("TCH010_1.py"))]
|
#[test_case(Rule::RuntimeStringUnion, Path::new("TC010_1.py"))]
|
||||||
#[test_case(Rule::RuntimeStringUnion, Path::new("TCH010_2.py"))]
|
#[test_case(Rule::RuntimeStringUnion, Path::new("TC010_2.py"))]
|
||||||
#[test_case(Rule::TypingOnlyFirstPartyImport, Path::new("TCH001.py"))]
|
#[test_case(Rule::TypingOnlyFirstPartyImport, Path::new("TC001.py"))]
|
||||||
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("TCH003.py"))]
|
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("TC003.py"))]
|
||||||
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("init_var.py"))]
|
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("init_var.py"))]
|
||||||
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("kw_only.py"))]
|
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("kw_only.py"))]
|
||||||
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("snapshot.py"))]
|
#[test_case(Rule::TypingOnlyStandardLibraryImport, Path::new("snapshot.py"))]
|
||||||
|
@ -46,7 +46,7 @@ mod tests {
|
||||||
Rule::TypingOnlyStandardLibraryImport,
|
Rule::TypingOnlyStandardLibraryImport,
|
||||||
Path::new("singledispatchmethod.py")
|
Path::new("singledispatchmethod.py")
|
||||||
)]
|
)]
|
||||||
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("TCH002.py"))]
|
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("TC002.py"))]
|
||||||
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("quote.py"))]
|
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("quote.py"))]
|
||||||
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("singledispatch.py"))]
|
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("singledispatch.py"))]
|
||||||
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("strict.py"))]
|
#[test_case(Rule::TypingOnlyThirdPartyImport, Path::new("strict.py"))]
|
||||||
|
|
|
@ -46,7 +46,7 @@ impl AlwaysFixableViolation for EmptyTypeCheckingBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TCH005
|
/// TC005
|
||||||
pub(crate) fn empty_type_checking_block(checker: &mut Checker, stmt: &ast::StmtIf) {
|
pub(crate) fn empty_type_checking_block(checker: &mut Checker, stmt: &ast::StmtIf) {
|
||||||
if !typing::is_type_checking_block(stmt, checker.semantic()) {
|
if !typing::is_type_checking_block(stmt, checker.semantic()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -96,7 +96,7 @@ enum Action {
|
||||||
Ignore,
|
Ignore,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TCH004
|
/// TC004
|
||||||
pub(crate) fn runtime_import_in_type_checking_block(
|
pub(crate) fn runtime_import_in_type_checking_block(
|
||||||
checker: &Checker,
|
checker: &Checker,
|
||||||
scope: &Scope,
|
scope: &Scope,
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl Violation for RuntimeStringUnion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TCH006
|
/// TC006
|
||||||
pub(crate) fn runtime_string_union(checker: &mut Checker, expr: &Expr) {
|
pub(crate) fn runtime_string_union(checker: &mut Checker, expr: &Expr) {
|
||||||
if !checker.semantic().in_type_definition() {
|
if !checker.semantic().in_type_definition() {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -243,7 +243,7 @@ impl Violation for TypingOnlyStandardLibraryImport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TCH001, TCH002, TCH003
|
/// TC001, TC002, TC003
|
||||||
pub(crate) fn typing_only_runtime_import(
|
pub(crate) fn typing_only_runtime_import(
|
||||||
checker: &Checker,
|
checker: &Checker,
|
||||||
scope: &Scope,
|
scope: &Scope,
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH005.py:4:5: TCH005 [*] Found empty type-checking block
|
TC005.py:4:5: TC005 [*] Found empty type-checking block
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | pass # TCH005
|
4 | pass # TC005
|
||||||
| ^^^^ TCH005
|
| ^^^^ TC005
|
||||||
|
|
|
|
||||||
= help: Delete empty type-checking block
|
= help: Delete empty type-checking block
|
||||||
|
|
||||||
|
@ -14,55 +14,55 @@ TCH005.py:4:5: TCH005 [*] Found empty type-checking block
|
||||||
1 1 | from typing import TYPE_CHECKING, List
|
1 1 | from typing import TYPE_CHECKING, List
|
||||||
2 2 |
|
2 2 |
|
||||||
3 |-if TYPE_CHECKING:
|
3 |-if TYPE_CHECKING:
|
||||||
4 |- pass # TCH005
|
4 |- pass # TC005
|
||||||
5 3 |
|
5 3 |
|
||||||
6 4 |
|
6 4 |
|
||||||
7 5 | if False:
|
7 5 | if False:
|
||||||
|
|
||||||
TCH005.py:8:5: TCH005 [*] Found empty type-checking block
|
TC005.py:8:5: TC005 [*] Found empty type-checking block
|
||||||
|
|
|
|
||||||
7 | if False:
|
7 | if False:
|
||||||
8 | pass # TCH005
|
8 | pass # TC005
|
||||||
| ^^^^ TCH005
|
| ^^^^ TC005
|
||||||
9 |
|
9 |
|
||||||
10 | if 0:
|
10 | if 0:
|
||||||
|
|
|
|
||||||
= help: Delete empty type-checking block
|
= help: Delete empty type-checking block
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
4 4 | pass # TCH005
|
4 4 | pass # TC005
|
||||||
5 5 |
|
5 5 |
|
||||||
6 6 |
|
6 6 |
|
||||||
7 |-if False:
|
7 |-if False:
|
||||||
8 |- pass # TCH005
|
8 |- pass # TC005
|
||||||
9 7 |
|
9 7 |
|
||||||
10 8 | if 0:
|
10 8 | if 0:
|
||||||
11 9 | pass # TCH005
|
11 9 | pass # TC005
|
||||||
|
|
||||||
TCH005.py:11:5: TCH005 [*] Found empty type-checking block
|
TC005.py:11:5: TC005 [*] Found empty type-checking block
|
||||||
|
|
|
|
||||||
10 | if 0:
|
10 | if 0:
|
||||||
11 | pass # TCH005
|
11 | pass # TC005
|
||||||
| ^^^^ TCH005
|
| ^^^^ TC005
|
||||||
|
|
|
|
||||||
= help: Delete empty type-checking block
|
= help: Delete empty type-checking block
|
||||||
|
|
||||||
ℹ Safe fix
|
ℹ Safe fix
|
||||||
7 7 | if False:
|
7 7 | if False:
|
||||||
8 8 | pass # TCH005
|
8 8 | pass # TC005
|
||||||
9 9 |
|
9 9 |
|
||||||
10 |-if 0:
|
10 |-if 0:
|
||||||
11 |- pass # TCH005
|
11 |- pass # TC005
|
||||||
12 10 |
|
12 10 |
|
||||||
13 11 |
|
13 11 |
|
||||||
14 12 | def example():
|
14 12 | def example():
|
||||||
|
|
||||||
TCH005.py:16:9: TCH005 [*] Found empty type-checking block
|
TC005.py:16:9: TC005 [*] Found empty type-checking block
|
||||||
|
|
|
|
||||||
14 | def example():
|
14 | def example():
|
||||||
15 | if TYPE_CHECKING:
|
15 | if TYPE_CHECKING:
|
||||||
16 | pass # TCH005
|
16 | pass # TC005
|
||||||
| ^^^^ TCH005
|
| ^^^^ TC005
|
||||||
17 | return
|
17 | return
|
||||||
|
|
|
|
||||||
= help: Delete empty type-checking block
|
= help: Delete empty type-checking block
|
||||||
|
@ -72,17 +72,17 @@ TCH005.py:16:9: TCH005 [*] Found empty type-checking block
|
||||||
13 13 |
|
13 13 |
|
||||||
14 14 | def example():
|
14 14 | def example():
|
||||||
15 |- if TYPE_CHECKING:
|
15 |- if TYPE_CHECKING:
|
||||||
16 |- pass # TCH005
|
16 |- pass # TC005
|
||||||
17 15 | return
|
17 15 | return
|
||||||
18 16 |
|
18 16 |
|
||||||
19 17 |
|
19 17 |
|
||||||
|
|
||||||
TCH005.py:22:9: TCH005 [*] Found empty type-checking block
|
TC005.py:22:9: TC005 [*] Found empty type-checking block
|
||||||
|
|
|
|
||||||
20 | class Test:
|
20 | class Test:
|
||||||
21 | if TYPE_CHECKING:
|
21 | if TYPE_CHECKING:
|
||||||
22 | pass # TCH005
|
22 | pass # TC005
|
||||||
| ^^^^ TCH005
|
| ^^^^ TC005
|
||||||
23 | x = 2
|
23 | x = 2
|
||||||
|
|
|
|
||||||
= help: Delete empty type-checking block
|
= help: Delete empty type-checking block
|
||||||
|
@ -92,16 +92,16 @@ TCH005.py:22:9: TCH005 [*] Found empty type-checking block
|
||||||
19 19 |
|
19 19 |
|
||||||
20 20 | class Test:
|
20 20 | class Test:
|
||||||
21 |- if TYPE_CHECKING:
|
21 |- if TYPE_CHECKING:
|
||||||
22 |- pass # TCH005
|
22 |- pass # TC005
|
||||||
23 21 | x = 2
|
23 21 | x = 2
|
||||||
24 22 |
|
24 22 |
|
||||||
25 23 |
|
25 23 |
|
||||||
|
|
||||||
TCH005.py:45:5: TCH005 [*] Found empty type-checking block
|
TC005.py:45:5: TC005 [*] Found empty type-checking block
|
||||||
|
|
|
|
||||||
44 | if TYPE_CHECKING:
|
44 | if TYPE_CHECKING:
|
||||||
45 | pass # TCH005
|
45 | pass # TC005
|
||||||
| ^^^^ TCH005
|
| ^^^^ TC005
|
||||||
46 |
|
46 |
|
||||||
47 | # https://github.com/astral-sh/ruff/issues/11368
|
47 | # https://github.com/astral-sh/ruff/issues/11368
|
||||||
|
|
|
|
||||||
|
@ -112,7 +112,7 @@ TCH005.py:45:5: TCH005 [*] Found empty type-checking block
|
||||||
42 42 | from typing_extensions import TYPE_CHECKING
|
42 42 | from typing_extensions import TYPE_CHECKING
|
||||||
43 43 |
|
43 43 |
|
||||||
44 |-if TYPE_CHECKING:
|
44 |-if TYPE_CHECKING:
|
||||||
45 |- pass # TCH005
|
45 |- pass # TC005
|
||||||
46 44 |
|
46 44 |
|
||||||
47 45 | # https://github.com/astral-sh/ruff/issues/11368
|
47 45 | # https://github.com/astral-sh/ruff/issues/11368
|
||||||
48 46 | if TYPE_CHECKING:
|
48 46 | if TYPE_CHECKING:
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
exempt_modules.py:14:12: TCH002 [*] Move third-party import `flask` into a type-checking block
|
exempt_modules.py:14:12: TC002 [*] Move third-party import `flask` into a type-checking block
|
||||||
|
|
|
|
||||||
13 | def f():
|
13 | def f():
|
||||||
14 | import flask
|
14 | import flask
|
||||||
| ^^^^^ TCH002
|
| ^^^^^ TC002
|
||||||
15 |
|
15 |
|
||||||
16 | x: flask
|
16 | x: flask
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:5:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
<filename>:5:5: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from pandas import (
|
4 | from pandas import (
|
||||||
5 | DataFrame, # DataFrame
|
5 | DataFrame, # DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
6 | Series, # Series
|
6 | Series, # Series
|
||||||
7 | )
|
7 | )
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:7:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
<filename>:7:5: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
6 | from pandas import (
|
6 | from pandas import (
|
||||||
7 | DataFrame, # DataFrame
|
7 | DataFrame, # DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
8 | Series, # Series
|
8 | Series, # Series
|
||||||
9 | )
|
9 | )
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:7:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
<filename>:7:5: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
6 | from pandas import (
|
6 | from pandas import (
|
||||||
7 | DataFrame, # DataFrame
|
7 | DataFrame, # DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
8 | Series, # Series
|
8 | Series, # Series
|
||||||
9 | )
|
9 | )
|
||||||
|
|
|
|
||||||
|
@ -30,12 +30,12 @@ snapshot_kind: text
|
||||||
11 13 | def f(x: DataFrame, y: Series):
|
11 13 | def f(x: DataFrame, y: Series):
|
||||||
12 14 | pass
|
12 14 | pass
|
||||||
|
|
||||||
<filename>:8:5: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block
|
<filename>:8:5: TC002 [*] Move third-party import `pandas.Series` into a type-checking block
|
||||||
|
|
|
|
||||||
6 | from pandas import (
|
6 | from pandas import (
|
||||||
7 | DataFrame, # DataFrame
|
7 | DataFrame, # DataFrame
|
||||||
8 | Series, # Series
|
8 | Series, # Series
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
9 | )
|
9 | )
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:6:8: TCH003 [*] Move standard library import `os` into a type-checking block
|
<filename>:6:8: TC003 [*] Move standard library import `os` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from typing import TYPE_CHECKING
|
4 | from typing import TYPE_CHECKING
|
||||||
5 |
|
5 |
|
||||||
6 | import os, pandas
|
6 | import os, pandas
|
||||||
| ^^ TCH003
|
| ^^ TC003
|
||||||
7 |
|
7 |
|
||||||
8 | def f(x: os, y: pandas):
|
8 | def f(x: os, y: pandas):
|
||||||
|
|
|
|
||||||
|
@ -26,12 +26,12 @@ snapshot_kind: text
|
||||||
8 11 | def f(x: os, y: pandas):
|
8 11 | def f(x: os, y: pandas):
|
||||||
9 12 | pass
|
9 12 | pass
|
||||||
|
|
||||||
<filename>:6:12: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
<filename>:6:12: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from typing import TYPE_CHECKING
|
4 | from typing import TYPE_CHECKING
|
||||||
5 |
|
5 |
|
||||||
6 | import os, pandas
|
6 | import os, pandas
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
7 |
|
7 |
|
||||||
8 | def f(x: os, y: pandas):
|
8 | def f(x: os, y: pandas):
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:6:8: TCH003 [*] Move standard library import `os` into a type-checking block
|
<filename>:6:8: TC003 [*] Move standard library import `os` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from typing import TYPE_CHECKING
|
4 | from typing import TYPE_CHECKING
|
||||||
5 |
|
5 |
|
||||||
6 | import os, sys
|
6 | import os, sys
|
||||||
| ^^ TCH003
|
| ^^ TC003
|
||||||
7 |
|
7 |
|
||||||
8 | def f(x: os, y: sys):
|
8 | def f(x: os, y: sys):
|
||||||
|
|
|
|
||||||
|
@ -25,12 +25,12 @@ snapshot_kind: text
|
||||||
8 10 | def f(x: os, y: sys):
|
8 10 | def f(x: os, y: sys):
|
||||||
9 11 | pass
|
9 11 | pass
|
||||||
|
|
||||||
<filename>:6:12: TCH003 [*] Move standard library import `sys` into a type-checking block
|
<filename>:6:12: TC003 [*] Move standard library import `sys` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from typing import TYPE_CHECKING
|
4 | from typing import TYPE_CHECKING
|
||||||
5 |
|
5 |
|
||||||
6 | import os, sys
|
6 | import os, sys
|
||||||
| ^^^ TCH003
|
| ^^^ TC003
|
||||||
7 |
|
7 |
|
||||||
8 | def f(x: os, y: sys):
|
8 | def f(x: os, y: sys):
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:4:18: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
<filename>:4:18: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
2 | from __future__ import annotations
|
2 | from __future__ import annotations
|
||||||
3 |
|
3 |
|
||||||
4 | import pandas as pd
|
4 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
5 |
|
5 |
|
||||||
6 | def f(x: pd.DataFrame):
|
6 | def f(x: pd.DataFrame):
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
quote.py:57:28: TCH004 [*] Quote references to `pandas.DataFrame`. Import is in a type-checking block.
|
quote.py:57:28: TC004 [*] Quote references to `pandas.DataFrame`. Import is in a type-checking block.
|
||||||
|
|
|
|
||||||
56 | if TYPE_CHECKING:
|
56 | if TYPE_CHECKING:
|
||||||
57 | from pandas import DataFrame
|
57 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH004
|
| ^^^^^^^^^ TC004
|
||||||
58 |
|
58 |
|
||||||
59 | def func(value: DataFrame):
|
59 | def func(value: DataFrame):
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
quote.py:2:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
quote.py:2:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
1 | def f():
|
1 | def f():
|
||||||
2 | from pandas import DataFrame
|
2 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
3 |
|
3 |
|
||||||
4 | def baz() -> DataFrame:
|
4 | def baz() -> DataFrame:
|
||||||
|
|
|
|
||||||
|
@ -26,11 +26,11 @@ quote.py:2:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type
|
||||||
6 9 |
|
6 9 |
|
||||||
7 10 |
|
7 10 |
|
||||||
|
|
||||||
quote.py:9:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
quote.py:9:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
8 | def f():
|
8 | def f():
|
||||||
9 | from pandas import DataFrame
|
9 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
10 |
|
10 |
|
||||||
11 | def baz() -> DataFrame[int]:
|
11 | def baz() -> DataFrame[int]:
|
||||||
|
|
|
|
||||||
|
@ -56,11 +56,11 @@ quote.py:9:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type
|
||||||
13 16 |
|
13 16 |
|
||||||
14 17 |
|
14 17 |
|
||||||
|
|
||||||
quote.py:16:22: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
quote.py:16:22: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
15 | def f():
|
15 | def f():
|
||||||
16 | import pandas as pd
|
16 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
17 |
|
17 |
|
||||||
18 | def baz() -> pd.DataFrame:
|
18 | def baz() -> pd.DataFrame:
|
||||||
|
|
|
|
||||||
|
@ -86,11 +86,11 @@ quote.py:16:22: TCH002 [*] Move third-party import `pandas` into a type-checking
|
||||||
20 23 |
|
20 23 |
|
||||||
21 24 |
|
21 24 |
|
||||||
|
|
||||||
quote.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
quote.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
22 | def f():
|
22 | def f():
|
||||||
23 | import pandas as pd
|
23 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
24 |
|
24 |
|
||||||
25 | def baz() -> pd.DataFrame.Extra:
|
25 | def baz() -> pd.DataFrame.Extra:
|
||||||
|
|
|
|
||||||
|
@ -116,11 +116,11 @@ quote.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checking
|
||||||
27 30 |
|
27 30 |
|
||||||
28 31 |
|
28 31 |
|
||||||
|
|
||||||
quote.py:30:22: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
quote.py:30:22: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
29 | def f():
|
29 | def f():
|
||||||
30 | import pandas as pd
|
30 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
31 |
|
31 |
|
||||||
32 | def baz() -> pd.DataFrame | int:
|
32 | def baz() -> pd.DataFrame | int:
|
||||||
|
|
|
|
||||||
|
@ -146,11 +146,11 @@ quote.py:30:22: TCH002 [*] Move third-party import `pandas` into a type-checking
|
||||||
34 37 |
|
34 37 |
|
||||||
35 38 |
|
35 38 |
|
||||||
|
|
||||||
quote.py:38:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
quote.py:38:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
37 | def f():
|
37 | def f():
|
||||||
38 | from pandas import DataFrame
|
38 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
39 |
|
39 |
|
||||||
40 | def baz() -> DataFrame():
|
40 | def baz() -> DataFrame():
|
||||||
|
|
|
|
||||||
|
@ -176,12 +176,12 @@ quote.py:38:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ
|
||||||
42 45 |
|
42 45 |
|
||||||
43 46 |
|
43 46 |
|
||||||
|
|
||||||
quote.py:47:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
quote.py:47:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
45 | from typing import Literal
|
45 | from typing import Literal
|
||||||
46 |
|
46 |
|
||||||
47 | from pandas import DataFrame
|
47 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
48 |
|
48 |
|
||||||
49 | def baz() -> DataFrame[Literal["int"]]:
|
49 | def baz() -> DataFrame[Literal["int"]]:
|
||||||
|
|
|
|
||||||
|
@ -207,11 +207,11 @@ quote.py:47:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ
|
||||||
51 54 |
|
51 54 |
|
||||||
52 55 |
|
52 55 |
|
||||||
|
|
||||||
quote.py:64:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
quote.py:64:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
63 | def f():
|
63 | def f():
|
||||||
64 | from pandas import DataFrame, Series
|
64 | from pandas import DataFrame, Series
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
65 |
|
65 |
|
||||||
66 | def baz() -> DataFrame | Series:
|
66 | def baz() -> DataFrame | Series:
|
||||||
|
|
|
|
||||||
|
@ -237,11 +237,11 @@ quote.py:64:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ
|
||||||
68 71 |
|
68 71 |
|
||||||
69 72 |
|
69 72 |
|
||||||
|
|
||||||
quote.py:64:35: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block
|
quote.py:64:35: TC002 [*] Move third-party import `pandas.Series` into a type-checking block
|
||||||
|
|
|
|
||||||
63 | def f():
|
63 | def f():
|
||||||
64 | from pandas import DataFrame, Series
|
64 | from pandas import DataFrame, Series
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
65 |
|
65 |
|
||||||
66 | def baz() -> DataFrame | Series:
|
66 | def baz() -> DataFrame | Series:
|
||||||
|
|
|
|
||||||
|
@ -267,11 +267,11 @@ quote.py:64:35: TCH002 [*] Move third-party import `pandas.Series` into a type-c
|
||||||
68 71 |
|
68 71 |
|
||||||
69 72 |
|
69 72 |
|
||||||
|
|
||||||
quote.py:71:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
quote.py:71:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
70 | def f():
|
70 | def f():
|
||||||
71 | from pandas import DataFrame, Series
|
71 | from pandas import DataFrame, Series
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
72 |
|
72 |
|
||||||
73 | def baz() -> (
|
73 | def baz() -> (
|
||||||
|
|
|
|
||||||
|
@ -310,11 +310,11 @@ quote.py:71:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ
|
||||||
86 86 |
|
86 86 |
|
||||||
87 87 |
|
87 87 |
|
||||||
|
|
||||||
quote.py:71:35: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block
|
quote.py:71:35: TC002 [*] Move third-party import `pandas.Series` into a type-checking block
|
||||||
|
|
|
|
||||||
70 | def f():
|
70 | def f():
|
||||||
71 | from pandas import DataFrame, Series
|
71 | from pandas import DataFrame, Series
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
72 |
|
72 |
|
||||||
73 | def baz() -> (
|
73 | def baz() -> (
|
||||||
|
|
|
|
||||||
|
@ -353,11 +353,11 @@ quote.py:71:35: TCH002 [*] Move third-party import `pandas.Series` into a type-c
|
||||||
86 86 |
|
86 86 |
|
||||||
87 87 |
|
87 87 |
|
||||||
|
|
||||||
quote.py:89:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
quote.py:89:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
88 | def f():
|
88 | def f():
|
||||||
89 | from pandas import DataFrame, Series
|
89 | from pandas import DataFrame, Series
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
90 |
|
90 |
|
||||||
91 | def func(self) -> DataFrame | list[Series]:
|
91 | def func(self) -> DataFrame | list[Series]:
|
||||||
|
|
|
|
||||||
|
@ -383,11 +383,11 @@ quote.py:89:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a typ
|
||||||
93 96 |
|
93 96 |
|
||||||
94 97 |
|
94 97 |
|
||||||
|
|
||||||
quote.py:89:35: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block
|
quote.py:89:35: TC002 [*] Move third-party import `pandas.Series` into a type-checking block
|
||||||
|
|
|
|
||||||
88 | def f():
|
88 | def f():
|
||||||
89 | from pandas import DataFrame, Series
|
89 | from pandas import DataFrame, Series
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
90 |
|
90 |
|
||||||
91 | def func(self) -> DataFrame | list[Series]:
|
91 | def func(self) -> DataFrame | list[Series]:
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
quote2.py:2:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:2:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
1 | def f():
|
1 | def f():
|
||||||
2 | from django.contrib.auth.models import AbstractBaseUser
|
2 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
3 |
|
3 |
|
||||||
4 | def test_remove_inner_quotes_double(self, user: AbstractBaseUser["int"]):
|
4 | def test_remove_inner_quotes_double(self, user: AbstractBaseUser["int"]):
|
||||||
|
|
|
|
||||||
|
@ -26,11 +26,11 @@ quote2.py:2:44: TCH002 [*] Move third-party import `django.contrib.auth.models.A
|
||||||
6 9 |
|
6 9 |
|
||||||
7 10 |
|
7 10 |
|
||||||
|
|
||||||
quote2.py:9:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:9:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
8 | def f():
|
8 | def f():
|
||||||
9 | from django.contrib.auth.models import AbstractBaseUser
|
9 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
10 |
|
10 |
|
||||||
11 | def test_remove_inner_quotes_single(self, user: AbstractBaseUser['int']):
|
11 | def test_remove_inner_quotes_single(self, user: AbstractBaseUser['int']):
|
||||||
|
|
|
|
||||||
|
@ -56,11 +56,11 @@ quote2.py:9:44: TCH002 [*] Move third-party import `django.contrib.auth.models.A
|
||||||
13 16 |
|
13 16 |
|
||||||
14 17 |
|
14 17 |
|
||||||
|
|
||||||
quote2.py:16:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:16:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
15 | def f():
|
15 | def f():
|
||||||
16 | from django.contrib.auth.models import AbstractBaseUser
|
16 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
17 |
|
17 |
|
||||||
18 | def test_remove_inner_quotes_mixed(self, user: AbstractBaseUser['int', "str"]):
|
18 | def test_remove_inner_quotes_mixed(self, user: AbstractBaseUser['int', "str"]):
|
||||||
|
|
|
|
||||||
|
@ -86,12 +86,12 @@ quote2.py:16:44: TCH002 [*] Move third-party import `django.contrib.auth.models.
|
||||||
20 23 |
|
20 23 |
|
||||||
21 24 |
|
21 24 |
|
||||||
|
|
||||||
quote2.py:25:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:25:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
23 | from typing import Annotated, Literal
|
23 | from typing import Annotated, Literal
|
||||||
24 |
|
24 |
|
||||||
25 | from django.contrib.auth.models import AbstractBaseUser
|
25 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
26 |
|
26 |
|
||||||
27 | def test_literal_annotation_args_contain_quotes(self, type1: AbstractBaseUser[Literal["user", "admin"], Annotated["int", "1", 2]]):
|
27 | def test_literal_annotation_args_contain_quotes(self, type1: AbstractBaseUser[Literal["user", "admin"], Annotated["int", "1", 2]]):
|
||||||
|
|
|
|
||||||
|
@ -117,12 +117,12 @@ quote2.py:25:44: TCH002 [*] Move third-party import `django.contrib.auth.models.
|
||||||
29 32 |
|
29 32 |
|
||||||
30 33 |
|
30 33 |
|
||||||
|
|
||||||
quote2.py:34:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:34:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
32 | from typing import Literal
|
32 | from typing import Literal
|
||||||
33 |
|
33 |
|
||||||
34 | from django.contrib.auth.models import AbstractBaseUser
|
34 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
35 |
|
35 |
|
||||||
36 | def test_union_contain_inner_quotes(self, type1: AbstractBaseUser["int" | Literal["int"]]):
|
36 | def test_union_contain_inner_quotes(self, type1: AbstractBaseUser["int" | Literal["int"]]):
|
||||||
|
|
|
|
||||||
|
@ -148,12 +148,12 @@ quote2.py:34:44: TCH002 [*] Move third-party import `django.contrib.auth.models.
|
||||||
38 41 |
|
38 41 |
|
||||||
39 42 |
|
39 42 |
|
||||||
|
|
||||||
quote2.py:43:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:43:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
41 | from typing import Literal
|
41 | from typing import Literal
|
||||||
42 |
|
42 |
|
||||||
43 | from django.contrib.auth.models import AbstractBaseUser
|
43 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
44 |
|
44 |
|
||||||
45 | def test_inner_literal_mixed_quotes(user: AbstractBaseUser[Literal['user', "admin"]]):
|
45 | def test_inner_literal_mixed_quotes(user: AbstractBaseUser[Literal['user', "admin"]]):
|
||||||
|
|
|
|
||||||
|
@ -179,12 +179,12 @@ quote2.py:43:44: TCH002 [*] Move third-party import `django.contrib.auth.models.
|
||||||
47 50 |
|
47 50 |
|
||||||
48 51 |
|
48 51 |
|
||||||
|
|
||||||
quote2.py:52:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:52:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
50 | from typing import Literal
|
50 | from typing import Literal
|
||||||
51 |
|
51 |
|
||||||
52 | from django.contrib.auth.models import AbstractBaseUser
|
52 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
53 |
|
53 |
|
||||||
54 | def test_inner_literal_single_quote(user: AbstractBaseUser[Literal['int'], str]):
|
54 | def test_inner_literal_single_quote(user: AbstractBaseUser[Literal['int'], str]):
|
||||||
|
|
|
|
||||||
|
@ -210,12 +210,12 @@ quote2.py:52:44: TCH002 [*] Move third-party import `django.contrib.auth.models.
|
||||||
56 59 |
|
56 59 |
|
||||||
57 60 |
|
57 60 |
|
||||||
|
|
||||||
quote2.py:61:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:61:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
59 | from typing import Literal
|
59 | from typing import Literal
|
||||||
60 |
|
60 |
|
||||||
61 | from django.contrib.auth.models import AbstractBaseUser
|
61 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
62 |
|
62 |
|
||||||
63 | def test_mixed_quotes_literal(user: AbstractBaseUser[Literal['user'], "int"]):
|
63 | def test_mixed_quotes_literal(user: AbstractBaseUser[Literal['user'], "int"]):
|
||||||
|
|
|
|
||||||
|
@ -241,12 +241,12 @@ quote2.py:61:44: TCH002 [*] Move third-party import `django.contrib.auth.models.
|
||||||
65 68 |
|
65 68 |
|
||||||
66 69 |
|
66 69 |
|
||||||
|
|
||||||
quote2.py:70:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote2.py:70:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
68 | from typing import Annotated, Literal
|
68 | from typing import Annotated, Literal
|
||||||
69 |
|
69 |
|
||||||
70 | from django.contrib.auth.models import AbstractBaseUser
|
70 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
71 |
|
71 |
|
||||||
72 | def test_annotated_literal_mixed_quotes(user: AbstractBaseUser[Annotated[str, "max_length=20", Literal['user', "admin"]]]):
|
72 | def test_annotated_literal_mixed_quotes(user: AbstractBaseUser[Annotated[str, "max_length=20", Literal['user', "admin"]]]):
|
||||||
|
|
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
---
|
---
|
||||||
quote3.py:4:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote3.py:4:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
2 | from typing import Literal, Union
|
2 | from typing import Literal, Union
|
||||||
3 |
|
3 |
|
||||||
4 | from django.contrib.auth.models import AbstractBaseUser
|
4 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
5 |
|
5 |
|
||||||
6 | def test_union_literal_mixed_quotes(user: AbstractBaseUser[Union[Literal['active', "inactive"], str]]):
|
6 | def test_union_literal_mixed_quotes(user: AbstractBaseUser[Union[Literal['active', "inactive"], str]]):
|
||||||
|
|
|
|
||||||
|
@ -28,12 +28,12 @@ quote3.py:4:44: TCH002 [*] Move third-party import `django.contrib.auth.models.A
|
||||||
8 11 |
|
8 11 |
|
||||||
9 12 |
|
9 12 |
|
||||||
|
|
||||||
quote3.py:13:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote3.py:13:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
11 | from typing import Callable, Literal
|
11 | from typing import Callable, Literal
|
||||||
12 |
|
12 |
|
||||||
13 | from django.contrib.auth.models import AbstractBaseUser
|
13 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
14 |
|
14 |
|
||||||
15 | def test_callable_literal_mixed_quotes(callable_fn: AbstractBaseUser[Callable[["int", Literal['admin', "user"]], 'bool']]):
|
15 | def test_callable_literal_mixed_quotes(callable_fn: AbstractBaseUser[Callable[["int", Literal['admin', "user"]], 'bool']]):
|
||||||
|
|
|
|
||||||
|
@ -59,12 +59,12 @@ quote3.py:13:44: TCH002 [*] Move third-party import `django.contrib.auth.models.
|
||||||
17 20 |
|
17 20 |
|
||||||
18 21 |
|
18 21 |
|
||||||
|
|
||||||
quote3.py:22:44: TCH002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
quote3.py:22:44: TC002 [*] Move third-party import `django.contrib.auth.models.AbstractBaseUser` into a type-checking block
|
||||||
|
|
|
|
||||||
20 | from typing import Annotated, Callable, Literal
|
20 | from typing import Annotated, Callable, Literal
|
||||||
21 |
|
21 |
|
||||||
22 | from django.contrib.auth.models import AbstractBaseUser
|
22 | from django.contrib.auth.models import AbstractBaseUser
|
||||||
| ^^^^^^^^^^^^^^^^ TCH002
|
| ^^^^^^^^^^^^^^^^ TC002
|
||||||
23 |
|
23 |
|
||||||
24 | def test_callable_annotated_literal(callable_fn: AbstractBaseUser[Callable[[int, Annotated[str, Literal['active', "inactive"]]], bool]]):
|
24 | def test_callable_annotated_literal(callable_fn: AbstractBaseUser[Callable[[int, Annotated[str, Literal['active', "inactive"]]], bool]]):
|
||||||
|
|
|
|
||||||
|
@ -90,12 +90,12 @@ quote3.py:22:44: TCH002 [*] Move third-party import `django.contrib.auth.models.
|
||||||
26 29 |
|
26 29 |
|
||||||
27 30 |
|
27 30 |
|
||||||
|
|
||||||
quote3.py:31:37: TCH002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block
|
quote3.py:31:37: TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block
|
||||||
|
|
|
|
||||||
29 | from typing import literal
|
29 | from typing import literal
|
||||||
30 |
|
30 |
|
||||||
31 | from django.contrib.auth import models
|
31 | from django.contrib.auth import models
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
32 |
|
32 |
|
||||||
33 | def test_attribute(arg: models.AbstractBaseUser["int"]):
|
33 | def test_attribute(arg: models.AbstractBaseUser["int"]):
|
||||||
|
|
|
|
||||||
|
@ -121,12 +121,12 @@ quote3.py:31:37: TCH002 [*] Move third-party import `django.contrib.auth.models`
|
||||||
35 38 |
|
35 38 |
|
||||||
36 39 |
|
36 39 |
|
||||||
|
|
||||||
quote3.py:40:37: TCH002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block
|
quote3.py:40:37: TC002 [*] Move third-party import `django.contrib.auth.models` into a type-checking block
|
||||||
|
|
|
|
||||||
38 | from typing import Literal
|
38 | from typing import Literal
|
||||||
39 |
|
39 |
|
||||||
40 | from django.contrib.auth import models
|
40 | from django.contrib.auth import models
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
41 |
|
41 |
|
||||||
42 | def test_attribute_typing_literal(arg: models.AbstractBaseUser[Literal["admin"]]):
|
42 | def test_attribute_typing_literal(arg: models.AbstractBaseUser[Literal["admin"]]):
|
||||||
|
|
|
|
||||||
|
@ -152,23 +152,23 @@ quote3.py:40:37: TCH002 [*] Move third-party import `django.contrib.auth.models`
|
||||||
44 47 |
|
44 47 |
|
||||||
45 48 |
|
45 48 |
|
||||||
|
|
||||||
quote3.py:59:29: TCH002 Move third-party import `third_party.Type` into a type-checking block
|
quote3.py:59:29: TC002 Move third-party import `third_party.Type` into a type-checking block
|
||||||
|
|
|
|
||||||
57 | def f():
|
57 | def f():
|
||||||
58 | from typing import Literal
|
58 | from typing import Literal
|
||||||
59 | from third_party import Type
|
59 | from third_party import Type
|
||||||
| ^^^^ TCH002
|
| ^^^^ TC002
|
||||||
60 |
|
60 |
|
||||||
61 | def test_string_contains_opposite_quote_do_not_fix(self, type1: Type[Literal["'"]], type2: Type[Literal["\'"]]):
|
61 | def test_string_contains_opposite_quote_do_not_fix(self, type1: Type[Literal["'"]], type2: Type[Literal["\'"]]):
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
||||||
quote3.py:67:29: TCH002 Move third-party import `third_party.Type` into a type-checking block
|
quote3.py:67:29: TC002 Move third-party import `third_party.Type` into a type-checking block
|
||||||
|
|
|
|
||||||
65 | def f():
|
65 | def f():
|
||||||
66 | from typing import Literal
|
66 | from typing import Literal
|
||||||
67 | from third_party import Type
|
67 | from third_party import Type
|
||||||
| ^^^^ TCH002
|
| ^^^^ TC002
|
||||||
68 |
|
68 |
|
||||||
69 | def test_quote_contains_backslash(self, type1: Type[Literal["\n"]], type2: Type[Literal["\""]]):
|
69 | def test_quote_contains_backslash(self, type1: Type[Literal["\n"]], type2: Type[Literal["\""]]):
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH004_1.py:4:26: TCH004 [*] Move import `datetime.datetime` out of type-checking block. Import is used for more than type hinting.
|
TC004_1.py:4:26: TC004 [*] Move import `datetime.datetime` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from datetime import datetime
|
4 | from datetime import datetime
|
||||||
| ^^^^^^^^ TCH004
|
| ^^^^^^^^ TC004
|
||||||
5 | x = datetime
|
5 | x = datetime
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH004_11.py:4:24: TCH004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting.
|
TC004_11.py:4:24: TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from typing import List
|
4 | from typing import List
|
||||||
| ^^^^ TCH004
|
| ^^^^ TC004
|
||||||
5 |
|
5 |
|
||||||
6 | __all__ = ("List",)
|
6 | __all__ = ("List",)
|
||||||
|
|
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH004_12.py:6:33: TCH004 [*] Move import `collections.abc.Callable` out of type-checking block. Import is used for more than type hinting.
|
TC004_12.py:6:33: TC004 [*] Move import `collections.abc.Callable` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
5 | if TYPE_CHECKING:
|
5 | if TYPE_CHECKING:
|
||||||
6 | from collections.abc import Callable
|
6 | from collections.abc import Callable
|
||||||
| ^^^^^^^^ TCH004
|
| ^^^^^^^^ TC004
|
||||||
7 |
|
7 |
|
||||||
8 | AnyCallable: TypeAlias = Callable[..., Any]
|
8 | AnyCallable: TypeAlias = Callable[..., Any]
|
||||||
|
|
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH004_17.py:6:24: TCH004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting.
|
TC004_17.py:6:24: TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
5 | if TYPE_CHECKING:
|
5 | if TYPE_CHECKING:
|
||||||
6 | from pandas import DataFrame
|
6 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH004
|
| ^^^^^^^^^ TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH004_2.py:4:26: TCH004 [*] Move import `datetime.date` out of type-checking block. Import is used for more than type hinting.
|
TC004_2.py:4:26: TC004 [*] Move import `datetime.date` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from datetime import date
|
4 | from datetime import date
|
||||||
| ^^^^ TCH004
|
| ^^^^ TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH004_4.py:4:24: TCH004 [*] Move import `typing.Any` out of type-checking block. Import is used for more than type hinting.
|
TC004_4.py:4:24: TC004 [*] Move import `typing.Any` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from typing import Any
|
4 | from typing import Any
|
||||||
| ^^^ TCH004
|
| ^^^ TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH004_5.py:4:24: TCH004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting.
|
TC004_5.py:4:24: TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from typing import List, Sequence, Set
|
4 | from typing import List, Sequence, Set
|
||||||
| ^^^^ TCH004
|
| ^^^^ TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ TCH004_5.py:4:24: TCH004 [*] Move import `typing.List` out of type-checking bloc
|
||||||
6 7 |
|
6 7 |
|
||||||
7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]):
|
7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]):
|
||||||
|
|
||||||
TCH004_5.py:4:30: TCH004 [*] Move import `typing.Sequence` out of type-checking block. Import is used for more than type hinting.
|
TC004_5.py:4:30: TC004 [*] Move import `typing.Sequence` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from typing import List, Sequence, Set
|
4 | from typing import List, Sequence, Set
|
||||||
| ^^^^^^^^ TCH004
|
| ^^^^^^^^ TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ TCH004_5.py:4:30: TCH004 [*] Move import `typing.Sequence` out of type-checking
|
||||||
6 7 |
|
6 7 |
|
||||||
7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]):
|
7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]):
|
||||||
|
|
||||||
TCH004_5.py:4:40: TCH004 [*] Move import `typing.Set` out of type-checking block. Import is used for more than type hinting.
|
TC004_5.py:4:40: TC004 [*] Move import `typing.Set` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from typing import List, Sequence, Set
|
4 | from typing import List, Sequence, Set
|
||||||
| ^^^ TCH004
|
| ^^^ TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH004_9.py:4:24: TCH004 [*] Move import `typing.Tuple` out of type-checking block. Import is used for more than type hinting.
|
TC004_9.py:4:24: TC004 [*] Move import `typing.Tuple` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from typing import Tuple, List, Dict
|
4 | from typing import Tuple, List, Dict
|
||||||
| ^^^^^ TCH004
|
| ^^^^^ TC004
|
||||||
5 |
|
5 |
|
||||||
6 | x: Tuple
|
6 | x: Tuple
|
||||||
|
|
|
|
||||||
|
@ -23,11 +23,11 @@ TCH004_9.py:4:24: TCH004 [*] Move import `typing.Tuple` out of type-checking blo
|
||||||
6 7 | x: Tuple
|
6 7 | x: Tuple
|
||||||
7 8 |
|
7 8 |
|
||||||
|
|
||||||
TCH004_9.py:4:31: TCH004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting.
|
TC004_9.py:4:31: TC004 [*] Move import `typing.List` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
3 | if TYPE_CHECKING:
|
3 | if TYPE_CHECKING:
|
||||||
4 | from typing import Tuple, List, Dict
|
4 | from typing import Tuple, List, Dict
|
||||||
| ^^^^ TCH004
|
| ^^^^ TC004
|
||||||
5 |
|
5 |
|
||||||
6 | x: Tuple
|
6 | x: Tuple
|
||||||
|
|
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
quote.py:57:28: TCH004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting.
|
quote.py:57:28: TC004 [*] Move import `pandas.DataFrame` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
56 | if TYPE_CHECKING:
|
56 | if TYPE_CHECKING:
|
||||||
57 | from pandas import DataFrame
|
57 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH004
|
| ^^^^^^^^^ TC004
|
||||||
58 |
|
58 |
|
||||||
59 | def func(value: DataFrame):
|
59 | def func(value: DataFrame):
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
runtime_evaluated_base_classes_1.py:10:12: TCH004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting.
|
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.
|
||||||
|
|
|
|
||||||
9 | if TYPE_CHECKING:
|
9 | if TYPE_CHECKING:
|
||||||
10 | import datetime # TCH004
|
10 | import datetime # TC004
|
||||||
| ^^^^^^^^ TCH004
|
| ^^^^^^^^ TC004
|
||||||
11 | from array import array # TCH004
|
11 | from array import array # TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
||||||
|
@ -18,19 +18,19 @@ runtime_evaluated_base_classes_1.py:10:12: TCH004 [*] Move import `datetime` out
|
||||||
8 |+import datetime
|
8 |+import datetime
|
||||||
8 9 |
|
8 9 |
|
||||||
9 10 | if TYPE_CHECKING:
|
9 10 | if TYPE_CHECKING:
|
||||||
10 |- import datetime # TCH004
|
10 |- import datetime # TC004
|
||||||
11 11 | from array import array # TCH004
|
11 11 | from array import array # TC004
|
||||||
12 12 |
|
12 12 |
|
||||||
13 13 | import pandas # TCH004
|
13 13 | import pandas # TC004
|
||||||
|
|
||||||
runtime_evaluated_base_classes_1.py:11:23: TCH004 [*] 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: TC004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
9 | if TYPE_CHECKING:
|
9 | if TYPE_CHECKING:
|
||||||
10 | import datetime # TCH004
|
10 | import datetime # TC004
|
||||||
11 | from array import array # TCH004
|
11 | from array import array # TC004
|
||||||
| ^^^^^ TCH004
|
| ^^^^^ TC004
|
||||||
12 |
|
12 |
|
||||||
13 | import pandas # TCH004
|
13 | import pandas # TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
||||||
|
@ -41,18 +41,18 @@ runtime_evaluated_base_classes_1.py:11:23: TCH004 [*] Move import `array.array`
|
||||||
8 |+from array import array
|
8 |+from array import array
|
||||||
8 9 |
|
8 9 |
|
||||||
9 10 | if TYPE_CHECKING:
|
9 10 | if TYPE_CHECKING:
|
||||||
10 11 | import datetime # TCH004
|
10 11 | import datetime # TC004
|
||||||
11 |- from array import array # TCH004
|
11 |- from array import array # TC004
|
||||||
12 12 |
|
12 12 |
|
||||||
13 13 | import pandas # TCH004
|
13 13 | import pandas # TC004
|
||||||
14 14 | import pyproj
|
14 14 | import pyproj
|
||||||
|
|
||||||
runtime_evaluated_base_classes_1.py:13:12: TCH004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting.
|
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.
|
||||||
|
|
|
|
||||||
11 | from array import array # TCH004
|
11 | from array import array # TC004
|
||||||
12 |
|
12 |
|
||||||
13 | import pandas # TCH004
|
13 | import pandas # TC004
|
||||||
| ^^^^^^ TCH004
|
| ^^^^^^ TC004
|
||||||
14 | import pyproj
|
14 | import pyproj
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
@ -64,10 +64,10 @@ runtime_evaluated_base_classes_1.py:13:12: TCH004 [*] Move import `pandas` out o
|
||||||
8 |+import pandas
|
8 |+import pandas
|
||||||
8 9 |
|
8 9 |
|
||||||
9 10 | if TYPE_CHECKING:
|
9 10 | if TYPE_CHECKING:
|
||||||
10 11 | import datetime # TCH004
|
10 11 | import datetime # TC004
|
||||||
11 12 | from array import array # TCH004
|
11 12 | from array import array # TC004
|
||||||
12 13 |
|
12 13 |
|
||||||
13 |- import pandas # TCH004
|
13 |- import pandas # TC004
|
||||||
14 14 | import pyproj
|
14 14 | import pyproj
|
||||||
15 15 |
|
15 15 |
|
||||||
16 16 |
|
16 16 |
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
runtime_evaluated_decorators_1.py:12:12: TCH004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting.
|
runtime_evaluated_decorators_1.py:12:12: TC004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
11 | if TYPE_CHECKING:
|
11 | if TYPE_CHECKING:
|
||||||
12 | import datetime # TCH004
|
12 | import datetime # TC004
|
||||||
| ^^^^^^^^ TCH004
|
| ^^^^^^^^ TC004
|
||||||
13 | from array import array # TCH004
|
13 | from array import array # TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
||||||
|
@ -18,19 +18,19 @@ runtime_evaluated_decorators_1.py:12:12: TCH004 [*] Move import `datetime` out o
|
||||||
10 |+import datetime
|
10 |+import datetime
|
||||||
10 11 |
|
10 11 |
|
||||||
11 12 | if TYPE_CHECKING:
|
11 12 | if TYPE_CHECKING:
|
||||||
12 |- import datetime # TCH004
|
12 |- import datetime # TC004
|
||||||
13 13 | from array import array # TCH004
|
13 13 | from array import array # TC004
|
||||||
14 14 |
|
14 14 |
|
||||||
15 15 | import pandas # TCH004
|
15 15 | import pandas # TC004
|
||||||
|
|
||||||
runtime_evaluated_decorators_1.py:13:23: TCH004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting.
|
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.
|
||||||
|
|
|
|
||||||
11 | if TYPE_CHECKING:
|
11 | if TYPE_CHECKING:
|
||||||
12 | import datetime # TCH004
|
12 | import datetime # TC004
|
||||||
13 | from array import array # TCH004
|
13 | from array import array # TC004
|
||||||
| ^^^^^ TCH004
|
| ^^^^^ TC004
|
||||||
14 |
|
14 |
|
||||||
15 | import pandas # TCH004
|
15 | import pandas # TC004
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
|
||||||
|
@ -41,18 +41,18 @@ runtime_evaluated_decorators_1.py:13:23: TCH004 [*] Move import `array.array` ou
|
||||||
10 |+from array import array
|
10 |+from array import array
|
||||||
10 11 |
|
10 11 |
|
||||||
11 12 | if TYPE_CHECKING:
|
11 12 | if TYPE_CHECKING:
|
||||||
12 13 | import datetime # TCH004
|
12 13 | import datetime # TC004
|
||||||
13 |- from array import array # TCH004
|
13 |- from array import array # TC004
|
||||||
14 14 |
|
14 14 |
|
||||||
15 15 | import pandas # TCH004
|
15 15 | import pandas # TC004
|
||||||
16 16 | import pyproj
|
16 16 | import pyproj
|
||||||
|
|
||||||
runtime_evaluated_decorators_1.py:15:12: TCH004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting.
|
runtime_evaluated_decorators_1.py:15:12: TC004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting.
|
||||||
|
|
|
|
||||||
13 | from array import array # TCH004
|
13 | from array import array # TC004
|
||||||
14 |
|
14 |
|
||||||
15 | import pandas # TCH004
|
15 | import pandas # TC004
|
||||||
| ^^^^^^ TCH004
|
| ^^^^^^ TC004
|
||||||
16 | import pyproj
|
16 | import pyproj
|
||||||
|
|
|
|
||||||
= help: Move out of type-checking block
|
= help: Move out of type-checking block
|
||||||
|
@ -64,10 +64,10 @@ runtime_evaluated_decorators_1.py:15:12: TCH004 [*] Move import `pandas` out of
|
||||||
10 |+import pandas
|
10 |+import pandas
|
||||||
10 11 |
|
10 11 |
|
||||||
11 12 | if TYPE_CHECKING:
|
11 12 | if TYPE_CHECKING:
|
||||||
12 13 | import datetime # TCH004
|
12 13 | import datetime # TC004
|
||||||
13 14 | from array import array # TCH004
|
13 14 | from array import array # TC004
|
||||||
14 15 |
|
14 15 |
|
||||||
15 |- import pandas # TCH004
|
15 |- import pandas # TC004
|
||||||
16 16 | import pyproj
|
16 16 | import pyproj
|
||||||
17 17 |
|
17 17 |
|
||||||
18 18 |
|
18 18 |
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
|
snapshot_kind: text
|
||||||
|
---
|
||||||
|
TC010_1.py:18:30: TC010 Invalid string member in `X | Y`-style union type
|
||||||
|
|
|
||||||
|
16 | type A = Value["int" | str] # OK
|
||||||
|
17 |
|
||||||
|
18 | OldS = TypeVar('OldS', int | 'str', str) # TC010
|
||||||
|
| ^^^^^ TC010
|
||||||
|
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
---
|
||||||
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
|
snapshot_kind: text
|
||||||
|
---
|
||||||
|
TC010_2.py:4:4: TC010 Invalid string member in `X | Y`-style union type
|
||||||
|
|
|
||||||
|
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
|
||||||
|
|
|
||||||
|
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
|
||||||
|
|
|
||||||
|
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
|
||||||
|
|
|
||||||
|
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
|
||||||
|
|
|
||||||
|
14 | type A = Value["int" | str] # OK
|
||||||
|
15 |
|
||||||
|
16 | OldS = TypeVar('OldS', int | 'str', str) # TC010
|
||||||
|
| ^^^^^ TC010
|
||||||
|
|
|
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
|
||||||
snapshot_kind: text
|
|
||||||
---
|
|
||||||
TCH010_1.py:18:30: TCH010 Invalid string member in `X | Y`-style union type
|
|
||||||
|
|
|
||||||
16 | type A = Value["int" | str] # OK
|
|
||||||
17 |
|
|
||||||
18 | OldS = TypeVar('OldS', int | 'str', str) # TCH010
|
|
||||||
| ^^^^^ TCH010
|
|
||||||
|
|
|
|
@ -1,40 +0,0 @@
|
||||||
---
|
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
|
||||||
snapshot_kind: text
|
|
||||||
---
|
|
||||||
TCH010_2.py:4:4: TCH010 Invalid string member in `X | Y`-style union type
|
|
||||||
|
|
|
||||||
4 | x: "int" | str # TCH010
|
|
||||||
| ^^^^^ TCH010
|
|
||||||
5 | x: ("int" | str) | "bool" # TCH010
|
|
||||||
|
|
|
||||||
|
|
||||||
TCH010_2.py:5:5: TCH010 Invalid string member in `X | Y`-style union type
|
|
||||||
|
|
|
||||||
4 | x: "int" | str # TCH010
|
|
||||||
5 | x: ("int" | str) | "bool" # TCH010
|
|
||||||
| ^^^^^ TCH010
|
|
||||||
|
|
|
||||||
|
|
||||||
TCH010_2.py:5:20: TCH010 Invalid string member in `X | Y`-style union type
|
|
||||||
|
|
|
||||||
4 | x: "int" | str # TCH010
|
|
||||||
5 | x: ("int" | str) | "bool" # TCH010
|
|
||||||
| ^^^^^^ TCH010
|
|
||||||
|
|
|
||||||
|
|
||||||
TCH010_2.py:12:20: TCH010 Invalid string member in `X | Y`-style union type
|
|
||||||
|
|
|
||||||
12 | z: list[str, str | "int"] = [] # TCH010
|
|
||||||
| ^^^^^ TCH010
|
|
||||||
13 |
|
|
||||||
14 | type A = Value["int" | str] # OK
|
|
||||||
|
|
|
||||||
|
|
||||||
TCH010_2.py:16:30: TCH010 Invalid string member in `X | Y`-style union type
|
|
||||||
|
|
|
||||||
14 | type A = Value["int" | str] # OK
|
|
||||||
15 |
|
|
||||||
16 | OldS = TypeVar('OldS', int | 'str', str) # TCH010
|
|
||||||
| ^^^^^ TCH010
|
|
||||||
|
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
init_var.py:5:25: TCH003 [*] Move standard library import `dataclasses.FrozenInstanceError` into a type-checking block
|
init_var.py:5:25: TC003 [*] Move standard library import `dataclasses.FrozenInstanceError` into a type-checking block
|
||||||
|
|
|
|
||||||
3 | from __future__ import annotations
|
3 | from __future__ import annotations
|
||||||
4 |
|
4 |
|
||||||
5 | from dataclasses import FrozenInstanceError, InitVar, dataclass
|
5 | from dataclasses import FrozenInstanceError, InitVar, dataclass
|
||||||
| ^^^^^^^^^^^^^^^^^^^ TCH003
|
| ^^^^^^^^^^^^^^^^^^^ TC003
|
||||||
6 | from pathlib import Path
|
6 | from pathlib import Path
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
@ -27,11 +27,11 @@ init_var.py:5:25: TCH003 [*] Move standard library import `dataclasses.FrozenIns
|
||||||
8 12 |
|
8 12 |
|
||||||
9 13 | @dataclass
|
9 13 | @dataclass
|
||||||
|
|
||||||
init_var.py:6:21: TCH003 [*] Move standard library import `pathlib.Path` into a type-checking block
|
init_var.py:6:21: TC003 [*] Move standard library import `pathlib.Path` into a type-checking block
|
||||||
|
|
|
|
||||||
5 | from dataclasses import FrozenInstanceError, InitVar, dataclass
|
5 | from dataclasses import FrozenInstanceError, InitVar, dataclass
|
||||||
6 | from pathlib import Path
|
6 | from pathlib import Path
|
||||||
| ^^^^ TCH003
|
| ^^^^ TC003
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
kw_only.py:5:45: TCH003 [*] Move standard library import `dataclasses.Field` into a type-checking block
|
kw_only.py:5:45: TC003 [*] Move standard library import `dataclasses.Field` into a type-checking block
|
||||||
|
|
|
|
||||||
3 | from __future__ import annotations
|
3 | from __future__ import annotations
|
||||||
4 |
|
4 |
|
||||||
5 | from dataclasses import KW_ONLY, dataclass, Field
|
5 | from dataclasses import KW_ONLY, dataclass, Field
|
||||||
| ^^^^^ TCH003
|
| ^^^^^ TC003
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
strict.py:27:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking block
|
strict.py:27:21: TC002 [*] Move third-party import `pkg.A` into a type-checking block
|
||||||
|
|
|
|
||||||
25 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime.
|
25 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime.
|
||||||
26 | import pkg
|
26 | import pkg
|
||||||
27 | from pkg import A
|
27 | from pkg import A
|
||||||
| ^ TCH002
|
| ^ TC002
|
||||||
28 |
|
28 |
|
||||||
29 | def test(value: A):
|
29 | def test(value: A):
|
||||||
|
|
|
|
||||||
|
@ -31,12 +31,12 @@ strict.py:27:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking
|
||||||
29 32 | def test(value: A):
|
29 32 | def test(value: A):
|
||||||
30 33 | return pkg.B()
|
30 33 | return pkg.B()
|
||||||
|
|
||||||
strict.py:35:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking block
|
strict.py:35:21: TC002 [*] Move third-party import `pkg.A` into a type-checking block
|
||||||
|
|
|
|
||||||
33 | def f():
|
33 | def f():
|
||||||
34 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime.
|
34 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime.
|
||||||
35 | from pkg import A, B
|
35 | from pkg import A, B
|
||||||
| ^ TCH002
|
| ^ TC002
|
||||||
36 |
|
36 |
|
||||||
37 | def test(value: A):
|
37 | def test(value: A):
|
||||||
|
|
|
|
||||||
|
@ -61,12 +61,12 @@ strict.py:35:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking
|
||||||
37 41 | def test(value: A):
|
37 41 | def test(value: A):
|
||||||
38 42 | return B()
|
38 42 | return B()
|
||||||
|
|
||||||
strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-checking block
|
strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-checking block
|
||||||
|
|
|
|
||||||
52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime
|
52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime
|
||||||
53 | import pkg
|
53 | import pkg
|
||||||
54 | from pkg.bar import A
|
54 | from pkg.bar import A
|
||||||
| ^ TCH002
|
| ^ TC002
|
||||||
55 |
|
55 |
|
||||||
56 | def test(value: A):
|
56 | def test(value: A):
|
||||||
|
|
|
|
||||||
|
@ -90,12 +90,12 @@ strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-chec
|
||||||
56 59 | def test(value: A):
|
56 59 | def test(value: A):
|
||||||
57 60 | return pkg.B()
|
57 60 | return pkg.B()
|
||||||
|
|
||||||
strict.py:62:12: TCH002 [*] Move third-party import `pkg` into a type-checking block
|
strict.py:62:12: TC002 [*] Move third-party import `pkg` into a type-checking block
|
||||||
|
|
|
|
||||||
60 | def f():
|
60 | def f():
|
||||||
61 | # In un-strict mode, this shouldn't raise an error, since `pkg.bar` is used at runtime.
|
61 | # In un-strict mode, this shouldn't raise an error, since `pkg.bar` is used at runtime.
|
||||||
62 | import pkg
|
62 | import pkg
|
||||||
| ^^^ TCH002
|
| ^^^ TC002
|
||||||
63 | import pkg.bar as B
|
63 | import pkg.bar as B
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
@ -118,12 +118,12 @@ strict.py:62:12: TCH002 [*] Move third-party import `pkg` into a type-checking b
|
||||||
64 67 |
|
64 67 |
|
||||||
65 68 | def test(value: pkg.A):
|
65 68 | def test(value: pkg.A):
|
||||||
|
|
||||||
strict.py:71:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checking block
|
strict.py:71:23: TC002 [*] Move third-party import `pkg.foo` into a type-checking block
|
||||||
|
|
|
|
||||||
69 | def f():
|
69 | def f():
|
||||||
70 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime.
|
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
|
71 | import pkg.foo as F
|
||||||
| ^ TCH002
|
| ^ TC002
|
||||||
72 | import pkg.foo.bar as B
|
72 | import pkg.foo.bar as B
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
@ -146,12 +146,12 @@ strict.py:71:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checki
|
||||||
73 76 |
|
73 76 |
|
||||||
74 77 | def test(value: F.Foo):
|
74 77 | def test(value: F.Foo):
|
||||||
|
|
||||||
strict.py:80:12: TCH002 [*] Move third-party import `pkg` into a type-checking block
|
strict.py:80:12: TC002 [*] Move third-party import `pkg` into a type-checking block
|
||||||
|
|
|
|
||||||
78 | def f():
|
78 | def f():
|
||||||
79 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime.
|
79 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime.
|
||||||
80 | import pkg
|
80 | import pkg
|
||||||
| ^^^ TCH002
|
| ^^^ TC002
|
||||||
81 | import pkg.foo.bar as B
|
81 | import pkg.foo.bar as B
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
@ -174,12 +174,12 @@ strict.py:80:12: TCH002 [*] Move third-party import `pkg` into a type-checking b
|
||||||
82 85 |
|
82 85 |
|
||||||
83 86 | def test(value: pkg.A):
|
83 86 | def test(value: pkg.A):
|
||||||
|
|
||||||
strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking block
|
strict.py:91:12: TC002 [*] Move third-party import `pkg` into a type-checking block
|
||||||
|
|
|
|
||||||
89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is
|
89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is
|
||||||
90 | # testing the implementation.
|
90 | # testing the implementation.
|
||||||
91 | import pkg
|
91 | import pkg
|
||||||
| ^^^ TCH002
|
| ^^^ TC002
|
||||||
92 | import pkgfoo.bar as B
|
92 | import pkgfoo.bar as B
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
@ -202,12 +202,12 @@ strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking b
|
||||||
93 96 |
|
93 96 |
|
||||||
94 97 | def test(value: pkg.A):
|
94 97 | def test(value: pkg.A):
|
||||||
|
|
||||||
strict.py:101:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checking block
|
strict.py:101:23: TC002 [*] Move third-party import `pkg.foo` into a type-checking block
|
||||||
|
|
|
|
||||||
99 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime.
|
99 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime.
|
||||||
100 | import pkg.bar as B
|
100 | import pkg.bar as B
|
||||||
101 | import pkg.foo as F
|
101 | import pkg.foo as F
|
||||||
| ^ TCH002
|
| ^ TC002
|
||||||
102 |
|
102 |
|
||||||
103 | def test(value: F.Foo):
|
103 | def test(value: F.Foo):
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
<filename>:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from typing import TYPE_CHECKING
|
4 | from typing import TYPE_CHECKING
|
||||||
5 |
|
5 |
|
||||||
6 | import pandas as pd
|
6 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
7 |
|
7 |
|
||||||
8 | def f(x: pd.DataFrame):
|
8 | def f(x: pd.DataFrame):
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
<filename>:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from typing import TYPE_CHECKING
|
4 | from typing import TYPE_CHECKING
|
||||||
5 |
|
5 |
|
||||||
6 | import pandas as pd
|
6 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
7 |
|
7 |
|
||||||
8 | if TYPE_CHECKING:
|
8 | if TYPE_CHECKING:
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
<filename>:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from typing import TYPE_CHECKING
|
4 | from typing import TYPE_CHECKING
|
||||||
5 |
|
5 |
|
||||||
6 | import pandas as pd
|
6 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
7 |
|
7 |
|
||||||
8 | if TYPE_CHECKING: import os
|
8 | if TYPE_CHECKING: import os
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
<filename>:6:18: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from typing import TYPE_CHECKING
|
4 | from typing import TYPE_CHECKING
|
||||||
5 |
|
5 |
|
||||||
6 | import pandas as pd
|
6 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
7 |
|
7 |
|
||||||
8 | if TYPE_CHECKING:
|
8 | if TYPE_CHECKING:
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH001.py:20:19: TCH001 [*] Move application import `.TYP001` into a type-checking block
|
TC001.py:20:19: TC001 [*] Move application import `.TYP001` into a type-checking block
|
||||||
|
|
|
|
||||||
19 | def f():
|
19 | def f():
|
||||||
20 | from . import TYP001
|
20 | from . import TYP001
|
||||||
| ^^^^^^ TCH001
|
| ^^^^^^ TC001
|
||||||
21 |
|
21 |
|
||||||
22 | x: TYP001
|
22 | x: TYP001
|
||||||
|
|
|
|
||||||
|
@ -14,7 +14,7 @@ TCH001.py:20:19: TCH001 [*] Move application import `.TYP001` into a type-checki
|
||||||
|
|
||||||
ℹ Unsafe fix
|
ℹ Unsafe fix
|
||||||
2 2 |
|
2 2 |
|
||||||
3 3 | For typing-only import detection tests, see `TCH002.py`.
|
3 3 | For typing-only import detection tests, see `TC002.py`.
|
||||||
4 4 | """
|
4 4 | """
|
||||||
5 |+from typing import TYPE_CHECKING
|
5 |+from typing import TYPE_CHECKING
|
||||||
6 |+
|
6 |+
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH003.py:8:12: TCH003 [*] Move standard library import `os` into a type-checking block
|
TC003.py:8:12: TC003 [*] Move standard library import `os` into a type-checking block
|
||||||
|
|
|
|
||||||
7 | def f():
|
7 | def f():
|
||||||
8 | import os
|
8 | import os
|
||||||
| ^^ TCH003
|
| ^^ TC003
|
||||||
9 |
|
9 |
|
||||||
10 | x: os
|
10 | x: os
|
||||||
|
|
|
|
||||||
|
@ -14,7 +14,7 @@ TCH003.py:8:12: TCH003 [*] Move standard library import `os` into a type-checkin
|
||||||
|
|
||||||
ℹ Unsafe fix
|
ℹ Unsafe fix
|
||||||
2 2 |
|
2 2 |
|
||||||
3 3 | For typing-only import detection tests, see `TCH002.py`.
|
3 3 | For typing-only import detection tests, see `TC002.py`.
|
||||||
4 4 | """
|
4 4 | """
|
||||||
5 |+from typing import TYPE_CHECKING
|
5 |+from typing import TYPE_CHECKING
|
||||||
6 |+
|
6 |+
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
exempt_type_checking_1.py:5:20: TCH003 [*] Move standard library import `typing.Final` into a type-checking block
|
exempt_type_checking_1.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block
|
||||||
|
|
|
|
||||||
3 | from __future__ import annotations
|
3 | from __future__ import annotations
|
||||||
4 |
|
4 |
|
||||||
5 | from typing import Final
|
5 | from typing import Final
|
||||||
| ^^^^^ TCH003
|
| ^^^^^ TC003
|
||||||
6 |
|
6 |
|
||||||
7 | Const: Final[dict] = {}
|
7 | Const: Final[dict] = {}
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
exempt_type_checking_2.py:5:20: TCH003 [*] Move standard library import `typing.Final` into a type-checking block
|
exempt_type_checking_2.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block
|
||||||
|
|
|
|
||||||
3 | from __future__ import annotations
|
3 | from __future__ import annotations
|
||||||
4 |
|
4 |
|
||||||
5 | from typing import Final, TYPE_CHECKING
|
5 | from typing import Final, TYPE_CHECKING
|
||||||
| ^^^^^ TCH003
|
| ^^^^^ TC003
|
||||||
6 |
|
6 |
|
||||||
7 | Const: Final[dict] = {}
|
7 | Const: Final[dict] = {}
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
exempt_type_checking_3.py:5:20: TCH003 [*] Move standard library import `typing.Final` into a type-checking block
|
exempt_type_checking_3.py:5:20: TC003 [*] Move standard library import `typing.Final` into a type-checking block
|
||||||
|
|
|
|
||||||
3 | from __future__ import annotations
|
3 | from __future__ import annotations
|
||||||
4 |
|
4 |
|
||||||
5 | from typing import Final, Mapping
|
5 | from typing import Final, Mapping
|
||||||
| ^^^^^ TCH003
|
| ^^^^^ TC003
|
||||||
6 |
|
6 |
|
||||||
7 | Const: Final[dict] = {}
|
7 | Const: Final[dict] = {}
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
init_var.py:6:21: TCH003 [*] Move standard library import `pathlib.Path` into a type-checking block
|
init_var.py:6:21: TC003 [*] Move standard library import `pathlib.Path` into a type-checking block
|
||||||
|
|
|
|
||||||
5 | from dataclasses import FrozenInstanceError, InitVar, dataclass
|
5 | from dataclasses import FrozenInstanceError, InitVar, dataclass
|
||||||
6 | from pathlib import Path
|
6 | from pathlib import Path
|
||||||
| ^^^^ TCH003
|
| ^^^^ TC003
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
undefined.py:3:29: TCH003 [*] Move standard library import `collections.abc.Sequence` into a type-checking block
|
undefined.py:3:29: TC003 [*] Move standard library import `collections.abc.Sequence` into a type-checking block
|
||||||
|
|
|
|
||||||
1 | from __future__ import annotations
|
1 | from __future__ import annotations
|
||||||
2 |
|
2 |
|
||||||
3 | from collections.abc import Sequence
|
3 | from collections.abc import Sequence
|
||||||
| ^^^^^^^^ TCH003
|
| ^^^^^^^^ TC003
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
runtime_evaluated_base_classes_3.py:5:18: TCH003 [*] Move standard library import `uuid.UUID` into a type-checking block
|
runtime_evaluated_base_classes_3.py:5:18: TC003 [*] Move standard library import `uuid.UUID` into a type-checking block
|
||||||
|
|
|
|
||||||
3 | import datetime
|
3 | import datetime
|
||||||
4 | import pathlib
|
4 | import pathlib
|
||||||
5 | from uuid import UUID # TCH003
|
5 | from uuid import UUID # TC003
|
||||||
| ^^^^ TCH003
|
| ^^^^ TC003
|
||||||
6 |
|
6 |
|
||||||
7 | import pydantic
|
7 | import pydantic
|
||||||
|
|
|
|
||||||
|
@ -17,7 +17,7 @@ runtime_evaluated_base_classes_3.py:5:18: TCH003 [*] Move standard library impor
|
||||||
2 2 |
|
2 2 |
|
||||||
3 3 | import datetime
|
3 3 | import datetime
|
||||||
4 4 | import pathlib
|
4 4 | import pathlib
|
||||||
5 |-from uuid import UUID # TCH003
|
5 |-from uuid import UUID # TC003
|
||||||
6 5 |
|
6 5 |
|
||||||
7 6 | import pydantic
|
7 6 | import pydantic
|
||||||
8 7 | from pydantic import BaseModel
|
8 7 | from pydantic import BaseModel
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
runtime_evaluated_decorators_3.py:6:18: TCH003 [*] Move standard library import `uuid.UUID` into a type-checking block
|
runtime_evaluated_decorators_3.py:6:18: TC003 [*] Move standard library import `uuid.UUID` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | from array import array
|
4 | from array import array
|
||||||
5 | from dataclasses import dataclass
|
5 | from dataclasses import dataclass
|
||||||
6 | from uuid import UUID # TCH003
|
6 | from uuid import UUID # TC003
|
||||||
| ^^^^ TCH003
|
| ^^^^ TC003
|
||||||
7 | from collections.abc import Sequence
|
7 | from collections.abc import Sequence
|
||||||
8 | from pydantic import validate_call
|
8 | from pydantic import validate_call
|
||||||
|
|
|
|
||||||
|
@ -17,7 +17,7 @@ runtime_evaluated_decorators_3.py:6:18: TCH003 [*] Move standard library import
|
||||||
3 3 | import datetime
|
3 3 | import datetime
|
||||||
4 4 | from array import array
|
4 4 | from array import array
|
||||||
5 5 | from dataclasses import dataclass
|
5 5 | from dataclasses import dataclass
|
||||||
6 |-from uuid import UUID # TCH003
|
6 |-from uuid import UUID # TC003
|
||||||
7 6 | from collections.abc import Sequence
|
7 6 | from collections.abc import Sequence
|
||||||
8 7 | from pydantic import validate_call
|
8 7 | from pydantic import validate_call
|
||||||
9 8 |
|
9 8 |
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
singledispatchmethod.py:4:21: TCH003 [*] Move standard library import `pathlib.Path` into a type-checking block
|
singledispatchmethod.py:4:21: TC003 [*] Move standard library import `pathlib.Path` into a type-checking block
|
||||||
|
|
|
|
||||||
3 | from collections.abc import MutableMapping, Mapping
|
3 | from collections.abc import MutableMapping, Mapping
|
||||||
4 | from pathlib import Path
|
4 | from pathlib import Path
|
||||||
| ^^^^ TCH003
|
| ^^^^ TC003
|
||||||
5 | from functools import singledispatchmethod
|
5 | from functools import singledispatchmethod
|
||||||
6 | from typing import Union
|
6 | from typing import Union
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
TCH002.py:5:22: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
TC002.py:5:22: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
4 | def f():
|
4 | def f():
|
||||||
5 | import pandas as pd # TCH002
|
5 | import pandas as pd # TC002
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
6 |
|
6 |
|
||||||
7 | x: pd.DataFrame
|
7 | x: pd.DataFrame
|
||||||
|
|
|
|
||||||
|
@ -21,16 +21,16 @@ TCH002.py:5:22: TCH002 [*] Move third-party import `pandas` into a type-checking
|
||||||
2 6 |
|
2 6 |
|
||||||
3 7 |
|
3 7 |
|
||||||
4 8 | def f():
|
4 8 | def f():
|
||||||
5 |- import pandas as pd # TCH002
|
5 |- import pandas as pd # TC002
|
||||||
6 9 |
|
6 9 |
|
||||||
7 10 | x: pd.DataFrame
|
7 10 | x: pd.DataFrame
|
||||||
8 11 |
|
8 11 |
|
||||||
|
|
||||||
TCH002.py:11:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
TC002.py:11:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
10 | def f():
|
10 | def f():
|
||||||
11 | from pandas import DataFrame # TCH002
|
11 | from pandas import DataFrame # TC002
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
12 |
|
12 |
|
||||||
13 | x: DataFrame
|
13 | x: DataFrame
|
||||||
|
|
|
|
||||||
|
@ -49,16 +49,16 @@ TCH002.py:11:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a ty
|
||||||
8 12 |
|
8 12 |
|
||||||
9 13 |
|
9 13 |
|
||||||
10 14 | def f():
|
10 14 | def f():
|
||||||
11 |- from pandas import DataFrame # TCH002
|
11 |- from pandas import DataFrame # TC002
|
||||||
12 15 |
|
12 15 |
|
||||||
13 16 | x: DataFrame
|
13 16 | x: DataFrame
|
||||||
14 17 |
|
14 17 |
|
||||||
|
|
||||||
TCH002.py:17:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
TC002.py:17:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
16 | def f():
|
16 | def f():
|
||||||
17 | from pandas import DataFrame as df # TCH002
|
17 | from pandas import DataFrame as df # TC002
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
18 |
|
18 |
|
||||||
19 | x: df
|
19 | x: df
|
||||||
|
|
|
|
||||||
|
@ -77,16 +77,16 @@ TCH002.py:17:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a ty
|
||||||
14 18 |
|
14 18 |
|
||||||
15 19 |
|
15 19 |
|
||||||
16 20 | def f():
|
16 20 | def f():
|
||||||
17 |- from pandas import DataFrame as df # TCH002
|
17 |- from pandas import DataFrame as df # TC002
|
||||||
18 21 |
|
18 21 |
|
||||||
19 22 | x: df
|
19 22 | x: df
|
||||||
20 23 |
|
20 23 |
|
||||||
|
|
||||||
TCH002.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
TC002.py:23:22: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
22 | def f():
|
22 | def f():
|
||||||
23 | import pandas as pd # TCH002
|
23 | import pandas as pd # TC002
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
24 |
|
24 |
|
||||||
25 | x: pd.DataFrame = 1
|
25 | x: pd.DataFrame = 1
|
||||||
|
|
|
|
||||||
|
@ -105,16 +105,16 @@ TCH002.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checkin
|
||||||
20 24 |
|
20 24 |
|
||||||
21 25 |
|
21 25 |
|
||||||
22 26 | def f():
|
22 26 | def f():
|
||||||
23 |- import pandas as pd # TCH002
|
23 |- import pandas as pd # TC002
|
||||||
24 27 |
|
24 27 |
|
||||||
25 28 | x: pd.DataFrame = 1
|
25 28 | x: pd.DataFrame = 1
|
||||||
26 29 |
|
26 29 |
|
||||||
|
|
||||||
TCH002.py:29:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
TC002.py:29:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
28 | def f():
|
28 | def f():
|
||||||
29 | from pandas import DataFrame # TCH002
|
29 | from pandas import DataFrame # TC002
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
30 |
|
30 |
|
||||||
31 | x: DataFrame = 2
|
31 | x: DataFrame = 2
|
||||||
|
|
|
|
||||||
|
@ -133,16 +133,16 @@ TCH002.py:29:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a ty
|
||||||
26 30 |
|
26 30 |
|
||||||
27 31 |
|
27 31 |
|
||||||
28 32 | def f():
|
28 32 | def f():
|
||||||
29 |- from pandas import DataFrame # TCH002
|
29 |- from pandas import DataFrame # TC002
|
||||||
30 33 |
|
30 33 |
|
||||||
31 34 | x: DataFrame = 2
|
31 34 | x: DataFrame = 2
|
||||||
32 35 |
|
32 35 |
|
||||||
|
|
||||||
TCH002.py:35:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
TC002.py:35:37: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
34 | def f():
|
34 | def f():
|
||||||
35 | from pandas import DataFrame as df # TCH002
|
35 | from pandas import DataFrame as df # TC002
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
36 |
|
36 |
|
||||||
37 | x: df = 3
|
37 | x: df = 3
|
||||||
|
|
|
|
||||||
|
@ -161,16 +161,16 @@ TCH002.py:35:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a ty
|
||||||
32 36 |
|
32 36 |
|
||||||
33 37 |
|
33 37 |
|
||||||
34 38 | def f():
|
34 38 | def f():
|
||||||
35 |- from pandas import DataFrame as df # TCH002
|
35 |- from pandas import DataFrame as df # TC002
|
||||||
36 39 |
|
36 39 |
|
||||||
37 40 | x: df = 3
|
37 40 | x: df = 3
|
||||||
38 41 |
|
38 41 |
|
||||||
|
|
||||||
TCH002.py:41:22: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
TC002.py:41:22: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
40 | def f():
|
40 | def f():
|
||||||
41 | import pandas as pd # TCH002
|
41 | import pandas as pd # TC002
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
42 |
|
42 |
|
||||||
43 | x: "pd.DataFrame" = 1
|
43 | x: "pd.DataFrame" = 1
|
||||||
|
|
|
|
||||||
|
@ -189,16 +189,16 @@ TCH002.py:41:22: TCH002 [*] Move third-party import `pandas` into a type-checkin
|
||||||
38 42 |
|
38 42 |
|
||||||
39 43 |
|
39 43 |
|
||||||
40 44 | def f():
|
40 44 | def f():
|
||||||
41 |- import pandas as pd # TCH002
|
41 |- import pandas as pd # TC002
|
||||||
42 45 |
|
42 45 |
|
||||||
43 46 | x: "pd.DataFrame" = 1
|
43 46 | x: "pd.DataFrame" = 1
|
||||||
44 47 |
|
44 47 |
|
||||||
|
|
||||||
TCH002.py:47:22: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
TC002.py:47:22: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
46 | def f():
|
46 | def f():
|
||||||
47 | import pandas as pd # TCH002
|
47 | import pandas as pd # TC002
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
48 |
|
48 |
|
||||||
49 | x = dict["pd.DataFrame", "pd.DataFrame"]
|
49 | x = dict["pd.DataFrame", "pd.DataFrame"]
|
||||||
|
|
|
|
||||||
|
@ -217,17 +217,17 @@ TCH002.py:47:22: TCH002 [*] Move third-party import `pandas` into a type-checkin
|
||||||
44 48 |
|
44 48 |
|
||||||
45 49 |
|
45 49 |
|
||||||
46 50 | def f():
|
46 50 | def f():
|
||||||
47 |- import pandas as pd # TCH002
|
47 |- import pandas as pd # TC002
|
||||||
48 51 |
|
48 51 |
|
||||||
49 52 | x = dict["pd.DataFrame", "pd.DataFrame"]
|
49 52 | x = dict["pd.DataFrame", "pd.DataFrame"]
|
||||||
50 53 |
|
50 53 |
|
||||||
|
|
||||||
TCH002.py:172:24: TCH002 [*] Move third-party import `module.Member` into a type-checking block
|
TC002.py:172:24: TC002 [*] Move third-party import `module.Member` into a type-checking block
|
||||||
|
|
|
|
||||||
170 | global Member
|
170 | global Member
|
||||||
171 |
|
171 |
|
||||||
172 | from module import Member
|
172 | from module import Member
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
173 |
|
173 |
|
||||||
174 | x: Member = 1
|
174 | x: Member = 1
|
||||||
|
|
|
|
|
@ -2,23 +2,23 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
runtime_evaluated_base_classes_2.py:3:21: TCH002 [*] Move third-party import `geopandas` into a type-checking block
|
runtime_evaluated_base_classes_2.py:3:21: TC002 [*] Move third-party import `geopandas` into a type-checking block
|
||||||
|
|
|
|
||||||
1 | from __future__ import annotations
|
1 | from __future__ import annotations
|
||||||
2 |
|
2 |
|
||||||
3 | import geopandas as gpd # TCH002
|
3 | import geopandas as gpd # TC002
|
||||||
| ^^^ TCH002
|
| ^^^ TC002
|
||||||
4 | import pydantic
|
4 | import pydantic
|
||||||
5 | import pyproj # TCH002
|
5 | import pyproj # TC002
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
||||||
ℹ Unsafe fix
|
ℹ Unsafe fix
|
||||||
1 1 | from __future__ import annotations
|
1 1 | from __future__ import annotations
|
||||||
2 2 |
|
2 2 |
|
||||||
3 |-import geopandas as gpd # TCH002
|
3 |-import geopandas as gpd # TC002
|
||||||
4 3 | import pydantic
|
4 3 | import pydantic
|
||||||
5 4 | import pyproj # TCH002
|
5 4 | import pyproj # TC002
|
||||||
6 5 | from pydantic import BaseModel
|
6 5 | from pydantic import BaseModel
|
||||||
7 6 |
|
7 6 |
|
||||||
8 7 | import numpy
|
8 7 | import numpy
|
||||||
|
@ -30,21 +30,21 @@ runtime_evaluated_base_classes_2.py:3:21: TCH002 [*] Move third-party import `ge
|
||||||
10 13 |
|
10 13 |
|
||||||
11 14 | class A(BaseModel):
|
11 14 | class A(BaseModel):
|
||||||
|
|
||||||
runtime_evaluated_base_classes_2.py:5:8: TCH002 [*] Move third-party import `pyproj` into a type-checking block
|
runtime_evaluated_base_classes_2.py:5:8: TC002 [*] Move third-party import `pyproj` into a type-checking block
|
||||||
|
|
|
|
||||||
3 | import geopandas as gpd # TCH002
|
3 | import geopandas as gpd # TC002
|
||||||
4 | import pydantic
|
4 | import pydantic
|
||||||
5 | import pyproj # TCH002
|
5 | import pyproj # TC002
|
||||||
| ^^^^^^ TCH002
|
| ^^^^^^ TC002
|
||||||
6 | from pydantic import BaseModel
|
6 | from pydantic import BaseModel
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
||||||
ℹ Unsafe fix
|
ℹ Unsafe fix
|
||||||
2 2 |
|
2 2 |
|
||||||
3 3 | import geopandas as gpd # TCH002
|
3 3 | import geopandas as gpd # TC002
|
||||||
4 4 | import pydantic
|
4 4 | import pydantic
|
||||||
5 |-import pyproj # TCH002
|
5 |-import pyproj # TC002
|
||||||
6 5 | from pydantic import BaseModel
|
6 5 | from pydantic import BaseModel
|
||||||
7 6 |
|
7 6 |
|
||||||
8 7 | import numpy
|
8 7 | import numpy
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
runtime_evaluated_decorators_2.py:10:8: TCH002 [*] Move third-party import `numpy` into a type-checking block
|
runtime_evaluated_decorators_2.py:10:8: TC002 [*] Move third-party import `numpy` into a type-checking block
|
||||||
|
|
|
|
||||||
8 | from attrs import frozen
|
8 | from attrs import frozen
|
||||||
9 |
|
9 |
|
||||||
10 | import numpy # TCH002
|
10 | import numpy # TC002
|
||||||
| ^^^^^ TCH002
|
| ^^^^^ TC002
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ runtime_evaluated_decorators_2.py:10:8: TCH002 [*] Move third-party import `nump
|
||||||
7 7 | import pyproj
|
7 7 | import pyproj
|
||||||
8 8 | from attrs import frozen
|
8 8 | from attrs import frozen
|
||||||
9 9 |
|
9 9 |
|
||||||
10 |-import numpy # TCH002
|
10 |-import numpy # TC002
|
||||||
10 |+from typing import TYPE_CHECKING
|
10 |+from typing import TYPE_CHECKING
|
||||||
11 |+
|
11 |+
|
||||||
12 |+if TYPE_CHECKING:
|
12 |+if TYPE_CHECKING:
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
singledispatch.py:12:20: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
singledispatch.py:12:20: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
10 | from numpy.typing import ArrayLike
|
10 | from numpy.typing import ArrayLike
|
||||||
11 | from scipy.sparse import spmatrix
|
11 | from scipy.sparse import spmatrix
|
||||||
12 | from pandas import DataFrame
|
12 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
13 |
|
13 |
|
||||||
14 | if TYPE_CHECKING:
|
14 | if TYPE_CHECKING:
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-checking block
|
strict.py:54:25: TC002 [*] Move third-party import `pkg.bar.A` into a type-checking block
|
||||||
|
|
|
|
||||||
52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime
|
52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime
|
||||||
53 | import pkg
|
53 | import pkg
|
||||||
54 | from pkg.bar import A
|
54 | from pkg.bar import A
|
||||||
| ^ TCH002
|
| ^ TC002
|
||||||
55 |
|
55 |
|
||||||
56 | def test(value: A):
|
56 | def test(value: A):
|
||||||
|
|
|
|
||||||
|
@ -31,12 +31,12 @@ strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-chec
|
||||||
56 59 | def test(value: A):
|
56 59 | def test(value: A):
|
||||||
57 60 | return pkg.B()
|
57 60 | return pkg.B()
|
||||||
|
|
||||||
strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking block
|
strict.py:91:12: TC002 [*] Move third-party import `pkg` into a type-checking block
|
||||||
|
|
|
|
||||||
89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is
|
89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is
|
||||||
90 | # testing the implementation.
|
90 | # testing the implementation.
|
||||||
91 | import pkg
|
91 | import pkg
|
||||||
| ^^^ TCH002
|
| ^^^ TC002
|
||||||
92 | import pkgfoo.bar as B
|
92 | import pkgfoo.bar as B
|
||||||
|
|
|
|
||||||
= help: Move into type-checking block
|
= help: Move into type-checking block
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
typing_modules_1.py:7:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
typing_modules_1.py:7:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
6 | def func():
|
6 | def func():
|
||||||
7 | from pandas import DataFrame
|
7 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
8 |
|
8 |
|
||||||
9 | df: DataFrame
|
9 | df: DataFrame
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
typing_modules_2.py:7:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
typing_modules_2.py:7:24: TC002 [*] Move third-party import `pandas.DataFrame` into a type-checking block
|
||||||
|
|
|
|
||||||
6 | def func():
|
6 | def func():
|
||||||
7 | from pandas import DataFrame
|
7 | from pandas import DataFrame
|
||||||
| ^^^^^^^^^ TCH002
|
| ^^^^^^^^^ TC002
|
||||||
8 |
|
8 |
|
||||||
9 | df: DataFrame
|
9 | df: DataFrame
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:4:18: TCH002 [*] Move third-party import `pandas` into a type-checking block
|
<filename>:4:18: TC002 [*] Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
2 | from __future__ import annotations
|
2 | from __future__ import annotations
|
||||||
3 |
|
3 |
|
||||||
4 | import pandas as pd
|
4 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
5 |
|
5 |
|
||||||
6 | from typing import TYPE_CHECKING
|
6 | from typing import TYPE_CHECKING
|
||||||
|
|
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs
|
||||||
snapshot_kind: text
|
snapshot_kind: text
|
||||||
---
|
---
|
||||||
<filename>:4:18: TCH002 Move third-party import `pandas` into a type-checking block
|
<filename>:4:18: TC002 Move third-party import `pandas` into a type-checking block
|
||||||
|
|
|
|
||||||
2 | from __future__ import annotations
|
2 | from __future__ import annotations
|
||||||
3 |
|
3 |
|
||||||
4 | import pandas as pd
|
4 | import pandas as pd
|
||||||
| ^^ TCH002
|
| ^^ TC002
|
||||||
5 |
|
5 |
|
||||||
6 | def f(x: pd.DataFrame):
|
6 | def f(x: pd.DataFrame):
|
||||||
|
|
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue