Visible marking of ABC implementation possibility #6528
Replies: 8 comments
-
tagging @StellaHuang95 |
Beta Was this translation helpful? Give feedback.
-
Adding the GIF that shows how to trigger this: I believe this new request is to mark the class somehow so that the code action is more apparent? |
Beta Was this translation helpful? Give feedback.
-
Precisely. It's simply non-obvious that something can be done. |
Beta Was this translation helpful? Give feedback.
-
It's unlikely we'd get to this anytime soon. It would need a lot of people asking for it. |
Beta Was this translation helpful? Give feedback.
-
And it's not obvious how we should expose it. I'm not sure a squiggle makes sense. Those indicate something wrong with your code. This is more likely a VS code UI suggestion. How to indicate Code Actions are available on different pieces of code without clicking on them. |
Beta Was this translation helpful? Give feedback.
-
Well, squiggle can be white, as in grammar typo underline. |
Beta Was this translation helpful? Give feedback.
-
If you are not implementing all of the abstract methods, pyright (the type checker upon which pylance is built) will emit an error if you attempt to instantiate the incomplete class. It will tell you which methods are unimplemented. Furthermore, if you mark the concrete class as from abc import ABC, abstractmethod
from typing import final
class AbstractClass(ABC):
@abstractmethod
def method1(self) -> int:
raise NotImplementedError()
class ConcreteClass1(AbstractClass):
pass
c = ConcreteClass1() # Error: cannot instantiate abstract class
@final
class ConcreteClass2(AbstractClass): # Error: final class does not implement abstract symbols
pass |
Beta Was this translation helpful? Give feedback.
-
Hello,
Related to, automatic inherited method implementation of
ABC
and `ABCMeta, I would suggest a visible marking a possibility of such action, e.g. a warning or a spelling underline under the class. It is only natural that abstract class needs an implementation. E.g:`class SketchEnv(Abstract
Right now there is no marking that this is possible, and new users (me) don't know that this is a thing.
Thank you.
P.S. Also, it would be good if an ABCMeta implementation of ABC would have their methods declated as @AbstractMethod automatically, e.g.
I know this isn't always the case (with real implementations), but my guess is that it is more often that not.
P.S.S. Better context (21.6.2024): #5362
Beta Was this translation helpful? Give feedback.
All reactions