In Python, I'd like to "disable" (or render unusable) an inherited class method in my queue data structure. I do this as follows:
class LLQueue(LinkedList):
def add_to_head(self, val):
raise NotImplementedError("Cannot add to head of a queue - use add_to_tail instead")
This works as intended, but the pyright linter provides a hint diagnostic: "val" is not accessed. I was hoping to suppress the hint diagnostic with a # type: ignore
in-line comment (or a similar comment), but this does not seem to work.
Start the parameter name with an underscore, e.g.
def add_to_head(self, _val):
From the documentation:
reportUnusedVariable [boolean or string, optional]: Generate or suppress diagnostics for a variable that is not accessed. The default value for this setting is "none". Variables whose names begin with an underscore are exempt from this check.