Should we change the Altair docs to use a more conventional method chaining syntax? #3570
Replies: 3 comments 9 replies
-
While we are talking about changing conventions, there are also other things we can consider for clarity, e.g. maybe we should always write |
Beta Was this translation helpful? Give feedback.
-
Related
|
Beta Was this translation helpful? Give feedback.
-
I'd be in favour of using whatever ruff does. +1 to all the advantages you listed. It's also the code style that users are likely to know from their own code bases where the formatters black and ruff (very similar in style for the purposes of this discussion) are ubiquitous.
The beauty of a code formatter would be that you can still use the current approach, but when saving the file/creating a PR/..., ruff takes care of this for you :) So everyone can still write however they want, but in the end it looks the same. |
Beta Was this translation helpful? Give feedback.
-
This has come up a few times in various issues, so I'm just making a single discussion for it here. Currently the altair documentation uses a less conventional syntax for method chaining:
It seems to be more popular in other libraries to use wrapping parens instead (e.g. pandas, polars, seaborn, ibis):
In addition to being more easily recognizable by folks new to the library, the second approach also has the advantage of being correctly autoformatted by ruff and similar formatters (and maybe it is clearer to read with exactly one method per line?). At the same time I have found the current approach quite convenient to type as I don't have to go back to add a parenthesis and I sometimes use it for other libraries as well (although I remember initially finding it confusing so it might just be me getting used to it). I see advantages of both approaches and the current one has been around for quite some time, although if I were to write a new library today I would probably opt for the second approach for consistency with other libraries and formatters.
A few places where this has come up:
when-then-otherwise
in User Guide #3544 (comment)Beta Was this translation helpful? Give feedback.
All reactions