@@ -164,7 +164,13 @@ def from_dict(cls, **kwargs):
164164 return cls (** kwargs )
165165
166166
167- def ignore_nothing (_ ):
167+ def ignore_nothing (resource , codebase ):
168+ """
169+ Return True if `resource` should be ignored.
170+
171+ This function is used as a callable for `ignored` argument in Codebase and
172+ Resource walk.
173+ """
168174 return False
169175
170176
@@ -775,10 +781,13 @@ def walk(self, topdown=True, skip_root=False, ignored=ignore_nothing):
775781
776782 If `skip_root` is True, the root resource is not returned unless this is
777783 a codebase with a single resource.
784+
785+ `ignored` is a callable that accepts two arguments, `resource` and `codebase`,
786+ and returns True if `resource` should be ignored.
778787 """
779788 root = self .root
780789
781- if ignored (root . path ):
790+ if ignored (root , self ):
782791 return
783792
784793 root = attr .evolve (root )
@@ -1116,17 +1125,21 @@ def walk(self, codebase, topdown=True, ignored=ignore_nothing):
11161125
11171126 Each level is sorted by children sort order (e.g. without-children, then
11181127 with-children and each group by case-insensitive name)
1128+
1129+ `ignored` is a callable that accepts two arguments, `resource` and `codebase`,
1130+ and returns True if `resource` should be ignored.
11191131 """
11201132
11211133 for child in self .children (codebase ):
1122- child = attr .evolve (child )
1123- if topdown and not ignored (child .path ):
1124- yield child
1125- for subchild in child .walk (codebase , topdown = topdown , ignored = ignored ):
1126- if not ignored (subchild .path ):
1127- yield subchild
1128- if not topdown and not ignored (child .path ):
1129- yield child
1134+ if not ignored (child , codebase ):
1135+ child = attr .evolve (child )
1136+ if topdown :
1137+ yield child
1138+ for subchild in child .walk (codebase , topdown = topdown , ignored = ignored ):
1139+ if not ignored (subchild , codebase ):
1140+ yield subchild
1141+ if not topdown :
1142+ yield child
11301143
11311144 def has_children (self ):
11321145 """
0 commit comments