Improve documentation for PLE1300 (#6430)

This commit is contained in:
Zanie Blue 2023-08-08 15:16:36 -05:00 committed by GitHub
parent c7703e205d
commit d33618062e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,8 +19,7 @@ use crate::checkers::ast::Checker;
/// Checks for unsupported format types in format strings.
///
/// ## Why is this bad?
/// The format string is not checked at compile time, so it is easy to
/// introduce bugs by mistyping the format string.
/// An invalid format string character will result in an error at runtime.
///
/// ## Example
/// ```python
@ -41,6 +40,7 @@ impl Violation for BadStringFormatCharacter {
}
}
/// PLE1300
/// Ex) `"{:z}".format("1")`
pub(crate) fn call(checker: &mut Checker, string: &str, range: TextRange) {
if let Ok(format_string) = FormatString::from_str(string) {
@ -64,6 +64,7 @@ pub(crate) fn call(checker: &mut Checker, string: &str, range: TextRange) {
}
}
/// PLE1300
/// Ex) `"%z" % "1"`
pub(crate) fn percent(checker: &mut Checker, expr: &Expr) {
// Grab each string segment (in case there's an implicit concatenation).