-
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.
Fix false positives in abstract methods (#35)
- Loading branch information
Showing
8 changed files
with
199 additions
and
8 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,54 @@ | ||
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. | ||
Args: | ||
var1 (str): Variable. | ||
Raises: | ||
ValueError: Example exception | ||
Yields: | ||
str: Paths to the files and directories listed. | ||
""" | ||
|
||
@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.) | ||
Args: | ||
var1 (str): Variable. | ||
Raises: | ||
ValueError: Example exception | ||
Yields: | ||
str: Paths to the files and directories listed. | ||
""" | ||
|
||
@abstractmethod | ||
def third_abstract_method(self, var1: str) -> str: | ||
"""The 3rd abstract method. | ||
The linter will complain about not having a return section. | ||
Args: | ||
var1 (str): Variable. | ||
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,70 @@ | ||
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. | ||
Parameters | ||
---------- | ||
var1 : str | ||
Variable. | ||
Raises | ||
------ | ||
ValueError | ||
Example exception | ||
Yields | ||
------ | ||
str | ||
Paths to the files and directories listed. | ||
""" | ||
|
||
@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.) | ||
Parameters | ||
---------- | ||
var1 : str | ||
Variable. | ||
Raises | ||
------ | ||
ValueError | ||
Example exception | ||
Yields | ||
------ | ||
str | ||
Paths to the files and directories listed. | ||
""" | ||
|
||
@abstractmethod | ||
def third_abstract_method(self, var1: str) -> str: | ||
"""The 3rd abstract method. | ||
The linter will complain about not having a return section. | ||
Parameters | ||
---------- | ||
var1 : str | ||
Variable. | ||
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
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