Let's consider this code:
from flask import Flask, url_for
import logging
app = Flask(__name__)
@app.route('/test/<int:x>')
def urltest(x):
return f"{x}"
@app.route("/")
def main():
BUILT_URL = url_for('urltest', x=[1337])
logging.warning(BUILT_URL)
return ""
since Werkzeug v2 (apparently since b45b508), BUILT_URL obtains a value /test/1337. But, as I understand, the call should have raised an error, because the type of parameter x is obviously wrong and should be int, not List[int]. If the value is a list containing single item, it is transformed to just that item. If the value contains many items, it is passed to converter as is.
This behavior breaks my application, because I use the custom converter for lists, similar to this one: https://uniwebsidad.com/libros/explore-flask/chapter-6/url-converters#custom-converters
I don't know, maybe it is a bad idea to build URLs from a list, but this behavior feels just wrong.
Environment:
- Python version: 3.8.5
- Werkzeug version: 2.0.1
Let's consider this code:
since Werkzeug v2 (apparently since b45b508),
BUILT_URLobtains a value/test/1337. But, as I understand, the call should have raised an error, because the type of parameterxis obviously wrong and should beint, notList[int]. If the value is a list containing single item, it is transformed to just that item. If the value contains many items, it is passed to converter as is.This behavior breaks my application, because I use the custom converter for lists, similar to this one: https://uniwebsidad.com/libros/explore-flask/chapter-6/url-converters#custom-converters
I don't know, maybe it is a bad idea to build URLs from a list, but this behavior feels just wrong.
Environment: