Skip to content

Suppress sections inside functions? #1604

@bryevdv

Description

@bryevdv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions