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

Fix stub for SpooledTemporaryFile #2452

Merged
merged 7 commits into from
Nov 20, 2018
Merged

Fix stub for SpooledTemporaryFile #2452

merged 7 commits into from
Nov 20, 2018

Conversation

ruuda
Copy link
Contributor

@ruuda ruuda commented Sep 12, 2018

Fixes #2431.

Not sure if inheriting from IO[Any] is the right way to do it, because in reality the class does not, but it implements the protocol. What is the proper way to indicate that?

Also updates some argument types to include Optional explicitly, to match the definition.

@srittau
Copy link
Collaborator

srittau commented Sep 12, 2018

At the moment, inheriting from IO[Any] is the best way to do that, although in the far, protocol-based IO future this will not be necessary anymore. Unfortunately that also means that you need to copy the abstract methods from IO into SpooledTemporaryFile.

prefix: Optional[str] = ..., dir: Optional[str] = ...
) -> None: ...
def rollover(self) -> None: ...
def __enter__(self) -> 'SpooledTemporaryFile': ...
Copy link
Member

Choose a reason for hiding this comment

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

Quoting is not necessary in stubs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@ruuda
Copy link
Contributor Author

ruuda commented Oct 26, 2018

Unfortunately that also means that you need to copy the abstract methods from IO into SpooledTemporaryFile.

I copied the abstract methods from IO now.

@srittau
Copy link
Collaborator

srittau commented Oct 31, 2018

Could you have a look at the build failures? It seems that imports of abstractmethod and Iterable are missing. Also, there' s a linter issue.

@ruuda
Copy link
Contributor Author

ruuda commented Oct 31, 2018

Fixed, thanks for the pointers.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Sorry for the long delay, this PR slipped through the cracks somehow.

Please remove the @abstractmethod markers from all methods, since there are concrete implementations in SpooledTemporaryFile. A few more notes below.

stdlib/3/tempfile.pyi Outdated Show resolved Hide resolved
stdlib/3/tempfile.pyi Outdated Show resolved Hide resolved
@srittau
Copy link
Collaborator

srittau commented Nov 20, 2018

CI is failing, because List is not imported.

@srittau srittau merged commit b7d6bab into python:master Nov 20, 2018
@ruuda ruuda deleted the tempfile branch November 20, 2018 10:42
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.

3 participants