fix: use is None instead of == None in snuba metrics utils#112904
Open
harshadkhetpal wants to merge 1 commit intogetsentry:masterfrom
Open
fix: use is None instead of == None in snuba metrics utils#112904harshadkhetpal wants to merge 1 commit intogetsentry:masterfrom
is None instead of == None in snuba metrics utils#112904harshadkhetpal wants to merge 1 commit intogetsentry:masterfrom
Conversation
PEP 8 E711: comparisons to None should use identity operators.
Comment on lines
+491
to
492
| If startisNone then it calculates from the beginning of unix time (for backward compatibility with | ||
| MetricsQuery.calculate_intervals_len) |
Contributor
There was a problem hiding this comment.
Bug: A find-and-replace operation introduced a typo (startisNone) in the docstring for the get_num_intervals() function. This is a documentation-only issue.
Severity: LOW
Suggested Fix
Correct the typo in the docstring on line 491 of src/sentry/snuba/metrics/utils.py. Change If startisNone then it calculates... to If start is None then it calculates... to fix the spacing.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/sentry/snuba/metrics/utils.py#L491-L492
Potential issue: In the docstring for the `get_num_intervals()` function, a
find-and-replace operation to convert `== None` to `is None` was applied without
handling spacing correctly. This resulted in the text `If start==None` being changed to
`If startisNone`. This is a cosmetic documentation issue and does not affect the runtime
behavior of the function, as the actual code logic correctly uses `if start is None:`.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Summary
Replaces
== Nonewithis Noneinsrc/sentry/snuba/metrics/utils.py.Motivation
PEP 8 specifies that comparisons to
Noneshould use identity comparison (is/is not) rather than equality. This is flagged as E711 by flake8/pycodestyle.Change
Testing
Style/correctness fix only; no behavior change.