Skip to content

Instantly share code, notes, and snippets.

@asfaltboy
Last active March 22, 2021 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asfaltboy/26a0e5a2372f2a3316ae874fc3494e62 to your computer and use it in GitHub Desktop.
Save asfaltboy/26a0e5a2372f2a3316ae874fc3494e62 to your computer and use it in GitHub Desktop.
pyright: Callable not a callable bug
from typing import Callable, NamedTuple, Tuple
# class RuleDefinition(NamedTuple):
# pattern: str
# path: str
# check: Callable
RuleDefinition = Tuple[str, str, Callable]
def _contains(pattern: str, path: str) -> bool:
return pattern in path
def _starts_with(pattern: str, path: str) -> bool:
return path.startswith(pattern)
def _ends_with(pattern: str, path: str) -> bool:
return path.endswith(pattern)
def check_rule(rule: RuleDefinition) -> str:
pattern, path, check = rule
if check(pattern=pattern, path=path):
return path
return ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment