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

Implement flake8-future-annotations FA100 #3979

Merged
merged 22 commits into from
May 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions crates/ruff/src/rules/flake8_future_annotations/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@ use ruff_python_stdlib::typing::PEP_585_SUBSCRIPT_ELIGIBLE;

use crate::checkers::ast::Checker;

/// ## What it does
/// Checks for missing `from __future__ import annotations` import if a type used in the
/// module can be rewritten using PEP 563.
///
/// ## Why is this bad?
/// Pairs well with pyupgrade with the --py37-plus flag or higher, since pyupgrade only
/// replaces type annotations with the PEP 563 rules if `from __future__ import annotations`
/// is present.
///
TylerYep marked this conversation as resolved.
Show resolved Hide resolved
/// ## Example
/// ```python
/// import typing as t
/// from typing import List
///
///
/// def function(a_dict: t.Dict[str, t.Optional[int]]) -> None:
/// a_list: List[str] = []
/// a_list.append("hello")
Expand All @@ -33,6 +25,7 @@ use crate::checkers::ast::Checker;
/// import typing as t
/// from typing import List
///
///
/// def function(a_dict: t.Dict[str, t.Optional[int]]) -> None:
/// a_list: List[str] = []
/// a_list.append("hello")
Expand All @@ -42,6 +35,7 @@ use crate::checkers::ast::Checker;
/// ```python
/// from __future__ import annotations
///
///
/// def function(a_dict: dict[str, int | None]) -> None:
/// a_list: list[str] = []
/// a_list.append("hello")
Expand Down