Skip to content
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

Add is_hexstr function #183

Merged
merged 13 commits into from Jan 14, 2020
Merged

Conversation

@Swixx
Copy link
Contributor

Swixx commented Dec 27, 2019

What was wrong?

Fixes #137, it was decided that a second function is_hexstr should be added that returns False on any
non-string input call to the function.

How was it fixed?

The specified function was implemented.

To-Do

  • [ X] Clean up commit history

Cute Animal Picture

put a cute animal picture link inside the parentheses

Adam Sawicki added 5 commits Dec 27, 2019
As per #137,
it was decided that a new function should be added with
the signature above that returns 'False' on any non-string
input.

The function has been added with appropiate test cases.
Due to the implementation of `is_hexstr()`, calls
to `is_text` are unneeded that occur before any call
to `is_hexstr()`.
Adam Sawicki
@Swixx Swixx changed the title Add is hexstr function Add is_hexstr function Dec 27, 2019
@pipermerriam pipermerriam requested a review from njgheorghita Dec 31, 2019
Copy link
Contributor

njgheorghita left a comment

🔥 Thanks for taking this on @Swixx ! Just a couple thoughts and then we're good to merge!

  • It can be helpful in the pr descriptions to put fixes #183 instead of per #183 since with fixes it will automatically close the issue once this is merged.
  • If you could update the docs/utilities.rst file to match what's been done in this pr, that'd be great! (eg. note that is_hex is deprecated, and update the is_hex docs to is_hexstr)
newsfragments/137.feature.rst Outdated Show resolved Hide resolved
tests/hexadecimal-utils/test_is_hexstr.py Outdated Show resolved Hide resolved
warnings.warn(
DeprecationWarning(
"is_hex(value: Any) has been deprecated and will be removed in a subsequent major version "
"release of the eth-utils library. Update your calls to use is_hexstr(Any) instead."

This comment has been minimized.

Copy link
@njgheorghita

njgheorghita Jan 6, 2020

Contributor

Nitpick: for consistency with the beginning of the warning msg consider updating to is_hexstr(value: Any)

eth_utils/hexadecimal.py Outdated Show resolved Hide resolved
@carver

This comment has been minimized.

Copy link
Collaborator

carver commented Jan 6, 2020

  • eg. note that is_hex is deprecated

Let's separate that part out into another issue. I think we might want to keep both versions, where is_hex is the stricter option and presumes str. If @Swixx opens another issue for that, then the discussion about keeping it doesn't need to block this PR.

@Swixx

This comment has been minimized.

Copy link
Contributor Author

Swixx commented Jan 8, 2020

@njgheorghita Made the requested changes. Per @carver's, I did not add anything to docs/utilities.rst.

("0xabcdef1234567890", True),
("0xABCDEF1234567890", True),
("0xAbCdEf1234567890", True),
("0XAbCdEf1234567890", True),

This comment has been minimized.

Copy link
@carver

carver Jan 8, 2020

Collaborator

Looks like this line got duplicated

Adam Sawicki
@njgheorghita

This comment has been minimized.

Copy link
Contributor

njgheorghita commented Jan 9, 2020

Let's separate that part out into another issue. I think we might want to keep both versions, where is_hex is the stricter option and presumes str.

There's maybe some confusion around this from @carver's comment, at least there is on my end. I understood "that part" to reference the deprecation of is_hex() in the code - and not the task of updating the docs. eg. We want users to still be able to use is_hex() without seeing a deprecation warning.

If correct, there's a couple last changes - thanks again @Swixx , sorry about the endless nitpicks.

  • remove the deprecation warnings from is_hex() and its corresponding tests
  • update docs/utilities.rst to document is_hexstr() and note why it's different from is_hex() - regardless of whether or not we deprecate is_hex() here, is_hexstr() should be documented

Finally, if you're up for it @Swixx ...

If @Swixx opens another issue for that, then the discussion about keeping it doesn't need to block this PR.

Where you should deprecate is_hex() and its corresponding tests/docs

@carver

This comment has been minimized.

Copy link
Collaborator

carver commented Jan 9, 2020

Yup, thanks for clarifying @njgheorghita -- that's exactly what I meant.

@Swixx

This comment has been minimized.

Copy link
Contributor Author

Swixx commented Jan 12, 2020

@carver will submit tonight. Just so we don't have to do another back and forth, how's the following?

.. note:: 

    This function differs from ``is_hex(value: Any)`` in that it will return
    False on all non-text type arguments, while ``is_hex`` will raise a ``TypeError``
    for all non-text type arguments.
@carver

This comment has been minimized.

Copy link
Collaborator

carver commented Jan 13, 2020

@carver will submit tonight. Just so we don't have to do another back and forth, how's the following?

.. note:: 

    This function differs from ``is_hex(value: Any)`` in that it will return
    False on all non-text type arguments, while ``is_hex`` will raise a ``TypeError``
    for all non-text type arguments.

Yup, looks good!

Adam Sawicki
docs/utilities.rst Outdated Show resolved Hide resolved
Co-Authored-By: Jason Carver <ut96caarrs@snkmail.com>
@carver

This comment has been minimized.

Copy link
Collaborator

carver commented Jan 13, 2020

@njgheorghita after you do your last lookover, no need to wait for me to merge 👍

Copy link
Contributor

njgheorghita left a comment

Excellent, thanks @Swixx !!

@njgheorghita njgheorghita merged commit 8d9f2d7 into ethereum:master Jan 14, 2020
10 checks passed
10 checks passed
ci/circleci: docs Your tests passed on CircleCI!
Details
ci/circleci: lint-py36 Your tests passed on CircleCI!
Details
ci/circleci: lint-py37 Your tests passed on CircleCI!
Details
ci/circleci: lint-py38 Your tests passed on CircleCI!
Details
ci/circleci: py35 Your tests passed on CircleCI!
Details
ci/circleci: py36 Your tests passed on CircleCI!
Details
ci/circleci: py36-typing1 Your tests passed on CircleCI!
Details
ci/circleci: py37 Your tests passed on CircleCI!
Details
ci/circleci: py38 Your tests passed on CircleCI!
Details
ci/circleci: pypy3 Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.