Skip to content

Commit

Permalink
fix: make timeout an optional positional arg [(#3938)](GoogleCloudPla…
Browse files Browse the repository at this point in the history
…tform/python-docs-samples#3938)

* fix: make timeout an optional positional arg

* place `none` back in function signature

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
  • Loading branch information
2 people authored and plamut committed Jul 10, 2020
1 parent 3d7b503 commit 88090bd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions samples/snippets/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,22 +678,24 @@ def callback(message):

receive_parser = subparsers.add_parser("receive", help=receive_messages.__doc__)
receive_parser.add_argument("subscription_name")
receive_parser.add_argument("--timeout", default=None, type=float)
receive_parser.add_argument("timeout", default=None, type=float, nargs="?")

receive_with_custom_attributes_parser = subparsers.add_parser(
"receive-custom-attributes",
help=receive_messages_with_custom_attributes.__doc__,
)
receive_with_custom_attributes_parser.add_argument("subscription_name")
receive_with_custom_attributes_parser.add_argument(
"--timeout", default=None, type=float
"timeout", default=None, type=float, nargs="?"
)

receive_with_flow_control_parser = subparsers.add_parser(
"receive-flow-control", help=receive_messages_with_flow_control.__doc__
)
receive_with_flow_control_parser.add_argument("subscription_name")
receive_with_flow_control_parser.add_argument("--timeout", default=None, type=float)
receive_with_flow_control_parser.add_argument(
"timeout", default=None, type=float, nargs="?"
)

synchronous_pull_parser = subparsers.add_parser(
"receive-synchronously", help=synchronous_pull.__doc__
Expand All @@ -710,15 +712,17 @@ def callback(message):
"listen-for-errors", help=listen_for_errors.__doc__
)
listen_for_errors_parser.add_argument("subscription_name")
listen_for_errors_parser.add_argument("--timeout", default=None, type=float)
listen_for_errors_parser.add_argument(
"timeout", default=None, type=float, nargs="?"
)

receive_messages_with_delivery_attempts_parser = subparsers.add_parser(
"receive-messages-with-delivery-attempts",
help=receive_messages_with_delivery_attempts.__doc__,
)
receive_messages_with_delivery_attempts_parser.add_argument("subscription_name")
receive_messages_with_delivery_attempts_parser.add_argument(
"--timeout", default=None, type=float
"timeout", default=None, type=float, nargs="?"
)

args = parser.parse_args()
Expand Down

0 comments on commit 88090bd

Please sign in to comment.