Skip to content

Commit 34b7854

Browse files
committed
Workaround typing issues with reserved names
1 parent 83aa5f3 commit 34b7854

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pulp-glue/pulp_glue/common/context.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ def list_iterator(
890890
if response["next"] is None:
891891
break
892892

893-
def list(self, limit: int, offset: int, parameters: t.Dict[str, t.Any]) -> t.List[t.Any]:
893+
def _list(self, limit: int, offset: int, parameters: t.Dict[str, t.Any]) -> t.List[t.Any]:
894894
"""
895895
List entities by the type of this context.
896896
@@ -1284,6 +1284,11 @@ def needs_capability(self, capability: str) -> None:
12841284
)
12851285
)
12861286

1287+
# "list" should be a reserverd word in Python...
1288+
# In this scope, we want to use the global "list" for typing hints.
1289+
list = _list
1290+
del _list
1291+
12871292

12881293
class PulpRemoteContext(PulpEntityContext):
12891294
"""

pulp-glue/pulp_glue/core/context.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class PulpTaskContext(PulpEntityContext):
398398

399399
resource_context: t.Optional[PulpEntityContext] = None
400400

401-
def list(self, limit: int, offset: int, parameters: t.Dict[str, t.Any]) -> t.List[t.Any]:
401+
def _list(self, limit: int, offset: int, parameters: t.Dict[str, t.Any]) -> t.List[t.Any]:
402402
if (
403403
parameters.get("logging_cid") is not None
404404
or parameters.get("logging_cid__contains") is not None
@@ -492,6 +492,11 @@ def summary(self) -> t.Dict[str, int]:
492492
result[state] = self.call("list", parameters=payload)["count"]
493493
return result
494494

495+
# "list" should be a reserverd word in Python...
496+
# In this scope, we want to use the global "list" for typing hints.
497+
list = _list
498+
del _list
499+
495500

496501
class PulpTaskGroupContext(PulpEntityContext):
497502
ENTITY = _("task group")

0 commit comments

Comments
 (0)