threedi / hhnk-threedi-plugin

QGIS plugin gebruikt voor analyses van 3Di modellen bij HHNK.
1 stars 0 forks source link

linting no-member when setattr is used #147

Open wvangerwen opened 8 months ago

wvangerwen commented 8 months ago

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 ""