moving python

This commit is contained in:
Samuel Colvin
2023-11-12 20:15:23 +00:00
parent 9e905332f3
commit eb6147512c
35 changed files with 92 additions and 16 deletions

View File

@@ -2,7 +2,7 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
# - id: no-commit-to-branch
- id: no-commit-to-branch
- id: check-yaml
args: ['--unsafe']
- id: check-toml

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2023 to present Samuel Colvin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# FastUI
WIP

View File

@@ -3,20 +3,15 @@ from __future__ import annotations as _annotations
from datetime import date
from fastapi import FastAPI
from pydantic import RootModel, BaseModel, Field
from pydantic import BaseModel, Field
import components as c
from components import AnyComponent
from components.events import PageEvent, GoToEvent
from fastui import components as c
from fastui import FastUI
app = FastAPI()
class FastUi(RootModel):
root: AnyComponent
@app.get('/api/', response_model=FastUi, response_model_exclude_none=True)
@app.get('/api/', response_model=FastUI, response_model_exclude_none=True)
def read_root() -> AnyComponent:
return c.Page(
children=[
@@ -44,7 +39,7 @@ class MyTableRow(BaseModel):
enabled: bool | None = None
@app.get('/api/table', response_model=FastUi, response_model_exclude_none=True)
@app.get('/api/table', response_model=FastUI, response_model_exclude_none=True)
def read_foo() -> AnyComponent:
return c.Page(
children=[

View File

@@ -20,7 +20,7 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"fastui": ["../frontend/fastui"]
"fastui": ["../react/fastui"]
}
},
"include": ["src"],

View File

@@ -17,7 +17,7 @@ export default () => {
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
fastui: path.resolve(__dirname, '../frontend/fastui'),
fastui: path.resolve(__dirname, '../react/fastui'),
},
},
server: serverConfig,

View File

@@ -9,7 +9,7 @@
"typecheck": "tsc --noEmit",
"build": "tsc",
"typewatch": "tsc --noEmit --watch",
"lint": "eslint frontend --ext .ts,.tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint react --ext .ts,.tsx --report-unused-disable-directives --max-warnings 0",
"lint-fix": "npm run lint -- --fix",
"prettier": "prettier --write",
"format": "npm run prettier -- . && npm run lint-fix"

49
pyproject.toml Normal file
View File

@@ -0,0 +1,49 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.sdist]
include = ["python"]
[tool.hatch.build.targets.wheel]
packages = ["python/fastui"]
[tool.hatch.version]
path = "python/fastui/__init__.py"
[project]
name = "fastui"
description = "Build UIs fast."
authors = [{ name = "Samuel Colvin", email = "s@muelcolvin.com" }]
license = "MIT"
readme = "README.md"
classifiers = [
"Development Status :: 4 - Beta",
"Topic :: Internet",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
]
requires-python = ">=3.8"
dependencies = [
"pydantic>=2.5.0b1",
"fastapi>=0.104.0",
]
dynamic = ["version"]
[project.urls]
Homepage = "https://github.com/samuelcolvin/fastui"
[tool.ruff]
line-length = 120
extend-select = ["Q", "RUF100", "UP", "I"]
flake8-quotes = {inline-quotes = "single", multiline-quotes = "double"}
target-version = "py38"

View File

@@ -0,0 +1,8 @@
__version__ = '0.0.1'
from pydantic import RootModel
from .components import AnyComponent
class FastUI(RootModel):
root: AnyComponent

View File

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"outDir": "./frontend-dist",
"outDir": "./react-dist",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
@@ -20,5 +20,5 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["frontend"]
"include": ["react"]
}