Skip to content

Add __len__ to UserList - #131

Merged
glensc merged 2 commits into
glensc:mainfrom
rawsun007:userlist-len
Sep 18, 2026
Merged

glensc merged 2 commits into
glensc:mainfrom
rawsun007:userlist-len

Conversation

@rawsun007

Copy link
Copy Markdown
Contributor

Following up on Taxel/PlexTraktSync#2575, where you suggested adding __len__ here and then relying on it consistently in PTS.

PublicList defines both __iter__ and __len__. UserList defines only __iter__, so:

>>> len(user_list)
TypeError: object of type 'UserList' has no len()

Callers that want a count have to materialise the iterator. This adds __len__ reading the same self._items that __iter__ walks, so the two cannot disagree.

Two commits, behaviour and test separate per AGENTS.md. pytest is 166 passing; reverting only the __len__ addition fails the new assertion with the TypeError above. flake8 on the two touched files reports only pre-existing hits, none on the added lines.

Not touched, but worth a look separately since __len__ makes it visible through len(): add_items and remove_items both do self._items = items, assigning the tuple of arguments. So after add_items(x) the list holds only x and has dropped whatever it held, and after remove_items(x) it holds exactly the item that was removed. test_user_list calls both with no arguments, so the suite never sees it. Happy to send that as its own PR if you want it fixed — it is a behaviour change, so I did not fold it in here.

Written by Claude Opus 5 in Claude Code, running under my account.

rawsun007 and others added 2 commits September 16, 2026 15:16
PublicList defines both __iter__ and __len__; UserList defines only
__iter__, so len() on a user list raises TypeError and callers have to
materialise the iterator to count it.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: df6231a2-9f40-457e-a15d-8d5a542d84ff

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@glensc

glensc commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Changes LGTM, but not PR body:

  1. avoid direction, like "you", "me": you suggested. you may write it was suggested in <link_to_exact_comment>.
  2. put discussion into comments, not pr body: "Happy to send that as its own PR" ...

If CI passes, I'll merge. PR body can be edited later as well.

@glensc
glensc merged commit fb6b13a into glensc:main Sep 18, 2026
8 checks passed
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