Skip to content

Commit c7ad546

Browse files
committed
Replace no-print-statements with the T20 ruff rules
1 parent 40a1972 commit c7ad546

File tree

5 files changed

+8
-13
lines changed

5 files changed

+8
-13
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ repos:
5454
- id: ruff
5555
args: [--fix, --show-fixes]
5656
- id: ruff-format
57-
- repo: https://github.com/MarcoGorelli/madforhooks
58-
rev: 0.4.1
59-
hooks:
60-
- id: no-print-statements
61-
files: ^pymc/
62-
exclude: (?x)(pymc/_version.py)
6357
- repo: local
6458
hooks:
6559
- id: check-no-tests-are-ignored

pymc/math.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import sys
1615
import warnings
1716

1817
from functools import partial, reduce
@@ -389,8 +388,7 @@ def perform(self, node, inputs, outputs, params=None):
389388
log_det = np.sum(np.log(np.abs(s)))
390389
z[0] = np.asarray(log_det, dtype=x.dtype)
391390
except Exception:
392-
print(f"Failed to compute logdet of {x}.", file=sys.stdout)
393-
raise
391+
raise ValueError(f"Failed to compute logdet of {x}.")
394392

395393
def grad(self, inputs, g_outputs):
396394
[gz] = g_outputs

pymc/tuning/starting.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
@author: johnsalvatier
1919
"""
2020

21-
import sys
2221
import warnings
2322

2423
from collections.abc import Sequence
@@ -184,7 +183,6 @@ def find_MAP(
184183
pm._log.info(e)
185184
finally:
186185
cost_func.progress.update(cost_func.task, completed=cost_func.n_eval, refresh=True)
187-
print(file=sys.stdout)
188186

189187
mx0 = RaveledVars(mx0, x0.point_map_info)
190188
unobserved_vars = get_default_varnames(model.unobserved_value_vars, include_transformed)

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extend-exclude = ["_version.py"]
3737
docstring-code-format = true
3838

3939
[tool.ruff.lint]
40-
select = ["C4", "D", "E", "F", "I", "UP", "W", "RUF"]
40+
select = ["C4", "D", "E", "F", "I", "UP", "W", "RUF", "T20"]
4141
ignore = [
4242
"E501",
4343
"F841", # Local variable name is assigned to but never used
@@ -72,6 +72,12 @@ lines-between-types = 1
7272
"I001", # Import block is un-sorted or un-formatted
7373
]
7474
"tests/*" = ["D"]
75+
"scripts/run_mypy.py" = [
76+
"T201", # No print statements
77+
]
78+
"*.ipynb" = [
79+
"T201", # No print statements
80+
]
7581

7682
[tool.coverage.report]
7783
exclude_lines = [

tests/gp/test_cov.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ def test_euclidean_dist(self):
483483
[1, 0, 1],
484484
]
485485
)
486-
print(result, expected)
487486
npt.assert_allclose(result, expected, atol=1e-5)
488487

489488

0 commit comments

Comments
 (0)