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

Resolve "possibly unbound" error #2

Merged
merged 1 commit into from
Nov 8, 2023
Merged

Resolve "possibly unbound" error #2

merged 1 commit into from
Nov 8, 2023

Conversation

EarlMilktea
Copy link
Contributor

PR for grover.py

Problem description

Variable n can be unbound if len(sys.argv) is neither 1 nor 3.

import sys

if len(sys.argv) == 1:
    n = 4
    target = q.util.str2binary("0101")
elif len(sys.argv) == 3:
    n = int(sys.argv[1])
    target = q.util.str2binary(sys.argv[2])
# NG!

Fix

raise ValueError if that occurs.

@wistaria wistaria merged commit 06def83 into wistaria:main Nov 8, 2023
4 checks passed
@EarlMilktea EarlMilktea deleted the fix-error branch November 8, 2023 11:37
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

Successfully merging this pull request may close these issues.

2 participants