Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linting no-member when setattr is used #147

Open
wvangerwen opened this issue Nov 7, 2023 · 0 comments
Open

linting no-member when setattr is used #147

wvangerwen opened this issue Nov 7, 2023 · 0 comments

Comments

@wvangerwen
Copy link
Collaborator

pylint shows an error when setting an attribute to a class with setattr
image

we use .add_file on hrt.Folder which dynamically sets attributes. Resulting in lots of linting errors.

This solution does not work as it introduces other errors. When accessing an unknown attribute it should still raise an error.

    def __getattr__(self, name):
        """Ignore pylint errors that attributs set with setattr are
        __getattr__ will only get called for undefined attributes.
        Idea from:
        https://stackoverflow.com/questions/35990313/avoid-pylint-warning-e1101-instance-of-has-no-member-for-class-with-dyn
        FIXME: disabled because it breaks code hints (ctrl+space)
        """
        warnings.warn(f"No member {name} contained in {self.__class__.__name__}.")
        return ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant