BUG: Fix #25481 by fixing the error message in TypeError
BUG: Fix #25481 by fixing the error message in TypeError

- [x] closes #25481
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry
