Skip to content

Commit c65617f

Browse files
Fixing type checker errors (#76)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Fixing error altered by the built in type checker tool in VSCode. This was done using the "basic" option for strictness. ## Context <!-- Why is this change required? What problem does it solve? --> Improves type consistency across the repository. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [ ] I have added tests to cover my changes (where appropriate) - [ ] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent 053efec commit c65617f

File tree

13 files changed

+50
-26
lines changed

13 files changed

+50
-26
lines changed

pages/call_and_recall/generate_invitations_page.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def wait_for_invitation_generation_complete(
6565
elapsed < timeout
6666
): # there may be a stored procedure to speed this process up
6767
table_text = self.display_rs.text_content()
68+
if table_text is None:
69+
pytest.fail("Failed to retrieve table text content")
70+
6871
if "Failed" in table_text:
6972
pytest.fail("Invitation has failed to generate")
7073
elif "Queued" in table_text or "In Progress" in table_text:
@@ -83,15 +86,19 @@ def wait_for_invitation_generation_complete(
8386
except Exception as e:
8487
pytest.fail(f"Invitations not generated successfully: {str(e)}")
8588

86-
value = (
87-
self.planned_invitations_total.text_content().strip()
88-
) # Get text and remove extra spaces
89+
value = self.planned_invitations_total.text_content()
90+
if value is None:
91+
pytest.fail("Failed to retrieve planned invitations total")
92+
value = value.strip() # Get text and remove extra spaces
8993
if int(value) < number_of_invitations:
9094
pytest.fail(
9195
f"There are less than {number_of_invitations} invitations generated"
9296
)
9397

94-
self_referrals_total = int(self.self_referrals_total.text_content().strip())
98+
self_referrals_total_text = self.self_referrals_total.text_content()
99+
if self_referrals_total_text is None:
100+
pytest.fail("Failed to retrieve self-referrals total")
101+
self_referrals_total = int(self_referrals_total_text.strip())
95102
if self_referrals_total >= 1:
96103
return True
97104
else:

pages/login/login_page.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def login_as_user(self, username: str) -> None:
2727
self.username.fill(user_details["username"])
2828
# Retrieve and enter password from .env file
2929
password = os.getenv("BCSS_PASS")
30+
if password is None:
31+
raise ValueError("Environment variable 'BCSS_PASS' is not set")
3032
self.password.fill(password)
3133
# Click Submit
3234
self.click(self.submit_button)

pages/screening_practitioner_appointments/book_appointment_page.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ def __init__(self, page: Page):
1010
super().__init__(page)
1111
self.page = page
1212
# Book Appointment - page locators
13-
self.screening_center_dropdown = page.locator("#UI_NEW_SCREENING_CENTRE")
14-
self.site_dropdown = page.locator("#UI_NEW_SITE")
15-
self.appointment_time_radio_button = page.locator(
16-
page.get_by_role("radio", name="UI_NEW_SLOT_SELECTION_ID")
13+
self.screening_center_dropdown = self.page.locator("#UI_NEW_SCREENING_CENTRE")
14+
self.site_dropdown = self.page.locator("#UI_NEW_SITE")
15+
self.appointment_time_radio_button = self.page.get_by_role(
16+
"radio", name="UI_NEW_SLOT_SELECTION_ID"
1717
)
18-
self.save_button = page.get_by_role("button", name="Save")
18+
self.save_button = self.page.get_by_role("button", name="Save")
1919
self.appointments_table = TableUtils(self.page, "#displayRS")
2020
self.current_month_displayed = self.page.locator("#MONTH_AND_YEAR")
2121

@@ -46,4 +46,7 @@ def appointment_booked_confirmation_is_displayed(self, message: str) -> None:
4646

4747
def get_current_month_displayed(self) -> str:
4848
"""Returns the current month displayed in the calendar."""
49-
return self.current_month_displayed.text_content()
49+
current_month_displayed_content = self.current_month_displayed.text_content()
50+
if current_month_displayed_content is None:
51+
raise ValueError("Current month displayed is 'None'")
52+
return current_month_displayed_content

pages/screening_subject_search/subject_demographic_page.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ def fill_dob_input(self, date: datetime) -> None:
7474
Args:
7575
date (datetime): The date you want to enter
7676
"""
77-
date = CalendarPicker(self.page).calendar_picker_ddmmyyyy(date, self.dob_field)
77+
if date is None:
78+
raise ValueError("The 'date' argument cannot be None")
79+
CalendarPicker(self.page).calendar_picker_ddmmyyyy(date, self.dob_field)
7880

7981
def fill_postcode_input(self, postcode: str) -> None:
8082
"""

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_visible_status_from_list(self, latest_event_status) -> Locator:
118118
locator = self.page.get_by_role("cell", name=status, exact=True)
119119
if locator.is_visible():
120120
return locator
121-
logging.error("Unable to find any of the listed statuses")
121+
raise ValueError("Unable to find any of the listed statuses")
122122

123123
def click_subjects_events_notes(self) -> None:
124124
"""Click on the 'Subject Events & Notes' link."""

tests/test_home_page_links.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from utils.user_tools import UserTools
44
from pages.base_page import BasePage
55
from utils.date_time_utils import DateTimeUtils
6+
import logging
67

78

89
@pytest.fixture(scope="function", autouse=True)
@@ -64,10 +65,12 @@ def test_home_page_links_navigation(page: Page) -> None:
6465
page.get_by_role("link", name="User guide").click()
6566
# Check that the user guide page can be accessed
6667
page1 = page1_info.value
68+
logging.info(f"User Guide Page: {page1}")
6769

6870
# Click 'help' link
6971
with page.expect_popup() as page2_info:
7072
# Check the help link works
7173
page.get_by_role("link", name="Help").click()
7274
# Check that the help page can be accessed
7375
page2 = page2_info.value
76+
logging.info(f"Help Page: {page2}")

tests_utils/test_user_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
pytestmark = [pytest.mark.utils]
77

88

9-
def test_retrieve_user(monkeypatch: object) -> None:
9+
def test_retrieve_user(monkeypatch: pytest.MonkeyPatch) -> None:
1010
monkeypatch.setattr(
1111
utils.user_tools,
1212
"USERS_FILE",

utils/batch_processing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def batch_processing(
7979

8080
check_batch_in_archived_batch_list(page, link_text)
8181

82+
if nhs_no_df is None:
83+
raise ValueError("No NHS numbers were retrieved for the batch")
84+
8285
for subject in range(len(nhs_no_df)):
8386
nhs_no = nhs_no_df["subject_nhs_number"].iloc[subject]
8487
logging.info(f"Verifying the event status for subject: {nhs_no}")

utils/calendar_picker.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ def v2_calendar_picker(self, date: datetime) -> None:
345345
click_year,
346346
click_decade,
347347
click_century,
348-
century,
349-
decade,
350-
year,
348+
str(century),
349+
str(decade),
350+
str(year),
351351
month_short,
352352
)
353353

@@ -444,6 +444,7 @@ def check_for_eligible_appointment_dates(
444444

445445
if background_colour in bg_colours:
446446
value = locator_element.get_attribute("name")
447-
if len(value) < 5:
447+
if value is not None and len(value) < 5:
448448
self.click(locator.nth(i))
449449
return True
450+
return False

utils/fit_kit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def process_kit_data(self, smokescreen_properties: dict) -> list:
141141

142142
def split_fit_kits(
143143
self, kit_id_df: pd.DataFrame, smokescreen_properties: dict
144-
) -> pd.DataFrame:
144+
) -> tuple[pd.DataFrame, pd.DataFrame]:
145145
"""
146146
This method splits the dataframe into two, 1 normal and 1 abnormal
147147
"""

0 commit comments

Comments
 (0)