Skip to content
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

Merged
merged 4 commits into from
Aug 3, 2018
Merged

Add stub for toml #2355

merged 4 commits into from
Aug 3, 2018

Conversation

gvanrossum
Copy link
Member

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]: ...
Copy link
Member

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+.

Copy link
Member

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.)

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]: ...
Copy link
Member

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.

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: ...
Copy link
Member

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).

class TomlDecodeError(Exception): ...

class TomlTz(datetime.tzinfo):
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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.)

@JelleZijlstra JelleZijlstra merged commit 1965e9d into master Aug 3, 2018
@JelleZijlstra JelleZijlstra deleted the toml branch August 3, 2018 06:02
@gvanrossum
Copy link
Member Author

gvanrossum commented Aug 3, 2018 via email

yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request Jan 23, 2019
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