Repository: slackapi/python-slackclient
Pull request #726 (2020-06-20 00:57:45)

Fix "InputBlock" hint validation
### Requirements

* [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).

codecov[bot]: # [Codecov](https://codecov.io/gh/slackapi/python-slackclient/pull/726?src=pr&el=h1) Report
> Merging [#726](https://codecov.io/gh/slackapi/python-slackclient/pull/726?src=pr&el=desc) into [master](https://codecov.io/gh/slackapi/python-slackclient/commit/c09eb25c53effeb8e034422364334c6786d2248e&el=desc) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/slackapi/python-slackclient/pull/726/graphs/tree.svg?width=650&height=150&src=pr&token=F0O7meYmtD)](https://codecov.io/gh/slackapi/python-slackclient/pull/726?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #726   +/-   ##
=======================================
  Coverage   85.21%   85.21%           
=======================================
  Files          22       22           
  Lines        2800     2800           
  Branches      280      280           
=======================================
  Hits         2386     2386           
  Misses        310      310           
  Partials      104      104           
```


| [Impacted Files](https://codecov.io/gh/slackapi/python-slackclient/pull/726?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [slack/web/classes/blocks.py](https://codecov.io/gh/slackapi/python-slackclient/pull/726/diff?src=pr&el=tree#diff-c2xhY2svd2ViL2NsYXNzZXMvYmxvY2tzLnB5) | `91.97% <100.00%> (ø)` | |
| [slack/web/classes/objects.py](https://codecov.io/gh/slackapi/python-slackclient/pull/726/diff?src=pr&el=tree#diff-c2xhY2svd2ViL2NsYXNzZXMvb2JqZWN0cy5weQ==) | `85.66% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/slackapi/python-slackclient/pull/726?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/slackapi/python-slackclient/pull/726?src=pr&el=footer). Last update [c09eb25...128084d](https://codecov.io/gh/slackapi/python-slackclient/pull/726?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/slack/web/classes/blocks.py b/slack/web/classes/blocks.py
index 401f884..b9af009 100644
--- a/slack/web/classes/blocks.py
+++ b/slack/web/classes/blocks.py
@@ -310,7 +310,11 @@ class InputBlock(Block):
 
     @JsonValidator(f"hint attribute cannot exceed {hint_max_length} characters")
     def _validate_hint_length(self):
-        return self.hint is None or len(self.hint) <= self.hint_max_length
+        return (
+            self.hint is None
+            or self.hint.text is None
+            or len(self.hint.text) <= self.label_max_length
+        )
 
     @JsonValidator(
         (


Test patch:
diff --git a/tests/web/classes/test_blocks.py b/tests/web/classes/test_blocks.py
index 812cd5b..e1bdb49 100644
--- a/tests/web/classes/test_blocks.py
+++ b/tests/web/classes/test_blocks.py
@@ -584,7 +584,23 @@ class InputBlockTests(unittest.TestCase):
                     "text": "Label",
                     "emoji": True
                 }
-            }
+            },
+            {
+                "type": "input",
+                "element": {
+                    "type": "plain_text_input",
+                },
+                "label": {
+                    "type": "plain_text",
+                    "text": "Label",
+                    "emoji": True,
+                },
+                "hint": {
+                    "type": "plain_text",
+                    "text": "some hint",
+                    "emoji": True,
+                },
+            },
         ]
         for input in blocks:
             self.assertDictEqual(input, InputBlock(**input).to_dict())