Skip to content

Commit

Permalink
Add isort pre-commit hook (#3563)
Browse files Browse the repository at this point in the history
* Add isort pre-commit hook

* Apply to other files

* Enforce trailing comma

* Make tests more robust
  • Loading branch information
philippjfr authored May 26, 2022
1 parent bdf0b25 commit 168d9af
Show file tree
Hide file tree
Showing 187 changed files with 730 additions and 562 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ repos:
- id: flake8 # See 'setup.cfg' for args
args: [panel]
files: panel/
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Function to configure serving the panel example apps via jupyter-server-proxy.
"""
import pathlib

from glob import glob

ICON_PATH = str((pathlib.Path(__file__).parent / "examples-icon.svg").absolute())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Function to configure serving the panel example apps via jupyter-server-proxy.
"""
import pathlib

from glob import glob

ICON_PATH = str((pathlib.Path(__file__).parent / "examples-icon.svg").absolute())
Expand Down
2 changes: 2 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

import param

param.parameterized.docstring_signature = False
Expand All @@ -13,6 +14,7 @@
description = 'High-level dashboarding for python visualization libraries'

import panel

version = release = base_version(panel.__version__)

# For the interactivity warning box created by nbsite to point to the right
Expand Down
3 changes: 1 addition & 2 deletions doc/generate_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.


import os
import optparse

import os

# automodule options
OPTIONS = ['members',
Expand Down
2 changes: 2 additions & 0 deletions dodo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os

if "PYCTDEV_ECOSYSTEM" not in os.environ:
os.environ["PYCTDEV_ECOSYSTEM"] = "conda"

from pyctdev import * # noqa: api


def task_pip_on_conda():
"""Experimental: provide pip build env via conda"""
return {'actions':[
Expand Down
6 changes: 3 additions & 3 deletions examples/apps/django2/project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

import sliders.pn_app as sliders_app

from bokeh.server.django import autoload, static_extensions
from django.apps import apps
from django.contrib import admin
from django.urls import path, include
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

import sliders.pn_app as sliders_app
from django.urls import include, path

pn_app_config = apps.get_app_config('bokeh.server.django')

Expand Down
1 change: 1 addition & 0 deletions examples/apps/django2/sliders/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.apps import AppConfig


class SlidersConfig(AppConfig):
name = 'sliders'
1 change: 1 addition & 0 deletions examples/apps/django2/sliders/pn_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .sinewave import SineWave


def app(doc):
sw = SineWave()
row = pn.Row(sw.param, sw.plot)
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/django2/sliders/sinewave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import param
import numpy as np
import param

from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/django2/sliders/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Create your views here.
from bokeh.embed import server_document

from django.http import HttpRequest, HttpResponse
from django.shortcuts import render


def sliders(request: HttpRequest) -> HttpResponse:
script = server_document(request.build_absolute_uri())
return render(request, "base.html", dict(script=script))
1 change: 1 addition & 0 deletions examples/apps/django_multi_apps/django_multi_apps/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os

import django

from channels.routing import get_default_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_multi_apps.settings')
Expand Down
2 changes: 2 additions & 0 deletions examples/apps/django_multi_apps/django_multi_apps/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"""

import os

from pathlib import Path

from bokeh.settings import bokehjsdir, settings

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down
4 changes: 3 additions & 1 deletion examples/apps/django_multi_apps/django_multi_apps/themes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import panel as pn
import holoviews as hv
import hvplot

import panel as pn

# import hvplot.pandas


Expand Down
10 changes: 5 additions & 5 deletions examples/apps/django_multi_apps/django_multi_apps/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

import gbm.pn_app as gbm_app
import sliders.pn_app as sliders_app
import stockscreener.pn_app as stockscreener_app

from bokeh.server.django import autoload, static_extensions
from django.apps import apps
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import path, include

import sliders.pn_app as sliders_app
import gbm.pn_app as gbm_app
import stockscreener.pn_app as stockscreener_app
from django.urls import include, path

from .themes import plot_themes

Expand Down
6 changes: 3 additions & 3 deletions examples/apps/django_multi_apps/gbm/pn_model.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import hvplot
import hvplot.pandas
import numpy as np
import pandas as pd

import param

import panel as pn
import hvplot
import hvplot.pandas


class GBM(param.Parameterized):
Expand Down
1 change: 0 additions & 1 deletion examples/apps/django_multi_apps/gbm/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Create your views here.
from bokeh.embed import server_document

from django.http import HttpRequest, HttpResponse
from django.shortcuts import render

Expand Down
1 change: 1 addition & 0 deletions examples/apps/django_multi_apps/landing/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.shortcuts import render


# Create your views here.
def landing(request):
return render(request, "landing/landing.html")
1 change: 1 addition & 0 deletions examples/apps/django_multi_apps/sliders/pn_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import param

from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

Expand Down
1 change: 0 additions & 1 deletion examples/apps/django_multi_apps/sliders/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Create your views here.
from bokeh.embed import server_document

from django.http import HttpRequest, HttpResponse
from django.shortcuts import render

Expand Down
1 change: 1 addition & 0 deletions examples/apps/django_multi_apps/stockscreener/pn_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

import pandas as pd

import panel as pn

from .pn_model import StockScreener
Expand Down
4 changes: 2 additions & 2 deletions examples/apps/django_multi_apps/stockscreener/pn_model.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import datetime as dt

import panel as pn
import param
import hvplot.pandas
import param

import panel as pn


class StockScreener(param.Parameterized):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# https://stackoverflow.com/questions/55743958/panel-widgets-do-not-update-plot
import datetime as dt

import panel as pn
import param
import holoviews as hv
import hvplot
import hvplot.pandas
import param

import panel as pn

# # initialization
# pn.widgets.DatetimeInput.format = '%d %B %Y'
Expand Down
1 change: 0 additions & 1 deletion examples/apps/django_multi_apps/stockscreener/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Create your views here.
from bokeh.embed import server_document

from django.http import HttpRequest, HttpResponse
from django.shortcuts import render

Expand Down
3 changes: 2 additions & 1 deletion examples/apps/django_multi_apps/stockscreener/zTrials.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import panel as pn
import param

import panel as pn


class CustomExample(param.Parameterized):
"""An example Parameterized class"""
Expand Down
4 changes: 2 additions & 2 deletions examples/apps/fastApi/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import panel as pn
from bokeh.embed import server_document
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates

from sliders.pn_app import createApp

import panel as pn

app = FastAPI()
templates = Jinja2Templates(directory="templates")

Expand Down
1 change: 1 addition & 0 deletions examples/apps/fastApi/sliders/pn_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .sinewave import SineWave


def createApp():
sw = SineWave()
return pn.Row(sw.param, sw.plot).servable()
1 change: 1 addition & 0 deletions examples/apps/fastApi/sliders/sinewave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import param

from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

Expand Down
6 changes: 3 additions & 3 deletions examples/apps/fastApi_multi_apps/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import panel as pn
from bokeh.embed import server_document
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates

from sliders.pn_app import createApp
from sliders2.pn_app import createApp2
from sliders.pn_app import createApp

import panel as pn

app = FastAPI()
templates = Jinja2Templates(directory="templates")
Expand Down
1 change: 1 addition & 0 deletions examples/apps/fastApi_multi_apps/sliders/pn_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .sinewave import SineWave


def createApp():
sw = SineWave()
return pn.Row(sw.param, sw.plot).servable()
1 change: 1 addition & 0 deletions examples/apps/fastApi_multi_apps/sliders/sinewave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import param

from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

Expand Down
1 change: 1 addition & 0 deletions examples/apps/fastApi_multi_apps/sliders2/pn_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .sinewave import SineWave


def createApp2():
sw = SineWave()
return pn.Row(sw.param, sw.plot).servable()
1 change: 1 addition & 0 deletions examples/apps/fastApi_multi_apps/sliders2/sinewave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import param

from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

Expand Down
41 changes: 21 additions & 20 deletions panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,28 @@
To learn more about Panel check out
https://panel.holoviz.org/getting_started/index.html
"""
from . import layout # noqa
from . import links # noqa
from . import pane # noqa
from . import param # noqa
from . import pipeline # noqa
from . import reactive # noqa
from . import viewable # noqa
from . import widgets # noqa

from .config import config, panel_extension as extension, __version__ # noqa
from .depends import bind, depends # noqa
from .interact import interact # noqa
from .io import _jupyter_server_extension_paths, ipywidget, serve, state # noqa
from .layout import ( # noqa
Accordion, Card, Column, GridSpec, GridBox, FlexBox, Tabs, Row,
Spacer, WidgetBox
from . import layout # noqa
from . import links # noqa
from . import pane # noqa
from . import param # noqa
from . import pipeline # noqa
from . import reactive # noqa
from . import viewable # noqa
from . import widgets # noqa
from .config import __version__, config, panel_extension as extension # noqa
from .depends import bind, depends # noqa
from .interact import interact # noqa
from .io import ( # noqa
_jupyter_server_extension_paths, ipywidget, serve, state,
)
from .pane import panel, Pane # noqa
from .param import Param # noqa
from .template import Template # noqa
from .widgets import indicators # noqa
from .layout import ( # noqa
Accordion, Card, Column, FlexBox, GridBox, GridSpec, Row, Spacer, Tabs,
WidgetBox,
)
from .pane import Pane, panel # noqa
from .param import Param # noqa
from .template import Template # noqa
from .widgets import indicators # noqa

__all__ = (
"__version__",
Expand Down
1 change: 1 addition & 0 deletions panel/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys


def main():
from panel.command import main as _main

Expand Down
Loading

0 comments on commit 168d9af

Please sign in to comment.