john-bodley opened a new pull request #7769: [format] Using Black
URL: https://github.com/apache/incubator-superset/pull/7769
 
 
   ### CATEGORY
   
   Choose one
   
   - [ ] Bug Fix
   - [x] Enhancement (new features, refinement)
   - [x] Refactor
   - [ ] Add tests
   - [ ] Build / Development Environment
   - [ ] Documentation
   
   ### SUMMARY
   
   Though for Python we currently use `flake8` and `pylint` for linting and 
error checking these don't auto-format the code and thus it's still relatively 
hard to try to enforce a common code style/format. 
   
   There seems to be three main auto-formatters: 
   
   - [autopep8](https://github.com/hhatto/autopep8)
   - [yapf](https://github.com/google/yapf)
   - [Black](https://github.com/python/black)
   
   
[Here's](https://medium.com/3yourmind/auto-formatters-for-python-8925065f9505) 
a fairly good comparison of the three tools. Note that `yapf` supports a number 
of styles including "pep8" (which is what `autopep8` uses). The "Facebook" 
style is similar to Black. 
   
   It seems like Black (with over 11,000 GitHub stars) is the most popular in 
part because it's not configurable and thus helps ensures consistency across 
various Python repos. 
   
   This PR performs the following:
   
   1. Formats all the code using the Black format. 
   2. Adds a pre-commit hook to auto-format the diff using the Black format on 
every local commit. 
   3. Adds a CI check to ensure that the code is Black format compliant. 
   
   Note the` flake8` and `pylint` CI remains as `flake8` includes checks for 
import ordering as well as type checking. `pylint` additionally checks for 
numerous errors. In the future there would be merit in further cleaning up the 
code and reducing the number of `flake8` codes we ignore. 
   
   ### TEST PLAN
   
   CI.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   ### REVIEWERS
   
   to: @betodealmeida @michellethomas @mistercrunch @villebro 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to