Skip to content

Commit

Permalink
fix(stubs): regenerate stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehr-akbarzadeh committed Jul 17, 2024
1 parent f6f94fd commit 6f192d2
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 179 deletions.
3 changes: 3 additions & 0 deletions stubs/sage_imap/decorators.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from sage_imap.exceptions import IMAPMailboxSelectionError as IMAPMailboxSelectionError

def mailbox_selection_required(func): ...
25 changes: 21 additions & 4 deletions stubs/sage_imap/exceptions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,27 @@ class IMAPMailboxFetchError(IMAPMailboxError):
default_detail: str
default_code: str

class EmailException(Exception):
class IMAPAppendError(IMAPMailboxError):
status_code: int
default_detail: str
default_code: str

class IMAPMailboxUploadError(IMAPMailboxError):
status_code: int
default_detail: str
default_code: str

class IMAPThreadError(IMAPMailboxError):
status_code: int
default_detail: str
default_code: str

class IMAPEmptyFileError(IMAPClientError):
status_code: int
default_detail: str
default_code: str

class IMAPInvalidEmailDateError(IMAPClientError):
status_code: int
default_detail: str
default_code: str
detail: Incomplete
code: Incomplete
def __init__(self, detail: str | None = None, code: str | None = None, status_code: int | None = None) -> None: ...
59 changes: 0 additions & 59 deletions stubs/sage_imap/helpers/email.pyi

This file was deleted.

81 changes: 81 additions & 0 deletions stubs/sage_imap/helpers/enums.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from _typeshed import Incomplete
from enum import StrEnum

logger: Incomplete

class Flag(StrEnum):
SEEN: str
ANSWERED: str
FLAGGED: str
DELETED: str
DRAFT: str
RECENT: str

class FlagCommand(StrEnum):
ADD: str
REMOVE: str

class Priority(StrEnum):
HIGH: str
NORMAL: str
LOW: str

class SpamResult(StrEnum):
DEFAULT: str
SPAM: str
NOT_SPAM: str

class AutoResponseSuppress(StrEnum):
ALL: str
DR: str
NDN: str
RN: str
NRN: str
OOF: str
AutoReply: str

class ContentType(StrEnum):
PLAIN: str
HTML: str
MULTIPART: str

class ContentTransferEncoding(StrEnum):
SEVEN_BIT: str
BASE64: str
QUOTED_PRINTABLE: str

class DefaultMailboxes(StrEnum):
INBOX: str
SENT: str
DRAFTS: str
TRASH: str
SPAM: str
ARCHIVE: str

class MailboxStatusItems(StrEnum):
MESSAGES: str
RECENT: str
UIDNEXT: str
UIDVALIDITY: str
UNSEEN: str

class MessagePart(StrEnum):
RFC822: str
BODY: str
BODY_TEXT: str
BODY_HEADER: str
BODY_HEADER_FIELDS: str
FLAGS: str
MODSEQ: str
BODY_STRUCTURE: str
BODY_PEEK: str
BODY_PEEK_TEXT: str
BODY_PEEK_HEADER: str
BODY_PEEK_HEADER_FIELDS: str
BODY_PEEK_ATTACHMENT: str

class ThreadingAlgorithm(StrEnum):
REFERENCES: str
ORDEREDSUBJECT: str
THREAD: str
SEQUENCE: str
16 changes: 0 additions & 16 deletions stubs/sage_imap/helpers/flags.pyi

This file was deleted.

16 changes: 0 additions & 16 deletions stubs/sage_imap/helpers/mailbox.pyi

This file was deleted.

24 changes: 0 additions & 24 deletions stubs/sage_imap/helpers/message.pyi

This file was deleted.

7 changes: 7 additions & 0 deletions stubs/sage_imap/helpers/typings.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from _typeshed import Incomplete

MessageId = str | int
MessageIDList = list[MessageId]
MessageSetType = str | MessageIDList
EmailDate: Incomplete
EmailHeaders = dict[str, str]
EmailAddress: Incomplete
RawEmail: Incomplete
Mailbox: Incomplete
Empty file.
72 changes: 72 additions & 0 deletions stubs/sage_imap/models/email.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import email
from _typeshed import Incomplete
from dataclasses import dataclass
from sage_imap.helpers.enums import Flag as Flag
from sage_imap.helpers.typings import EmailAddress as EmailAddress, EmailDate as EmailDate
from typing import Any, Callable

logger: Incomplete

@dataclass
class Attachment:
filename: str
content_type: str
payload: bytes = ...
id: str | None = ...
content_id: str | None = ...
content_transfer_encoding: str | None = ...
def __init__(self, filename, content_type, payload, id=..., content_id=..., content_transfer_encoding=...) -> None: ...

@dataclass
class EmailMessage:
message_id: str = ...
subject: str = ...
from_address: EmailAddress | None = ...
to_address: list[EmailAddress] = ...
cc_address: list[EmailAddress] = ...
bcc_address: list[EmailAddress] = ...
date: EmailDate | None = ...
raw: bytes | None = ...
plain_body: str = ...
html_body: str = ...
attachments: list[Attachment] = ...
flags: list[Flag] = ...
headers: dict[str, Any] = ...
size: int = ...
sequence_number: int | None = ...
uid: int | None = ...
def __post_init__(self) -> None: ...
@classmethod
def read_from_eml_file(cls, file_path: str) -> EmailMessage: ...
@classmethod
def read_from_eml_bytes(cls, eml_bytes: bytes) -> EmailMessage: ...
def parse_eml_content(self) -> None: ...
def sanitize_message_id(self, message_id: str) -> str | None: ...
def parse_date(self, date_str: str | None) -> EmailDate | None: ...
def extract_body(self, message: email.message.EmailMessage) -> tuple[str, str]: ...
def extract_attachments(self, message: email.message.EmailMessage) -> list[Attachment]: ...
@staticmethod
def extract_flags(flag_data: bytes) -> list[Flag]: ...
def decode_payload(self, part: email.message.EmailMessage) -> str: ...
def has_attachments(self) -> bool: ...
def get_attachment_filenames(self) -> list[str]: ...
def write_to_eml_file(self, file_path: str) -> None: ...
def __init__(self, message_id, subject=..., from_address=..., to_address=..., cc_address=..., bcc_address=..., date=..., raw=..., plain_body=..., html_body=..., attachments=..., flags=..., headers=..., size=..., sequence_number=..., uid=...) -> None: ...

class EmailIterator:
def __init__(self, email_list: list[EmailMessage]) -> None: ...
def __iter__(self) -> EmailIterator: ...
def __next__(self) -> EmailMessage: ...
def __getitem__(self, index: int | slice) -> EmailMessage | EmailIterator: ...
def __len__(self) -> int: ...
def reset(self) -> None: ...
def current_position(self) -> int: ...
def __reversed__(self) -> EmailIterator: ...
def __contains__(self, item: EmailMessage) -> bool: ...
def count(self, condition: Callable[[EmailMessage], bool]) -> int: ...
def filter(self, criteria: Callable[[EmailMessage], bool]) -> EmailIterator: ...
def filter_by_header(self, key: str) -> EmailIterator: ...
def filter_by_subject_part(self, part: str) -> EmailIterator: ...
def find_by_message_id(self, message_id: str) -> EmailMessage | None: ...
def filter_by_attachment(self) -> EmailIterator: ...
def get_total_size(self) -> int: ...
9 changes: 9 additions & 0 deletions stubs/sage_imap/models/message.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from dataclasses import dataclass
from enum import StrEnum as StrEnum
from sage_imap.helpers.typings import MessageSetType as MessageSetType

@dataclass
class MessageSet:
msg_ids: MessageSetType = ...
def __post_init__(self) -> None: ...
def __init__(self, msg_ids=...) -> None: ...
2 changes: 1 addition & 1 deletion stubs/sage_imap/services/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .client import IMAPClient as IMAPClient
from .flag import IMAPFlagService as IMAPFlagService
from .folder import IMAPFolderService as IMAPFolderService
from .mailbox import IMAPMailboxService as IMAPMailboxService
from .mailbox import IMAPMailboxService as IMAPMailboxService, IMAPMailboxUIDService as IMAPMailboxUIDService
34 changes: 0 additions & 34 deletions stubs/sage_imap/services/email.pyi

This file was deleted.

6 changes: 3 additions & 3 deletions stubs/sage_imap/services/flag.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from _typeshed import Incomplete
from sage_imap.exceptions import IMAPFlagOperationError as IMAPFlagOperationError
from sage_imap.helpers.flags import FlagCommand as FlagCommand, Flags as Flags
from sage_imap.helpers.enums import Flag as Flag, FlagCommand as FlagCommand
from sage_imap.models.message import MessageSet as MessageSet

logger: Incomplete

class IMAPFlagService:
mailbox: Incomplete
def __init__(self, mailbox: IMAPMailboxService) -> None: ...
def add_flag(self, msg_ids: MessageSet, flag: Flags) -> None: ...
def remove_flag(self, msg_ids: MessageSet, flag: Flags) -> None: ...
def add_flag(self, msg_ids: MessageSet, flag: Flag) -> None: ...
def remove_flag(self, msg_ids: MessageSet, flag: Flag) -> None: ...
Loading

0 comments on commit 6f192d2

Please sign in to comment.