diff --git a/.github/maintainers_guide.md b/.github/maintainers_guide.md index 14b1f3d..b8ace89 100644 --- a/.github/maintainers_guide.md +++ b/.github/maintainers_guide.md @@ -20,14 +20,14 @@ 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 ``` @@ -35,8 +35,8 @@ 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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 671a84c..07528d5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 }} diff --git a/README.md b/README.md index 121737a..de153df 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,30 @@ -# Python Slack Hooks +

Python Slack Hooks

+ +

+ + PyPI - Version + + Python Versions +

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`. @@ -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", @@ -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. \ No newline at end of file +for more information. diff --git a/pyproject.toml b/pyproject.toml index 4067b3d..906a889 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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", diff --git a/requirements/format.txt b/requirements/format.txt index 8df1850..a0c3308 100644 --- a/requirements/format.txt +++ b/requirements/format.txt @@ -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" diff --git a/scripts/_utils.sh b/scripts/_utils.sh index f41d7aa..73ee0b6 100644 --- a/scripts/_utils.sh +++ b/scripts/_utils.sh @@ -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 } diff --git a/slack_cli_hooks/hooks/check_update.py b/slack_cli_hooks/hooks/check_update.py index 217abc2..61475f9 100644 --- a/slack_cli_hooks/hooks/check_update.py +++ b/slack_cli_hooks/hooks/check_update.py @@ -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 @@ -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, @@ -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: