Skip to content

Commit

Permalink
Fix type stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed May 7, 2022
1 parent d97f474 commit 8fd7000
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 177 deletions.
85 changes: 43 additions & 42 deletions robyn/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ from watchdog.observers import Observer

from typing import Callable


class Robyn:
"""This is the python wrapper for the Robyn binaries."""

def __init__(self, file_object: str) -> None:
pass
...

def before_request(self, endpoint: str): # -> (handler: Unknown) -> None:
def before_request(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.before_request decorator to add a get route]
The @app.before_request decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""

pass
...

def after_request(self, endpoint: str): # -> (handler: Unknown) -> None:
"""
Expand All @@ -38,7 +39,7 @@ class Robyn:
:param endpoint [str]: [endpoint to server the route]
"""

pass
...

def add_directory(
self,
Expand All @@ -47,103 +48,103 @@ class Robyn:
index_file: str = ...,
show_files_listing: str = ...,
):
pass
...

def add_header(self, key: str, value: str) -> None:
pass
...

def add_web_socket(self, endpoint: str, ws: WS) -> None:
pass
...

def startup_handler(self, handler: Callable) -> None:
pass
...

def shutdown_handler(self, handler: Callable) -> None:
pass
...

def start(self, url: str = ..., port: int = ...) -> None:
"""
[Starts the server]
Starts the server
:param port [int]: [reperesents the port number at which the server is listening]
:param port int: reperesents the port number at which the server is listening
"""

pass
...

def get(self, endpoint: str): # -> (handler: Unknown) -> None:
def get(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.get decorator to add a get route]
The @app.get decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""
pass
...

def post(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.post decorator to add a get route]
The @app.post decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""
pass
...

def put(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.put decorator to add a get route]
The @app.put decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""

pass
...

def delete(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.delete decorator to add a get route]
The @app.delete decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""

pass
...

def patch(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.patch decorator to add a get route]
The @app.patch decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""

pass
...

def head(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.head decorator to add a get route]
The @app.head decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""

pass
...

def options(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.options decorator to add a get route]
The @app.options decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""

pass
...

def connect(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.connect decorator to add a get route]
The @app.connect decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""
pass
...

def trace(self, endpoint: str) -> Callable[..., None]:
"""
[The @app.trace decorator to add a get route]
The @app.trace decorator to add a get route
:param endpoint [str]: [endpoint to server the route]
:param endpoint str: endpoint to server the route
"""

pass
...
22 changes: 14 additions & 8 deletions robyn/processpool.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
from numbers import Number
from robyn.ws import WS
from robyn.events import Events
from robyn.robyn import SocketHeld

from typing import Dict, Tuple, Callable

Route = Tuple[str, str, Callable, bool, int]


def spawn_process(
directories: tuple,
headers: tuple,
routes: tuple,
middlewares: tuple,
web_sockets: list,
event_handlers: dict,
directories: Tuple[str, str, str, str],
headers: Tuple[str, str],
routes: Tuple[Route],
middlewares: Tuple[Route],
web_sockets: Dict[str, WS],
event_handlers: Dict[Events, list],
socket: SocketHeld,
workers: Number,
) -> None:
Expand All @@ -18,8 +24,8 @@ def spawn_process(
:param directories tuple: the list of all the directories and related data in a tuple
:param headers tuple: All the global headers in a tuple
:param routes tuple: The routes touple, containing the description about every route.
:param middlewares tuple: The middleware router touple, containing the description about every route.
:param routes Tuple[Route]: The routes touple, containing the description about every route.
:param middlewares Tuple[Route]: The middleware router touple, containing the description about every route.
:param web_sockets list: This is a list of all the web socket routes
:param event_handlers Dict: This is an event dict that contains the event handlers
:param socket SocketHeld: This is the main tcp socket, which is being shared across multiple processes.
Expand Down
126 changes: 0 additions & 126 deletions robyn/robyn.cpython-38-darwin.pyi

This file was deleted.

4 changes: 3 additions & 1 deletion robyn/router.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from abc import ABC, abstractmethod
from robyn.ws import WS
from typing import Callable
from typing import Callable, List, Tuple

Routes = List[Tuple[str, str, Callable, bool, int]]


class BaseRouter(ABC):
Expand Down

0 comments on commit 8fd7000

Please sign in to comment.