Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Footer Section #1733

Closed
Spectre5 opened this issue May 21, 2021 · 3 comments · Fixed by #1817
Closed

Feature Request: Footer Section #1733

Spectre5 opened this issue May 21, 2021 · 3 comments · Fixed by #1817
Labels
enhancement New feature or request

Comments

@Spectre5
Copy link

There is already a feature to add import headings at the start of a section. Can we also add a footer at the end of the section? My use case is where I've made a custom section for some libraries that are not available in the development environment and so I want to surround those imports with disable and enable tags to silence pylint.

Currently I just use the enable comment as the heading for the next section, but this is fragile as there are times where that section doesn't exist and thus the imports are disabled for the entire rest of the file.

As a quick example of what I'd like to have:

import os

# pylint: disable=import-error
import library_not_available_in_dev

# pylint: enable=import-error

import first_party

Note that I've added a blank line before the line # pylint: enable=import-error for compatibility with black which doesn't allow a comment on a line directly after an import.

I realize that I could just use import library_not_available_in_dev # pylint: disable=import-error on a single line instead, but in my actual application I have many of these libraries that are not available and thus it is cleaner/preferable to surround that block of imports with disable/enable tags as I've shown.

@timothycrosley timothycrosley added the enhancement New feature or request label May 22, 2021
@timothycrosley
Copy link
Member

I like this idea! And would happily merge in a PR that adds support - or circle back and complete it for a future version. Thanks for submitting the improvement ticket!

@Spectre5
Copy link
Author

Great. My personal life is busy at the moment, but if you don't get around to it soon, I'll submit a PR when I can find some time

@Spectre5
Copy link
Author

Spectre5 commented Oct 23, 2021

@timothycrosley can we get a new point release so that this (and any other new features) can be available via PyPI?

(I thought I already commented this, but I don't see it so maybe I forgot to hit comment)

Oops, I see I made it on the PR itself now, sorry for the double message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants