FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Creating clearer KeyError messages. by MicahGale · Pull Request #18 · paulromano/endf-python · GitHub

Creating clearer KeyError messages. - #18

Draft
MicahGale wants to merge 2 commits into
paulromano:mainfrom
MicahGale:keyError_clarify
Draft

Creating clearer KeyError messages.#18
MicahGale wants to merge 2 commits into
paulromano:mainfrom
MicahGale:keyError_clarify

Conversation

MicahGale commented Oct 11, 2024
edited
Loading

Copy link
Copy Markdown

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

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL