Skip to content

Commit

Permalink
Include instance attributes on Request stub
Browse files Browse the repository at this point in the history
Adding the stub for `getHeader` means that mypy isn't looking at
twisted's implementation to deduce what types instance attributes have.
So let's add those to the stub.

I don't want to maintain a stub out-of-tree forever, but I've submitted
the `getHeader` annotation upstream in
twisted/twisted#1669 .
  • Loading branch information
David Robertson committed Oct 21, 2021
1 parent 9e69559 commit c0f7400
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion stubs/twisted/web/http.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
from typing import AnyStr, Optional
import typing
from typing import AnyStr, Optional, Dict, List

from twisted.internet.defer import Deferred
from twisted.logger import Logger
from twisted.web.http_headers import Headers


class Request:

method: bytes
uri: bytes
path: bytes
args: Dict[bytes, List[bytes]]
content: typing.BinaryIO
cookies: List[bytes]
requestHeaders: Headers
responseHeaders: Headers
notifications: List[Deferred[None]]
_disconnected: bool
_log: Logger

def getHeader(self, key: AnyStr) -> Optional[AnyStr]: ...

0 comments on commit c0f7400

Please sign in to comment.