Skip to content

Commit

Permalink
pyeio/core/ext: update
Browse files Browse the repository at this point in the history
  • Loading branch information
harttraveller committed May 19, 2024
1 parent ab99635 commit f36002a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pyeio/core/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ def standardize(extension: str) -> StandardExtension:

def valid(
extension: str,
allowed: set[str],
allowed: str | set[str],
message: Optional[str] = None,
) -> None:
"""Validates expected extension."""
if extension != allowed:
raise Exception # todo add custom
invalid = extension == allowed if isinstance(allowed, str) else extension in allowed
if invalid:
raise exc.InvalidExtensionError(
extension=extension, allowed=allowed, message=message
)

0 comments on commit f36002a

Please sign in to comment.