Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused type: ignore statements #874

Merged
merged 3 commits into from
May 22, 2023

Conversation

jklaise
Copy link
Contributor

@jklaise jklaise commented Feb 14, 2023

This PR adds the mypy options warn_unused_ignores = True and warn_redundant_casts = True and fixes the resulting errors. This is motivated because type: ignore statements can become stale as newer versions of mypy fix bugs and libraries against which we typecheck ship typing stubs and fix bugs therein (e.g. numpy), see more here: https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-warn-unused-ignores

Will open a similar PR for alibi-detect after SeldonIO/alibi-detect#738.

@ascillitoe @mauicv FYI

@jklaise jklaise changed the title Remove unused type: ignore statements Remove unused type: ignore statements Feb 14, 2023
@ascillitoe
Copy link
Contributor

Makes sense!

@jklaise
Copy link
Contributor Author

jklaise commented Feb 14, 2023

Not entirely unexpected, but there's some complications with running this on older python versions which have older dependencies (e.g. numpy) which may not allow removing type: ignore or, indeed, suggest removing ones that shouldn't be removed in newer python versions... https://github.com/SeldonIO/alibi/actions/runs/4173451223/jobs/7225790896

See discussion: python/mypy#8823, not this is slightly different as we don't check in our code the current Python version, but still may be relevant.

@ascillitoe
Copy link
Contributor

Perhaps controversial, but do we actually care about mypy and flake8 passing for older Python versions. One could argue that its better for our codebase to be fully mypy and flake8 compliant on our most recent supported Python version, rather than include additional complexity to get these checks passing for Python versions that are close to EoL? We could factor out the mypy/flake8 checks to a separate workflow that is only run on ubuntu-latest, 3.10 for example...

@jklaise
Copy link
Contributor Author

jklaise commented Feb 14, 2023

I was thinking similarly, need to think a bit more about implications.

@jklaise jklaise marked this pull request as ready for review May 19, 2023 15:03
@codecov
Copy link

codecov bot commented May 19, 2023

Codecov Report

Merging #874 (e324583) into master (9a4c0bb) will not change coverage.
The diff coverage is 74.50%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #874   +/-   ##
=======================================
  Coverage   85.28%   85.28%           
=======================================
  Files          74       74           
  Lines        8832     8832           
=======================================
  Hits         7532     7532           
  Misses       1300     1300           
Impacted Files Coverage Δ
alibi/explainers/backends/pytorch/cfrl_base.py 28.75% <0.00%> (ø)
alibi/explainers/permutation_importance.py 97.09% <0.00%> (ø)
alibi/saving.py 83.75% <0.00%> (ø)
alibi/utils/visualization.py 48.10% <0.00%> (ø)
alibi/explainers/cfproto.py 75.57% <50.00%> (ø)
alibi/explainers/cem.py 79.31% <60.00%> (ø)
alibi/confidence/trustscore.py 86.07% <100.00%> (ø)
alibi/datasets/default.py 93.47% <100.00%> (ø)
alibi/explainers/anchors/anchor_image.py 93.12% <100.00%> (ø)
alibi/explainers/anchors/anchor_tabular.py 89.57% <100.00%> (ø)
... and 7 more

@jklaise jklaise merged commit 48b8cd9 into SeldonIO:master May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants