Method: pylint.checkers.misc.EncodingChecker._check_encoding
Calls: 41327, Exceptions: 0, Paths: 1Back
Path 1: 41327 calls (1.0)
1 (993) 2 (978) 3 (967) 4 (942) 5 (910) 6 (830) 7 (784) 8 (750) 9 (737) 10 (676)
bytes (41327)
'utf-8' (41317) 'iso-8859-1' (9) 'utf' (1)
'\n' (11233) '\r\n' (668) ' pass\n' (654) ' pass\n' (408) ' """\n' (373) '"""\n' (274) ' def __init__(self):\n' (169) ' pass\r\...
1def _check_encoding(
2 self, lineno: int, line: bytes, file_encoding: str
3 ) -> str | None:
4 try:
5 return line.decode(file_encoding)
6 except UnicodeDecodeError:
7 pass
8 except LookupError:
9 if (
10 line.startswith(b"#")
11 and "coding" in str(line)
12 and file_encoding in str(line)
13 ):
14 msg = f"Cannot decode using encoding '{file_encoding}', bad encoding"
15 self.add_message("syntax-error", line=lineno, args=msg)
16 return None