From 124ede7be87e124e08f2edf6c6adf5034095508c Mon Sep 17 00:00:00 2001 From: wobY <24554109+wobYY@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:27:50 +0200 Subject: [PATCH 1/3] Fixes: Issue #1507 --- gspread/client.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gspread/client.py b/gspread/client.py index e82e5be0..03a2b177 100644 --- a/gspread/client.py +++ b/gspread/client.py @@ -329,6 +329,19 @@ def copy( for p in permissions: if p.get("deleted"): continue + + # .list_permissions() returns a list of permissions, + # even the folder permissions if the file is in a shared folder. + # We only want the permissions that are directly applied to the + # spreadsheet file, i.e. 'writer', 'commenter' and 'reader'. + perm_details = { + p_details.get("permissionType"): p_details.get("inherited") + for p_details in p.get("permissionDetails") + } + if p.get("role") in ("organizer", "fileOrganizer") and ( + perm_details.get("file") or perm_details.get("member") + ): + continue # In case of domain type the domain extract the domain # In case of user/group extract the emailAddress From e30c24f78183e210f4110c21fb1f53155669db37 Mon Sep 17 00:00:00 2001 From: alifeee Date: Tue, 24 Sep 2024 18:26:45 +0100 Subject: [PATCH 2/3] run `tox -e format` --- gspread/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gspread/client.py b/gspread/client.py index 03a2b177..1a07bcb8 100644 --- a/gspread/client.py +++ b/gspread/client.py @@ -329,7 +329,7 @@ def copy( for p in permissions: if p.get("deleted"): continue - + # .list_permissions() returns a list of permissions, # even the folder permissions if the file is in a shared folder. # We only want the permissions that are directly applied to the From da5c5a36f67c4d522d5054d48db28294f29e9b0e Mon Sep 17 00:00:00 2001 From: alifeee Date: Tue, 24 Sep 2024 18:30:37 +0100 Subject: [PATCH 3/3] increase maximum allowed lint complexity --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 8e235edc..33c1c198 100644 --- a/tox.ini +++ b/tox.ini @@ -16,7 +16,7 @@ commands = pytest {posargs} tests/ extend-ignore = E203 extend-exclude = .tox,./env,./gspread/__init__.py max-line-length = 255 -max-complexity = 10 +max-complexity = 11 show-source = True statistics = True