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

Invalid strings don't cause any sort of error #57

Closed
Qix- opened this issue Apr 17, 2021 · 6 comments
Closed

Invalid strings don't cause any sort of error #57

Qix- opened this issue Apr 17, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@Qix-
Copy link

Qix- commented Apr 17, 2021

Hi there - firstly, thank you for saving me days of work with this library <3 Hugely appreciated, and it's very well done.

In the following, no error is produced:

import portion as P

ival = P.from_string('[10, 20] | 25', int)
print(ival) #-> "[10,20]"

Would it be possible to produce an error if there is unexpected input? Or, alternatively, would it be possible to have a check_string(s) function that performed a full-string match based on the same parameters?

As of right now, the invalid | 25 gets swallowed.

Thanks for any information!

@AlexandreDecan AlexandreDecan added the bug Something isn't working label Apr 17, 2021
@AlexandreDecan
Copy link
Owner

Hello,

Thanks for reporting this bug! Indeed, the function should raise an error in that case. I'll have a look at why it doesn't and try to fix it.

@AlexandreDecan
Copy link
Owner

I found what went wrong, and I added some checks that raise a ValueError if the interval cannot be parsed correctly.
This will be part of next patch release. Since I was working on using poetry instead of setuptools to manage portion, I'll release both changes at the same time. Expect some delay (a few days at most) depending on how successful I was to integrate poetry :-)

@Qix-
Copy link
Author

Qix- commented Apr 17, 2021

Sounds good, thanks for the quick response!

@AlexandreDecan
Copy link
Owner

You're welcome ;)

I'll update this issue as soon as the fix is available on PyPI.

@AlexandreDecan
Copy link
Owner

Release 2.1.6 will be available on PyPI in a few minutes.

@Qix-
Copy link
Author

Qix- commented Apr 17, 2021

Thanks! That's awesome, I appreciate it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants