From 6b983ebbc146673760a4bb742fcb6fb7d10f4d80 Mon Sep 17 00:00:00 2001 From: Keith James Date: Mon, 23 Sep 2024 12:22:36 +0100 Subject: [PATCH] Fix id parameter showing builtin "id" Fix docstrings with single rather than triple quotes. --- src/npg_notify/db/mlwh.py | 16 ++++++++-------- src/npg_notify/porch_wrapper/qc_state.py | 2 +- tests/test_retrieve_contacts.py | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/npg_notify/db/mlwh.py b/src/npg_notify/db/mlwh.py index 603c800..bc9a454 100644 --- a/src/npg_notify/db/mlwh.py +++ b/src/npg_notify/db/mlwh.py @@ -18,7 +18,7 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see . -from sqlalchemy import ForeignKey, Integer, String, UniqueConstraint, select +from sqlalchemy import DateTime, ForeignKey, Integer, String, UniqueConstraint, select from sqlalchemy.exc import NoResultFound from sqlalchemy.orm import ( DeclarativeBase, @@ -46,7 +46,7 @@ class Base(DeclarativeBase): class Study(Base): - "A representation for the 'study' table." + """A representation for the 'study' table.""" __tablename__ = "study" @@ -89,7 +89,7 @@ def contacts(self) -> list[str]: class StudyUser(Base): - "A representation for the 'study_users' table." + """A representation for the 'study_users' table.""" __tablename__ = "study_users" @@ -111,18 +111,18 @@ def __repr__(self): class StudyNotFoundError(Exception): - "An error to use when a study does not exist in mlwh." + """An error to use when a study does not exist in mlwh.""" pass -def get_study_contacts(session: Session, id: str) -> list[str]: +def get_study_contacts(session: Session, study_id: str) -> list[str]: """Retrieves emails of study contacts from the mlwh database. Args: session: sqlalchemy.orm.Session object - id: + study_id: String study ID. Returns: @@ -136,13 +136,13 @@ def get_study_contacts(session: Session, id: str) -> list[str]: """ try: contacts = ( - session.execute(select(Study).where(Study.id_study_lims == id)) + session.execute(select(Study).where(Study.id_study_lims == study_id)) .scalar_one() .contacts() ) except NoResultFound: raise StudyNotFoundError( - f"Study with ID {id} is not found in ml warehouse" + f"Study with ID {study_id} is not found in ml warehouse" ) return contacts diff --git a/src/npg_notify/porch_wrapper/qc_state.py b/src/npg_notify/porch_wrapper/qc_state.py index 0c30869..041e4b2 100644 --- a/src/npg_notify/porch_wrapper/qc_state.py +++ b/src/npg_notify/porch_wrapper/qc_state.py @@ -267,7 +267,7 @@ def process_task(conf_file_path) -> bool: ) as session: for study_id in study_ids: contacts_per_study[study_id] = get_study_contacts( - session=session, id=study_id + session=session, study_id=study_id ) except Exception as err: diff --git a/tests/test_retrieve_contacts.py b/tests/test_retrieve_contacts.py index 03067d7..42dc826 100644 --- a/tests/test_retrieve_contacts.py +++ b/tests/test_retrieve_contacts.py @@ -9,8 +9,8 @@ def test_retrieving_study_contacts(mlwh_test_session): ): get_study_contacts(mlwh_test_session, "666") - for id in ["2", "5", "4"]: - assert get_study_contacts(mlwh_test_session, id) == [] + for study_id in ["2", "5", "4"]: + assert get_study_contacts(mlwh_test_session, study_id) == [] users = ["owner", "user1", "user2", "user3"] assert get_study_contacts(mlwh_test_session, "3") == [