[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
b505e2a7bd
commit
585c75aec8
2 changed files with 21 additions and 9 deletions
|
|
@ -1085,16 +1085,27 @@ class Flask(Scaffold):
|
||||||
|
|
||||||
# Check HTTP method
|
# Check HTTP method
|
||||||
supported_http_methods = {
|
supported_http_methods = {
|
||||||
"GET", "POST", "PUT", "PATCH", "DELETE",
|
"GET",
|
||||||
"HEAD", "CONNECT", "OPTIONS", "TRACE",
|
"POST",
|
||||||
"COPY", "LINK", "UNLINK", "PURGE",
|
"PUT",
|
||||||
"LOCK", "UNLOCK", "PROFIND", "VIEW"
|
"PATCH",
|
||||||
|
"DELETE",
|
||||||
|
"HEAD",
|
||||||
|
"CONNECT",
|
||||||
|
"OPTIONS",
|
||||||
|
"TRACE",
|
||||||
|
"COPY",
|
||||||
|
"LINK",
|
||||||
|
"UNLINK",
|
||||||
|
"PURGE",
|
||||||
|
"LOCK",
|
||||||
|
"UNLOCK",
|
||||||
|
"PROFIND",
|
||||||
|
"VIEW",
|
||||||
}
|
}
|
||||||
for item in methods:
|
for item in methods:
|
||||||
if item not in supported_http_methods:
|
if item not in supported_http_methods:
|
||||||
raise TypeError(
|
raise TypeError(f"'{item}' method is not specified in HTTP.")
|
||||||
f"'{item}' method is not specified in HTTP."
|
|
||||||
)
|
|
||||||
|
|
||||||
rule = self.url_rule_class(rule, methods=methods, **options)
|
rule = self.url_rule_class(rule, methods=methods, **options)
|
||||||
rule.provide_automatic_options = provide_automatic_options # type: ignore
|
rule.provide_automatic_options = provide_automatic_options # type: ignore
|
||||||
|
|
|
||||||
|
|
@ -2029,8 +2029,9 @@ def test_app_freed_on_zero_refcount():
|
||||||
|
|
||||||
|
|
||||||
def test_validate_http_method_route(app, client):
|
def test_validate_http_method_route(app, client):
|
||||||
|
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
|
|
||||||
@app.route("/", methods=["BAD_METHOD"])
|
@app.route("/", methods=["BAD_METHOD"])
|
||||||
def bad_method_func():
|
def bad_method_func():
|
||||||
return "Hello World"
|
return "Hello World"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue