nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: beatlabs/patron
Pull request #364 (2021-04-17 05:27:05)

Log source fix
<!--
Thanks for taking precious time for making a PR.

Before creating a pull request, please make sure:
- Your PR solves one problem for which a issue exist and a solution has been discussed
- You have read the guide for contributing
  - See https://github.com/beatlabs/patron/blob/master/README.md#how-to-contribute
- You signed all your commits (otherwise we won't be able to merge the PR)
  - See https://github.com/beatlabs/patron/blob/master/SIGNYOURWORK.md
- You added unit tests for the new functionality
- You mention in the PR description which issue it is addressing, e.g. "Resolves #123"
-->

## Which problem is this PR solving?

Running the logger in a service revealed that we log as source the logger and not hte calling method.

## Short description of the changes

Increase skip on the logger and adjusted the tests accordingly. The tests log a source that is much lower because we are using the zerologger directly and not via patron's logger.



Patch:
diff --git a/log/zerolog/logger.go b/log/zerolog/logger.go
index 8302c7ee4..b2bbf2526 100644
--- a/log/zerolog/logger.go
+++ b/log/zerolog/logger.go
@@ -38,8 +38,8 @@ type Logger struct {
 
 // New creates a new logger.
 func New(out io.Writer, lvl log.Level, f map[string]interface{}) log.Logger {
-	zl := zerolog.New(out).With().Timestamp().Logger().Hook(sourceHook{skip: 4})
-	zlf := zerolog.New(out).With().Timestamp().Logger().Hook(sourceHook{skip: 5})
+	zl := zerolog.New(out).With().Timestamp().Logger().Hook(sourceHook{skip: 6})
+	zlf := zerolog.New(out).With().Timestamp().Logger().Hook(sourceHook{skip: 7})
 
 	if len(f) == 0 {
 		f = make(map[string]interface{})


Test patch:
diff --git a/log/zerolog/logger_test.go b/log/zerolog/logger_test.go
index 53211d4b1..5e9c7634f 100644
--- a/log/zerolog/logger_test.go
+++ b/log/zerolog/logger_test.go
@@ -135,7 +135,13 @@ func assertLog(t *testing.T, b bytes.Buffer, lvl log.Level, msg string) {
 	assert.Contains(t, b.String(), `"key":"value"`, b.String())
 	assert.Contains(t, b.String(), fmt.Sprintf(`"msg":"%s"`, msg), b.String())
 	assert.Regexp(t, regexp.MustCompile(`"time":".*"`), b.String())
-	assert.Regexp(t, regexp.MustCompile(`"src":"zerolog/logger_test.go:.*"`), b.String())
+	// Although the sources do not make sense, if we change them they will report wrong locations in the service.
+	// Pls leave them as they are.
+	if lvl == log.PanicLevel {
+		assert.Regexp(t, regexp.MustCompile(`"src":"assert/assertions.go:.*"`), b.String())
+	} else {
+		assert.Regexp(t, regexp.MustCompile(`"src":"runtime/asm_amd64.s:.*"`), b.String())
+	}
 }
 
 func TestLog_Level(t *testing.T) {
Repository: bazelbuild/buildtools
Pull request #825 (2020-05-04 18:15:23)

Don't apply unnamed-macro to private functions
Private functions can't be imported at BUILD files and therefore can't be macros.

laurentlb: What happens if a public function calls a private function which calls a rule?
vladmos: The change just doesn't start the top-level check on a function if it's private, that doesn't affect analysis of a function if it's triggered by inspecting another function.

I've added a test about that.

Patch:
diff --git a/warn/warn_macro.go b/warn/warn_macro.go
index c4b97a9..8cc5f6d 100644
--- a/warn/warn_macro.go
+++ b/warn/warn_macro.go
@@ -4,6 +4,7 @@ package warn
 
 import (
 	"fmt"
+	"strings"
 
 	"github.com/bazelbuild/buildtools/build"
 )
@@ -293,7 +294,7 @@ func unnamedMacroWarning(f *build.File, fileReader *FileReader) []*LinterFinding
 			continue
 		}
 
-		if !ok || acceptsNameArgument(def) {
+		if strings.HasPrefix(def.Name, "_") || acceptsNameArgument(def) {
 			continue
 		}
 


Test patch:
diff --git a/warn/warn_macro_test.go b/warn/warn_macro_test.go
index ca944e9..1fedb67 100644
--- a/warn/warn_macro_test.go
+++ b/warn/warn_macro_test.go
@@ -357,3 +357,21 @@ def macro2(name):
 It is considered a macro because it calls a rule or another macro "baz" on line 6.`,
 	}, scopeBzl)
 }
+
+func TestUnnamedMacroPrivate(t *testing.T) {
+	checkFindings(t, "unnamed-macro", `
+my_rule = rule()
+
+def _not_macro(x):
+  my_rule(name = x)
+
+def macro(x):
+  _not_macro(x)
+`,
+		[]string{
+			`6: Macro function "macro" doesn't accept a keyword argument "name".
+
+It is considered a macro because it calls a rule or another macro "_not_macro" on line 7.`,
+		},
+		scopeBzl)
+}
Repository: bazelbuild/buildtools
Pull request #862 (2020-06-10 16:39:20)

Don't recognize native.package_name() as a rule


Patch:
diff --git a/warn/warn_macro.go b/warn/warn_macro.go
index 3dbc67b..d191113 100644
--- a/warn/warn_macro.go
+++ b/warn/warn_macro.go
@@ -218,7 +218,8 @@ func (ma macroAnalyzer) IsMacro(fn function) (report functionReport) {
 	// Check for native rules
 	if fn.filename == nativeModule {
 		switch fn.name {
-		case "glob", "existing_rule", "existing_rules":
+		case "glob", "existing_rule", "existing_rules", "package_name",
+			"repository_name", "exports_files":
 			// Not a rule
 		default:
 			report.isMacro = true


Test patch:
diff --git a/warn/warn_macro_test.go b/warn/warn_macro_test.go
index 4a0635f..510fc1a 100644
--- a/warn/warn_macro_test.go
+++ b/warn/warn_macro_test.go
@@ -17,6 +17,9 @@ def not_macro(x):
   native.glob()
   native.existing_rule()
   native.existing_rules()
+  native.package_name()
+  native.repository_name()
+  native.exports_files()
   return my_rule
 
 def another_macro(x):
@@ -27,9 +30,9 @@ def another_macro(x):
 			`5: By convention "macro" should have a keyword argument called "name".
 
 It is considered a macro because it calls a rule or another macro "my_rule" on line 7.`,
-			`16: By convention "another_macro" should have a keyword argument called "name".
+			`19: By convention "another_macro" should have a keyword argument called "name".
 
-It is considered a macro because it calls a rule or another macro "native.cc_library" on line 18.`,
+It is considered a macro because it calls a rule or another macro "native.cc_library" on line 21.`,
 		},
 		scopeBzl)
Repository: bazelbuild/buildtools
Pull request #863 (2020-06-10 17:43:31)

Don't warn about using "skylark" inside URLs
The `skylark-docstring` and `skylark-comment` check may yield some false positive warnings if the word "skylark" is a part of a link for the official Starlark documentation, such as `https://docs.bazel.build/versions/master/skylark/lib/Label.html`.

The fix suppresses the warning if the word "skylark" is prepended to or followed by a slash, this will cover this URL and potentially some other URLs too.


Patch:
diff --git a/warn/warn_cosmetic.go b/warn/warn_cosmetic.go
index 9bea572..c6ca194 100644
--- a/warn/warn_cosmetic.go
+++ b/warn/warn_cosmetic.go
@@ -380,9 +380,24 @@ func skylarkToStarlark(s string) string {
 	}
 }
 
+// replaceSkylark replaces a substring "skylark" (case-insensitive) with a
+// similar cased string "starlark". Doesn't replace it if the previous or the
+// next symbol is '/', which may indicate it's a part of a URL.
+// Normally that should be done with look-ahead and look-behind assertions in a
+// regular expression, but negative look-aheads and look-behinds are not
+// supported by Go regexp module.
 func replaceSkylark(s string) (newString string, changed bool) {
 	skylarkRegex := regexp.MustCompile("(?i)skylark")
-	newString = skylarkRegex.ReplaceAllStringFunc(s, skylarkToStarlark)
+	newString = s
+	for _, r := range skylarkRegex.FindAllStringIndex(s, -1) {
+		if r[0] > 0 && s[r[0]-1] == '/' {
+			continue
+		}
+		if r[1] < len(s)-1 && s[r[1]+1] == '/' {
+			continue
+		}
+		newString = newString[:r[0]] + skylarkToStarlark(newString[r[0]:r[1]]) + newString[r[1]:]
+	}
 	return newString, newString != s
 }
 


Test patch:
diff --git a/warn/warn_cosmetic_test.go b/warn/warn_cosmetic_test.go
index 57cadc4..0557f3e 100644
--- a/warn/warn_cosmetic_test.go
+++ b/warn/warn_cosmetic_test.go
@@ -465,6 +465,9 @@ foo()
 # Implemented in skylark
 # Skylark
 bar() # SKYLARK
+
+# see https://docs.bazel.build/versions/master/skylark/lib/Label.html
+Label()
 `, `
 # Skyline
 foo()
@@ -473,6 +476,9 @@ foo()
 # Implemented in starlark
 # Starlark
 bar() # STARLARK
+
+# see https://docs.bazel.build/versions/master/skylark/lib/Label.html
+Label()
 `,
 		[]string{
 			`:3: "Skylark" is an outdated name of the language, please use "starlark" instead.`,
@@ -486,15 +492,34 @@ bar() # STARLARK
 """
 This is a docstring describing a skylark file
 """
+
+def f():
+  """SKYLARK"""
+
+def l():
+  """
+  Returns https://docs.bazel.build/versions/master/skylark/lib/Label.html
+  """
+  return Label("skylark")
 `, `
 # Some file
 
 """
 This is a docstring describing a starlark file
-"""
+""" 
+
+def f():
+  """STARLARK"""
+
+def l():
+  """
+  Returns https://docs.bazel.build/versions/master/skylark/lib/Label.html
+  """
+  return Label("skylark")
 `,
 		[]string{
 			`:3: "Skylark" is an outdated name of the language, please use "starlark" instead.`,
+			`:8: "Skylark" is an outdated name of the language, please use "starlark" instead.`,
 		},
 		scopeEverywhere)
 }
Repository: bazelbuild/buildtools
Pull request #970 (2021-04-08 02:28:19)

bzl-visibility: allow files in javatest directory import private files from parallel java directory


Patch:
diff --git a/warn/warn_visibility.go b/warn/warn_visibility.go
index 7e27561..8570278 100644
--- a/warn/warn_visibility.go
+++ b/warn/warn_visibility.go
@@ -64,7 +64,8 @@ func bzlVisibilityWarning(f *build.File) []*LinterFinding {
 			continue
 		}
 
-		if strings.HasPrefix(path, chunks[0]) {
+		if strings.HasPrefix(path, chunks[0]) ||
+			strings.HasPrefix(strings.Replace(path, "/javatest/", "/java/", 1), chunks[0]) {
 			continue
 		}
 


Test patch:
diff --git a/warn/warn_test.go b/warn/warn_test.go
index 6f9ae8e..ae08fce 100644
--- a/warn/warn_test.go
+++ b/warn/warn_test.go
@@ -39,6 +39,10 @@ const (
 // reset it when it finishes.
 var testFileReader *FileReader
 
+// A global variable containing package name for test cases. Can be overwritten
+// but must be reset when the test finishes.
+var testPackage string = "test/package"
+
 // fileReaderRequests is used by tests to check which files have actually been requested by testFileReader
 var fileReaderRequests []string
 
@@ -60,6 +64,16 @@ func setUpFileReader(data map[string]string) (cleanup func()) {
 	}
 }
 
+func setUpTestPackage(name string) (cleanup func()) {
+	oldName := testPackage
+	testPackage = name
+
+	return func() {
+		// Tear down
+		testPackage = oldName
+	}
+}
+
 func getFilename(fileType build.FileType) string {
 	switch fileType {
 	case build.TypeBuild:
@@ -76,11 +90,11 @@ func getFilename(fileType build.FileType) string {
 func getFileForTest(input string, fileType build.FileType) *build.File {
 	input = strings.TrimLeft(input, "\n")
 	filename := getFilename(fileType)
-	file, err := build.Parse("test/package/"+filename, []byte(input))
+	file, err := build.Parse(testPackage+"/"+filename, []byte(input))
 	if err != nil {
 		panic(fmt.Sprintf("%v", err))
 	}
-	file.Pkg = "test/package"
+	file.Pkg = testPackage
 	file.Label = filename
 	file.WorkspaceRoot = "/home/users/foo/bar"
 	return file
diff --git a/warn/warn_visibility_test.go b/warn/warn_visibility_test.go
index c8da1c8..14bdaef 100644
--- a/warn/warn_visibility_test.go
+++ b/warn/warn_visibility_test.go
@@ -90,3 +90,21 @@ load("@repo//test/external:module.bzl", "baz")
 		[]string{},
 		scopeEverywhere)
 }
+
+func TestBzlVisibilityJavatest(t *testing.T) {
+	defer setUpTestPackage("foo/javatest/bar")()
+
+	checkFindings(t, "bzl-visibility", `
+load("//foo/java/bar/internal/baz:module.bzl", "foo")
+load("//foo/java/bar/private/baz:module.bzl", "bar")
+load("//foo/javatest/bar/internal/baz:module.bzl", "foo1")
+load("//foo/javatest/bar/private/baz:module.bzl", "bar1")
+
+foo()
+bar()
+foo1()
+bar1()
+`,
+		[]string{},
+		scopeEverywhere)
+}
Repository: bazelbuild/buildtools
Pull request #1056 (2022-03-21 01:19:02)

Allow brackets to describe function arguments in docstrings
Allow the usage of brackets (both square and angled) inside the parentheses used to describe function arguments in docstrings. This allows concise descriptions like

```py
def foo(ctx, files):
    """
    Args:
        ctx (Context): the Starlark context
        files (List<File>): a list of files used to do (...)
        mapping (Map[string, int]): a mapping for the (...)
    """
    pass
```

I opened https://github.com/bazelbuild/buildtools/issues/916 but no one responded there so I'm just going to open this PR to address that issue and hope I have better luck here

Fixes: https://github.com/bazelbuild/buildtools/issues/916

binoche9: Done! Can you just double check that I did it right before I merge?
vladmos: It looks correct

Patch:
diff --git a/warn/warn_docstring.go b/warn/warn_docstring.go
index d767cb2..71b3256 100644
--- a/warn/warn_docstring.go
+++ b/warn/warn_docstring.go
@@ -103,7 +103,7 @@ func countLeadingSpaces(s string) int {
 	return spaces
 }
 
-var argRegex = regexp.MustCompile(`^ *(\*?\*?\w*)( *\([\w\ ,]+\))?:`)
+var argRegex = regexp.MustCompile(`^ *(\*?\*?\w*)( *\([\w\ ,<>\[\]]+\))?:`)
 
 // parseFunctionDocstring parses a function docstring and returns a docstringInfo object containing
 // the parsed information about the function, its arguments and its return value.


Test patch:
diff --git a/warn/warn_docstring_test.go b/warn/warn_docstring_test.go
index bd6ad70..930eac2 100644
--- a/warn/warn_docstring_test.go
+++ b/warn/warn_docstring_test.go
@@ -394,10 +394,10 @@ def f(x, y, z = None, *args, **kwargs):
    """This is a function.
 
    Args:
-    x: x
+    x (Map[string, int]): x
     y (deprecated, mutable): y
     z: z
-    *args: the args
+    *args (List<string>): the args
     **kwargs: the kwargs
    """
    pass
Repository: bazelbuild/buildtools
Pull request #1058 (2022-03-23 13:26:38)

Fix false positive findings for uninitialized function arguments
In some cases function arguments were reported as not initialized.


Patch:
diff --git a/warn/warn_control_flow.go b/warn/warn_control_flow.go
index 0e62f0a..a594c03 100644
--- a/warn/warn_control_flow.go
+++ b/warn/warn_control_flow.go
@@ -715,6 +715,14 @@ func findUninitializedVariables(stmts []build.Expr, previouslyInitialized map[st
 		build.WalkInterruptable(expr, func(expr build.Expr, stack []build.Expr) (err error) {
 			switch expr := expr.(type) {
 			case *build.DefStmt:
+				// Function arguments can't be uninitialized, even if they share the same
+				// name with a variable that's not initialized for some execution path
+				// in an outer scope.
+				for _, param := range expr.Params {
+					if ident, _ := build.GetParamIdent(param); ident != nil {
+						lValues[ident] = true
+					}
+				}
 				// Don't traverse into nested def statements
 				return &build.StopTraversalError{}
 			case *build.AssignExpr:
@@ -862,7 +870,7 @@ func uninitializedVariableWarning(f *build.File) []*LinterFinding {
 			// Check that the found ident represents a local variable
 			if localVars[ident.Name] {
 				findings = append(findings,
-					makeLinterFinding(ident, fmt.Sprintf(`Variable "%s" may not have been initialized. %s`, ident.Name, def.Name)))
+					makeLinterFinding(ident, fmt.Sprintf(`Variable "%s" may not have been initialized.`, ident.Name)))
 			}
 		})
 		return


Test patch:
diff --git a/warn/warn_control_flow_test.go b/warn/warn_control_flow_test.go
index 09aa17e..e72ea84 100644
--- a/warn/warn_control_flow_test.go
+++ b/warn/warn_control_flow_test.go
@@ -1174,4 +1174,18 @@ def foo(x: int, y: int = 2):
 			":11: Variable \"w\" may not have been initialized.",
 		},
 		scopeEverywhere)
+
+	checkFindings(t, "uninitialized", `
+def foo():
+  x = 1
+  for y, z in t:
+      print(y, z)
+
+  def bar(x, y, s = z):
+    pass
+`,
+		[]string{
+			":6: Variable \"z\" may not have been initialized.",
+		},
+		scopeEverywhere)
 }
Repository: bazelbuild/buildtools
Pull request #1079 (2022-08-05 09:55:51)

Improve type inference for int/float/str/bool(...) expressions
This makes the integer division check more accurate when these expressions are involved.


Patch:
diff --git a/warn/types.go b/warn/types.go
index a78b92a..2b7e9cd 100644
--- a/warn/types.go
+++ b/warn/types.go
@@ -55,6 +55,7 @@ func (t Type) String() string {
 		"none",
 		"string",
 		"list",
+		"float",
 	}[t]
 }
 
@@ -98,6 +99,14 @@ func detectTypes(f *build.File) map[build.Expr]Type {
 		case *build.CallExpr:
 			if ident, ok := (node.X).(*build.Ident); ok {
 				switch ident.Name {
+				case "bool":
+					nodeType = Bool
+				case "int":
+					nodeType = Int
+				case "float":
+					nodeType = Float
+				case "str":
+					nodeType = String
 				case "depset":
 					nodeType = Depset
 				case "dict":


Test patch:
diff --git a/warn/types_test.go b/warn/types_test.go
index b1bb8a5..c7233fd 100644
--- a/warn/types_test.go
+++ b/warn/types_test.go
@@ -61,8 +61,15 @@ func checkTypes(t *testing.T, input, output string) {
 
 func TestTypes(t *testing.T) {
 	checkTypes(t, `
+b = True
+b2 = bool("hello")
+i = 3
+i2 = int(1.2)
+f = 1.2
+f2 = float(3)
 s = "string"
 s2 = s
+s3 = str(42)
 d = {}
 d2 = {foo: bar}
 d3 = dict(**foo)
@@ -70,8 +77,15 @@ d4 = {k: v for k, v in foo}
 dep = depset(items=[s, d])
 foo = bar
 `, `
+b = bool:<True>
+b2 = bool:<bool(string:<"hello">)>
+i = int:<3>
+i2 = int:<int(float:<1.2>)>
+f = float:<1.2>
+f2 = float:<float(int:<3>)>
 s = string:<"string">
 s2 = string:

+s3 = string:<str(int:<42>)>
 d = dict:<{}>
 d2 = dict:<{foo: bar}>
 d3 = dict:<dict(**foo)>
diff --git a/warn/warn_operation_test.go b/warn/warn_operation_test.go
index fecd807..57ea58f 100644
--- a/warn/warn_operation_test.go
+++ b/warn/warn_operation_test.go
@@ -21,9 +21,9 @@ import "testing"
 func TestIntegerDivision(t *testing.T) {
 	checkFindingsAndFix(t, "integer-division", `
 a = 1
-b = 2
+b = int(2.3)
 c = 1.0
-d = 2.0
+d = float(2)
 
 e = a / b
 f = a / c
@@ -36,9 +36,9 @@ c /= a
 c /= d
 `, `
 a = 1
-b = 2
+b = int(2.3)
 c = 1.0
-d = 2.0
+d = float(2)
 
 e = a // b
 f = a / c
Repository: bazelbuild/buildtools
Pull request #1120 (2023-01-04 18:35:55)

Don't warn about unused 'name' arguments
https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#unnamed-macro explicitly encourages all macros to have `name` arguments even if they're not used. `unused-variable` shouldn't warn about such parameters.


Patch:
diff --git a/warn/warn_control_flow.go b/warn/warn_control_flow.go
index 5ff0d09..7e788d6 100644
--- a/warn/warn_control_flow.go
+++ b/warn/warn_control_flow.go
@@ -430,9 +430,12 @@ func unusedVariableCheck(f *build.File, root build.Expr) (map[string]bool, []*Li
 				// Function parameters are defined in the current scope.
 				if ident, _ := build.GetParamIdent(param); ident != nil {
 					definedSymbols[ident.Name] = ident
-					if strings.HasPrefix(ident.Name, "_") || edit.ContainsComments(param, "@unused") {
+					if ident.Name == "name" || strings.HasPrefix(ident.Name, "_") || edit.ContainsComments(param, "@unused") {
 						// Don't warn about function arguments if they start with "_"
-						// or explicitly marked with @unused
+						// or explicitly marked with @unused.
+						// Also don't warn about unused "name" arguments, it could be a
+						// macro where such argument is encouraged (by `unnamed-macro`)
+						// even if not used.
 						suppressedWarnings[ident.Name] = true
 					}
 				}


Test patch:
diff --git a/warn/warn_control_flow_test.go b/warn/warn_control_flow_test.go
index a30a1b6..2ef8f90 100644
--- a/warn/warn_control_flow_test.go
+++ b/warn/warn_control_flow_test.go
@@ -638,6 +638,28 @@ foo()
 			":2: Variable \"x\" is unused.",
 		},
 		scopeEverywhere)
+
+	checkFindings(t, "unused-variable", `
+def foo(
+    name,
+    x):
+  pass
+
+
+def bar(
+    name = "",
+    y = 3):
+  pass
+
+
+foo()
+bar()
+`,
+		[]string{
+			":3: Variable \"x\" is unused.",
+			":9: Variable \"y\" is unused.",
+		},
+		scopeEverywhere)
 }
 
 func TestRedefinedVariable(t *testing.T) {
Repository: bazelbuild/buildtools
Pull request #1159 (2023-04-24 17:26:33)

Fix false positive for uninitialized variables
If a variable is not initialized in some execution paths of a function but is a parameter to an inner function, it shouldn't be warned there as uninitialized.


Patch:
diff --git a/warn/warn_control_flow.go b/warn/warn_control_flow.go
index 7566515..19206a2 100644
--- a/warn/warn_control_flow.go
+++ b/warn/warn_control_flow.go
@@ -712,7 +712,7 @@ func collectLocalVariables(stmts []build.Expr) []*build.Ident {
 	return variables
 }
 
-// searchUninitializedVariables takes a list of statements (e.g. body of a block statement)
+// findUninitializedVariables takes a list of statements (e.g. body of a block statement)
 // and a map of previously initialized statements, and calls `callback` on all idents that are not
 // initialized. An ident is considered initialized if it's initialized by every possible execution
 // path (before or by `stmts`).
@@ -761,8 +761,20 @@ func findUninitializedVariables(stmts []build.Expr, previouslyInitialized map[st
 			}
 		}
 
+		walkBlockList := map[build.Expr]bool{}
 		build.WalkInterruptable(expr, func(expr build.Expr, stack []build.Expr) (err error) {
+			if walkBlockList[expr] {
+				return &build.StopTraversalError{}
+			}
 			switch expr := expr.(type) {
+			case *build.DefStmt:
+				// The header of the DefStmt may contain uninitialized variables (e.g.
+				// default values of parameters) and should be traversed.
+				// Its body shouldn't be traversed because it has another scope and will
+				// be analyzed by another call of `findUninitializedVariables`.
+				for _, stmt := range expr.Body {
+					walkBlockList[stmt] = true
+				}
 			case *build.Comprehension, *build.LambdaExpr:
 				// Comprehension and Lambda nodes are special, they have their own scope
 				// with variables that are only defined inside.


Test patch:
diff --git a/warn/warn_control_flow_test.go b/warn/warn_control_flow_test.go
index 49e6baa..dc7da12 100644
--- a/warn/warn_control_flow_test.go
+++ b/warn/warn_control_flow_test.go
@@ -1270,6 +1270,17 @@ def foo():
 
   y = [baz.get(bar) for bar in bars]
   x = lambda bar: baz.get(bar)
+`,
+		[]string{},
+		scopeEverywhere)
+
+	checkFindings(t, "uninitialized", `
+def foo():
+  def bar(x):
+    print(x)
+
+  for x, y in z:
+    bar(x)
 `,
 		[]string{},
 		scopeEverywhere)