Skip to content

stub for poplib #1211

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

Merged
merged 2 commits into from
Apr 27, 2017
Merged

stub for poplib #1211

merged 2 commits into from
Apr 27, 2017

Conversation

JelleZijlstra
Copy link
Member

No description provided.

@matthiaskramm
Copy link
Contributor

Strictly speaking, some of these methods, like retr, also work for unicode, on Python 2.

@JelleZijlstra
Copy link
Member Author

Thanks, you're right. I'm just changing all the str types to Text. Strictly speaking maybe the class should be generic over AnyStr in Python 2, but that feels like overkill, so I'd prefer to not do that until we find that it causes issues in real code.

@matthiaskramm
Copy link
Contributor

It didn't occur to me, until just now, that because of the unicode -> Union[unicode, str] promotion, Text is now effectively a synonym for Union[unicode, bytes] on Python 2. (A parameter annotated with Text will happily accept bytes in both mypy and pytype)

In general, is that the behavior we want? Or do we want to explicitly say Union[bytes, Text]?

@matthiaskramm
Copy link
Contributor

Actually, moving this question into python/typing#418, and merging this stub in its current version.

@matthiaskramm matthiaskramm merged commit ee0f341 into python:master Apr 27, 2017
def pass_(self, pswd: Text) -> bytes: ...
def stat(self) -> Tuple[int, int]: ...
def list(self, which: Optional[Text] = ...) -> bytes: ...
def retr(self, which: Text) -> bytes: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found (through testing against some working code) that this is wrong -- it returns a tuple (https://docs.python.org/2/library/poplib.html#poplib.POP3.retr). It also conceivably accepts an int as argument.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I'll submit another PR to fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the argument type, it really accepts anything because the only thing it does with the argument is "%s". I think I put Text because that's the only type that's actually used in the tests. I think I'll just make it Any instead to be safe.

@JelleZijlstra JelleZijlstra deleted the poplib branch April 30, 2017 05:09
gvanrossum pushed a commit that referenced this pull request Apr 30, 2017
Fixes a problem introduced in #1211.
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.

3 participants