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

Refactor "repr" objects #3399

Open
nicoddemus opened this issue Apr 13, 2018 · 6 comments
Open

Refactor "repr" objects #3399

nicoddemus opened this issue Apr 13, 2018 · 6 comments
Assignees
Labels
topic: reporting related to terminal output and user-facing messages and errors type: refactoring internal improvements to the code

Comments

@nicoddemus
Copy link
Member

Follow up of #3361 (comment).

@RonnyPfannschmidt could you write down the strategy you have in mind to refactor the repr objects and what is the problem with their design currently?

cc @brianmaissy @whimboo

xref: #3343

@nicoddemus nicoddemus added topic: reporting related to terminal output and user-facing messages and errors type: refactoring internal improvements to the code labels Apr 13, 2018
@pytestbot pytestbot added the platform: mac mac platform-specific problem label Apr 13, 2018
@RonnyPfannschmidt
Copy link
Member

i do not have a strategy as of now

the design flaws are mostly based in mixing output styling mechanisms with the representation mechanism

in addition serialization capabilities are missing completely

@brianmaissy
Copy link
Contributor

brianmaissy commented Apr 15, 2018

Maybe we want to pass around objects that implement an interface: serialize, deserialize, and toterminal. I would avoid calling these objects anything with repr in the name, it's confusing that the "repr" of something isn't just a string

@brianmaissy brianmaissy removed the platform: mac mac platform-specific problem label Apr 15, 2018
@RonnyPfannschmidt
Copy link
Member

deserialize cant work that way
serialize needs help in order to be deserializable
toterminal is a massive issue (as its contrary to supporting sane ux, or other outputs like junitxml, pytest-html or a pytest-"gui"

@nicoddemus
Copy link
Member Author

@RonnyPfannschmidt it seems you want a complete overhaul of the "repr" objects (which I agree could use a better name). Problem is that we 1) don't even know what the "overhaul" is and 2) we don't have the man power to even discuss it right now (it seems to me).

The refactoring discussed here won't change what you see that's bad about the current design, but:

  1. It will improve the current state of things: the internal design will be more formal and more well thought; in particular I don't see that it will introduce further complication, in fact it will simplify things.
  2. It will solve a number of problems that we have today, specially the serialization of the traceback representation in xdist.

So I propose we aim to incremental improvement rather than stop everything on its tracks hoping for a perfect solution, which might never even happen. What do you think?

@RonnyPfannschmidt
Copy link
Member

as increment i propose adding an actual exception attribute to the reprs which is optional and planned for removal in the overhaul

@RonnyPfannschmidt
Copy link
Member

while reviewing what the std-lib currently has to offer,
i took note that the objects there can serve a s a nice example api with the caveat, that safe reprs are not used and formatting choices may slightly differ

however statement range finding and other details may really want to use python 3.11 features for co_positions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: refactoring internal improvements to the code
Projects
None yet
Development

No branches or pull requests

4 participants