falcon
falcon copied to clipboard
Refactor CONSUME_MULTIPLE_SEGMENTS in BaseConverter
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 on CONSUME_MULTIPLE_SEGMENTS
.
https://github.com/falconry/falcon/blob/4910dd73ecd1b9c8cf6cae045b26ad432fa56128/falcon/routing/converters.py#L46-L53
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.
https://github.com/falconry/falcon/blob/4910dd73ecd1b9c8cf6cae045b26ad432fa56128/falcon/routing/converters.py#L61-L62