Skip to content

Commit

Permalink
CLN: Lint validation.py and formats/__init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
NickleDave committed Mar 28, 2023
1 parent 702a1c4 commit 7080693
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
6 changes: 1 addition & 5 deletions src/crowsetta/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
FORMATS[attr.name] = attr


__all__ = [
'bbox',
'FORMATS',
'seq'
]
__all__ = ["bbox", "FORMATS", "seq"]


def by_name(name: str) -> Type:
Expand Down
8 changes: 2 additions & 6 deletions src/crowsetta/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ def validate_ext(file: PathLike, extension: Union[str, tuple]) -> None:
raise TypeError(f"Extension must be str or tuple but type was {type(extension)}")

if not (isinstance(file, str) or isinstance(file, PurePath)):
raise TypeError(
f"File must be a str or a pathlib.Path, but type of file was {type(file)}.\n" f"File: {file}"
)
raise TypeError(f"File must be a str or a pathlib.Path, but type of file was {type(file)}.\n" f"File: {file}")

# we need to use `endswith` instead of
# e.g. comparing with `pathlib.Path.suffix`
# because suffix won't work for "multi-part" extensions like '.not.mat'
if not any([str(file).endswith(ext) for ext in extension]):
raise ValueError(
f"Invalid extension for file: {file}.\n" f"Valid extension(s): '{extension}'"
)
raise ValueError(f"Invalid extension for file: {file}.\n" f"Valid extension(s): '{extension}'")

0 comments on commit 7080693

Please sign in to comment.