-
Notifications
You must be signed in to change notification settings - Fork 276
Closed
Labels
Description
Describe the Bug
When I enable the unannotated-parameter error in scipy-stubs (scipy/scipy-stubs#1262), 17 errors are reported (gh action log) for the first parameter of classmethods or __new__ methods if its name isn't cls
Repro
class A:
def __new__(cls, a: int) -> A: ... # ✔️
class B:
def __new__(_cls, a: int) -> B: ... # ❌ `__new__` is missing an annotation for parameter `_cls`(sandbox)
I'd rather just name them cls, but I'm not able to, because then it wouldn't match the runtime name (i.e., stubtest will complain).
And although it's not an issue for scipy-stubs, I also noticed that this is also the case for self parameters of instance methods (sandbox).
The opposite also seems to be the case, i.e. non-instance method parameters called self or cls without annotation, regardless of position, will not be reported as unannotated. For example the following will be accepted:
def f(a: str, self, cls, b: int) -> None: ... # ✔️ (sandbox)
Sandbox Link
(Only applicable for extension issues) IDE Information
No response
Reactions are currently unavailable