-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
Conversation
✅ Deploy Preview for robyn canceled.
|
@Kludex @RobertCraigie , would it be possible for you folks to have a review at this PR? |
robyn/__init__.pyi
Outdated
import os | ||
import asyncio | ||
import multiprocessing as mp | ||
from inspect import signature | ||
from robyn.events import Events | ||
from .robyn import Server, SocketHeld | ||
from .argument_parser import ArgumentParser | ||
from .responses import jsonify, static_file | ||
from .dev_event_handler import EventHandler | ||
from .processpool import spawn_process | ||
from .log_colors import Colors | ||
from .ws import WS | ||
from .router import MiddlewareRouter, Router, WebSocketRouter | ||
from multiprocess import Process | ||
from watchdog.observers import Observer |
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.
https://github.com/PyCQA/isort would probably make your life easier here.
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 so much for this! How did I not know about this 🤣
robyn/argument_parser.pyi
Outdated
class ArgumentParser(argparse.ArgumentParser): | ||
|
||
def __init__(self) -> None: | ||
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.
You can use ...
instead of pass
, and when you add a docstring, you don't need any. JFYK
pass | |
... |
@Kludex , can you please have a look again? |
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.
@sansyrox Sorry for the delay. It looks pretty good to me!
|
||
pass | ||
|
||
def jsonify(input_dict: dict) -> str: |
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
or object
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
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! I will change it in the next release! :D
Description
TODO:
To create generic types for rust files.Fix docstringsThis PR fixes #130