You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Convert a URI template field value to another format or type.
Args:
value (str or List[str]): Original string to convert.
If ``CONSUME_MULTIPLE_SEGMENTS=True`` this value is a
list of strings containing the path segments matched by
the converter.
This is a bit awkward because CONSUME_MULTIPLE_SEGMENTS can only be known at run time, but it's so tightly coupled to the behavior of the class it feels like it should be static.
Can I propose having two classes instead, e.g. BaseConverter and BaseConverterMultipleSegment, with value as str and list[str] respectively?
Then we could probably get rid of ⬇️ and just do an isinstance check.
The main reason for the current design is that converters for historical reason do not need to be subclasses of BaseConverter, but ducktyping is used.
I'm not opposed to changing the requirement to have them being a sublcass of BaseConverter and BaseConverterMultipleSegment but it would likely be a v5 since it would be nicer if v4 would just raise deprecation warnings for this.
I was going to add types to
falcon/falcon/routing/converters.py
Line 34 in 4910dd7
but as the docs give the type of
value
⬇️ depend onCONSUME_MULTIPLE_SEGMENTS
.falcon/falcon/routing/converters.py
Lines 46 to 53 in 4910dd7
This is a bit awkward because
CONSUME_MULTIPLE_SEGMENTS
can only be known at run time, but it's so tightly coupled to the behavior of the class it feels like it should be static.Can I propose having two classes instead, e.g.
BaseConverter
andBaseConverterMultipleSegment
, withvalue
asstr
andlist[str]
respectively?Then we could probably get rid of ⬇️ and just do an
isinstance
check.falcon/falcon/routing/converters.py
Lines 61 to 62 in 4910dd7
The text was updated successfully, but these errors were encountered: