Skip to content

Commit

Permalink
Replace no-print-statements with the T20 ruff rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Armavica committed Oct 8, 2024
1 parent 40a1972 commit c7ad546
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ repos:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format
- repo: https://github.com/MarcoGorelli/madforhooks
rev: 0.4.1
hooks:
- id: no-print-statements
files: ^pymc/
exclude: (?x)(pymc/_version.py)
- repo: local
hooks:
- id: check-no-tests-are-ignored
Expand Down
4 changes: 1 addition & 3 deletions pymc/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import warnings

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

def grad(self, inputs, g_outputs):
[gz] = g_outputs
Expand Down
2 changes: 0 additions & 2 deletions pymc/tuning/starting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
@author: johnsalvatier
"""

import sys
import warnings

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

mx0 = RaveledVars(mx0, x0.point_map_info)
unobserved_vars = get_default_varnames(model.unobserved_value_vars, include_transformed)
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extend-exclude = ["_version.py"]
docstring-code-format = true

[tool.ruff.lint]
select = ["C4", "D", "E", "F", "I", "UP", "W", "RUF"]
select = ["C4", "D", "E", "F", "I", "UP", "W", "RUF", "T20"]
ignore = [
"E501",
"F841", # Local variable name is assigned to but never used
Expand Down Expand Up @@ -72,6 +72,12 @@ lines-between-types = 1
"I001", # Import block is un-sorted or un-formatted
]
"tests/*" = ["D"]
"scripts/run_mypy.py" = [
"T201", # No print statements
]
"*.ipynb" = [
"T201", # No print statements
]

[tool.coverage.report]
exclude_lines = [
Expand Down
1 change: 0 additions & 1 deletion tests/gp/test_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ def test_euclidean_dist(self):
[1, 0, 1],
]
)
print(result, expected)
npt.assert_allclose(result, expected, atol=1e-5)


Expand Down

0 comments on commit c7ad546

Please sign in to comment.