From 6a473832a33d2f1a0e9d81e3159927272691a6d4 Mon Sep 17 00:00:00 2001 From: James Myatt Date: Tue, 5 Nov 2024 16:25:19 +0000 Subject: [PATCH 1/2] Fix type hints for add_collection --- invoke/collection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/invoke/collection.py b/invoke/collection.py index 23dcff928..09175f642 100644 --- a/invoke/collection.py +++ b/invoke/collection.py @@ -1,6 +1,6 @@ import copy from types import ModuleType -from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import Any, Callable, Dict, List, Optional, Tuple, Union from .util import Lexicon, helpline @@ -284,14 +284,14 @@ def add_task( def add_collection( self, - coll: "Collection", + coll: Union["Collection", ModuleType], name: Optional[str] = None, default: Optional[bool] = None, ) -> None: """ Add `.Collection` ``coll`` as a sub-collection of this one. - :param coll: The `.Collection` to add. + :param coll: The `.Collection` to add or `ModuleType` to add as a collection. :param str name: The name to attach the collection as. Defaults to the collection's From 60c3050a99de64f0a055fa3cc40f6def70a6774a Mon Sep 17 00:00:00 2001 From: James Myatt Date: Wed, 6 Nov 2024 09:21:47 +0000 Subject: [PATCH 2/2] Update collection.py Fix E501 error --- invoke/collection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/invoke/collection.py b/invoke/collection.py index 09175f642..cece24cd4 100644 --- a/invoke/collection.py +++ b/invoke/collection.py @@ -291,7 +291,9 @@ def add_collection( """ Add `.Collection` ``coll`` as a sub-collection of this one. - :param coll: The `.Collection` to add or `ModuleType` to add as a collection. + :param coll: + The `.Collection` to add. A `ModuleType` will be converted to a + `.Collection` using `.Collection.from_module`. :param str name: The name to attach the collection as. Defaults to the collection's