Skip to content

Commit 646521b

Browse files
ref: fix types for create_or_update to match the requirements of BaseManager (#73596)
fixes this when managers are type checked: ``` src/sentry/db/models/manager/base.py:481: error: Argument 1 to "create_or_update" has incompatible type "type[M]"; expected "type[BaseModel]" [arg-type] ``` <!-- Describe your PR here. -->
1 parent ca89542 commit 646521b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sentry/db/models/query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _resolve(instance: Model, node: BaseExpression | F) -> BaseExpression:
6262
return runner
6363

6464

65-
def _get_field(model: type[BaseModel], key: str) -> Field[object, object]:
65+
def _get_field(model: type[Model], key: str) -> Field[object, object]:
6666
field = model._meta.get_field(key)
6767
if not isinstance(field, Field):
6868
raise TypeError(f"expected Field for {key}, got ({field})")
@@ -171,8 +171,8 @@ def update_or_create(
171171

172172

173173
def create_or_update(
174-
model: type[BaseModel], using: str | None = None, **kwargs: Any
175-
) -> tuple[int, Literal[False]] | tuple[BaseModel, Literal[True]]:
174+
model: type[Model], using: str | None = None, **kwargs: Any
175+
) -> tuple[int, Literal[False]] | tuple[Model, Literal[True]]:
176176
"""
177177
Similar to get_or_create, either updates a row or creates it.
178178

0 commit comments

Comments
 (0)