Skip to content

Is it possible to modify how run() is typed so the result isn't potentially None? #1027

Open
@red8888

Description

@red8888

This is a semi ignore question, but I want to know if this is possible and if I could open a PR to fix.

This is kind of an annoy behavior:
def run(self, command: str, **kwargs: Any) -> Optional["Result"]:

It means I always have to check if its not None, but from what I understand the only case where it will return None is if disown is set to True right?

Is there a way to refactor so the response is always expected to return unless disown is set to true?

Maybe just a super simple class hierarchy where the base Runner class has everything but there are two children:
DisownedRunner and OwnedRunner?

And then DisownedRunner runner is the only one that is potentially None?

Thanks! I'm asking more what it would take to fix so I can open a PR more than just asking for this to be fixed, I'd like to contribute!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions