| Total Complexity | 3 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| 1 | import autopep8 |
||
| 7 | class PEP8Bear(CorrectionBasedBear): |
||
| 8 | RESULT_MESSAGE = "The code does not comply to PEP8." |
||
| 9 | |||
| 10 | @staticmethod |
||
| 11 | def run_autopep(file, pep_ignore, pep_select): |
||
| 12 | new_file = autopep8.fix_code(''.join(file), |
||
| 13 | options={'ignore': pep_ignore, |
||
| 14 | 'select': pep_select}) |
||
| 15 | |||
| 16 | return new_file.splitlines(True), [] |
||
| 17 | |||
| 18 | GET_REPLACEMENT = run_autopep |
||
| 19 | |||
| 20 | def run(self, |
||
| 21 | filename, |
||
| 22 | file, |
||
| 23 | pep_ignore: typed_list(str)=(), |
||
| 24 | pep_select: typed_list(str)=()): |
||
| 25 | """ |
||
| 26 | Detects and fixes PEP8 incompliant code. This bear will not change |
||
| 27 | functionality of the code in any way. |
||
| 28 | |||
| 29 | :param pep_ignore: A list of errors/warnings to ignore. |
||
| 30 | :param pep_select: A list of errors/warnings to exclusively apply. |
||
| 31 | """ |
||
| 32 | for result in self.retrieve_results(filename, |
||
| 33 | file, |
||
| 34 | pep_ignore=pep_ignore, |
||
| 35 | pep_select=pep_select): |
||
| 36 | yield result |
||
| 37 |