#[inline]
pub(super) fn bytes_match_keyword(bytes: &[u8], pos: usize, keyword: &[u8]) -> bool {
if pos + keyword.len() > bytes.len() {
return false;
}
&bytes[pos..pos + keyword.len()] == keyword
}
#[inline]
pub(super) fn extract_ascii_ident(bytes: &[u8], start: usize, end: usize) -> String {
if start >= end || end > bytes.len() {
return String::new();
}
let slice = &bytes[start..end];
if slice.iter().all(|b| b.is_ascii()) {
String::from_utf8_lossy(slice).into_owned()
} else {
String::new()
}
}
pub(super) const SKIP_BUILTINS: &[&str] = &[
"None",
"True",
"False",
"str",
"int",
"float",
"bool",
"bytes",
"list",
"dict",
"set",
"tuple",
"frozenset",
"type",
"object",
"Any",
"Union",
"Optional",
"List",
"Dict",
"Set",
"Tuple",
"Callable",
"Sequence",
"Mapping",
"Iterable",
"Iterator",
"Type",
"self",
"cls",
];
pub(super) const SKIP_TYPE_HINTS: &[&str] = &[
"None",
"True",
"False",
"str",
"int",
"float",
"bool",
"bytes",
"list",
"dict",
"set",
"tuple",
"frozenset",
"type",
"object",
"Any",
"Union",
"Optional",
"List",
"Dict",
"Set",
"Tuple",
"Callable",
"Sequence",
"Mapping",
"Iterable",
"Iterator",
"Generator",
"Coroutine",
"Awaitable",
"AsyncIterator",
"AsyncGenerator",
"Type",
"ClassVar",
"Final",
"Literal",
"TypeVar",
"Generic",
"Protocol",
"Self",
"self",
"cls",
];
pub(super) const PYTHON_KEYWORDS: &[&str] = &[
"if", "else", "elif", "while", "for", "try", "except", "finally", "with", "as", "def", "class",
"return", "yield", "raise", "import", "from", "pass", "break", "continue", "lambda", "and",
"or", "not", "in", "is", "True", "False", "None", "assert", "del", "exec", "print", "global",
"nonlocal", "async", "await",
];
pub(super) const TYPE_FACTORIES: &[&str] = &[
"defaultdict",
"Counter",
"deque",
"OrderedDict",
"ChainMap",
"namedtuple",
"TypedDict",
"NewType",
"cast",
"Depends",
"Security",
"Field",
];