Skip to content

Commit

Permalink
Improve linting reporting and conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
palemieux authored Dec 22, 2020
1 parent a9849ea commit a19473d
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 26 deletions.
11 changes: 6 additions & 5 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/python/ttconv/filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class Filter:

def process(self, isd: ISD):
"""Process the specified ISD and returns it."""
pass
raise NotImplementedError
9 changes: 7 additions & 2 deletions src/main/python/ttconv/imsc/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/python/ttconv/imsc/style_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def model_prop(cls):

@property
@classmethod
def ns(cls):
def ns(cls): # pylint: disable=invalid-name
raise NotImplementedError

@property
Expand Down
1 change: 0 additions & 1 deletion src/main/python/ttconv/imsc/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
'''IMSC writer'''

import logging
from fractions import Fraction
import numbers
import typing
import xml.etree.ElementTree as et
Expand Down
2 changes: 1 addition & 1 deletion src/main/python/ttconv/isd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/main/python/ttconv/tt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 10 additions & 11 deletions src/test/python/test_imsc_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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),
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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(
Expand Down Expand Up @@ -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")

Expand Down
7 changes: 4 additions & 3 deletions src/test/python/test_isd_multithreading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/test/python/test_progress_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

LOGGER = logging.getLogger("ttconv")

# pylint: disable=R0201,C0115,C0116

class IMSCAppLoggingProgressBarTest(unittest.TestCase):

def test_logging_info(self):
Expand Down

0 comments on commit a19473d

Please sign in to comment.