Skip to content

Sourcery refactored main branch#1

Open
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main
Open

Sourcery refactored main branch#1
sourcery-ai[bot] wants to merge 1 commit intomainfrom
sourcery/main

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Nov 25, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from dongjin2008 November 25, 2023 19:26
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -21 to +28
if node.left is not None:
self._add(data, node.left)
else:
if node.left is None:
node.left = Node(data)
else:
if node.right is not None:
self._add(data, node.right)
else:
node.right = Node(data)
self._add(data, node.left)
elif node.right is not None:
self._add(data, node.right)
else:
node.right = Node(data)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Tree._add refactored with the following changes:

Comment on lines -33 to +32
if self.root is not None:
return self._find(data, self.root)
else:
return None
return self._find(data, self.root) if self.root is not None else None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Tree.find refactored with the following changes:

Comment on lines -58 to +54
print(str(node.data) + ' ')
print(f'{str(node.data)} ')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Tree._printTree refactored with the following changes:

Comment on lines -28 to +36
output = ""
output = ""
string = string.lower()
string = string.strip()
if string == "":
if not (string := string.strip()):
return(self.blank_string)
else:
for c in string:
for k,v in self.key.items():
if v == c:
output += k

for c in string:
for k,v in self.key.items():
if v == c:
output += k

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main.decrypt_string refactored with the following changes:

(x,y) = caterpillar.pos()
outside = x < left_wall or x > right_Wall or y > top_wall or y < bottom_wall
return outside
return x < left_wall or x > right_Wall or y > top_wall or y < bottom_wall
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function outside_window refactored with the following changes:

Comment on lines -83 to +97
c.itemconfigure(score_text , text='Score : ' + str(score))
c.itemconfigure(score_text, text=f'Score : {str(score)}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function increase_score refactored with the following changes:

Comment on lines -7 to +8

if(re.fullmatch(regex, email)):
return True
else:
return False

return bool((re.fullmatch(regex, email)))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function isValidEmail refactored with the following changes:

Comment on lines -16 to +13
username = email[0:email.index('@')]
username = email[:email.index('@')]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 16-16 refactored with the following changes:

Comment on lines -6 to +10
cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
f"{cv2.data.haarcascades}haarcascade_frontalface_default.xml"
)
body_cascade = cv2.CascadeClassifier(
cv2.data.haarcascades + "haarcascade_fullbody.xml")
f"{cv2.data.haarcascades}haarcascade_fullbody.xml"
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 6-8 refactored with the following changes:

blur = cv2.GaussianBlur(gray, (5, 5), 0)
canny = cv2.Canny(blur, 50, 150)
return canny
return cv2.Canny(blur, 50, 150)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function canny refactored with the following changes:

Comment on lines -65 to +64
masked_image = cv2.bitwise_and(image, mask)
return masked_image
return cv2.bitwise_and(image, mask)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function roi refactored with the following changes:

Comment on lines +8 to +12
missed = 0
while len(word) > 0:
main = ""
missed = 0
for letter in word:
if letter in guessmade:
main = main + letter
else:
main = main + "_" + " "
main = main + letter if letter in guessmade else f"{main}_ "
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function hangman refactored with the following changes:

player.y += player_speed
if player.top <= 0:
player.top = 0
player.top = max(player.top, 0)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function player_movement refactored with the following changes:

Comment on lines -38 to +37
if opponent.top <= 0:
opponent.top = 0
opponent.top = max(opponent.top, 0)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function opponent_ai refactored with the following changes:

Comment on lines -4 to +12
for i in range(4):
for _ in range(4):
n = input("Enter noun : ")
noun.append(n)
plural = []
for i in range(6):
for _ in range(6):
pn = input("Enter plural noun : ")
plural.append(pn)
adjective = []
for i in range(2):
for _ in range(2):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 4-23 refactored with the following changes:

