-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
We have some trouble with overloads on __init__ methods. We get DOC105: ... for what we think should be supported/correct code:
DOC105: Method `FooWrite.__init__`: Argument names match, but type hints in these args do not match: bar, baz
Here is the offending code:
class FooWrite(SomeObject):
"""
The Foo write class.
Args:
bar (str | None): Description of bar.
baz (int | None): Description of baz.
"""
@overload
def __init__(self, bar: None, baz: None) -> NoReturn: ...
@overload
def __init__(self, bar: str | None, baz: int | None) -> None: ...
def __init__(self, bar: str | None, baz: int | None) -> None:
if bar is None and baz is None:
raise ValueErrorIf we instead do the exact same on a different method, everything works as expected:
class FooWrite(SomeObject):
@overload
def method(self, bar: None, baz: None) -> NoReturn: ...
@overload
def method(self, bar: str | None, baz: int | None) -> None: ...
def method(self, bar: str | None, baz: int | None) -> None:
"""
The method method
Args:
bar (str | None): Description of bar.
baz (int | None): Description of baz.
"""
if bar is None and baz is None:
raise ValueErrorAny idea? I suspect there's something going wrong since we look for/demand the docstring be place on the class instead of the method.
Some more info: We run pydoclint as part of pre-commit, here is the config we use:
- repo: https://github.com/jsh9/pydoclint
rev: 0.6.7
hooks:
- id: pydoclint
require_serial: true
args:
- --style=google
- --exclude=tests/|scripts/
- --quiet
- --skip-checking-raises=true
- --check-class-attributes=false
Metadata
Metadata
Assignees
Labels
No labels