Skip to content

Commit f5f6b26

Browse files
committed
#102 generate.py: Directory.walk: Add comments to explain what @overload is doing here
1 parent af2e123 commit f5f6b26

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bin/generate.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,8 @@ def __init__(
12291229
self.path,
12301230
)
12311231

1232+
# The @overload definitions are purely here for static typing reasons.
1233+
# This overload takes a single function as argument, which is used for both files and directories.
12321234
@overload
12331235
def walk(
12341236
self,
@@ -1237,6 +1239,7 @@ def walk(
12371239
dir_last=False,
12381240
): ...
12391241

1242+
# This overload takes one function for test cases and a separate function for directories.
12401243
@overload
12411244
def walk(
12421245
self,
@@ -1246,6 +1249,9 @@ def walk(
12461249
dir_last=False,
12471250
): ...
12481251

1252+
# Below is the actual implementation of `walk`,
1253+
# no parameter types are needed here because they are already defined by the @overloads.
1254+
12491255
# Map a function over all test cases directory tree.
12501256
# dir_f by default reuses testcase_f
12511257
def walk(self, testcase_f=None, dir_f=True, *, dir_last=False):

0 commit comments

Comments
 (0)