Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions unsloth_zoo/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,8 +806,8 @@ def create_standalone_class(
source = source + full_class

# Remove @auto_docstring
source = re.sub(r"@auto_docstring[\s]{0,}(\([^\)]{1,}\))?", "", source)
source = re.sub(r"@check_model_inputs[\s]{0,}(\([^\)]{1,}\))?", "", source)
source = re.sub(r"@auto_docstring[\s]{0,}(\([^\)]{0,}\))?", "", source)
source = re.sub(r"@check_model_inputs[\s]{0,}(\([^\)]{0,}\))?", "", source)
Comment on lines +809 to +810
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the change is functionally correct, the regular expressions can be simplified for better readability by using common regex quantifiers. [\s]{0,} can be replaced with \s*, and [^\)]{0,} can be replaced with [^\)]*.

Suggested change
source = re.sub(r"@auto_docstring[\s]{0,}(\([^\)]{0,}\))?", "", source)
source = re.sub(r"@check_model_inputs[\s]{0,}(\([^\)]{0,}\))?", "", source)
source = re.sub(r"@auto_docstring\s*(\([^\)]*\))?", "", source)
source = re.sub(r"@check_model_inputs\s*(\([^\)]*\))?", "", source)
# source = source.replace("@auto_docstring", "")

# Fix Gemma 3 ignore_index being not set!
Expand Down