Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor for PermissionsGroup called improperly for declaration #137

Open
brunson opened this issue Mar 28, 2019 · 1 comment
Open

Constructor for PermissionsGroup called improperly for declaration #137

brunson opened this issue Mar 28, 2019 · 1 comment

Comments

@brunson
Copy link

brunson commented Mar 28, 2019

Here you can see a call to get_permissions_groups() makes a subsequent call internal to the module that passes group_name and keyword args to PermissionsGroup.init() in a manner incompatible with the declaration:

  File "/Users/eric.brunson/myproject/dyn.py", line 26, in get_data
    for group in get_permissions_groups():
  File "/Users/eric.brunson/src/github.com/dyn-python/dyn/tm/accounts.py", line 95, in get_permissions_groups
    groups.append(PermissionsGroup(None, api=False, **group))
TypeError: __init__() got multiple values for argument 'group_name'

This patch works around it. I initially changed to call signature, but that could break 3rd party code so went with this:

$ git diff
diff --git a/dyn/tm/accounts.py b/dyn/tm/accounts.py
index 64b1772..9c5ab0f 100644
--- a/dyn/tm/accounts.py
+++ b/dyn/tm/accounts.py
@@ -92,7 +92,12 @@ def get_permissions_groups(search=None):
     response = DynectSession.get_session().execute(uri, 'GET', api_args)
     groups = []
     for group in response['data']:
-        groups.append(PermissionsGroup(None, api=False, **group))
+        if 'group_name' in group:
+            group_name = group.pop('group_name')
+        else:
+            group_name = None
+        groups.append(PermissionsGroup(group_name, api=False, **group))
     if search is not None:
         original = groups
         groups = []
@gdelaney
Copy link

I recently his this issue on python3. Applied the patch provided and it resolved it. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants