-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Sphinx docstring style (#46)
- Loading branch information
Showing
26 changed files
with
2,607 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from abc import ABC, abstractmethod | ||
from collections.abc import Generator, Iterator | ||
|
||
|
||
class AbstractClass(ABC): | ||
"""Example abstract class.""" | ||
|
||
@abstractmethod | ||
def abstract_method(self, var1: str) -> Generator[str, None, None]: | ||
"""Abstract method. | ||
No violations in this method. | ||
:param var1: Variable. | ||
:type var1: str | ||
:raises: ValueError: Example exception | ||
:yield: Paths to the files and directories listed. | ||
:rtype: str | ||
""" | ||
|
||
@abstractmethod | ||
def another_abstract_method(self, var1: str) -> Iterator[str]: | ||
"""Another abstract method. | ||
The linter will complain about not having a return section, because | ||
if the return type annotation is `Iterator`, it is supposed to be | ||
returning something, rather than yielding something. (To yield | ||
something, use `Generator` as the return type annotation.) | ||
:param var1: Variable. | ||
:type var1: str | ||
:raises: ValueError: Example exception | ||
:yield: Paths to the files and directories listed. | ||
:rtype: str | ||
""" | ||
|
||
@abstractmethod | ||
def third_abstract_method(self, var1: str) -> str: | ||
"""The 3rd abstract method. | ||
The linter will complain about not having a return section. | ||
:param var1: Variable. | ||
:type var1: str | ||
:raises: ValueError: Example exception | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
class A: | ||
""" | ||
A class that does something | ||
:param arg1: Arg 1 | ||
:type arg1: int | ||
:param arg2: Arg 2 | ||
:type arg2: float | ||
""" | ||
|
||
def __init__(self, arg1: int, arg2: float) -> None: | ||
"""Initialize the class""" | ||
self.arg1 = arg1 | ||
self.arg2 = arg2 | ||
|
||
|
||
class B: | ||
""" | ||
A class that does something | ||
:param arg1: Arg 1 | ||
:type arg1: int | ||
:param arg2: Arg 2 | ||
:type arg2: float | ||
:return: None | ||
:rtype: None | ||
""" | ||
|
||
def __init__(self, arg1: int, arg2: float) -> None: | ||
""" | ||
Do something. | ||
:param arg1: Arg 1 | ||
:type arg1: int | ||
:param arg2: Arg 2 | ||
:type arg2: float | ||
:return: None | ||
:rtype: None | ||
""" | ||
self.arg1 = arg1 | ||
self.arg2 = arg2 | ||
|
||
|
||
class C: | ||
""" | ||
A class that does something | ||
:raises TypeError: Type error | ||
""" | ||
|
||
def __init__(self, arg1: int, arg2: float) -> None: | ||
""" | ||
Do something. | ||
:param arg1: Arg 1 | ||
:type arg1: int | ||
:param arg2: Arg 2 | ||
:type arg2: float | ||
:raises TypeError: Type error | ||
""" | ||
self.arg1 = arg1 | ||
self.arg2 = arg2 | ||
|
||
if arg1 + arg2 == 0: | ||
raise ValueError('Something wrong') | ||
|
||
|
||
class D: | ||
""" | ||
A class that does something | ||
:yield: Thing to yield | ||
:rtype: int | ||
""" | ||
|
||
def __init__(self, arg1: int, arg2: float) -> None: | ||
""" | ||
Do something. | ||
:param arg1: Arg 1 | ||
:type arg1: int | ||
:param arg2: Arg 2 | ||
:type arg2: float | ||
:yield: Thing to yield | ||
:rtype: int | ||
""" | ||
self.arg1 = arg1 | ||
self.arg2 = arg2 | ||
|
||
|
||
class E: | ||
""" | ||
A class that does something | ||
:attr attr1: | ||
:attr attr1: Arg 2 | ||
""" | ||
|
||
def __init__(self, arg1: int, arg2: float) -> None: | ||
""" | ||
Do something. | ||
:param arg1: Arg 1 | ||
:type arg1: int | ||
:param arg2: Arg 2 | ||
:type arg2: float | ||
:raises: ValueError: When some values are invalid | ||
""" | ||
self.arg1 = arg1 | ||
self.arg2 = arg2 | ||
|
||
if arg1 + arg2 == 0: | ||
raise ValueError('Something wrong') |
Oops, something went wrong.