Python: Add VALID_TYPES to class Property #49
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To fix Pylint E1101:no-member warning in the resulting Python code that comes from this line in the template:
shacl2code/src/shacl2code/lang/templates/python.j2
Lines 44 to 45 in b9246b2
Without the VALID_TYPES declared in the
Property
class, Pylint will warn:To fix that, an empty
VALID_TYPES = ()
is added.In
check_type()
, the argumenttypes
will then be checked first if it is empty.If
types
is empty, then the rest ofcheck_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.