Open davetapley opened 8 months ago
Hi,
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 https://github.com/falconry/falcon/blob/4910dd73ecd1b9c8cf6cae045b26ad432fa56128/falcon/routing/converters.py#L34
but as the docs give the type of
value
⬇️ depend onCONSUME_MULTIPLE_SEGMENTS
. https://github.com/falconry/falcon/blob/4910dd73ecd1b9c8cf6cae045b26ad432fa56128/falcon/routing/converters.py#L46-L53This 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. https://github.com/falconry/falcon/blob/4910dd73ecd1b9c8cf6cae045b26ad432fa56128/falcon/routing/converters.py#L61-L62