Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Option<String> → Option<&str> conversion using as_deref #1675

Merged
merged 1 commit into from Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/checkers/ast.rs
Expand Up @@ -933,7 +933,7 @@ where
if self.settings.enabled.contains(&CheckCode::PT013) {
if let Some(check) = flake8_pytest_style::plugins::import_from(
stmt,
module.as_ref().map(String::as_str),
module.as_deref(),
level.as_ref(),
) {
self.add_check(check);
Expand Down Expand Up @@ -999,7 +999,7 @@ where
self.add_check(Check::new(
CheckKind::ImportStarNotPermitted(helpers::format_import_from(
level.as_ref(),
module.as_ref().map(String::as_str),
module.as_deref(),
)),
Range::from_located(stmt),
));
Expand All @@ -1010,7 +1010,7 @@ where
self.add_check(Check::new(
CheckKind::ImportStarUsed(helpers::format_import_from(
level.as_ref(),
module.as_ref().map(String::as_str),
module.as_deref(),
)),
Range::from_located(stmt),
));
Expand Down Expand Up @@ -1076,7 +1076,7 @@ where
if self.settings.enabled.contains(&CheckCode::T100) {
if let Some(check) = flake8_debugger::checks::debugger_import(
stmt,
module.as_ref().map(String::as_str),
module.as_deref(),
&alias.node.name,
) {
self.add_check(check);
Expand Down Expand Up @@ -2636,11 +2636,7 @@ where
}
}
if self.settings.enabled.contains(&CheckCode::UP025) {
pyupgrade::plugins::rewrite_unicode_literal(
self,
expr,
kind.as_ref().map(String::as_str),
);
pyupgrade::plugins::rewrite_unicode_literal(self, expr, kind.as_deref());
}
}
ExprKind::Lambda { args, body, .. } => {
Expand Down Expand Up @@ -2978,7 +2974,7 @@ where
flake8_blind_except::plugins::blind_except(
self,
type_.as_deref(),
name.as_ref().map(String::as_str),
name.as_deref(),
body,
);
}
Expand Down Expand Up @@ -3442,7 +3438,7 @@ impl<'a> Checker<'a> {
if let BindingKind::StarImportation(level, module) = &binding.kind {
from_list.push(helpers::format_import_from(
level.as_ref(),
module.as_ref().map(String::as_str),
module.as_deref(),
));
}
}
Expand Down Expand Up @@ -3923,7 +3919,7 @@ impl<'a> Checker<'a> {
if let BindingKind::StarImportation(level, module) = &binding.kind {
from_list.push(helpers::format_import_from(
level.as_ref(),
module.as_ref().map(String::as_str),
module.as_deref(),
));
}
}
Expand Down