Skip to content

Correct is/is not usage in pt.py to not be used with the value is a literal #1428

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

Merged
merged 1 commit into from
Oct 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/main/java/pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def checkout(args):
else:
branches.append(branch.strip())

if args.patchset is None or args.patchset is 0:
if args.patchset is None or args.patchset == 0:
branch = 'ticket/{:d}'.format(args.id)
illegals = set(branches) & {'ticket'}
else:
Expand All @@ -104,7 +104,7 @@ def checkout(args):
print(' ' + illegal)
exit(errno.EINVAL)

if args.patchset is None or args.patchset is 0:
if args.patchset is None or args.patchset == 0:
# checkout the current ticket patchset
if args.force:
__call(['git', 'checkout', '-B', branch, '{}/{}'.format(args.remote, branch)])
Expand All @@ -131,7 +131,7 @@ def pull(args):
__call(['git', 'reset', '--hard'])

# pull the patchset from the remote repository
if args.patchset is None or args.patchset is 0:
if args.patchset is None or args.patchset == 0:
print("Pulling ticket {} from the '{}' repository".format(args.id, args.remote))
patchset_ref = 'ticket/{:d}'.format(args.id)
else:
Expand Down Expand Up @@ -550,11 +550,11 @@ def __checkout(remote, ticket, patchset, branch, force=False):
else:
# try to merge the existing ref with the FETCH_HEAD
merge = __call(['git', 'merge', '--ff-only', branch, 'FETCH_HEAD'], echo=True, fail=False)
if len(merge) is 1:
if len(merge) == 1:
up_to_date = merge[0].lower().index('up-to-date') > 0
if up_to_date:
return
elif len(merge) is 0:
elif len(merge) == 0:
print('')
print("Your '{}' branch has diverged from patchset {} on the '{}' repository.".format(branch, patchset, remote))
print('')
Expand Down Expand Up @@ -617,13 +617,13 @@ def __call(cmd_args, echo=False, fail=True, err=None):
lines = []
for line in iter(p.stdout.readline, b''):
line_str = str(line).strip()
if len(line_str) is 0:
if len(line_str) == 0:
break
lines.append(line_str)
if echo:
print(line_str)
p.wait()
if fail and p.returncode is not 0:
if fail and p.returncode != 0:
exit(p.returncode)

return lines
Expand Down