mirror of
https://github.com/huggingface/transformers.git
synced 2025-08-02 11:11:05 +06:00
feat: filter try/except when looking at custom code (#21914)
* feat: filter try/except * Update src/transformers/dynamic_module_utils.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> --------- Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
This commit is contained in:
parent
02a77fa04c
commit
c5a1ff9ef0
@ -116,6 +116,9 @@ def check_imports(filename):
|
||||
with open(filename, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
# filter out try/except block so in custom code we can have try/except imports
|
||||
content = re.sub(r"\s*try\s*:\s*.*?\s*except\s*:", "", content, flags=re.MULTILINE)
|
||||
|
||||
# Imports of the form `import xxx`
|
||||
imports = re.findall(r"^\s*import\s+(\S+)\s*$", content, flags=re.MULTILINE)
|
||||
# Imports of the form `from xxx import yyy`
|
||||
|
Loading…
Reference in New Issue
Block a user