Skip to content

Commit

Permalink
Merge branch 'master' into re-using
Browse files Browse the repository at this point in the history
  • Loading branch information
korverdev authored Jun 4, 2024
2 parents 26c0c5b + 3760e61 commit 7c51d80
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ repos:
- -d
- "{extends: relaxed, rules: {line-length: {max: 90}}}"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
rev: v0.4.7
hooks:
- id: ruff
- id: ruff-format
Expand Down
60 changes: 26 additions & 34 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,12 @@ def _script_main() -> int:
return main(*sys.argv[1:])


def _usage_error(parser: argparse.ArgumentParser, message: str) -> int:
parser.print_usage()
print(message, file=sys.stderr)
return EX_USAGE


def main(*args: str) -> int:
"""Contains flow control"""
try:
Expand All @@ -1081,30 +1087,27 @@ def main(*args: str) -> int:
print(f" {ifile}: {cfg_file}")

if options.regex and options.write_changes:
print(
return _usage_error(
parser,
"ERROR: --write-changes cannot be used together with --regex",
file=sys.stderr,
)
parser.print_help()
return EX_USAGE
word_regex = options.regex or word_regex_def
try:
word_regex = re.compile(word_regex)
except re.error as e:
print(f'ERROR: invalid --regex "{word_regex}" ({e})', file=sys.stderr)
parser.print_help()
return EX_USAGE
return _usage_error(
parser,
f'ERROR: invalid --regex "{word_regex}" ({e})',
)

if options.ignore_regex:
try:
ignore_word_regex = re.compile(options.ignore_regex)
except re.error as e:
print(
return _usage_error(
parser,
f'ERROR: invalid --ignore-regex "{options.ignore_regex}" ({e})',
file=sys.stderr,
)
parser.print_help()
return EX_USAGE
else:
ignore_word_regex = None

Expand All @@ -1117,24 +1120,20 @@ def main(*args: str) -> int:
)
for ignore_words_file in ignore_words_files:
if not os.path.isfile(ignore_words_file):
print(
return _usage_error(
parser,
f"ERROR: cannot find ignore-words file: {ignore_words_file}",
file=sys.stderr,
)
parser.print_help()
return EX_USAGE
build_ignore_words(ignore_words_file, ignore_words, ignore_words_cased)

uri_regex = options.uri_regex or uri_regex_def
try:
uri_regex = re.compile(uri_regex)
except re.error as e:
print(
return _usage_error(
parser,
f'ERROR: invalid --uri-regex "{uri_regex}" ({e})',
file=sys.stderr,
)
parser.print_help()
return EX_USAGE

uri_ignore_words = set(
itertools.chain(*parse_ignore_words_option(options.uri_ignore_words_list))
Expand All @@ -1155,20 +1154,16 @@ def main(*args: str) -> int:
)
break
else:
print(
return _usage_error(
parser,
f"ERROR: Unknown builtin dictionary: {u}",
file=sys.stderr,
)
parser.print_help()
return EX_USAGE
else:
if not os.path.isfile(dictionary):
print(
return _usage_error(
parser,
f"ERROR: cannot find dictionary file: {dictionary}",
file=sys.stderr,
)
parser.print_help()
return EX_USAGE
use_dictionaries.append(dictionary)
misspellings: Dict[str, Misspelling] = {}
for dictionary in use_dictionaries:
Expand All @@ -1182,13 +1177,11 @@ def main(*args: str) -> int:
context = None
if options.context is not None:
if (options.before_context is not None) or (options.after_context is not None):
print(
return _usage_error(
parser,
"ERROR: --context/-C cannot be used together with "
"--context-before/-B or --context-after/-A",
file=sys.stderr,
)
parser.print_help()
return EX_USAGE
context_both = max(0, options.context)
context = (context_both, context_both)
elif (options.before_context is not None) or (options.after_context is not None):
Expand All @@ -1214,12 +1207,11 @@ def main(*args: str) -> int:
try:
glob_match.match("/random/path") # does not need a real path
except re.error:
print(
return _usage_error(
parser,
"ERROR: --skip/-S has been fed an invalid glob, "
"try escaping special characters",
file=sys.stderr,
)
return EX_USAGE

bad_count = 0
for filename in sorted(options.files):
Expand Down
17 changes: 12 additions & 5 deletions codespell_lib/data/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21468,7 +21468,7 @@ driects->directs
drity->dirty
drived->derived, drove, driven,
driveing->driving
drivin->driving, drive-in,
drivin->driving, driven, drive-in,
drivr->driver
drnik->drink
drob->drop
Expand Down Expand Up @@ -23140,6 +23140,7 @@ equilvalents->equivalents
equiped->equipped
equipmentd->equipment
equipments->equipment
equipmnet->equipment
equippin->equipping
equippment->equipment
equiptment->equipment
Expand Down Expand Up @@ -24331,10 +24332,13 @@ exercieses->exercises
exerciesing->exercising
exerciess->exercises
exercisin->exercising
exercize->exercise
exercized->exercised
exercizes->exercises
exercizing->exercising
exercizable->exercisable
exercize->exercise, exorcize,
exercized->exercised, exorcized,
exercizer->exerciser, exorcist,
exercizers->exercisers, exorcists,
exercizes->exercises, exorcizes,
exercizing->exercising, exorcizing,
exerience->experience
exerienced->experienced
exeriences->experiences
Expand Down Expand Up @@ -24550,6 +24554,8 @@ exntry->entry
exolicit->explicit
exolicitly->explicitly
exonorate->exonerate
exorcizer->exorcist
exorcizers->exorcists
exort->export, extort, exert, exhort,
exorted->exported, extorted, exerted, exhorted,
exorting->exporting, extorting, exerting, exhorting,
Expand Down Expand Up @@ -54603,6 +54609,7 @@ surprisin->surprising
surprisinlgy->surprisingly
surprize->surprise
surprized->surprised
surprizes->surprises
surprizing->surprising
surprizingly->surprisingly
surregat->surrogate
Expand Down
Loading

0 comments on commit 7c51d80

Please sign in to comment.