- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.2k
Open
Labels
CheckersRelated to a checkerRelated to a checkerDiscussion 🤔Needs decision 🔒Needs a decision before implemention or rejectionNeeds a decision before implemention or rejection
Milestone
Description
# pylint: disable=no-self-use
class Parent:
    def func(self) -> int | None:
        return None
    def serialize(self) -> str:
        x = self.func()  # assignment-from-none
        return f"Result: {x if x else ''}"
class Child(Parent):
    def func(self) -> int:
        return 42In the example above, assignment-from-none is emitted on a method call even though func() could be overwritten and not return None.
Proposal
Limit the assignment-from-none check to functions. Methods should only be considered if marked with @typing.final. It might also work to check the return type itself to see if it's only -> None.
Reason
We can't reliably determine if a method is ever overwritten and thus return something else then None.
THuppke, pwohlhart, Baughn, HDavidEspinosa, chlndh and 1 more
Metadata
Metadata
Assignees
Labels
CheckersRelated to a checkerRelated to a checkerDiscussion 🤔Needs decision 🔒Needs a decision before implemention or rejectionNeeds a decision before implemention or rejection