summaryrefslogtreecommitdiff
path: root/coverage
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
parent26445508a2eb1c7ef459a33ec058eb3f3c5b41dd (diff)
downloadpython-coveragepy-git-709c7443e30b20226c4fb61acaf47de529a7688c.tar.gz
refactor, docs: clean-up for #1387
Diffstat (limited to 'coverage')
-rw-r--r--coverage/control.py2
-rw-r--r--coverage/files.py18
2 files changed, 13 insertions, 7 deletions
diff --git a/coverage/control.py b/coverage/control.py
index a955c283..7315fb39 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -530,7 +530,7 @@ class Coverage:
self._inorout = InOrOut(
warn=self._warn,
debug=(self._debug if self._debug.should('trace') else None),
- include_namespace_packages=self.config.include_namespace_packages
+ include_namespace_packages=self.config.include_namespace_packages,
)
self._inorout.configure(self.config)
self._inorout.plugins = self._plugins
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