1414import types
1515
1616# 3rd party
17+ from typing import no_type_check
18+
1719import pytest
18- from pytest_regressions .file_regression import FileRegressionFixture
20+ from pytest_regressions .file_regression import FileRegressionFixture # type: ignore
1921
2022# this package
2123from domdf_python_tools .pretty_print import FancyPrinter , simple_repr
@@ -140,6 +142,7 @@ def __hash__(self):
140142
141143class TestFancyPrinter :
142144
145+ @no_type_check
143146 def test_init (self ):
144147 FancyPrinter ()
145148 FancyPrinter (indent = 4 , width = 40 , depth = 5 , stream = io .StringIO (), compact = True )
@@ -182,6 +185,7 @@ def test_basic(self, safe):
182185 assert not pp .isrecursive (safe ), f"expected not isrecursive for { safe !r} "
183186 assert pp .isreadable (safe ), f"expected isreadable for { safe !r} "
184187
188+ @no_type_check
185189 def test_knotted (self ):
186190 a = list (range (100 ))
187191 b = list (range (200 ))
@@ -278,6 +282,7 @@ def test_knotted(self):
278282 # self.assertEqual(FancyPrinter().pformat(cont), expected)
279283 # self.assertEqual(FancyPrinter(width=1, indent=0).pformat(cont), expected)
280284
285+ @no_type_check
281286 def test_basic_line_wrap (self ):
282287 # verify basic line-wrapping operation
283288 o = {
@@ -449,7 +454,7 @@ def test_sorted_dict(self):
449454 (): {}}) == r"{5: [[]], 'xy\tab\n': (3,), (): {}}"
450455
451456 def test_ordered_dict (self , file_regression : FileRegressionFixture ):
452- d = collections .OrderedDict ()
457+ d : collections . OrderedDict = collections .OrderedDict ()
453458 assert FancyPrinter (width = 1 ).pformat (d ) == 'OrderedDict()'
454459 d = collections .OrderedDict ([])
455460 assert FancyPrinter (width = 1 ).pformat (d ) == 'OrderedDict()'
@@ -564,7 +569,7 @@ def test_sort_unorderable_values(self):
564569 assert FancyPrinter ().pformat ({Unorderable : 0 , 1 : 0 }) == '{1: 0, ' + repr (Unorderable ) + ': 0}'
565570
566571 # Issue 14998: TypeError on tuples with NoneTypes as dict keys.
567- keys = [(1 , ), (None , )]
572+ keys = [(1 , ), (None , )] # type: ignore
568573 assert FancyPrinter ().pformat (dict .fromkeys (keys , 0 )) == '{%r: 0, %r: 0}' % tuple (sorted (keys , key = id ))
569574
570575 def test_sort_orderable_and_unorderable_values (self ):
@@ -694,7 +699,7 @@ def test_compact_width(self):
694699 number = 10
695700 o = [0 ] * number
696701 for i in range (levels - 1 ):
697- o = [o ]
702+ o = [o ] # type: ignore
698703 for w in range (levels * 2 + 1 , levels + 3 * number - 1 ):
699704 lines = FancyPrinter (width = w , compact = True ).pformat (o , ).splitlines ()
700705 maxwidth = max (map (len , lines ))
@@ -811,20 +816,20 @@ def test_bytearray_wrap(self, value, width, file_regression: FileRegressionFixtu
811816 self .check_file_regression (FancyPrinter (width = width ).pformat (value ), file_regression )
812817
813818 def test_default_dict (self , file_regression : FileRegressionFixture ):
814- d = collections .defaultdict (int )
819+ d : collections . defaultdict = collections .defaultdict (int )
815820 assert FancyPrinter (width = 1 ).pformat (d ) == "defaultdict(<class 'int'>, {})"
816821 words = 'the quick brown fox jumped over a lazy dog' .split ()
817822 d = collections .defaultdict (int , zip (words , itertools .count ()))
818823 self .check_file_regression (FancyPrinter ().pformat (d ), file_regression )
819824
820825 def test_counter (self , file_regression : FileRegressionFixture ):
821- d = collections .Counter ()
826+ d : collections . Counter = collections .Counter ()
822827 assert FancyPrinter (width = 1 ).pformat (d ) == "Counter()"
823828 d = collections .Counter ('senselessness' )
824829 self .check_file_regression (FancyPrinter (width = 40 ).pformat (d ), file_regression )
825830
826831 def test_chainmap (self , file_regression : FileRegressionFixture ):
827- d = collections .ChainMap ()
832+ d : collections . ChainMap = collections .ChainMap ()
828833 assert FancyPrinter (width = 1 ).pformat (d ) == "ChainMap({})"
829834 words = 'the quick brown fox jumped over a lazy dog' .split ()
830835 items = list (zip (words , itertools .count ()))
@@ -838,7 +843,7 @@ def test_chainmap_nested(self, file_regression: FileRegressionFixture):
838843 self .check_file_regression (FancyPrinter ().pformat (d ), file_regression )
839844
840845 def test_deque (self ):
841- d = collections .deque ()
846+ d : collections . deque = collections .deque ()
842847 assert FancyPrinter (width = 1 ).pformat (d ) == "deque([])"
843848 d = collections .deque (maxlen = 7 )
844849 assert FancyPrinter (width = 1 ).pformat (d ) == "deque([], maxlen=7)"
@@ -873,14 +878,14 @@ def check_file_regression(self, data, file_regression: FileRegressionFixture):
873878 file_regression .check (data , extension = ".txt" , encoding = "UTF-8" )
874879
875880 def test_user_dict (self , file_regression : FileRegressionFixture ):
876- d = collections .UserDict ()
881+ d : collections . UserDict = collections .UserDict ()
877882 assert FancyPrinter (width = 1 ).pformat (d ) == "{}"
878883 words = 'the quick brown fox jumped over a lazy dog' .split ()
879- d = collections .UserDict (zip (words , itertools .count ()))
884+ d = collections .UserDict (zip (words , itertools .count ())) # type: ignore
880885 self .check_file_regression (FancyPrinter ().pformat (d ), file_regression )
881886
882887 def test_user_list (self , file_regression : FileRegressionFixture ):
883- d = collections .UserList ()
888+ d : collections . UserList = collections .UserList ()
884889 assert FancyPrinter (width = 1 ).pformat (d ) == "[]"
885890 words = 'the quick brown fox jumped over a lazy dog' .split ()
886891 d = collections .UserList (zip (words , itertools .count ()))
0 commit comments