Skip to content

Commit

Permalink
Merge back release 0.2.x. Release 0.2.1 (#44)
Browse files Browse the repository at this point in the history
* [0.2.x] Update changelog

* [0.2.x] Bumped version for 0.2.0 release.

* [#37] Fix call_command issue with command of type Subcommand

* [0.2.x] Bumped version for 0.2.0rc2 release.

* [0.2.x] Bumped version for 0.2 release

* Fix subcommand config attribute (#43)

* [#42] Fix subcommand config attribute

* [0.2.x] Modify workflow to run on pull request

* [config] Add readthedocs configuration file

* [0.2.x] Bumped version for 0.2.1 release. Update pyproject.toml
  • Loading branch information
StephaneCapponi authored Sep 22, 2023
1 parent 3de19de commit c808a32
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ on:
push:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'

pull_request:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ on:
pull_request:
branches:
- master
- 'release/**'
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
push:
branches:
- master
- 'release/**'
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ on:
push:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'

pull_request:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ on:
push:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'

pull_request:
branches:
- master
- 'release/**'
paths-ignore:
- 'docs/**'

Expand Down
15 changes: 15 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.9"

python:
install:
- method: pip
path: .
- requirements: docs/requirements.txt

sphinx:
configuration: docs/conf.py
9 changes: 9 additions & 0 deletions docs/internals/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ section of releases.

.. towncrier release notes start

Socon 0.2.1
===========

Bug Fixes:
----------

* `#42 <https://github.com/socon-dev/socon/issues/42>`_: Fixed by saving the subcommand and calling
the right method to set the config attribute.

Socon 0.2.0
===========

Expand Down
10 changes: 10 additions & 0 deletions docs/spelling_wordlist
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ url
virtualenv
whitespace
whitespaces
projectcommand
projectcommands
basecommand
basecommands
Subcommand
subcommand
subcommands
isort
pyproject
toml
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ homepage = "https://socon.readthedocs.io/en/latest/"
repository = "https://github.com/socon-dev/socon"
changelog = "https://github.com/socon-dev/socon/blob/master/docs/internals/changelog.txt"

[tool.setuptools]
packages = ["socon"]
[tool.setuptools.packages.find]
include = ["socon*"]

[tool.setuptools.dynamic]
version = {attr = "socon.__version__"}
Expand Down
2 changes: 1 addition & 1 deletion socon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from socon.utils.version import get_version

VERSION = (0, 2, 0, "final", 0)
VERSION = (0, 2, 1, "final", 0)

__version__ = get_version(VERSION)

Expand Down
10 changes: 6 additions & 4 deletions socon/core/management/subcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ def parse_args(self, argv: tuple) -> Config:
# message when we run the subcommand.
setattr(options, "subcommand", subcommand)

# Save the subcommand for later use in the handle method. This is to avoid
# to seach again for the command and initialize it with no config. #42
self.__subcommand = command

# Create a config object that will store all the options
return command.baseconfig(options, extras_args)
return command.set_config(options, extras_args)

def handle(self, config: Config):
"""Execute the subcommand"""
subcommand = config.getoption("subcommand")
command = self.get_subcommand(subcommand, self.argv)
return command.execute(config)
return self.__subcommand.execute(config)
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ class SubTwocommand(BaseCommand):

def handle(self, config: Config) -> None:
print(config.extras_args)


class SubAccessConfig(BaseCommand):
"""Subcommand to check access to sub config attribute"""

name = "sub-config"
manager = "with_subs"

def handle(self, config: Config) -> None:
assert self.config == config
6 changes: 6 additions & 0 deletions tests/admin_scripts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1419,3 +1419,9 @@ def test_call_main_sub_command_with_call_command(self, capsys):
assert "List of available subcommands:" in captured.out
assert "sub1" in captured.out
assert "sub2" in captured.out

def test_access_config_attribute(self, test_dir):
"""Check that we can access the config attribute. Test for #42"""
args = ["base-subcommand", "sub-config", "--project", "subcommands"]
_, err = self.run_manage(args, test_dir)
assert err == ""

0 comments on commit c808a32

Please sign in to comment.