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

fix: enhance missing methods to handle missing keys more explicitly i… by t4m4k0ty4 · Pull Request #59 · fluentpython/example-code-2e · GitHub

fix: enhance missing methods to handle missing keys more explicitly i… - #59

Open
t4m4k0ty4 wants to merge 1 commit into
fluentpython:masterfrom
t4m4k0ty4:master
Open

fix: enhance missing methods to handle missing keys more explicitly i…#59
t4m4k0ty4 wants to merge 1 commit into
fluentpython:masterfrom
t4m4k0ty4:master

Conversation

Copy link
Copy Markdown

Description

This PR improves the implementation of missing methods across several mapping subclasses to ensure safer and more predictable behavior when attempting to access keys in a case-insensitive manner.

Problem

In the original version, calls to self[_upper(key)] were made without checking if the transformed key actually exists. This could result in unhandled KeyErrors or unintended recursion, especially in dictionary-like structures where missing is automatically called upon a missing key.

Impact of my solution

This change enhances code clarity and error safety, making the behavior of custom mappings more robust and closer to Python’s expectations for missing.

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.

1 participant


Back | FazBrowse Home | New Git URL