Comments (6)
Don't raise NotImplementedError
(class) but NotImplementedError()
(instance).
from vulture.
It's not documented in the README, but you can suppress unreachable-code errors for a line with noqa: V201
. Vulture should perhaps handle this case automatically though.
from vulture.
Just randomly reading this.
but we need the yield statement there to make the method into a generator!
May I ask what the yield
makes for a difference? So where does it break if it is missing? Runtime, type checking, other static checkers or just that the developer knows about it?
I am just asking such that I can think about other possible solutions.
from vulture.
Runtime (e.g. inspect.isgeneratorfunction()
as well as static typechecking. I guess it's also useful for human readers but the runtime requirement is the hard one.
from vulture.
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:
class AbstractFoo(ABC):
@abstractmethod
def some_generator(self):
yield from GeneratorNotImplemented()
where GeneratorNotImplemented
is something like
class GeneratorNotImplemented:
def __init__(self):
raise NotImplementedError
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 yields
(similar to yield
followed by a return
to create an empty iterator). Because the yield
was put there on purpose and changes the behavior of the program.
I also checked mypy
and PyCharm
both of them will mark the code as unreachable (like vulture
).
from vulture.
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"
from vulture.
Related Issues (20)
- Multiprocessing vulture with python. HOT 1
- TOML parsing fails with multi-line strings HOT 1
- Remove files from AST tree HOT 1
- Vulture not finding code that it should be HOT 1
- False positives for TypedDicts
- Help with ignoring decorated method HOT 4
- [QUESTION] How to suppress `unused-property` error?
- finding completely dead files HOT 1
- Switch to tomli/tomllib for toml parsing HOT 2
- Feature request: A way to more specifically target items for whitelisting HOT 1
- Add a way to ignore the same files as `.gitignore` HOT 9
- False positive when an attribute uses `weakref.finalize` HOT 1
- The pre-commit autoupdate downgrades to v2.11 HOT 6
- AttributeError: 'Tuple' object has no attribute 'id' HOT 3
- Dealing with recursive functions that are only called by themselves
- The conda package for `vulture` is unmaintained HOT 6
- Confusing recursive processing of directory HOT 4
- RecursionError: maximum recursion depth exceeded HOT 5
- Wanting to contribute: is there a need for a vs code extension that helps you find the unused functions with one click? HOT 3
- Inline ignoring again HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vulture.