From ec88acc291907abc670cc3f89809b5999100c4a0 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Fri, 29 Dec 2023 04:41:29 -0800 Subject: [PATCH] [`pyupgrade`] Document more fix unsafety for UP007 (#9306) ``` from typing import Optional x = "asdf" def foo(a: Optional[x]): pass ``` --- .../src/rules/pyupgrade/rules/use_pep604_annotation.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs index 5332be054f86b..d3ad5b7dea447 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs @@ -40,7 +40,9 @@ use crate::settings::types::PythonVersion; /// ## Fix safety /// This rule's fix is marked as unsafe, as it may lead to runtime errors when /// alongside libraries that rely on runtime type annotations, like Pydantic, -/// on Python versions prior to Python 3.10. +/// on Python versions prior to Python 3.10. It may also lead to runtime errors +/// in unusual and likely incorrect type annotations where the type does not +/// support the `|` operator. /// /// ## Options /// - `target-version`