PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: PyCQA/pyflakes (python)
Issue: annotated variable hides "undefined name"
this works:

```console
$ pyflakes /dev/stdin <<< 'x = x'
/dev/stdin:1:5: undefined name 'x'
$
```

this does not:

```console
$ pyflakes /dev/stdin <<< 'x: int = x'
$
```
Pull request description: detect undefined name of variable defined by AnnAssign
resolves #728

Patch:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index ae15621..56fc3ca 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -2265,7 +2265,6 @@ class Checker:
             self.scope[node.name] = prev_definition
 
     def ANNASSIGN(self, node):
-        self.handleNode(node.target, node)
         self.handleAnnotation(node.annotation, node)
         # If the assignment has value, handle the *value* now.
         if node.value:
@@ -2274,6 +2273,7 @@ class Checker:
                 self.handleAnnotation(node.value, node)
             else:
                 self.handleNode(node.value, node)
+        self.handleNode(node.target, node)
 
     def COMPARE(self, node):
         left = node.left


Test patch:
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 3775cd3..d881205 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -298,6 +298,11 @@ class TestTypeAnnotations(TestCase):
         a: 'a: "A"'
         ''', m.ForwardAnnotationSyntaxError)
 
+    def test_variable_annotation_references_self_name_undefined(self):
+        self.flakes("""
+        x: int = x
+        """, m.UndefinedName)
+
     def test_TypeAlias_annotations(self):
         self.flakes("""
         from typing_extensions import TypeAlias