Skip to content

Commit e77e179

Browse files
ref: fix typing for fixtures.schema_validation (#96667)
this decorator caused anything decorated to become Any <!-- Describe your PR here. -->
1 parent 66722af commit e77e179

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

fixtures/schema_validation.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1+
import functools
2+
from collections.abc import Callable
3+
14
import pytest
25
from jsonschema import ValidationError
36

47

5-
def invalid_schema(func):
6-
def inner(self, *args, **kwargs):
8+
def invalid_schema[**P](func: Callable[P, None]) -> Callable[P, None]:
9+
@functools.wraps(func)
10+
def inner(*args: P.args, **kwargs: P.kwargs) -> None:
711
with pytest.raises(ValidationError):
8-
func(self)
12+
func(*args, **kwargs)
913

1014
return inner
1115

1216

13-
def invalid_schema_with_error_message(message):
14-
def decorator(func):
15-
def inner(self, *args, **kwargs):
17+
def invalid_schema_with_error_message[
18+
**P
19+
](message: str) -> Callable[[Callable[P, None]], Callable[P, None]]:
20+
def decorator(func: Callable[P, None]) -> Callable[P, None]:
21+
@functools.wraps(func)
22+
def inner(*args: P.args, **kwargs: P.kwargs) -> None:
1623
with pytest.raises(ValidationError) as excinfo:
17-
func(self)
24+
func(*args, **kwargs)
1825
assert excinfo.value.message == message
1926

2027
return inner

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ disable_error_code = [
157157
[[tool.mypy.overrides]]
158158
module = [
159159
"fixtures.safe_migrations_apps.*",
160+
"fixtures.schema_validation",
160161
"sentry.analytics.*",
161162
"sentry.api.decorators",
162163
"sentry.api.endpoints.integrations.sentry_apps.installation.external_issue.*",

0 commit comments

Comments
 (0)