Checking responders signatures
- Dominant language
- Python
- Stars
- 9.8k
- Forks
- 1k
- Avg merge
- 5d 9h
- Merged PRs (30d)
- 9
Description
I propose adding check if responder arguments match the template fields. Now it's easy to introduce error by renaming
arguments while refactoring.
Since this feature is likely to use the heavy `inspect` module, it may be implemented in `inspect_app`, which
imports it anyway. Then inspect_app will additionally emit warnings if arguments mismatch.
Also for type-annotated arguments it may be useful to check if type matches the field converter type.
```python
fields = get_route_fields()
responder = get_route_responder()
req, resp, *args = inspect.signature(responder).values()
for field, arg in zip(fields, args):
check_arg(field, arg)
check_anno(field, arg.annotation)
```
Contributor guide
Research direction
Start by reading the inspect_app entry point and the existing get_route_fields and get_route_responder flow. Review how inspect.signature and responder warnings are currently handled, then define the expected behavior for argument-name and annotation mismatches. Done means the proposal's checks and warning behavior are specified and covered by appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100