mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:52:01 +00:00
Add another check
This commit is contained in:
parent
6257dd00c7
commit
211849901c
7 changed files with 120 additions and 54 deletions
|
@ -27,26 +27,27 @@ pub enum Message {
|
|||
#[serde(with = "LocationDef")]
|
||||
location: Location,
|
||||
},
|
||||
IfTuple {
|
||||
filename: PathBuf,
|
||||
#[serde(with = "LocationDef")]
|
||||
location: Location,
|
||||
},
|
||||
}
|
||||
|
||||
impl Message {
|
||||
/// A four-letter shorthand code for the message.
|
||||
pub fn code(&self) -> &'static str {
|
||||
match self {
|
||||
Message::ImportStarUsage {
|
||||
filename: _,
|
||||
location: _,
|
||||
} => "F403",
|
||||
Message::ImportStarUsage { .. } => "F403",
|
||||
Message::IfTuple { .. } => "F634",
|
||||
}
|
||||
}
|
||||
|
||||
/// The body text for the message.
|
||||
pub fn body(&self) -> &'static str {
|
||||
match self {
|
||||
Message::ImportStarUsage {
|
||||
filename: _,
|
||||
location: _,
|
||||
} => "Unable to detect undefined names",
|
||||
Message::ImportStarUsage { .. } => "Unable to detect undefined names",
|
||||
Message::IfTuple { .. } => "If test is a tuple, which is always `True`",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +66,17 @@ impl fmt::Display for Message {
|
|||
self.code().red().bold(),
|
||||
self.body()
|
||||
),
|
||||
Message::IfTuple { filename, location } => write!(
|
||||
f,
|
||||
"{}{}{}{}{}\t{}\t{}",
|
||||
filename.to_string_lossy().white().bold(),
|
||||
":".cyan(),
|
||||
location.column(),
|
||||
":".cyan(),
|
||||
location.row(),
|
||||
self.code().red().bold(),
|
||||
self.body()
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue