From 866824db7c5fac0e860bf0d784c8d766cb2e6ac4 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Sat, 21 Oct 2017 12:38:02 +0200 Subject: [PATCH 1/2] [config] Adds __doc__ to option/service. Fix variable names in Option.__get__() that would have an unpredicatable behaviour in the rare case of using get on a type. Update to Medikit. --- Makefile | 18 +++++++++++++----- Projectfile | 4 ++-- bonobo/config/options.py | 8 +++++--- bonobo/config/services.py | 4 ++-- setup.py | 2 +- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 221b012..fdab6c6 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ -# This file has been auto-generated. -# All changes will be lost, see Projectfile. -# -# Updated at 2017-10-05 18:56:33.985014 +# This file has been auto-generated by Medikit. All changes will be lost. +# Updated on 2017-10-21. PACKAGE ?= bonobo PYTHON ?= $(shell which python) @@ -22,7 +20,7 @@ YAPF ?= $(PYTHON) -m yapf YAPF_OPTIONS ?= -rip VERSION ?= $(shell git describe 2>/dev/null || echo dev) -.PHONY: $(SPHINX_SOURCEDIR) clean format install install-dev test +.PHONY: $(SPHINX_SOURCEDIR) clean format install install-dev test update update-requirements # Installs the local project dependencies. install: @@ -40,6 +38,16 @@ install-dev: clean: rm -rf build dist *.egg-info +# Update project artifacts using medikit, after installing it eventually. +update: + python -c 'import medikit; print(medikit.__version__)' || pip install medikit; + $(PYTHON) -m medikit update + +# Remove requirements files and update project artifacts using medikit, after installing it eventually. +update-requirements: + rm -rf requirements*.txt + $(MAKE) update + test: install-dev $(PYTEST) $(PYTEST_OPTIONS) tests diff --git a/Projectfile b/Projectfile index 0973c1f..c812fc1 100644 --- a/Projectfile +++ b/Projectfile @@ -1,6 +1,6 @@ -# bonobo (see github.com/python-edgy/project) +# bonobo's description for medikit -from edgy.project import require +from medikit import require pytest = require('pytest') python = require('python') diff --git a/bonobo/config/options.py b/bonobo/config/options.py index 065cc9d..7ee26e8 100644 --- a/bonobo/config/options.py +++ b/bonobo/config/options.py @@ -53,21 +53,23 @@ class Option: _creation_counter = 0 - def __init__(self, type=None, *, required=True, positional=False, default=None): + def __init__(self, type=None, *, required=True, positional=False, default=None, __doc__=None): self.name = None self.type = type self.required = required if default is None else False self.positional = positional self.default = default + self.__doc__ = __doc__ or self.__doc__ + # This hack is necessary for python3.5 self._creation_counter = Option._creation_counter Option._creation_counter += 1 - def __get__(self, inst, typ): + def __get__(self, inst, type_): # XXX If we call this on the type, then either return overriden value or ... ??? if inst is None: - return vars(type).get(self.name, self) + return vars(type_).get(self.name, self) if not self.name in inst._options_values: inst._options_values[self.name] = self.get_default() diff --git a/bonobo/config/services.py b/bonobo/config/services.py index 1810ebc..acf4dfd 100644 --- a/bonobo/config/services.py +++ b/bonobo/config/services.py @@ -49,8 +49,8 @@ class Service(Option): """ - def __init__(self, name): - super().__init__(str, required=False, default=name) + def __init__(self, name, __doc__=None): + super().__init__(str, required=False, default=name, __doc__=__doc__) def __set__(self, inst, value): inst._options_values[self.name] = validate_service_name(value) diff --git a/setup.py b/setup.py index be97d0c..7b513dc 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# This file is autogenerated by edgy.project code generator. +# This file is autogenerated by medikit code generator. # All changes will be overwritten. from setuptools import setup, find_packages From d596d3a4384f222ec70c9e30e4e1e6ad1d7b6030 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Sat, 21 Oct 2017 12:39:46 +0200 Subject: [PATCH 2/2] Update requirements. --- requirements-docker.txt | 6 +++--- requirements-jupyter.txt | 2 +- requirements.txt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/requirements-docker.txt b/requirements-docker.txt index 976b56d..9e68208 100644 --- a/requirements-docker.txt +++ b/requirements-docker.txt @@ -1,16 +1,16 @@ -e .[docker] appdirs==1.4.3 -bonobo-docker==0.2.11 +bonobo-docker==0.2.12 certifi==2017.7.27.1 chardet==3.0.4 colorama==0.3.9 docker-pycreds==0.2.1 docker==2.3.0 -fs==2.0.11 +fs==2.0.12 idna==2.6 packaging==16.8 pbr==3.1.1 -psutil==5.3.1 +psutil==5.4.0 pyparsing==2.2.0 pytz==2017.2 requests==2.18.4 diff --git a/requirements-jupyter.txt b/requirements-jupyter.txt index e1b0ba7..2ad75ab 100644 --- a/requirements-jupyter.txt +++ b/requirements-jupyter.txt @@ -19,7 +19,7 @@ markupsafe==1.0 mistune==0.7.4 nbconvert==5.3.1 nbformat==4.4.0 -notebook==5.1.0 +notebook==5.2.0 pandocfilters==1.4.2 parso==0.1.0 pexpect==4.2.1 diff --git a/requirements.txt b/requirements.txt index d6439df..13d5113 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,11 +3,11 @@ appdirs==1.4.3 certifi==2017.7.27.1 chardet==3.0.4 colorama==0.3.9 -fs==2.0.11 +fs==2.0.12 idna==2.6 packaging==16.8 pbr==3.1.1 -psutil==5.3.1 +psutil==5.4.0 pyparsing==2.2.0 pytz==2017.2 requests==2.18.4