Last active
March 22, 2021 21:49
-
-
Save asfaltboy/26a0e5a2372f2a3316ae874fc3494e62 to your computer and use it in GitHub Desktop.
pyright: Callable not a callable bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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