nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: gruntwork-io/cloud-nuke
Pull request #589 (2023-09-20 02:11:45)

Delete unused files
<!-- Prepend '[WIP]' to the title if this PR is still a work-in-progress. Remove it when it is ready for review! -->

## Description

<!-- Description of the changes introduced by this PR. -->

## TODOs

Read the [Gruntwork contribution guidelines](https://gruntwork.notion.site/Gruntwork-Coding-Methodology-02fdcd6e4b004e818553684760bf691e).

- [ ] Update the docs.
- [ ] Run the relevant tests successfully, including pre-commit checks.
- [ ] Ensure any 3rd party code adheres with our [license policy](https://www.notion.so/gruntwork/Gruntwork-licenses-and-open-source-usage-policy-f7dece1f780341c7b69c1763f22b1378) or delete this line if its not applicable.
- [ ] Include release notes. If this PR is backward incompatible, include a migration guide.
- [ ] Attention Grunts - if this PR adds support for a new resource, ensure the `nuke_sandbox` and `nuke_phxdevops` jobs in `.circleci/config.yml` have been updated with appropriate exclusions (either directly in the job or via the `.circleci/nuke_config.yml` file) to prevent nuking IAM roles, groups, resources, etc that are important for the test accounts.


## Release Notes (draft)

<!-- One-line description of the PR that can be included in the final release notes. -->
Added / Removed / Updated [X].

### Migration Guide

<!-- Important: If you made any backward incompatible changes, then you must write a migration guide! -->




Patch:
diff --git a/util/has_aws_backup_tag.go b/util/has_aws_backup_tag.go
deleted file mode 100644
index 6a69276..0000000
--- a/util/has_aws_backup_tag.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package util
-
-import (
-	awsgo "github.com/aws/aws-sdk-go/aws"
-	"github.com/aws/aws-sdk-go/service/ec2"
-)
-
-// Check if the image has an AWS Backup tag
-// Resources created by AWS Backup are listed as owned by self, but are actually
-// AWS managed resources and cannot be deleted here.
-func HasAWSBackupTag(tags []*ec2.Tag) bool {
-	t := make(map[string]string)
-
-	for _, v := range tags {
-		t[awsgo.StringValue(v.Key)] = awsgo.StringValue(v.Value)
-	}
-
-	if _, ok := t["aws:backup:source-resource"]; ok {
-		return true
-	}
-	return false
-}


Test patch:
diff --git a/aws/resources/test_utils.go b/aws/resources/test_utils.go
deleted file mode 100644
index 2e6f097..0000000
--- a/aws/resources/test_utils.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package resources
-
-import (
-	"testing"
-
-	terratestaws "github.com/gruntwork-io/terratest/modules/aws"
-
-	"github.com/aws/aws-sdk-go/aws"
-	"github.com/aws/aws-sdk-go/aws/session"
-	"github.com/stretchr/testify/require"
-)
-
-func GetTestSession(t *testing.T, approvedRegions []string, forbiddenRegions []string) *session.Session {
-	region := terratestaws.GetRandomStableRegion(t, approvedRegions, forbiddenRegions)
-	session, err := session.NewSession(&aws.Config{Region: aws.String(region)})
-	require.NoError(t, err)
-
-	return session
-}
Repository: gitleaks/gitleaks
Pull request #1317 (2023-12-22 17:05:12)

rename filesystem to directory
### Description:
Lil renaming

### Checklist:

* [x] Does your PR pass tests?
* [ ] Have you written new tests for your changes?
* [x] Have you lint your code locally prior to submission?



Patch:
diff --git a/cmd/detect.go b/cmd/detect.go
index ef9c7af..f7f7825 100644
--- a/cmd/detect.go
+++ b/cmd/detect.go
@@ -63,7 +63,7 @@ func runDetect(cmd *cobra.Command, args []string) {
 
 	// start the detector scan
 	if noGit {
-		paths, err := sources.FilesystemTargets(source, detector.Sema, detector.FollowSymlinks)
+		paths, err := sources.DirectoryTargets(source, detector.Sema, detector.FollowSymlinks)
 		if err != nil {
 			log.Fatal().Err(err)
 		}
diff --git a/detect/filesystem.go b/detect/directory.go
similarity index 100%
rename from detect/filesystem.go
rename to detect/directory.go
diff --git a/sources/filesystem.go b/sources/directory.go
similarity index 91%
rename from sources/filesystem.go
rename to sources/directory.go
index 09a87e8..30fe349 100644
--- a/sources/filesystem.go
+++ b/sources/directory.go
@@ -14,7 +14,7 @@ type ScanTarget struct {
 	Symlink string
 }
 
-func FilesystemTargets(source string, s *semgroup.Group, followSymlinks bool) (<-chan ScanTarget, error) {
+func DirectoryTargets(source string, s *semgroup.Group, followSymlinks bool) (<-chan ScanTarget, error) {
 	paths := make(chan ScanTarget)
 	s.Go(func() error {
 		defer close(paths)


Test patch:
diff --git a/detect/detect_test.go b/detect/detect_test.go
index 9417aaf..201829f 100644
--- a/detect/detect_test.go
+++ b/detect/detect_test.go
@@ -630,7 +630,7 @@ func TestFromFiles(t *testing.T) {
 		err = detector.AddGitleaksIgnore(ignorePath)
 		require.NoError(t, err)
 		detector.FollowSymlinks = true
-		paths, err := sources.FilesystemTargets(tt.source, detector.Sema, true)
+		paths, err := sources.DirectoryTargets(tt.source, detector.Sema, true)
 		require.NoError(t, err)
 		findings, err := detector.DetectFiles(paths)
 		require.NoError(t, err)
@@ -681,7 +681,7 @@ func TestDetectWithSymlinks(t *testing.T) {
 		cfg, _ := vc.Translate()
 		detector := NewDetector(cfg)
 		detector.FollowSymlinks = true
-		paths, err := sources.FilesystemTargets(tt.source, detector.Sema, true)
+		paths, err := sources.DirectoryTargets(tt.source, detector.Sema, true)
 		require.NoError(t, err)
 		findings, err := detector.DetectFiles(paths)
 		require.NoError(t, err)
Repository: gitleaks/gitleaks
Pull request #1595 (2024-10-22 20:06:35)

Add jquery dist files to global ignorelist
### Description:
The intent of this is to gradually add more _known_ static assets to alleviate false positives.

Jquery-ui was the only one I could find an example of, on hand.

### Checklist:

* [x] Does your PR pass tests?
* [x] Have you written new tests for your changes?
* [ ] Have you lint your code locally prior to submission?



Patch:
diff --git a/cmd/generate/config/base/config.go b/cmd/generate/config/base/config.go
index 540a91b..767e92d 100644
--- a/cmd/generate/config/base/config.go
+++ b/cmd/generate/config/base/config.go
@@ -71,7 +71,7 @@ func CreateGlobalConfig() config.Config {
 				regexp.MustCompile(`(^|/)mvnw(\.cmd)?$`),
 				regexp.MustCompile(`(^|/)\.mvn/wrapper/MavenWrapperDownloader\.java$`),
 
-				// ----------- Node.js files -----------
+				// ----------- JavaScript files -----------
 				// Dependencies and lock files.
 				regexp.MustCompile(`(^|/)node_modules/.*?$`),
 				regexp.MustCompile(`(^|/)package-lock\.json$`),
@@ -79,6 +79,8 @@ func CreateGlobalConfig() config.Config {
 				regexp.MustCompile(`(^|/)pnpm-lock\.yaml$`),
 				regexp.MustCompile(`(^|/)npm-shrinkwrap\.json$`),
 				regexp.MustCompile(`(^|/)bower_components/.*?$`),
+				// TODO: Add more common static assets, such as swagger-ui.
+				regexp.MustCompile(`(^|/)jquery(-ui)?-[a-zA-Z0-9.-]+\.js$`),
 
 				// ----------- Python files -----------
 				// Dependencies and lock files.
diff --git a/config/gitleaks.toml b/config/gitleaks.toml
index 6af0968..13f3060 100644
--- a/config/gitleaks.toml
+++ b/config/gitleaks.toml
@@ -43,6 +43,7 @@ paths = [
     '''(^|/)pnpm-lock\.yaml$''',
     '''(^|/)npm-shrinkwrap\.json$''',
     '''(^|/)bower_components/.*?$''',
+    '''(^|/)jquery(-ui)?-[a-zA-Z0-9.-]+\.js$''',
     '''(^|/)Pipfile\.lock$''',
     '''(^|/)poetry\.lock$''',
     '''(?i)/?(v?env|virtualenv)/lib/.+$''',


Test patch:
diff --git a/cmd/generate/config/base/config_test.go b/cmd/generate/config/base/config_test.go
index 2f64171..e871525 100644
--- a/cmd/generate/config/base/config_test.go
+++ b/cmd/generate/config/base/config_test.go
@@ -83,3 +83,35 @@ func TestConfigAllowlistRegexes(t *testing.T) {
 		})
 	}
 }
+
+func TestConfigAllowlistPaths(t *testing.T) {
+	tests := map[string]struct {
+		invalid []string
+		valid   []string
+	}{
+		"javascript - jquery.js": {
+			invalid: []string{
+				`src/main/resources/static/jquery-ui-1.12.1/jquery-ui-min.js`,
+				`src/main/resources/static/js/jquery-ui-1.10.4.min.js`,
+			},
+		},
+	}
+
+	cfg := CreateGlobalConfig()
+	allowlist := cfg.Allowlist
+	for name, cases := range tests {
+		t.Run(name, func(t *testing.T) {
+			for _, c := range cases.invalid {
+				if !allowlist.PathAllowed(c) {
+					t.Errorf("invalid path not marked as allowed: %s", c)
+				}
+			}
+
+			for _, c := range cases.valid {
+				if allowlist.PathAllowed(c) {
+					t.Errorf("valid path marked as allowed: %s", c)
+				}
+			}
+		})
+	}
+}
Repository: zauberzeug/nicegui
Pull request #3130 (2024-05-27 19:28:17)

Allow commas in unquoted prop strings
As noticed in discussion #3128, adding props like
```py
.props('accept=.jpeg,.jpg,.png')
```
didn't work, because commas in a prop string required it to be wrapped in quotes:
```py
.props('accept=".jpeg,.jpg,.png"')
```

But since I don't see a reason why dots are recognized as a value character but commas aren't, I added it to the `PROPS_PATTERN`.


Patch:
diff --git a/nicegui/element.py b/nicegui/element.py
index c5556d8c..ffff5c9d 100644
--- a/nicegui/element.py
+++ b/nicegui/element.py
@@ -42,7 +42,7 @@ PROPS_PATTERN = re.compile(r'''
             '       # Match the closing quote
         )
         |           # Or
-        ([\w\-.%:\/]+)  # Capture group 4: Value without quotes
+        ([\w\-.,%:\/]+)  # Capture group 4: Value without quotes
     )
 )?                  # End of optional non-capturing group for value
 (?:$|\s)            # Match end of string or whitespace


Test patch:
diff --git a/tests/test_element.py b/tests/test_element.py
index b3515adb..a19f6a81 100644
--- a/tests/test_element.py
+++ b/tests/test_element.py
@@ -50,6 +50,7 @@ def test_props_parsing():
     assert ui.element._parse_props('href=http://192.168.42.100/') == {'href': 'http://192.168.42.100/'}
     assert ui.element._parse_props('hint="Your \\"given\\" name"') == {'hint': 'Your "given" name'}
     assert ui.element._parse_props('input-style="{ color: #ff0000 }"') == {'input-style': '{ color: #ff0000 }'}
+    assert ui.element._parse_props('accept=.jpeg,.jpg,.png') == {'accept': '.jpeg,.jpg,.png'}
 
     assert ui.element._parse_props('empty=""') == {'empty': ''}
     assert ui.element._parse_props("empty=''") == {'empty': ''}
Repository: zauberzeug/nicegui
Pull request #3281 (2024-06-24 23:29:52)

ui.number value discrepancy
This is the fix as described in #3142


frankvp11: Huh, I didn't see that coming... 
Because you've said that I've thought about the other possible cases where this can happen, and I believe that this would be the only one.
I think that doing something like this would fix it. Do you agree?
```python
def _value_to_event_value(value: Any) -> Any:
    if value == 0:
        return 0
    if value:
        return float(value)
    return None
```
This covers both cases where the value is 0 or 0.0. The other cases where the previous code could have failed is from some empty collection (list, dict, set, etc). I don't think we should worry about those though and can safely return None in those cases.
falkoschindler: Yeah, the devil is in the details...

I think we can simplify your solution:
- if value is 0: return `0` (equal to `float(value)`)
- if value is truthy (i.e. not `None`): return `float(value)`
- else: return `None` (which should be `value`)

So basically we are converting to a float whenever `value` is not None:
```py
return float(value) if value is not None else value
```

But now that I think of it, what's the purpose of this conversion anyway? `value` should be of type `float | None` already. Should we simply remove this override of `_value_to_event_value` and use its base implementation, which simply returns `value`? It seems like its sole purpose was to convert `None` to 0.
frankvp11: That's what it looks like. As for your implementation, it does indeed look simpler, I can change mine to that if you'd like?

Patch:
diff --git a/nicegui/elements/number.py b/nicegui/elements/number.py
index 9f024cfe..e4691d95 100644
--- a/nicegui/elements/number.py
+++ b/nicegui/elements/number.py
@@ -133,6 +133,3 @@ class Number(ValidationElement, DisableableElement):
         if value == '':
             return 0
         return self.format % float(value)
-
-    def _value_to_event_value(self, value: Any) -> Any:
-        return float(value) if value else 0


Test patch:
diff --git a/tests/test_number.py b/tests/test_number.py
index 68379d14..0711591b 100644
--- a/tests/test_number.py
+++ b/tests/test_number.py
@@ -126,3 +126,25 @@ def test_changing_limits(screen: Screen):
 
     screen.click('Step up')
     screen.should_contain_input('1')
+
+
+def test_none_values(screen: Screen):
+    n = ui.number('Number', on_change=lambda e: ui.label(f'event: {e.value}'))
+    ui.label().bind_text_from(n, 'value', lambda value: f'model: {value}')
+
+    screen.open('/')
+    element = screen.selenium.find_element(By.XPATH, '//*[@aria-label="Number"]')
+    element.send_keys('0')
+    screen.should_contain_input('0')
+    screen.should_contain('model: 0')
+    screen.should_contain('event: 0')
+
+    element.send_keys(Keys.BACKSPACE)
+    screen.should_contain_input('')
+    screen.should_contain('model: None')
+    screen.should_contain('event: None')
+
+    element.send_keys('1')
+    screen.should_contain_input('1')
+    screen.should_contain('model: 1')
+    screen.should_contain('event: 1')