Repository: scikit-hep/pyhf

Issue:
Jinja2 v3.1.0 breaks nbsphinx
### Summary

[`Jinja2` `v3.1.0`](https://pypi.org/project/Jinja2/3.1.0/#history) was released 2 hours ago and is breaking [`nbsphinx`](https://github.com/spatialaudio/nbsphinx) (v0.8.7). This will need to get resolved soon by `nbsphinx`, but as a stopgap we should probably put in a 

```diff
             'sphinx-click',
             'sphinx_rtd_theme',
             'nbsphinx!=0.8.8',  # c.f. https://github.com/spatialaudio/nbsphinx/issues/620
+            'Jinja2!=3.1.0',
             'ipywidgets',
             'sphinx-issues',
             'sphinx-copybutton>=0.3.2',
```

until things can get resolved.

### OS / Environment

```console
All
```


### Steps to Reproduce

N/A

### File Upload (optional)

_No response_

### Expected Results

For the docs to build

### Actual Results

nbsphinx errors due to new Jinja2 API

```
...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 35 source files that are out of date
updating environment: [new config] 153 added, 0 changed, 0 removed
reading sources... [  0%] _generated/pyhf.compat
reading sources... [  1%] _generated/pyhf.compat.interpret_rootname
reading sources... [  1%] _generated/pyhf.compat.paramset_to_rootnames
reading sources... [  2%] _generated/pyhf.contrib.utils.download
reading sources... [  3%] _generated/pyhf.contrib.viz.brazil
reading sources... [  3%] _generated/pyhf.contrib.viz.brazil.BrazilBandCollection
reading sources... [  4%] _generated/pyhf.contrib.viz.brazil.plot_brazil_band
reading sources... [  5%] _generated/pyhf.contrib.viz.brazil.plot_cls_components
reading sources... [  5%] _generated/pyhf.contrib.viz.brazil.plot_results
reading sources... [  6%] _generated/pyhf.exceptions.ImportBackendError
reading sources... [  7%] _generated/pyhf.exceptions.InvalidBackend
reading sources... [  7%] _generated/pyhf.exceptions.InvalidInterpCode
reading sources... [  8%] _generated/pyhf.exceptions.InvalidMeasurement
reading sources... [  9%] _generated/pyhf.exceptions.InvalidModel
reading sources... [  9%] _generated/pyhf.exceptions.InvalidModifier
reading sources... [ 10%] _generated/pyhf.exceptions.InvalidNameReuse
reading sources... [ 11%] _generated/pyhf.exceptions.InvalidOptimizer
reading sources... [ 11%] _generated/pyhf.exceptions.InvalidPatchLookup
reading sources... [ 12%] _generated/pyhf.exceptions.InvalidPatchSet
reading sources... [ 13%] _generated/pyhf.exceptions.InvalidPdfData
reading sources... [ 13%] _generated/pyhf.exceptions.InvalidPdfParameters
reading sources... [ 14%] _generated/pyhf.exceptions.InvalidSpecification
reading sources... [ 15%] _generated/pyhf.exceptions.InvalidWorkspaceOperation
reading sources... [ 15%] _generated/pyhf.exceptions.PatchSetVerificationError
reading sources... [ 16%] _generated/pyhf.get_backend
reading sources... [ 16%] _generated/pyhf.infer.calculators.AsymptoticCalculator
reading sources... [ 17%] _generated/pyhf.infer.calculators.AsymptoticTestStatDistribution
reading sources... [ 18%] _generated/pyhf.infer.calculators.EmpiricalDistribution
reading sources... [ 18%] _generated/pyhf.infer.calculators.HypoTestFitResults
reading sources... [ 19%] _generated/pyhf.infer.calculators.ToyCalculator
reading sources... [ 20%] _generated/pyhf.infer.calculators.generate_asimov_data
reading sources... [ 20%] _generated/pyhf.infer.hypotest
reading sources... [ 21%] _generated/pyhf.infer.intervals.upperlimit
reading sources... [ 22%] _generated/pyhf.infer.mle.fit
reading sources... [ 22%] _generated/pyhf.infer.mle.fixed_poi_fit
reading sources... [ 23%] _generated/pyhf.infer.mle.twice_nll
reading sources... [ 24%] _generated/pyhf.infer.test_statistics.q0
reading sources... [ 24%] _generated/pyhf.infer.test_statistics.qmu
reading sources... [ 25%] _generated/pyhf.infer.test_statistics.qmu_tilde
reading sources... [ 26%] _generated/pyhf.infer.test_statistics.tmu
reading sources... [ 26%] _generated/pyhf.infer.test_statistics.tmu_tilde
reading sources... [ 27%] _generated/pyhf.infer.utils.all_pois_floating
reading sources... [ 28%] _generated/pyhf.infer.utils.create_calculator
reading sources... [ 28%] _generated/pyhf.infer.utils.get_test_stat
reading sources... [ 29%] _generated/pyhf.interpolators.code0
reading sources... [ 30%] _generated/pyhf.interpolators.code1
reading sources... [ 30%] _generated/pyhf.interpolators.code2
reading sources... [ 31%] _generated/pyhf.interpolators.code4
reading sources... [ 32%] _generated/pyhf.interpolators.code4p
reading sources... [ 32%] _generated/pyhf.modifiers.histosys
reading sources... [ 33%] _generated/pyhf.modifiers.histosys.histosys_builder
reading sources... [ 33%] _generated/pyhf.modifiers.histosys.histosys_combined
reading sources... [ 34%] _generated/pyhf.modifiers.histosys.required_parset
reading sources... [ 35%] _generated/pyhf.modifiers.normfactor
reading sources... [ 35%] _generated/pyhf.modifiers.normfactor.normfactor_builder
reading sources... [ [36](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:36)%] _generated/pyhf.modifiers.normfactor.normfactor_combined
reading sources... [ [37](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:37)%] _generated/pyhf.modifiers.normfactor.required_parset
reading sources... [ 37%] _generated/pyhf.modifiers.normsys
reading sources... [ [38](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:38)%] _generated/pyhf.modifiers.normsys.normsys_builder
reading sources... [ [39](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:39)%] _generated/pyhf.modifiers.normsys.normsys_combined
reading sources... [ 39%] _generated/pyhf.modifiers.normsys.required_parset
reading sources... [ [40](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:40)%] _generated/pyhf.modifiers.shapefactor
reading sources... [ [41](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:41)%] _generated/pyhf.modifiers.shapefactor.required_parset
reading sources... [ 41%] _generated/pyhf.modifiers.shapefactor.shapefactor_builder
reading sources... [ [42](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:42)%] _generated/pyhf.modifiers.shapefactor.shapefactor_combined
reading sources... [ [43](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:43)%] _generated/pyhf.modifiers.shapesys
reading sources... [ 43%] _generated/pyhf.modifiers.shapesys.required_parset
reading sources... [ [44](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:44)%] _generated/pyhf.modifiers.shapesys.shapesys_builder
reading sources... [ [45](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:45)%] _generated/pyhf.modifiers.shapesys.shapesys_combined
reading sources... [ 45%] _generated/pyhf.modifiers.staterror
reading sources... [ [46](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:46)%] _generated/pyhf.modifiers.staterror.required_parset
reading sources... [ [47](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:47)%] _generated/pyhf.modifiers.staterror.staterror_builder
reading sources... [ 47%] _generated/pyhf.modifiers.staterror.staterror_combined
reading sources... [ [48](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:48)%] _generated/pyhf.optimize.mixins.OptimizerMixin
reading sources... [ [49](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:49)%] _generated/pyhf.optimize.opt_minuit.minuit_optimizer
reading sources... [ 49%] _generated/pyhf.optimize.opt_scipy.scipy_optimizer
reading sources... [ [50](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:50)%] _generated/pyhf.optimizer
reading sources... [ 50%] _generated/pyhf.patchset.Patch
reading sources... [ [51](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:51)%] _generated/pyhf.patchset.PatchSet
reading sources... [ [52](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:52)%] _generated/pyhf.pdf.Model
reading sources... [ 52%] _generated/pyhf.pdf._ModelConfig
reading sources... [ [53](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:53)%] _generated/pyhf.probability.Independent
reading sources... [ [54](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:54)%] _generated/pyhf.probability.Normal
reading sources... [ 54%] _generated/pyhf.probability.Poisson
reading sources... [ [55](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:55)%] _generated/pyhf.probability.Simultaneous
reading sources... [ [56](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:56)%] _generated/pyhf.readxml
reading sources... [ 56%] _generated/pyhf.readxml.clear_filecache
reading sources... [ [57](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:57)%] _generated/pyhf.readxml.dedupe_parameters
reading sources... [ [58](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:58)%] _generated/pyhf.readxml.extract_error
reading sources... [ 58%] _generated/pyhf.readxml.import_root_histogram
reading sources... [ [59](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:59)%] _generated/pyhf.readxml.parse
reading sources... [ [60](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:60)%] _generated/pyhf.readxml.process_channel
reading sources... [ 60%] _generated/pyhf.readxml.process_data
reading sources... [ [61](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:61)%] _generated/pyhf.readxml.process_measurements
reading sources... [ [62](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:62)%] _generated/pyhf.readxml.process_sample
reading sources... [ 62%] _generated/pyhf.schema
reading sources... [ [63](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:63)%] _generated/pyhf.schema.Schema
reading sources... [ [64](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:64)%] _generated/pyhf.schema.load_schema
reading sources... [ 64%] _generated/pyhf.schema.validate
reading sources... [ [65](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:65)%] _generated/pyhf.set_backend
reading sources... [ [66](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:66)%] _generated/pyhf.simplemodels.correlated_background
reading sources... [ 66%] _generated/pyhf.simplemodels.uncorrelated_background
reading sources... [ [67](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:67)%] _generated/pyhf.tensor.jax_backend.jax_backend
reading sources... [ 67%] _generated/pyhf.tensor.numpy_backend.numpy_backend
reading sources... [ [68](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:68)%] _generated/pyhf.tensor.pytorch_backend.pytorch_backend
reading sources... [ [69](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:69)%] _generated/pyhf.tensor.tensorflow_backend.tensorflow_backend
reading sources... [ 69%] _generated/pyhf.tensorlib
reading sources... [ [70](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:70)%] _generated/pyhf.utils.citation
reading sources... [ [71](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:71)%] _generated/pyhf.utils.digest
reading sources... [ 71%] _generated/pyhf.utils.options_from_eqdelimstring
reading sources... [ [72](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:72)%] _generated/pyhf.workspace.Workspace
reading sources... [ [73](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:73)%] _generated/pyhf.writexml
reading sources... [ 73%] _generated/pyhf.writexml.build_channel
reading sources... [ [74](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:74)%] _generated/pyhf.writexml.build_data
reading sources... [ [75](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:75)%] _generated/pyhf.writexml.build_measurement
reading sources... [ 75%] _generated/pyhf.writexml.build_modifier
reading sources... [ [76](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:76)%] _generated/pyhf.writexml.build_sample
reading sources... [ [77](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:77)%] _generated/pyhf.writexml.indent
reading sources... [ 77%] api
reading sources... [ [78](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:78)%] babel
reading sources... [ [79](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:79)%] citations
reading sources... [ 79%] cli
reading sources... [ [80](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:80)%] contributors
reading sources... [ [81](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:81)%] development
reading sources... [ 81%] examples
reading sources... [ [82](https://github.com/scikit-hep/pyhf/runs/5679132850?check_suite_focus=true#step:7:82)%] examples/notebooks/ShapeFactor

Notebook error:
AttributeError in examples/notebooks/ShapeFactor.ipynb:
module 'jinja2.utils' has no attribute 'escape'
make: *** [Makefile:57: html] Error 2
```


### pyhf Version

`master` on commit 419bc766791aa18226777910002bd91c695d0465


### Code of Conduct

- [X] I agree to follow the Code of Conduct


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -55,7 +55,6 @@
             'sphinx-click',
             'sphinx_rtd_theme',
             'nbsphinx!=0.8.8',  # c.f. https://github.com/spatialaudio/nbsphinx/issues/620
-            'Jinja2!=3.1.0',  # c.f. https://github.com/spatialaudio/nbsphinx/issues/641
             'ipywidgets',
             'sphinx-issues',
             'sphinx-copybutton>=0.3.2',


Test patch: