Skip to content

Commit

Permalink
fixing development
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Nov 12, 2023
1 parent b459134 commit dff86b3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ testcov: test

.PHONY: dev
dev:
uvicorn demo.server:app --reload --reload-dir demo
uvicorn demo.server:app --reload

.PHONY: all
all: testcov lint
4 changes: 2 additions & 2 deletions demo/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pydantic import BaseModel, Field

from fastui import components as c
from fastui import FastUI
from fastui import FastUI, PageEvent, GoToEvent, Display, AnyComponent

app = FastAPI()

Expand Down Expand Up @@ -52,7 +52,7 @@ def read_foo() -> AnyComponent:
],
columns=[
c.Column(field='name', on_click=GoToEvent(url='/api/more/{id}/')),
c.Column(field='dob', display=c.Display.date),
c.Column(field='dob', display=Display.date),
c.Column(field='enabled'),
]
)
Expand Down
4 changes: 2 additions & 2 deletions python/fastui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
__version__ = '0.0.1'

from pydantic import RootModel
import pydantic

from .components import AnyComponent


class FastUI(RootModel):
class FastUI(pydantic.RootModel):
root: AnyComponent
3 changes: 2 additions & 1 deletion python/fastui/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

import pydantic

from . import events, extra
from .. import events
from . import extra
from .table import Table

if typing.TYPE_CHECKING:
Expand Down
21 changes: 3 additions & 18 deletions python/fastui/components/table.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
from __future__ import annotations as _annotations

import typing
from enum import StrEnum

import pydantic

from . import events, extra
from .. import events
from ..display import Display
from . import extra

# TODO allow dataclasses and dicts here too
DataModel = typing.TypeVar('DataModel', bound=pydantic.BaseModel)


class Display(StrEnum):
"""
How to a value.
"""

auto = 'auto' # default, same as None below
plain = 'plain'
datetime = 'datetime'
date = 'date'
duration = 'duration'
as_title = 'as_title'
markdown = 'markdown'
json = 'json'
inline_code = 'inline_code'


class Column(pydantic.BaseModel):
"""
Description of a table column.
Expand Down
17 changes: 17 additions & 0 deletions python/fastui/display.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from enum import StrEnum


class Display(StrEnum):
"""
How to a value.
"""

auto = 'auto' # default, same as None below
plain = 'plain'
datetime = 'datetime'
date = 'date'
duration = 'duration'
as_title = 'as_title'
markdown = 'markdown'
json = 'json'
inline_code = 'inline_code'
File renamed without changes.

0 comments on commit dff86b3

Please sign in to comment.