-
Notifications
You must be signed in to change notification settings - Fork 156
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
Allow unreachable trailing yield
, to make an abstract generator method
#298
Comments
Just randomly reading this.
May I ask what the I am just asking such that I can think about other possible solutions. |
Runtime (e.g. |
I agree that that type checker and code readability can probably easily be managed (type annotation, custom decorator, custom exception). For runtime checks I thought about the following:
where
However, I guess it it less readable than the original code. Sorry, if this goes into a wrong direction for you. I am not maintainer of this project. Bye the way, the more I think about it, the more sense it makes to me to not mark them as unreachable I also checked |
Don't raise |
It's not documented in the README, but you can suppress unreachable-code errors for a line with |
Here's another use case. I don't force a child class to implement the method and I have a default empty one. def my_generator(self) -> Generator[str, None, None]:
return
yield # I have to add "noqa: V201" |
Consider the following example, where an abstract method is a generator:
We want to
raise NotImplementedError
to prevent accidental calls, but then Vulture errors out because theyield
is unreachable. Indeed it is unreachable - but we need theyield
statement there to make the method into a generator!Decent solutions might include supporting some way to ignore unreachable-code warnings (as is possible for unused variables), or more direct heuristics like "ignore an unreachable bare yield if there are no following statements and only a
raise
statement preceding" - I'm not attached to any particular solution, but would love something to unblock this so I can enforce Vulture rather than just running it by hand occasionally 🙂The text was updated successfully, but these errors were encountered: