The Understand Python API gives scripts access to everything Understand knows about your code — entities, references, metrics, and dependencies — and powers custom checks, graphs, and reports.

Metric#

class understand.Metric#

Bases: object

Accessors for available metrics and metric descriptions.

Metric objects are hashable and compare by metric id.

Methods Summary

description

Return a description of the metric.

id

Return the metric id.

list

Return a list of metrics.

lookup

Return the Metric object for the given metric id.

name

Return the name of the metric.

tags

Return tags for the metric.

Methods Documentation

description() str#

Return a description of the metric.

Return type:

str

Returns:

the description of the metric.

id() str#

Return the metric id.

classmethod list(kindstring='', db=None, enabled_only=True) list[understand.Metric]#
classmethod list(target=None, enabled_only=True) list[understand.Metric]

Return a list of metrics.

Parameters:
  • target (understand.Ent or understand.Arch or understand.Db or None) – optional, list only metrics valid for this target

  • kindstring (str or None) – optional, a language-specific entity filter string

  • db (understand.Db) – optional, a database. A database is required to list metric plugins by kindstring. Providing a database limits results to metrics potentially applicable to the database or entities in the database. For built-in metrics, this will remove any metrics that don’t match the database languages. For metric plugins, this removes any plugins that don’t return True from the test_available function.

  • enabled_only (bool) – optional, defaults to True. When True return only enabled metrics.

Return type:

list[understand.Metric]

Returns:

metrics defined for entities matching the given kindstring or all possible metric names if no kindstring is given.

Either (target, enabled_only) or (kindstring, db, enabled_only) may be used.

classmethod lookup(metricid) understand.Metric#

Return the Metric object for the given metric id.

Parameters:

metricid (str) – the id of the metric

Return type:

understand.Metric or None

name() str#

Return the name of the metric.

Return type:

str

Returns:

the name of the metric

tags() list[str]#

Return tags for the metric.

Tags are optional and may be empty.