Join GitHub today
Use the get_attribute hook for dynamic classes #6371
@ilevkivskyi Thanks for the review! I made the changes you requested.
One of the test cases is that the attribute hook can produce an error. I invented my own error, "Field does not exist", but ideally I would test that you can fallback to the normal mypy error handling -- but I don't think you can access a MemberContext to call
Hm, ~~the old docstring was wrong too~~ (it specifies that the hook will be called with the base class name where the field is defined, but it is called with the derived class name). I assume the documented behavior is the desirable one? [edit: not sure if old docstring was wrong anymore, investigating.]