Skip to content

added type hints to strings/min_cost_string_conversion.py #2337

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

Conversation

Sonic0588
Copy link
Contributor

@Sonic0588 Sonic0588 commented Aug 18, 2020

Describe your change:

Added static type checking to min_cost_string_conversion.py towards issue #2128.

  • 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.
  • 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.
  • 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}.

@@ -9,7 +11,9 @@
"""


def compute_transform_tables(X, Y, cC, cR, cD, cI):
def compute_transform_tables(
X: str, Y: str, cC: int, cR: int, cD: int, cI: int
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it is just me but I hate these variable names. Uppercase characters are reserved for constants in Python and single letter and double letter variable names are so old school. They look kludgy in modern programming. Why make the caller/reader guess all the time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, agree with you. I've corrected that in the new commit.

Comment on lines 15 to 16
first_string: str,
second_string: str,
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
first_string: str,
second_string: str,
source_string: str,
destination_string: str,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done it

@TravisBuddy
Copy link

Hey @Sonic0588,
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: 6650c3e0-e3bb-11ea-ae1e-a7d25f4a9615

@Sonic0588 Sonic0588 requested a review from cclauss August 26, 2020 18:53
@stale
Copy link

stale bot commented Sep 26, 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 26, 2020
@stale stale bot removed the stale Used to mark an issue or pull request stale. label Sep 26, 2020
Copy link
Member

@poyea poyea left a comment

Choose a reason for hiding this comment

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

Thank you for your pull request!🤩

@poyea
Copy link
Member

poyea commented Oct 1, 2020

It would be even better if you can add a few doctests for this file. Take a look at our Contribution Guidelines and open a new pull request for it, if you want to do so! Thanks.

@poyea poyea merged commit 2388bf4 into TheAlgorithms:master Oct 1, 2020
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
…s#2337)

* done

* add types for local variables

* Revert "add types for local variables"

This reverts commit 971c156.

* rename variables

* Update strings/min_cost_string_conversion.py

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

* rename strings

* use flake8

* Update strings/min_cost_string_conversion.py

Co-authored-by: Christian Clauss <[email protected]>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
…s#2337)

* done

* add types for local variables

* Revert "add types for local variables"

This reverts commit 971c156.

* rename variables

* Update strings/min_cost_string_conversion.py

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

* rename strings

* use flake8

* Update strings/min_cost_string_conversion.py

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.

5 participants