Skip to content

Python: Add VALID_TYPES to class Property #49

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bact
Copy link
Contributor

@bact bact commented May 2, 2025

To fix Pylint E1101:no-member warning in the resulting Python code that comes from this line in the template:

def validate(self, value):
check_type(value, self.VALID_TYPES)

Without the VALID_TYPES declared in the Property class, Pylint will warn:

Instance of 'Property' has no 'VALID_TYPES' member

To fix that, an empty VALID_TYPES = () is added.

In check_type(), the argument types will then be checked first if it is empty.

If types is empty, then the rest of check_type() will be skipped.

Note that this PR has changed the semantic of an empty VALID_TYPES. Previously, if VALID_TYPES happens to be empty, it means "nothing is valid". With this PR, it means "everything is valid" (or "nothing to validate").

--

Also sort the imports.

To fix Pylint E1101:no-member warning in the resulting Python code

Also sort the imports

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Copy link

github-actions bot commented May 2, 2025

Coverage report

This PR does not seem to contain any modification to coverable code.

@bact bact marked this pull request as draft May 3, 2025 10:02
typing.Any cannot be used with isinstance()

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact bact marked this pull request as ready for review May 3, 2025 10:24
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact bact marked this pull request as draft May 4, 2025 13:48
@bact
Copy link
Contributor Author

bact commented May 4, 2025

This creates other warnings. Because of the type mismatches introduced by this PR.
Put to draft.

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

Successfully merging this pull request may close these issues.

1 participant