lint: Migrate typing.Text check to semgrep.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-11-16 17:39:23 -08:00
committed by Anders Kaseorg
parent e5779c1ca0
commit d0d8c358b3
5 changed files with 13 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
import re
from typing import List, Text
from typing import List
from gitlint.git import GitCommit
from gitlint.options import StrOption
@@ -85,7 +85,7 @@ imperative_forms = [
imperative_forms.sort()
def head_binary_search(key: Text, words: List[str]) -> str:
def head_binary_search(key: str, words: List[str]) -> str:
""" Find the imperative mood version of `word` by looking at the first
3 characters. """
@@ -124,7 +124,7 @@ class ImperativeMood(LineRule):
error_msg = ('The first word in commit title should be in imperative mood '
'("{word}" -> "{imperative}"): "{title}"')
def validate(self, line: Text, commit: GitCommit) -> List[RuleViolation]:
def validate(self, line: str, commit: GitCommit) -> List[RuleViolation]:
violations = []
# Ignore the section tag (ie `<section tag>: <message body>.`)
@@ -152,7 +152,7 @@ class TitleMatchRegexAllowException(LineRule):
target = CommitMessageTitle
options_spec = [StrOption('regex', ".*", "Regex the title should match")]
def validate(self, title: Text, commit: GitCommit) -> List[RuleViolation]:
def validate(self, title: str, commit: GitCommit) -> List[RuleViolation]:
regex = self.options['regex'].value
pattern = re.compile(regex, re.UNICODE)