Minor refactor for readability
Time: 5.73s => 5.88s/5.82s
This commit is contained in:
parent
a41820fbf0
commit
2b50911c9d
|
@ -533,17 +533,20 @@ class Session(nodes.FSCollector):
|
|||
fil=filter_, rec=self._recurse, bf=True, sort=True
|
||||
):
|
||||
pkginit = path.dirpath().join("__init__.py")
|
||||
if pkginit.exists() and not any(x in parts(pkginit.strpath) for x in paths):
|
||||
if pkginit.exists() and not any(
|
||||
x in parts(pkginit.strpath) for x in paths
|
||||
):
|
||||
for x in root._collectfile(pkginit):
|
||||
yield x
|
||||
paths.append(x.fspath.dirpath())
|
||||
|
||||
if not any(x in parts(path.strpath) for x in paths):
|
||||
for x in root._collectfile(path):
|
||||
if (type(x), x.fspath) in self._node_cache:
|
||||
yield self._node_cache[(type(x), x.fspath)]
|
||||
key = (type(x), x.fspath)
|
||||
if key in self._node_cache:
|
||||
yield self._node_cache[key]
|
||||
else:
|
||||
self._node_cache[(type(x), x.fspath)] = x
|
||||
self._node_cache[key] = x
|
||||
yield x
|
||||
else:
|
||||
assert argpath.check(file=1)
|
||||
|
|
|
@ -563,6 +563,10 @@ class Package(Module):
|
|||
yield Module(init_module, self)
|
||||
pkg_prefixes = set()
|
||||
for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
|
||||
# We will visit our own __init__.py file, in which case we skip it.
|
||||
if path.isfile():
|
||||
if path.basename == "__init__.py" and path.dirpath() == this_path:
|
||||
continue
|
||||
|
||||
parts_ = parts(path.strpath)
|
||||
if any(
|
||||
|
|
Loading…
Reference in New Issue