Skip to content

Commit

Permalink
Refactor code using encodings (codespell-project#3172)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos authored Oct 23, 2023
1 parent a7b5dd2 commit be55dfa
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
# Pass all misspellings through this translation table to generate
# alternative misspellings and fixes.
alt_chars = (("'", "’"),)
encodings = ("utf-8", "iso-8859-1")
USAGE = """
\t%prog [OPTIONS] [file1 file2 ... fileN]
"""
Expand Down Expand Up @@ -249,7 +248,7 @@ def open_with_chardet(self, filename: str) -> Tuple[List[str], str]:
def open_with_internal(self, filename: str) -> Tuple[List[str], str]:
encoding = None
first_try = True
for encoding in encodings:
for encoding in ("utf-8", "iso-8859-1"):
if first_try:
first_try = False
elif not self.quiet_level & QuietLevels.ENCODING:
Expand Down Expand Up @@ -834,10 +833,10 @@ def parse_file(
bad_count = 0
lines = None
changed = False
encoding = encodings[0] # if not defined, use UTF-8

if filename == "-":
f = sys.stdin
encoding = "utf-8"
lines = f.readlines()
else:
if options.check_filenames:
Expand Down

0 comments on commit be55dfa

Please sign in to comment.