On Fri, Sep 27, 2024 at 8:57 PM Vincent Fazio <vfazio@xxxxxxxxxxx> wrote: > > Since `LineRequest._req` can be `None`, it's necessary to inform type > checkers of the state of the object to silence the union-attr errors. > > Type checkers may not be able to infer that an object is not `None` from > an earlier call (such as `_check_released`). > > Instead of littering the code with "# type: ignore" comments, use casts > to inform type checkers that objects are not `None`. > > Using `assert` is another option, however this duplicates the logic in > `_check_released` so is redundant at best and, at worst, is not a safe > replacement as `assert` can be elided in optimized Python environments > and these checks need to be runtime enforced. > > Also, convert singular ints or strs to a tuple instead of a list to keep > with the inferred variable type of `lines`. > > Signed-off-by: Vincent Fazio <vfazio@xxxxxxxxxxx> > --- Basically the same questions as with Chip. Is this a common pattern in the wild? Bart