falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.53k stars 945 forks source link

TestClient methods are typed to return _ResultBase, but actually return Result #2207

Closed davetapley closed 1 month ago

davetapley commented 9 months ago

All these methods are typed to return _ResultBase:

https://github.com/falconry/falcon/blob/4910dd73ecd1b9c8cf6cae045b26ad432fa56128/falcon/testing/client.py#L1041-L1046

But actually returns Result here: https://github.com/falconry/falcon/blob/4910dd73ecd1b9c8cf6cae045b26ad432fa56128/falcon/testing/client.py#L638

And Result defines the methods which are useful in testing: https://github.com/falconry/falcon/blob/4910dd73ecd1b9c8cf6cae045b26ad432fa56128/falcon/testing/client.py#L328-L348


But because it's typed _ResultBase I get e.g. Cannot access member "json" for type "_ResultBase", even though the methods work 😬

I presume this is an oversight and not intentional?

CaselIT commented 9 months ago

That seems likely yes. PR to fix would be appreciated!

davetapley commented 9 months ago

Closing for reasons on: https://github.com/falconry/falcon/pull/2209#issuecomment-1922220895

CaselIT commented 9 months ago

it seems doable, with a lot more effort

davetapley commented 9 months ago

@CaselIT I agree! See https://github.com/falconry/falcon/discussions/2210 😁