Skip to content

Commit cc7e4ee

Browse files
committed
revert changes in #1252 leaked into master
Signed-off-by: Oleg Hoefling <[email protected]>
1 parent b81b1bf commit cc7e4ee

File tree

2 files changed

+9
-195
lines changed

2 files changed

+9
-195
lines changed

django-stubs/test/client.pyi

Lines changed: 8 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from io import BytesIO
33
from json import JSONEncoder
44
from re import Pattern
55
from types import TracebackType
6-
from typing import Any, Generic, NoReturn, TypeVar, overload
6+
from typing import Any, Generic, NoReturn, TypeVar
77

88
from django.contrib.auth.base_user import AbstractBaseUser
99
from django.contrib.sessions.backends.base import SessionBase
@@ -16,7 +16,6 @@ from django.http.response import HttpResponseBase
1616
from django.template.base import Template
1717
from django.test.utils import ContextList
1818
from django.urls import ResolverMatch
19-
from typing_extensions import Literal
2019

2120
BOUNDARY: str
2221
MULTIPART_CONTENT: str
@@ -99,8 +98,6 @@ class _MonkeyPatchedWSGIResponse(_WSGIResponse):
9998
context: ContextList | dict[str, Any]
10099
content: bytes
101100
resolver_match: ResolverMatch
102-
103-
class _MonkeyPatchedWSGIResponseRedirect(_MonkeyPatchedWSGIResponse):
104101
redirect_chain: list[tuple[str, int]]
105102

