Skip to content

Commit

Permalink
chore: Update isort configuration for more accurate imports
Browse files Browse the repository at this point in the history
Refines the isort configuration to improve import order and structure within the project. This includes:

-  Enabling `skip_gitignore` to avoid sorting imports in ignored files.
-  Specifying `src_paths` to limit sorting to relevant source code directories.
-  Updating `skip_glob` to exclude additional files from import sorting.

This ensures that imports are organized according to project conventions and improves code readability.
  • Loading branch information
RedAtman committed Aug 6, 2024
1 parent 6750208 commit facf014
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,29 @@ norecursedirs = [
[tool.isort]
# reference: https://pycqa.github.io/isort/docs/configuration/options.html
# settings_file = ".isort.cfg"
profile = "black"
# reverse_sort = true
atomic = true
line_length = 120
skip_gitignore = true
profile = "black"
src_paths = ["isort", "test"]
# reverse_sort = true
# tuple_bracket_spacing = true
# tuple_brackets = false
force_grid_wrap = 0
# force_grid_wrap = 4
# 是否按照嵌套顺序分组导入
force_sort_within_sections = true
# 导入顺序 例如: 在项目中应该先导入标准库、然后是第三方库、最后是自己的模块
sections = [
"FUTURE",
"STDLIB",
"DJANGO",
"THIRDPARTY",
"FIRSTPARTY",
"LOCALFOLDER",
]
# no_lines_before = ["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
# no_lines_before = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
# 是否根据文件中导入语句的顺序对导入进行排序
force_single_line = false
# 是否在导入语句过多时分割成多行
combine_as_imports = false
known_third_party = ["django", "rest_framework"]
known_first_party = ["my_module1"]
known_local_folder = ["my_module3"]
known_django = "django"
# known_third_party = ["django", "rest_framework"]
# known_first_party = ["black", "blib2to3", "blackd", "_black_version"]
# known_local_folder = ["my_module3"]
# known_django = "django"
lines_after_imports = 2
lines_between_types = 1
# multi_line = 3
Expand All @@ -116,14 +111,16 @@ skip = [
"static",
"templates",
'node_modules',
"build",
".tox",
'venv',
'env',
"apps/*/migrations",
"apps/*/static",
"apps/*/templates",
]
extend_skip = ['.md', '.json', '.gitignore', '.dockerignore']
skip_glob = ['docs/*']
skip_glob = ['docs/*', "tests/data", "profiling"]
extend_skip_glob = ['my_*_module.py']
# 是否在导入中添加导入时间戳注释: 要求 isort=>5.5.0
# 在导入中添加导入时间戳注释: 要求 isort=>5.5.0
# annotate = true

0 comments on commit facf014

Please sign in to comment.