-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add stub for toml #2355
Add stub for toml #2355
Conversation
third_party/2and3/toml.pyi
Outdated
class TomlTz(datetime.tzinfo): | ||
def __init__(self, toml_offset: str) -> None: ... | ||
|
||
def load(f: Union[str, list, IO[str]], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... |
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.
The first two elements of the Union should be Text
and List[Text]
. The implementation looks like it should also support PathLike in 3.6+.
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.
(But I don't feel strongly about whether we should add PathLike support in the stub if the library itself doesn't advertise that it supports PathLike. Your call.)
third_party/2and3/toml.pyi
Outdated
def __init__(self, toml_offset: str) -> None: ... | ||
|
||
def load(f: Union[str, list, IO[str]], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... | ||
def loads(s: str, _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... |
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.
The argument here should also be Text.
third_party/2and3/toml.pyi
Outdated
def load(f: Union[str, list, IO[str]], _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... | ||
def loads(s: str, _dict: Type[MutableMapping[str, Any]] = ...) -> MutableMapping[str, Any]: ... | ||
|
||
def dump(o: Mapping[str, Any], f: IO[str]) -> 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.
f
can actually be any object with a write
method. Perhaps we should go with the python/typing#564 of defining a simple protocol for this argument. In this case, it would just have def write(self, obj: str) -> Any: ...
.
I decided to add PathLike and pathlib.PurePath support since those look pretty intentional (uiri/toml#159).
third_party/2and3/toml.pyi
Outdated
|
||
class TomlDecodeError(Exception): ... | ||
|
||
class TomlTz(datetime.tzinfo): |
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.
Hm, this actually doesn't exist in master (https://github.com/uiri/toml/blob/master/toml/__init__.py), at least not at the top level.
I was looking at my installed version of toml before, which is apparently pretty out of date.
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.
Relative to master we're also missing TomlArraySeparatorEncoder and a couple of other Encoder and Decoder classes.
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.
I've deleted TomlTz, but I'd prefer not to add the other things -- they're not mentioned in the API reference in the README.rst. Let someone else finish this once they're documented. (The PR that prompted me to do this isn't even going to be merged.)
Thanks for holding my sloppiness in check!
|
See uiri/toml#178