admin管理员组文章数量:1122846
I have an abstract method which just includes a pass statement, as the method implementation is in another class that inherits from this abstract class. Here is the method:
@abstractmethod
def parse_sun_times(self, times_as_strings: Dict[str, str]) -> SunTimes:
"""
Parses a dictionary of time strings into a SunTimes object.
Args:
times_as_strings (Dict[str, str]): A dictionary containing time strings as values and
sun phases as keys
Returns:
SunTimes: An object representing parsed sunrise, sunset, and twilight times.
"""
pass
Pylint is giving the warning "unnecessary pass statement". Is there some way I can signify to pylint that this is an abstract method, or do I just have to disable the warning manually?
I have an abstract method which just includes a pass statement, as the method implementation is in another class that inherits from this abstract class. Here is the method:
@abstractmethod
def parse_sun_times(self, times_as_strings: Dict[str, str]) -> SunTimes:
"""
Parses a dictionary of time strings into a SunTimes object.
Args:
times_as_strings (Dict[str, str]): A dictionary containing time strings as values and
sun phases as keys
Returns:
SunTimes: An object representing parsed sunrise, sunset, and twilight times.
"""
pass
Pylint is giving the warning "unnecessary pass statement". Is there some way I can signify to pylint that this is an abstract method, or do I just have to disable the warning manually?
Share Improve this question edited Nov 22, 2024 at 18:02 imad97 asked Nov 22, 2024 at 17:32 imad97imad97 2661 silver badge12 bronze badges 8 | Show 3 more comments1 Answer
Reset to default 3As mentioned in Mathias' comment, because there is a docstring as the first element after the signature, the definition is syntactically complete without the need for a pass statement. To remove the warning, either remove the docstring or the pass statement, as it is unnecessary to include both.
本文标签: pythonPylint unnecessary pass statement for abstract methodStack Overflow
版权声明:本文标题:python - Pylint unnecessary pass statement for abstract method - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301931a1931348.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
...
instead ofpass
? – Alex Duchnowski Commented Nov 22, 2024 at 17:41