Skip to content

Commit

Permalink
Merge branch 'release/v0.31.3' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
neithere authored Jul 9, 2024
2 parents 9ef9a62 + b8af671 commit 7dcb6a6
Show file tree
Hide file tree
Showing 28 changed files with 140 additions and 86 deletions.
19 changes: 4 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,11 @@ repos:
- id: check-yaml
files: .*\.(yaml|yml)$

- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
hooks:
- id: isort
name: isort

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

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

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

Version 0.31.3
--------------

Bugs fixed:

- test failures under Python 3.13 (issue #228).

Version 0.31.2 (2024-01-24)
---------------------------

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configuration file for the Sphinx documentation builder."""

import os
import sys
from datetime import date
Expand Down
2 changes: 1 addition & 1 deletion docs/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, 3.12.
on the following versions of Python: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13.

If you need support for ancient Pythons, please use the following versions
of Argh (the numeric puns were semi-intentional):
Expand Down
5 changes: 5 additions & 0 deletions docs/similar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ supports Python3. Not every "yes" in this table would count as pro.
questionable practice); it does not derive the CLI arguments from the
function signature but entirely relies on additional decorators, while Argh
strives for the opposite.
* typer_ is a wrapper on top of `click`, which works with type hints instead
of decorators. This is very similar to argh's new 2024 design. Typer also
adds a lot of bells and whistles, and optional color support with `rich`,
so it is a full-featured package with several dependencies.

.. _argdeclare: http://code.activestate.com/recipes/576935-argdeclare-declarative-interface-to-argparse/
.. _argparse-cli: http://code.google.com/p/argparse-cli/
Expand All @@ -69,3 +73,4 @@ supports Python3. Not every "yes" in this table would count as pro.
.. _cement: http://builtoncement.com/2.0/
.. _autocommand: https://pypi.python.org/pypi/autocommand/
.. _click: https://click.palletsprojects.com
.. _typer: https://typer.tiangolo.com
10 changes: 2 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "argh"
version = "0.31.2"
version = "0.31.3"
description = "Plain Python functions as CLI commands without boilerplate"
readme = "README.rst"
requires-python = ">=3.8"
Expand Down Expand Up @@ -36,6 +36,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: User Interfaces",
Expand Down Expand Up @@ -71,13 +72,6 @@ linters = [
[tool.distutils.bdist_wheel]
universal = 1

[tool.isort]
multi_line_output = 3
profile = "black"

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

[tool.bandit]
exclude_dirs = ["tests"]

Expand Down
1 change: 1 addition & 0 deletions src/argh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Argh
~~~~
"""

#
# Copyright © 2010—2023 Andrey Mikhaylenko and contributors
#
Expand Down
10 changes: 5 additions & 5 deletions src/argh/assembling.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Functions and classes to properly assemble your commands in a parser.
"""

import inspect
import textwrap
import warnings
Expand Down Expand Up @@ -517,9 +518,9 @@ def _merge_inferred_and_declared_args(

# arguments inferred from function signature
for parser_add_argument_spec in inferred_args:
specs_by_func_arg_name[
parser_add_argument_spec.func_arg_name
] = parser_add_argument_spec
specs_by_func_arg_name[parser_add_argument_spec.func_arg_name] = (
parser_add_argument_spec
)

# arguments declared via @arg decorator
for declared_spec in declared_args:
Expand Down Expand Up @@ -734,8 +735,7 @@ def add_subcommands(
add_commands(parser, functions, group_name=group_name, group_kwargs=group_kwargs)


class ArgumentNameMappingError(AssemblingError):
...
class ArgumentNameMappingError(AssemblingError): ...


class TypingHintArgSpecGuesser:
Expand Down
1 change: 1 addition & 0 deletions src/argh/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def func(...):
...
"""

import logging
import os
from argparse import ArgumentParser
Expand Down
1 change: 1 addition & 0 deletions src/argh/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Constants
~~~~~~~~~
"""

import argparse

__all__ = (
Expand Down
2 changes: 2 additions & 0 deletions src/argh/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
Command decorators
~~~~~~~~~~~~~~~~~~
"""

from typing import Callable, List, Optional, Type


from argh.constants import (
ATTR_ALIASES,
ATTR_ARGS,
Expand Down
1 change: 1 addition & 0 deletions src/argh/dispatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Dispatching
~~~~~~~~~~~
"""

import argparse
import inspect
import io
Expand Down
1 change: 1 addition & 0 deletions src/argh/dto.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Data transfer objects for internal usage.
"""

from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Type, Union

Expand Down
1 change: 1 addition & 0 deletions src/argh/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Helpers
~~~~~~~
"""

import argparse
from typing import Optional, Sequence

Expand Down
1 change: 1 addition & 0 deletions src/argh/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Interaction
~~~~~~~~~~~
"""

from typing import Optional

__all__ = ["confirm"]
Expand Down
16 changes: 6 additions & 10 deletions src/argh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Utilities
~~~~~~~~~
"""

import argparse
import re
from typing import Tuple
Expand Down Expand Up @@ -59,8 +60,7 @@ def unindent(text: str) -> str:
return re.sub(rf"(^|\n) {{{depth}}}", "\\1", text)


class SubparsersNotDefinedError(Exception):
...
class SubparsersNotDefinedError(Exception): ...


def naive_guess_func_arg_name(option_strings: Tuple[str, ...]) -> str:
Expand Down Expand Up @@ -89,17 +89,13 @@ def _opt_to_func_arg_name(opt: str) -> str:
)


class ArghError(Exception):
...
class ArghError(Exception): ...


class CliArgToFuncArgGuessingError(ArghError):
...
class CliArgToFuncArgGuessingError(ArghError): ...


class TooManyPositionalArgumentNames(CliArgToFuncArgGuessingError):
...
class TooManyPositionalArgumentNames(CliArgToFuncArgGuessingError): ...


class MixedPositionalAndOptionalArgsError(CliArgToFuncArgGuessingError):
...
class MixedPositionalAndOptionalArgsError(CliArgToFuncArgGuessingError): ...
1 change: 1 addition & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Common stuff for tests
~~~~~~~~~~~~~~~~~~~~~~
"""

import io
import os
import sys
Expand Down
16 changes: 6 additions & 10 deletions tests/test_assembling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Unit Tests For Assembling Phase
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""

import argparse
from typing import Literal, Optional
from unittest.mock import MagicMock, call, patch
Expand Down Expand Up @@ -85,8 +86,7 @@ def test_guess_action_from_default():


def test_positional_with_default_int():
def func(pos_int_default=123):
...
def func(pos_int_default=123): ...

parser = argh.ArghParser(prog="test")
parser.set_default_command(
Expand All @@ -97,8 +97,7 @@ def func(pos_int_default=123):


def test_positional_with_default_bool():
def func(pos_bool_default=False):
...
def func(pos_bool_default=False): ...

parser = argh.ArghParser(prog="test")
parser.set_default_command(
Expand Down Expand Up @@ -500,8 +499,7 @@ def func():


def test_set_default_command__varkwargs_sharing_prefix():
def func(*, alpha: str = "Alpha", aleph: str = "Aleph"):
...
def func(*, alpha: str = "Alpha", aleph: str = "Aleph"): ...

parser = argh.ArghParser()
parser.add_argument = MagicMock()
Expand Down Expand Up @@ -767,11 +765,9 @@ def test_is_positional():

def test_typing_hints_only_used_when_arg_deco_not_used():
@argh.arg("foo", type=int)
def func_decorated(foo: Optional[float]):
...
def func_decorated(foo: Optional[float]): ...

def func_undecorated(bar: Optional[float]):
...
def func_undecorated(bar: Optional[float]): ...

parser = argparse.ArgumentParser()
parser.add_argument = MagicMock()
Expand Down
1 change: 1 addition & 0 deletions tests/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""

from unittest.mock import patch

import argh
Expand Down
1 change: 1 addition & 0 deletions tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Unit Tests For Decorators
~~~~~~~~~~~~~~~~~~~~~~~~~
"""

import pytest

import argh
Expand Down
7 changes: 3 additions & 4 deletions tests/test_dispatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Dispatching tests
~~~~~~~~~~~~~~~~~
"""

import argparse
import io
from unittest.mock import Mock, patch
Expand Down Expand Up @@ -198,8 +199,7 @@ def hit():
def test_dispatch_command_naming_policy(
parser_cls_mock, set_default_command_mock, dispatch_mock
):
def func():
...
def func(): ...

parser_mock = Mock()
parser_cls_mock.return_value = parser_mock
Expand Down Expand Up @@ -234,8 +234,7 @@ def func():
def test_dispatch_commands_naming_policy(
parser_cls_mock, add_commands_mock, dispatch_mock
):
def func():
...
def func(): ...

parser_mock = Mock()
parser_cls_mock.return_value = parser_mock
Expand Down
13 changes: 5 additions & 8 deletions tests/test_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Unit Tests For the Argument DTO
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""

from argh.dto import ParserAddArgumentSpec


def test_update_empty_dto() -> None:
def stub_completer():
...
def stub_completer(): ...

dto = ParserAddArgumentSpec(
func_arg_name="foo",
Expand Down Expand Up @@ -37,11 +37,9 @@ def stub_completer():


def test_update_full_dto() -> None:
def stub_completer_one():
...
def stub_completer_one(): ...

def stub_completer_two():
...
def stub_completer_two(): ...

dto = ParserAddArgumentSpec(
func_arg_name="foo",
Expand Down Expand Up @@ -75,8 +73,7 @@ def stub_completer_two():
)


class TestGetAllKwargs:
...
class TestGetAllKwargs: ...


def test_make_from_kwargs_minimal() -> None:
Expand Down
Loading

0 comments on commit 7dcb6a6

Please sign in to comment.