MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / Mapping

Function Mapping

src/commoncode/datautils.py:227–259  ·  view source on GitHub ↗

Return a mapping attribute: the optional value_type defines the type of values it stores. The key is always a string. Notes: in Python 2 the type is Dict as there is no typing available for dict for now.

(
    value_type=typing.Any,
    default=attr.NOTHING,
    validator=None,
    repr=False,
    eq=True,
    order=True,  # NOQA
    converter=None,
    help=None,
    label=None,
)

Source from the content-addressed store, hash-verified

225
226
227def Mapping(
228 value_type=typing.Any,
229 default=attr.NOTHING,
230 validator=None,
231 repr=False,
232 eq=True,
233 order=True, # NOQA
234 converter=None,
235 help=None,
236 label=None,
237): # NOQA
238 """
239 Return a mapping attribute: the optional value_type defines the type of values it
240 stores. The key is always a string.
241
242 Notes: in Python 2 the type is Dict as there is no typing available for
243 dict for now.
244 """
245 if default is attr.NOTHING:
246 default = attr.Factory(dict)
247
248 return attribute(
249 default=default,
250 validator=validator,
251 repr=repr,
252 eq=eq,
253 order=order,
254 init=True,
255 type=typing.Dict[str, value_type],
256 converter=converter,
257 help=help,
258 label=label,
259 )
260
261
262##################################################

Callers 6

DependentPackageClass · 0.90
FileReferenceClass · 0.90
PackageDataClass · 0.90
GemClass · 0.90
HeaderClass · 0.90

Calls 1

attributeFunction · 0.70

Tested by

no test coverage detected