Skip to content

fix: use is None instead of == None in snuba metrics utils#112904

Open
harshadkhetpal wants to merge 1 commit intogetsentry:masterfrom
harshadkhetpal:fix/pep8-is-none-metrics-utils
Open

fix: use is None instead of == None in snuba metrics utils#112904
harshadkhetpal wants to merge 1 commit intogetsentry:masterfrom
harshadkhetpal:fix/pep8-is-none-metrics-utils

Conversation

@harshadkhetpal
Copy link
Copy Markdown

Summary

Replaces == None with is None in src/sentry/snuba/metrics/utils.py.

Motivation

PEP 8 specifies that comparisons to None should use identity comparison (is/is not) rather than equality. This is flagged as E711 by flake8/pycodestyle.

Change

# Before
if value == None:
    ...

# After
if value is None:
    ...

Testing

Style/correctness fix only; no behavior change.

PEP 8 E711: comparisons to None should use identity operators.
@harshadkhetpal harshadkhetpal requested a review from a team as a code owner April 14, 2026 09:21
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 14, 2026
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant