Skip to content

Disable ANN201 None-autofix for abstractmethods? #9004

@twoertwein

Description

@twoertwein

Abstract methods often have an almost empty body (doc-string, pass, or raise) but it seems unlikely that they should return None. https://github.com/JelleZijlstra/autotyping does not add None for abstractmethods.

import abc

class Test(abc.ABC):
    @abc.abstractmethod
    def test(self):  #ruff adds  -> None
        """sub-classes have to implement this"""
$ ruff --version
ruff 0.1.7
$ ruff --select ANN2 --exit-non-zero-on-fix --unsafe-fixes test.py 
Found 1 error (1 fixed, 0 remaining).

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions