Skip to content

Commit 6440d59

Browse files
michaelosthegericardoV94
authored andcommitted
Switch from pass-listing to fail-listing
1 parent 441bed0 commit 6440d59

File tree

1 file changed

+34
-79
lines changed

1 file changed

+34
-79
lines changed

scripts/run_mypy.py

Lines changed: 34 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Invokes mypy and compare the reults with files in /pymc except tests
3-
and a list of files that are expected to pass without mypy errors.
3+
and a list of files that are knwon to fail.
44
55
Exit code 0 indicates that there are no unexpected results.
66
@@ -20,74 +20,31 @@
2020
import pandas
2121

2222
DP_ROOT = pathlib.Path(__file__).absolute().parent.parent
23-
PASSING = """
24-
pymc/__init__.py
25-
pymc/_version.py
26-
pymc/backends/__init__.py
27-
pymc/backends/arviz.py
28-
pymc/backends/base.py
29-
pymc/backends/ndarray.py
30-
pymc/backends/report.py
31-
pymc/blocking.py
32-
pymc/data.py
33-
pymc/distributions/__init__.py
34-
pymc/distributions/bound.py
35-
pymc/distributions/censored.py
36-
pymc/distributions/discrete.py
37-
pymc/distributions/logprob.py
38-
pymc/distributions/shape_utils.py
39-
pymc/distributions/simulator.py
40-
pymc/distributions/transforms.py
41-
pymc/exceptions.py
42-
pymc/func_utils.py
43-
pymc/gp/__init__.py
44-
pymc/gp/cov.py
45-
pymc/gp/gp.py
46-
pymc/gp/mean.py
47-
pymc/gp/util.py
48-
pymc/logprob/__init__.py
49-
pymc/logprob/abstract.py
50-
pymc/logprob/cumsum.py
51-
pymc/math.py
52-
pymc/ode/__init__.py
53-
pymc/ode/ode.py
54-
pymc/ode/utils.py
55-
pymc/plots/__init__.py
56-
pymc/sampling_jax.py
57-
pymc/sampling/__init__.py
58-
pymc/sampling/forward.py
59-
pymc/sampling/mcmc.py
60-
pymc/sampling/parallel.py
61-
pymc/sampling/population.py
62-
pymc/smc/__init__.py
63-
pymc/smc/sampling.py
64-
pymc/smc/kernels.py
65-
pymc/stats/__init__.py
66-
pymc/stats/convergence.py
67-
pymc/step_methods/__init__.py
68-
pymc/step_methods/arraystep.py
69-
pymc/step_methods/compound.py
70-
pymc/step_methods/metropolis.py
71-
pymc/step_methods/hmc/__init__.py
72-
pymc/step_methods/hmc/base_hmc.py
73-
pymc/step_methods/hmc/hmc.py
74-
pymc/step_methods/hmc/integration.py
75-
pymc/step_methods/hmc/nuts.py
76-
pymc/step_methods/hmc/quadpotential.py
77-
pymc/step_methods/slicer.py
78-
pymc/step_methods/step_sizes.py
79-
pymc/tuning/__init__.py
80-
pymc/tuning/scaling.py
81-
pymc/tuning/starting.py
82-
pymc/util.py
83-
pymc/variational/__init__.py
84-
pymc/variational/callbacks.py
85-
pymc/variational/inference.py
86-
pymc/variational/operators.py
87-
pymc/variational/stein.py
88-
pymc/variational/test_functions.py
89-
pymc/variational/updates.py
90-
pymc/vartypes.py
23+
FAILING = """
24+
pymc/distributions/continuous.py
25+
pymc/distributions/dist_math.py
26+
pymc/distributions/distribution.py
27+
pymc/distributions/mixture.py
28+
pymc/distributions/multivariate.py
29+
pymc/distributions/timeseries.py
30+
pymc/distributions/truncated.py
31+
pymc/initial_point.py
32+
pymc/logprob/censoring.py
33+
pymc/logprob/joint_logprob.py
34+
pymc/logprob/mixture.py
35+
pymc/logprob/rewriting.py
36+
pymc/logprob/scan.py
37+
pymc/logprob/tensor.py
38+
pymc/logprob/transforms.py
39+
pymc/logprob/utils.py
40+
pymc/model.py
41+
pymc/model_graph.py
42+
pymc/printing.py
43+
pymc/pytensorf.py
44+
pymc/sampling/jax.py
45+
pymc/stats/log_likelihood.py
46+
pymc/variational/approximations.py
47+
pymc/variational/opvi.py
9148
"""
9249

9350

@@ -140,7 +97,7 @@ def mypy_to_pandas(input_lines: Iterator[str]) -> pandas.DataFrame:
14097

14198

14299
def check_no_unexpected_results(mypy_lines: Iterator[str]):
143-
"""Compares mypy results with list of known PASSING files.
100+
"""Compares mypy results with list of known FAILING files.
144101
145102
Exits the process with non-zero exit code upon unexpected results.
146103
"""
@@ -158,9 +115,9 @@ def check_no_unexpected_results(mypy_lines: Iterator[str]):
158115
+ "\n".join(sorted(map(str, failing - all_files)))
159116
)
160117
passing = all_files - failing
161-
expected_passing = set(PASSING.strip().split("\n")) - {""}
162-
unexpected_failing = expected_passing - passing
163-
unexpected_passing = passing - expected_passing
118+
expected_failing = set(FAILING.strip().split("\n")) - {""}
119+
unexpected_failing = failing - expected_failing
120+
unexpected_passing = passing.intersection(expected_failing)
164121

165122
if not unexpected_failing:
166123
print(f"{len(passing)}/{len(all_files)} files pass as expected.")
@@ -175,15 +132,13 @@ def check_no_unexpected_results(mypy_lines: Iterator[str]):
175132
print("You can run `python scripts/run_mypy.py --verbose` to reproduce this test locally.")
176133
sys.exit(1)
177134

178-
if unexpected_passing == {"pymc/sampling/jax.py"}:
179-
print("Letting you know that 'pymc/sampling/jax.py' unexpectedly passed.")
180-
print("But this file is known to sometimes pass and sometimes not.")
181-
print("Unless you tried to resolve problems in sampling/jax.py just ignore this message.")
182-
elif unexpected_passing:
135+
if unexpected_passing:
183136
print("!!!!!!!!!")
184137
print(f"{len(unexpected_passing)} files unexpectedly passed the type checks:")
185138
print("\n".join(sorted(map(str, unexpected_passing))))
186-
print("This is good news! Go to scripts/run_mypy.py and add them to the list.")
139+
print(
140+
"This is good news! Go to scripts/run_mypy.py and remove them from the `FAILING` list."
141+
)
187142
if all_files.issubset(passing):
188143
print("WOW! All files are passing the mypy type checks!")
189144
print("scripts\\run_mypy.py may no longer be needed.")

0 commit comments

Comments
 (0)