pyinvoke / invoke

Pythonic task management & command execution.
http://pyinvoke.org
BSD 2-Clause "Simplified" License
4.31k stars 365 forks source link

TypeError: 'str' object is not callable when accessing Context attribute of the task. #908

Closed EugenSusurrus closed 1 year ago

EugenSusurrus commented 1 year ago

Currently I have a tasks file which defines tasks as follows:

@task
def install(c, qt_version):
    """Downloads the specified Qt version from SFTP server and installs it in the default location."""
    installer_path = _download_installer(qt_version, TARGET_DIR)
    print(c.cwd())

Which errors out when accessing the attributes on the task context with the following error.

The tasks are distributed in the package as an entry point as follows:

[options.entry_points]
console_scripts =
    newmanage = repo.newmanage.main:program.run
Traceback (most recent call last):
  File "/Users/admin/Workspace/repo/env/bin/newmanage", line 8, in <module>
    sys.exit(program.run())
  File "/Users/admin/Workspace/repo/env/lib/python3.8/site-packages/invoke/program.py", line 384, in run
    self.execute()
  File "/Users/admin/Workspace/repo/env/lib/python3.8/site-packages/invoke/program.py", line 569, in execute
    executor.execute(*self.tasks)
  File "/Users/admin/Workspace/repo/env/lib/python3.8/site-packages/invoke/executor.py", line 129, in execute
    result = call.task(*args, **call.kwargs)
  File "/Users/admin/Workspace/repo/env/lib/python3.8/site-packages/invoke/tasks.py", line 127, in __call__
    result = self.body(*args, **kwargs)
  File "/Users/admin/Workspace/repo/submodules/repo/src/repo/newmanage/tasks_squish.py", line 95, in install
    print(c.cwd())
TypeError: 'str' object is not callable

Does anyone know why the argument passed by the task decorator is of type str in this case? Any idea?

Used invoke version is:

Name: invoke
Version: 1.7.3
Summary: Pythonic task execution
Home-page: https://pyinvoke.org
Author: Jeff Forcier
Author-email: jeff@bitprophet.org
License: BSD

Many thanks in advance!

EugenSusurrus commented 1 year ago

Done too much coding today apparently 😆

Context().cwd is a property, not a method, that was the cause for it. I'll close the issue.