nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: PyCQA/pyflakes
Pull request #416 (2019-01-21 01:11:40)

Allow star args in type comments
Found while trying out the release on [this file](https://github.com/lyft/awspricing/blob/23493d2c397da9dcffcf3b598df5b5d32f303121/awspricing/constants.py#L14)


Patch:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 7b68b21..480ee00 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -1037,7 +1037,10 @@ class Checker(object):
             comment = comment.split(':', 1)[1].strip()
             func_match = TYPE_FUNC_RE.match(comment)
             if func_match:
-                parts = (func_match.group(1), func_match.group(2).strip())
+                parts = (
+                    func_match.group(1).replace('*', ''),
+                    func_match.group(2).strip(),
+                )
             else:
                 parts = (comment,)
 


Test patch:
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 1ed676b..40397e8 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -231,6 +231,14 @@ class TestTypeAnnotations(TestCase):
             return a + b
         """)
 
+    def test_typeCommentsStarArgs(self):
+        self.flakes("""
+        from mod import A, B, C, D
+        def f(a, *b, **c):
+            # type: (A, *B, **C) -> D
+            return a + b
+        """)
+
     def test_typeCommentsFullSignatureWithDocstring(self):
         self.flakes('''
         from mod import A, B, C, D
Repository: PyCQA/pyflakes
Pull request #588 (2020-10-12 13:33:34)

Recognize __qualname__ when used in class scope
`pyflakes` doesn't recognize [`__qualname__`](https://docs.python.org/3/glossary.html#term-qualified-name).

Reproducer:
```
$ echo -e "class Foo:\n    __qualname__" | python3
$ pyflakes --version
2.2.0 Python 3.8.6 on Linux
$ echo -e "class Foo:\n    __qualname__" | pyflakes 
<stdin>:2:5 undefined name '__qualname__'
```

Initially reported [here](https://gitlab.com/pycqa/flake8/-/issues/227), relates #259.


Patch:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index d6d057e..0d65506 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -669,6 +669,10 @@ class DummyNode(object):
         self.col_offset = col_offset
 
 
+class DetectClassScopedMagic:
+    names = dir()
+
+
 # Globally defined names which are not attributes of the builtins module, or
 # are only present on some platforms.
 _MAGIC_GLOBALS = ['__file__', '__builtins__', 'WindowsError']
@@ -1231,7 +1235,7 @@ class Checker(object):
             # the special name __path__ is valid only in packages
             return
 
-        if name == '__module__' and isinstance(self.scope, ClassScope):
+        if name in DetectClassScopedMagic.names and isinstance(self.scope, ClassScope):
             return
 
         # protected with a NameError handler?


Test patch:
diff --git a/pyflakes/test/test_undefined_names.py b/pyflakes/test/test_undefined_names.py
index c952cbb..e0e628d 100644
--- a/pyflakes/test/test_undefined_names.py
+++ b/pyflakes/test/test_undefined_names.py
@@ -279,6 +279,23 @@ class Test(TestCase):
                 __module__
         ''', m.UndefinedName)
 
+    @skipIf(version_info < (3, 3), "Python >= 3.3 only")
+    def test_magicQualnameInClassScope(self):
+        """
+        Use of the C{__qualname__} magic builtin should not emit an undefined
+        name warning if used in class scope.
+        """
+        self.flakes('__qualname__', m.UndefinedName)
+        self.flakes('''
+        class Foo:
+            __qualname__
+        ''')
+        self.flakes('''
+        class Foo:
+            def bar(self):
+                __qualname__
+        ''', m.UndefinedName)
+
     def test_globalImportStar(self):
         """Can't find undefined names with import *."""
         self.flakes('from fu import *; bar',
Repository: PyCQA/pyflakes
Pull request #679 (2022-02-13 01:09:00)

support `TypeAlias` annotations
For assignments with `TypeAlias` as annotation, handle the value as an annotation also.

Avoids incorrectly detecting `Bar` as unused in `x: TypeAlias = 'Bar'`.

resolves https://github.com/PyCQA/pyflakes/issues/671


Patch:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 45f2a42..7f33d6a 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -128,7 +128,7 @@ def _is_const_non_singleton(node):  # type: (ast.AST) -> bool
     return _is_constant(node) and not _is_singleton(node)
 
 
-def _is_name_or_attr(node, name):  # type: (ast.Ast, str) -> bool
+def _is_name_or_attr(node, name):  # type: (ast.AST, str) -> bool
     return (
         (isinstance(node, ast.Name) and node.id == name) or
         (isinstance(node, ast.Attribute) and node.attr == name)
@@ -2381,9 +2381,13 @@ class Checker(object):
     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:
-            # If the assignment has value, handle the *value* now.
-            self.handleNode(node.value, node)
+            # If the annotation is `TypeAlias`, handle the *value* as an annotation.
+            if _is_typing(node.annotation, 'TypeAlias', self.scopeStack):
+                self.handleAnnotation(node.value, node)
+            else:
+                self.handleNode(node.value, 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 f3b6c24..3b6d5e7 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -300,6 +300,46 @@ class TestTypeAnnotations(TestCase):
         a: 'a: "A"'
         ''', m.ForwardAnnotationSyntaxError)
 
+    @skipIf(version_info < (3, 6), 'new in Python 3.6')
+    def test_TypeAlias_annotations(self):
+        self.flakes("""
+        from typing_extensions import TypeAlias
+        from foo import Bar
+
+        bar: TypeAlias = Bar
+        """)
+        self.flakes("""
+        from typing_extensions import TypeAlias
+        from foo import Bar
+
+        bar: TypeAlias = 'Bar'
+        """)
+        self.flakes("""
+        from typing_extensions import TypeAlias
+        from foo import Bar
+
+        class A:
+            bar: TypeAlias = Bar
+        """)
+        self.flakes("""
+        from typing_extensions import TypeAlias
+        from foo import Bar
+
+        class A:
+            bar: TypeAlias = 'Bar'
+        """)
+        self.flakes("""
+        from typing_extensions import TypeAlias
+
+        bar: TypeAlias
+        """)
+        self.flakes("""
+        from typing_extensions import TypeAlias
+        from foo import Bar
+
+        bar: TypeAlias
+        """, m.UnusedImport)
+
     @skipIf(version_info < (3, 6), 'new in Python 3.6')
     def test_annotating_an_import(self):
         self.flakes('''
Repository: PyCQA/pyflakes
Pull request #831 (2025-03-30 18:05:43)

Allow an assignment expression to redefine an annotation
This PR fixes the issue I reported, #830

It effectively reverts part of [this commit](https://github.com/PyCQA/pyflakes/commit/b1f8362e45aab6e5ba0b49b282b5be9c05467c50) so that annotations in scope are allowed to be re-assigned.


Patch:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index c7d3e88..9888d7a 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -1008,8 +1008,12 @@ class Checker:
                     for scope in reversed(self.scopeStack)
                     if not isinstance(scope, GeneratorScope)
                 )
-                # it may be a re-assignment to an already existing name
-                scope.setdefault(value.name, value)
+                if value.name in scope and isinstance(scope[value.name], Annotation):
+                    # re-assignment to name that was previously only an annotation
+                    scope[value.name] = value
+                else:
+                    # it may be a re-assignment to an already existing name
+                    scope.setdefault(value.name, value)
             else:
                 self.scope[value.name] = value
 


Test patch:
diff --git a/pyflakes/test/test_other.py b/pyflakes/test/test_other.py
index 68c38e9..2399082 100644
--- a/pyflakes/test/test_other.py
+++ b/pyflakes/test/test_other.py
@@ -1744,6 +1744,13 @@ class TestUnusedAssignment(TestCase):
         print(x)
         ''')
 
+    def test_assign_expr_after_annotation(self):
+        self.flakes("""
+        a: int
+        print(a := 3)
+        print(a)
+        """)
+
     def test_assign_expr_generator_scope(self):
         """Test assignment expressions in generator expressions."""
         self.flakes('''