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

Rework _WarningStream to behave closer to io.StringIO() #884

Closed
miketheman opened this issue Mar 23, 2022 · 0 comments · Fixed by #886
Closed

Rework _WarningStream to behave closer to io.StringIO() #884

miketheman opened this issue Mar 23, 2022 · 0 comments · Fixed by #886

Comments

@miketheman
Copy link
Member

As discussed in pypa/readme_renderer#231

Here's the custom class:

class _WarningStream:
def __init__(self) -> None:
self.output = io.StringIO()
def write(self, text: str) -> None:
matched = _REPORT_RE.search(text)
if not matched:
self.output.write(text)
return
self.output.write(
"line {line}: {level_text}: {message}\n".format(
level_text=matched.group("level").capitalize(),
line=matched.group("line"),
message=matched.group("message").rstrip("\r\n"),
)
)
def __str__(self) -> str:
return self.output.getvalue().strip()

@bhrutledge has some ideas on how to replace the usage to better reflect the future interaction of twine check and readme_renderer when docutils doesn't pass a warning, but readme_renderer does.

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 a pull request may close this issue.

1 participant