Skip to content

Corrected filename and include static types #2440

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

Merged
merged 4 commits into from
Sep 17, 2020

Conversation

NumberPiOso
Copy link
Contributor

@NumberPiOso NumberPiOso commented Sep 16, 2020

continuing in line with #2128.

My first time contributing code to open source so criticism is encouraged.

  • The name of the file is now compliant with python naming conventions
  • Add static type as stated in contributing guidelines

Describe your change:

  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I 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.

- The name of the file is now compliant with python naming conventions
- Add static type as stated in contributing guidelines
@spamegg1
Copy link
Contributor

spamegg1 commented Sep 16, 2020

Hi @NumberPiOso ,
It says you deleted the file, and rewrote it from scratch? It would have been better if you just edited it line by line so we could easily see the differences under "Files changed."

Also I see that you included type hints for some variables too. Like:

user_input: str = input("Enter numbers separated by comma:\n").strip()
sequence: List[int] = [int(item.strip()) for item in user_input.split(",")]

etc.

I think CONTRIBUTING.md says to provide type hints only for the input parameters and return values of functions and nothing else, because it causes too much visual clutter and Python is smart enough to figure it out. (There might be some exceptions to this but I don't know.)

Good luck and happy coding!

>>> print(binary_search(test_list, 3))
False
>>> print(binary_search(test_list, 13))
True
Copy link
Member

@cclauss cclauss Sep 16, 2020

Choose a reason for hiding this comment

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

Please add tests for negative integers, floats, repeated numbers, letters, empty list, single element list.

@NumberPiOso
Copy link
Contributor Author

Hi @spamegg1

It says you deleted the file, and rewrote it from scratch? It would have been better if you just edited it line by line so we could easily see the differences under "Files changed."

It is because the other file was named simple-binary-search.py so I renamed it to simple_binary_search.py

I did it using git mv, is there any other way to do this in order for github to show us the differences?

Also I see that you included type hints for some variables too. Like:

user_input: str = input("Enter numbers separated by comma:\n").strip()
sequence: List[int] = [int(item.strip()) for item in user_input.split(",")]

etc.

I think CONTRIBUTING.md says to provide type hints only for the input parameters and return values of functions and nothing else, because it causes too much visual clutter and Python is smart enough to figure it out. (There might be some exceptions to this but I don't know.)

Totally agreed, I will correct it.

Thank you.

NumberPiOso and others added 3 commits September 16, 2020 17:46
- Delete documentation line to run doctests
- Delete type hints for variables that comes from functions

Co-authored-by: Christian Clauss <[email protected]>
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.

LGTM. It would be easier to review as two PRs. One that changed the filename and the other that changed the file contents.

@cclauss cclauss merged commit 86fb299 into TheAlgorithms:master Sep 17, 2020
@NumberPiOso NumberPiOso deleted the update_binary branch September 17, 2020 14:30
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* Corrected name and include static types

- The name of the file is now compliant with python naming conventions
- Add static type as stated in contributing guidelines

* Apply suggestions from code review

- Delete documentation line to run doctests
- Delete type hints for variables that comes from functions

Co-authored-by: Christian Clauss <[email protected]>

* Add edge cases tests.

* print(f"{target} was {not_str}found in {sequence}")

Co-authored-by: Christian Clauss <[email protected]>
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.

3 participants