from pprint import pprint
ctx = {'@vocab': 'http://ex.org/#', 'path': {'@type': '@id'}}
data = {
'http://ex.org/#maxCount': 1,
'http://ex.org/#path': 'http://ex.org/#shortname'
}
pprint(jsonld.compact(data, ctx))
# {
# '@context': {'@vocab': 'http://ex.org/#', 'path': {'@type': '@id'}},
# # NOTE: maxCount: not declared in context => compacted OK
# 'maxCount': 1
# # NOTE: path: declared in context => compacting FAILED
# 'http://ex.org/#path': 'http://ex.org/#shortname',
# }