invoke: 0.12 cannot use context for state handling

------------------
@ctask
def a(ctx):
    ctx['a'] = 123
    print('a')

@ctask(a)
def b(ctx):
    print(ctx['a'])
    print('b')
------------------
$ > invoke b

Expected result: a 123 b (it works with Invoke 0.11.1) Actual result: the following exception:

Traceback (most recent call last):
  File "/home/matefarkas/work/bsp-install/bin/inv", line 9, in <module>
    load_entry_point('invoke', 'console_scripts', 'inv')()
  File "/home/matefarkas/work/invoke/invoke/program.py", line 270, in run
    self.execute()
  File "/home/matefarkas/work/invoke/invoke/program.py", line 379, in execute
    executor.execute(*self.tasks)
  File "/home/matefarkas/work/invoke/invoke/executor.py", line 114, in execute
    result = call.task(*args, **call.kwargs)
  File "/home/matefarkas/work/invoke/invoke/tasks.py", line 113, in __call__
    result = self.body(*args, **kwargs)
  File "/home/matefarkas/work/invoke/tasks.py", line 15, in b
    print(ctx['a'])
  File "/home/matefarkas/work/invoke/invoke/config.py", line 110, in __getitem__
    return self._get(key)
  File "/home/matefarkas/work/invoke/invoke/config.py", line 113, in _get
    value = self.config[key]
  File "/home/matefarkas/work/invoke/invoke/config.py", line 110, in __getitem__
    return self._get(key)
  File "/home/matefarkas/work/invoke/invoke/config.py", line 113, in _get
    value = self.config[key]
KeyError: 'a'

As I know, since 0.12 Invoke does not remembers the state changed in pre tasks.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 4
  • Comments: 28 (22 by maintainers)

Commits related to this issue

Most upvoted comments

@dennybaa It’s not released on PyPI yet! Doing that very soon though. Look for a version 0.16.0 to appear.