Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplemented static type checking to avl_tree.py #2295
Conversation
TravisBuddy
commented
Aug 10, 2020
|
Hey @anushkrishnav, TravisCI finished with status TravisBuddy Request Identifier: c07007a0-dad8-11ea-bee2-571e9d389dd6 |
| @@ -11,15 +11,15 @@ | |||
|
|
|||
|
|
|||
| class my_queue: | |||
This comment has been minimized.
This comment has been minimized.
cclauss
Aug 10, 2020
Member
| class my_queue: | |
| class MyQueue: |
Proper Python class naming. See CONTRIBUTING.md.
This comment has been minimized.
This comment has been minimized.
anushkrishnav
Aug 10, 2020
Author
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: | |||
This comment has been minimized.
This comment has been minimized.
cclauss
Aug 10, 2020
Member
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)?
This comment has been minimized.
This comment has been minimized.
anushkrishnav
Aug 10, 2020
•
Author
Do you mean a string representation of the object? Thats sounds more reasonable .Wll correct it
This comment has been minimized.
This comment has been minimized.
| def set_data(self, data): | ||
| self.data = data | ||
| def set_data(self, data: int) -> None: | ||
| self.data: int = data |
This comment has been minimized.
This comment has been minimized.
| @@ -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: | |||
This comment has been minimized.
This comment has been minimized.
| 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!") |
This comment has been minimized.
This comment has been minimized.
cclauss
Aug 10, 2020
Member
Algorithmic functions/methods should not print() as discussed in CONTRIBUTING.md. Please raise an appropriate exception instead.
|
AVLTree has doctests but the other classes need them as well as discussed in CONTRIBUTING.md. |
TravisBuddy
commented
Aug 10, 2020
|
Hey @anushkrishnav, TravisCI finished with status TravisBuddy Request Identifier: 07df93f0-daff-11ea-bc40-19e33457b5db |
Okay Working on it |
anushkrishnav commentedAug 10, 2020
•
edited
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 #2293