@@ -95,29 +95,44 @@ def test_link_loader_tb01(self):
9595class TestMetaProperties (TestUnitBase ):
9696
9797 def test_style_guide (self ):
98- from flake8 .api import legacy as flake8
99- from flake8 .main .options import JobsArgument
100- logging .StreamHandler .terminator = '\n '
98+ import pycodestyle
99+
100+ class RespectFlake8NoQA (pycodestyle .StandardReport ):
101+ def error (self , lno , offset , text , check ):
102+ for line in self .lines [:5 ]:
103+ _ , _ , noqa = line .partition ('flake8:' )
104+ if noqa .lstrip ().startswith ('noqa' ):
105+ return
106+ line : str = self .lines [lno - 1 ]
107+ _ , _ , comment = line .partition ('#' )
108+ if comment .lower ().strip ().startswith ('noqa' ):
109+ return
110+ super ().error (lno , offset , text , check )
111+
112+ stylez = pycodestyle .StyleGuide (
113+ ignore = [
114+ 'E128' , # A continuation line is under-indented for a visual indentation.
115+ 'E203' , # Colons should not have any space before them.
116+ 'E701' , # Multiple statements on one line (colon)
117+ 'E704' , # Multiple statements on one line (def)
118+ 'W503' , # Line break occurred before a binary operator
119+ 'F722' , # syntax error in forward annotation
120+ 'F821' , # undefined name
121+ 'E261' , # at least two spaces before inline comment
122+ ],
123+ max_line_length = 140 ,
124+ reporter = RespectFlake8NoQA ,
125+ )
126+
101127 root = os .path .abspath (inspect .stack ()[0 ][1 ])
102128 for _ in range (3 ):
103129 root = os .path .dirname (root )
104130
105- rules = flake8 .get_style_guide (ignore = [
106- 'E128' , # A continuation line is under-indented for a visual indentation.
107- 'E203' , # Colons should not have any space before them.
108- 'E701' , # Multiple statements on one line (colon)
109- 'E704' , # Multiple statements on one line (def)
110- 'W503' , # Line break occurred before a binary operator
111- 'F722' , # syntax error in forward annotation
112- 'F821' , # undefined name
113- 'E261' , # at least two spaces before inline comment
114- ], max_line_length = 140 , jobs = JobsArgument ('1' ))
115- report = rules .check_files (path for path in glob (
131+ python_files = [path for path in glob (
116132 os .path .join (root , 'refinery' , '**' , '*.py' ), recursive = True )
117- if 'thirdparty' not in path
118- )
119- self .assertEqual (report .total_errors , 0 ,
120- msg = 'Flake8 formatting errors were found.' )
133+ if 'thirdparty' not in path ]
134+ report = stylez .check_files (python_files )
135+ self .assertEqual (report .total_errors , 0 , 'PEP8 formatting errors were found.' )
121136
122137 def test_no_legacy_interfaces (self ):
123138 for unit in get_all_entry_points ():
0 commit comments