Skip to content

Comments

Fix TypeError in repr when unit is None and interval is 1#651

Open
Fridayai700 wants to merge 1 commit intodbader:masterfrom
Fridayai700:fix-repr-unit-none
Open

Fix TypeError in repr when unit is None and interval is 1#651
Fridayai700 wants to merge 1 commit intodbader:masterfrom
Fridayai700:fix-repr-unit-none

Conversation

@Fridayai700
Copy link

Summary

Fixes #646.

repr(schedule.every(1)) crashes with TypeError: 'NoneType' object is not subscriptable because self.unit[:-1] is attempted when self.unit is None.

The fix guards self.unit against None before slicing. When unit is None, it renders as [None] (consistent with how job_func renders when unset).

Test plan

  • New test for repr(schedule.every(1)) verifies no crash
  • Updated existing test for repr(schedule.every(10)) — now renders [None] instead of None
  • All 77 non-timezone tests pass (4 timezone tests are pre-existing failures)

Job.__repr__ crashes with `TypeError: 'NoneType' object is not
subscriptable` when called on a partially-composed Job with
interval=1, because `self.unit[:-1]` is attempted on None.

Guard self.unit against None before slicing.

Fixes dbader#646.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

[CRASH CONDITION] - Guard self.unit against None

1 participant