[ty] Include imported sub-modules as attributes on modules for completions by BurntSushi · Pull Request #18898 · astral-sh/ruff (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this return None instead of panicking?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a logic error to end up with an empty string here:
- If
selfis not a relativeModuleNametoparent,self.0.strip_prefix(&*parent.0)will returnNone - If
selfis the sameModuleNameasparent,self.0.strip_prefix(&*parent.0)will returnSome("")and the secondstrip_prefix()call will returnNone
I don't think there's any way in which we'd get an empty string here if both self and parent are valid ModuleNames (which should be guaranteed by the invariants upheld by the ModuleName constructor methods)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I distilled Alex's reasoning into a small comment on the assert.