PyCQA / PyCQA/isort

Feature Request: section headers and footers support multiple lines

Open
#1,923 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

Currently, I use region folding to nest away and hide my imports:

################################################################################
#region Imports

#===============================================================================
#region stdlib

import sys

#endregion stdlib
#===============================================================================

#===============================================================================
#region third party

import pytest

#endregion third party
#===============================================================================

#endregion Imports
################################################################################

such that they fold into:

################################################################################
#region Imports

#===============================================================================
#region stdlib
#===============================================================================

#===============================================================================
#region third party
#===============================================================================

#endregion Imports
################################################################################

and

################################################################################
#region Imports
################################################################################

It would be really awesome if isort supported multi-line section headers and footers in order to support both fixing and understanding the existence of headers/footers like these.

For config, it would be great if both of these formats were handled (I prefer the array version, but others might not):

import_heading_stdlib = "#===============================================================================\n#region Standard Library\n"

or

import_heading_stdlib = [ 
    "#===============================================================================",
    "#region Standard Library",
    ""
]

Currently if the single string style is used, headers and footers just get repeated.
Currently if the array style is used, all text between and including the square brackets are joined as a string and used.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing isort's existing handling of import_heading configuration, including the single-string and array forms shown in the issue. Verify how headers and footers are currently parsed and emitted; done means both formats preserve multiple lines without repeating headers or joining array syntax incorrectly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.