"task" is not exported from module "invoke"

Open
#1,013 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start by inspecting the main init.py export surface and compare the proposed change with the discussion in issue 814. Verify that from invoke import task is recognized by Pylance without breaking the existing public imports; the issue is done when the warning is resolved and the package's exports remain correct.

Written by the indexing model from the issue text.

Description

I am using vscode. I get a pylance warning:
"task" is not exported from module "invoke"

This is from this line:
from invoke import task

It all works, but is a little annoying.

I'm not sure the sophisticated way to do it in a library, but you could add a complete __all__= in your main __init__.py.

For instace:

# At bottom of __init__.py

__all__ = (
    "__version_info__",
    "__version__",
    "AmbiguousEnvVar",
    "Argument",
    "AuthFailure",
    "Call",
    "Collection",
    "CollectionNotFound",
    "CommandTimedOut",
    "Config",
    "Context",
    "Exit",
    "Executor",
    "FailingResponder",
    "Failure",
    "FilesystemLoader",
    "Local",
    "MockContext",
    "ParseError",
    "Parser",
    "ParserContext",
    "ParseResult",
    "PlatformError",
    "Program",
    "Promise",
    "pty_size",
    "Responder",
    "ResponseNotAccepted",
    "Result",
    "Runner",
    "run",
    "StreamWatcher",
    "SubprocessPipeError",
    "sudo",
    "task",
    "Task",
    "call",
    "ThreadException",
    "UncastableEnvVar",
    "UnexpectedExit",
    "UnknownFileType",
    "UnpicklableConfigMember",
    "WatcherError",
)

This is also covered in https://github.com/pyinvoke/invoke/issues/814, but I think the solution mentioned there is not ideal.

Dominant language
Python
Stars
4.8k
Forks
412
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pyinvoke/invoke

All issues in pyinvoke/invoke

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.