You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
importtypesystemclassConfig(typesystem.Schema):
num_worker_processes=typesystem.Integer()
enable_auto_reload=typesystem.Boolean()
text='''{ "num_worker_processes": "x", "enable_auto_reload": "true"}'''value, messages=typesystem.validate_json(text, validator=Config)
assertvalueisNoneformessageinmessages:
line_no=message.start_position.line_nocolumn_no=message.start_position.column_noprint(f"Error {message.text!r} at line {line_no}, column {column_no}.")
# Error 'Must be a number.' at line 2, column 29.
However, it fails with ValidationError. I expected it to print 'Must be a number ...' instead:
$ pipenv install typesystem
$ pipenv run python3 -c 'import typesystem; print(typesystem.__version__)'
0.2.2
$ pipenv run python3 example.py
Traceback (most recent call last):
File "/Users/me/.local/share/virtualenvs/example-AxLzGwo/lib/python3.7/site-packages/typesystem/tokenize/positional_validation.py", line 13, in validate_with_positions
return validator.validate(token.value)
File "/Users/me/.local/share/virtualenvs/example-AxLzGwo/lib/python3.7/site-packages/typesystem/schemas.py", line 147, in validate
value = validator.validate(value, strict=strict)
File "/Users/me/.local/share/virtualenvs/example-AxLzGwo/lib/python3.7/site-packages/typesystem/fields.py", line 545, in validate
raise ValidationError(messages=error_messages)
typesystem.base.ValidationError: {'num_worker_processes': 'Must be a number.'}
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "example.py", line 12, in <module>
value, messages = typesystem.validate_json(text, validator=Config)
File "/Users/me/.local/share/virtualenvs/example-AxLzGwo/lib/python3.7/site-packages/typesystem/tokenize/tokenize_json.py", line 197, in validate_json
return validate_with_positions(token=token, validator=validator)
File "/Users/me/.local/share/virtualenvs/example-AxLzGwo/lib/python3.7/site-packages/typesystem/tokenize/positional_validation.py", line 36, in validate_with_positions
raise ValidationError(messages=messages)
typesystem.base.ValidationError: {'num_worker_processes': 'Must be a number.'}
I've copy-pasted "Tokenized Errors" example from documentation to
example.py:However, it fails with
ValidationError. I expected it to print'Must be a number ...'instead: