KEMBAR78
ref: fix type errors pointed out by django-stubs 5.0.4 by asottile-sentry · Pull Request #75359 · getsentry/sentry · GitHub
Skip to content

Conversation

@asottile-sentry
Copy link
Contributor

@asottile-sentry asottile-sentry commented Jul 31, 2024

src/sentry/integrations/services/repository/impl.py:55: error: Incompatible type for lookup 'status': (got "ObjectStatus", expected "str | int")  [misc]
src/sentry/sentry_apps/services/app/impl.py:193: error: Incompatible type for lookup 'api_token_id': (got "str", expected "ApiToken | int | None")  [misc]

@asottile-sentry asottile-sentry requested review from a team July 31, 2024 18:27
@asottile-sentry asottile-sentry requested a review from a team as a code owner July 31, 2024 18:27
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 31, 2024
@asottile-sentry asottile-sentry enabled auto-merge (squash) July 31, 2024 18:28
has_integration: bool | None = None,
has_provider: bool | None = None,
status: ObjectStatus | None = None,
status: int | None = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

despite looking like an enum ObjectStatus is just a namespace for ints

Copy link
Member

Choose a reason for hiding this comment

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

It looks like this is the only caller which ever provides a value so this one looks good: https://github.com/getsentry/sentry/blob/master/src/sentry/plugins/providers/integration_repository.py#L97

Copy link
Member

Choose a reason for hiding this comment

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

👍 The service definition is also int | None.

@asottile-sentry asottile-sentry disabled auto-merge July 31, 2024 18:33
@asottile-sentry asottile-sentry requested a review from a team July 31, 2024 18:33
@asottile-sentry
Copy link
Contributor Author

can someone from @getsentry/hybrid-cloud confirm that these schema changes make sense?

@codecov
Copy link

codecov bot commented Jul 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.22%. Comparing base (1a59af2) to head (e8c963a).
Report is 4 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #75359       +/-   ##
===========================================
+ Coverage   57.18%   78.22%   +21.03%     
===========================================
  Files        6774     6784       +10     
  Lines      301932   302326      +394     
  Branches    51954    52022       +68     
===========================================
+ Hits       172660   236487    +63827     
+ Misses     124473    59470    -65003     
- Partials     4799     6369     +1570     
Files Coverage Δ
...rc/sentry/integrations/services/repository/impl.py 85.07% <ø> (ø)
src/sentry/sentry_apps/services/app/model.py 94.89% <100.00%> (+9.18%) ⬆️

... and 2020 files with indirect coverage changes

uuids: list[str]
status: int
api_token_id: str
api_token_id: int
Copy link
Member

Choose a reason for hiding this comment

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

@asottile-sentry asottile-sentry merged commit b51c4e2 into master Jul 31, 2024
@asottile-sentry asottile-sentry deleted the asottile-type-errors-django-stubs-5-0-4 branch July 31, 2024 19:31
has_integration: bool | None = None,
has_provider: bool | None = None,
status: ObjectStatus | None = None,
status: int | None = None,
Copy link
Member

Choose a reason for hiding this comment

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

👍 The service definition is also int | None.

uuids: list[str]
status: int
api_token_id: str
api_token_id: int
Copy link
Member

Choose a reason for hiding this comment

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

This should be fine too. We have coerce_numbers_to_str enabled in pydantic 2 which should cover any deploy time differences.

asottile-sentry added a commit that referenced this pull request Jul 31, 2024
<!-- Describe your PR here. -->

this had three sets of breakage addressed by other PRs:

- our foreign key subclass was not functioning, django-stubs added a
default TypeVar here which started getting filled in with an unbound
TypeVar resulting in thousands of errors: fixed by
#75228
- we were able to remove our fork's [descriptor
patch](getsentry/sentry-forked-django-stubs#4)
(which removed the non-model overload of `__get__` for fields) as mypy
[fixed this issue](python/mypy#17381). in doing
so it pointed out an unsafe descriptor access through a mixin and so
that had to go: #75360
- django-stubs improved some field validation through QuerySets which
was only checked through managers before: fixed by
#75359
@github-actions github-actions bot locked and limited conversation to collaborators Aug 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants