Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/maintainers_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ Install necessary Python runtimes for development/testing. You can rely on GitHu
```zsh
pyenv install -l | grep -v "-e[conda|stackless|pypy]"

pyenv install 3.8.5 # select the latest patch version
pyenv local 3.8.5
pyenv install 3.9.18 # select the latest patch version
pyenv local 3.9.18

pyenv versions
system
3.6.10
3.7.7
* 3.8.5 (set by /path-to-python-slack-hooks/.python-version)
* 3.9.18 (set by /path-to-python-slack-hooks/.python-version)

pyenv rehash
```

Then, you can create a new Virtual Environment this way:

```zsh
python -m venv env_3.8.5
source env_3.8.5/bin/activate
python -m venv env_3.9.18
source env_3.9.18/bin/activate
```

## Tasks
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "pypy3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
# Python Slack Hooks
<h1 align="center">Python Slack Hooks</h1>

<p align="center">
<a href="https://pypi.org/project/slack-cli-hooks/">
<img alt="PyPI - Version" src="https://img.shields.io/pypi/v/slack-cli-hooks?style=flat-square"></a>
<a href="https://pypi.org/project/slack-cli-hooks/">
<img alt="Python Versions" src="https://img.shields.io/pypi/pyversions/slack-cli-hooks.svg?style=flat-square"></a>
</p>

This library defines the contract between the
[Slack CLI](https://api.slack.com/automation/cli/install) and
[Bolt for Python](https://slack.dev/bolt-python/).

## Overview
This library enables inter-process communication between the [Slack CLI](https://api.slack.com/automation/cli/install) and applications built with Bolt for Python.

When used together, the CLI delegates various tasks to the Bolt application by invoking processes ("hooks") and then making use of the responses provided by each hook's `stdout`.
This library enables inter-process communication between the [Slack CLI](https://api.slack.com/automation/cli/install) and applications built with Bolt for Python.

When used together, the CLI delegates various tasks to the Bolt application by invoking processes ("hooks") and then making use of the responses provided by each hook's `stdout`.

For a complete list of available hooks, read the [Supported Hooks](#supported-hooks) section.

## Requirements

The latest minor version of [Bolt v1](https://pypi.org/project/slack-bolt/) is recommended.

## Usage

A Slack CLI-compatible Slack application includes a `./slack.json` file that contains hooks specific to that project. Each hook is associated with commands that are available in the Slack CLI. By default, `get-hooks` retrieves all of the [supported hooks](#supported-hooks) and their corresponding scripts as defined in this library.

The CLI will always use the version of the `python-slack-hooks` that is specified in the project's `requirements.txt`.
Expand All @@ -30,15 +40,15 @@ The hooks currently supported for use within the Slack CLI include `check-update
| `get-manifest` | `slack manifest` | [get_manifest.py](./slack_cli_hooks/hooks/get_manifest.py) | Converts a `manifest.json` file into a valid manifest JSON payload. |
| `start` | `slack run` | [start.py](./slack_cli_hooks/hooks/start.py) | While developing locally, the CLI manages a socket connection with Slack's backend and utilizes this hook for events received via this connection. |


### Overriding Hooks
To customize the behavior of a hook, add the hook to your application's `/slack.json` file, and provide a corresponding script to be executed.

To customize the behavior of a hook, add the hook to your application's `/slack.json` file, and provide a corresponding script to be executed.

When commands are run, the Slack CLI will look to the project's hook definitions and use those instead of what's defined in this library, if provided.

Below is an example `/slack.json` file that overrides the default `start`:

```
```json
{
"hooks": {
"get-hooks": "python3 -m slack_cli_hooks.hooks.get_hooks",
Expand All @@ -51,4 +61,4 @@ Below is an example `/slack.json` file that overrides the default `start`:

Contributions are always welcome! Please review the
[contributing guidelines](https://github.com/slackapi/python-slack-hooks/blob/main/.github/CONTRIBUTING.md)
for more information.
for more information.
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version", "readme", "dependencies"]
description = "The Slack CLI contract implementation for Bolt Python"
license = { text = "MIT" }
authors = [{ name = "Slack Technologies, LLC", email = "opensource@slack.com" }]
requires-python = ">=3.6"
requires-python = ">=3.9"
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Environment :: Console",
Expand All @@ -18,9 +18,6 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Programming Language :: Python :: Implementation :: PyPy"

Have we verified if this module works with PyPy? If we haven't , running tests like below should be a good way to check it out: https://github.com/slackapi/python-slack-sdk/blob/v3.26.2/.github/workflows/ci-build.yml#L25

If it does not work for some reason, I believe it's fine to remove PyPy from this metadata as the need for it should be minor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, all tests pass with pypy3.10 💯 add this to the ci build

Expand Down
3 changes: 1 addition & 2 deletions requirements/format.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
black==22.8.0; python_version=="3.6"
black; python_version>"3.6" # Until we drop Python 3.6 support, we have to stay with this version
black
flake8>=5.0.4, <7;
pytype; (python_version<"3.11" or python_version>"3.11")
pytype==2023.11.29; python_version=="3.11"
10 changes: 1 addition & 9 deletions scripts/_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@ clean_project() {
}

install_development_requirements() {
python_version=`python --version | awk '{print $2}'`

if [ ${python_version:0:3} == "3.6" ]
then
pip install -r requirements.txt
else
pip install -e .
fi

pip install -U pip
pip install -e .
pip install -r requirements/testing.txt
pip install -r requirements/format.txt
}
Expand Down
15 changes: 2 additions & 13 deletions slack_cli_hooks/hooks/check_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import slack_bolt
import slack_sdk
from pkg_resources import parse_version as Version
from packaging.version import Version

import slack_cli_hooks.version
from slack_cli_hooks.error import PypiError
Expand All @@ -18,17 +18,6 @@
DEPENDENCIES: List[ModuleType] = [slack_cli_hooks, slack_bolt, slack_sdk]


def parse_major(v: Version) -> int:
"""The first item of :attr:`release` or ``0`` if unavailable.

>>> parse_major(Version("1.2.3"))
1
"""
# This implementation comes directly from the Version implementation since it is not supported in 3.6
# source: https://github.com/pypa/packaging/blob/main/src/packaging/version.py
return v._version.release[0] if len(v._version) >= 1 else 0 # type: ignore


class Release:
def __init__(
self,
Expand All @@ -44,7 +33,7 @@ def __init__(
self.current = current.base_version
self.latest = latest.base_version
self.update = current < latest
self.breaking = (parse_major(current) - parse_major(latest)) != 0
self.breaking = (current.major - latest.major) != 0
if error:
self.error = error
if message:
Expand Down