Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web: Type SUPPORTED_METHODS so it can be overridden. #3354

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tornado/test/httpclient_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def patch(self):


class AllMethodsHandler(RequestHandler):
SUPPORTED_METHODS = RequestHandler.SUPPORTED_METHODS + ("OTHER",) # type: ignore
SUPPORTED_METHODS = RequestHandler.SUPPORTED_METHODS + ("OTHER",)

def method(self):
assert self.request.method is not None
Expand Down
4 changes: 1 addition & 3 deletions tornado/test/web_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,9 +2187,7 @@ def test_standard_methods(self):

class PatchMethodTest(SimpleHandlerTestCase):
class Handler(RequestHandler):
SUPPORTED_METHODS = RequestHandler.SUPPORTED_METHODS + ( # type: ignore
"OTHER",
)
SUPPORTED_METHODS = RequestHandler.SUPPORTED_METHODS + ("OTHER",)

def patch(self):
self.write("patch")
Expand Down
12 changes: 10 additions & 2 deletions tornado/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async def main():
import typing

if typing.TYPE_CHECKING:
from typing import Set # noqa: F401
from typing import Collection, Set # noqa: F401


# The following types are accepted by RequestHandler.set_header
Expand Down Expand Up @@ -192,7 +192,15 @@ class RequestHandler(object):

"""

SUPPORTED_METHODS = ("GET", "HEAD", "POST", "DELETE", "PATCH", "PUT", "OPTIONS")
SUPPORTED_METHODS = (
"GET",
"HEAD",
"POST",
"DELETE",
"PATCH",
"PUT",
"OPTIONS",
) # type: Collection[str]

_template_loaders = {} # type: Dict[str, template.BaseLoader]
_template_loader_lock = threading.Lock()
Expand Down
Loading