-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Implemented static type checking to avl_tree.py #2295
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
Implemented static type checking to avl_tree.py #2295
Conversation
Hey @anushkrishnav, TravisCI finished with status TravisBuddy Request Identifier: c07007a0-dad8-11ea-bee2-571e9d389dd6 |
@@ -11,15 +11,15 @@ | |||
|
|||
|
|||
class my_queue: |
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.
class my_queue: | |
class MyQueue: |
Proper Python class naming. See CONTRIBUTING.md.
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 just implemented the static type checking on an exsisting document in the repo . But I would do the suggested changes .
@@ -31,18 +31,22 @@ def pop(self): | |||
def count(self): | |||
return self.tail - self.head | |||
|
|||
def print(self): | |||
def print(self) -> None: |
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.
This is a bad method name because it shadows a Python builtin function. Why not rename this to str() and then just print(my_queue_instance)
?
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.
Do you mean a string representation of the object? Thats sounds more reasonable .Wll correct it
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.
def set_data(self, data): | ||
self.data = data | ||
def set_data(self, data: int) -> None: | ||
self.data: int = data |
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.
Not required because of the previous line.
@@ -31,18 +31,22 @@ def pop(self): | |||
def count(self): | |||
return self.tail - self.head | |||
|
|||
def print(self): | |||
def print(self) -> None: | |||
print(self.data) | |||
print("**************") | |||
print(self.data[self.head : self.tail]) | |||
|
|||
|
|||
class my_node: |
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.
class my_node: | |
class Node: |
print("insert:" + str(data)) | ||
self.root = insert_node(self.root, data) | ||
|
||
def del_node(self, data): | ||
def del_node(self, data: int) -> None: | ||
print("delete:" + str(data)) | ||
if self.root is None: | ||
print("Tree is empty!") |
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.
Algorithmic functions/methods should not print() as discussed in CONTRIBUTING.md. Please raise an appropriate exception instead.
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.
AVLTree has doctests but the other classes need them as well as discussed in CONTRIBUTING.md.
Hey @anushkrishnav, TravisCI finished with status TravisBuddy Request Identifier: 07df93f0-daff-11ea-bc40-19e33457b5db |
Okay Working on it |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Please reopen this issue once you commit the changes requested or make improvements on the code. Thank you for your contributions. |
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.I am more than willing to implement static type checking for other program files too . I was inspired by PR adding static type checking to basic_binary_tree.py #2293