mirror of https://github.com/astral-sh/ruff
Rename rule to SA201
This commit is contained in:
parent
2606ce2de4
commit
5145f2f0bb
|
|
@ -1143,7 +1143,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
|||
(Flake8Logging, "015") => (RuleGroup::Stable, rules::flake8_logging::rules::RootLoggerCall),
|
||||
|
||||
// SQLAlchemy
|
||||
(SQLAlchemy, "001") => (RuleGroup::Preview, rules::sqlalchemy::rules::SQLAlchemyMissingMappedTypeAnnotation),
|
||||
(SQLAlchemy, "201") => (RuleGroup::Preview, rules::sqlalchemy::rules::SQLAlchemyMissingMappedTypeAnnotation),
|
||||
|
||||
_ => return None,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ mod tests {
|
|||
use crate::test::test_path;
|
||||
use crate::{assert_messages, settings};
|
||||
|
||||
#[test_case(Rule::SQLAlchemyMissingMappedTypeAnnotation, Path::new("SA001.py"))]
|
||||
#[test_case(Rule::SQLAlchemyMissingMappedTypeAnnotation, Path::new("SA201.py"))]
|
||||
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
|
||||
let diagnostics = test_path(
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ impl Violation for SQLAlchemyMissingMappedTypeAnnotation {
|
|||
}
|
||||
}
|
||||
|
||||
/// SA001
|
||||
/// SA201
|
||||
pub(crate) fn missing_mapped_type_annotation(checker: &mut Checker, body: &[Stmt]) {
|
||||
if !checker.semantic().seen_module(Modules::SQLALCHEMY) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,100 +1,100 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/sqlalchemy/mod.rs
|
||||
---
|
||||
SA001.py:52:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:52:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
50 | __tablename__ = "company"
|
||||
51 |
|
||||
52 | id = mapped_column(Integer, primary_key=True)
|
||||
| ^^ SA001
|
||||
| ^^ SA201
|
||||
53 | employees = relationship("Employee", back_populates="company")
|
||||
|
|
||||
|
||||
SA001.py:53:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:53:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
52 | id = mapped_column(Integer, primary_key=True)
|
||||
53 | employees = relationship("Employee", back_populates="company")
|
||||
| ^^^^^^^^^ SA001
|
||||
| ^^^^^^^^^ SA201
|
||||
54 |
|
||||
55 | name = mapped_column(String)
|
||||
|
|
||||
|
||||
SA001.py:55:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:55:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
53 | employees = relationship("Employee", back_populates="company")
|
||||
54 |
|
||||
55 | name = mapped_column(String)
|
||||
| ^^^^ SA001
|
||||
| ^^^^ SA201
|
||||
56 | company_name = synonym("name")
|
||||
|
|
||||
|
||||
SA001.py:56:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:56:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
55 | name = mapped_column(String)
|
||||
56 | company_name = synonym("name")
|
||||
| ^^^^^^^^^^^^ SA001
|
||||
| ^^^^^^^^^^^^ SA201
|
||||
|
|
||||
|
||||
SA001.py:62:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:62:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
60 | __tablename__ = "employee"
|
||||
61 |
|
||||
62 | id = mapped_column(Integer, primary_key=True)
|
||||
| ^^ SA001
|
||||
| ^^ SA201
|
||||
63 | company_id = mapped_column(ForeignKey("company.id"))
|
||||
64 | company = relationship("Company", back_populates="employees")
|
||||
|
|
||||
|
||||
SA001.py:63:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:63:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
62 | id = mapped_column(Integer, primary_key=True)
|
||||
63 | company_id = mapped_column(ForeignKey("company.id"))
|
||||
| ^^^^^^^^^^ SA001
|
||||
| ^^^^^^^^^^ SA201
|
||||
64 | company = relationship("Company", back_populates="employees")
|
||||
|
|
||||
|
||||
SA001.py:64:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:64:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
62 | id = mapped_column(Integer, primary_key=True)
|
||||
63 | company_id = mapped_column(ForeignKey("company.id"))
|
||||
64 | company = relationship("Company", back_populates="employees")
|
||||
| ^^^^^^^ SA001
|
||||
| ^^^^^^^ SA201
|
||||
65 |
|
||||
66 | company_name = association_proxy("company", "name")
|
||||
|
|
||||
|
||||
SA001.py:66:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:66:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
64 | company = relationship("Company", back_populates="employees")
|
||||
65 |
|
||||
66 | company_name = association_proxy("company", "name")
|
||||
| ^^^^^^^^^^^^ SA001
|
||||
| ^^^^^^^^^^^^ SA201
|
||||
67 |
|
||||
68 | first_name = mapped_column(String)
|
||||
|
|
||||
|
||||
SA001.py:68:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:68:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
66 | company_name = association_proxy("company", "name")
|
||||
67 |
|
||||
68 | first_name = mapped_column(String)
|
||||
| ^^^^^^^^^^ SA001
|
||||
| ^^^^^^^^^^ SA201
|
||||
69 | last_name = mapped_column(String)
|
||||
|
|
||||
|
||||
SA001.py:69:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:69:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
68 | first_name = mapped_column(String)
|
||||
69 | last_name = mapped_column(String)
|
||||
| ^^^^^^^^^ SA001
|
||||
| ^^^^^^^^^ SA201
|
||||
70 |
|
||||
71 | name_length = column_property(func.length(first_name + last_name))
|
||||
|
|
||||
|
||||
SA001.py:71:5: SA001 Missing `Mapped` or other ORM container class type annotation
|
||||
SA201.py:71:5: SA201 Missing `Mapped` or other ORM container class type annotation
|
||||
|
|
||||
69 | last_name = mapped_column(String)
|
||||
70 |
|
||||
71 | name_length = column_property(func.length(first_name + last_name))
|
||||
| ^^^^^^^^^^^ SA001
|
||||
| ^^^^^^^^^^^ SA201
|
||||
|
|
||||
|
|
@ -4138,9 +4138,9 @@
|
|||
"S702",
|
||||
"S704",
|
||||
"SA",
|
||||
"SA0",
|
||||
"SA00",
|
||||
"SA001",
|
||||
"SA2",
|
||||
"SA20",
|
||||
"SA201",
|
||||
"SIM",
|
||||
"SIM1",
|
||||
"SIM10",
|
||||
|
|
|
|||
Loading…
Reference in New Issue