Skip to content

Enhancement: display "Booking" as a set of attributes and not an object #3

@MyrtoG

Description

@MyrtoG

Version

v2

Impact

High

Suggested Priority

High

Description

At the moment, when printing a "Booking" object, we get back a result of an object type. Even though that doesn't necessarily affect the way the application is running at the moment, it could cause problems in the future when debugging.
To identify the issue, follow the steps below.

In the CLI run:

  1. python3
  2. from lib.booking import Booking
  3. booking = Booking(135, "2024-06-05 21:21", 1, 2, 3)
  4. booking
    You will get a result similar to this:
    <lib.booking.Booking object at 0x1047a61e0>

To fix this I suggest adding a repl method in the booking.py:

_def __repr__(self):
    return f"Booking({self.id}, {self.dt}, {self.gid_id}, {self.user_id}, {self.ticket_count})"_

If afer adding the repl method we repeat the steps in the REPL, we should now be getting the result below:

Booking(135, "2024-06-05 21:21", 1, 2, 3)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions