Skip to content

Commit

Permalink
Dropped direct calls to __repr__()
Browse files Browse the repository at this point in the history
Also made the helper function of the parent class 'private'.
  • Loading branch information
mgcam committed Jun 12, 2024
1 parent 00df2ed commit fd3e9ef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lang_qc/db/mlwh_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Base(DeclarativeBase):
A base class for declarative class definitions for the ml warehouse database.
"""

def get_row_description(self, fields: list[str]) -> str:
def _get_row_description(self, fields: list[str]) -> str:
"""
Returns a printable representation of the database table row. Interprets
a list of strings given as the `fields` argument as a list of column
Expand Down Expand Up @@ -564,7 +564,7 @@ class PacBioRunWellMetrics(Base):
def __repr__(self):
"""Returns a printable representation of the database row"""

return self.get_row_description(
return self._get_row_description(
["pac_bio_run_name", "well_label", "plate_number", "id_pac_bio_product"]
)

Expand Down
2 changes: 1 addition & 1 deletion lang_qc/models/pacbio/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def pre_root(cls, values: dict[str, Any]) -> dict[str, Any]:
lims_data = mlwh_db_row.get_experiment_info()
if len(lims_data) == 0:
raise MissingLimsDataError(
f"No LIMS data retrieved for {mlwh_db_row.__repr__()} "
f"No LIMS data retrieved for {str(mlwh_db_row)} "
"on account of partially linked or unlinked product data."
)

Expand Down
7 changes: 3 additions & 4 deletions tests/test_mlwh_db_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def test_pac_bio_well_metrics_repr(mlwhdb_test_session, mlwhdb_load_runs):
PacBioRunWellMetrics.id_pac_bio_product == id
)
db_row = mlwhdb_test_session.execute(query).scalar_one()
assert (
db_row.__repr__()
== "lang_qc.db.mlwh_schema.PacBioRunWellMetrics: " + data[id]
)
expected_string = "lang_qc.db.mlwh_schema.PacBioRunWellMetrics: " + data[id]
assert db_row.__repr__() == expected_string
assert str(db_row) == expected_string

0 comments on commit fd3e9ef

Please sign in to comment.