apache / apache/buildstream

Incorrect `no-member` linter errors from cython modules

Open
#1,397 0 comments 0 reactions 0 assignees View on GitHub
refactoring
Dominant language
Python
Stars
140
Forks
45
Avg merge
1d 3h
Merged PRs (30d)
6

Description

[See original issue on GitLab](https://gitlab.com/BuildStream/buildstream/-/issues/1397)
In GitLab by [[Gitlab user @tristanvb]](https://gitlab.com/tristanvb) on Oct 1, 2020, 05:30

Follow-up from "Refactor: Lazily instantiate ProvenanceInformation objects"

The following discussion from !2026 should be addressed:

- [ ] [[Gitlab user @BenjaminSchubert]](https://gitlab.com/BenjaminSchubert) started a [discussion](https://gitlab.com/BuildStream/buildstream/-/merge_requests/2026#note_421537473): (+1 comment)

> [[Gitlab user @tristanvb]](https://gitlab.com/tristanvb) I've look into the linting error more, I can't figure out why it does fail.
>
> At that point I'd suggest extracing the `top_element.link_target.as_str()` in a variable and silence pylint for that error on the line

## Follow up comment

I chased this down the rabbit hole a bit, and stumbled on [this post](https://www.semicolonworld.com/question/58415/pylint-1-4-reports-e1101-no-member-on-all-c-extensions), and discovered we are whitelisting our cython modules to be loaded by the linter and telling the linter to enable `c-extension-no-member`.

I was also unable to get to the bottom of it, it seems we are hitting some kind of edge case, and I think a hint is that the errors themselves are incorrect, if I remove all the disabling of `no-member` in `loader.py`:

```
src/buildstream/_loader/loader.py:149:8: E1101: Class 'dependencies' has no 'extend' member (no-member)
src/buildstream/_loader/loader.py:354:26: E1101: Class 'link_target' has no 'as_str' member (no-member)
src/buildstream/_loader/loader.py:392:27: E1101: Class 'node' has no 'get_str' member (no-member)
```

In each case, the linter is mistaking a variable name for a class, the error in question *should* be printed as:

```
src/buildstream/_loader/loader.py:354:26: E1101: Class 'ScalarNode' has no 'as_str' member (no-member)
```

But the linter instead thinks the reference to the instance `link_target` is itself the `ScalarNode` class.

In any case, for now I will just disable the error as you suggest.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing pylint on src/buildstream/_loader/loader.py, especially lines 149, 354, and 392, and inspect the Cython-module whitelist and c-extension-no-member settings mentioned in the issue. Done means the false no-member reports for dependencies.extend, link_target.as_str, and node.get_str are resolved and the relevant lint run passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.