Skip to content

[traceback] Expose print_list method in traceback for python3. #2837

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
Mar 11, 2019
Merged

[traceback] Expose print_list method in traceback for python3. #2837

merged 2 commits into from
Mar 11, 2019

Conversation

lic9
Copy link
Contributor

@lic9 lic9 commented Mar 8, 2019

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.

Thank you for the pull request. Notes below.

@@ -36,6 +36,7 @@ if sys.version_info >= (3, 5):
def extract_stack(f: Optional[FrameType] = ...,
limit: Optional[int] = ...) -> StackSummary: ...
def format_list(extracted_list: List[FrameSummary]) -> List[str]: ...
def print_list(extracted_list: List[FrameSummary], file: Optional[IO[str]] = ...) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. This should be marked with # undocumented.
  2. While StackSummary.from_list() is also annotated as expecting a list, expecting an Iterable[FrameSummary] should suffice.
  3. print() is annotated as expecting an IO[str]. We are trying to move away from using IO for argument types. Could you defined a protocol like this and use it for the file argument:
class _Writable(Protocol):
    def write(self, s: str) -> Any:
        pass

I will send a separate PR for print().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do. Thanks for the commends and suggestions!

Copy link
Collaborator

Choose a reason for hiding this comment

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

For reference, the print PR is #2848.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like all tests have finished but status is still pending...

The patch contains two minor fixes:
1) Mark the method as '# undocumented'
2) Change 'file' argument type from IO to _Writable
@srittau
Copy link
Collaborator

srittau commented Mar 11, 2019

I don't know why it's still showing as pending, but since all tests are green, I'm meeting.

@srittau srittau merged commit 5918098 into python:master Mar 11, 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