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

Not composable: maybe([None])[0].is_none() #8

Open
nyanpasu64 opened this issue Dec 9, 2018 · 2 comments
Open

Not composable: maybe([None])[0].is_none() #8

nyanpasu64 opened this issue Dec 9, 2018 · 2 comments

Comments

@nyanpasu64
Copy link

nyanpasu64 commented Dec 9, 2018

  • Kubuntu 18.04 x64
  • Anaconda 3.6, pip install pymaybe
  • maybe([None])[0].is_none() is True.
  • maybe([None])[0].get() raises Exception, despite [None][0] is None.
  • maybe({'a': None})['a'].get() raises Exception, despite {'a': None}['a'] is None.

https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/

Despite being a maybe "implementation", this library fails to distinguish a missing element from a deliberate None value.

@akazukin5151
Copy link

Just change this to return Nothing()

def get(self):
raise NothingValueError('No such element')

Seems like you're supposed to use the or_else() method instead of get(), but then why provide a get() method anyway?

@georgipopovhs
Copy link

There is a similar issue also with obj.member = None; maybe(obj).member.get().
I think the root cause is maybe(None).get() raises.
To me it's more logical to have maybe(None).get() == None.
This can be done if we update the code to have maybe(None) == Something(None).

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

No branches or pull requests

3 participants