Skip to content

Commit

Permalink
Merge pull request #508 from AnswerDotAI/update_dep
Browse files Browse the repository at this point in the history
Update fastcore dep and remove str2x functions
  • Loading branch information
jph00 authored Oct 10, 2024
2 parents 654d6d9 + c40e236 commit ec5e6e7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 75 deletions.
2 changes: 0 additions & 2 deletions fasthtml/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@
'fasthtml.core.serve': ('api/core.html#serve', 'fasthtml/core.py'),
'fasthtml.core.signal_shutdown': ('api/core.html#signal_shutdown', 'fasthtml/core.py'),
'fasthtml.core.snake2hyphens': ('api/core.html#snake2hyphens', 'fasthtml/core.py'),
'fasthtml.core.str2date': ('api/core.html#str2date', 'fasthtml/core.py'),
'fasthtml.core.str2int': ('api/core.html#str2int', 'fasthtml/core.py'),
'fasthtml.core.uri': ('api/core.html#uri', 'fasthtml/core.py')},
'fasthtml.fastapp': { 'fasthtml.fastapp._app_factory': ('api/fastapp.html#_app_factory', 'fasthtml/fastapp.py'),
'fasthtml.fastapp._get_tbl': ('api/fastapp.html#_get_tbl', 'fasthtml/fastapp.py'),
Expand Down
22 changes: 4 additions & 18 deletions fasthtml/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

# %% auto 0
__all__ = ['empty', 'htmx_hdrs', 'fh_cfg', 'htmx_resps', 'htmxsrc', 'htmxwssrc', 'fhjsscr', 'htmxctsrc', 'surrsrc', 'scopesrc',
'viewport', 'charset', 'all_meths', 'parsed_date', 'snake2hyphens', 'HtmxHeaders', 'str2int', 'str2date',
'HttpHeader', 'HtmxResponseHeaders', 'form2dict', 'parse_form', 'flat_xt', 'Beforeware', 'EventStream',
'signal_shutdown', 'WS_RouteX', 'uri', 'decode_uri', 'flat_tuple', 'Redirect', 'RouteX', 'RouterX',
'get_key', 'def_hdrs', 'FastHTML', 'serve', 'Client', 'cookie', 'reg_re_param', 'MiddlewareBase',
'FtResponse']
'viewport', 'charset', 'all_meths', 'parsed_date', 'snake2hyphens', 'HtmxHeaders', 'HttpHeader',
'HtmxResponseHeaders', 'form2dict', 'parse_form', 'flat_xt', 'Beforeware', 'EventStream', 'signal_shutdown',
'WS_RouteX', 'uri', 'decode_uri', 'flat_tuple', 'Redirect', 'RouteX', 'RouterX', 'get_key', 'def_hdrs',
'FastHTML', 'serve', 'Client', 'cookie', 'reg_re_param', 'MiddlewareBase', 'FtResponse']

# %% ../nbs/api/00_core.ipynb
import json,uuid,inspect,types,uvicorn,signal,asyncio,threading
Expand Down Expand Up @@ -71,25 +70,12 @@ def _get_htmx(h):
res = {k:h.get(v.lower(), None) for k,v in htmx_hdrs.items()}
return HtmxHeaders(**res)

# %% ../nbs/api/00_core.ipynb
def str2int(s)->int:
"Convert `s` to an `int`"
s = s.lower()
if s=='on': return 1
if s=='none': return 0
return 0 if not s else int(s)

# %% ../nbs/api/00_core.ipynb
def _mk_list(t, v): return [t(o) for o in v]

# %% ../nbs/api/00_core.ipynb
fh_cfg = AttrDict(indent=True)

# %% ../nbs/api/00_core.ipynb
def str2date(s:str)->date:
"`date.fromisoformat` with empty string handling"
return date.fromisoformat(s) if s else None

# %% ../nbs/api/00_core.ipynb
def _fix_anno(t):
"Create appropriate callable type for casting a `str` to type `t` (or first type in `t` if union)"
Expand Down
58 changes: 4 additions & 54 deletions nbs/api/00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -270,43 +270,6 @@
"_get_htmx(h.headers)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "edbc8d46",
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"def str2int(s)->int:\n",
" \"Convert `s` to an `int`\"\n",
" s = s.lower()\n",
" if s=='on': return 1\n",
" if s=='none': return 0\n",
" return 0 if not s else int(s)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e68fead1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1, 0)"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"str2int('1'),str2int('none')"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -337,19 +300,6 @@
"fh_cfg = AttrDict(indent=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "87871953",
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"def str2date(s:str)->date:\n",
" \"`date.fromisoformat` with empty string handling\"\n",
" return date.fromisoformat(s) if s else None"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1295,7 +1245,7 @@
{
"data": {
"text/plain": [
"'a604e4a2-08e8-462d-aff9-15468891fe09'"
"'8c0971cb-1c05-4aa4-99da-4553d00a0c3f'"
]
},
"execution_count": null,
Expand Down Expand Up @@ -2252,13 +2202,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Set to 2024-10-10 04:51:50.335203\n"
"Set to 2024-10-09 13:14:23.141104\n"
]
},
{
"data": {
"text/plain": [
"'Session time: 2024-10-10 04:51:50.335203'"
"'Session time: 2024-10-09 13:14:23.141104'"
]
},
"execution_count": null,
Expand Down Expand Up @@ -2489,7 +2439,7 @@
{
"data": {
"text/plain": [
"'Cookie was set at time 15:25:23.475549'"
"'Cookie was set at time 13:14:28.411872'"
]
},
"execution_count": null,
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lib_name = fasthtml
version = 0.6.11
min_python = 3.10
license = apache2
requirements = fastcore>=1.7.10 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.0.9 python-multipart beautifulsoup4
requirements = fastcore>=1.7.13 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.0.9 python-multipart beautifulsoup4
dev_requirements = ipython lxml pysymbol_llm
black_formatting = False
conda_user = fastai
Expand Down

0 comments on commit ec5e6e7

Please sign in to comment.