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

TypeError: unhashable type: 'slice' #36

Closed
realcr opened this issue Jun 10, 2016 · 3 comments
Closed

TypeError: unhashable type: 'slice' #36

realcr opened this issue Jun 10, 2016 · 3 comments

Comments

@realcr
Copy link

realcr commented Jun 10, 2016

Hi Jab, thank you for this great package.

I recently upgraded my bidict to version 11.0 from an older version (bidict==0.9.0.post1), and all of my tests broke.

It seems like the syntax bd[:some_key] is not working anymore.

>>> import bidict
>>> bd = bidict.bidict()
>>> bd["hello"] = "world"
>>> bd[:"world"]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/real/.virtualenvs/wchat/lib/python3.4/site-packages/bidict/_common.py", line 57, in __getitem__
    return self._fwd[key]
TypeError: unhashable type: 'slice'

Is this behaviour intentional? I just checked at the docs and it seems like any mention of this syntax is gone.

@jab
Copy link
Owner

jab commented Jun 10, 2016

Hi @realcr, sorry you were bitten by the breaking changes! Yes, after careful consideration and discussion in #19, the slice syntax was removed in 0.10.0, and I definitely made sure to document this prominently, see http://bidict.readthedocs.io/en/v0.10.0.post1/changelog.html#breaking-api-changes

If you'd like to upgrade to the latest, I hope it isn't too hard to replace your b[:foo] references with b.inv[foo].

So happy to hear you find bidict useful. By the way, if you'd like to share your use case, I'm always interested to better understand how people are using bidict, and how it could meet their needs better. On that note, I've been working hard on a new release, and am excited to see how people like it. Please feel free to join us on gitter if you're interested (very low activity), where I announce things like new releases (and by default Gitter will email you about mentions you missed).

@jab jab closed this as completed Jun 10, 2016
@realcr
Copy link
Author

realcr commented Jun 10, 2016

Hi Jab, I just fixed all my code to use the new b.inv syntax, and it works perfectly, thank you.
I should have noticed the changes. I was disconnected from Pypi for a while :)

I use bdict for lots of small things inside my python modules. I recently used it for a ticketing system, and before I used it to match between message name and message id in a lower level messaging protocol used with asyncio. I think bdict is a much cleaner solution that the good old two dictionaries with duct tape around them.

@jab
Copy link
Owner

jab commented Jun 11, 2016

Glad you were able to get your code working again so quickly! And thanks for sharing your use cases, so great to hear bidict has offered you a cleaner solution than the old two-dict approach.

By the way, I made a bunch more progress today on the soon-to-be-released version, and would love to hear what you think. The latest summary of the changes can be found here:
https://bidict.readthedocs.io/en/dev/changelog.html
And a little more explanation of some of the new safety features can be found here:
http://bidict.readthedocs.io/en/dev/basic-usage.html#uniqueness-of-values
If you have any thoughts, please don't hesitate to share them in https://gitter.im/jab/bidict or https://gitter.im/jab.
Thanks for using bidict!

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

2 participants