Repository navigation
Hash SpanLevel by name and warn that hashing it is discouraged - #2768
Merged
Merged
Conversation
`SpanLevel` compares equal to a level name but hashed as its number, so
`level in {'warn', 'error'}` was False for a warning span while the list
form was True. Hash the name instead, and warn on every hash, since no
single hash can agree with the name, the number and `'warning'` at once.
Fixes #2758
Signed-off-by: Christopher Krah <48338417+chrikrah@users.noreply.github.com>
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2758.
SpanLevel.__hash__now hashes the level name and warns, as alexmojaki suggested on the issue, solevel in {'warn', 'error'}agrees withlevel == 'warn'.The cost is
level in {13}, which matched before and now misses;'warning'still misses a set that holds'warn'. The warning names both and points atlevel.name.@alexmojaki I went with
UserWarning, because Python's default filters hide aDeprecationWarningraised from a sampler module, which is where these lookups live. Would you rather have it as a deprecation anyway?