From: Simon Marchi Date: Tue, 19 Sep 2023 18:45:05 +0000 (-0400) Subject: python: run isort on everything X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=5995b304e5601bf9b97ffa661b21874bec6c0e3a python: run isort on everything Run isort on the whole repo, to nicely sort Python imports. Add a mention in CONTRIBUTING.adoc, that all Python imports must be sorted using the version of isort specified in dev-requirements.txt. Add `isort ~= 5.12` to dev-requirements.txt. 5.12 is the latest stable version available on PyPi as of writing. Tell isort to use its `black` profile, in pyproject.toml, so that black remains happy. The details of that profile are here: https://pycqa.github.io/isort/docs/configuration/profiles.html Tell isort to ignore `tests/utils/python/tap`, since it's code copied from elsewhere. Use the `length_sort` option, because Philippe prefers it like that. See: https://pycqa.github.io/isort/docs/configuration/custom_sections_and_ordering.html Change-Id: I8778f908342d0feeb97d4442506113d9252559e7 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/10871 Tested-by: jenkins Reviewed-by: Philippe Proulx --- diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 5937194f..5435ff6e 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -1955,3 +1955,6 @@ private: All Python code must be formatted using the version of https://github.com/psf/black[Black] specified in `dev-requirements.txt`. + +All Python imports must be sorted using the version of +https://pycqa.github.io/isort/[isort] indicated in `dev-requirements.txt`. diff --git a/dev-requirements.txt b/dev-requirements.txt index f955fb6e..b68507ad 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -2,3 +2,4 @@ black ~= 23.9.1 flake8 >= 3.8 # Required for black 22.0, it's broken with click >= 8.1 click < 8.1 +isort ~= 5.12 diff --git a/doc/bindings/python/ext/bt2sphinxurl.py b/doc/bindings/python/ext/bt2sphinxurl.py index d76cc1c7..830e0d1e 100644 --- a/doc/bindings/python/ext/bt2sphinxurl.py +++ b/doc/bindings/python/ext/bt2sphinxurl.py @@ -33,12 +33,13 @@ # # :bt2link:`libbabeltrace2 ` -import docutils -import docutils.utils -import docutils.nodes import re import functools +import docutils +import docutils.nodes +import docutils.utils + def _bt2man_role( bt2_version, name, rawtext, text, lineno, inliner, options=None, content=None diff --git a/doc/bindings/python/source/conf.py b/doc/bindings/python/source/conf.py index 148cc92a..99e60af8 100644 --- a/doc/bindings/python/source/conf.py +++ b/doc/bindings/python/source/conf.py @@ -2,9 +2,10 @@ # # Copyright (c) 2020 Philippe Proulx -import bt2 import re +import bt2 + # project project = "Babeltrace 2 Python bindings" copyright = "2020, EfficiOS, Inc" diff --git a/pyproject.toml b/pyproject.toml index 39d5b4a3..7c1cb584 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,3 +15,8 @@ ) ''' + +[tool.isort] +profile = "black" +extend_skip_glob = ["tests/utils/python/tap"] +length_sort = true diff --git a/src/bindings/python/bt2/bt2/__init__.py b/src/bindings/python/bt2/bt2/__init__.py index cf4d9bd2..089c98b0 100644 --- a/src/bindings/python/bt2/bt2/__init__.py +++ b/src/bindings/python/bt2/bt2/__init__.py @@ -4,186 +4,199 @@ import sys +from bt2.mip import get_maximal_mip_version, get_greatest_operative_mip_version +from bt2.error import ( + ComponentClassType, + _Error, + _ErrorCause, + _MemoryError, + _ComponentErrorCause, + _ComponentClassErrorCause, + _MessageIteratorErrorCause, +) +from bt2.field import ( + _BoolField, + _RealField, + _ArrayField, + _OptionField, + _StringField, + _IntegerField, + _VariantField, + _BitArrayField, + _BoolFieldConst, + _RealFieldConst, + _StructureField, + _ArrayFieldConst, + _EnumerationField, + _OptionFieldConst, + _StaticArrayField, + _StringFieldConst, + _DynamicArrayField, + _IntegerFieldConst, + _VariantFieldConst, + _BitArrayFieldConst, + _SignedIntegerField, + _StructureFieldConst, + _UnsignedIntegerField, + _EnumerationFieldConst, + _StaticArrayFieldConst, + _DynamicArrayFieldConst, + _SignedEnumerationField, + _SignedIntegerFieldConst, + _DoublePrecisionRealField, + _SinglePrecisionRealField, + _UnsignedEnumerationField, + _UnsignedIntegerFieldConst, + _SignedEnumerationFieldConst, + _DoublePrecisionRealFieldConst, + _SinglePrecisionRealFieldConst, + _UnsignedEnumerationFieldConst, +) +from bt2.graph import Graph +from bt2.utils import Stop, TryAgain, UnknownObject, _OverflowError +from bt2.value import ( + MapValue, + BoolValue, + RealValue, + ArrayValue, + StringValue, + SignedIntegerValue, + UnsignedIntegerValue, + create_value, + _IntegerValue, + _MapValueConst, + _BoolValueConst, + _RealValueConst, + _ArrayValueConst, + _StringValueConst, + _IntegerValueConst, + _SignedIntegerValueConst, + _UnsignedIntegerValueConst, +) +from bt2.plugin import find_plugin, find_plugins, find_plugins_in_path +from bt2.logging import ( + LoggingLevel, + get_global_logging_level, + set_global_logging_level, + get_minimal_logging_level, +) +from bt2.message import ( + _EventMessage, + _PacketEndMessage, + _StreamEndMessage, + _EventMessageConst, + _PacketEndMessageConst, + _StreamEndMessageConst, + _DiscardedEventsMessage, + _PacketBeginningMessage, + _StreamBeginningMessage, + _DiscardedPacketsMessage, + _DiscardedEventsMessageConst, + _PacketBeginningMessageConst, + _StreamBeginningMessageConst, + _DiscardedPacketsMessageConst, + _MessageIteratorInactivityMessage, + _MessageIteratorInactivityMessageConst, +) +from bt2.version import __version__ +from bt2.component import ( + _UserSinkComponent, + _SinkComponentConst, + _IncompleteUserClass, + _UserFilterComponent, + _UserSourceComponent, + _FilterComponentConst, + _SourceComponentConst, + _SinkComponentClassConst, + _FilterComponentClassConst, + _SourceComponentClassConst, +) +from bt2.py_plugin import register_plugin, plugin_component_class +from bt2.field_path import ( + FieldPathScope, + _IndexFieldPathItem, + _CurrentArrayElementFieldPathItem, + _CurrentOptionContentFieldPathItem, +) + # import all public names from bt2.clock_class import ClockClassOffset -from bt2.clock_snapshot import _ClockSnapshotConst -from bt2.clock_snapshot import _UnknownClockSnapshot -from bt2.component import _IncompleteUserClass -from bt2.component import _SourceComponentClassConst -from bt2.component import _FilterComponentClassConst -from bt2.component import _SinkComponentClassConst -from bt2.component import _SourceComponentConst -from bt2.component import _FilterComponentConst -from bt2.component import _SinkComponentConst -from bt2.component import _UserSourceComponent -from bt2.component import _UserFilterComponent -from bt2.component import _UserSinkComponent -from bt2.component_descriptor import ComponentDescriptor -from bt2.error import ComponentClassType -from bt2.error import _ErrorCause -from bt2.error import _ComponentErrorCause -from bt2.error import _ComponentClassErrorCause -from bt2.error import _MessageIteratorErrorCause -from bt2.error import _Error -from bt2.error import _MemoryError from bt2.event_class import EventClassLogLevel -from bt2.field import _BoolField -from bt2.field import _BitArrayField -from bt2.field import _IntegerField -from bt2.field import _UnsignedIntegerField -from bt2.field import _SignedIntegerField -from bt2.field import _RealField -from bt2.field import _SinglePrecisionRealField -from bt2.field import _DoublePrecisionRealField -from bt2.field import _EnumerationField -from bt2.field import _UnsignedEnumerationField -from bt2.field import _SignedEnumerationField -from bt2.field import _StringField -from bt2.field import _StructureField -from bt2.field import _OptionField -from bt2.field import _VariantField -from bt2.field import _ArrayField -from bt2.field import _StaticArrayField -from bt2.field import _DynamicArrayField -from bt2.field import _BoolFieldConst -from bt2.field import _BitArrayFieldConst -from bt2.field import _IntegerFieldConst -from bt2.field import _UnsignedIntegerFieldConst -from bt2.field import _SignedIntegerFieldConst -from bt2.field import _RealFieldConst -from bt2.field import _SinglePrecisionRealFieldConst -from bt2.field import _DoublePrecisionRealFieldConst -from bt2.field import _EnumerationFieldConst -from bt2.field import _UnsignedEnumerationFieldConst -from bt2.field import _SignedEnumerationFieldConst -from bt2.field import _StringFieldConst -from bt2.field import _StructureFieldConst -from bt2.field import _OptionFieldConst -from bt2.field import _VariantFieldConst -from bt2.field import _ArrayFieldConst -from bt2.field import _StaticArrayFieldConst -from bt2.field import _DynamicArrayFieldConst -from bt2.field_class import IntegerDisplayBase -from bt2.field_class import _BoolFieldClass -from bt2.field_class import _BitArrayFieldClass -from bt2.field_class import _IntegerFieldClass -from bt2.field_class import _UnsignedIntegerFieldClass -from bt2.field_class import _SignedIntegerFieldClass -from bt2.field_class import _RealFieldClass -from bt2.field_class import _EnumerationFieldClass -from bt2.field_class import _UnsignedEnumerationFieldClass -from bt2.field_class import _SignedEnumerationFieldClass -from bt2.field_class import _StringFieldClass -from bt2.field_class import _StructureFieldClass -from bt2.field_class import _OptionFieldClass -from bt2.field_class import _OptionWithSelectorFieldClass -from bt2.field_class import _OptionWithBoolSelectorFieldClass -from bt2.field_class import _OptionWithIntegerSelectorFieldClass -from bt2.field_class import _OptionWithUnsignedIntegerSelectorFieldClass -from bt2.field_class import _OptionWithSignedIntegerSelectorFieldClass -from bt2.field_class import _VariantFieldClass -from bt2.field_class import _VariantFieldClassWithoutSelector -from bt2.field_class import _VariantFieldClassWithIntegerSelector -from bt2.field_class import _VariantFieldClassWithUnsignedIntegerSelector -from bt2.field_class import _VariantFieldClassWithSignedIntegerSelector -from bt2.field_class import _ArrayFieldClass -from bt2.field_class import _StaticArrayFieldClass -from bt2.field_class import _DynamicArrayFieldClass -from bt2.field_class import _DynamicArrayWithLengthFieldFieldClass -from bt2.field_class import _BoolFieldClassConst -from bt2.field_class import _BitArrayFieldClassConst -from bt2.field_class import _IntegerFieldClassConst -from bt2.field_class import _UnsignedIntegerFieldClassConst -from bt2.field_class import _SignedIntegerFieldClassConst -from bt2.field_class import _RealFieldClassConst -from bt2.field_class import _EnumerationFieldClassConst -from bt2.field_class import _UnsignedEnumerationFieldClassConst -from bt2.field_class import _SignedEnumerationFieldClassConst -from bt2.field_class import _StringFieldClassConst -from bt2.field_class import _StructureFieldClassConst -from bt2.field_class import _OptionFieldClassConst -from bt2.field_class import _OptionWithSelectorFieldClassConst -from bt2.field_class import _OptionWithBoolSelectorFieldClassConst -from bt2.field_class import _OptionWithIntegerSelectorFieldClassConst -from bt2.field_class import _OptionWithUnsignedIntegerSelectorFieldClassConst -from bt2.field_class import _OptionWithSignedIntegerSelectorFieldClassConst -from bt2.field_class import _VariantFieldClassConst -from bt2.field_class import _VariantFieldClassWithoutSelectorConst -from bt2.field_class import _VariantFieldClassWithIntegerSelectorConst -from bt2.field_class import _VariantFieldClassWithUnsignedIntegerSelectorConst -from bt2.field_class import _VariantFieldClassWithSignedIntegerSelectorConst -from bt2.field_class import _ArrayFieldClassConst -from bt2.field_class import _StaticArrayFieldClassConst -from bt2.field_class import _DynamicArrayFieldClassConst -from bt2.field_class import _DynamicArrayWithLengthFieldFieldClassConst -from bt2.field_path import FieldPathScope -from bt2.field_path import _IndexFieldPathItem -from bt2.field_path import _CurrentArrayElementFieldPathItem -from bt2.field_path import _CurrentOptionContentFieldPathItem -from bt2.graph import Graph -from bt2.integer_range_set import SignedIntegerRange -from bt2.integer_range_set import UnsignedIntegerRange -from bt2.integer_range_set import SignedIntegerRangeSet -from bt2.integer_range_set import UnsignedIntegerRangeSet -from bt2.integer_range_set import _SignedIntegerRangeConst -from bt2.integer_range_set import _UnsignedIntegerRangeConst -from bt2.integer_range_set import _SignedIntegerRangeSetConst -from bt2.integer_range_set import _UnsignedIntegerRangeSetConst +from bt2.field_class import ( + IntegerDisplayBase, + _BoolFieldClass, + _RealFieldClass, + _ArrayFieldClass, + _OptionFieldClass, + _StringFieldClass, + _IntegerFieldClass, + _VariantFieldClass, + _BitArrayFieldClass, + _BoolFieldClassConst, + _RealFieldClassConst, + _StructureFieldClass, + _ArrayFieldClassConst, + _EnumerationFieldClass, + _OptionFieldClassConst, + _StaticArrayFieldClass, + _StringFieldClassConst, + _DynamicArrayFieldClass, + _IntegerFieldClassConst, + _VariantFieldClassConst, + _BitArrayFieldClassConst, + _SignedIntegerFieldClass, + _StructureFieldClassConst, + _UnsignedIntegerFieldClass, + _EnumerationFieldClassConst, + _StaticArrayFieldClassConst, + _DynamicArrayFieldClassConst, + _SignedEnumerationFieldClass, + _OptionWithSelectorFieldClass, + _SignedIntegerFieldClassConst, + _UnsignedEnumerationFieldClass, + _UnsignedIntegerFieldClassConst, + _OptionWithBoolSelectorFieldClass, + _SignedEnumerationFieldClassConst, + _VariantFieldClassWithoutSelector, + _OptionWithSelectorFieldClassConst, + _UnsignedEnumerationFieldClassConst, + _OptionWithIntegerSelectorFieldClass, + _VariantFieldClassWithIntegerSelector, + _DynamicArrayWithLengthFieldFieldClass, + _OptionWithBoolSelectorFieldClassConst, + _VariantFieldClassWithoutSelectorConst, + _OptionWithIntegerSelectorFieldClassConst, + _OptionWithSignedIntegerSelectorFieldClass, + _VariantFieldClassWithIntegerSelectorConst, + _DynamicArrayWithLengthFieldFieldClassConst, + _VariantFieldClassWithSignedIntegerSelector, + _OptionWithUnsignedIntegerSelectorFieldClass, + _VariantFieldClassWithUnsignedIntegerSelector, + _OptionWithSignedIntegerSelectorFieldClassConst, + _VariantFieldClassWithSignedIntegerSelectorConst, + _OptionWithUnsignedIntegerSelectorFieldClassConst, + _VariantFieldClassWithUnsignedIntegerSelectorConst, +) from bt2.interrupter import Interrupter -from bt2.logging import LoggingLevel -from bt2.logging import get_minimal_logging_level -from bt2.logging import get_global_logging_level -from bt2.logging import set_global_logging_level -from bt2.message import _EventMessage -from bt2.message import _PacketBeginningMessage -from bt2.message import _PacketEndMessage -from bt2.message import _StreamBeginningMessage -from bt2.message import _StreamEndMessage -from bt2.message import _MessageIteratorInactivityMessage -from bt2.message import _DiscardedEventsMessage -from bt2.message import _DiscardedPacketsMessage -from bt2.message import _EventMessageConst -from bt2.message import _PacketBeginningMessageConst -from bt2.message import _PacketEndMessageConst -from bt2.message import _StreamBeginningMessageConst -from bt2.message import _StreamEndMessageConst -from bt2.message import _MessageIteratorInactivityMessageConst -from bt2.message import _DiscardedEventsMessageConst -from bt2.message import _DiscardedPacketsMessageConst -from bt2.message_iterator import _UserMessageIterator -from bt2.mip import get_greatest_operative_mip_version -from bt2.mip import get_maximal_mip_version -from bt2.plugin import find_plugins_in_path -from bt2.plugin import find_plugins -from bt2.plugin import find_plugin -from bt2.py_plugin import plugin_component_class -from bt2.py_plugin import register_plugin +from bt2.clock_snapshot import _ClockSnapshotConst, _UnknownClockSnapshot from bt2.query_executor import QueryExecutor -from bt2.trace_collection_message_iterator import AutoSourceComponentSpec -from bt2.trace_collection_message_iterator import ComponentSpec -from bt2.trace_collection_message_iterator import TraceCollectionMessageIterator -from bt2.utils import UnknownObject -from bt2.utils import _OverflowError -from bt2.utils import TryAgain -from bt2.utils import Stop -from bt2.value import create_value -from bt2.value import BoolValue -from bt2.value import _IntegerValue -from bt2.value import UnsignedIntegerValue -from bt2.value import SignedIntegerValue -from bt2.value import RealValue -from bt2.value import StringValue -from bt2.value import ArrayValue -from bt2.value import MapValue -from bt2.value import _BoolValueConst -from bt2.value import _IntegerValueConst -from bt2.value import _UnsignedIntegerValueConst -from bt2.value import _SignedIntegerValueConst -from bt2.value import _RealValueConst -from bt2.value import _StringValueConst -from bt2.value import _ArrayValueConst -from bt2.value import _MapValueConst -from bt2.version import __version__ +from bt2.message_iterator import _UserMessageIterator +from bt2.integer_range_set import ( + SignedIntegerRange, + UnsignedIntegerRange, + SignedIntegerRangeSet, + UnsignedIntegerRangeSet, + _SignedIntegerRangeConst, + _UnsignedIntegerRangeConst, + _SignedIntegerRangeSetConst, + _UnsignedIntegerRangeSetConst, +) +from bt2.component_descriptor import ComponentDescriptor +from bt2.trace_collection_message_iterator import ( + ComponentSpec, + AutoSourceComponentSpec, + TraceCollectionMessageIterator, +) if (sys.version_info.major, sys.version_info.minor) != (3, 4): @@ -234,9 +247,10 @@ del sys def _init_and_register_exit(): - from bt2 import native_bt import atexit + from bt2 import native_bt + atexit.register(native_bt.bt2_exit_handler) native_bt.bt2_init_from_bt2() diff --git a/src/bindings/python/bt2/bt2/clock_class.py b/src/bindings/python/bt2/bt2/clock_class.py index 576fb7cb..c7527c77 100644 --- a/src/bindings/python/bt2/bt2/clock_class.py +++ b/src/bindings/python/bt2/bt2/clock_class.py @@ -2,11 +2,12 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object +import uuid as uuidp + from bt2 import utils as bt2_utils from bt2 import value as bt2_value -import uuid as uuidp +from bt2 import object as bt2_object +from bt2 import native_bt class ClockClassOffset: diff --git a/src/bindings/python/bt2/bt2/clock_snapshot.py b/src/bindings/python/bt2/bt2/clock_snapshot.py index 3118d996..82591463 100644 --- a/src/bindings/python/bt2/bt2/clock_snapshot.py +++ b/src/bindings/python/bt2/bt2/clock_snapshot.py @@ -2,13 +2,14 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils import numbers -from bt2 import clock_class as bt2_clock_class import functools +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import clock_class as bt2_clock_class + @functools.total_ordering class _ClockSnapshotConst(bt2_object._UniqueObject): diff --git a/src/bindings/python/bt2/bt2/component.py b/src/bindings/python/bt2/bt2/component.py index 7357eb7e..30f0849c 100644 --- a/src/bindings/python/bt2/bt2/component.py +++ b/src/bindings/python/bt2/bt2/component.py @@ -2,19 +2,20 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils -from bt2 import message_iterator as bt2_message_iterator +import sys import collections.abc + +from bt2 import port as bt2_port +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils from bt2 import value as bt2_value -from bt2 import trace_class as bt2_trace_class +from bt2 import object as bt2_object +from bt2 import native_bt from bt2 import clock_class as bt2_clock_class +from bt2 import trace_class as bt2_trace_class from bt2 import query_executor as bt2_query_executor -from bt2 import port as bt2_port -from bt2 import error as bt2_error +from bt2 import message_iterator as bt2_message_iterator from bt2 import integer_range_set as bt2_integer_range_set -import sys class _IncompleteUserClass(Exception): diff --git a/src/bindings/python/bt2/bt2/component_descriptor.py b/src/bindings/python/bt2/bt2/component_descriptor.py index 4decafec..35179ab7 100644 --- a/src/bindings/python/bt2/bt2/component_descriptor.py +++ b/src/bindings/python/bt2/bt2/component_descriptor.py @@ -2,9 +2,9 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import component as bt2_component from bt2 import value as bt2_value +from bt2 import component as bt2_component +from bt2 import native_bt def _is_source_comp_cls(comp_cls): diff --git a/src/bindings/python/bt2/bt2/connection.py b/src/bindings/python/bt2/bt2/connection.py index 71066ac6..cdbe271e 100644 --- a/src/bindings/python/bt2/bt2/connection.py +++ b/src/bindings/python/bt2/bt2/connection.py @@ -2,9 +2,9 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt from bt2 import port as bt2_port from bt2 import object as bt2_object +from bt2 import native_bt class _ConnectionConst(bt2_object._SharedObject): diff --git a/src/bindings/python/bt2/bt2/error.py b/src/bindings/python/bt2/bt2/error.py index 40f281d9..b6d0e9e1 100644 --- a/src/bindings/python/bt2/bt2/error.py +++ b/src/bindings/python/bt2/bt2/error.py @@ -2,9 +2,10 @@ # # Copyright (c) 2019 Simon Marchi -from bt2 import native_bt from collections import abc +from bt2 import native_bt + class ComponentClassType: SOURCE = native_bt.COMPONENT_CLASS_TYPE_SOURCE diff --git a/src/bindings/python/bt2/bt2/event.py b/src/bindings/python/bt2/bt2/event.py index baec2aa5..3ff934fd 100644 --- a/src/bindings/python/bt2/bt2/event.py +++ b/src/bindings/python/bt2/bt2/event.py @@ -2,14 +2,15 @@ # # Copyright (c) 2016-2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object +import collections.abc + +from bt2 import field as bt2_field from bt2 import utils as bt2_utils -from bt2 import event_class as bt2_event_class +from bt2 import object as bt2_object from bt2 import packet as bt2_packet from bt2 import stream as bt2_stream -from bt2 import field as bt2_field -import collections.abc +from bt2 import native_bt +from bt2 import event_class as bt2_event_class class _EventConst(bt2_object._UniqueObject, collections.abc.Mapping): diff --git a/src/bindings/python/bt2/bt2/event_class.py b/src/bindings/python/bt2/bt2/event_class.py index b36ab54c..54ca10a6 100644 --- a/src/bindings/python/bt2/bt2/event_class.py +++ b/src/bindings/python/bt2/bt2/event_class.py @@ -2,11 +2,11 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object from bt2 import utils as bt2_utils -from bt2 import field_class as bt2_field_class from bt2 import value as bt2_value +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import field_class as bt2_field_class def _bt2_stream_class(): diff --git a/src/bindings/python/bt2/bt2/field.py b/src/bindings/python/bt2/bt2/field.py index b1f2f9d5..b3bdcd54 100644 --- a/src/bindings/python/bt2/bt2/field.py +++ b/src/bindings/python/bt2/bt2/field.py @@ -2,14 +2,15 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object +import math +import numbers +import functools +import collections.abc + from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import native_bt from bt2 import field_class as bt2_field_class -import collections.abc -import functools -import numbers -import math def _create_field_from_ptr_template( diff --git a/src/bindings/python/bt2/bt2/field_class.py b/src/bindings/python/bt2/bt2/field_class.py index ed2c44f5..8594b496 100644 --- a/src/bindings/python/bt2/bt2/field_class.py +++ b/src/bindings/python/bt2/bt2/field_class.py @@ -2,14 +2,15 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils import collections.abc -from bt2 import field_path as bt2_field_path -from bt2 import integer_range_set as bt2_integer_range_set + from bt2 import error as bt2_error +from bt2 import utils as bt2_utils from bt2 import value as bt2_value +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import field_path as bt2_field_path +from bt2 import integer_range_set as bt2_integer_range_set def _obj_type_from_field_class_ptr_template(type_map, ptr): diff --git a/src/bindings/python/bt2/bt2/field_path.py b/src/bindings/python/bt2/bt2/field_path.py index d16f0f36..d64d2286 100644 --- a/src/bindings/python/bt2/bt2/field_path.py +++ b/src/bindings/python/bt2/bt2/field_path.py @@ -3,8 +3,9 @@ # Copyright (c) 2018 Francis Deslauriers import collections -from bt2 import native_bt + from bt2 import object as bt2_object +from bt2 import native_bt class FieldPathScope: diff --git a/src/bindings/python/bt2/bt2/graph.py b/src/bindings/python/bt2/bt2/graph.py index 9ec3cc1f..6bd4e1e7 100644 --- a/src/bindings/python/bt2/bt2/graph.py +++ b/src/bindings/python/bt2/bt2/graph.py @@ -2,18 +2,19 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils -from bt2 import interrupter as bt2_interrupter -from bt2 import connection as bt2_connection -from bt2 import component as bt2_component import functools -from bt2 import port as bt2_port -from bt2 import logging as bt2_logging + from bt2 import mip as bt2_mip +from bt2 import port as bt2_port from bt2 import error as bt2_error +from bt2 import utils as bt2_utils from bt2 import value as bt2_value +from bt2 import object as bt2_object +from bt2 import logging as bt2_logging +from bt2 import component as bt2_component +from bt2 import native_bt +from bt2 import connection as bt2_connection +from bt2 import interrupter as bt2_interrupter def _graph_port_added_listener_from_native( diff --git a/src/bindings/python/bt2/bt2/integer_range_set.py b/src/bindings/python/bt2/bt2/integer_range_set.py index 7857f8b8..86bfd467 100644 --- a/src/bindings/python/bt2/bt2/integer_range_set.py +++ b/src/bindings/python/bt2/bt2/integer_range_set.py @@ -2,12 +2,13 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils -from bt2 import error as bt2_error import collections.abc +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import native_bt + class _IntegerRangeConst: def __init__(self, lower, upper=None): diff --git a/src/bindings/python/bt2/bt2/interrupter.py b/src/bindings/python/bt2/bt2/interrupter.py index b926b45e..cd7ef806 100644 --- a/src/bindings/python/bt2/bt2/interrupter.py +++ b/src/bindings/python/bt2/bt2/interrupter.py @@ -2,9 +2,9 @@ # # Copyright (c) 2019 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object from bt2 import error as bt2_error +from bt2 import object as bt2_object +from bt2 import native_bt class Interrupter(bt2_object._SharedObject): diff --git a/src/bindings/python/bt2/bt2/message.py b/src/bindings/python/bt2/bt2/message.py index 9947dffb..c56f6961 100644 --- a/src/bindings/python/bt2/bt2/message.py +++ b/src/bindings/python/bt2/bt2/message.py @@ -2,13 +2,13 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object +from bt2 import event as bt2_event from bt2 import utils as bt2_utils -from bt2 import clock_snapshot as bt2_clock_snapshot +from bt2 import object as bt2_object from bt2 import packet as bt2_packet from bt2 import stream as bt2_stream -from bt2 import event as bt2_event +from bt2 import native_bt +from bt2 import clock_snapshot as bt2_clock_snapshot def _create_from_ptr(ptr): diff --git a/src/bindings/python/bt2/bt2/message_iterator.py b/src/bindings/python/bt2/bt2/message_iterator.py index ce755e5c..b6887dc0 100644 --- a/src/bindings/python/bt2/bt2/message_iterator.py +++ b/src/bindings/python/bt2/bt2/message_iterator.py @@ -2,17 +2,18 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils -from bt2 import message as bt2_message import collections.abc -from bt2 import stream as bt2_stream -from bt2 import event_class as bt2_event_class -from bt2 import packet as bt2_packet + from bt2 import port as bt2_port -from bt2 import clock_class as bt2_clock_class from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import packet as bt2_packet +from bt2 import stream as bt2_stream +from bt2 import message as bt2_message +from bt2 import native_bt +from bt2 import clock_class as bt2_clock_class +from bt2 import event_class as bt2_event_class class _MessageIterator(collections.abc.Iterator): diff --git a/src/bindings/python/bt2/bt2/mip.py b/src/bindings/python/bt2/bt2/mip.py index 0cc1f82d..21cb0c61 100644 --- a/src/bindings/python/bt2/bt2/mip.py +++ b/src/bindings/python/bt2/bt2/mip.py @@ -2,10 +2,10 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import utils as bt2_utils from bt2 import error as bt2_error +from bt2 import utils as bt2_utils from bt2 import logging as bt2_logging +from bt2 import native_bt from bt2 import component_descriptor as bt2_component_descriptor diff --git a/src/bindings/python/bt2/bt2/packet.py b/src/bindings/python/bt2/bt2/packet.py index 9802d658..0e7605f1 100644 --- a/src/bindings/python/bt2/bt2/packet.py +++ b/src/bindings/python/bt2/bt2/packet.py @@ -2,9 +2,9 @@ # # Copyright (c) 2016-2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object from bt2 import field as bt2_field +from bt2 import object as bt2_object +from bt2 import native_bt def _bt2_stream(): diff --git a/src/bindings/python/bt2/bt2/plugin.py b/src/bindings/python/bt2/bt2/plugin.py index 1a3a6de5..0c990667 100644 --- a/src/bindings/python/bt2/bt2/plugin.py +++ b/src/bindings/python/bt2/bt2/plugin.py @@ -2,12 +2,13 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils +import os.path import collections.abc + +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object from bt2 import component as bt2_component -import os.path +from bt2 import native_bt def find_plugins_in_path(path, recurse=True, fail_on_load_error=False): diff --git a/src/bindings/python/bt2/bt2/port.py b/src/bindings/python/bt2/bt2/port.py index 034e58d1..b9a5529a 100644 --- a/src/bindings/python/bt2/bt2/port.py +++ b/src/bindings/python/bt2/bt2/port.py @@ -2,8 +2,8 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt from bt2 import object as bt2_object +from bt2 import native_bt def _bt2_connection(): diff --git a/src/bindings/python/bt2/bt2/py_plugin.py b/src/bindings/python/bt2/bt2/py_plugin.py index 863ae7f0..5702a2fe 100644 --- a/src/bindings/python/bt2/bt2/py_plugin.py +++ b/src/bindings/python/bt2/bt2/py_plugin.py @@ -2,10 +2,10 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import utils as bt2_utils -from bt2 import component as bt2_component import sys +from bt2 import utils as bt2_utils +from bt2 import component as bt2_component # Python plugin path to `_PluginInfo` (cache) _plugin_infos = {} @@ -91,9 +91,9 @@ def _try_load_plugin_module(path): # do not load module and create plugin info twice for this path return _plugin_infos[path] - import importlib.machinery - import inspect import hashlib + import inspect + import importlib.machinery if path is None: raise TypeError("missing path") diff --git a/src/bindings/python/bt2/bt2/query_executor.py b/src/bindings/python/bt2/bt2/query_executor.py index a4927f0c..de6f4441 100644 --- a/src/bindings/python/bt2/bt2/query_executor.py +++ b/src/bindings/python/bt2/bt2/query_executor.py @@ -2,12 +2,12 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object +from bt2 import error as bt2_error from bt2 import utils as bt2_utils -from bt2 import interrupter as bt2_interrupter from bt2 import value as bt2_value -from bt2 import error as bt2_error +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import interrupter as bt2_interrupter def _bt2_component(): diff --git a/src/bindings/python/bt2/bt2/stream.py b/src/bindings/python/bt2/bt2/stream.py index 3f4cedef..9d8d1ae9 100644 --- a/src/bindings/python/bt2/bt2/stream.py +++ b/src/bindings/python/bt2/bt2/stream.py @@ -2,13 +2,13 @@ # # Copyright (c) 2016-2017 Philippe Proulx -from bt2 import native_bt +from bt2 import error as bt2_error from bt2 import utils as bt2_utils +from bt2 import value as bt2_value from bt2 import object as bt2_object from bt2 import packet as bt2_packet +from bt2 import native_bt from bt2 import stream_class as bt2_stream_class -from bt2 import value as bt2_value -from bt2 import error as bt2_error def _bt2_trace(): diff --git a/src/bindings/python/bt2/bt2/stream_class.py b/src/bindings/python/bt2/bt2/stream_class.py index e73b40e9..5c6faa07 100644 --- a/src/bindings/python/bt2/bt2/stream_class.py +++ b/src/bindings/python/bt2/bt2/stream_class.py @@ -2,14 +2,15 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object +import collections.abc + from bt2 import utils as bt2_utils -from bt2 import field_class as bt2_field_class -from bt2 import event_class as bt2_event_class -from bt2 import clock_class as bt2_clock_class from bt2 import value as bt2_value -import collections.abc +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import clock_class as bt2_clock_class +from bt2 import event_class as bt2_event_class +from bt2 import field_class as bt2_field_class def _bt2_trace_class(): diff --git a/src/bindings/python/bt2/bt2/trace.py b/src/bindings/python/bt2/bt2/trace.py index 32e730e3..a7038b28 100644 --- a/src/bindings/python/bt2/bt2/trace.py +++ b/src/bindings/python/bt2/bt2/trace.py @@ -2,17 +2,17 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils +import uuid as uuidp +import functools import collections.abc + +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils from bt2 import value as bt2_value +from bt2 import object as bt2_object from bt2 import stream as bt2_stream +from bt2 import native_bt from bt2 import stream_class as bt2_stream_class -from bt2 import error as bt2_error - -import functools -import uuid as uuidp def _bt2_trace_class(): diff --git a/src/bindings/python/bt2/bt2/trace_class.py b/src/bindings/python/bt2/bt2/trace_class.py index f6efe71c..41863940 100644 --- a/src/bindings/python/bt2/bt2/trace_class.py +++ b/src/bindings/python/bt2/bt2/trace_class.py @@ -4,17 +4,18 @@ # Copyright (c) 2018 Francis Deslauriers # Copyright (c) 2019 Simon Marchi -from bt2 import native_bt +import functools +import collections.abc + +from bt2 import error as bt2_error +from bt2 import trace as bt2_trace from bt2 import utils as bt2_utils +from bt2 import value as bt2_value from bt2 import object as bt2_object -from bt2 import stream_class as bt2_stream_class +from bt2 import native_bt from bt2 import field_class as bt2_field_class +from bt2 import stream_class as bt2_stream_class from bt2 import integer_range_set as bt2_integer_range_set -from bt2 import trace as bt2_trace -from bt2 import error as bt2_error -from bt2 import value as bt2_value -import collections.abc -import functools def _trace_class_destruction_listener_from_native( diff --git a/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py b/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py index 3c50cd17..3a6b9521 100644 --- a/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py +++ b/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py @@ -2,24 +2,24 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import utils as bt2_utils -from bt2 import logging as bt2_logging +import numbers +import datetime import itertools -from bt2 import message_iterator as bt2_message_iterator +from collections import namedtuple + +from bt2 import mip as bt2_mip from bt2 import port as bt2_port -from bt2 import component as bt2_component +from bt2 import error as bt2_error +from bt2 import graph as bt2_graph +from bt2 import utils as bt2_utils from bt2 import value as bt2_value from bt2 import plugin as bt2_plugin -from bt2 import error as bt2_error +from bt2 import logging as bt2_logging +from bt2 import component as bt2_component +from bt2 import native_bt from bt2 import query_executor as bt2_query_executor +from bt2 import message_iterator as bt2_message_iterator from bt2 import component_descriptor as bt2_component_descriptor -from bt2 import mip as bt2_mip -from bt2 import graph as bt2_graph -import datetime -from collections import namedtuple -import numbers - # a pair of component and ComponentSpec _ComponentAndSpec = namedtuple("_ComponentAndSpec", ["comp", "spec"]) diff --git a/src/bindings/python/bt2/bt2/utils.py b/src/bindings/python/bt2/bt2/utils.py index 6ce992af..c8fb5171 100644 --- a/src/bindings/python/bt2/bt2/utils.py +++ b/src/bindings/python/bt2/bt2/utils.py @@ -3,9 +3,9 @@ # Copyright (c) 2017 Philippe Proulx +from bt2 import error as bt2_error from bt2 import logging as bt2_logging from bt2 import native_bt -from bt2 import error as bt2_error class UnknownObject(Exception): diff --git a/src/bindings/python/bt2/bt2/value.py b/src/bindings/python/bt2/bt2/value.py index d2cb4e07..c938ff90 100644 --- a/src/bindings/python/bt2/bt2/value.py +++ b/src/bindings/python/bt2/bt2/value.py @@ -2,15 +2,16 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt -from bt2 import object as bt2_object -from bt2 import utils as bt2_utils -from bt2 import error as bt2_error -import collections.abc -import functools -import numbers -import math import abc +import math +import numbers +import functools +import collections.abc + +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import native_bt def _create_from_ptr_template(ptr, object_map): diff --git a/tests/bindings/python/bt2/test_clock_class.py b/tests/bindings/python/bt2/test_clock_class.py index 9707052f..843333c8 100644 --- a/tests/bindings/python/bt2/test_clock_class.py +++ b/tests/bindings/python/bt2/test_clock_class.py @@ -3,13 +3,14 @@ # Copyright (C) 2019 EfficiOS Inc. # -import unittest import uuid +import unittest + import bt2 import utils -from utils import run_in_component_init, TestOutputPortMessageIterator from bt2 import value as bt2_value from bt2 import clock_class as bt2_clock_class +from utils import TestOutputPortMessageIterator, run_in_component_init class ClockClassOffsetTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_component.py b/tests/bindings/python/bt2/test_component.py index 71808fa5..b99d632a 100644 --- a/tests/bindings/python/bt2/test_component.py +++ b/tests/bindings/python/bt2/test_component.py @@ -4,6 +4,7 @@ # import unittest + import bt2 from bt2 import component as bt2_component diff --git a/tests/bindings/python/bt2/test_component_class.py b/tests/bindings/python/bt2/test_component_class.py index d944c909..a405c005 100644 --- a/tests/bindings/python/bt2/test_component_class.py +++ b/tests/bindings/python/bt2/test_component_class.py @@ -4,6 +4,7 @@ # import unittest + import bt2 diff --git a/tests/bindings/python/bt2/test_component_descriptor.py b/tests/bindings/python/bt2/test_component_descriptor.py index 818b245e..dcad514e 100644 --- a/tests/bindings/python/bt2/test_component_descriptor.py +++ b/tests/bindings/python/bt2/test_component_descriptor.py @@ -4,6 +4,7 @@ # import unittest + import bt2 diff --git a/tests/bindings/python/bt2/test_connection.py b/tests/bindings/python/bt2/test_connection.py index 7ec6bb01..4664ffce 100644 --- a/tests/bindings/python/bt2/test_connection.py +++ b/tests/bindings/python/bt2/test_connection.py @@ -4,9 +4,10 @@ # import unittest + import bt2 -from bt2 import connection as bt2_connection from bt2 import port as bt2_port +from bt2 import connection as bt2_connection class ConnectionTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_error.py b/tests/bindings/python/bt2/test_error.py index b4b90ad5..95d20ebc 100644 --- a/tests/bindings/python/bt2/test_error.py +++ b/tests/bindings/python/bt2/test_error.py @@ -3,10 +3,11 @@ # Copyright (C) 2019 EfficiOS Inc. # -from bt2 import native_bt -import bt2 import unittest +import bt2 +from bt2 import native_bt + class FailingIter(bt2._UserMessageIterator): def __next__(self): diff --git a/tests/bindings/python/bt2/test_event.py b/tests/bindings/python/bt2/test_event.py index 970b7c22..72490603 100644 --- a/tests/bindings/python/bt2/test_event.py +++ b/tests/bindings/python/bt2/test_event.py @@ -4,14 +4,14 @@ # import unittest + import bt2 import utils -from utils import TestOutputPortMessageIterator - from bt2 import field as bt2_field from bt2 import stream as bt2_stream from bt2 import event_class as bt2_event_class from bt2 import clock_snapshot as bt2_clock_snapshot +from utils import TestOutputPortMessageIterator class EventTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_event_class.py b/tests/bindings/python/bt2/test_event_class.py index 0e97c09e..295d8fb8 100644 --- a/tests/bindings/python/bt2/test_event_class.py +++ b/tests/bindings/python/bt2/test_event_class.py @@ -4,13 +4,13 @@ # import unittest + import bt2 -from utils import get_default_trace_class -from bt2 import stream_class as bt2_stream_class +from bt2 import value as bt2_value from bt2 import event_class as bt2_event_class from bt2 import field_class as bt2_field_class -from bt2 import value as bt2_value -from utils import TestOutputPortMessageIterator +from bt2 import stream_class as bt2_stream_class +from utils import TestOutputPortMessageIterator, get_default_trace_class def _create_const_event_class(tc, stream_class): diff --git a/tests/bindings/python/bt2/test_field.py b/tests/bindings/python/bt2/test_field.py index e7517941..e72c0ef0 100644 --- a/tests/bindings/python/bt2/test_field.py +++ b/tests/bindings/python/bt2/test_field.py @@ -3,16 +3,16 @@ # Copyright (C) 2019 EfficiOS Inc. # -from functools import partial, partialmethod +import copy +import math import operator import unittest -import math -import copy import itertools import collections -import bt2 -from utils import get_default_trace_class, create_const_field +from functools import partial, partialmethod +import bt2 +from utils import create_const_field, get_default_trace_class _COMP_BINOPS = (operator.eq, operator.ne) diff --git a/tests/bindings/python/bt2/test_field_class.py b/tests/bindings/python/bt2/test_field_class.py index d12e3987..cb011a6e 100644 --- a/tests/bindings/python/bt2/test_field_class.py +++ b/tests/bindings/python/bt2/test_field_class.py @@ -4,10 +4,11 @@ # import unittest + import bt2 -from utils import get_default_trace_class, TestOutputPortMessageIterator from bt2 import value as bt2_value from bt2 import field_class as bt2_field_class +from utils import TestOutputPortMessageIterator, get_default_trace_class def _create_stream(tc, ctx_field_classes): diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py index acf283ce..579572ed 100644 --- a/tests/bindings/python/bt2/test_graph.py +++ b/tests/bindings/python/bt2/test_graph.py @@ -4,6 +4,7 @@ # import unittest + import bt2 diff --git a/tests/bindings/python/bt2/test_integer_range_set.py b/tests/bindings/python/bt2/test_integer_range_set.py index 808a4045..d15dbaf2 100644 --- a/tests/bindings/python/bt2/test_integer_range_set.py +++ b/tests/bindings/python/bt2/test_integer_range_set.py @@ -3,10 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # -import bt2 import unittest -from utils import get_default_trace_class, create_const_field +import bt2 +from utils import create_const_field, get_default_trace_class def get_const_signed_integer_range(int_ranges): diff --git a/tests/bindings/python/bt2/test_interrupter.py b/tests/bindings/python/bt2/test_interrupter.py index 636c03e4..c7f44350 100644 --- a/tests/bindings/python/bt2/test_interrupter.py +++ b/tests/bindings/python/bt2/test_interrupter.py @@ -3,9 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # -import bt2 import unittest +import bt2 + class InterrupterTestCase(unittest.TestCase): def setUp(self): diff --git a/tests/bindings/python/bt2/test_message.py b/tests/bindings/python/bt2/test_message.py index 11d12a02..fbd5b5b9 100644 --- a/tests/bindings/python/bt2/test_message.py +++ b/tests/bindings/python/bt2/test_message.py @@ -4,18 +4,19 @@ # import unittest + import bt2 import utils -from utils import TestOutputPortMessageIterator -from bt2 import clock_snapshot as bt2_clock_snapshot from bt2 import event as bt2_event -from bt2 import event_class as bt2_event_class from bt2 import field as bt2_field +from bt2 import trace as bt2_trace from bt2 import packet as bt2_packet from bt2 import stream as bt2_stream -from bt2 import stream_class as bt2_stream_class -from bt2 import trace as bt2_trace +from bt2 import event_class as bt2_event_class from bt2 import trace_class as bt2_trace_class +from bt2 import stream_class as bt2_stream_class +from bt2 import clock_snapshot as bt2_clock_snapshot +from utils import TestOutputPortMessageIterator class AllMessagesTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_message_iterator.py b/tests/bindings/python/bt2/test_message_iterator.py index 71f63639..ee3a3bb8 100644 --- a/tests/bindings/python/bt2/test_message_iterator.py +++ b/tests/bindings/python/bt2/test_message_iterator.py @@ -3,12 +3,13 @@ # Copyright (C) 2019 EfficiOS Inc. # +import sys import unittest + import bt2 -import sys -from utils import TestOutputPortMessageIterator from bt2 import port as bt2_port from bt2 import message_iterator as bt2_message_iterator +from utils import TestOutputPortMessageIterator class SimpleSink(bt2._UserSinkComponent): diff --git a/tests/bindings/python/bt2/test_mip.py b/tests/bindings/python/bt2/test_mip.py index a73054fa..873da22a 100644 --- a/tests/bindings/python/bt2/test_mip.py +++ b/tests/bindings/python/bt2/test_mip.py @@ -4,6 +4,7 @@ # import unittest + import bt2 diff --git a/tests/bindings/python/bt2/test_package.py b/tests/bindings/python/bt2/test_package.py index f13f8eb0..6fd8425a 100644 --- a/tests/bindings/python/bt2/test_package.py +++ b/tests/bindings/python/bt2/test_package.py @@ -3,9 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # -import bt2 import unittest +import bt2 + class PackageTestCase(unittest.TestCase): def _assert_in_bt2(self, name): diff --git a/tests/bindings/python/bt2/test_packet.py b/tests/bindings/python/bt2/test_packet.py index 5448c03c..77effada 100644 --- a/tests/bindings/python/bt2/test_packet.py +++ b/tests/bindings/python/bt2/test_packet.py @@ -4,10 +4,11 @@ # import unittest + import utils -from utils import run_in_component_init -from bt2 import stream as bt2_stream from bt2 import field as bt2_field +from bt2 import stream as bt2_stream +from utils import run_in_component_init class PacketTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_plugin.py b/tests/bindings/python/bt2/test_plugin.py index 7c766c69..d6f4c4a0 100644 --- a/tests/bindings/python/bt2/test_plugin.py +++ b/tests/bindings/python/bt2/test_plugin.py @@ -3,10 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # -import unittest -import bt2 import os +import unittest +import bt2 _TEST_PLUGIN_PLUGINS_PATH = os.environ["BT_PLUGINS_PATH"] _TEST_PLUGIN_PLUGIN_EXTENSION_BY_OS = {"cygwin": "dll", "mingw": "dll"} diff --git a/tests/bindings/python/bt2/test_port.py b/tests/bindings/python/bt2/test_port.py index 17945cb0..3a446145 100644 --- a/tests/bindings/python/bt2/test_port.py +++ b/tests/bindings/python/bt2/test_port.py @@ -4,6 +4,7 @@ # import unittest + import bt2 from bt2 import port as bt2_port diff --git a/tests/bindings/python/bt2/test_query_executor.py b/tests/bindings/python/bt2/test_query_executor.py index 0b7296a4..466ebb5f 100644 --- a/tests/bindings/python/bt2/test_query_executor.py +++ b/tests/bindings/python/bt2/test_query_executor.py @@ -3,9 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # +import re import unittest + import bt2 -import re class QueryExecutorTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_stream.py b/tests/bindings/python/bt2/test_stream.py index 25dc5600..bae158b1 100644 --- a/tests/bindings/python/bt2/test_stream.py +++ b/tests/bindings/python/bt2/test_stream.py @@ -4,12 +4,13 @@ # import unittest + import utils -from utils import run_in_component_init from bt2 import trace as bt2_trace -from bt2 import stream as bt2_stream from bt2 import value as bt2_value +from bt2 import stream as bt2_stream from bt2 import stream_class as bt2_stream_class +from utils import run_in_component_init class StreamTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_stream_class.py b/tests/bindings/python/bt2/test_stream_class.py index 09e6e5e0..3668fe86 100644 --- a/tests/bindings/python/bt2/test_stream_class.py +++ b/tests/bindings/python/bt2/test_stream_class.py @@ -4,12 +4,13 @@ # import unittest -from utils import run_in_component_init -from bt2 import stream_class as bt2_stream_class -from bt2 import trace_class as bt2_trace_class + from bt2 import clock_class as bt2_clock_class from bt2 import event_class as bt2_event_class from bt2 import field_class as bt2_field_class +from bt2 import trace_class as bt2_trace_class +from bt2 import stream_class as bt2_stream_class +from utils import run_in_component_init class StreamClassTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_trace.py b/tests/bindings/python/bt2/test_trace.py index ad0ef39e..e7aa18be 100644 --- a/tests/bindings/python/bt2/test_trace.py +++ b/tests/bindings/python/bt2/test_trace.py @@ -5,13 +5,14 @@ import uuid import unittest + import utils -from utils import get_default_trace_class -from bt2 import trace_class as bt2_trace_class -from bt2 import value as bt2_value from bt2 import trace as bt2_trace -from bt2 import stream as bt2_stream from bt2 import utils as bt2_utils +from bt2 import value as bt2_value +from bt2 import stream as bt2_stream +from bt2 import trace_class as bt2_trace_class +from utils import get_default_trace_class class TraceTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_trace_class.py b/tests/bindings/python/bt2/test_trace_class.py index f9a21a0f..4b861a0d 100644 --- a/tests/bindings/python/bt2/test_trace_class.py +++ b/tests/bindings/python/bt2/test_trace_class.py @@ -4,14 +4,15 @@ # import unittest + +from bt2 import utils as bt2_utils +from bt2 import trace_class as bt2_trace_class +from bt2 import stream_class as bt2_stream_class from utils import ( run_in_component_init, get_default_trace_class, get_const_stream_beginning_message, ) -from bt2 import stream_class as bt2_stream_class -from bt2 import trace_class as bt2_trace_class -from bt2 import utils as bt2_utils class TraceClassTestCase(unittest.TestCase): diff --git a/tests/bindings/python/bt2/test_trace_collection_message_iterator.py b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py index 954b149c..84b19cf9 100644 --- a/tests/bindings/python/bt2/test_trace_collection_message_iterator.py +++ b/tests/bindings/python/bt2/test_trace_collection_message_iterator.py @@ -3,12 +3,12 @@ # Copyright (C) 2019 EfficiOS Inc. # -import unittest -import datetime -import bt2 import os import os.path +import datetime +import unittest +import bt2 _BT_TESTS_DATADIR = os.environ["BT_TESTS_DATADIR"] _BT_CTF_TRACES_PATH = os.environ["BT_CTF_TRACES_PATH"] diff --git a/tests/bindings/python/bt2/test_value.py b/tests/bindings/python/bt2/test_value.py index 62b09888..4a9c0a50 100644 --- a/tests/bindings/python/bt2/test_value.py +++ b/tests/bindings/python/bt2/test_value.py @@ -3,12 +3,13 @@ # Copyright (C) 2019 EfficiOS Inc. # -from functools import partial, partialmethod +import copy +import math import operator -import collections import unittest -import math -import copy +import collections +from functools import partial, partialmethod + import bt2 diff --git a/tests/bindings/python/bt2/utils.py b/tests/bindings/python/bt2/utils.py index c59fd8d5..3a5fcb05 100644 --- a/tests/bindings/python/bt2/utils.py +++ b/tests/bindings/python/bt2/utils.py @@ -3,9 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # -import bt2 import collections.abc +import bt2 + # Run callable `func` in the context of a component's __init__ method. The # callable is passed the Component being instantiated. diff --git a/tests/data/auto-source-discovery/grouping/bt_plugin_test.py b/tests/data/auto-source-discovery/grouping/bt_plugin_test.py index 208f5381..2bf0843b 100644 --- a/tests/data/auto-source-discovery/grouping/bt_plugin_test.py +++ b/tests/data/auto-source-discovery/grouping/bt_plugin_test.py @@ -3,9 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # -import bt2 import os +import bt2 + # Source component classes in this file recognize and group inputs in # various ways. One stream is created by each component, with a name # derived from the component class and the inputs. This is then checked diff --git a/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py b/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py index 36315a4a..ddb6508a 100644 --- a/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py +++ b/tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py @@ -3,9 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # -import bt2 import os +import bt2 + # This file defines source component classes to help verify the parameters an # log levels passed to components. Each component creates one stream, with a # name derived from either: diff --git a/tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py b/tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py index d651e251..327d052b 100644 --- a/tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py +++ b/tests/data/cli/exit_status/bt_plugin_test_cli_exit_status.py @@ -3,10 +3,11 @@ # Copyright (C) 2019 EfficiOS Inc. # -import bt2 -import signal import os import time +import signal + +import bt2 bt2.register_plugin(__name__, "test_exit_status") diff --git a/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py b/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py index cc9bc53b..efbdb8e3 100644 --- a/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py +++ b/tests/data/plugins/flt.lttng-utils.debug-info/bt_plugin_test_debug_info.py @@ -3,9 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # -import bt2 import math +import bt2 + bt2.register_plugin(__name__, "test_debug_info") diff --git a/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py b/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py index 4e4a9b6d..cd659f49 100644 --- a/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py +++ b/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py @@ -3,17 +3,17 @@ # Copyright (C) 2019 Philippe Proulx # -import argparse -import collections.abc -import logging import os -import os.path import re +import sys +import json import socket import struct -import sys +import logging +import os.path +import argparse import tempfile -import json +import collections.abc from collections import namedtuple diff --git a/tests/lib/conds/test.py b/tests/lib/conds/test.py index d8e5fe2e..48ad2281 100644 --- a/tests/lib/conds/test.py +++ b/tests/lib/conds/test.py @@ -2,15 +2,14 @@ # # Copyright (c) 2020 Philippe Proulx -import unittest -import subprocess -import functools -import signal import os -import os.path import re import json - +import signal +import os.path +import unittest +import functools +import subprocess # the `conds-triggers` program's full path _CONDS_TRIGGERS_PATH = os.environ["BT_TESTS_LIB_CONDS_TRIGGER_BIN"] diff --git a/tests/plugins/sink.text.pretty/test_pretty.py b/tests/plugins/sink.text.pretty/test_pretty.py index 0e0cd218..f04a04dc 100644 --- a/tests/plugins/sink.text.pretty/test_pretty.py +++ b/tests/plugins/sink.text.pretty/test_pretty.py @@ -3,6 +3,7 @@ # Copyright (C) 2020 EfficiOS, Inc. import unittest + import bt2 diff --git a/tests/plugins/src.ctf.fs/query/test_query_support_info.py b/tests/plugins/src.ctf.fs/query/test_query_support_info.py index 527a5dae..683312f5 100644 --- a/tests/plugins/src.ctf.fs/query/test_query_support_info.py +++ b/tests/plugins/src.ctf.fs/query/test_query_support_info.py @@ -3,10 +3,10 @@ # Copyright (C) 2019 Simon Marchi # -import unittest -import bt2 import os +import unittest +import bt2 session_rotation_trace_path = os.path.join( os.environ["BT_CTF_TRACES_PATH"], "succeed", "session-rotation" diff --git a/tests/plugins/src.ctf.fs/query/test_query_trace_info.py b/tests/plugins/src.ctf.fs/query/test_query_trace_info.py index ee906356..18a17120 100644 --- a/tests/plugins/src.ctf.fs/query/test_query_trace_info.py +++ b/tests/plugins/src.ctf.fs/query/test_query_trace_info.py @@ -3,11 +3,11 @@ # Copyright (C) 2019 Simon Marchi # -import unittest -import bt2 import os import re +import unittest +import bt2 test_ctf_traces_path = os.environ["BT_CTF_TRACES_PATH"] diff --git a/tests/python-plugin-provider/test_python_plugin_provider.py b/tests/python-plugin-provider/test_python_plugin_provider.py index c48d2dc9..7f9f46d9 100644 --- a/tests/python-plugin-provider/test_python_plugin_provider.py +++ b/tests/python-plugin-provider/test_python_plugin_provider.py @@ -3,9 +3,10 @@ # Copyright (C) 2019 EfficiOS Inc. # +import os import unittest + import bt2 -import os class PythonPluginProviderTestCase(unittest.TestCase): diff --git a/tests/utils/python/split_sort_compare.py b/tests/utils/python/split_sort_compare.py index c57e84e9..91c0d5d6 100644 --- a/tests/utils/python/split_sort_compare.py +++ b/tests/utils/python/split_sort_compare.py @@ -2,8 +2,8 @@ # # Copyright (C) 2020 Francis Deslauriers -import sys import re +import sys def main(): diff --git a/tests/utils/python/testrunner.py b/tests/utils/python/testrunner.py index a7cd8263..88b96ef8 100644 --- a/tests/utils/python/testrunner.py +++ b/tests/utils/python/testrunner.py @@ -3,11 +3,11 @@ # Copyright (c) 2016 Philippe Proulx # -from tap import TAPTestRunner -import unittest import sys import argparse +import unittest +from tap import TAPTestRunner if __name__ == "__main__": argparser = argparse.ArgumentParser()