Skip to content

Commit

Permalink
Revert "Expand scope of quoted-annotation rule (#5766)" (#6237)
Browse files Browse the repository at this point in the history
This is causing some problems, so we'll just revert for now.

Closes #6189.
  • Loading branch information
charliermarsh authored Aug 1, 2023
1 parent 29fb655 commit 0753017
Show file tree
Hide file tree
Showing 8 changed files with 561 additions and 699 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"""A mirror of UP037_1.py, with `from __future__ import annotations`."""

from __future__ import annotations

from typing import (
Expand Down
108 changes: 0 additions & 108 deletions crates/ruff/resources/test/fixtures/pyupgrade/UP037_1.py

This file was deleted.

2 changes: 1 addition & 1 deletion crates/ruff/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ impl<'a> Checker<'a> {

self.semantic.restore(snapshot);

if self.semantic.in_typing_only_annotation() {
if self.semantic.in_annotation() && self.semantic.future_annotations() {
if self.enabled(Rule::QuotedAnnotation) {
pyupgrade::rules::quoted_annotation(self, value, range);
}
Expand Down
3 changes: 1 addition & 2 deletions crates/ruff/src/rules/pyupgrade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ mod tests {
#[test_case(Rule::OutdatedVersionBlock, Path::new("UP036_5.py"))]
#[test_case(Rule::PrintfStringFormatting, Path::new("UP031_0.py"))]
#[test_case(Rule::PrintfStringFormatting, Path::new("UP031_1.py"))]
#[test_case(Rule::QuotedAnnotation, Path::new("UP037_0.py"))]
#[test_case(Rule::QuotedAnnotation, Path::new("UP037_1.py"))]
#[test_case(Rule::QuotedAnnotation, Path::new("UP037.py"))]
#[test_case(Rule::RedundantOpenModes, Path::new("UP015.py"))]
#[test_case(Rule::ReplaceStdoutStderr, Path::new("UP022.py"))]
#[test_case(Rule::ReplaceUniversalNewlines, Path::new("UP021.py"))]
Expand Down
5 changes: 0 additions & 5 deletions crates/ruff/src/rules/pyupgrade/rules/quoted_annotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ use crate::registry::Rule;
/// will always evaluate type annotations in a deferred manner, making
/// the quotes unnecessary.
///
/// Type annotations can also be unquoted in some other contexts, even
/// without `from __future__ import annotations`. For example, annotated
/// assignments within function bodies are not evaluated at runtime, and so can
/// be unquoted.
///
/// ## Example
/// ```python
/// from __future__ import annotations
Expand Down
Loading

0 comments on commit 0753017

Please sign in to comment.