Skip to content

Mthunzy#1

Open
mtntojhb025-dot wants to merge 1 commit into
micanipho:mainfrom
mtntojhb025-dot:main
Open

Mthunzy#1
mtntojhb025-dot wants to merge 1 commit into
micanipho:mainfrom
mtntojhb025-dot:main

Conversation

@mtntojhb025-dot
Copy link
Copy Markdown

Mthunzi Ntombela

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements solutions for a Python coding assessment involving flight ticket parsing, leap year calculations, and reactor status monitoring. The changes include function implementations in system_check.py and creation of a test file test_reactor.py.

Key Changes:

  • Implemented four string parsing functions for flight ticket processing (departure airport, baggage allowance, flight number validation)
  • Added leap year calculation logic using modulo operations
  • Implemented reactor status monitoring with temperature and radiation checks

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 13 comments.

File Description
test_reactor.py Creates empty TestReactor class (missing required test implementations)
system_check.py Implements all five required functions with logic for ticket parsing, leap year detection, and reactor monitoring
pycache/system_check.cpython-310.pyc Compiled Python bytecode (auto-generated from system_check.py changes)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread system_check.py
if temp < 500:
return "Maintenance Mode"
return "Normal Operation"
pass
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable code: the pass statement on line 146 will never execute because the function returns on line 145. Remove this line to clean up the code.

Suggested change
pass

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
Comment on lines +96 to +102
if year%4 == 0:
if year%100 == 0:
if year%400 == 0:
return True
return False
return True
return False
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces around the modulo operator. According to PEP 8 style guidelines, binary operators should have spaces around them. Change year%4 to year % 4, year%100 to year % 100, and year%400 to year % 400 for better readability.

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
# TODO: Write your code here
splitted_ticket = ticket_string.split("-")
return splitted_ticket[2]
pass
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable code: the pass statement on line 23 will never execute because the function returns on line 22. Remove this line to clean up the code.

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
return True
return False
# TODO: Write your code here
pass
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable code: the pass statement on line 104 will never execute because the function returns on lines 96-102. Remove this line to clean up the code.

Suggested change
pass

Copilot uses AI. Check for mistakes.
Comment thread test_reactor.py
Comment on lines +1 to +3
class TestReactor:
def __int__(self):
pass No newline at end of file
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TestReactor class is empty and doesn't contain any test methods. According to the requirements in system_check.py (lines 117-118), this class should implement TDD tests for the reactor_status function. The class should inherit from unittest.TestCase and include test methods for the various reactor status conditions (Sensor Error, CRITICAL, WARNING, Maintenance Mode, and Normal Operation).

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
Comment on lines +66 to +72
t_number = ticket_number[-1]

if t_number.isdigit():
if int(t_number)%2 == 0:
return "Valid - Northbound"
else:
return "Valid - Southbound"
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic only checks the last digit of the flight number (ticket_number[-1]) instead of extracting and checking the entire numeric portion. For example, in "JO234", this code checks if "4" is even/odd, but it should check if "234" is even/odd. Extract the numeric part properly (e.g., using ticket_number[2:] for "JO234") and convert it to an integer before checking.

Suggested change
t_number = ticket_number[-1]
if t_number.isdigit():
if int(t_number)%2 == 0:
return "Valid - Northbound"
else:
return "Valid - Southbound"
# Extract numeric portion from flight number (e.g., "JO234" -> "234")
numeric_part = ''.join(filter(str.isdigit, ticket_number))
if numeric_part:
try:
num = int(numeric_part)
if num % 2 == 0:
return "Valid - Northbound"
else:
return "Valid - Southbound"
except ValueError:
return "Invalid Flight"

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
Flight Number (JO234) can vary in length. You must find it relative to the hyphens.
"""
# TODO: Write your code here
splitted_ticket = ticket_string.split("-")
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ticket string is split multiple times across different functions (lines 21, 41, 64). Consider adding input validation and error handling for the split operation. If the ticket string doesn't contain the expected number of hyphens, the code will raise an IndexError. This would improve robustness.

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
elif cl == "FL":
return "First Class - 60kg"
return "Standard - 0kg"
pass
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable code: the pass statement on line 50 will never execute because the function returns on line 49. Remove this line to clean up the code.

Suggested change
pass

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
return "Valid - Southbound"
else:
return "Invalid Flight"
pass
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreachable code: the pass statement on line 75 will never execute because the function returns on line 74. Remove this line to clean up the code.

Suggested change
pass

Copilot uses AI. Check for mistakes.
Comment thread system_check.py
return "Sensor Error"
if temp > 2000 or radiation > 500:
return "CRITICAL"
if (temp >= 1000 and temp <= 2000) and radiation > 100:
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is always true, because of this condition.

Suggested change
if (temp >= 1000 and temp <= 2000) and radiation > 100:
if temp >= 1000 and radiation > 100:

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants