Created originally on Bitbucket by ariava (Arianna Avanzini)
Was already merged in Bitbucket before import, marked as merged by the import user
- Use 'isinstance()' instead of 'is' in _annotation_key() to account for user-defined subclasses of list and dict.
- Cleanup assert messages when validating annotations and convert them to exceptions.
- Remove intermediate variables used just once before return.
- Cleanup comments.