diff --git a/tools/mk_pyi.py b/tools/mk_pyi.py index 76849232..2af99b3f 100755 --- a/tools/mk_pyi.py +++ b/tools/mk_pyi.py @@ -14,3 +14,37 @@ attrs = (['name'] if o.lower() in named else []) + hx_attrs + evt_attrs attrs_str = ', '.join(f'{t}:{"Any" if t not in hx_attrs_annotations else str(hx_attrs_annotations[t]).replace("typing.","")}=None' for t in attrs) f.write(f"def {o}(*c, {attrs_str}, **kwargs): ...\n") + +with open('fasthtml/core.pyi', 'r+') as f: + methods = """ + def get(self, path:str): + ... + + def post(self, path:str): + ... + + def put(self, path:str): + ... + + def delete(self, path:str): + ... + + def patch(self, path:str): + ... + + def head(self, path:str): + ... + + def options(self, path:str): + ... + + def trace(self, path:str): + ...\n""" + + lines = f.readlines() + for i, line in enumerate(lines): + if line.startswith('all_meths = '): # Add type stubs of request methods before defination of `all_meths`. + lines.insert(i, methods) + break + f.seek(0) + f.writelines(lines)