-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup types for Robyn #192
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,7 @@ | ||
import argparse | ||
|
||
|
||
class ArgumentParser(argparse.ArgumentParser): | ||
|
||
def __init__(self) -> None: | ||
... | ||
|
||
def num_processes(self): | ||
... | ||
|
||
def workers(self): | ||
... | ||
|
||
def is_dev(self): | ||
... | ||
def __init__(self) -> None: ... | ||
def num_processes(self): ... | ||
def workers(self): ... | ||
def is_dev(self): ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
from __future__ import annotations | ||
from typing import Callable, Optional, Tuple | ||
|
||
from typing import Callable, Optional, Tuple | ||
|
||
class SocketHeld: | ||
def __init__(self, url: str, port: int): | ||
pass | ||
|
||
def try_clone(self) -> SocketHeld: | ||
pass | ||
|
||
|
||
class Server: | ||
def __init__(self): | ||
pass | ||
|
||
def add_directory( | ||
self, | ||
route: str, | ||
|
@@ -22,10 +19,8 @@ class Server: | |
show_files_listing: bool, | ||
): | ||
pass | ||
|
||
def add_header(self, key: str, value: str): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if the method just returns None it's generally preferable to be explicit about that to avoid any potential differences in inference between type checkers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it! I will change it in the next release! :D |
||
pass | ||
|
||
def add_route( | ||
self, | ||
route_type: str, | ||
|
@@ -35,7 +30,6 @@ class Server: | |
number_of_params: int, | ||
): | ||
pass | ||
|
||
def add_middleware_route( | ||
self, | ||
route_type: str, | ||
|
@@ -45,13 +39,10 @@ class Server: | |
number_of_params: int, | ||
): | ||
pass | ||
|
||
def add_startup_handler(self, handler: Callable, is_async: bool): | ||
pass | ||
|
||
def add_shutdown_handler(self, handler: Callable, is_async: bool): | ||
pass | ||
|
||
def add_web_socket_route( | ||
self, | ||
route: str, | ||
|
@@ -60,6 +51,5 @@ class Server: | |
message_route: Tuple[Callable, bool, int], | ||
): | ||
pass | ||
|
||
def start(self, socket: SocketHeld, workers: int): | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,39 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Callable, Tuple | ||
|
||
from robyn.ws import WS | ||
from typing import Callable | ||
|
||
Route = Tuple[str, str, Callable, bool, int] | ||
|
||
class BaseRouter(ABC): | ||
@abstractmethod | ||
def add_route(*args) -> None: | ||
pass | ||
|
||
|
||
class Router(BaseRouter): | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def add_route(self, route_type: str, endpoint: str, handler: Callable) -> None: | ||
pass | ||
|
||
def get_routes(self) -> list: | ||
def get_routes(self) -> list[Route]: | ||
pass | ||
|
||
|
||
class MiddlewareRouter(BaseRouter): | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def add_route(self, route_type: str, endpoint: str, handler: Callable) -> None: | ||
pass | ||
|
||
def add_after_request(self, endpoint: str) -> Callable[..., None]: | ||
pass | ||
|
||
def add_before_request(self, endpoint: str) -> Callable[..., None]: | ||
pass | ||
|
||
def get_routes(self) -> list: | ||
def get_routes(self) -> list[Route]: | ||
pass | ||
|
||
|
||
class WebSocketRouter(BaseRouter): | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def add_route(self, endpoint: str, web_socket: WS) -> None: | ||
pass | ||
|
||
def get_routes(self) -> dict[str, WS]: | ||
pass |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
from robyn import Robyn | ||
|
||
|
||
class WS: | ||
"""This is the python wrapper for the web socket that will be used here. | ||
""" | ||
"""This is the python wrapper for the web socket that will be used here.""" | ||
|
||
def __init__(self, robyn_object: Robyn, endpoint: str) -> None: | ||
pass | ||
|
||
def on(self, type: str): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if the type arguments for a generic type don't matter in that context you should still use
Any
orobject
in its place. This is because in strict mode, pyright will report an error if a type annotation is unknown (i.e. missing type arguments).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @RobertCraigie! I will include it in the next release! :D