Repository navigation
Open
Labels
enhancementIndicates new feature requestsIndicates new feature requestshelp wantedIndicates that a maintainer wants help on an issue or pull requestIndicates that a maintainer wants help on an issue or pull request
Description
We would like the mypy type checker to run successfully on the shap codebase with the setting check_untyped_defs = true.
However, at present this does not pass on many submodules, so they opt out from this configuration setting:
Lines 104 to 108 in 86b6ee0
| [[tool.mypy.overrides]] | |
| # Disable some checks from certain shap modules | |
| # TODO: get these passing! | |
| module = [ | |
| "shap._explanation", |
When the typing issues in a given module are fixed, the relevant exclusion in pyproject.toml should be removed.
Checklist of modules to fix:
-
__init__.py -
_explanation.py -
_serializable.py -
_version.py -
actions/__init__.py -
actions/_action.py -
actions/_optimizer.py -
datasets.py -
explainers/__init__.py -
explainers/_additive.py -
explainers/_deep/__init__.py -
explainers/_deep/deep_pytorch.py -
explainers/_deep/deep_tf.py -
explainers/_deep/deep_utils.py -
explainers/_exact.py -
explainers/_explainer.py -
explainers/_gpu_tree.py -
explainers/_gradient.py -
explainers/_kernel.py -
explainers/_linear.py -
explainers/_partition.py -
explainers/_permutation.py -
explainers/_sampling.py -
explainers/_tree.py -
explainers/other/__init__.py -
explainers/other/_coefficient.py -
explainers/other/_lime.py -
explainers/other/_maple.py -
explainers/other/_random.py -
explainers/other/_treegain.py -
explainers/other/_ubjson.py -
explainers/pytree.py -
explainers/tf_utils.py -
links.py -
maskers/__init__.py -
maskers/_composite.py -
maskers/_fixed_composite.py -
maskers/_fixed.py -
maskers/_image.py -
maskers/_masker.py -
maskers/_output_composite.py -
maskers/_tabular.py -
maskers/_text.py -
models/__init__.py -
models/_model.py -
models/_teacher_forcing.py -
models/_text_generation.py -
models/_topk_lm.py -
models/_transformers_pipeline.py -
plots/__init__.py -
plots/_bar.py -
plots/_beeswarm.py -
plots/_benchmark.py -
plots/_decision.py -
plots/_embedding.py -
plots/_force_matplotlib.py -
plots/_force.py -
plots/_group_difference.py -
plots/_heatmap.py -
plots/_image.py -
plots/_labels.py -
plots/_monitoring.py -
plots/_partial_dependence.py -
plots/_scatter.py -
plots/_text.py -
plots/_utils.py -
plots/_violin.py -
plots/_waterfall.py -
plots/colors/__init__.py -
plots/colors/_colorconv.py -
plots/colors/_colors.py -
utils/__init__.py -
utils/_clustering.py -
utils/_exceptions.py -
utils/_general.py -
utils/_keras.py -
utils/_legacy.py -
utils/_masked_model.py -
utils/_show_progress.py -
utils/image.py -
utils/transformers.py
Metadata
Metadata
Assignees
Labels
enhancementIndicates new feature requestsIndicates new feature requestshelp wantedIndicates that a maintainer wants help on an issue or pull requestIndicates that a maintainer wants help on an issue or pull request
Activity
TYP: add type hints and enable check_untyped_defs for explainers.othe…
TYP: add type hints and enable check_untyped_defs for explainers.tf_u…
BaibhavKundu2005 commentedon Apr 18, 2026
Hi @connortann. I'd like to take
plots/_waterfall.pyandmaskers/_tabular.py. I'll add the strict type hints, remove them from thepyproject.tomlexclusion list, and open a PR oncemypypasses locally.SarthakB11 commentedon Apr 22, 2026
I've been working through the unchecked modules — PRs open for
explainers/other/_random.py(#4436) andexplainers/tf_utils.py(#4445), both green CI.Planning to continue with
maskers/_image.pyandplots/_force.pyover the next two weeks.TYP: enable mypy check_untyped_defs for shap/maskers/_image
PredictiveManish commentedon Apr 23, 2026
I'm working on
shap/explainers/_tree.py. made some changes currently testing them, soon will make a PR.SarthakB11 commentedon Apr 23, 2026
PRs now open for
maskers/_image.py(#4761),plots/_force.py(#4760), andplots/_force_matplotlib.py(#4772) — all building on the earlier work.TYP: add type hints for explainers.other._random (#4436)
TYP: add type hints for plots._benchmark (#5101)
lll-hhh commentedon Nov 2, 2026
I would like to take the
shap/explainers/_deep/deep_pytorch.pyslice. On main8dfb527, enablingcheck_untyped_defsfor this module exposes 7 mypy diagnostics with PyTorch installed: optional interim state, the list/array attribution result, and the backward-hook gradient list. I checked all 473 open PRs and the claims here; #4219 does not modify this module, and I found no competing typing slice. Scope: resolve these internal typing issues, remove only this module from the exemption, and add small deterministic CPU tests for output ranking, multiple inputs, and interim-layer attribution to preserve numeric and return-shape behavior. No operator support or algorithm changes. AI disclosure: Codex is preparing and testing this under the user's authorization, originating from this tracker; no independent human review is claimed.