Bug Description
When a Job object is created but not yet fully configured (e.g., schedule.every(10).seconds without calling .do()), accessing repr() or printing the job crashes with a TypeError because self.unit is None.
Steps to Reproduce
import schedule
job = schedule.every(10)
# unit is not yet set
print(job) # TypeError: argument of type 'NoneType' is not iterable
The crash happens in Job.__repr__ where it checks if self.unit[0] != "s" — this fails when self.unit is None.
Fix
Add a guard in __repr__ to handle None unit:
def __repr__(self):
...
if self.unit is not None and self.unit[0] != "s":
...
References
Bug Description
When a
Jobobject is created but not yet fully configured (e.g.,schedule.every(10).secondswithout calling.do()), accessingrepr()or printing the job crashes with aTypeErrorbecauseself.unitisNone.Steps to Reproduce
The crash happens in
Job.__repr__where it checksif self.unit[0] != "s"— this fails whenself.unit is None.Fix
Add a guard in
__repr__to handleNoneunit:References