nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: slackapi/python-slack-sdk
Pull request #1433 (2023-11-23 01:09:11)

Add RichTextBlock to Block.parse() targets
## Summary

This pull request adds a missing change in https://github.com/slackapi/python-slack-sdk/pull/1431

(reported at https://github.com/slackapi/python-slack-sdk/pull/1431#discussion_r1402730142)

### Category (place an `x` in each of the `[ ]`)

- [ ] **slack_sdk.web.WebClient (sync/async)** (Web API client)
- [ ] **slack_sdk.webhook.WebhookClient (sync/async)** (Incoming Webhook, response_url sender)
- [ ] **slack_sdk.socket_mode** (Socket Mode client)
- [ ] **slack_sdk.signature** (Request Signature Verifier)
- [ ] **slack_sdk.oauth** (OAuth Flow Utilities)
- [x] **slack_sdk.models** (UI component builders)
- [ ] **slack_sdk.scim** (SCIM API client)
- [ ] **slack_sdk.audit_logs** (Audit Logs API client)
- [ ] **slack_sdk.rtm_v2** (RTM client)
- [ ] `/docs-src` (Documents, have you run `./scripts/docs.sh`?)
- [ ] `/docs-src-v2` (Documents, have you run `./scripts/docs-v2.sh`?)
- [ ] `/tutorial` (PythOnBoardingBot tutorial)
- [ ] `tests`/`integration_tests` (Automated tests for this library)

## Requirements (place an `x` in each `[ ]`)

- [x] I've read and understood the [Contributing Guidelines](https://github.com/slackapi/python-slack-sdk/blob/main/.github/contributing.md) and have done my best effort to follow them.
- [x] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct).
- [x] I've run `python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh` after making the changes.


tj-smith47: You are a saint @seratch 🙏🏼 I appreciate all your efforts!

Patch:
diff --git a/slack_sdk/models/blocks/blocks.py b/slack_sdk/models/blocks/blocks.py
index 5bd0171..5d67213 100644
--- a/slack_sdk/models/blocks/blocks.py
+++ b/slack_sdk/models/blocks/blocks.py
@@ -89,6 +89,8 @@ class Block(JsonObject):
                     return HeaderBlock(**block)
                 elif type == VideoBlock.type:
                     return VideoBlock(**block)
+                elif type == RichTextBlock.type:
+                    return RichTextBlock(**block)
                 else:
                     cls.logger.warning(f"Unknown block detected and skipped ({block})")
                     return None


Test patch:
diff --git a/tests/slack_sdk/models/test_blocks.py b/tests/slack_sdk/models/test_blocks.py
index 4ea1158..836f65b 100644
--- a/tests/slack_sdk/models/test_blocks.py
+++ b/tests/slack_sdk/models/test_blocks.py
@@ -973,6 +973,7 @@ class RichTextBlockTests(unittest.TestCase):
             ],
         }
         self.assertDictEqual(dict_block, RichTextBlock(**dict_block).to_dict())
