Skip to content

Commit b115ed3

Browse files
committed
refactor: keep Analysis private
1 parent 40a052e commit b115ed3

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

coverage/control.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ def analysis2(
922922
coverage data.
923923
924924
"""
925-
analysis = self.analyze(morf)
925+
analysis = self._analyze(morf)
926926
return (
927927
analysis.filename,
928928
sorted(analysis.statements),
@@ -931,8 +931,8 @@ def analysis2(
931931
analysis.missing_formatted(),
932932
)
933933

934-
def analyze(self, morf: TMorf) -> Analysis:
935-
"""A public API for getting Analysis. TODO!!! """
934+
def _analyze(self, morf: TMorf) -> Analysis:
935+
"""Analyze a module or file. Private for now."""
936936
self._init()
937937
self._post_init()
938938

coverage/report_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_analysis_to_report(
9797

9898
for fr, morf in sorted(fr_morfs):
9999
try:
100-
analysis = coverage.analyze(morf)
100+
analysis = coverage._analyze(morf)
101101
except NotPython:
102102
# Only report errors for .py files, and only if we didn't
103103
# explicitly suppress those errors.

tests/coveragetest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def check_coverage(
209209
del sys.modules[modname]
210210

211211
# Get the analysis results, and check that they are right.
212-
analysis = cov.analyze(mod)
212+
analysis = cov._analyze(mod)
213213
statements = sorted(analysis.statements)
214214
if lines:
215215
if isinstance(lines[0], int):
@@ -513,7 +513,7 @@ def get_missing_arc_description(self, cov: Coverage, start: TLineNo, end: TLineN
513513
assert self.last_module_name is not None
514514
filename = self.last_module_name + ".py"
515515
fr = cov._get_file_reporter(filename)
516-
arcs_executed = cov.analyze(filename).arcs_executed
516+
arcs_executed = cov._analyze(filename).arcs_executed
517517
return fr.missing_arc_description(start, end, arcs_executed)
518518

519519

tests/test_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ def fun2(x):
10231023
# Import the Python file, executing it.
10241024
self.start_import_stop(cov, "missing")
10251025

1026-
nums = cov.analyze("missing.py").numbers
1026+
nums = cov._analyze("missing.py").numbers
10271027
assert nums.n_files == 1
10281028
assert nums.n_statements == 7
10291029
assert nums.n_excluded == 1

tests/test_plugins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def test_plugin2_with_branch(self) -> None:
409409
# The way plugin2 works, a file named foo_7.html will be claimed to
410410
# have 7 lines in it. If render() was called with line number 4,
411411
# then the plugin will claim that lines 4 and 5 were executed.
412-
analysis = cov.analyze("foo_7.html")
412+
analysis = cov._analyze("foo_7.html")
413413
assert analysis.statements == {1, 2, 3, 4, 5, 6, 7}
414414
# Plugins don't do branch coverage yet.
415415
assert analysis.has_arcs is True

0 commit comments

Comments
 (0)