-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 TestReport.longreprtext when TestReport.longrepr is not a string #7561
Conversation
@@ -82,9 +82,10 @@ def toterminal(self, out: TerminalWriter) -> None: | |||
longrepr.toterminal(out) | |||
else: | |||
try: | |||
out.line(longrepr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bluetech do you know why mypy
didn't catch this problem? TerminalWriter.line
expects a str
argument, but longrepr
is declared as Any
in the class definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a function which accepts str
also accepts Any
because it's gradually typed (there's options to turn this off in mypy, but getting to that ideal is very very difficult)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I indeed:
A static type checker will treat every type as being compatible with Any and Any as being compatible with every type.
Thanks! My thought was that a function declaring str
would accuse Any
as incompatible, but the above definition clearly states otherwise. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -82,9 +82,10 @@ def toterminal(self, out: TerminalWriter) -> None: | |||
longrepr.toterminal(out) | |||
else: | |||
try: | |||
out.line(longrepr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a function which accepts str
also accepts Any
because it's gradually typed (there's options to turn this off in mypy, but getting to that ideal is very very difficult)
pytest 6.0.0 has broken the job with issue [1], until it's fixed with PR [2] and released let's pin it. [1] pytest-dev/pytest#7559 [2] pytest-dev/pytest#7561 Change-Id: I073cfbcb4a65e716373f0a4df4766fd38a801618
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think CollectErrorRepr
might need the same treatment, not sure.
The typing of longrepr
is unfortunate...
Anyone with merge and release super powers? That changes deserves a fast track. I already opened pytest-dev/pytest-html#318 as I have a strong interest in keeping this plugin green and compatible with any new release of pytest. |
Every maintainer has that. 😁 We should have a release real soon, as there are a number of regressions we should take care. 👍 |
c587089
to
d3267bc
Compare
Good call! It didn't require changes, but I added a test to avoid future regressions.
Indeed. We should eventually try to narrow down all possible values it might have, to eventually refactor that out somehow. |
[6.0.x] Merge pull request #7561 from nicoddemus/longreprtext-7559
Fix #7559