Repository: slackapi/python-slack-sdk
Pull request #1251 (2022-08-02 20:46:26)

Add in timezone property for timepicker element
## Summary

Adding in a new `timezone` string property to the TimePicker block element. See #1249 for more info.

Along with adding in the new property in `slack_sdk/models/blocks/block_elements.py`, also updated and previewed the docs and added a unit test corresponding to the addition of this new property.

### 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.


codecov[bot]: # [Codecov](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi) Report
> Merging [#1251](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi) (fe8ce75) into [main](https://codecov.io/gh/slackapi/python-slack-sdk/commit/a72b5e4a076cb0f8d12d51e07f44f4c1d2fe41a0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi) (a72b5e4) will **increase** coverage by `0.08%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##             main    #1251      +/-   ##
==========================================
+ Coverage   86.57%   86.65%   +0.08%     
==========================================
  Files         111      111              
  Lines       10986    11026      +40     
==========================================
+ Hits         9511     9555      +44     
+ Misses       1475     1471       -4     
```


| [Impacted Files](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi) | Coverage Δ | |
|---|---|---|
| [slack\_sdk/models/blocks/block\_elements.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL21vZGVscy9ibG9ja3MvYmxvY2tfZWxlbWVudHMucHk=) | `92.89% <100.00%> (+0.01%)` | :arrow_up: |
| [slack\_sdk/socket\_mode/builtin/internals.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL3NvY2tldF9tb2RlL2J1aWx0aW4vaW50ZXJuYWxzLnB5) | `72.68% <0.00%> (-1.88%)` | :arrow_down: |
| [slack\_sdk/web/client.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL3dlYi9jbGllbnQucHk=) | `86.52% <0.00%> (ø)` | |
| [slack\_sdk/web/async\_client.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL3dlYi9hc3luY19jbGllbnQucHk=) | `85.14% <0.00%> (ø)` | |
| [slack\_sdk/web/legacy\_client.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL3dlYi9sZWdhY3lfY2xpZW50LnB5) | `86.24% <0.00%> (ø)` | |
| [slack\_sdk/models/blocks/\_\_init\_\_.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL21vZGVscy9ibG9ja3MvX19pbml0X18ucHk=) | `100.00% <0.00%> (ø)` | |
| [slack\_sdk/models/blocks/blocks.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL21vZGVscy9ibG9ja3MvYmxvY2tzLnB5) | `96.83% <0.00%> (+0.57%)` | :arrow_up: |
| [slack\_sdk/socket\_mode/builtin/client.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL3NvY2tldF9tb2RlL2J1aWx0aW4vY2xpZW50LnB5) | `90.24% <0.00%> (+0.60%)` | :arrow_up: |
| [slack\_sdk/socket\_mode/builtin/connection.py](https://codecov.io/gh/slackapi/python-slack-sdk/pull/1251/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi#diff-c2xhY2tfc2RrL3NvY2tldF9tb2RlL2J1aWx0aW4vY29ubmVjdGlvbi5weQ==) | `67.03% <0.00%> (+2.59%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=slackapi)


Patch:
diff --git a/slack_sdk/models/blocks/block_elements.py b/slack_sdk/models/blocks/block_elements.py
index 1773a3b..b3c2b06 100644
--- a/slack_sdk/models/blocks/block_elements.py
+++ b/slack_sdk/models/blocks/block_elements.py
@@ -461,7 +461,7 @@ class TimePickerElement(InputInteractiveElement):
 
     @property
     def attributes(self) -> Set[str]:
-        return super().attributes.union({"initial_time"})
+        return super().attributes.union({"initial_time", "timezone"})
 
     def __init__(
         self,
@@ -471,6 +471,7 @@ class TimePickerElement(InputInteractiveElement):
         initial_time: Optional[str] = None,
         confirm: Optional[Union[dict, ConfirmObject]] = None,
         focus_on_load: Optional[bool] = None,
+        timezone: Optional[str] = None,
         **others: dict,
     ):
         """
@@ -494,6 +495,7 @@ class TimePickerElement(InputInteractiveElement):
                 that appears after a time is selected.
             focus_on_load: Indicates whether the element will be set to auto focus within the view object.
                 Only one element can be set to true. Defaults to false.
+            timezone: The timezone to consider for this input value.
         """
         super().__init__(
             type=self.type,
@@ -505,6 +507,7 @@ class TimePickerElement(InputInteractiveElement):
         show_unknown_key_warning(self, others)
 
         self.initial_time = initial_time
+        self.timezone = timezone
 
     @JsonValidator("initial_time attribute must be in format 'HH:mm'")
     def _validate_initial_time_valid(self) -> bool:


Test patch:
diff --git a/tests/slack_sdk/models/test_elements.py b/tests/slack_sdk/models/test_elements.py
index c4a25fb..dea3902 100644
--- a/tests/slack_sdk/models/test_elements.py
+++ b/tests/slack_sdk/models/test_elements.py
@@ -382,6 +382,19 @@ class TimePickerElementTests(unittest.TestCase):
         }
         self.assertDictEqual(input, TimePickerElement(**input).to_dict())
 
+    def test_timezone(self):
+        input = {
+            "type": "timepicker",
+            "action_id": "timepicker123",
+            "initial_time": "11:40",
+            "placeholder": {
+                "type": "plain_text",
+                "text": "Select a time",
+            },
+            "timezone": "America/Los_Angeles",
+        }
+        self.assertDictEqual(input, TimePickerElement(**input).to_dict())
+
 
 # -------------------------------------------------
 # Image