-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Python 3 compatibility syntax error fixes #10519
Conversation
""" | ||
(x1, x2) and (y1, y2) are two ranges | ||
if condition x = 100 to 300 | ||
then condition y can only be like 50 to 99 or 301 to 400 | ||
hence, non-overlapping condition = (x1 <= x2 < y1 <= y2) or (y1 <= y2 < x1 <= x2) | ||
""" | ||
(x1, x2), (y1, y2) = x, y | ||
separate = (x1 <= x2 <= y1 <= y2) or (y1 <= y2 <= x1 <= x2) | ||
return (not separate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove redundant parenthesis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess those are necessary there. I can rewrite that as
x1, x2 = x
y1, y2 = y
But not as
(x1, x2), (y1, y2) = x, y
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant in the return statement --> return not separate
instead of return(not separate)
. It's just a code clean up similar to removing the extra spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Will create a separate PR soon for these kind of clean ups.
@@ -54,13 +54,14 @@ def sort_shipping_rule_conditions(self): | |||
d.idx = i + 1 | |||
|
|||
def validate_overlapping_shipping_rule_conditions(self): | |||
def overlap_exists_between((x1, x2), (y1, y2)): | |||
def overlap_exists_between(x, y): | |||
""" | |||
(x1, x2) and (y1, y2) are two ranges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of x and y, use a more descriptive parameter name. Something like num_range1
and num_range2
immediately makes it easy to know what is going on in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -54,13 +54,14 @@ def sort_shipping_rule_conditions(self): | |||
d.idx = i + 1 | |||
|
|||
def validate_overlapping_shipping_rule_conditions(self): | |||
def overlap_exists_between((x1, x2), (y1, y2)): | |||
def overlap_exists_between(x, y): | |||
""" | |||
(x1, x2) and (y1, y2) are two ranges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the documentation as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
How can I make it better than it currently is?
@@ -16,5 +16,5 @@ def execute(): | |||
try: | |||
reset_perms(doctype) | |||
except: | |||
print "Error resetting perms for", doctype | |||
print("Error resetting perms for", doctype) | |||
raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You left this out. raise
in this form is not python 3 compatible. The python 3 compatible form is also not compatible with python 2. However, six is a dependency so use six.reraise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Um. I read accepted answer from this Stack Overflow question. I'm confused.
Anyways. That doesn't really prevent me from running bench --site site1.local install-app erpnext
as of now. I'll tackle that when it becomes a problem. Cool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. You are right. I was wrong. There's nothing wrong with that raise statement
erpnext port
while running
bench --site site1.local install-app erpnext
few syntax errors occur this PR fixes that