106103
class _MonkeyPatchedASGIResponse(_ASGIResponse):
@@ -131,136 +128,25 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
131128
) -> None: ...
132129
# Silence type warnings, since this class overrides arguments and return types in an unsafe manner.
133130
def request(self, **request: Any) -> _MonkeyPatchedWSGIResponse: ...
134-
@overload # type: ignore
135-
def get(
136-
self, path: str, data: Any = ..., follow: Literal[False] = ..., secure: bool = ..., **extra: Any
137-
) -> _MonkeyPatchedWSGIResponse: ...
138-
@overload
139-
def get(
140-
self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any
141-
) -> _MonkeyPatchedWSGIResponseRedirect: ...
142-
@overload
143-
def get(
131+
def get( # type: ignore
144132
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
145133
) -> _MonkeyPatchedWSGIResponse: ...
146-
@overload # type: ignore
147-
def post(
148-
self,
149-
path: str,
150-
data: Any = ...,
151-
content_type: str = ...,
152-
follow: Literal[False] = ...,
153-
secure: bool = ...,
154-
**extra: Any
155-
) -> _MonkeyPatchedWSGIResponse: ...
156-
@overload
157-
def post(
158-
self,
159-
path: str,
160-
data: Any = ...,
161-
content_type: str = ...,
162-
follow: Literal[True] = ...,
163-
secure: bool = ...,
164-
**extra: Any
165-
) -> _MonkeyPatchedWSGIResponseRedirect: ...
166-
@overload
167-
def post(
134+
def post( # type: ignore
168135
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
169136
) -> _MonkeyPatchedWSGIResponse: ...
170-
@overload # type: ignore
171-
def head(
172-
self, path: str, data: Any = ..., follow: Literal[False] = ..., secure: bool = ..., **extra: Any
173-
) -> _MonkeyPatchedWSGIResponse: ...
174-
@overload
175-
def head(
176-
self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any
177-
) -> _MonkeyPatchedWSGIResponseRedirect: ...
178-
@overload
179-
def head(
137+
def head( # type: ignore
180138
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
181139
) -> _MonkeyPatchedWSGIResponse: ...
182-
@overload # type: ignore
183-
def trace(
184-
self, path: str, data: Any = ..., follow: Literal[False] = ..., secure: bool = ..., **extra: Any
185-
) -> _MonkeyPatchedWSGIResponse: ...
186-
@overload
187-
def trace(
188-
self, path: str, data: Any = ..., follow: Literal[True] = ..., secure: bool = ..., **extra: Any
189-
) -> _MonkeyPatchedWSGIResponseRedirect: ...
190-
@overload
191-
def trace(
140+
def trace( # type: ignore
192141
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
193142
) -> _MonkeyPatchedWSGIResponse: ...
194-
@overload # type: ignore
195-
def put(
196-
self,
197-
path: str,
198-
data: Any = ...,
199-
content_type: str = ...,
200-
follow: Literal[False] = ...,
201-
secure: bool = ...,
202-
**extra: Any
203-
) -> _MonkeyPatchedWSGIResponse: ...
204-
@overload
205-
def put(
206-
self,
207-
path: str,
208-
data: Any = ...,
209-
content_type: str = ...,
210-
follow: Literal[True] = ...,
211-
secure: bool = ...,
212-
**extra: Any
213-
) -> _MonkeyPatchedWSGIResponseRedirect: ...
214-
@overload
215-
def put(
143+
def put( # type: ignore
216144
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
217145
) -> _MonkeyPatchedWSGIResponse: ...
218-
@overload # type: ignore
219-
def patch(
220-
self,
221-
path: str,
222-
data: Any = ...,
223-
content_type: str = ...,
224-
follow: Literal[False] = ...,
225-
secure: bool = ...,
226-
**extra: Any
227-
) -> _MonkeyPatchedWSGIResponse: ...
228-
@overload
229-
def patch(
230-
self,
231-
path: str,
232-
data: Any = ...,
233-
content_type: str = ...,
234-
follow: Literal[True] = ...,
235-
secure: bool = ...,
236-
**extra: Any
237-
) -> _MonkeyPatchedWSGIResponseRedirect: ...
238-
@overload
239-
def patch(
146+
def patch( # type: ignore
240147
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
241148
) -> _MonkeyPatchedWSGIResponse: ...
242-
@overload # type: ignore
243-
def delete(
244-
self,
245-
path: str,
246-
data: Any = ...,
247-
content_type: str = ...,
248-
follow: Literal[False] = ...,
249-
secure: bool = ...,
250-
**extra: Any
251-
) -> _MonkeyPatchedWSGIResponse: ...
252-
@overload
253-
def delete(
254-
self,
255-
path: str,
256-
data: Any = ...,
257-
content_type: str = ...,
258-
follow: Literal[True] = ...,
259-
secure: bool = ...,
260-
**extra: Any
261-
) -> _MonkeyPatchedWSGIResponseRedirect: ...
262-
@overload
263-
def delete(
149+
def delete( # type: ignore
264150
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
265151
) -> _MonkeyPatchedWSGIResponse: ...
266152

tests/typecheck/test/test_client.yml

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
reveal_type(response.client) # N: Revealed type is "django.test.client.Client"
1010
reveal_type(response.context) # N: Revealed type is "Union[django.test.utils.ContextList, builtins.dict[builtins.str, Any]]"
1111
reveal_type(response.content) # N: Revealed type is "builtins.bytes"
12+
reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]"
1213
response.json()
1314
- case: async_client_methods
1415
main: |
@@ -34,76 +35,3 @@
3435
async_factory = AsyncRequestFactory()
3536
async_request = async_factory.get('foo')
3637
reveal_type(async_request) # N: Revealed type is "django.core.handlers.asgi.ASGIRequest"
37-
- case: client_follow_flag
38-
main: |
39-
from django.test.client import Client
40-
client = Client()
41-
response = client.get('foo')
42-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
43-
response = client.get('foo', follow=False)
44-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
45-
response = client.get('foo', follow=True)
46-
reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]"
47-
x: bool
48-
response = client.get('foo', follow=x)
49-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
50-
51-
response = client.post('foo')
52-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
53-
response = client.post('foo', follow=False)
54-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
55-
response = client.post('foo', follow=True)
56-
reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]"
57-
x: bool
58-
response = client.post('foo', follow=x)
59-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
60-
61-
response = client.head('foo')
62-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
63-
response = client.head('foo', follow=False)
64-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
65-
response = client.head('foo', follow=True)
66-
reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]"
67-
x: bool
68-
response = client.head('foo', follow=x)
69-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
70-
71-
response = client.trace('foo')
72-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
73-
response = client.trace('foo', follow=False)
74-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
75-
response = client.trace('foo', follow=True)
76-
reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]"
77-
x: bool
78-
response = client.trace('foo', follow=x)
79-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
80-
81-
response = client.put('foo')
82-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
83-
response = client.put('foo', follow=False)
84-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
85-
response = client.put('foo', follow=True)
86-
reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]"
87-
x: bool
88-
response = client.put('foo', follow=x)
89-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
90-
91-
response = client.patch('foo')
92-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
93-
response = client.patch('foo', follow=False)
94-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
95-
response = client.patch('foo', follow=True)
96-
reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]"
97-
x: bool
98-
response = client.patch('foo', follow=x)
99-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
100-
101-
response = client.delete('foo')
102-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
103-
response = client.delete('foo', follow=False)
104-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"
105-
response = client.delete('foo', follow=True)
106-
reveal_type(response.redirect_chain) # N: Revealed type is "builtins.list[Tuple[builtins.str, builtins.int]]"
107-
x: bool
108-
response = client.delete('foo', follow=x)
109-
response.redirect_chain # E: "_MonkeyPatchedWSGIResponse" has no attribute "redirect_chain"

0 commit comments

Comments
 (0)