parameters = (self.name.get(), self.price.get())
self.run_query(query, parameters)
self.message['text'] = 'Product {} added Successfully'.format(self.name.get())
self.message['text'] = f'Product {self.name.get()} added Successfully'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Product.add_product refactored with the following changes:

query = 'DELETE FROM product WHERE name = ?'
self.run_query(query, (name, ))
self.message['text'] = 'Record {} deleted Successfully'.format(name)
self.message['text'] = f'Record {name} deleted Successfully'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Product.delete_product refactored with the following changes:

self.run_query(query, parameters)
self.edit_wind.destroy()
self.message['text'] = 'Record {} updated successfylly'.format(name)
self.message['text'] = f'Record {name} updated successfylly'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Product.edit_records refactored with the following changes:


# If there is no data, we add the value in the top element and return
if self.top == None:
if self.top is None:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Stack.push refactored with the following changes:

def pop(self):
# If there is no data in the top node, we return
if self.top == None:
if self.top is None:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Stack.pop refactored with the following changes:

Comment on lines -11 to +22
while i < (num + 1) :
while i < k + 1:
print(" " * k, end = "")
j = 0

while j <= t:
print("*", "", end="")
j = j + 1
i = i + 1
j += 1

i += 1
t = t + 1
k = k - 1
k -= 1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 11-22 refactored with the following changes:

def generate_board(num):
base = 3
side = base * base
side = base**2
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function generate_board refactored with the following changes:

This removes the following comments ( why? ):

# default number of empty slots
# given number of empty slots

Comment on lines -85 to +80
print(str(bo[i][j]) + " ", end="")
print(f"{str(bo[i][j])} ", end="")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function print_board refactored with the following changes:

Comment on lines -126 to -132
# searching for next empty solt
slot = next_empty(bo)
if not slot:
if slot := next_empty(bo):
row, col = slot
else:
# return True if there is no empty slot
return True
else:
row, col = slot
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function solve refactored with the following changes:

This removes the following comments ( why? ):

# searching for next empty solt

Comment on lines -333 to +351
return

else:
if action == 'inspect':
print("\n" + ZONE_MAP[player.location]["DESCRIPTION"])
return

elif action == 'examine' or action == 'interact':
print("\n" + ZONE_MAP[player.location]["EXAMINATION"])
return

elif action == 'look':
elif action == 'inspect':
print("\n" + ZONE_MAP[player.location]["DESCRIPTION"])
elif action in ['examine', 'interact']:
print("\n" + ZONE_MAP[player.location]["EXAMINATION"])
elif action == 'look':
# Display effects if there are any.
if len(player.effects) > 0:
print("\nYou have entitled with the following effects:")
for effect in player.effects:
sys.stdout.write("\t" + effect + "\n")
sys.stdout.flush()
time.sleep(0.5)

return
if len(player.effects) > 0:
print("\nYou have entitled with the following effects:")
for effect in player.effects:
sys.stdout.write("\t" + effect + "\n")
sys.stdout.flush()
time.sleep(0.5)

else:
print("\nYou have no effects.\n")
return
else:
print("\nYou have no effects.\n")
else:
print("\nI don't understand that command.\nPlease enter a valid command. ⚠️\n")

else:
print("\nI don't understand that command.\nPlease enter a valid command. ⚠️\n")
return
return
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function player_interact refactored with the following changes:

Comment on lines -173 to +160
else :
else:
if TieGame():
print("Tie Game")
x = input("Do you want to play again? (y/n)")
if x.lower() == 'y' or x.lower() =='yes':
if x.lower() in ['y', 'yes']:
StartTheGame()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 173-179 refactored with the following changes:


possible_words = []

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function find_possible_words refactored with the following changes:

Comment on lines -52 to +45
for i in range(6):

return(possible_words)
for _ in range(6):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 52-69 refactored with the following changes:

else:
score += 3

score += random.randint(5,10) if answer == "2" else 3
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 42-204 refactored with the following changes:

ret += " "
else:
ret += tmp + " "
ret += f"{tmp} "
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parse_infix refactored with the following changes:

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.

0 participants