question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RFC] Make code argument first positional in @response

See original GitHub issue

I opened #193 2 months ago but didn’t get much feedback so I figured I’d open an RFC issue for more visibility.

Currently, status code defaults to 200, which is also Flask default.

    def response(
            self, schema=None, *, code=200, description=None,
            example=None, examples=None, headers=None
    ):

The proposal is to make code mandatory and first positional arg.

    def response(
            self, code, schema=None, *, description=None,
            example=None, examples=None, headers=None
    ):

The first motivation for this was to make the signature coherent with the long-awaited upcoming alt_response decorator (#159).

Obviously, this change breaks everyone’s code, but it is at worst a tedious find’n replace, no feature broken.

Pros

  • In line with alt_response decorator.
  • Nicer visually to have all the codes and schemas aligned.
  • No real reason to have 200 as default, apart from alignment with Flask. In my typical REST API resource, only 3 endpoints out of 5 return a 200.
  • Make it explicit to the user that a code will be added to the response and which one.

Cons

  • Need to specify 200 more than half of the time while it could be the default.
  • Need to change existing codebases.

I’m leaning towards moving on with this, but I can allow a little bit more time for feedback before I do so. It is not so much about counting 👍 and 👎 than letting users express specific concerns I might have overlooked.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Anti-Distinctlymintycommented, Jan 28, 2021

Yes, that was my instinct. In which case my vote is to just go ahead with this and @alt_response. The change is breaking, but minimal effort to fix, and I would greatly appreciate the ability to properly document all responses.

0reactions
lafrechcommented, Feb 13, 2021

Done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC# 691 - IETF
The list of reply codes is also slightly different to reflect the four lists in RFCs ... Servers which do not implement any...
Read more >
rfcs/1951-expand-impl-trait.md at master · rust-lang/rfcs - GitHub
This RFC proposes to stabilize the impl Trait feature with its current syntax, while also expanding it to encompass argument position. That means,...
Read more >
Pre-RFC: Named arguments - language design - Rust Internals
Summary. This RFC introduces named arguments for Rust. Named arguments are the ability to call a function , method or closure while precising ......
Read more >
[RFC] First-class callable syntax - externals.io
I'd like to present an RFC for a first-class callable syntax, which is intended as a simpler alternative to the partial function application...
Read more >
API — Flask Documentation (2.2.x)
The idea of the first parameter is to give Flask an idea of what belongs to your application. ... Run setup code when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found