webcompat / webcompat-metrics-server

Server in charge of delivering different data to the webcompat-metrics-client
Mozilla Public License 2.0
6 stars 5 forks source link

Define the python linter #42

Closed karlcow closed 4 years ago

karlcow commented 6 years ago

There are many different linters for python. We should try to adopt one style and be using the same. Let's document that in the project.

flake8 is a wrapper around linters. so we can add whichever we think is interesting.

For example pylint would detect the non documented class (missing docstrings).

karlcow commented 6 years ago

This is related to #41 too.

karlcow commented 6 years ago

Some references for deciding:

magsout commented 6 years ago

prettier python https://github.com/prettier/plugin-python

karlcow commented 6 years ago

@laghee What you do think want?

My current install of flake8 is

Installed plugins: mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0
laghee commented 6 years ago

@karlcow I think I have a pretty vanilla version of flake8, and I've been using autopep8 to format (which I kind of hate because it won't automatically break long lines). I don't always love auto-formatting either, but I definitely like to have the option to clean up simple things that are a pain to go back and fix by hand.

I'll try out black for a while and see how that goes.

laghee commented 5 years ago

So, a few things about black defaults as pertains to our current codebase:

(*These 2 defaults can be altered/eliminated with command line options.)

Are any (or all 😁 ) of these going to make you want to rip all your hair out, @karlcow?

My fondness for auto-formatting is mostly about line breaks -- constantly looking up how to correctly split an overly long line in various expressions drives me nuts. But I (or whoever) could always run black locally for that sort of thing.

I think it's worth adding blackas a defined project tool if we're happy with their defaults as is. Or if we're only altering one requirement (line length OR double quotes, but not both). Otherwise it seems like it would add more burden than it removes.

Thoughts?

karlcow commented 5 years ago

My fondness for auto-formatting is mostly about line breaks -- constantly looking up how to correctly split an overly long line in various expressions drives me nuts.

I think this is the important thing. We don't want you to go to the nuts hospital. 🃏 Specifically if it makes it easier for both people to write code and reviewer to do less nitpicking it would be a good thing.

And that would make a good testbed for the webcompat.com project.

Let's do it, and I'll let you choose the right amount of custom settings or defaults we should use.

laghee commented 5 years ago

I'm going with black configured to leave line length at the library standard of 79 char, but letting it change all quotes to doubles. I'm drafting documentation for dev setup, so I don't want to move on adding it to requirements.txt until I've worked out the configuration setup with python-dotenv, etc.

I'm thinking we should keep flake8 for CircleCI testing for a while to avoid having current tests break (to avoid this we'd have to do a big overhaul for the single-to-double-quote change). As files are touched, we could gradually transition to double quotes.

karlcow commented 5 years ago

This sounds like a very good plan.

karlcow commented 4 years ago

@laghee do you still use black? What are your configurations?

I'm thinking of making it mandatory. And that would be a good test to see if we would adopt it on webcompat.com.

karlcow commented 4 years ago

https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/ This could be handy.

karlcow commented 4 years ago

Let's make things green https://requires.io/github/webcompat/webcompat-metrics-server/requirements/?branch=42%2F1

laghee commented 4 years ago

@laghee do you still use black? What are your configurations?

The only configuration I customized beyond their defaults is to leave line length at the library standard of 79 characters (so everything is being slowly changed to double quotes).

Missed you, @karlcow 🐮! Glad you're back and healthy.

karlcow commented 4 years ago

ok let's see if we can live with the new proposed settings. And thanks… super happy to be back.