Skip to content

Commit 9a451a8

Browse files
chore: fix issue with adding type-hints to 'manager' attribute
When attempting to add type-hints to the the 'manager' attribute into a RESTObject derived class it would break things. This was because our auto-manager creation code would automatically add the specified annotated manager to the 'manager' attribute. This breaks things. Now check in our auto-manager creation if our attribute is called 'manager'. If so we ignore it.
1 parent 2cd15ac commit 9a451a8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

gitlab/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ def _create_managers(self) -> None:
150150
# annotations. If an attribute is annotated as being a *Manager type
151151
# then we create the manager and assign it to the attribute.
152152
for attr, annotation in sorted(self.__annotations__.items()):
153+
# We ignore creating a manager for the 'manager' attribute as that
154+
# is done in the self.__init__() method
155+
if attr in ("manager",):
156+
continue
153157
if not isinstance(annotation, (type, str)):
154158
continue
155159
if isinstance(annotation, type):

0 commit comments

Comments
 (0)