Skip to content

Commit

Permalink
Disable irrelevant pylint errors
Browse files Browse the repository at this point in the history
Errors were:

```
************* Module stbt_rig
stbt_rig.py:1237:4: [W0223(abstract-method), StbtCollector] Method 'get_closest_marker' is abstract in class 'Node' but is not overridden
stbt_rig.py:1237:4: [W0223(abstract-method), StbtCollector] Method 'gethookproxy' is abstract in class 'FSCollector' but is not overridden
stbt_rig.py:1237:4: [W0223(abstract-method), StbtCollector] Method 'isinitpath' is abstract in class 'FSCollector' but is not overridden
stbt_rig.py:1257:4: [W0223(abstract-method), StbtRemoteTest] Method 'get_closest_marker' is abstract in class 'Node' but is not overridden
```

The `get_closest_marker` is a pylint false positive because it's defined
multiple times in `class Node`:

```python
class Node(metaclass=NodeMeta):
    ...
    @overload
    def get_closest_marker(self, name: str) -> Optional[Mark]:
        raise NotImplementedError()

    @overload  # noqa: F811
    def get_closest_marker(self, name: str, default: Mark) -> Mark:  # noqa: F811
        raise NotImplementedError()

    def get_closest_marker(  # noqa: F811
        self, name: str, default: Optional[Mark] = None
    ) -> Optional[Mark]:
        """return the first marker matching the name, from closest (for example function) to farther level (for example
        module level).

        :param default: fallback return value of no marker was found
        :param name: name to filter by
        """
        return next(self.iter_markers(name=name), default)
```

The other two don't need to be inherited because they'll never be called:
pytest-dev/pytest#7591 .  This is fixed in
pytest 6.1: pytest-dev/pytest#7648
  • Loading branch information
wmanley committed Sep 8, 2020
1 parent 7e72a34 commit 08284a5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stbt_rig.py
Expand Up @@ -1235,6 +1235,7 @@ def pytest_collect_file(path, parent):


class StbtCollector(pytest.File):
# pylint: disable=abstract-method
def collect(self):
with open(self.fspath.strpath) as f:
# We implement our own parsing to avoid import stbt ImportErrors
Expand All @@ -1255,6 +1256,7 @@ def collect(self):


class StbtRemoteTest(pytest.Item):
# pylint: disable=abstract-method
def __init__(self, parent, filename, testname, line_number):
super(StbtRemoteTest, self).__init__(testname, parent)
self._filename = filename
Expand Down

0 comments on commit 08284a5

Please sign in to comment.