MCPcopy Index your code
hub / github.com/STIXProject/python-stix / warn

Function warn

stix/utils/deprecated.py:32–48  ·  view source on GitHub ↗

Raises a Python UserWarning if `value` is not None. This is typically going to be used inside setter functions for deprecated fields. The deprecation warning shouldn't be raised when the field is being initialized to ``None``.

(value)

Source from the content-addressed store, hash-verified

30
31
32def warn(value):
33 """Raises a Python UserWarning if `value` is not None.
34
35 This is typically going to be used inside setter functions for deprecated
36 fields. The deprecation warning shouldn't be raised when the field is being
37 initialized to ``None``.
38
39 """
40 if value is None:
41 return
42
43 if is_sequence(value) and not value:
44 return
45
46 fmt = "The use of this field has been deprecated. Received '{0}' object."
47 msg = fmt.format(type(value).__name__)
48 warnings.warn(msg)
49
50
51class IdrefDeprecatedList(TypedList):

Callers 2

fieldFunction · 0.85
insertMethod · 0.85

Calls 1

is_sequenceFunction · 0.85

Tested by

no test coverage detected