Oh goodness. Sorry for overlooking that.
user_courses() is a function I wrote which does use the method user.get_courses(), the only difference is I add some additional filtering to ensure I am only looking at academic courses for the correct enrollment term.
I think that the problem I am seeing is probably tied to the large assignment lists. Because, while your test case produced 225 assignments across 5 courses, my students have hundreds of assignments in a single course.
To further clarify, my school uses course sections to identify different academic tracks. Students are assigned to an academic track at the time of enrollment. Then, when they are added to a Canvas course, they are assigned to the appropriate course section.
In addition, differentiated versions of each assignment are assigned to each section. (So, Example Assignment A-G would be assigned to the A-G course section, while Example Assignment Grad would be assigned to the Grad section.)
In these particular courses, where hundreds of assignments are being assigned each semester (and they are year long courses), the resulting error is that, in addition to those hundreds of assignments which a student should be correctly assigned to, when I pull their list of assignments, their lists will also include hundreds of assignments belonging to other course sections.
Here are two example courses for the same student, one course with this error, the other without.
Course 1 (World Literature)
Total Assignments for the student: 474
Total Published Assignments for the current semester assigned to the student: 40 (seen below)
W21D2 SYK: JLC Quiz 1 (Grad-Op.2) (223678)
W22D2 SYK: JLC Quiz 2 (Grad-Opt2) (225113)
W19D2 SYK: Ultimate Anthology Final (218084)
W20D1 SYK: JLC Exit Ticket (A-G/Grad) (222860)
W22D2 SYK: Exit Ticket (Grad) (225108)
LP3 Entire Notebook Check (218083)
W20D2 Learn: Notebook Check (222863)
W21D2 Learn: Notebook Check (223672)
W20D1 Learn: China Research (AG/Grad) (222856)
W22D2 Learn: Notebook Check (225101)
W20D2 Practice: JLC Chapter 1 & 2 Reading Questions (Grad-Opt.2) (222865)
W21D1 Practice: JLC Chapter 3 & 4 Reading Questions (Grad-Op.2) (223665)
Mid Year Reading Survey (223148)
W21D2 Practice: JLC Chapter 5 & 6 Reading Questions (Grad-Op.2) (223675)
W22D1 Practice: JLC Chapter 7 & 8 Reading Questions (Grad-Op.2) (225097)
W22D2 Practice: JLC Chapter 9 & 10 Reading Questions (Grad-Op.2) (225104)
LP3 Entire Notebook Check (218083)
W20D2 Learn: Notebook Check (222863)
W21D2 Learn: Notebook Check (223672)
W20D1 Learn: China Research (AG/Grad) (222856)
W20D1 Learn: KWL (all) (222859)
W20D1 Learn: China Research (Op2) (222858)
W20D1 Learn: China Research (M2/M3) (222857)
W22D2 Learn: Notebook Check (225101)
W20D2 Practice: JLC Chapter 1 & 2 Reading Questions (A-G) (222864)
W20D2 Practice: JLC Chapter 1 & 2 Reading Questions (Grad-Opt.2) (222865)
W20D2 Practice: JLC Chapter 1 & 2 Reading Questions (M2/M3) (222866)
W21D1 Practice: JLC Chapter 3 & 4 Reading Questions (A-G) (223664)
W21D2 Practice: JLC Chapter 5 & 6 Reading Questions (A-G) (223674)
W21D1 Practice: JLC Chapter 3 & 4 Reading Questions (Grad-Op.2) (223665)
W21D1 Practice: JLC Chapter 3 & 4 Reading Questions (M2/M3) (223666)
Mid Year Reading Survey (223148)
W21D2 Practice: JLC Chapter 5 & 6 Reading Questions (Grad-Op.2) (223675)
W21D2 Practice: JLC Chapter 5 & 6 Reading Questions (M2/M3) (223676)
W22D1 Practice: JLC Chapter 7 & 8 Reading Questions (A-G) (225096)
W22D1 Practice: JLC Chapter 7 & 8 Reading Questions (Grad-Op.2) (225097)
W22D1 Practice: JLC Chapter 7 & 8 Reading Questions (M2/M3) (225098)
W22D2 Practice: JLC Chapter 9 & 10 Reading Questions (A-G) (225103)
W22D2 Practice: JLC Chapter 9 & 10 Reading Questions (Grad-Op.2) (225104)
W22D2 Practice: JLC Chapter 9 & 10 Reading Questions (M2/M3) (225105)
This student belongs to the course section 'Grad', but they are also receiving assignments that belong to A-G, Opt-2, and M2/M3 course sections as well.
In contrast, here is that same student's assignment list for a different course.
Course 2 (World History)
Total Assignments for the student: 94
Total Published Assignments for the current semester assigned to the student: 16 (seen below)
W19 D2 SYK: LP 3 Unit Test (Grad) (218025)
W20D1 SYK: Exit Ticket (All) (222849)
W21D1 SYK: Exit Ticket (A-G/Grad) (223513)
W21D2 SYK: The Mongol's Impact (Grad) (224754)
W22D1 SYK: Exit Ticket (A-G, Grad) (225076)
W19 D2 Full Notebook Check (218022)
W20D2 Learn: Notebook Check (All) (222853)
W21D2 Learn: Notebook Check (All) (223517)
W22D2 Learn: Notebook Check (All) (225089)
W19 D2 Practice: Islam Webquest (A-G/Grad) (218023)
W20D2 Extend: All the Khan's Horses (Grad, Opt.2, M2/M3) (222852)
W21D1 Extend: Sorqoqtani Beki - Graphic Biography (Grad, Opt.2, M2/M3) (223507)
W20D1: Practice Videos on the Mongols (A-G/Grad) (222850)
W21D2 Practice: Video: The Last Chief of the Comanches (A-G/Grad) (223524)
W22D1 Extend: Mongol and Comanche Comparison Paragraph (Grad/Opt 2) (225075)
W22D2 Practice: Mongol Influence Research Paragraph (A-G/Grad) (225090)
24.25 Lompoc HS World history
In the above list, we do see some additional section names ('A-G', 'Opt-2') but only when in combination with 'Grad', because the assignment was given to both sections.