Include alias when formatting import-from structs (#5786)

## Summary

When required-imports is set with the syntax from ... import ... as ...,
autofix I002 is failing

## Test Plan

Reuse the same python files as
`crates/ruff/src/rules/isort/mod.rs:required_import` test.
This commit is contained in:
guillaumeLepape 2023-07-15 21:53:21 +02:00 committed by GitHub
parent 8ccd697020
commit 6824b67f44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 171 additions and 0 deletions

View file

@ -85,6 +85,9 @@ impl std::fmt::Display for ImportFrom<'_> {
write!(f, "{module}")?;
}
write!(f, " import {}", self.name.name)?;
if let Some(as_name) = self.name.as_name {
write!(f, " as {as_name}")?;
}
Ok(())
}
}