Set up code formatting tools
- auto-format code with:
+ autoflake => * remove unused imports and variables
* remove duplicate dict keys
* expand star imports
+ black => enforce an uncompromising code style
+ isort => enforce a consistent import style
compliant with Google's Python style guide
- add nox session "format" to run these tools
This commit is contained in:
parent
ceabb00bab
commit
fb407631d9
5 changed files with 335 additions and 2 deletions
|
|
@ -32,6 +32,10 @@ python = "^3.9"
|
|||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
|
||||
# Code formatters
|
||||
autoflake = "^2.3"
|
||||
black = "^24.8"
|
||||
isort = "^5.13"
|
||||
|
||||
|
||||
[tool.poetry.urls]
|
||||
|
|
@ -40,6 +44,57 @@ python = "^3.9"
|
|||
|
||||
|
||||
|
||||
[tool.autoflake]
|
||||
# Source: https://github.com/PyCQA/autoflake#configuration
|
||||
|
||||
in-place = true
|
||||
recursive = true
|
||||
expand-star-imports = true
|
||||
remove-all-unused-imports = true
|
||||
ignore-init-module-imports = true # modifies "remove-all-unused-imports"
|
||||
remove-duplicate-keys = true
|
||||
remove-unused-variables = true
|
||||
|
||||
|
||||
|
||||
[tool.black]
|
||||
# Source: https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html
|
||||
|
||||
line-length = 88
|
||||
target-version = ["py312", "py311", "py310", "py39"]
|
||||
|
||||
|
||||
|
||||
[tool.isort]
|
||||
# Source: https://pycqa.github.io/isort/docs/configuration/options.html
|
||||
|
||||
known_first_party = ["lalib"]
|
||||
|
||||
atomic = true
|
||||
case_sensitive = true
|
||||
combine_star = true
|
||||
force_alphabetical_sort_within_sections = true
|
||||
lines_after_imports = 2
|
||||
remove_redundant_aliases = true
|
||||
|
||||
# Comply with black's style => Instead of: 'profile = "black"'
|
||||
# Source: https://pycqa.github.io/isort/docs/configuration/profiles.html
|
||||
ensure_newline_before_comments = true
|
||||
force_grid_wrap = 0
|
||||
include_trailing_comma = true
|
||||
line_length = 88
|
||||
multi_line_output = 3
|
||||
split_on_trailing_comma = true
|
||||
use_parentheses = true
|
||||
|
||||
# Comply with Google's Python style guide
|
||||
# => All imports go on a single line (with some exceptions)
|
||||
# Source: https://google.github.io/styleguide/pyguide.html#313-imports-formatting
|
||||
force_single_line = true
|
||||
single_line_exclusions = ["collections.abc", "typing"]
|
||||
|
||||
|
||||
|
||||
[build-system]
|
||||
|
||||
requires = ["poetry-core"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue