Draft
Conversation
Owner
|
I am going to add support for auto-formatting with black and isort based on this once I've figured out how likely my VPS is going to handle installing Python 3.6+ (black requirement) as I just noticed it still runs on 3.5. |
Owner
|
I recently setup that combination on another project with pre-commit and ran into some caveats, namely isort having issues figuring out which libraries are third- or first-party and thus confusing their ordering. I could fix those by introducing another pre-step that will populate a list of third party libraries before running isort. This is the pre-commit configuration, isort configuration and black configuration that I used: .pre-commit-config.yamlrepos:
# Note: black config can be found in the pyproject.toml
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3.7
# This little thingie helps isort to figure out what libraries are
# third party, see https://github.com/asottile/seed-isort-config
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.2
hooks:
- id: seed-isort-config
# Note: isort config can be found in the .isort.cfg
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
name: isort
entry: isort
require_serial: true
language: python
types: [python]
exclude: migrations/*.py
pyproject.toml[tool.black]
line-length = 88
target_version = ['py37']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
).isort.cfg[settings]
force_grid_wrap=False
force_single_line=True
include_trailing_comma=True
line_length=88
multi_line_output=3
use_parentheses=True
known_third_party=
known_first_party=msrcms
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP. Fixes #15
Added black formatting, pre-commit & black config file and updated travis file.
I would need some information about the coding format for this project before I apply the formatting via black.