-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
--warn-return-any is too specialized #2901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Those sound like good tweaks to me, though I'd consider limiting the exception to argument/variables of |
I'd like to clarify my statements from #2905 without opening new issue. In case of generators, it is clear that @ddfisher, you said that it's not possible to access return value from generator function. Since Python 3.3 this is possible and PEP 380 describes it. |
I'm not sure I completely followed your comment, but to clarify what I said earlier: attempting to access the return value of a generator function which is typed as |
@miedzinski can you clarify what you're proposing? I tried to provide an example below but I think I'm missing something:
Also, PEP implies |
@ddfisher I thought you meant generators in general. If it was about @pkch, for example def f(x: Any) -> Generator[int, Any, Any]:
yield 0
return x If |
What do we need to move this forward? I had a couple bugs not discovered by |
Honestly I don't personally understand this issue very well. Perhaps it would be helpful to provide some examples? |
For example, let's say here:
|
Oooh, subtle! I'm still not sure what Jukka's three initial bullets stand for. |
Here's my understanding, please someone correct me if I missed something: @ddfisher proposal was to add a flag (say, @JukkaL suggested in the three bullet points the additional cases (let's call them cases 1, 2, 3) where For example:
@ddfisher proposal with the 4 exclusions would work perfectly for my use case. Edit: changed |
And what are some examples that would be disallowed? |
And many other cases not obvious to me, such as overlapping |
Should this be closed now that #3470 is closed? |
I think so, we already have several flags for |
Recently the
--warn-return-any
option was added which causes mypy to warn if returning a value with anAny
type (#2854). @ddfisher pointed out the this is not very general:I agree that #2854 seems too narrowly focused. I like @ddfisher's suggestion, with a few tweaks:
Any
should probably be okay as a function argument type if the argument type isAny
(orobject
).Any
value to a variable with anAny
/object
type seems okay as well.Any
value usingisinstance
orcast
should be allowed.The text was updated successfully, but these errors were encountered: