Add fix for future-required-type-annotation (#8711)

## Summary

We already support inserting imports for `I002` -- this PR just adds the
same fix for `FA102`, which is explicitly about `from __future__ import
annotations`.

Closes https://github.com/astral-sh/ruff/issues/8682.
This commit is contained in:
Charlie Marsh 2023-11-15 19:08:02 -08:00 committed by GitHub
parent cd29761b9c
commit a59172528c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 131 additions and 26 deletions

View file

@ -248,6 +248,12 @@ impl<'a> Definitions<'a> {
ContextualizedDefinitions(definitions.raw)
}
/// Returns a reference to the Python AST.
pub fn python_ast(&self) -> Option<&'a [Stmt]> {
let module = self[DefinitionId::module()].as_module()?;
Some(module.python_ast)
}
}
impl<'a> Deref for Definitions<'a> {