Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt style guide + checks #13

Open
steven-esser opened this issue Nov 2, 2020 · 9 comments
Open

Adopt style guide + checks #13

steven-esser opened this issue Nov 2, 2020 · 9 comments

Comments

@steven-esser
Copy link
Contributor

@pombredanne @JonoYang @AyanSinhaMahapatra @sbs2001

We need to make a decision as to what our python style approach should be. We have in the past a mix of PEP8 and some using black. I am not opposed to any method, we just need to decide on something.

Thoughts?

@JonoYang
Copy link
Member

JonoYang commented Nov 2, 2020

@MaJuRG I think it would be best to run black before committing code or (if possible) have some way to run black automatically on code that we push to a repo.

@sbs2001
Copy link

sbs2001 commented Nov 2, 2020

@JonoYang

For

run black before committing code

That can be handled by using a git pre-commit hook alright. We can add that too in the skeleton .

have some way to run black automatically on code that we push to a repo.

This can be done via github action or even as a part of travis.

Having said that I don't think it would be a good idea to adopt black 100%. Rather incremental adoption seems a better/safer approach, especially in the context of huge codebase like scancode. For this we could run black only on the files which are changed.

Do note that black has default line limit of 88 characters, which might need to be overridden with some other limit.

Unrelated :
@MaJuRG as this repo is a template for the org's projects, why not make it a template repo ? https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-template-repository .

@AyanSinhaMahapatra
Copy link
Member

@sbs2001 that makes a lot of sense.

Using black in a pre-commit hook and addition to Travis (like with some reasonable changes like the character limit as you mentioned) and then incremental addition (maybe adding tickets to fully adopt the standard) seems alright. Anyway running on changed files is reasonable since it's better than to run on all files.

And adding this as a template repo also makes sense, for any new projects.

@steven-esser
Copy link
Contributor Author

@sbs2001 @AyanSinhaMahapatra

Interesting idea about making this repo a GH "template". As long as nothing strange happens to this repo on the GH side once enabled, we can probably adopt this feature.

@steven-esser
Copy link
Contributor Author

steven-esser commented Nov 4, 2020

w.r.t. the black question:

I think the real question is do we want to use black or do we use style-check scripts and leave it up to the user to fix issues manually. In the context of this skeleton repo, we have approached from an "automation-first" perspective. The less manual intervention, the better and I believe @JonoYang and @pombredanne agree with me here.

As far as the incremental adoption, remember that we are just discussing in the skeleton repo context. Many existing repos (such as scancode-toolkit) have yet to adopt this internal standard and therefore would not be immediately effected by the adoption of black.

@sbs2001
Copy link

sbs2001 commented Nov 5, 2020

@MaJuRG how about using black for both ? black --check as style check in CI and black <whatever> for formatting (which the commiter would need to run).

@steven-esser
Copy link
Contributor Author

@sbs2001 Good point thanks :) This fits nicely.

@sbs2001
Copy link

sbs2001 commented Mar 5, 2021

VulnerableCode finally uses black for both formatting and checking :)

1 similar comment
@sbs2001
Copy link

sbs2001 commented Mar 5, 2021

VulnerableCode finally uses black for both formatting and checking :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants