Skip to content

reports: use attr.asdict with serialize_repr_{crash,traceback}#6732

Merged
blueyed merged 3 commits into
pytest-dev:masterfrom
blueyed:more-attrs
Feb 14, 2020
Merged

reports: use attr.asdict with serialize_repr_{crash,traceback}#6732
blueyed merged 3 commits into
pytest-dev:masterfrom
blueyed:more-attrs

Conversation

@blueyed

@blueyed blueyed commented Feb 13, 2020

Copy link
Copy Markdown
Contributor

This helps with skipping "private" properties there.

Comment thread src/_pytest/_code/code.py Outdated
reprentries = attr.ib(type=Sequence[Union["ReprEntry", "ReprEntryNative"]])
extraline = attr.ib(type=Optional[str])
style = attr.ib(type="_TracebackStyle")
style = style

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
style = style

@bluetech

Copy link
Copy Markdown
Member

LGTM, though I think it will be better to also convert TerminalRepr and all of its other subclasses to attrs at the same time. Just to stave off any weird interactions between attrs and non-attrs classes in the class hierarchy. I'm sure it works fine but it just seems like something that is better avoided.

@nicoddemus

Copy link
Copy Markdown
Member

LGTM, though I think it will be better to also convert TerminalRepr and all of its other subclasses to attrs at the same time.

That would be ideal, but let's not hold this PR on that (I don't think here will be any weird interactions). Let's leave it up to @blueyed if he wants to tackle converting the other classes or not.

@blueyed blueyed merged commit 9631b3c into pytest-dev:master Feb 14, 2020
@blueyed blueyed deleted the more-attrs branch February 14, 2020 18:39
@blueyed

blueyed commented Feb 14, 2020

Copy link
Copy Markdown
Contributor Author

It's not trivial for all of them, but will create a WIP PR for it already.

blueyed added a commit to blueyed/pytest that referenced this pull request Feb 15, 2020
…t-dev#6732)

* Turn ReprTraceback into attrs class

* Use attr.asdict with serialize_repr_{crash,traceback}

* Turn ReprFileLocation into attrs class, convert py.path.local

(cherry picked from commit 9631b3c)
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