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

Utils: reject empty input in get_yields #1314

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

jayaddison
Copy link
Collaborator

Resolves #1313.

@jknndy
Copy link
Collaborator

jknndy commented Oct 21, 2024

When I apply these changes to #1307 test case _3 is still expecting 0 servings . Not sure what's causing it yet

@jayaddison
Copy link
Collaborator Author

Ah, I think it's that this str(...) typecast turns a None value into the string 'None'.

That input -- and a bunch of other nonsense inputs, seem to return 0 servings:

>>> from recipe_scrapers._utils import get_yields
>>> get_yields('None')
'0 servings'
>>> get_yields('N one')
'0 servings'
>>> get_yields('N')
'0 servings'
>>> get_yields('n')
'0 servings'
>>> get_yields('adsf')
'0 servings'

@jayaddison
Copy link
Collaborator Author

I think we can prevent the typecasting of None to 'None' -- but I can't think of an easy way to validate other non-empty strings.

@jayaddison jayaddison merged commit c0a9bb6 into main Oct 22, 2024
19 checks passed
@jayaddison jayaddison deleted the issue-1313/get-yields-empty-string branch October 22, 2024 22:55
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.

Bug: get_yields utility function returns zero for an empty string input
2 participants