Fix minor error in dynamic load function
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

The `validate_docstrings.py` script dynamically loads modules/classes/functions from its command-line argument.

Currently, if the user supplies an invalid argument, an UnboundLocalError can be obtained:
```
Traceback (most recent call last):
...
File "./scripts/validate_docstrings.py", line 275, in _load_obj
    obj = getattr(obj, part)
UnboundLocalError: local variable 'obj' referenced before assignment
```

This PR fixes a check within the relevant function, so that a more informative error can be raised:
```
$ ./scripts/validate_docstrings.py tslibs.Timestamp
Traceback (most recent call last):
...
ImportError: No module can be imported from "tslibs.Timestamp"
```



