Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.12 (closes #196) #195

Merged
merged 15 commits into from
Oct 4, 2023
5 changes: 3 additions & 2 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
- 'pypy-3.8'
- '3.12'
- 'pypy-3.9'
- 'pypy-3.10'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ repos:
name: isort

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.9.1
hooks:
- id: black
language_version: python3

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8

Expand All @@ -37,14 +37,14 @@ repos:
- id: mypy

- repo: https://github.com/PyCQA/bandit
rev: 1.7.4
rev: 1.7.5
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
additional_dependencies: ["bandit[toml]"]

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
rev: v1.32.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Deprecated:

Enhancements:

- Added support for Python 3.12.
- Added type annotations to existing Argh code (#185 → #189).
- The `dispatch()` function has been refactored, so in case you need finer
control over the process, two new, more granular functions can be used:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ A very simple application with one command:
import argh

def main() -> str:
return 'Hello world'
return "Hello world"

argh.dispatch_command(main)

Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Dependencies
------------

The `argh` library is supported (and tested unless otherwise specified)
on the following versions of Python: 3.8, 3.9, 3.10, 3.11.
on the following versions of Python: 3.8, 3.9, 3.10, 3.11, 3.12.

If you need support for ancient Pythons, please use the following versions
of Argh (the numeric puns were semi-intentional):
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: User Interfaces",
Expand All @@ -53,9 +54,9 @@ completion = [
"argcomplete >= 2.0",
]
test = [
"tox >= 4.4",
"pytest >= 7.2",
"pytest-cov >= 4.0",
"tox >= 4.11.3",
"pytest >= 7.4",
"pytest-cov >= 4.1",
]
docs = [
"sphinx >= 6.1",
Expand All @@ -64,7 +65,7 @@ docs = [
"readthedocs-sphinx-search == 0.2.0",
]
linters = [
"pre-commit >= 3.0.4",
"pre-commit >= 3.4.0",
]

[tool.distutils.bdist_wheel]
Expand All @@ -75,7 +76,7 @@ multi_line_output = 3
profile = "black"

[tool.black]
target-version = ["py38", "py39", "py310", "py311"]
target-version = ["py38", "py39", "py310", "py311", "py312"]

[tool.bandit]
exclude_dirs = ["tests"]
Expand Down
2 changes: 1 addition & 1 deletion src/argh/dispatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def _execute_command(
All other exceptions propagate unless marked as wrappable
by :func:`wrap_errors`.
"""

# the function is nested to catch certain exceptions (see below)
def _call():
# Actually call the function
Expand Down Expand Up @@ -360,7 +361,6 @@ def default_exception_processor(exc: Exception) -> str:
for line in result:
yield line
except tuple(wrappable_exceptions) as exc:

processor = getattr(
function, ATTR_WRAPPED_EXCEPTIONS_PROCESSOR, default_exception_processor
)
Expand Down
1 change: 0 additions & 1 deletion tests/test_dispatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def func():
@patch("argh.dispatching.add_commands")
@patch("argparse.ArgumentParser")
def test_entrypoint(ap_cls_mock, add_commands_mock, dispatch_mock):

entrypoint = argh.EntryPoint("my cool app")

# no commands
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ envlist =
py39
py310
py311
py312
pypy3
as-module
lint
Expand All @@ -18,7 +19,9 @@ python =
3.9: py39
3.10: py310
3.11: py311,lint,as-module
3.12: py312
pypy-3.9: pypy3
pypy-3.10: pypy3

[testenv]
description = run unit tests
Expand Down Expand Up @@ -46,4 +49,4 @@ commands =
description = verify with linters
extras = linters
commands =
pre-commit run -a
pre-commit run -a