Skip to content

Commit

Permalink
Remove error code validation from config parser
Browse files Browse the repository at this point in the history
  • Loading branch information
scottp-dpaw committed Oct 17, 2022
1 parent cd45107 commit 4fe7aeb
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions mypy/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ def try_split(v: str | Sequence[str], split_regex: str = "[,]") -> list[str]:
return [p.strip() for p in v]


def validate_codes(codes: list[str]) -> list[str]:
invalid_codes = set(codes) - set(error_codes.keys())
if invalid_codes:
raise argparse.ArgumentTypeError(
f"Invalid error code(s): {', '.join(sorted(invalid_codes))}"
)
return codes


def expand_path(path: str) -> str:
"""Expand the user home directory and any environment variables contained within
the provided path.
Expand Down Expand Up @@ -158,8 +149,8 @@ def check_follow_imports(choice: str) -> str:
"plugins": lambda s: [p.strip() for p in s.split(",")],
"always_true": lambda s: [p.strip() for p in s.split(",")],
"always_false": lambda s: [p.strip() for p in s.split(",")],
"disable_error_code": lambda s: validate_codes([p.strip() for p in s.split(",")]),
"enable_error_code": lambda s: validate_codes([p.strip() for p in s.split(",")]),
"disable_error_code": lambda s: [p.strip() for p in s.split(",")],
"enable_error_code": lambda s: [p.strip() for p in s.split(",")],
"package_root": lambda s: [p.strip() for p in s.split(",")],
"cache_dir": expand_path,
"python_executable": expand_path,
Expand All @@ -179,8 +170,8 @@ def check_follow_imports(choice: str) -> str:
"plugins": try_split,
"always_true": try_split,
"always_false": try_split,
"disable_error_code": lambda s: validate_codes(try_split(s)),
"enable_error_code": lambda s: validate_codes(try_split(s)),
"disable_error_code": lambda s: try_split(s),
"enable_error_code": lambda s: try_split(s),
"package_root": try_split,
"exclude": str_or_array_as_list,
}
Expand Down

0 comments on commit 4fe7aeb

Please sign in to comment.