Add DocTests to is_palindrome.py#10081
Conversation
for more information, see https://pre-commit.ci
…om/SaiHarshaK/Python into u/skottapalli/is_palindrome_update
| >>> is_palindrome_dict(\ | ||
| ListNode(\ | ||
| 1, ListNode(2, ListNode(1, ListNode(3, ListNode(2, ListNode(1))))))) |
There was a problem hiding this comment.
PEP8 discourages backslash line termination in Python because any whitespace to the right of the backslash breaks the script on a change that is invisible to the reader. Also, backslashes are not required inside of (), [], {}...
| >>> is_palindrome_dict(\ | |
| ListNode(\ | |
| 1, ListNode(2, ListNode(1, ListNode(3, ListNode(2, ListNode(1))))))) | |
| >>> is_palindrome_dict( | |
| ... ListNode( | |
| ... 1, ListNode(2, ListNode(1, ListNode(3, ListNode(2, ListNode(1))))) | |
| ... ) | |
| ... ) |
There was a problem hiding this comment.
Ruff complains that the length of the line is >88 which is why I had to split them into multiple lines.
If i do not add backslash, DocTest assumes ListNode( is the expected value and thereby the test fails
There was a problem hiding this comment.
You needed the three dots at the beginning of each continued line as discussed in the doctest docs.
Co-authored-by: Christian Clauss <cclauss@me.com>
cclauss
left a comment
There was a problem hiding this comment.
mypy takes some time to get used to but it is quite helpful in the end. If you do new_variable = None then it wants you to declare the datatype of new_variable because it refuses to guess.
|
@cclauss Please check now |
|
Could you check the comment regarding backslashes? |
|
I changed the title from doctests to type hints but this looks good to go... Thanks. |
Describe your change:
This PR adds DocTests to the functions in is_palindrome.py to increase its codecoverage from 0% to 96%.
Tested this change locally and can verify that they are passing.
Ref #9943
Checklist: