CI/DOC: Fixing bug in validate_docstrings.py
Follow up of #23514. One of the validation error wasn't tested, and with the refactoring a typo was introduced, where a bracket closed in the wrong place, raised a KeyError when a private class was found in a docstrings (and adding test for that case

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