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

Inconsistent Tree.__contains__ / Tree.__getitem__ behaviour #851

Open
ei-grad opened this issue Mar 8, 2019 · 2 comments
Open

Inconsistent Tree.__contains__ / Tree.__getitem__ behaviour #851

ei-grad opened this issue Mar 8, 2019 · 2 comments

Comments

@ei-grad
Copy link

ei-grad commented Mar 8, 2019

The fe5289e introduced the Tree.__contains__ behaviour change, which is inconsistent with Tree.__getitem__ behaviour. I couldn't find a proper explanation for a such change, so it looks like a bug for me:

ipdb> p tree.path                                                                                                                                                                                                   
'data_dir'
ipdb> p [i.name for i in tree]                                                                                                                                                                                      
['data_sub_dir']
ipdb> p tree['data_sub_dir']                                                                                                                                                                                        
<git.Tree "43420912747f332d8bbd0859003a032a301ebbd6">
ipdb> p 'data_sub_dir' in tree                                                                                                                                                                                      
False
ipdb> p 'data_dir/data_sub_dir' in tree                                                                                                                                                                             
True

Not sure if this could be fixed now due to compatibility reasons, but if so, could there be a better workaround than iterating over Tree._cache?

@Byron
Copy link
Member

Byron commented Jul 20, 2019

Thanks for bringing this up! It's a bit disturbing to see the referenced commit was created by me just... 9 years ago!

To me, it also looks like a bug! The behaviour I would expect is 'data_sub_dir' in tree to be true and the other one to be false.

@bazilek
Copy link

bazilek commented Apr 13, 2020

any ideas how to address the cache issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants