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

Add __getattr__ to bpy.types.OperatorProperties to suppress warnings when accessing attributes #6

Open
Mysteryem opened this issue Nov 21, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Mysteryem
Copy link
Owner

Example use of OperatorProperties is in the description classmethod of Operator subclasses or in cases of checking whether a specific property of an Operator instance is set or if the default value of that property is being used.

The properties of the Operator can be accessed from its OperatorProperties through the same, normal attribute access, but PyCharm will consider these attributes to not exist since they're not defined in the OperatorProperties class.

Adding a __getattr__ stub method to OperatorProperties will suppress warnings when accessing attributes that don't exist in the class. (adding __getattribute__ seems to work too)

The method must have a docstring indicating

I'm not anticipating that there will be a way to signify to PyCharm that it should look at the attributes of the Operator instead.

Note that the properties of Operator instances may actually be stored in its OperatorProperties (.properties). The Operator class overrides __getattribute__ to get attributes from its OperatorProperties if the name of the attribute matches a property defined in the OperatorProperties. See the Operator class in bpy_types.py of Blender.

@Mysteryem Mysteryem added the enhancement New feature or request label Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant