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
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/shacl2code/lang/templates/python.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import sys
import threading
import time
import warnings
from abc import ABC, abstractmethod
from contextlib import contextmanager
from datetime import datetime, timezone, timedelta
from datetime import datetime, timedelta, timezone
from enum import Enum
from abc import ABC, abstractmethod


def check_type(obj, types):
if not isinstance(obj, types):
if types and not isinstance(obj, types):
if isinstance(types, (list, tuple)):
raise TypeError(
f"Value must be one of type: {', '.join(t.__name__ for t in types)}. Got {type(obj)}"
Expand All @@ -35,6 +35,8 @@ class Property(ABC):
class
"""

VALID_TYPES = () # if empty, everything is valid

def __init__(self, *, pattern=None):
self.pattern = pattern

Expand Down
Loading