Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow returning inferred None from functions #5663
As discussed in the issue, assigning an inferred (from generics, overloads, or lambdas)
Note: this error is quite nasty for dataclasses, where it flags a legitimate typical use case (see tests).
NoneTyp attribute to handle an edge case such as this seems like an overkill. This increases complexity and adds some overhead with a pretty small gain.
Instead, I'd rather rewrite the
None return check to look at whether the callable refers to something with an explicit declared
None return type (look for the annotation in the node, not the inferred type). It's fine if the semantics of the check change slightly as this is not required for correctness.
OK, I have rewritten it without a flag and I like the new semantics even more, it looks more consistent.
This however required fixing an unrelated issue: previously all
Thanks for the update, I like how the new check works. There seems to be a problem with methods though (see my comment).