Skip to content

Add Workers and partial ListenerHolder typing#226

Open
Andrew-Chen-Wang wants to merge 1 commit intoemmett-framework:masterfrom
Andrew-Chen-Wang:andrew/_granian.pyi
Open

Add Workers and partial ListenerHolder typing#226
Andrew-Chen-Wang wants to merge 1 commit intoemmett-framework:masterfrom
Andrew-Chen-Wang:andrew/_granian.pyi

Conversation

@Andrew-Chen-Wang
Copy link
Copy Markdown
Contributor

No description provided.

class RSGIWorker(__WorkerConfig):
...

class WSGIWorker(__WorkerConfig):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WSGIWorker doesn't accept websockets_enabled and opt_enabled parameters


class ListenerHolder:
@classmethod
def from_address(cls, bind_addr: str, port: int, backlog: int) -> "ListenerHolder": ...
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add from __future__ import annotations and remove the string annotation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is future annotations in re of Protocol?

also unless i'm mistaken, the class method doesn't return the instance?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, ListenerHolder.from_address returns an instance, see

pub fn from_address(_cls: &PyType, address: &str, port: u16, backlog: i32) -> PyResult<Self> {

I commented about __future__ so you can rewrite the upper as:

class ListenerHolder:
    @classmethod
    def from_address(cls, bind_addr: str, port: int, backlog: int) -> ListenerHolder: ...

@gi0baro gi0baro force-pushed the master branch 2 times, most recently from ff9588a to 1814868 Compare May 1, 2024 22:24
@gi0baro gi0baro force-pushed the master branch 3 times, most recently from eb5297c to 8f05250 Compare December 12, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants