From 8333cfb9712c9d83bf1abb42c7eefb06bbbc4720 Mon Sep 17 00:00:00 2001 From: Marko Durkovic Date: Wed, 27 Jul 2022 16:39:26 +0200 Subject: [PATCH] Update code for current linters --- src/rosbags/convert/__main__.py | 4 ++-- src/rosbags/typesys/idl.py | 2 -- src/rosbags/typesys/msg.py | 2 -- tests/test_serde.py | 2 +- tools/bench/bench.py | 8 ++++---- tools/compare/compare.py | 8 ++++---- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/rosbags/convert/__main__.py b/src/rosbags/convert/__main__.py index 5fe15bd8..dcd09ce2 100644 --- a/src/rosbags/convert/__main__.py +++ b/src/rosbags/convert/__main__.py @@ -60,13 +60,13 @@ def main() -> None: args = parser.parse_args() if args.dst is not None and (args.src.suffix == '.bag') == (args.dst.suffix == '.bag'): - print('Source and destination rosbag versions must differ.') # noqa: T001 + print('Source and destination rosbag versions must differ.') # noqa: T201 sys.exit(1) try: convert(**args.__dict__) except ConverterError as err: - print(f'ERROR: {err}') # noqa: T001 + print(f'ERROR: {err}') # noqa: T201 sys.exit(1) diff --git a/src/rosbags/typesys/idl.py b/src/rosbags/typesys/idl.py index 28cfcd85..84522269 100644 --- a/src/rosbags/typesys/idl.py +++ b/src/rosbags/typesys/idl.py @@ -254,8 +254,6 @@ string_literal class VisitorIDL(Visitor): # pylint: disable=too-many-public-methods """IDL file visitor.""" - # pylint: disable=no-self-use - RULES = parse_grammar(GRAMMAR_IDL) def __init__(self) -> None: diff --git a/src/rosbags/typesys/msg.py b/src/rosbags/typesys/msg.py index 3b9a110f..0ba942b4 100644 --- a/src/rosbags/typesys/msg.py +++ b/src/rosbags/typesys/msg.py @@ -205,8 +205,6 @@ def denormalize_msgtype(typename: str) -> str: class VisitorMSG(Visitor): """MSG file visitor.""" - # pylint: disable=no-self-use - RULES = parse_grammar(GRAMMAR_MSG) BASETYPES = { diff --git a/tests/test_serde.py b/tests/test_serde.py index 8142ac79..586e3573 100644 --- a/tests/test_serde.py +++ b/tests/test_serde.py @@ -254,7 +254,7 @@ def test_deserializer() -> None: assert msg.header.frame_id == 'foo42' field = msg.magnetic_field assert (field.x, field.y, field.z) == (128., 128., 128.) - diag = numpy.diag(msg.magnetic_field_covariance.reshape(3, 3)) # type: ignore + diag = numpy.diag(msg.magnetic_field_covariance.reshape(3, 3)) assert (diag == [1., 1., 1.]).all() msg_big = deserialize_cdr(*MSG_MAGN_BIG[:2]) diff --git a/tools/bench/bench.py b/tools/bench/bench.py index b8e70b17..8cc84606 100644 --- a/tools/bench/bench.py +++ b/tools/bench/bench.py @@ -133,16 +133,16 @@ def main() -> None: """Benchmark rosbag2 against rosbag2_py.""" path = Path(sys.argv[1]) try: - print('Comparing messages from rosbag2 and rosbag2_py.') # noqa: T001 + print('Comparing messages from rosbag2 and rosbag2_py.') # noqa: T201 compare(path) except AssertionError as err: - print(f'Comparison failed {err!r}') # noqa: T001 + print(f'Comparison failed {err!r}') # noqa: T201 sys.exit(1) - print('Measuring execution times of rosbag2 and rosbag2_py.') # noqa: T001 + print('Measuring execution times of rosbag2 and rosbag2_py.') # noqa: T201 time_py = timeit(lambda: read_deser_rosbag2_py(path), number=1) time = timeit(lambda: read_deser_rosbag2(path), number=1) - print( # noqa: T001 + print( # noqa: T201 f'Processing times:\n' f'rosbag2_py {time_py:.3f}\n' f'rosbag2 {time:.3f}\n' diff --git a/tools/compare/compare.py b/tools/compare/compare.py index f928737f..02fe5aea 100644 --- a/tools/compare/compare.py +++ b/tools/compare/compare.py @@ -67,7 +67,7 @@ def fixup_ros1(conns: List[rosbag.bag._Connection_Info]) -> None: genpy.Duration.nanosec = property(lambda x: x.nsecs) if conn := next((x for x in conns if x.datatype == 'sensor_msgs/CameraInfo'), None): - print('Patching CameraInfo') # noqa: T001 + print('Patching CameraInfo') # noqa: T201 cls = rosbag.bag._get_message_type(conn) # pylint: disable=protected-access cls.d = property(lambda x: x.D, lambda x, y: setattr(x, 'D', y)) # noqa: B010 cls.k = property(lambda x: x.K, lambda x, y: setattr(x, 'K', y)) # noqa: B010 @@ -135,7 +135,7 @@ def main_bag1_bag1(path1: Path, path2: Path) -> None: assert next(src1, None) is None assert next(src2, None) is None - print('Bags are identical.') # noqa: T001 + print('Bags are identical.') # noqa: T201 def main_bag1_bag2(path1: Path, path2: Path) -> None: @@ -160,12 +160,12 @@ def main_bag1_bag2(path1: Path, path2: Path) -> None: assert next(src1, None) is None assert next(src2, None) is None - print('Bags are identical.') # noqa: T001 + print('Bags are identical.') # noqa: T201 if __name__ == '__main__': if len(sys.argv) != 3: - print(f'Usage: {sys.argv} [rosbag1] [rosbag2]') # noqa: T001 + print(f'Usage: {sys.argv} [rosbag1] [rosbag2]') # noqa: T201 sys.exit(1) arg1 = Path(sys.argv[1]) arg2 = Path(sys.argv[2])