Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle multiline options #3400

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,11 @@ class QuietLevels:


class GlobMatch:
def __init__(self, pattern: Optional[List[str]]) -> None:
self.pattern_list: Optional[List[str]] = pattern
def __init__(self, pattern: List[str]) -> None:
self.pattern_list: List[str] = pattern

def match(self, filename: str) -> bool:
return (
any(fnmatch.fnmatch(filename, p) for p in self.pattern_list)
if self.pattern_list
else False
)
return any(fnmatch.fnmatch(filename, p) for p in self.pattern_list)


class Misspelling:
Expand Down Expand Up @@ -493,6 +489,7 @@ def parse_options(
"accepts globs as well. E.g.: if you want "
"codespell to skip .eps and .txt files, "
'you\'d give "*.eps,*.txt" to this option.',
default=list(),
DimitriPapadopoulos marked this conversation as resolved.
Show resolved Hide resolved
)

parser.add_argument(
Expand Down Expand Up @@ -1106,19 +1103,20 @@ def parse_file(


def flatten_clean_comma_separated_arguments(
arguments: Optional[List[str]],
) -> Optional[List[str]]:
arguments: List[str],
) -> List[str]:
"""
>>> flatten_clean_comma_separated_arguments(["a, b ,\n c, d,", "e"])
['a', 'b', 'c', 'd', 'e']
>>> flatten_clean_comma_separated_arguments([])
>>> flatten_clean_comma_separated_arguments(None)
[]
"""
return (
[item.strip() for argument in arguments for item in argument.split(",") if item]
if arguments
else None
)
return [
item.strip()
for argument in arguments
for item in argument.split(",")
if item
]


def _script_main() -> int:
Expand Down
Loading