Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating clearer KeyError messages. #18

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MicahGale
Copy link

@MicahGale MicahGale commented Oct 11, 2024

This is a quick first pass at trying to make the KeyError message clear this is a user error, and not a library error. @paulromano, Is this a reasonable approach before I go further down this path?

Things implemented:

  1. Moved all manually documented attributes to @property wrappers for _private fields.
  2. Made a subclass of dict. This overwrites __getitem__ to rewrite the KeyError.
  3. Tried to disable __setitem__ for the wrapper to make it immutable. Not sure if I did this right.
  4. Wrapper is spawned as a deepcopy of the _private dicts to add a layer of immutability as well.

TODO

  • Verify this behaves as expected
  • Check on test coverage
  • Clarify type annotations are accurate.

Fixes #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeyError when accessing section_text for certain sections
1 participant