+        self.assertDictEqual(dict_block, Block.parse(dict_block).to_dict())
 
         _ = RichTextElementParts
         class_block = RichTextBlock(
Repository: slackapi/python-slackclient
Pull request #677 (2020-05-10 01:53:18)

Fix rendering of DateLink objects
###  Summary

Per the date formatting documentation[1], any date links should be
prefixed with "<!date^" before the epoch and other information.
Currently this is not included in the rendering of a DateLink text
representation, which breaks rendering of dates within Slack.

Fixes: #676

[1]: https://api.slack.com/reference/surfaces/formatting#date-formatting

### Requirements (place an `x` in each `[ ]`)

* [x] I've read and understood the [Contributing Guidelines](https://github.com/slackapi/python-slackclient/blob/master/.github/contributing.md) and have done my best effort to follow them.
* [x] I've read and agree to the [Code of Conduct](https://slackhq.github.io/code-of-conduct).


Patch:
diff --git a/slack/web/classes/objects.py b/slack/web/classes/objects.py
index 0dd871d..ce5082d 100644
--- a/slack/web/classes/objects.py
+++ b/slack/web/classes/objects.py
@@ -65,7 +65,7 @@ class DateLink(Link):
             link = f"^{link}"
         else:
             link = ""
-        super().__init__(url=f"{epoch}^{date_format}{link}", text=fallback)
+        super().__init__(url=f"!date^{epoch}^{date_format}{link}", text=fallback)
 
 
 class ObjectLink(Link):


Test patch:
diff --git a/tests/web/classes/test_objects.py b/tests/web/classes/test_objects.py
index f928ac6..2a14be5 100644
--- a/tests/web/classes/test_objects.py
+++ b/tests/web/classes/test_objects.py
@@ -100,7 +100,9 @@ class DateLinkTests(unittest.TestCase):
         datelink = DateLink(
             date=self.epoch, date_format="{date_long}", fallback=f"{self.epoch}"
         )
-        self.assertEqual(f"{datelink}", f"<{self.epoch}^{{date_long}}|{self.epoch}>")
+        self.assertEqual(
+            f"{datelink}", f"<!date^{self.epoch}^{{date_long}}|{self.epoch}>"
+        )
 
     def test_with_url(self):
         datelink = DateLink(
@@ -111,7 +113,7 @@ class DateLinkTests(unittest.TestCase):
         )
         self.assertEqual(
             f"{datelink}",
-            f"<{self.epoch}^{{date_long}}^http://google.com|{self.epoch}>",
+            f"<!date^{self.epoch}^{{date_long}}^http://google.com|{self.epoch}>",
         )
 
 
@@ -386,6 +388,7 @@ class OptionGroupTests(unittest.TestCase):
 
     def test_options_length(self):
         with self.assertRaises(SlackObjectFormationError):
-            OptionGroup(
-                label="option_group", options=self.common_options * 34
-            ).to_dict("text")
+            OptionGroup(label="option_group", options=self.common_options * 34).to_dict(
+                "text"
+            )
+
Repository: slackapi/python-slackclient
Pull request #745 (2020-07-10 18:08:49)

DatePickerElement - initial date. Fixed regex error, so it can accept 10 and 20 for day value now.
Fix for the issue:
https://github.com/slackapi/python-slackclient/issues/744


Patch:
diff --git a/slack/web/classes/elements.py b/slack/web/classes/elements.py
index ba166ad..8f094da 100644
--- a/slack/web/classes/elements.py
+++ b/slack/web/classes/elements.py
@@ -369,7 +369,7 @@ class DatePickerElement(InputInteractiveElement):
     @JsonValidator("initial_date attribute must be in format 'YYYY-MM-DD'")
     def _validate_initial_date_valid(self):
         return self.initial_date is None or re.match(
-            r"\d{4}-(0[1-9]|1[0-2])-([0-2][1-9]|3[01])", self.initial_date
+            r"\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])", self.initial_date
         )
 
 


Test patch:
diff --git a/tests/web/classes/test_elements.py b/tests/web/classes/test_elements.py
index b2a260d..012191d 100644
--- a/tests/web/classes/test_elements.py
+++ b/tests/web/classes/test_elements.py
@@ -196,8 +196,8 @@ class DatePickerElementTests(unittest.TestCase):
         self.assertDictEqual(input, DatePickerElement(**input).to_dict())
 
     def test_json(self):
-        for month in range(1 - 12):
-            for day in range(1 - 31):
+        for month in range(1, 12):
+            for day in range(1, 31):
                 date = f"2020-{month:02}-{day:02}"
                 self.assertDictEqual(
                     {
Repository: sloria/environs
Pull request #364 (2024-11-08 18:58:41)

Support for returning the file directory of loaded env file - Implements #362


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9577c43..bc9d55e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,15 @@
 # Changelog
 
+## 11.1.0 (unreleased)
+
+Features:
+
+- Add `return_path` argument to `Env.read_env` to return the path of the
+  parsed file ([#362](https://github.com/sloria/environs/issues/362)).
+  Thanks [senese](https://github.com/senese) for the suggestion and PR.
+  NOTE: This is added as a backwards-compatible change that is scheduled to be
+  removed in 12.0.0. The path will stored as an attribute of `Env`.
+
 ## 11.0.0 (2024-03-04)
 
 Fixes:
diff --git a/src/environs/__init__.py b/src/environs/__init__.py
index b4aeb2e..3fd370b 100644
--- a/src/environs/__init__.py
+++ b/src/environs/__init__.py
@@ -417,7 +417,8 @@ class Env:
         recurse: _BoolType = True,
         verbose: _BoolType = False,
         override: _BoolType = False,
-    ) -> _BoolType:
+        return_path: _BoolType = False,
+    ) -> typing.Union[_BoolType, _StrType]:
         """Read a .env file into os.environ.
 
         If .env is not found in the directory from which this method is called,
@@ -425,6 +426,8 @@ class Env:
         file is found. If you do not wish to recurse up the tree, you may pass
         False as a second positional argument.
         """
+
+        is_env_loaded = False
         if path is None:
             # By default, start search from the same directory this function is called
             current_frame = inspect.currentframe()
@@ -445,10 +448,18 @@ class Env:
             for dirname in _walk_to_root(start_dir):
                 check_path = Path(dirname) / env_name
                 if check_path.exists():
-                    return load_dotenv(check_path, verbose=verbose, override=override)
-            return False
+                    is_env_loaded = load_dotenv(
+                        check_path, verbose=verbose, override=override
+                    )
+                    env_path = str(check_path)
+        else:
+            is_env_loaded = load_dotenv(str(start), verbose=verbose, override=override)
+            env_path = str(start)
+
+        if return_path:
+            return env_path
         else:
-            return load_dotenv(str(start), verbose=verbose, override=override)
+            return is_env_loaded
 
     @contextlib.contextmanager
     def prefixed(self, prefix: _StrType) -> typing.Iterator["Env"]:


Test patch:
diff --git a/tests/test_environs.py b/tests/test_environs.py
index fb7cb77..8885062 100644
--- a/tests/test_environs.py
+++ b/tests/test_environs.py
@@ -362,6 +362,11 @@ class TestEnvFileReading:
         with pytest.raises(ValueError, match="path must be a filename"):
             assert env.read_env("tests")
 
+    def test_read_env_return_path(self, env):
+        path = env.read_env(return_path=True)
+        env_path = str(HERE / ".env")
+        assert path == env_path
+
 
 def always_fail(value):
     raise environs.EnvError("something went wrong")
Repository: warpnet/salt-lint
Pull request #286 (2022-09-12 16:41:26)

[FEATURE] Add regex for alternate typo of onchanges
Add to the existing rule to catch `onchanges` typos:

```
on_change:
on_change_any:
on_change_in:
on_changes:
on_changes_any:
on_changes_in:
```

M3GH4NN: @jbouter @sblaisot @roaldnefs could one of you you take a look at this PR? or could you point me in the direction of someone who could help? Thanks in advance.

Patch:
diff --git a/saltlint/rules/TypoOnchangesRule.py b/saltlint/rules/TypoOnchangesRule.py
index 7574fb6..3e2f869 100644
--- a/saltlint/rules/TypoOnchangesRule.py
+++ b/saltlint/rules/TypoOnchangesRule.py
@@ -13,4 +13,4 @@ class TypoOnchangesRule(TypographicalErrorRule):
     shortdesc = '"onchange" looks like a typo. Did you mean "onchanges"?'
     description = '"onchange" looks like a typo. Did you mean "onchanges"?'
     version_added = 'v0.6.0'
-    regex = re.compile(r"^\s+- onchange(|_in|_any):")
+    regex = re.compile(r"^\s+- (on_?change(|_in|_any)|on_changes(|_in|_any)):")


Test patch:
diff --git a/tests/unit/TestTypoOnchangesRule.py b/tests/unit/TestTypoOnchangesRule.py
index 39924f1..f147a5c 100644
--- a/tests/unit/TestTypoOnchangesRule.py
+++ b/tests/unit/TestTypoOnchangesRule.py
@@ -41,6 +41,20 @@ testfile:
     - onchange_any:
         - yetanotherfile
         - onemorefile
+    - on_change:
+        - otherfile
+    - on_change_in:
+        - anotherfile
+    - on_change_any:
+        - yetanotherfile
+        - onemorefile
+    - on_changes:
+        - otherfile
+    - on_changes_in:
+        - anotherfile
+    - on_changes_any:
+        - yetanotherfile
+        - onemorefile
 '''
 
 class TestTypoOnchangesRule(unittest.TestCase):
@@ -56,4 +70,4 @@ class TestTypoOnchangesRule(unittest.TestCase):
 
     def test_statement_negative(self):
         results = self.runner.run_state(BAD_ONCHANGES_LINE)
-        self.assertEqual(3, len(results))
+        self.assertEqual(9, len(results))
Repository: warpnet/salt-lint
Pull request #303 (2023-02-05 18:13:48)

fix: octal rule triggers on time format
Time values such as this:

```
some_calendar_entry:
  file.managed:
    - name: /tmp/my_unit_file
    - contents: |
        OnCalendar=Sun 18:00
```

should not trigger this rule.

Changed the regex to accommodate this case while still catching/ignoring previous identified test cases

nicholasmhughes: @roaldnefs 

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 979daca..f031905 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 ### Added
 - Add Python 3.12 support ([#315](https://github.com/warpnet/salt-lint/pull/315)).
 
+### Fixed
+- Ignore false positive result in rule 210 ([#303](https://github.com/warpnet/salt-lint/pull/303)).
+
 ## [0.9.2] (2023-02-09)
 ### Fixed
 - Ensure version identification adheres to [PEP440](https://peps.python.org/pep-0440/) ([!304](https://github.com/warpnet/salt-lint/issues/304))
diff --git a/saltlint/rules/YamlHasOctalValueRule.py b/saltlint/rules/YamlHasOctalValueRule.py
index 2001e49..6207251 100644
--- a/saltlint/rules/YamlHasOctalValueRule.py
+++ b/saltlint/rules/YamlHasOctalValueRule.py
@@ -19,5 +19,12 @@ class YamlHasOctalValueRule(Rule):
 
     bracket_regex = re.compile(r"^[^:]+:\s{0,}0[0-9]{1,}\s{0,}((?={#)|(?=#)|(?=$))")
 
+    exclude_regex = re.compile(r"[ T]\d\d:\d\d(?:[: ]|$)")
+
     def match(self, file, line):
-        return self.bracket_regex.search(line)
+        found = self.bracket_regex.search(line)
+        if found:
+            # Skip false positive result if the exclude_regex matches.
+            if self.exclude_regex.search(found.group(0)):
+                return None
+        return found


Test patch:
diff --git a/tests/unit/TestYamlHasOctalValueRule.py b/tests/unit/TestYamlHasOctalValueRule.py
index e03fc44..604d64c 100644
--- a/tests/unit/TestYamlHasOctalValueRule.py
+++ b/tests/unit/TestYamlHasOctalValueRule.py
@@ -31,9 +31,20 @@ apache_disable_default_site:
 
 # MAC addresses shouldn't be matched, for more information see:
 # https://github.com/warpnet/salt-lint/issues/202
-infoblox_remove_record:
+infoblox_remove_record1:
   infoblox_host_record.absent:
     - mac: 4c:f2:d3:1b:2e:05
+
+infoblox_remove_record2:
+  infoblox_host_record.absent:
+    - mac: 05:f2:d3:1b:2e:4c
+
+# time values should not trigger this rule
+some_calendar_entry:
+  file.managed:
+    - name: /tmp/my_unit_file
+    - contents: |
+        oncalendar=Sun 18:00
 '''
 
 BAD_NUMBER_STATE = '''
Repository: googlefonts/ufo2ft
Pull request #358 (2019-12-04 15:18:24)

OutlineOTFCompiler: Guard against missing nominalWidthX
Can be triggered if a UFO defines `info.postscriptDefaultWidthX` but not `info.postscriptNominalWidthX`.


Patch:
diff --git a/Lib/ufo2ft/outlineCompiler.py b/Lib/ufo2ft/outlineCompiler.py
index 055819d..90ba5be 100644
--- a/Lib/ufo2ft/outlineCompiler.py
+++ b/Lib/ufo2ft/outlineCompiler.py
@@ -948,8 +948,8 @@ class OutlineOTFCompiler(BaseOutlineCompiler):
         if self._defaultAndNominalWidths is None:
             info = self.ufo.info
             # populate the width values
-            if not any(
-                getattr(info, attr, None) is not None
+            if all(
+                getattr(info, attr, None) is None
                 for attr in ("postscriptDefaultWidthX", "postscriptNominalWidthX")
             ):
                 # no custom values set in fontinfo.plist; compute optimal ones
@@ -958,8 +958,12 @@ class OutlineOTFCompiler(BaseOutlineCompiler):
                 widths = [otRound(glyph.width) for glyph in self.allGlyphs.values()]
                 defaultWidthX, nominalWidthX = optimizeWidths(widths)
             else:
-                defaultWidthX = otRound(info.postscriptDefaultWidthX)
-                nominalWidthX = otRound(info.postscriptNominalWidthX)
+                defaultWidthX = otRound(
+                    getAttrWithFallback(info, "postscriptDefaultWidthX")
+                )
+                nominalWidthX = otRound(
+                    getAttrWithFallback(info, "postscriptNominalWidthX")
+                )
             self._defaultAndNominalWidths = (defaultWidthX, nominalWidthX)
         return self._defaultAndNominalWidths
 


Test patch:
diff --git a/tests/outlineCompiler_test.py b/tests/outlineCompiler_test.py
index cc2e2d1..b0eabf4 100644
--- a/tests/outlineCompiler_test.py
+++ b/tests/outlineCompiler_test.py
@@ -494,6 +494,31 @@ class OutlineOTFCompilerTest(object):
         # 250 - nominalWidthX
         assert charStrings.getItemAndSelector("space")[0].program == [-53, "endchar"]
 
+    def test_optimized_default_but_no_nominal_widths(self, FontClass):
+        ufo = FontClass()
+        ufo.info.familyName = "Test"
+        ufo.info.styleName = "R"
+        ufo.info.ascender = 1
+        ufo.info.descender = 1
+        ufo.info.capHeight = 1
+        ufo.info.xHeight = 1
+        ufo.info.unitsPerEm = 1000
+        ufo.info.postscriptDefaultWidthX = 500
+        for glyphName, width in (
+            (".notdef", 500),
+            ("space", 500),
+            ("a", 500),
+        ):
+            glyph = ufo.newGlyph(glyphName)
+            glyph.width = width
+
+        font = compileOTF(ufo)
+        cff = font["CFF "].cff
+        private = cff[list(cff.keys())[0]].Private
+
+        assert private.defaultWidthX == 500
+        assert private.nominalWidthX == 0
+
 
 class GlyphOrderTest(object):
     def test_compile_original_glyph_order(self, testufo):
Repository: googlefonts/ufo2ft
Pull request #360 (2020-02-06 10:44:37)

postProcessor: clear existing “post” extraNames
When renaming glyphs, extraNames attribute of “post” table needs to be cleared as it will contain old names which will otherwise be kept in the table even if unused.

See https://github.com/googlefonts/noto-fonts/issues/1543


Patch:
diff --git a/Lib/ufo2ft/postProcessor.py b/Lib/ufo2ft/postProcessor.py
index bdb7896..28adff4 100644
--- a/Lib/ufo2ft/postProcessor.py
+++ b/Lib/ufo2ft/postProcessor.py
@@ -78,6 +78,7 @@ class PostProcessor(object):
         # to TTX directly before compiling first, the post table will not
         # contain the extraNames.
         if "post" in otf and otf["post"].formatType == 2.0:
+            otf["post"].extraNames = []
             otf["post"].compile(self.otf)
 
         if "CFF " in otf:


Test patch:
diff --git a/tests/data/TestVariableFont-CFF2-useProductionNames.ttx b/tests/data/TestVariableFont-CFF2-useProductionNames.ttx
index eaa705e..4f5a07a 100644
--- a/tests/data/TestVariableFont-CFF2-useProductionNames.ttx
+++ b/tests/data/TestVariableFont-CFF2-useProductionNames.ttx
@@ -185,8 +185,6 @@
     </psNames>
     <extraNames>
       <!-- following are the name that are not taken from the standard Mac glyph order -->
-      <psName name="dotabovecomb"/>
-      <psName name="edotabove"/>
       <psName name="uni0061"/>
       <psName name="uni0065"/>
       <psName name="uni0073"/>
diff --git a/tests/data/TestVariableFont-TTF-useProductionNames.ttx b/tests/data/TestVariableFont-TTF-useProductionNames.ttx
index b256931..622eefa 100644
--- a/tests/data/TestVariableFont-TTF-useProductionNames.ttx
+++ b/tests/data/TestVariableFont-TTF-useProductionNames.ttx
@@ -304,8 +304,6 @@
     </psNames>
     <extraNames>
       <!-- following are the name that are not taken from the standard Mac glyph order -->
-      <psName name="dotabovecomb"/>
-      <psName name="edotabove"/>
       <psName name="uni0061"/>
       <psName name="uni0065"/>
       <psName name="uni0073"/>
Repository: googlefonts/ufo2ft
Pull request #622 (2022-06-17 16:00:31)

Restore cubicConversionError renaming
My colleague @hoolean found this while investigating https://github.com/fonttools/fonttools/issues/2518. He pin-pointed it to https://github.com/googlefonts/ufo2ft/commit/48cf175c2cf3e460ea13d80b7628d580a0d9a5eb#diff-ac2b4a91d2e815dc8fb72da8fa23b409950a6901f465b74e118f088da3c74aedL310-L319 where we forgot to rename one parameter. So, this parameter has been ignored since v2.25.0 (Oct 2021).


Patch:
diff --git a/Lib/ufo2ft/__init__.py b/Lib/ufo2ft/__init__.py
index af27646..a3b1c51 100644
--- a/Lib/ufo2ft/__init__.py
+++ b/Lib/ufo2ft/__init__.py
@@ -57,6 +57,10 @@ def call_preprocessor(ufo_or_ufos, *, preProcessorClass, **kwargs):
                 "public.skipExportGlyphs", []
             )
 
+    # Preprocessors expect this parameter under a different name.
+    if "cubicConversionError" in kwargs:
+        kwargs["conversionError"] = kwargs.pop("cubicConversionError")
+
     callables = [preProcessorClass]
     if hasattr(preProcessorClass, "initDefaultFilters"):
         callables.append(preProcessorClass.initDefaultFilters)


Test patch:
diff --git a/tests/outlineCompiler_test.py b/tests/outlineCompiler_test.py
index 19a225f..b31319c 100644
--- a/tests/outlineCompiler_test.py
+++ b/tests/outlineCompiler_test.py
@@ -1132,6 +1132,33 @@ def test_compile_empty_ufo(FontClass):
     assert font["OS/2"].sTypoDescender == -200
 
 
+def test_pass_on_conversion_error(FontClass):
+    ufo = FontClass()
+    ufo.info.unitsPerEm = 2000
+
+    # Draw quarter circle
+    glyph = ufo.newGlyph("test")
+    pen = glyph.getPointPen()
+    pen.beginPath()
+    pen.addPoint((0, 43), segmentType="line")
+    pen.addPoint((25, 43))
+    pen.addPoint((43, 25))
+    pen.addPoint((43, 0), segmentType="curve")
+    pen.addPoint((0, 0), segmentType="line")
+    pen.endPath()
+
+    font1 = compileTTF(ufo)  # Default error: 0.001
+    font2 = compileTTF(ufo, cubicConversionError=0.0005)
+
+    # One off-curve:
+    font1_coords = list(font1["glyf"]["test"].coordinates)
+    assert font1_coords == [(0, 43), (0, 0), (43, 0), (43, 43)]
+
+    # Two off-curves:
+    font2_coords = list(font2["glyf"]["test"].coordinates)
+    assert font2_coords == [(0, 43), (0, 0), (43, 0), (43, 19), (19, 43)]
+
+
 if __name__ == "__main__":
     import sys