Skip to content

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

Closed

Conversation

anushkrishnav
Copy link

@anushkrishnav anushkrishnav commented Aug 10, 2020

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains 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

@TravisBuddy
Copy link

Hey @anushkrishnav,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: c07007a0-dad8-11ea-bee2-571e9d389dd6

@@ -11,15 +11,15 @@


class my_queue:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class my_queue:
class MyQueue:

Proper Python class naming. See CONTRIBUTING.md.

Copy link
Author

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:
Copy link
Member

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)?

Copy link
Author

@anushkrishnav anushkrishnav Aug 10, 2020

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

Copy link
Member

@cclauss cclauss Aug 10, 2020

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
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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!")
Copy link
Member

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.

Copy link
Member

@cclauss cclauss left a 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.

@TravisBuddy
Copy link

Hey @anushkrishnav,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 07df93f0-daff-11ea-bc40-19e33457b5db

@anushkrishnav
Copy link
Author

AVLTree has doctests but the other classes need them as well as discussed in CONTRIBUTING.md.

Okay Working on it

@stale
Copy link

stale bot commented Sep 27, 2020

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.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Sep 27, 2020
@stale
Copy link

stale bot commented Oct 4, 2020

Please reopen this issue once you commit the changes requested or make improvements on the code. Thank you for your contributions.

@stale stale bot closed this Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Used to mark an issue or pull request stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants