diff --git a/.pylintrc b/.pylintrc index 5c59a39f..dd23d4e7 100644 --- a/.pylintrc +++ b/.pylintrc @@ -139,7 +139,8 @@ disable=print-statement, deprecated-sys-function, exception-escape, comprehension-escape, - trailing-whitespace + trailing-whitespace, + similarities # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -521,7 +522,7 @@ valid-metaclass-classmethod-first-arg=cls [DESIGN] # Maximum number of arguments for function / method. -max-args=5 +max-args=8 # Maximum number of attributes for a class (see R0902). max-attributes=20 @@ -530,10 +531,10 @@ max-attributes=20 max-bool-expr=5 # Maximum number of branch for function / method body. -max-branches=20 +max-branches=30 # Maximum number of locals for function / method body. -max-locals=15 +max-locals=30 # Maximum number of parents for a class (see R0901). max-parents=7 @@ -542,7 +543,7 @@ max-parents=7 max-public-methods=100 # Maximum number of return / yield for function / method body. -max-returns=6 +max-returns=12 # Maximum number of statements in function / method body. max-statements=200 diff --git a/src/main/python/ttconv/filters/__init__.py b/src/main/python/ttconv/filters/__init__.py index 9437e59b..cb3bee33 100644 --- a/src/main/python/ttconv/filters/__init__.py +++ b/src/main/python/ttconv/filters/__init__.py @@ -33,4 +33,4 @@ class Filter: def process(self, isd: ISD): """Process the specified ISD and returns it.""" - pass + raise NotImplementedError diff --git a/src/main/python/ttconv/imsc/attributes.py b/src/main/python/ttconv/imsc/attributes.py index 537bea19..ab1bd77c 100644 --- a/src/main/python/ttconv/imsc/attributes.py +++ b/src/main/python/ttconv/imsc/attributes.py @@ -215,8 +215,13 @@ def extract(ttml_element) -> typing.Optional[model.ActiveAreaType]: @staticmethod def set(ttml_element, active_area): - ttml_element.set(ActiveAreaAttribute.qn, - f"{(active_area.left_offset * 100)}% {(active_area.top_offset * 100)}% {(active_area.width * 100)}% {active_area.height * 100}%") + ttml_element.set( + ActiveAreaAttribute.qn, + f"{active_area.left_offset * 100:g}% " + f"{active_area.top_offset * 100:g}% " + f"{active_area.width * 100:g}% " + f"{active_area.height * 100:g}%" + ) class TickRateAttribute: '''ttp:tickRate attribute diff --git a/src/main/python/ttconv/imsc/style_properties.py b/src/main/python/ttconv/imsc/style_properties.py index e617018c..d934e7ce 100644 --- a/src/main/python/ttconv/imsc/style_properties.py +++ b/src/main/python/ttconv/imsc/style_properties.py @@ -46,7 +46,7 @@ def model_prop(cls): @property @classmethod - def ns(cls): + def ns(cls): # pylint: disable=invalid-name raise NotImplementedError @property diff --git a/src/main/python/ttconv/imsc/writer.py b/src/main/python/ttconv/imsc/writer.py index 0fc03a8d..ee1b0e50 100644 --- a/src/main/python/ttconv/imsc/writer.py +++ b/src/main/python/ttconv/imsc/writer.py @@ -26,7 +26,6 @@ '''IMSC writer''' import logging -from fractions import Fraction import numbers import typing import xml.etree.ElementTree as et diff --git a/src/main/python/ttconv/isd.py b/src/main/python/ttconv/isd.py index 6b554f40..a2c67be1 100644 --- a/src/main/python/ttconv/isd.py +++ b/src/main/python/ttconv/isd.py @@ -342,7 +342,7 @@ def _process_element( parent_computed_end: typing.Optional[Fraction], element: model.ContentElement ) -> typing.Optional[model.ContentElement]: - + # pylint: disable=too-many-arguments,too-many-locals,too-many-branches # first check the activity cache and return immediate if the element is not active diff --git a/src/main/python/ttconv/tt.py b/src/main/python/ttconv/tt.py index d962aa23..cc4af07e 100644 --- a/src/main/python/ttconv/tt.py +++ b/src/main/python/ttconv/tt.py @@ -93,7 +93,7 @@ def progress_str(progress_type: ProgressConsoleHandler.ProgressType, percent_pro is_progress_bar_record = hasattr(record, 'progress_bar') percent_progress = None - if self.display_progress_bar == False and is_progress_bar_record: + if not self.display_progress_bar and is_progress_bar_record: return if is_progress_bar_record: diff --git a/src/test/python/test_imsc_writer.py b/src/test/python/test_imsc_writer.py index e45d7fd8..d2d2b991 100644 --- a/src/test/python/test_imsc_writer.py +++ b/src/test/python/test_imsc_writer.py @@ -43,7 +43,6 @@ import ttconv.imsc.attributes as attributes from ttconv.scc.utils import get_extent_from_dimensions import ttconv.imsc.config as imsc_config -import ttconv.imsc.namespaces as imsc_ns def _get_set_style(imsc_style_prop, model_value): e = et.Element("p") @@ -466,14 +465,14 @@ def test_style_property_base_has_px(self): False ) - def test_style_property_Disparity_has_px(self): + def test_style_property_disparity_has_px(self): prop = styles.LengthType(1, styles.LengthType.units.em) self.assertEqual(imsc_styles.StyleProperties.Disparity.has_px(prop), False) prop = styles.LengthType(1, styles.LengthType.units.px) self.assertEqual(imsc_styles.StyleProperties.Disparity.has_px(prop), True) - def test_style_property_Extent_has_px(self): + def test_style_property_extent_has_px(self): prop = styles.ExtentType(styles.LengthType(1, styles.LengthType.units.px), styles.LengthType(1, styles.LengthType.units.em)) self.assertEqual(imsc_styles.StyleProperties.Extent.has_px(prop), True) @@ -490,14 +489,14 @@ def test_style_property_Extent_has_px(self): styles.LengthType(1, styles.LengthType.units.em)) self.assertEqual(imsc_styles.StyleProperties.Extent.has_px(prop), False) - def test_style_property_FontSize_has_px(self): + def test_style_property_font_size_has_px(self): prop = styles.LengthType(1, styles.LengthType.units.em) self.assertEqual(imsc_styles.StyleProperties.FontSize.has_px(prop), False) prop = styles.LengthType(1, styles.LengthType.units.px) self.assertEqual(imsc_styles.StyleProperties.FontSize.has_px(prop), True) - def test_style_property_LineHeight_has_px(self): + def test_style_property_line_height_has_px(self): prop = styles.SpecialValues.normal self.assertEqual(imsc_styles.StyleProperties.LineHeight.has_px(prop), False) @@ -507,7 +506,7 @@ def test_style_property_LineHeight_has_px(self): prop = styles.LengthType(1, styles.LengthType.units.px) self.assertEqual(imsc_styles.StyleProperties.LineHeight.has_px(prop), True) - def test_style_property_Origin_has_px(self): + def test_style_property_origin_has_px(self): prop = styles.PositionType(styles.LengthType(1, styles.LengthType.units.px), styles.LengthType(1, styles.LengthType.units.em)) self.assertEqual(imsc_styles.StyleProperties.Origin.has_px(prop), True) @@ -524,7 +523,7 @@ def test_style_property_Origin_has_px(self): styles.LengthType(1, styles.LengthType.units.em)) self.assertEqual(imsc_styles.StyleProperties.Origin.has_px(prop), False) - def test_style_property_Padding_has_px(self): + def test_style_property_padding_has_px(self): prop = styles.PaddingType( before = styles.LengthType(10.1, styles.LengthType.units.px), end = styles.LengthType(20.2, styles.LengthType.units.em), @@ -565,7 +564,7 @@ def test_style_property_Padding_has_px(self): ) self.assertEqual(imsc_styles.StyleProperties.Padding.has_px(prop), False) - def test_style_property_RubyReserve_has_px(self): + def test_style_property_ruby_reserve_has_px(self): prop = styles.RubyReserveType( position=styles.RubyReserveType.Position.both, length=styles.LengthType(value=1.2, units=styles.LengthType.Units.px) @@ -579,7 +578,7 @@ def test_style_property_RubyReserve_has_px(self): self.assertEqual(imsc_styles.StyleProperties.RubyReserve.has_px(prop), False) - def test_style_property_TextOutline_has_px(self): + def test_style_property_text_outline_has_px(self): prop = styles.SpecialValues.none self.assertEqual(imsc_styles.StyleProperties.TextOutline.has_px(prop), False) @@ -595,7 +594,7 @@ def test_style_property_TextOutline_has_px(self): ) self.assertEqual(imsc_styles.StyleProperties.TextOutline.has_px(prop), True) - def test_style_property_TextShadow_has_px(self): + def test_style_property_text_shadow_has_px(self): prop = styles.TextShadowType( ( styles.TextShadowType.Shadow( @@ -698,7 +697,7 @@ def test_fps(self): config = imsc_config.IMSCWriterConfiguration(time_format=imsc_config.TimeExpressionEnum.frames, fps=Fraction(30, 1)) xml_from_model = imsc_writer.from_model(imsc_reader.to_model(ttml_doc), config) - body_element = xml_from_model.find("tt:body", {"tt": imsc_ns.TTML}) + body_element = xml_from_model.find("tt:body", {"tt": xml_ns.TTML}) self.assertEqual(body_element.get("begin"), "150f") diff --git a/src/test/python/test_isd_multithreading.py b/src/test/python/test_isd_multithreading.py index 6e53cb74..84692ee6 100644 --- a/src/test/python/test_isd_multithreading.py +++ b/src/test/python/test_isd_multithreading.py @@ -39,9 +39,10 @@ def test_large_document(self): regions = [] - DOC_SIZE = 101 + # size of the document in number of p elements + doc_size = 101 - for i in range(DOC_SIZE): + for i in range(doc_size): r = model.Region(f"{i}", doc) r.set_style(styles.StyleProperties.ShowBackground, styles.ShowBackgroundType.whenActive) doc.put_region(r) @@ -53,7 +54,7 @@ def test_large_document(self): div = model.Div(doc) body.push_child(div) - for i in range(DOC_SIZE): + for i in range(doc_size): p = model.P(doc) p.set_begin(i) p.set_end(i + 1) diff --git a/src/test/python/test_progress_logging.py b/src/test/python/test_progress_logging.py index cc086c24..14afe93b 100644 --- a/src/test/python/test_progress_logging.py +++ b/src/test/python/test_progress_logging.py @@ -31,6 +31,8 @@ LOGGER = logging.getLogger("ttconv") +# pylint: disable=R0201,C0115,C0116 + class IMSCAppLoggingProgressBarTest(unittest.TestCase): def test_logging_info(self):