summaryrefslogtreecommitdiff
path: root/coverage/files.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-11-17 06:59:15 -0500
committerNed Batchelder <ned@nedbatchelder.com>2022-11-17 06:59:15 -0500
commit709c7443e30b20226c4fb61acaf47de529a7688c (patch)
treee8dfee5a7feeabaac8da847f83b18de825f0f9d9 /coverage/files.py
parent26445508a2eb1c7ef459a33ec058eb3f3c5b41dd (diff)
downloadpython-coveragepy-git-709c7443e30b20226c4fb61acaf47de529a7688c.tar.gz
refactor, docs: clean-up for #1387
Diffstat (limited to 'coverage/files.py')
-rw-r--r--coverage/files.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/coverage/files.py b/coverage/files.py
index 8be292f3..f016a32e 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -470,14 +470,20 @@ def find_python_files(dirname, include_namespace_packages):
best, but sub-directories are checked for a __init__.py to be sure we only
find the importable files.
+ If `include_namespace_packages` is True, then the check for __init__.py
+ files is skipped.
+
+ Files with strange characters are skipped, since they couldn't have been
+ imported, and are probably editor side-files.
+
"""
for i, (dirpath, dirnames, filenames) in enumerate(os.walk(dirname)):
- if (i > 0 and '__init__.py' not in filenames
- and not include_namespace_packages):
- # If a directory doesn't have __init__.py, then it isn't
- # importable and neither are its files
- del dirnames[:]
- continue
+ if not include_namespace_packages:
+ if i > 0 and "__init__.py" not in filenames:
+ # If a directory doesn't have __init__.py, then it isn't
+ # importable and neither are its files
+ del dirnames[:]
+ continue
for filename in filenames:
# We're only interested in files that look like reasonable Python
# files: Must end with .py or .pyw, and must not have certain funny