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

ci: run pre commit in ci for code quality #225

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
17 changes: 6 additions & 11 deletions .github/workflows/codequality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install solara
run: |
pip install ".[dev]" mypy==0.991 black==22.12.0 codespell==2.2.4 "click<8.1.4"
mypy --install-types --non-interactive solara
- name: Run codespell
run: codespell
- name: Run black
run: black solara
- name: Run flake8
uses: suo/flake8-github-action@releases/v1
- name: mypy
run: mypy solara
pip install -e ".[dev]"
- name: Run pre commit
run: |
pip install pre-commit
pre-commit run --all-files --show-diff-on-failure
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- id: flake8
additional_dependencies: [flake8-print]
- repo: https://github.com/PyCQA/isort
rev: 5.11.5
rev: 5.12.0
hooks:
- id: isort
files: \.py$
Expand Down
1 change: 1 addition & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ check_untyped_defs = True
ignore_missing_imports = True
exclude=04-a_directory
no_implicit_optional = False
no_namespace_packages = True
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional, Union

import reacton.ipyvuetify as v

import solara

from .. import auth
Expand Down
1 change: 1 addition & 0 deletions packages/solara-enterprise/solara_enterprise/auth/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from authlib.integrations.flask_client import OAuth
from flask import redirect, request, session

from solara.server import settings

logger = logging.getLogger("solara.enterprise.auth.starlette")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Dict, Optional

from authlib.integrations.starlette_client import OAuth
from solara.server import settings
from starlette.authentication import (
AuthCredentials,
AuthenticationBackend,
Expand All @@ -13,6 +12,8 @@
from starlette.requests import HTTPConnection, Request
from starlette.responses import RedirectResponse

from solara.server import settings

logger = logging.getLogger("solara.enterprise.auth.starlette")


Expand Down
1 change: 1 addition & 0 deletions packages/solara-enterprise/solara_enterprise/cache/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import MutableMapping

import diskcache

import solara.settings
import solara.util

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import pickle
from typing import Any, Callable, MutableMapping

import solara.settings
import solara.util
from cachetools import LRUCache

from solara_enterprise.cache.base import Base, make_key

import solara.settings
import solara.util

logger = logging.getLogger("solara-enterprise.cache.memory")


Expand Down
4 changes: 2 additions & 2 deletions packages/solara-enterprise/solara_enterprise/cache/redis.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Any, Callable, Optional

import redis
import solara.settings

from solara_enterprise.cache.base import Base, make_key

import solara.settings


class Redis(Base):
"""Wraps a client such that the values are pickled/unpickled"""
Expand Down
5 changes: 3 additions & 2 deletions packages/solara-enterprise/solara_enterprise/search/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
from pathlib import Path
from typing import Any, List

import solara
from rich import print as rprint
from solara.server import settings
from typing_extensions import TypedDict

import solara
from solara.server import settings

from .. import license


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ipyvue
import solara
import traitlets

import solara


class SearchWidget(ipyvue.VueTemplate):
template_file = (__file__, "search.vue")
Expand Down
5 changes: 3 additions & 2 deletions packages/solara-enterprise/solara_enterprise/ssg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from pathlib import Path
from typing import List, Optional

import solara
from rich import print as rprint
from solara.server import settings
from typing_extensions import TypedDict

import solara
from solara.server import settings

from . import license

logger = logging.getLogger("solara.server.ssg")
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ line-length = 160
[tool.ruff]
line-length = 160


[tool.isort]
profile = "black"
known_first_party = ["solara", "solara_enterprise"]


[tool.pytest.ini_options]
Expand All @@ -136,3 +138,4 @@ timeout = 180

[tool.codespell]
skip='equis-in-vidi.md,substiterat-vati.md,.*,solara/website/build,*.svg,highlight-dark.css,packages/**/dist/*,node_modules,packages/assets,package*.json,tsconfig.tsbuildinfo'
ignore-words-list='nd,convertor,prolem,ore,limite,sive,currus'
1 change: 1 addition & 0 deletions solara/components/code_highlight_css.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ipyvuetify as vy

import solara


Expand Down
1 change: 1 addition & 0 deletions solara/layout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import reacton.ipyvuetify as v

import solara
from solara.kitchensink import vue

Expand Down
3 changes: 1 addition & 2 deletions solara/server/assets/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4904,7 +4904,7 @@ form{
.bp3-running-text table th, table.bp3-html-table th{
color:#182026;
font-weight:600; }

.bp3-running-text table td,
table.bp3-html-table td{
color:#182026; }
Expand Down Expand Up @@ -14477,4 +14477,3 @@ div.jp-Cell-Placeholder-content-2 {
div.jp-Cell-Placeholder-content-3 {
top: 140px;
}

1 change: 1 addition & 0 deletions solara/template/portal/solara_portal/components/article.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import reacton.ipyvuetify as rv

import solara

from ..data import articles
Expand Down
1 change: 1 addition & 0 deletions solara/template/portal/solara_portal/components/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import reacton.ipyvuetify as rv

import solara

from ..data import dfs
Expand Down
1 change: 1 addition & 0 deletions solara/template/portal/solara_portal/pages/viz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Optional

import plotly.express as px

import solara

from ... import data
Expand Down
1 change: 0 additions & 1 deletion solara/website/pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from ..components import Header, Hero


title = "Home"

route_order = ["/", "showcase", "docs", "api", "examples", "apps"]
Expand Down
1 change: 1 addition & 0 deletions solara/website/pages/api/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import plotly.express as px

import solara

df = px.data.iris()
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/cdn_helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
import os
from pathlib import Path

from solara.server.cdn_helper import get_cdn_url, get_data, get_from_cache, put_in_cache, get_path
from solara.server.cdn_helper import (
get_cdn_url,
get_data,
get_from_cache,
get_path,
put_in_cache,
)


def norm(path):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/cross_filter_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Optional

import solara
import vaex

import solara

df = vaex.from_arrays(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])


Expand Down
3 changes: 2 additions & 1 deletion tests/unit/datatable_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import solara
import vaex

import solara
from solara.components.datatable import DataTable, DataTableWidget

df_vaex = vaex.datasets.titanic()
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/matplotlib_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import solara
from matplotlib.figure import Figure

import solara


@solara.component
def Page():
Expand Down