pytensor icon indicating copy to clipboard operation
pytensor copied to clipboard

Fix E721: do not compare types, for exact checks use is / is not

Open maresb opened this issue 1 year ago • 1 comments

Description

This splits out a controvertial part of #581 code cleanup. See https://github.com/pymc-devs/pytensor/pull/581#discussion_r1448620228.

This runs a risk of breaking something extremely subtle, so I think we will not want to merge this, but I wanted to at least give this its own PR number for reference.

Checklist

Type of change

  • [ ] New feature / enhancement
  • [ ] Bug fix
  • [ ] Documentation
  • [X] Maintenance
  • [ ] Other (please specify):

maresb avatar Jan 15 '24 13:01 maresb

Codecov Report

Attention: Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.

Project coverage is 80.83%. Comparing base (4b6a444) to head (e4d207b). Report is 170 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/graph/null_type.py 0.00% 1 Missing :warning:
pytensor/raise_op.py 50.00% 1 Missing :warning:
pytensor/scalar/basic.py 50.00% 1 Missing :warning:
pytensor/tensor/rewriting/math.py 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #596   +/-   ##
=======================================
  Coverage   80.83%   80.83%           
=======================================
  Files         163      163           
  Lines       46897    46897           
  Branches    11468    11468           
=======================================
  Hits        37910    37910           
  Misses       6774     6774           
  Partials     2213     2213           
Files with missing lines Coverage Δ
pytensor/compile/debugmode.py 61.33% <100.00%> (ø)
pytensor/compile/ops.py 83.57% <100.00%> (ø)
pytensor/graph/basic.py 88.61% <ø> (ø)
pytensor/graph/rewriting/unify.py 99.33% <100.00%> (ø)
pytensor/ifelse.py 51.70% <100.00%> (ø)
pytensor/link/c/params_type.py 80.41% <ø> (ø)
pytensor/link/c/type.py 75.98% <ø> (ø)
pytensor/scalar/math.py 87.34% <100.00%> (ø)
pytensor/scan/op.py 84.71% <100.00%> (ø)
pytensor/sparse/basic.py 82.53% <ø> (ø)
... and 9 more

codecov-commenter avatar Jan 15 '24 13:01 codecov-commenter

I think we can go ahead with this one @maresb

Can you rebase?

ricardoV94 avatar Jun 06 '24 11:06 ricardoV94

@ricardoV94, rebase is complete.

maresb avatar Jun 06 '24 12:06 maresb

@maresb were we suppressing this pre-commit rule, should we reactivate it?

ricardoV94 avatar Jun 06 '24 13:06 ricardoV94

@maresb were we suppressing this pre-commit rule, should we reactivate it?

No we weren't, it's just totally broken in Ruff: https://github.com/astral-sh/ruff/issues/6465

But now E721 passes with flake8

maresb avatar Jun 06 '24 14:06 maresb