-
-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Set up style guide and tooling for consistency in backend code #1008
Comments
Part of this is a copy-paste of a comment I left in Matrix. The issue is called "Backend Codebase should follow consistent coding style", but I think that's too strong of a statement. I was expecting to discuss adding automatic formatting rules. Style is not a very well defined term. I'd say we should discuss the formatting we use and/or want to enforce. |
We definitely cannot expect 100% consistent codebase, but we can add a few rules that would choose one style over the other when given two sensible options |
As I argued on Matrix: I think the easiest way to get this off the ground quickly would be with the |
I wish we could have personal setups and a single neutral rule-set for the repository. We apply black to what we check out to personalize the code, then we apply black to de-personalize when commiting. Not sure if that's feasible. Totally tangential, but I feel like code versioning systems should account for the fact that there's a lot of changes you can make to code that only affects its formatting and are totally irrelevant to compilers. Then you could format stuff however you like and not affect any other developer's experience. Though, you'd still have to take care to write good code. Short functions and all that. |
@mathemancer and I discussed the usage of The issue with |
I've looked at black's style guide: https://black.readthedocs.io/en/latest/the_black_code_style/current_style.html and I really liked it. It should solve some pain points that I've been experiencing. I'm antsy to try it out on our codebase to get a better picture of the effect. I don't feel like I have an hour to burn at the moment. If anyone would like to do it, go ahead! |
@dmos62 I'm very skeptical of |
@kgodey my idea is let's run black and look at the output. Then we have something to talk about. I haven't looked at its style configuration, but it mentions that it purposefully doesn't offer a lot of options. |
@dmos62 We already did that early on in the project and then disabled it. I've also used it at previous workplaces. |
I'll include another link here to the code-style guidelines/tooling discussion thread, since we seem to be discussing this on two threads simultaneously: #1007. |
Sorry, I wasn't aware of this ticket when I commented on #1007. @kgodey said:
I'm curious to hear more about your concern here. Can you provide an example of a case in which you find it helpful to communicate intent through code formatting? I also wonder whether Mathesar's python code might contain intent within formatting that fails to reach me because I typically do not attempt to infer intent from formatting while reading code. If we have conventions for communicating intent through formatting in our codebase, are those conventions documented anywhere? |
@seancolsen We have no backend conventions documented anywhere. The action item for this issue is to first document backend style and formatting conventions, and then set up tooling to support those conventions.
I plan to create a draft of our backend style guide first before spending more time on this conversation; I think we'll have a more productive discussion when we actually have a concrete proposal to discuss. I'm reading through everyone's comments on this issue and on #1007 and I'll make sure to address them in the style guide. It might take me a couple of weeks because my current priority is getting the Views product work done. |
@kgodey you've mentioned disliking |
@dmos62 Turning on You are free to experiment with |
Didn't mean to hurry. I don't think this is a high priority. |
This issue has not been updated in 90 days and is being marked as stale. |
This is not a current priority, closing this. |
Problem
Right now the backend code has inconsistent styling in few places though they are all valid according to flake8. We should aim to have a style guide that should be followed as much as possible and convert the existing codebase to follow that styleguide
Proposed solution
Come up with a draft of style guide + associated tooling (linters, formatters, etc.), then discuss with the rest of the backend team and finalize it.
Additional context
The text was updated successfully, but these errors were encountered: