Skip to content

Commit b5a26d1

Browse files
authored
email.message: Fix invalid TypeVar usage; add some default values (#9620)
1 parent 6011cac commit b5a26d1

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

stdlib/email/message.pyi

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,52 @@ class Message:
3838
def keys(self) -> list[str]: ...
3939
def values(self) -> list[_HeaderType]: ...
4040
def items(self) -> list[tuple[str, _HeaderType]]: ...
41-
def get(self, name: str, failobj: _T = ...) -> _HeaderType | _T: ...
42-
def get_all(self, name: str, failobj: _T = ...) -> list[_HeaderType] | _T: ...
41+
@overload
42+
def get(self, name: str, failobj: None = None) -> _HeaderType | None: ...
43+
@overload
44+
def get(self, name: str, failobj: _T) -> _HeaderType | _T: ...
45+
@overload
46+
def get_all(self, name: str, failobj: None = None) -> list[_HeaderType] | None: ...
47+
@overload
48+
def get_all(self, name: str, failobj: _T) -> list[_HeaderType] | _T: ...
4349
def add_header(self, _name: str, _value: str, **_params: _ParamsType) -> None: ...
4450
def replace_header(self, _name: str, _value: _HeaderType) -> None: ...
4551
def get_content_type(self) -> str: ...
4652
def get_content_maintype(self) -> str: ...
4753
def get_content_subtype(self) -> str: ...
4854
def get_default_type(self) -> str: ...
4955
def set_default_type(self, ctype: str) -> None: ...
50-
def get_params(self, failobj: _T = ..., header: str = "content-type", unquote: bool = True) -> list[tuple[str, str]] | _T: ...
51-
def get_param(self, param: str, failobj: _T = ..., header: str = "content-type", unquote: bool = True) -> _T | _ParamType: ...
56+
@overload
57+
def get_params(
58+
self, failobj: None = None, header: str = "content-type", unquote: bool = True
59+
) -> list[tuple[str, str]] | None: ...
60+
@overload
61+
def get_params(self, failobj: _T, header: str = "content-type", unquote: bool = True) -> list[tuple[str, str]] | _T: ...
62+
@overload
63+
def get_param(
64+
self, param: str, failobj: None = None, header: str = "content-type", unquote: bool = True
65+
) -> _ParamType | None: ...
66+
@overload
67+
def get_param(self, param: str, failobj: _T, header: str = "content-type", unquote: bool = True) -> _ParamType | _T: ...
5268
def del_param(self, param: str, header: str = "content-type", requote: bool = True) -> None: ...
5369
def set_type(self, type: str, header: str = "Content-Type", requote: bool = True) -> None: ...
54-
def get_filename(self, failobj: _T = ...) -> _T | str: ...
55-
def get_boundary(self, failobj: _T = ...) -> _T | str: ...
70+
@overload
71+
def get_filename(self, failobj: None = None) -> str | None: ...
72+
@overload
73+
def get_filename(self, failobj: _T) -> str | _T: ...
74+
@overload
75+
def get_boundary(self, failobj: None = None) -> str | None: ...
76+
@overload
77+
def get_boundary(self, failobj: _T) -> str | _T: ...
5678
def set_boundary(self, boundary: str) -> None: ...
5779
@overload
5880
def get_content_charset(self) -> str | None: ...
5981
@overload
6082
def get_content_charset(self, failobj: _T) -> str | _T: ...
61-
def get_charsets(self, failobj: _T = ...) -> _T | list[str]: ...
83+
@overload
84+
def get_charsets(self, failobj: None = None) -> list[str] | None: ...
85+
@overload
86+
def get_charsets(self, failobj: _T) -> list[str] | _T: ...
6287
def walk(self: Self) -> Generator[Self, None, None]: ...
6388
def get_content_disposition(self) -> str | None: ...
6489
def as_string(self, unixfrom: bool = False, maxheaderlen: int = 0, policy: Policy | None = None) -> str: ...

0 commit comments

Comments
 (0)