mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:23:11 +00:00
Match import name ignores against both name and alias (#12033)
## Summary Right now, it's inconsistent... We sometimes match against the name, and sometimes against the alias (`asname`). I could see a case for always matching against the name, but matching against both seems fine too, since the rule is really about the combination of the two? Closes https://github.com/astral-sh/ruff/issues/12031.
This commit is contained in:
parent
00e456ead4
commit
83fe44728b
5 changed files with 5 additions and 5 deletions
|
@ -62,7 +62,7 @@ pub(crate) fn camelcase_imported_as_acronym(
|
|||
&& helpers::is_acronym(name, asname)
|
||||
{
|
||||
// Ignore any explicitly-allowed names.
|
||||
if ignore_names.matches(name) {
|
||||
if ignore_names.matches(name) || ignore_names.matches(asname) {
|
||||
return None;
|
||||
}
|
||||
let mut diagnostic = Diagnostic::new(
|
||||
|
|
|
@ -59,7 +59,7 @@ pub(crate) fn camelcase_imported_as_constant(
|
|||
&& !helpers::is_acronym(name, asname)
|
||||
{
|
||||
// Ignore any explicitly-allowed names.
|
||||
if ignore_names.matches(asname) {
|
||||
if ignore_names.matches(name) || ignore_names.matches(asname) {
|
||||
return None;
|
||||
}
|
||||
let mut diagnostic = Diagnostic::new(
|
||||
|
|
|
@ -54,7 +54,7 @@ pub(crate) fn camelcase_imported_as_lowercase(
|
|||
) -> Option<Diagnostic> {
|
||||
if helpers::is_camelcase(name) && ruff_python_stdlib::str::is_cased_lowercase(asname) {
|
||||
// Ignore any explicitly-allowed names.
|
||||
if ignore_names.matches(asname) {
|
||||
if ignore_names.matches(name) || ignore_names.matches(asname) {
|
||||
return None;
|
||||
}
|
||||
let mut diagnostic = Diagnostic::new(
|
||||
|
|
|
@ -54,7 +54,7 @@ pub(crate) fn constant_imported_as_non_constant(
|
|||
) -> Option<Diagnostic> {
|
||||
if str::is_cased_uppercase(name) && !str::is_cased_uppercase(asname) {
|
||||
// Ignore any explicitly-allowed names.
|
||||
if ignore_names.matches(asname) {
|
||||
if ignore_names.matches(name) || ignore_names.matches(asname) {
|
||||
return None;
|
||||
}
|
||||
let mut diagnostic = Diagnostic::new(
|
||||
|
|
|
@ -54,7 +54,7 @@ pub(crate) fn lowercase_imported_as_non_lowercase(
|
|||
if !str::is_cased_uppercase(name) && str::is_cased_lowercase(name) && !str::is_lowercase(asname)
|
||||
{
|
||||
// Ignore any explicitly-allowed names.
|
||||
if ignore_names.matches(asname) {
|
||||
if ignore_names.matches(name) || ignore_names.matches(asname) {
|
||||
return None;
|
||||
}
|
||||
let mut diagnostic = Diagnostic::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue