Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`add_collection()` is missing the `ModuleType` in the type-hints

Open
#950 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Review invoke/collection.py at line 287 and compare add_collection's annotation with the reported ModuleType use. Update the type hint so modules are accepted, then verify that the original typing error no longer occurs.

Written by the indexing model from the issue text.

Description

Since upgrading to 2.1.2 I'm getting a typing error when adding a module as collection.

The error originates from this line: https://github.com/pyinvoke/invoke/blob/b2da4d929d0e895d44d7f5b4581749f4709022e6/invoke/collection.py#L287

It can be fixed by using

    def add_collection(
        self,
        coll: Union["Collection", ModuleType],     # <-- fix
        name: Optional[str] = None,
        default: Optional[bool] = None,
    ) -> None:
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.