sentry icon indicating copy to clipboard operation
sentry copied to clipboard

ref(incidents): Add type hints to sentry/incidents/logic.py

Open RyanSkonnord opened this issue 1 year ago • 1 comments

Add type hints to the sentry.incidents.logic module and some related functions.

Remove unused function parameters. Change default collection args from None to () where they are treated interchangeably, to minimize nullable arg types. Add explicit null checks where required by the type checker.

Add underscore prefix to functions used privately. Move functions that were used only by a single module.

RyanSkonnord avatar Aug 02 '24 17:08 RyanSkonnord

Codecov Report

Attention: Patch coverage is 93.37748% with 10 lines in your changes missing coverage. Please review.

:white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/incidents/logic.py 95.31% 3 Missing and 3 partials :warning:
src/sentry/incidents/models/alert_rule.py 66.66% 1 Missing and 1 partial :warning:
src/sentry/integrations/pagerduty/utils.py 33.33% 1 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #75541      +/-   ##
==========================================
- Coverage   78.13%   78.13%   -0.01%     
==========================================
  Files        6931     6931              
  Lines      307646   307695      +49     
  Branches    50358    50364       +6     
==========================================
+ Hits       240386   240424      +38     
- Misses      60864    60870       +6     
- Partials     6396     6401       +5     

codecov[bot] avatar Aug 02 '24 18:08 codecov[bot]

this patch has gotten pretty large -- can we split out parts of those and land them separately to minimize risk and increase reviewability?

It got large because that's what was necessary to remove "sentry.incidents.logic" from pyproject.toml. You want me to put it back in?

RyanSkonnord avatar Aug 29 '24 21:08 RyanSkonnord

this patch has gotten pretty large -- can we split out parts of those and land them separately to minimize risk and increase reviewability?

It got large because that's what was necessary to remove "sentry.incidents.logic" from pyproject.toml. You want me to put it back in?

no. there are logical parts of this patch that can be landed separately which will reduce risk and improve reviewability

asottile-sentry avatar Sep 03 '24 16:09 asottile-sentry

@asottile-sentry Functional changes broken out into:

  1. https://github.com/getsentry/sentry/pull/77197
  2. https://github.com/getsentry/sentry/pull/77199
  3. https://github.com/getsentry/sentry/pull/77200
  4. https://github.com/getsentry/sentry/pull/77201

RyanSkonnord avatar Sep 09 '24 21:09 RyanSkonnord

@asottile-sentry Now the PR should consist only of type annotation fixes, with the only changes to flow being a few helper functions motivated by type-checking.

RyanSkonnord avatar Sep 10 '24 18:09 RyanSkonnord