mirror of
https://github.com/httpie/cli.git
synced 2025-06-23 19:11:30 +02:00
Add more types and docs for plugins API
This commit is contained in:
parent
f954c9e2b7
commit
e1627803fe
@ -1,5 +1,7 @@
|
|||||||
class BasePlugin:
|
from typing import Tuple, Union
|
||||||
|
|
||||||
|
|
||||||
|
class BasePlugin:
|
||||||
# The name of the plugin, eg. "My auth".
|
# The name of the plugin, eg. "My auth".
|
||||||
name = None
|
name = None
|
||||||
|
|
||||||
@ -53,7 +55,7 @@ class AuthPlugin(BasePlugin):
|
|||||||
# then this is `None`.
|
# then this is `None`.
|
||||||
raw_auth = None
|
raw_auth = None
|
||||||
|
|
||||||
def get_auth(self, username=None, password=None):
|
def get_auth(self, username: str = None, password: str = None):
|
||||||
"""
|
"""
|
||||||
If `auth_parse` is set to `True`, then `username`
|
If `auth_parse` is set to `True`, then `username`
|
||||||
and `password` contain the parsed credentials.
|
and `password` contain the parsed credentials.
|
||||||
@ -101,14 +103,19 @@ class ConverterPlugin(BasePlugin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, mime):
|
def __init__(self, mime: str):
|
||||||
self.mime = mime
|
self.mime = mime
|
||||||
|
|
||||||
def convert(self, content_bytes):
|
def convert(self, content_bytes: bytes) -> Tuple[str, Union[str, bytes]]:
|
||||||
|
"""
|
||||||
|
Convert content as needed and return a tuple containing the new Content-Type and content, e.g.:
|
||||||
|
('application/json', '{}')
|
||||||
|
|
||||||
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def supports(cls, mime):
|
def supports(cls, mime: str) -> bool:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user