Skip to content

Inconsistent Tree.__contains__ / Tree.__getitem__ behaviour #851

Open
@ei-grad

Description

@ei-grad

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions