Skip to content

Manchester | 26-SDC-Jul | Fithi Teklom | Sprint 5 | Prep exercises - #681

Open
Fithi-Teklom wants to merge 10 commits into
CodeYourFuture:mainfrom
Fithi-Teklom:feature/prep-exercises
Open

Fithi-Teklom wants to merge 10 commits into
CodeYourFuture:mainfrom
Fithi-Teklom:feature/prep-exercises

Conversation

@Fithi-Teklom

@Fithi-Teklom Fithi-Teklom commented Sep 1, 2026 •

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1155

Changelist

Completed the sprint 5 prep exercises covering types, classes and objects, dataclasses, generics, enums , methods and inheritance.

@Fithi-Teklom Fithi-Teklom added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Tools The name of the module. labels Sep 1, 2026

@Khantdotcom Khantdotcom left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mandatory fix required : Variable declarations missing in Person class.



def get_address(person: Person) -> str:
return person.address

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does person have address in your data model?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback. Could you clarify why the variable declarations are a mandatory fix here?

My understanding is that assigning self.name, self.age and self.preferred_operating_system in init already defines the instance attributes and allows mypy to infer their types.

As I understand it, the purpose of this exercise is to demonstrate that mypy can detect access to an attribute, such as address, that isn't defined on the Person class. Since address is intentionally absent from the data model, mypy should flag that access.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ohh yes you're right. I overlooked it.

For more practice on attr access, check out those methods :
• getattr(obj, name[, default])
• setattr(obj, name, value)
• hasattr(obj, name)
• delattr(obj, name).

@Fithi-Teklom Fithi-Teklom changed the title Manchester | 26-SDC-Jun | Fithi Teklom | Sprint 5 | Prep exercises Manchester | 26-SDC-Jul | Fithi Teklom | Sprint 5 | Prep exercises Sep 4, 2026

@LonMcGregor LonMcGregor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good work, Apologies for the late review. I've left a few extra comments


def is_adult(self):
today = date.today()
age = today.year - self.date_of_birth.year

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will this always work? What if today is the 10th of October and the person was born on the 20th of october 18 years ago?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you, for the feedback. I have improved the calculation.

Comment thread sprint5-prep-exercises/generic.py Outdated
class Person:
name: str
age: int
children: list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This list could contain anything, is there a way of using generics to force the right type of list?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I've changed the annotation from children: list to children: list["Person"] so that the type checker knows the list should contain Person instances rather than arbitrary values.

# │
# ├── get_name()
# │
# ▼

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good explanation

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 7, 2026
@Fithi-Teklom Fithi-Teklom added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. Module-Tools The name of the module. labels Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants