diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index f2c6c44cb6..baf77997af 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -228,7 +228,6 @@ def open_with_chardet(self, filename: str) -> Tuple[List[str], str]: break self.encdetector.close() encoding = self.encdetector.result["encoding"] - assert encoding is not None # noqa: S101 try: f = open(filename, encoding=encoding, newline="") @@ -245,7 +244,7 @@ def open_with_chardet(self, filename: str) -> Tuple[List[str], str]: lines = f.readlines() f.close() - return lines, encoding + return lines, f.encoding def open_with_internal(self, filename: str) -> Tuple[List[str], str]: encoding = None