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

Suppress sections inside functions? #1604

Closed
bryevdv opened this issue Nov 29, 2020 · 3 comments
Closed

Suppress sections inside functions? #1604

bryevdv opened this issue Nov 29, 2020 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@bryevdv
Copy link

bryevdv commented Nov 29, 2020

Trying to update Bokeh to use isort 5 and running in to an issue where isort now wants to add section headers inside functions:

diff --git a/bokeh/client/session.py b/bokeh/client/session.py
index c81b65e62..1629753a0 100644
--- a/bokeh/client/session.py
+++ b/bokeh/client/session.py
@@ -203,6 +203,7 @@ def show_session(session_id=None, url='default', session=None, browser=None, new
             session_id = coords.session_id

         if controller is None:
+            # Bokeh imports
             from bokeh.util.browser import get_browser_controller
             controller = get_browser_controller(browser=browser)

@@ -266,9 +267,11 @@ class ClientSession:
         self._document = None
         self._id = self._ensure_session_id(session_id)

+        # Bokeh imports
         from .connection import ClientConnection
         self._connection = ClientConnection(session=self, io_loop=io_loop, websocket_url=websocket_url, argum

+        # Bokeh imports
         from ..server.callbacks import _DocumentCallbackGroup
         self._callbacks = _DocumentCallbackGroup(self._connection.io_loop)

diff --git a/bokeh/core/property/visual.py b/bokeh/core/property/visual.py
index 99dcf26ed..47985126b 100644
--- a/bokeh/core/property/visual.py
+++ b/bokeh/core/property/visual.py
@@ -151,6 +151,7 @@ class Image(Property):
     """

     def validate(self, value, detail=True):
+        # External imports
         import numpy as np

         if value is None or isinstance(value, (str, PIL.Image.Image)):
@@ -167,6 +168,7 @@ class Image(Property):
         if value is None:
             return

+        # External imports
         import numpy as np
         if isinstance(value, np.ndarray):
             value = PIL.Image.fromarray(value)

We really only want section headings to ever appear once, at the top, module level, and not for every import inside a function. Is there a way to disable this behavior? I did spend time looking over the isort options documentation as well a GIS and GH issue search but did not see anything relevant.

@bryevdv bryevdv changed the title Sections inside functions Suppress sections inside functions? Nov 29, 2020
@timothycrosley timothycrosley added the enhancement New feature or request label Nov 30, 2020
@bryevdv
Copy link
Author

bryevdv commented Nov 30, 2020

@timothycrosley should I infer from the enhancement tag that there is not currently any way to disable this?

@timothycrosley
Copy link
Member

timothycrosley commented Dec 1, 2020

@bryevdv, yes that's correct. There aren't currently separate config options for nested / unested imports. This was somewhat intentional as it keeps everything simple, and so far there hasn't been any requests to do so. However, I think it makes perfect sense to at minimum allow not having headers for nested import sections.

@timothycrosley
Copy link
Member

This is now fixed in develop and will be released in the 5.7.0 release of isort.

Thanks!

~Timothy

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

No branches or pull requests

2 participants